comparison src/syntax.c @ 22130:b25abff012fd

(skip_chars): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Mon, 18 May 1998 04:53:37 +0000
parents 09efd6a94b4b
children 1f0dc0251be3
comparison
equal deleted inserted replaced
22129:d76e72401a73 22130:b25abff012fd
1252 int n_char_ranges = 0; 1252 int n_char_ranges = 0;
1253 int negate = 0; 1253 int negate = 0;
1254 register int i, i_byte; 1254 register int i, i_byte;
1255 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1255 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1256 int string_multibyte = STRING_MULTIBYTE (string); 1256 int string_multibyte = STRING_MULTIBYTE (string);
1257 int size_byte = STRING_BYTES (XSTRING (string));
1257 1258
1258 CHECK_STRING (string, 0); 1259 CHECK_STRING (string, 0);
1259 char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2); 1260 char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2);
1260 1261
1261 if (NILP (lim)) 1262 if (NILP (lim))
1271 1272
1272 bzero (fastmap, sizeof fastmap); 1273 bzero (fastmap, sizeof fastmap);
1273 1274
1274 i = 0, i_byte = 0; 1275 i = 0, i_byte = 0;
1275 1276
1276 if (i < XSTRING (string)->size 1277 if (i_byte < size_byte
1277 && XSTRING (string)->data[0] == '^') 1278 && XSTRING (string)->data[0] == '^')
1278 { 1279 {
1279 negate = 1; i++, i_byte++; 1280 negate = 1; i++, i_byte++;
1280 } 1281 }
1281 1282
1282 /* Find the characters specified and set their elements of fastmap. 1283 /* Find the characters specified and set their elements of fastmap.
1283 If syntaxp, each character counts as itself. 1284 If syntaxp, each character counts as itself.
1284 Otherwise, handle backslashes and ranges specially. */ 1285 Otherwise, handle backslashes and ranges specially. */
1285 1286
1286 while (i < XSTRING (string)->size) 1287 while (i_byte < size_byte)
1287 { 1288 {
1288 int c_leading_code; 1289 int c_leading_code;
1289 1290
1290 if (string_multibyte) 1291 if (string_multibyte)
1291 { 1292 {
1292 c_leading_code = XSTRING (string)->data[i_byte]; 1293 c_leading_code = XSTRING (string)->data[i_byte];
1293 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); 1294 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
1294 } 1295 }
1295 else 1296 else
1296 c = c_leading_code = XSTRING (string)->data[i++]; 1297 c = c_leading_code = XSTRING (string)->data[i_byte++];
1297 1298
1298 /* Convert multibyteness between what the string has 1299 /* Convert multibyteness between what the string has
1299 and what the buffer has. */ 1300 and what the buffer has. */
1300 if (multibyte) 1301 if (multibyte)
1301 c = unibyte_char_to_multibyte (c); 1302 c = unibyte_char_to_multibyte (c);
1306 fastmap[syntax_spec_code[c & 0377]] = 1; 1307 fastmap[syntax_spec_code[c & 0377]] = 1;
1307 else 1308 else
1308 { 1309 {
1309 if (c == '\\') 1310 if (c == '\\')
1310 { 1311 {
1311 if (i == XSTRING (string)->size) 1312 if (i_byte == size_byte)
1312 break; 1313 break;
1313 1314
1314 if (string_multibyte) 1315 if (string_multibyte)
1315 { 1316 {
1316 c_leading_code = XSTRING (string)->data[i]; 1317 c_leading_code = XSTRING (string)->data[i_byte];
1317 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte); 1318 FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
1318 } 1319 }
1319 else 1320 else
1320 c = c_leading_code = XSTRING (string)->data[i++]; 1321 c = c_leading_code = XSTRING (string)->data[i_byte++];
1321 } 1322 }
1322 if (i < XSTRING (string)->size 1323 if (i_byte < size_byte
1323 && XSTRING (string)->data[i_byte] == '-') 1324 && XSTRING (string)->data[i_byte] == '-')
1324 { 1325 {
1325 unsigned int c2, c2_leading_code; 1326 unsigned int c2, c2_leading_code;
1326 1327
1327 /* Skip over the dash. */ 1328 /* Skip over the dash. */
1328 i++, i_byte++; 1329 i++, i_byte++;
1329 1330
1330 if (i == XSTRING (string)->size) 1331 if (i_byte == size_byte)
1331 break; 1332 break;
1332 1333
1333 /* Get the end of the range. */ 1334 /* Get the end of the range. */
1334 if (string_multibyte) 1335 if (string_multibyte)
1335 { 1336 {
1336 c2_leading_code = XSTRING (string)->data[i_byte]; 1337 c2_leading_code = XSTRING (string)->data[i_byte];
1337 FETCH_STRING_CHAR_ADVANCE (c2, string, i, i_byte); 1338 FETCH_STRING_CHAR_ADVANCE (c2, string, i, i_byte);
1338 } 1339 }
1339 else 1340 else
1340 c2 = XSTRING (string)->data[i++]; 1341 c2 = XSTRING (string)->data[i_byte++];
1341 1342
1342 if (SINGLE_BYTE_CHAR_P (c)) 1343 if (SINGLE_BYTE_CHAR_P (c))
1343 { 1344 {
1344 if (! SINGLE_BYTE_CHAR_P (c2)) 1345 if (! SINGLE_BYTE_CHAR_P (c2))
1345 error ("Invalid charcter range: %s", 1346 error ("Invalid charcter range: %s",