diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/coding.c | 11 | ||||
| -rw-r--r-- | src/composite.h | 11 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4e33ccb0c0d..24161dbda1e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -2,6 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | * coding.c (EMIT_ONE_BYTE, EMIT_TWO_BYTES): Use unsigned, not int. | 3 | * coding.c (EMIT_ONE_BYTE, EMIT_TWO_BYTES): Use unsigned, not int. |
| 4 | This avoids several warnings with gcc -Wstrict-overflow. | 4 | This avoids several warnings with gcc -Wstrict-overflow. |
| 5 | (DECODE_COMPOSITION_RULE): If the rule is invalid, goto invalid_code | ||
| 6 | directly, rather than having caller test rule sign. This avoids | ||
| 7 | some unnecessary tests. | ||
| 8 | * composite.h (COMPOSITION_ENCODE_RULE_VALID): New macro. | ||
| 9 | (COMPOSITION_ENCODE_RULE): Arguments now must be valid. This | ||
| 10 | affects only one use, in DECODE_COMPOSITION_RULE, which is changed. | ||
| 5 | 11 | ||
| 6 | * xfont.c (xfont_text_extents): Remove var that was set but not used. | 12 | * xfont.c (xfont_text_extents): Remove var that was set but not used. |
| 7 | (xfont_open): Avoid unnecessary tests. | 13 | (xfont_open): Avoid unnecessary tests. |
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 | } |
diff --git a/src/composite.h b/src/composite.h index ffdb57a571e..cfb5db0dc6a 100644 --- a/src/composite.h +++ b/src/composite.h | |||
| @@ -148,12 +148,15 @@ extern Lisp_Object composition_temp; | |||
| 148 | COMPOSITION_DECODE_REFS (rule_code, gref, nref); \ | 148 | COMPOSITION_DECODE_REFS (rule_code, gref, nref); \ |
| 149 | } while (0) | 149 | } while (0) |
| 150 | 150 | ||
| 151 | /* Nonzero if the global reference point GREF and new reference point NREF are | ||
| 152 | valid. */ | ||
| 153 | #define COMPOSITION_ENCODE_RULE_VALID(gref, nref) \ | ||
| 154 | ((unsigned) (gref) < 12 && (unsigned) (nref) < 12) | ||
| 155 | |||
| 151 | /* Return encoded composition rule for the pair of global reference | 156 | /* Return encoded composition rule for the pair of global reference |
| 152 | point GREF and new reference point NREF. If arguments are invalid, | 157 | point GREF and new reference point NREF. Arguments must be valid. */ |
| 153 | return -1. */ | ||
| 154 | #define COMPOSITION_ENCODE_RULE(gref, nref) \ | 158 | #define COMPOSITION_ENCODE_RULE(gref, nref) \ |
| 155 | ((unsigned) (gref) < 12 && (unsigned) (nref) < 12 \ | 159 | ((gref) * 12 + (nref)) |
| 156 | ? (gref) * 12 + (nref) : -1) | ||
| 157 | 160 | ||
| 158 | /* Data structure that records information about a composition | 161 | /* Data structure that records information about a composition |
| 159 | currently used in some buffers or strings. | 162 | currently used in some buffers or strings. |