Mercurial > emacs
comparison src/fns.c @ 17063:647b28ba4d1b
(Fcopy_sequence, concat, internal_equal, Ffillarray):
Fix a bug of miscalculation of `size_in_chars' of a bool vector.
(Fset_char_table_range): When range is vector, make the original
char table deeper if necessary.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 22 Feb 1997 19:31:56 +0000 |
parents | 591b7a95d7a5 |
children | 47bfc66eb7f1 |
comparison
equal
deleted
inserted
replaced
17062:a9f1f08212ec | 17063:647b28ba4d1b |
---|---|
324 | 324 |
325 if (BOOL_VECTOR_P (arg)) | 325 if (BOOL_VECTOR_P (arg)) |
326 { | 326 { |
327 Lisp_Object val; | 327 Lisp_Object val; |
328 int size_in_chars | 328 int size_in_chars |
329 = (XBOOL_VECTOR (arg)->size + BITS_PER_CHAR) / BITS_PER_CHAR; | 329 = (XBOOL_VECTOR (arg)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
330 | 330 |
331 val = Fmake_bool_vector (Flength (arg), Qnil); | 331 val = Fmake_bool_vector (Flength (arg), Qnil); |
332 bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data, | 332 bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data, |
333 size_in_chars); | 333 size_in_chars); |
334 return val; | 334 return val; |
437 if (STRINGP (this)) | 437 if (STRINGP (this)) |
438 XSETFASTINT (elt, XSTRING (this)->data[thisindex++]); | 438 XSETFASTINT (elt, XSTRING (this)->data[thisindex++]); |
439 else if (BOOL_VECTOR_P (this)) | 439 else if (BOOL_VECTOR_P (this)) |
440 { | 440 { |
441 int size_in_chars | 441 int size_in_chars |
442 = ((XBOOL_VECTOR (this)->size + BITS_PER_CHAR) | 442 = ((XBOOL_VECTOR (this)->size + BITS_PER_CHAR - 1) |
443 / BITS_PER_CHAR); | 443 / BITS_PER_CHAR); |
444 int byte; | 444 int byte; |
445 byte = XBOOL_VECTOR (val)->data[thisindex / BITS_PER_CHAR]; | 445 byte = XBOOL_VECTOR (val)->data[thisindex / BITS_PER_CHAR]; |
446 if (byte & (1 << (thisindex % BITS_PER_CHAR))) | 446 if (byte & (1 << (thisindex % BITS_PER_CHAR))) |
447 elt = Qt; | 447 elt = Qt; |
1097 return 0; | 1097 return 0; |
1098 /* Boolvectors are compared much like strings. */ | 1098 /* Boolvectors are compared much like strings. */ |
1099 if (BOOL_VECTOR_P (o1)) | 1099 if (BOOL_VECTOR_P (o1)) |
1100 { | 1100 { |
1101 int size_in_chars | 1101 int size_in_chars |
1102 = (XBOOL_VECTOR (o1)->size + BITS_PER_CHAR) / BITS_PER_CHAR; | 1102 = (XBOOL_VECTOR (o1)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
1103 | 1103 |
1104 if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size) | 1104 if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size) |
1105 return 0; | 1105 return 0; |
1106 if (bcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data, | 1106 if (bcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data, |
1107 size_in_chars)) | 1107 size_in_chars)) |
1181 } | 1181 } |
1182 else if (BOOL_VECTOR_P (array)) | 1182 else if (BOOL_VECTOR_P (array)) |
1183 { | 1183 { |
1184 register unsigned char *p = XBOOL_VECTOR (array)->data; | 1184 register unsigned char *p = XBOOL_VECTOR (array)->data; |
1185 int size_in_chars | 1185 int size_in_chars |
1186 = (XBOOL_VECTOR (array)->size + BITS_PER_CHAR) / BITS_PER_CHAR; | 1186 = (XBOOL_VECTOR (array)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
1187 | 1187 |
1188 charval = (! NILP (item) ? -1 : 0); | 1188 charval = (! NILP (item) ? -1 : 0); |
1189 for (index = 0; index < size_in_chars; index++) | 1189 for (index = 0; index < size_in_chars; index++) |
1190 p[index] = charval; | 1190 p[index] = charval; |
1191 } | 1191 } |
1331 else if (INTEGERP (range)) | 1331 else if (INTEGERP (range)) |
1332 Faset (char_table, range, value); | 1332 Faset (char_table, range, value); |
1333 else if (VECTORP (range)) | 1333 else if (VECTORP (range)) |
1334 { | 1334 { |
1335 for (i = 0; i < XVECTOR (range)->size - 1; i++) | 1335 for (i = 0; i < XVECTOR (range)->size - 1; i++) |
1336 char_table = Faref (char_table, XVECTOR (range)->contents[i]); | 1336 { |
1337 Lisp_Object tmp = Faref (char_table, XVECTOR (range)->contents[i]); | |
1338 if (NILP (tmp)) | |
1339 { | |
1340 /* Make this char-table deeper. */ | |
1341 XVECTOR (char_table)->contents[XVECTOR (range)->contents[i]] | |
1342 = tmp = Fmake_char_table (Qnil, Qnil); | |
1343 } | |
1344 char_table = tmp; | |
1345 } | |
1337 | 1346 |
1338 if (EQ (XVECTOR (range)->contents[i], Qnil)) | 1347 if (EQ (XVECTOR (range)->contents[i], Qnil)) |
1339 XCHAR_TABLE (char_table)->defalt = value; | 1348 XCHAR_TABLE (char_table)->defalt = value; |
1340 else | 1349 else |
1341 Faset (char_table, XVECTOR (range)->contents[i], value); | 1350 Faset (char_table, XVECTOR (range)->contents[i], value); |