comparison src/fns.c @ 49915:95557d4395b0

(string_to_multibyte): Remove unused var i. (Flanginfo): Fix int/Lisp_Object mixup. (void_call2): New fun. (Fmap_char_table): Use it in place of call2.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 22 Feb 2003 22:21:11 +0000
parents 2a19e12053a4
children c0f3ec529c05
comparison
equal deleted inserted replaced
49914:b4b6ede28a6f 49915:95557d4395b0
1045 string_to_multibyte (string) 1045 string_to_multibyte (string)
1046 Lisp_Object string; 1046 Lisp_Object string;
1047 { 1047 {
1048 unsigned char *buf; 1048 unsigned char *buf;
1049 int nbytes; 1049 int nbytes;
1050 int i;
1051 1050
1052 if (STRING_MULTIBYTE (string)) 1051 if (STRING_MULTIBYTE (string))
1053 return string; 1052 return string;
1054 1053
1055 nbytes = parse_str_to_multibyte (SDATA (string), SBYTES (string)); 1054 nbytes = parse_str_to_multibyte (SDATA (string), SBYTES (string));
2697 call2 (function, make_number (c), elt); 2696 call2 (function, make_number (c), elt);
2698 } 2697 }
2699 } 2698 }
2700 } 2699 }
2701 2700
2701 static void void_call2 P_ ((Lisp_Object a, Lisp_Object b, Lisp_Object c));
2702 static void
2703 void_call2 (a, b, c)
2704 Lisp_Object a, b, c;
2705 {
2706 call2 (a, b, c);
2707 }
2708
2702 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, 2709 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table,
2703 2, 2, 0, 2710 2, 2, 0,
2704 doc: /* Call FUNCTION for each (normal and generic) characters in CHAR-TABLE. 2711 doc: /* Call FUNCTION for each (normal and generic) characters in CHAR-TABLE.
2705 FUNCTION is called with two arguments--a key and a value. 2712 FUNCTION is called with two arguments--a key and a value.
2706 The key is always a possible IDX argument to `aref'. */) 2713 The key is always a possible IDX argument to `aref'. */)
2710 /* The depth of char table is at most 3. */ 2717 /* The depth of char table is at most 3. */
2711 Lisp_Object indices[3]; 2718 Lisp_Object indices[3];
2712 2719
2713 CHECK_CHAR_TABLE (char_table); 2720 CHECK_CHAR_TABLE (char_table);
2714 2721
2715 map_char_table ((POINTER_TYPE *) call2, Qnil, char_table, function, 0, indices); 2722 /* When Lisp_Object is represented as a union, `call2' cannot directly
2723 be passed to map_char_table because it returns a Lisp_Object rather
2724 than returning nothing.
2725 Casting leads to crashes on some architectures. -stef */
2726 map_char_table (void_call2, Qnil, char_table, function, 0, indices);
2716 return Qnil; 2727 return Qnil;
2717 } 2728 }
2718 2729
2719 /* Return a value for character C in char-table TABLE. Store the 2730 /* Return a value for character C in char-table TABLE. Store the
2720 actual index for that value in *IDX. Ignore the default value of 2731 actual index for that value in *IDX. Ignore the default value of
3488 val = make_unibyte_string (str, strlen (str)); 3499 val = make_unibyte_string (str, strlen (str));
3489 /* Fixme: Is this coding system necessarily right, even if 3500 /* Fixme: Is this coding system necessarily right, even if
3490 it is consistent with CODESET? If not, what to do? */ 3501 it is consistent with CODESET? If not, what to do? */
3491 Faset (v, make_number (i), 3502 Faset (v, make_number (i),
3492 code_convert_string_norecord (val, Vlocale_coding_system, 3503 code_convert_string_norecord (val, Vlocale_coding_system,
3493 Qnil)); 3504 0));
3494 } 3505 }
3495 return v; 3506 return v;
3496 } 3507 }
3497 #endif /* DAY_1 */ 3508 #endif /* DAY_1 */
3498 #ifdef MON_1 3509 #ifdef MON_1
3506 for (i = 0; i < 12; i++) 3517 for (i = 0; i < 12; i++)
3507 { 3518 {
3508 str = nl_langinfo (months[i]); 3519 str = nl_langinfo (months[i]);
3509 val = make_unibyte_string (str, strlen (str)); 3520 val = make_unibyte_string (str, strlen (str));
3510 p->contents[i] = 3521 p->contents[i] =
3511 code_convert_string_norecord (val, Vlocale_coding_system, Qnil); 3522 code_convert_string_norecord (val, Vlocale_coding_system, 0);
3512 } 3523 }
3513 XSETVECTOR (val, p); 3524 XSETVECTOR (val, p);
3514 return val; 3525 return val;
3515 } 3526 }
3516 #endif /* MON_1 */ 3527 #endif /* MON_1 */