comparison src/fns.c @ 4796:c45fdd4e1858

Don't args-out-of-range in compare-strings.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 02 Jan 2010 01:02:43 +0900
parents 80cd90837ac5
children a5eca70cf401
comparison
equal deleted inserted replaced
4795:084056f46755 4796:c45fdd4e1858
313 313
314 DEFUN ("compare-strings", Fcompare_strings, 6, 7, 0, /* 314 DEFUN ("compare-strings", Fcompare_strings, 6, 7, 0, /*
315 Compare the contents of two strings, maybe ignoring case. 315 Compare the contents of two strings, maybe ignoring case.
316 In string STR1, skip the first START1 characters and stop at END1. 316 In string STR1, skip the first START1 characters and stop at END1.
317 In string STR2, skip the first START2 characters and stop at END2. 317 In string STR2, skip the first START2 characters and stop at END2.
318 END1 and END2 default to the full lengths of the respective strings. 318 END1 and END2 default to the full lengths of the respective strings,
319 319 and arguments that are outside the string (negative start or ENDi
320 Case is significant in this comparison if IGNORE-CASE is nil. 320 greater than length) are coerced to 0 or string length as appropriate.
321
322 Optional IGNORE-CASE non-nil means use case-insensitive comparison.
323 Case is significant by default.
321 324
322 The value is t if the strings (or specified portions) match. 325 The value is t if the strings (or specified portions) match.
323 If string STR1 is less, the value is a negative number N; 326 If string STR1 is less, the value is a negative number N;
324 - 1 - N is the number of characters that match at the beginning. 327 - 1 - N is the number of characters that match at the beginning.
325 If string STR1 is greater, the value is a positive number N; 328 If string STR1 is greater, the value is a positive number N;
333 int res; 336 int res;
334 337
335 CHECK_STRING (str1); 338 CHECK_STRING (str1);
336 CHECK_STRING (str2); 339 CHECK_STRING (str2);
337 get_string_range_char (str1, start1, end1, &ccstart1, &ccend1, 340 get_string_range_char (str1, start1, end1, &ccstart1, &ccend1,
338 GB_HISTORICAL_STRING_BEHAVIOR); 341 GB_HISTORICAL_STRING_BEHAVIOR|GB_COERCE_RANGE);
339 get_string_range_char (str2, start2, end2, &ccstart2, &ccend2, 342 get_string_range_char (str2, start2, end2, &ccstart2, &ccend2,
340 GB_HISTORICAL_STRING_BEHAVIOR); 343 GB_HISTORICAL_STRING_BEHAVIOR|GB_COERCE_RANGE);
341 344
342 bstart1 = string_index_char_to_byte (str1, ccstart1); 345 bstart1 = string_index_char_to_byte (str1, ccstart1);
343 blen1 = string_offset_char_to_byte_len (str1, bstart1, ccend1 - ccstart1); 346 blen1 = string_offset_char_to_byte_len (str1, bstart1, ccend1 - ccstart1);
344 bstart2 = string_index_char_to_byte (str2, ccstart2); 347 bstart2 = string_index_char_to_byte (str2, ccstart2);
345 blen2 = string_offset_char_to_byte_len (str2, bstart2, ccend2 - ccstart2); 348 blen2 = string_offset_char_to_byte_len (str2, bstart2, ccend2 - ccstart2);