comparison src/fns.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 6075d714658b
children b405438285a2
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
571 for the `string-translatable' property, then concat should also 571 for the `string-translatable' property, then concat should also
572 concat the args but use the `string-translatable' strings, and store 572 concat the args but use the `string-translatable' strings, and store
573 the result in the returned string's `string-translatable' property. */ 573 the result in the returned string's `string-translatable' property. */
574 #endif 574 #endif
575 if (target_type == c_string) 575 if (target_type == c_string)
576 { 576 args_mse = alloca_array (struct merge_string_extents_struct, nargs);
577 args_mse = ((struct merge_string_extents_struct *)
578 alloca (nargs *
579 sizeof (struct merge_string_extents_struct)));
580 }
581 577
582 /* In append, the last arg isn't treated like the others */ 578 /* In append, the last arg isn't treated like the others */
583 if (last_special && nargs > 0) 579 if (last_special && nargs > 0)
584 { 580 {
585 nargs--; 581 nargs--;
1806 1802
1807 DEFUN ("sort", Fsort, 2, 2, 0, /* 1803 DEFUN ("sort", Fsort, 2, 2, 0, /*
1808 Sort LIST, stably, comparing elements using PREDICATE. 1804 Sort LIST, stably, comparing elements using PREDICATE.
1809 Returns the sorted list. LIST is modified by side effects. 1805 Returns the sorted list. LIST is modified by side effects.
1810 PREDICATE is called with two elements of LIST, and should return T 1806 PREDICATE is called with two elements of LIST, and should return T
1811 if the first element is \"less\" than the second. 1807 if the first element is "less" than the second.
1812 */ 1808 */
1813 (list, pred)) 1809 (list, pred))
1814 { 1810 {
1815 return list_sort (list, pred, merge_pred_function); 1811 return list_sort (list, pred, merge_pred_function);
1816 } 1812 }
1915 1911
1916 la = XINT (Flength (a)); 1912 la = XINT (Flength (a));
1917 lb = XINT (Flength (b)); 1913 lb = XINT (Flength (b));
1918 m = (la > lb ? la : lb); 1914 m = (la > lb ? la : lb);
1919 fill = 0; 1915 fill = 0;
1920 keys = (Lisp_Object *) alloca (m * sizeof (Lisp_Object)); 1916 keys = alloca_array (Lisp_Object, m);
1921 vals = (Lisp_Object *) alloca (m * sizeof (Lisp_Object)); 1917 vals = alloca_array (Lisp_Object, m);
1922 flags = (char *) alloca (m * sizeof (char)); 1918 flags = alloca_array (char, m);
1923 1919
1924 /* First extract the pairs from A. */ 1920 /* First extract the pairs from A. */
1925 for (rest = a; !NILP (rest); rest = XCDR (XCDR (rest))) 1921 for (rest = a; !NILP (rest); rest = XCDR (XCDR (rest)))
1926 { 1922 {
1927 Lisp_Object k = XCAR (rest); 1923 Lisp_Object k = XCAR (rest);
3007 3003
3008 DEFUN ("old-equal", Fold_equal, 2, 2, 0, /* 3004 DEFUN ("old-equal", Fold_equal, 2, 2, 0, /*
3009 T if two Lisp objects have similar structure and contents. 3005 T if two Lisp objects have similar structure and contents.
3010 They must have the same data type. 3006 They must have the same data type.
3011 \(Note, however, that an exception is made for characters and integers; 3007 \(Note, however, that an exception is made for characters and integers;
3012 this is known as the \"char-int confoundance disease.\" See `eq' and 3008 this is known as the "char-int confoundance disease." See `eq' and
3013 `old-eq'.) 3009 `old-eq'.)
3014 This function is provided only for byte-code compatibility with v19. 3010 This function is provided only for byte-code compatibility with v19.
3015 Do not use it. 3011 Do not use it.
3016 */ 3012 */
3017 (o1, o2)) 3013 (o1, o2))
3216 } 3212 }
3217 3213
3218 DEFUN ("mapconcat", Fmapconcat, 3, 3, 0, /* 3214 DEFUN ("mapconcat", Fmapconcat, 3, 3, 0, /*
3219 Apply FN to each element of SEQ, and concat the results as strings. 3215 Apply FN to each element of SEQ, and concat the results as strings.
3220 In between each pair of results, stick in SEP. 3216 In between each pair of results, stick in SEP.
3221 Thus, \" \" as SEP results in spaces between the values returned by FN. 3217 Thus, " " as SEP results in spaces between the values returned by FN.
3222 */ 3218 */
3223 (fn, seq, sep)) 3219 (fn, seq, sep))
3224 { 3220 {
3225 int len = XINT (Flength (seq)); 3221 int len = XINT (Flength (seq));
3226 int nargs; 3222 int nargs;
3229 struct gcpro gcpro1; 3225 struct gcpro gcpro1;
3230 3226
3231 nargs = len + len - 1; 3227 nargs = len + len - 1;
3232 if (nargs < 0) return build_string (""); 3228 if (nargs < 0) return build_string ("");
3233 3229
3234 args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); 3230 args = alloca_array (Lisp_Object, nargs);
3235 3231
3236 GCPRO1 (sep); 3232 GCPRO1 (sep);
3237 mapcar1 (len, args, fn, seq); 3233 mapcar1 (len, args, fn, seq);
3238 UNGCPRO; 3234 UNGCPRO;
3239 3235
3252 SEQUENCE may be a list, a vector, a bit vector, or a string. 3248 SEQUENCE may be a list, a vector, a bit vector, or a string.
3253 */ 3249 */
3254 (fn, seq)) 3250 (fn, seq))
3255 { 3251 {
3256 int len = XINT (Flength (seq)); 3252 int len = XINT (Flength (seq));
3257 Lisp_Object *args = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); 3253 Lisp_Object *args = alloca_array (Lisp_Object, len);
3258 3254
3259 mapcar1 (len, args, fn, seq); 3255 mapcar1 (len, args, fn, seq);
3260 3256
3261 return Flist (len, args); 3257 return Flist (len, args);
3262 } 3258 }
3267 SEQUENCE may be a list, a vector or a string. 3263 SEQUENCE may be a list, a vector or a string.
3268 */ 3264 */
3269 (fn, seq)) 3265 (fn, seq))
3270 { 3266 {
3271 int len = XINT (Flength (seq)); 3267 int len = XINT (Flength (seq));
3272 Lisp_Object *args = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); 3268 Lisp_Object *args = alloca_array (Lisp_Object, len);
3273 3269
3274 mapcar1 (len, args, fn, seq); 3270 mapcar1 (len, args, fn, seq);
3275 3271
3276 return Fvector (len, args); 3272 return Fvector (len, args);
3277 } 3273 }