aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1997-04-07 07:12:13 +0000
committerKenichi Handa1997-04-07 07:12:13 +0000
commited8ec86d08a6f2b656e67493003aa4624f868299 (patch)
treeee584057d7960743fb32065c9b39473cad81e85e /src
parent887bfbd7dad82b22175f75bcf5fa38ffe1af6268 (diff)
downloademacs-ed8ec86d08a6f2b656e67493003aa4624f868299.tar.gz
emacs-ed8ec86d08a6f2b656e67493003aa4624f868299.zip
(category-table-p): Check only type and purpose.
(copy_category_table, Fmodify_category_entry): Adjusted for the new structure of Lisp_Char_Table.
Diffstat (limited to 'src')
-rw-r--r--src/category.c109
1 files changed, 58 insertions, 51 deletions
diff --git a/src/category.c b/src/category.c
index 58d5f41a617..cd87abd5637 100644
--- a/src/category.c
+++ b/src/category.c
@@ -145,8 +145,7 @@ DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0,
145 Lisp_Object arg; 145 Lisp_Object arg;
146{ 146{
147 if (CHAR_TABLE_P (arg) 147 if (CHAR_TABLE_P (arg)
148 && EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table) 148 && EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table))
149 && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (arg)) == 2)
150 return Qt; 149 return Qt;
151 return Qnil; 150 return Qnil;
152} 151}
@@ -187,37 +186,46 @@ This is the one used for new buffers.")
187 186
188/* Return a copy of category table TABLE. We can't simply use the 187/* Return a copy of category table TABLE. We can't simply use the
189 function copy-sequence because no contents should be shared between 188 function copy-sequence because no contents should be shared between
190 the original and the copy. 189 the original and the copy. This function is called recursively by
191 190 biding TABLE to a sub char table. */
192 If TOP is 1, we at first copy the tree structure of the table. */
193 191
194Lisp_Object 192Lisp_Object
195copy_category_table (table, top) 193copy_category_table (table)
196 Lisp_Object table; 194 Lisp_Object table;
197{ 195{
198 int i; 196 Lisp_Object tmp;
197 int i, to;
199 198
200 if (top) 199 if (!NILP (XCHAR_TABLE (table)->top))
201 table = Fcopy_sequence (table); 200 {
202 else if (!NILP (XCHAR_TABLE (table)->defalt)) 201 /* TABLE is a top level char table.
203 XCHAR_TABLE (table)->defalt 202 At first, make a copy of tree structure of the table. */
204 = Fcopy_sequence (XCHAR_TABLE (table)->defalt); 203 table = Fcopy_sequence (table);
205 204
206 for (i = 0; i < CHAR_TABLE_ORDINARY_SLOTS; i++) 205 /* Then, copy elements for single byte characters one by one. */
206 for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++)
207 if (!NILP (tmp = XCHAR_TABLE (table)->contents[i]))
208 XCHAR_TABLE (table)->contents[i] = Fcopy_sequence (tmp);
209 to = CHAR_TABLE_ORDINARY_SLOTS;
210 }
211 else
207 { 212 {
208 Lisp_Object idx = make_number (i); 213 i = 32;
209 Lisp_Object val = Faref (table, idx); 214 to = SUB_CHAR_TABLE_ORDINARY_SLOTS;
210
211 if (NILP (val)) /* Do nothing because we can share nil. */
212 ;
213 else if (CATEGORY_SET_P (val))
214 Faset (table, idx, Fcopy_sequence (val));
215 else if (CHAR_TABLE_P (val))
216 Faset (table, idx, copy_category_table (val, 0));
217 else /* Invalid contents. */
218 Faset (table, idx, Qnil);
219 } 215 }
220 216
217 /* If the table has non-nil default value, copy it. */
218 if (!NILP (tmp = XCHAR_TABLE (table)->defalt))
219 XCHAR_TABLE (table)->defalt = Fcopy_sequence (tmp);
220
221 /* At last, copy the remaining elements while paying attention to a
222 sub char table. */
223 for (; i < to; i++)
224 if (!NILP (tmp = XCHAR_TABLE (table)->contents[i]))
225 XCHAR_TABLE (table)->contents[i]
226 = (SUB_CHAR_TABLE_P (tmp)
227 ? copy_category_table (tmp) : Fcopy_sequence (tmp));
228
221 return table; 229 return table;
222} 230}
223 231
@@ -284,7 +292,7 @@ DEFUN ("category-set-mnemonics", Fcategory_set_mnemonics,
284 return build_string (str); 292 return build_string (str);
285} 293}
286 294
287/* Modify all category sets stored under category table TABLE so that 295/* Modify all category sets stored under sub char-table TABLE so that
288 they contain (SET_VALUE is t) or don't contain (SET_VALUE is nil) 296 they contain (SET_VALUE is t) or don't contain (SET_VALUE is nil)
289 CATEGORY. */ 297 CATEGORY. */
290 298
@@ -302,13 +310,13 @@ modify_lower_category_set (table, category, set_value)
302 XCHAR_TABLE (table)->defalt = val; 310 XCHAR_TABLE (table)->defalt = val;
303 } 311 }
304 312
305 for (i = 32; i < CHAR_TABLE_ORDINARY_SLOTS; i++) 313 for (i = 32; i < SUB_CHAR_TABLE_ORDINARY_SLOTS; i++)
306 { 314 {
307 val = XCHAR_TABLE (table)->contents[i]; 315 val = XCHAR_TABLE (table)->contents[i];
308 316
309 if (CATEGORY_SET_P (val)) 317 if (CATEGORY_SET_P (val))
310 SET_CATEGORY_SET (val, category, set_value); 318 SET_CATEGORY_SET (val, category, set_value);
311 else if (CHAR_TABLE_P (val)) 319 else if (SUB_CHAR_TABLE_P (val))
312 modify_lower_category_set (val, category, set_value); 320 modify_lower_category_set (val, category, set_value);
313 } 321 }
314} 322}
@@ -352,7 +360,7 @@ If optional forth argument RESET is non NIL,\n\
352 360
353 set_value = NILP (reset) ? Qt : Qnil; 361 set_value = NILP (reset) ? Qt : Qnil;
354 362
355 if ((c) < CHAR_TABLE_SINGLE_BYTE_SLOTS) 363 if (c < CHAR_TABLE_SINGLE_BYTE_SLOTS)
356 { 364 {
357 val = XCHAR_TABLE (table)->contents[c]; 365 val = XCHAR_TABLE (table)->contents[c];
358 if (!CATEGORY_SET_P (val)) 366 if (!CATEGORY_SET_P (val))
@@ -361,25 +369,24 @@ If optional forth argument RESET is non NIL,\n\
361 return Qnil; 369 return Qnil;
362 } 370 }
363 371
364 if (COMPOSITE_CHAR_P (c))
365 c = cmpchar_component (c, 0);
366 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2); 372 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
367 373
368 /* The top level table. */ 374 /* The top level table. */
369 val = XCHAR_TABLE (table)->contents[charset + 128]; 375 val = XCHAR_TABLE (table)->contents[charset + 128];
370 if (NILP (val)) 376 if (CATEGORY_SET_P (val))
377 category_set = val;
378 else if (!SUB_CHAR_TABLE_P (val))
371 { 379 {
372 category_set = MAKE_CATEGORY_SET; 380 category_set = val = MAKE_CATEGORY_SET;
373 XCHAR_TABLE (table)->contents[charset + 128] = category_set; 381 XCHAR_TABLE (table)->contents[charset + 128] = category_set;
374 } 382 }
375 else if (CATEGORY_SET_P (val))
376 category_set = val;
377 383
378 if (!c1) 384 if (c1 <= 0)
379 { 385 {
380 /* Only a charset is specified. */ 386 /* Only a charset is specified. */
381 if (CHAR_TABLE_P (val)) 387 if (SUB_CHAR_TABLE_P (val))
382 /* All characters in CHARSET should be the same as for CATEGORY. */ 388 /* All characters in CHARSET should be the same as for having
389 CATEGORY or not. */
383 modify_lower_category_set (val, category, set_value); 390 modify_lower_category_set (val, category, set_value);
384 else 391 else
385 SET_CATEGORY_SET (category_set, category, set_value); 392 SET_CATEGORY_SET (category_set, category, set_value);
@@ -387,9 +394,9 @@ If optional forth argument RESET is non NIL,\n\
387 } 394 }
388 395
389 /* The second level table. */ 396 /* The second level table. */
390 if (!CHAR_TABLE_P (val)) 397 if (!SUB_CHAR_TABLE_P (val))
391 { 398 {
392 val = Fmake_char_table (Qnil, Qnil); 399 val = make_sub_char_table (Qnil);
393 XCHAR_TABLE (table)->contents[charset + 128] = val; 400 XCHAR_TABLE (table)->contents[charset + 128] = val;
394 /* We must set default category set of CHARSET in `defalt' slot. */ 401 /* We must set default category set of CHARSET in `defalt' slot. */
395 XCHAR_TABLE (val)->defalt = category_set; 402 XCHAR_TABLE (val)->defalt = category_set;
@@ -397,17 +404,17 @@ If optional forth argument RESET is non NIL,\n\
397 table = val; 404 table = val;
398 405
399 val = XCHAR_TABLE (table)->contents[c1]; 406 val = XCHAR_TABLE (table)->contents[c1];
400 if (NILP (val)) 407 if (CATEGORY_SET_P (val))
408 category_set = val;
409 else if (!SUB_CHAR_TABLE_P (val))
401 { 410 {
402 category_set = Fcopy_sequence (XCHAR_TABLE (table)->defalt); 411 category_set = val = Fcopy_sequence (XCHAR_TABLE (table)->defalt);
403 XCHAR_TABLE (table)->contents[c1] = category_set; 412 XCHAR_TABLE (table)->contents[c1] = category_set;
404 } 413 }
405 else if (CATEGORY_SET_P (val))
406 category_set = val;
407 414
408 if (!c2) 415 if (c2 <= 0)
409 { 416 {
410 if (CHAR_TABLE_P (val)) 417 if (SUB_CHAR_TABLE_P (val))
411 /* All characters in C1 group of CHARSET should be the same as 418 /* All characters in C1 group of CHARSET should be the same as
412 for CATEGORY. */ 419 for CATEGORY. */
413 modify_lower_category_set (val, category, set_value); 420 modify_lower_category_set (val, category, set_value);
@@ -417,9 +424,9 @@ If optional forth argument RESET is non NIL,\n\
417 } 424 }
418 425
419 /* The third (bottom) level table. */ 426 /* The third (bottom) level table. */
420 if (!CHAR_TABLE_P (val)) 427 if (!SUB_CHAR_TABLE_P (val))
421 { 428 {
422 val = Fmake_char_table (Qnil, Qnil); 429 val = make_sub_char_table (Qnil, Qnil);
423 XCHAR_TABLE (table)->contents[c1] = val; 430 XCHAR_TABLE (table)->contents[c1] = val;
424 /* We must set default category set of CHARSET and C1 in 431 /* We must set default category set of CHARSET and C1 in
425 `defalt' slot. */ 432 `defalt' slot. */
@@ -428,13 +435,13 @@ If optional forth argument RESET is non NIL,\n\
428 table = val; 435 table = val;
429 436
430 val = XCHAR_TABLE (table)->contents[c2]; 437 val = XCHAR_TABLE (table)->contents[c2];
431 if (NILP (val)) 438 if (CATEGORY_SET_P (val))
439 category_set = val;
440 else if (!SUB_CHAR_TABLE_P (val))
432 { 441 {
433 category_set = Fcopy_sequence (XCHAR_TABLE (table)->defalt); 442 category_set = Fcopy_sequence (XCHAR_TABLE (table)->defalt);
434 XCHAR_TABLE (table)->contents[c2] = category_set; 443 XCHAR_TABLE (table)->contents[c2] = category_set;
435 } 444 }
436 else if (CATEGORY_SET_P (val))
437 category_set = val;
438 else 445 else
439 /* This should never happen. */ 446 /* This should never happen. */
440 error ("Invalid category table"); 447 error ("Invalid category table");