diff options
| author | Kenichi Handa | 2000-08-05 01:45:10 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-08-05 01:45:10 +0000 |
| commit | 82d497fc5cc33264c5be033fcdb836ae59a0b21d (patch) | |
| tree | 4c2e82cedb53b32c48f7242cfd46a52809e29a6b /src | |
| parent | 688351f25d0c4a26adde45006aad357a58388a50 (diff) | |
| download | emacs-82d497fc5cc33264c5be033fcdb836ae59a0b21d.tar.gz emacs-82d497fc5cc33264c5be033fcdb836ae59a0b21d.zip | |
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/syntax.c | 52 |
2 files changed, 40 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8f19cd75888..152940dcac1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2000-08-05 Kenichi Handa <handa@etl.go.jp> | ||
| 2 | |||
| 3 | * syntax.c (skip_chars): Fix handling of multibyte<->unibyte | ||
| 4 | conversion. | ||
| 5 | |||
| 1 | 2000-08-04 Gerd Moellmann <gerd@gnu.org> | 6 | 2000-08-04 Gerd Moellmann <gerd@gnu.org> |
| 2 | 7 | ||
| 3 | * syntax.c (skip_chars): Fix typo in error message. | 8 | * syntax.c (skip_chars): Fix typo in error message. |
diff --git a/src/syntax.c b/src/syntax.c index 3b0289f41ad..9361ba05477 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1348,12 +1348,34 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1348 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 1348 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 1349 | int string_multibyte; | 1349 | int string_multibyte; |
| 1350 | int size_byte; | 1350 | int size_byte; |
| 1351 | unsigned char *str; | ||
| 1352 | int len; | ||
| 1351 | 1353 | ||
| 1352 | CHECK_STRING (string, 0); | 1354 | CHECK_STRING (string, 0); |
| 1353 | char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2); | 1355 | char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2); |
| 1354 | string_multibyte = STRING_MULTIBYTE (string); | 1356 | string_multibyte = STRING_MULTIBYTE (string); |
| 1357 | str = XSTRING (string)->data; | ||
| 1355 | size_byte = STRING_BYTES (XSTRING (string)); | 1358 | size_byte = STRING_BYTES (XSTRING (string)); |
| 1356 | 1359 | ||
| 1360 | /* Adjust the multibyteness of the string to that of the buffer. */ | ||
| 1361 | if (multibyte != string_multibyte) | ||
| 1362 | { | ||
| 1363 | int nbytes; | ||
| 1364 | |||
| 1365 | if (multibyte) | ||
| 1366 | nbytes = count_size_as_multibyte (XSTRING (string)->data, | ||
| 1367 | XSTRING (string)->size); | ||
| 1368 | else | ||
| 1369 | nbytes = XSTRING (string)->size; | ||
| 1370 | if (nbytes != size_byte) | ||
| 1371 | { | ||
| 1372 | str = (unsigned char *) alloca (nbytes); | ||
| 1373 | copy_text (XSTRING (string)->data, str, nbytes, | ||
| 1374 | string_multibyte, multibyte); | ||
| 1375 | size_byte = nbytes; | ||
| 1376 | } | ||
| 1377 | } | ||
| 1378 | |||
| 1357 | if (NILP (lim)) | 1379 | if (NILP (lim)) |
| 1358 | XSETINT (lim, forwardp ? ZV : BEGV); | 1380 | XSETINT (lim, forwardp ? ZV : BEGV); |
| 1359 | else | 1381 | else |
| @@ -1367,12 +1389,12 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1367 | 1389 | ||
| 1368 | bzero (fastmap, sizeof fastmap); | 1390 | bzero (fastmap, sizeof fastmap); |
| 1369 | 1391 | ||
| 1370 | i = 0, i_byte = 0; | 1392 | i_byte = 0; |
| 1371 | 1393 | ||
| 1372 | if (i_byte < size_byte | 1394 | if (i_byte < size_byte |
| 1373 | && XSTRING (string)->data[0] == '^') | 1395 | && XSTRING (string)->data[0] == '^') |
| 1374 | { | 1396 | { |
| 1375 | negate = 1; i++, i_byte++; | 1397 | negate = 1; i_byte++; |
| 1376 | } | 1398 | } |
| 1377 | 1399 | ||
| 1378 | /* Find the characters specified and set their elements of fastmap. | 1400 | /* Find the characters specified and set their elements of fastmap. |
| @@ -1381,16 +1403,10 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1381 | 1403 | ||
| 1382 | while (i_byte < size_byte) | 1404 | while (i_byte < size_byte) |
| 1383 | { | 1405 | { |
| 1384 | int c_leading_code = XSTRING (string)->data[i_byte]; | 1406 | int c_leading_code = str[i_byte]; |
| 1385 | |||
| 1386 | FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); | ||
| 1387 | 1407 | ||
| 1388 | /* Convert multibyteness between what the string has | 1408 | c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte - i_byte, len); |
| 1389 | and what the buffer has. */ | 1409 | i_byte += len; |
| 1390 | if (multibyte) | ||
| 1391 | c = unibyte_char_to_multibyte (c); | ||
| 1392 | else | ||
| 1393 | c &= 0377; | ||
| 1394 | 1410 | ||
| 1395 | if (syntaxp) | 1411 | if (syntaxp) |
| 1396 | fastmap[syntax_spec_code[c & 0377]] = 1; | 1412 | fastmap[syntax_spec_code[c & 0377]] = 1; |
| @@ -1401,23 +1417,25 @@ skip_chars (forwardp, syntaxp, string, lim) | |||
| 1401 | if (i_byte == size_byte) | 1417 | if (i_byte == size_byte) |
| 1402 | break; | 1418 | break; |
| 1403 | 1419 | ||
| 1404 | c_leading_code = XSTRING (string)->data[i_byte]; | 1420 | c_leading_code = str[i_byte]; |
| 1405 | FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); | 1421 | c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); |
| 1422 | i_byte += len; | ||
| 1406 | } | 1423 | } |
| 1407 | if (i_byte < size_byte | 1424 | if (i_byte < size_byte |
| 1408 | && XSTRING (string)->data[i_byte] == '-') | 1425 | && str[i_byte] == '-') |
| 1409 | { | 1426 | { |
| 1410 | unsigned int c2, c2_leading_code; | 1427 | unsigned int c2, c2_leading_code; |
| 1411 | 1428 | ||
| 1412 | /* Skip over the dash. */ | 1429 | /* Skip over the dash. */ |
| 1413 | i++, i_byte++; | 1430 | i_byte++; |
| 1414 | 1431 | ||
| 1415 | if (i_byte == size_byte) | 1432 | if (i_byte == size_byte) |
| 1416 | break; | 1433 | break; |
| 1417 | 1434 | ||
| 1418 | /* Get the end of the range. */ | 1435 | /* Get the end of the range. */ |
| 1419 | c2_leading_code = XSTRING (string)->data[i_byte]; | 1436 | c2_leading_code = str[i_byte]; |
| 1420 | FETCH_STRING_CHAR_ADVANCE (c2, string, i, i_byte); | 1437 | c2 =STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); |
| 1438 | i_byte += len; | ||
| 1421 | 1439 | ||
| 1422 | if (SINGLE_BYTE_CHAR_P (c)) | 1440 | if (SINGLE_BYTE_CHAR_P (c)) |
| 1423 | { | 1441 | { |