diff options
| author | 2023-11-17 03:51:04 +0100 | |
|---|---|---|
| committer | 2023-11-17 03:51:04 +0100 | |
| commit | acf3cdcf80da7c3443e202a02d4b626c13e9e8dd (patch) | |
| tree | f9498dfd051d469d9e76c4b47c5704bfc9a79e48 /xs_json.h | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | penes-snac2-acf3cdcf80da7c3443e202a02d4b626c13e9e8dd.tar.gz penes-snac2-acf3cdcf80da7c3443e202a02d4b626c13e9e8dd.tar.xz penes-snac2-acf3cdcf80da7c3443e202a02d4b626c13e9e8dd.zip | |
Backport from xs.
Diffstat (limited to 'xs_json.h')
| -rw-r--r-- | xs_json.h | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -248,24 +248,20 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t) | |||
| 248 | break; | 248 | break; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | if (cp >= 0xd800 && cp <= 0xdfff) { | 251 | if (xs_is_surrogate(cp)) { |
| 252 | /* it's a surrogate pair */ | ||
| 253 | cp = (cp & 0x3ff) << 10; | ||
| 254 | |||
| 255 | /* \u must follow */ | 252 | /* \u must follow */ |
| 256 | if (fgetc(f) != '\\' || fgetc(f) != 'u') { | 253 | if (fgetc(f) != '\\' || fgetc(f) != 'u') { |
| 257 | *t = JS_ERROR; | 254 | *t = JS_ERROR; |
| 258 | break; | 255 | break; |
| 259 | } | 256 | } |
| 260 | 257 | ||
| 261 | unsigned int i; | 258 | unsigned int p2; |
| 262 | if (fscanf(f, "%04x", &i) != 1) { | 259 | if (fscanf(f, "%04x", &p2) != 1) { |
| 263 | *t = JS_ERROR; | 260 | *t = JS_ERROR; |
| 264 | break; | 261 | break; |
| 265 | } | 262 | } |
| 266 | 263 | ||
| 267 | cp |= (i & 0x3ff); | 264 | cp = xs_surrogate_dec(cp, p2); |
| 268 | cp += 0x10000; | ||
| 269 | } | 265 | } |
| 270 | 266 | ||
| 271 | /* replace dangerous control codes with their visual representations */ | 267 | /* replace dangerous control codes with their visual representations */ |