comparison src/data.c @ 50632:bd83590b911a

(Faset): Calculate nbytes earlier, to satisfy the now pickier PARSE_MULTIBYTE_SEQ.
author Miles Bader <miles@gnu.org>
date Fri, 18 Apr 2003 01:23:23 +0000
parents 247bd25de9e9
children 7ef125284156
comparison
equal deleted inserted replaced
50631:763258a2d395 50632:bd83590b911a
2027 XCHAR_TABLE (array)->contents[code[i]] = newelt; 2027 XCHAR_TABLE (array)->contents[code[i]] = newelt;
2028 } 2028 }
2029 } 2029 }
2030 else if (STRING_MULTIBYTE (array)) 2030 else if (STRING_MULTIBYTE (array))
2031 { 2031 {
2032 int idxval_byte, prev_bytes, new_bytes; 2032 int idxval_byte, prev_bytes, new_bytes, nbytes;
2033 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; 2033 unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
2034 2034
2035 if (idxval < 0 || idxval >= SCHARS (array)) 2035 if (idxval < 0 || idxval >= SCHARS (array))
2036 args_out_of_range (array, idx); 2036 args_out_of_range (array, idx);
2037 CHECK_NUMBER (newelt); 2037 CHECK_NUMBER (newelt);
2038
2039 nbytes = SBYTES (array);
2038 2040
2039 idxval_byte = string_char_to_byte (array, idxval); 2041 idxval_byte = string_char_to_byte (array, idxval);
2040 p1 = SDATA (array) + idxval_byte; 2042 p1 = SDATA (array) + idxval_byte;
2041 PARSE_MULTIBYTE_SEQ (p1, nbytes - idxval_byte, prev_bytes); 2043 PARSE_MULTIBYTE_SEQ (p1, nbytes - idxval_byte, prev_bytes);
2042 new_bytes = CHAR_STRING (XINT (newelt), p0); 2044 new_bytes = CHAR_STRING (XINT (newelt), p0);
2043 if (prev_bytes != new_bytes) 2045 if (prev_bytes != new_bytes)
2044 { 2046 {
2045 /* We must relocate the string data. */ 2047 /* We must relocate the string data. */
2046 int nchars = SCHARS (array); 2048 int nchars = SCHARS (array);
2047 int nbytes = SBYTES (array);
2048 unsigned char *str; 2049 unsigned char *str;
2049 2050
2050 str = (nbytes <= MAX_ALLOCA 2051 str = (nbytes <= MAX_ALLOCA
2051 ? (unsigned char *) alloca (nbytes) 2052 ? (unsigned char *) alloca (nbytes)
2052 : (unsigned char *) xmalloc (nbytes)); 2053 : (unsigned char *) xmalloc (nbytes));