X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Ffns.c;h=0a26ebe17d5111236c84ad858fec0b9f8211d221;hb=29c4caea228ce22a9bfa76ef833d4473a9be8979;hp=d60e8609a88c2db25f8fece5a7666df1b9ff39ad;hpb=81dd3117efce019fc5956143896f1c5d375f55a0;p=sxemacs diff --git a/src/fns.c b/src/fns.c index d60e860..0a26ebe 100644 --- a/src/fns.c +++ b/src/fns.c @@ -46,6 +46,7 @@ along with this program. If not, see . */ #include "systime.h" #include "ui/insdel.h" #include "lstream.h" +#include "ent/ent.h" /* for the categorial views */ #include "category.h" #include "seq.h" @@ -147,11 +148,11 @@ Return a pseudo-random number. All integers representable in Lisp are equally likely. On most systems, this is 31 bits' worth. -With positive integer argument LIMIT, return random number +With positive integer argument LIMIT, return random number in interval [0,LIMIT). LIMIT can be a big integer, in which case the range of possible values is extended. -With argument t, set the random number seed from the +With argument t, set the random number seed from the current time and pid. */ (limit)) @@ -698,8 +699,8 @@ concat(int nargs, Lisp_Object * args, Bufbyte *string_result_ptr = NULL; struct gcpro gcpro1; int speccount = specpdl_depth(); - Charcount total_length; - + Charcount total_length; + /* The modus operandi in Emacs is "caller gc-protects args". However, concat is called many times in Emacs on freshly @@ -716,7 +717,7 @@ concat(int nargs, Lisp_Object * args, the result in the returned string's `string-translatable' property. */ #endif if (target_type == c_string) - XMALLOC_OR_ALLOCA(args_mse, nargs, struct merge_string_extents_struct); + XMALLOC_OR_ALLOCA(args_mse, nargs, struct merge_string_extents_struct); /* In append, the last arg isn't treated like the others */ if (last_special && nargs > 0) { @@ -758,7 +759,7 @@ concat(int nargs, Lisp_Object * args, /* Charcount is a misnomer here as we might be dealing with the length of a vector or list, but emphasizes that we're not dealing with Bytecounts in strings */ - /* Charcount total_length; */ + /* Charcount total_length; */ for (argnum = 0, total_length = 0; argnum < nargs; argnum++) { #ifdef LOSING_BYTECODE @@ -772,21 +773,21 @@ concat(int nargs, Lisp_Object * args, switch (target_type) { case c_cons: - if (total_length == 0) { + if (total_length == 0) { /* In append, if all but last arg are nil, return last arg */ - XMALLOC_UNBIND(args_mse, nargs, speccount); + XMALLOC_UNBIND(args_mse, nargs, speccount); RETURN_UNGCPRO(last_tail); - } + } val = Fmake_list(make_int(total_length), Qnil); break; case c_dllist: - if (total_length == 0) { + if (total_length == 0) { /* In append, if all but last arg are nil, return last arg */ - XMALLOC_UNBIND(args_mse, nargs, speccount); + XMALLOC_UNBIND(args_mse, nargs, speccount); RETURN_UNGCPRO(last_tail); - } + } val = Fmake_list(make_int(total_length), Qnil); break; case c_vector: @@ -807,7 +808,7 @@ concat(int nargs, Lisp_Object * args, in order to make the char fit properly. O(N^2) yuckage. */ val = Qnil; - XMALLOC_ATOMIC_OR_ALLOCA( string_result, + XMALLOC_ATOMIC_OR_ALLOCA( string_result, total_length * MAX_EMCHAR_LEN, Bufbyte ); string_result_ptr = string_result; @@ -889,7 +890,7 @@ concat(int nargs, Lisp_Object * args, XINT(elt)); } else { CHECK_CHAR_COERCE_INT(elt); - if(string_result_ptr != NULL) { + if(string_result_ptr != NULL) { string_result_ptr += set_charptr_emchar(string_result_ptr, XCHAR(elt)); @@ -911,18 +912,22 @@ concat(int nargs, Lisp_Object * args, val = make_string(string_result, string_result_ptr - string_result); - for (argnum = 0; argnum < nargs; argnum++) { - if (STRINGP(args_mse[argnum].string)) - copy_string_extents(val, - args_mse[argnum].string, - args_mse[argnum]. - entry_offset, 0, - args_mse[argnum]. - entry_length); + if (args_mse != NULL) { + for (argnum = 0; argnum < nargs; argnum++) { + if (STRINGP(args_mse[argnum].string)) + copy_string_extents(val, + args_mse[argnum].string, + args_mse[argnum]. + entry_offset, 0, + args_mse[argnum]. + entry_length); + } + XMALLOC_UNBIND(string_result, + total_length * MAX_EMCHAR_LEN, speccount); + XMALLOC_UNBIND(args_mse, nargs, speccount); + } else { + abort(); } - XMALLOC_UNBIND(string_result, - total_length * MAX_EMCHAR_LEN, speccount); - XMALLOC_UNBIND(args_mse, nargs, speccount); } if (!NILP(prev)) @@ -1009,7 +1014,7 @@ END may be nil or omitted; then the substring runs to the end of STRING. If START or END is negative, it counts from the end. Relevant parts of the string-extent-data are copied to the new string. */ - (string, start, end)) + (string, start, end)) { Charcount ccstart, ccend; Bytecount bstart, blen; @@ -1894,7 +1899,7 @@ list_merge(Lisp_Object org_l1, Lisp_Object org_l2, } /************************************************************************/ -/* property-list functions */ +/* property-list functions */ /************************************************************************/ /* For properties of text, we need to do order-insensitive comparison of @@ -2743,7 +2748,7 @@ internal_equalp (Lisp_Object obj1, Lisp_Object obj2, int depth) const struct lrecord_implementation *imp1 = XRECORD_LHEADER_IMPLEMENTATION (obj1), *imp2 = XRECORD_LHEADER_IMPLEMENTATION (obj2); - + /* #### not yet implemented properly, needs another flag to specify equalp-ness */ return (imp1 == imp2) && @@ -3272,7 +3277,7 @@ static short base64_char_to_value[128] = { .--------. .--------. .--------. |aaaaaabb| |bbbbcccc| |ccdddddd| `--------' `--------' `--------' - 6 2 4 4 2 6 + 6 2 4 4 2 6 .--------+--------+--------+--------. |00aaaaaa|00bbbbbb|00cccccc|00dddddd| `--------+--------+--------+--------' @@ -3631,7 +3636,7 @@ base16_decode_1(Lstream * istream, int length, Bufbyte * to) low = ec - 'A' + 10; else if (islower(ec)) low = ec - 'a' + 10; - else + else ignore_p = 1; if (low < 0 || low >= 16)