Mercurial > emacs
comparison src/character.c @ 109859:68616bb3ae25
merged from trunk
author | Joakim <joakim@localhost.localdomain> |
---|---|
date | Mon, 14 Jun 2010 11:48:51 +0200 |
parents | c3fda38a8b8b |
children | aec1143e8d85 376148b31b5e |
comparison
equal
deleted
inserted
replaced
109858:73108272ef0b | 109859:68616bb3ae25 |
---|---|
959 usage: (string &rest CHARACTERS) */) | 959 usage: (string &rest CHARACTERS) */) |
960 (n, args) | 960 (n, args) |
961 int n; | 961 int n; |
962 Lisp_Object *args; | 962 Lisp_Object *args; |
963 { | 963 { |
964 int i; | 964 int i, c; |
965 unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n); | 965 unsigned char *buf, *p; |
966 unsigned char *p = buf; | 966 Lisp_Object str; |
967 int c; | 967 USE_SAFE_ALLOCA; |
968 | |
969 SAFE_ALLOCA (buf, unsigned char *, MAX_MULTIBYTE_LENGTH * n); | |
970 p = buf; | |
968 | 971 |
969 for (i = 0; i < n; i++) | 972 for (i = 0; i < n; i++) |
970 { | 973 { |
971 CHECK_CHARACTER (args[i]); | 974 CHECK_CHARACTER (args[i]); |
972 c = XINT (args[i]); | 975 c = XINT (args[i]); |
973 p += CHAR_STRING (c, p); | 976 p += CHAR_STRING (c, p); |
974 } | 977 } |
975 | 978 |
976 return make_string_from_bytes ((char *) buf, n, p - buf); | 979 str = make_string_from_bytes ((char *) buf, n, p - buf); |
980 SAFE_FREE (); | |
981 return str; | |
977 } | 982 } |
978 | 983 |
979 DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, | 984 DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, |
980 doc: /* Concatenate all the argument bytes and make the result a unibyte string. | 985 doc: /* Concatenate all the argument bytes and make the result a unibyte string. |
981 usage: (unibyte-string &rest BYTES) */) | 986 usage: (unibyte-string &rest BYTES) */) |
982 (n, args) | 987 (n, args) |
983 int n; | 988 int n; |
984 Lisp_Object *args; | 989 Lisp_Object *args; |
985 { | 990 { |
986 int i; | 991 int i, c; |
987 unsigned char *buf = (unsigned char *) alloca (n); | 992 unsigned char *buf, *p; |
988 unsigned char *p = buf; | 993 Lisp_Object str; |
989 unsigned c; | 994 USE_SAFE_ALLOCA; |
995 | |
996 SAFE_ALLOCA (buf, unsigned char *, n); | |
997 p = buf; | |
990 | 998 |
991 for (i = 0; i < n; i++) | 999 for (i = 0; i < n; i++) |
992 { | 1000 { |
993 CHECK_NATNUM (args[i]); | 1001 CHECK_NATNUM (args[i]); |
994 c = XFASTINT (args[i]); | 1002 c = XFASTINT (args[i]); |
995 if (c >= 256) | 1003 if (c >= 256) |
996 args_out_of_range_3 (args[i], make_number (0), make_number (255)); | 1004 args_out_of_range_3 (args[i], make_number (0), make_number (255)); |
997 *p++ = c; | 1005 *p++ = c; |
998 } | 1006 } |
999 | 1007 |
1000 return make_string_from_bytes ((char *) buf, n, p - buf); | 1008 str = make_string_from_bytes ((char *) buf, n, p - buf); |
1009 SAFE_FREE (); | |
1010 return str; | |
1001 } | 1011 } |
1002 | 1012 |
1003 DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, | 1013 DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, |
1004 Schar_resolve_modifiers, 1, 1, 0, | 1014 Schar_resolve_modifiers, 1, 1, 0, |
1005 doc: /* Resolve modifiers in the character CHAR. | 1015 doc: /* Resolve modifiers in the character CHAR. |