aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2011-04-04 23:41:53 -0700
committerPaul Eggert2011-04-04 23:41:53 -0700
commitd5efd1d1b54595db795d6fddb32404cc74923d77 (patch)
tree23ea4fd384e74bebe571c176e13ecec3f07fa9d3 /src/coding.c
parentb25d760e185c85e190402eddd0d756ddc014a58c (diff)
downloademacs-d5efd1d1b54595db795d6fddb32404cc74923d77.tar.gz
emacs-d5efd1d1b54595db795d6fddb32404cc74923d77.zip
* coding.c (DECODE_COMPOSITION_RULE): If the rule is invalid, goto invalid_code
directly, rather than having caller test rule sign. This avoids some unnecessary tests. * composite.h (COMPOSITION_ENCODE_RULE_VALID): New macro. (COMPOSITION_ENCODE_RULE): Arguments now must be valid. This affects only one use, in DECODE_COMPOSITION_RULE, which is changed.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/coding.c b/src/coding.c
index 6e5d0655258..555c29cbdf3 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -3254,13 +3254,13 @@ detect_coding_iso_2022 (struct coding_system *coding,
3254 3254
3255/* Decode a composition rule C1 and maybe one more byte from the 3255/* Decode a composition rule C1 and maybe one more byte from the
3256 source, and set RULE to the encoded composition rule. If the rule 3256 source, and set RULE to the encoded composition rule. If the rule
3257 is invalid, set RULE to some negative value. */ 3257 is invalid, goto invalid_code. */
3258 3258
3259#define DECODE_COMPOSITION_RULE(rule) \ 3259#define DECODE_COMPOSITION_RULE(rule) \
3260 do { \ 3260 do { \
3261 rule = c1 - 32; \ 3261 rule = c1 - 32; \
3262 if (rule < 0) \ 3262 if (rule < 0) \
3263 break; \ 3263 goto invalid_code; \
3264 if (rule < 81) /* old format (before ver.21) */ \ 3264 if (rule < 81) /* old format (before ver.21) */ \
3265 { \ 3265 { \
3266 int gref = (rule) / 9; \ 3266 int gref = (rule) / 9; \
@@ -3274,9 +3274,10 @@ detect_coding_iso_2022 (struct coding_system *coding,
3274 int b; \ 3274 int b; \
3275 \ 3275 \
3276 ONE_MORE_BYTE (b); \ 3276 ONE_MORE_BYTE (b); \
3277 if (! COMPOSITION_ENCODE_RULE_VALID (rule - 81, b - 32)) \
3278 goto invalid_code; \
3277 rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ 3279 rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \
3278 if (rule >= 0) \ 3280 rule += 0x100; /* Distinguish it from the old format. */ \
3279 rule += 0x100; /* to destinguish it from the old format */ \
3280 } \ 3281 } \
3281 } while (0) 3282 } while (0)
3282 3283
@@ -3543,8 +3544,6 @@ decode_coding_iso_2022 (struct coding_system *coding)
3543 int rule; 3544 int rule;
3544 3545
3545 DECODE_COMPOSITION_RULE (rule); 3546 DECODE_COMPOSITION_RULE (rule);
3546 if (rule < 0)
3547 goto invalid_code;
3548 STORE_COMPOSITION_RULE (rule); 3547 STORE_COMPOSITION_RULE (rule);
3549 continue; 3548 continue;
3550 } 3549 }