Mercurial > hg > xemacs-beta
changeset 5386:af961911bcb2
Make listu() and listn() assemble lists in forward order. Use them.
See xemacs-patches message with ID
<AANLkTi=Tnd_e8WqiGBE2DmNGmY7zhqxhVNtxECnQo8w9@mail.gmail.com>
author | Jerry James <james@xemacs.org> |
---|---|
date | Tue, 29 Mar 2011 15:59:56 -0600 |
parents | 436e67ca8c79 |
children | fd5cd747075f |
files | src/ChangeLog src/alloc.c src/dired.c src/editfns.c src/faces.c |
diffstat | 5 files changed, 85 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Tue Mar 29 17:28:34 2011 +0100 +++ b/src/ChangeLog Tue Mar 29 15:59:56 2011 -0600 @@ -1,3 +1,13 @@ +2011-03-24 Jerry James <james@xemacs.org> + + * alloc.c (listu): Assemble the list in the right order so we don't + have to reverse it. + (listn): Ditto. + * dired.c (Ffile_attributes): Use listn instead of building an array + to pass to Flist. GC protect the mode string. + * editfns.c (Fdecode_time): Use listn instead of Flist. + * faces.c (vars_of_faces): Use listu instead of Flist. + 2011-03-24 Jerry James <james@xemacs.org> * README.kkcc: "occured" -> "occurred".
--- a/src/alloc.c Tue Mar 29 17:28:34 2011 +0100 +++ b/src/alloc.c Tue Mar 29 15:59:56 2011 -0600 @@ -1465,18 +1465,23 @@ listu (Lisp_Object first, ...) { Lisp_Object obj = Qnil; - Lisp_Object val; - va_list va; - - va_start (va, first); - val = first; - while (!UNBOUNDP (val)) + + if (!UNBOUNDP (first)) { - obj = Fcons (val, obj); + va_list va; + Lisp_Object last, val; + + last = obj = Fcons (first, Qnil); + va_start (va, first); val = va_arg (va, Lisp_Object); + while (!UNBOUNDP (val)) + { + last = XCDR (last) = Fcons (val, Qnil); + val = va_arg (va, Lisp_Object); + } + va_end (va); } - va_end (va); - return Fnreverse (obj); + return obj; } /* Return a list of arbitrary length, with length specified and remaining @@ -1485,15 +1490,21 @@ Lisp_Object listn (int num_args, ...) { - int i; Lisp_Object obj = Qnil; - va_list va; - - va_start (va, num_args); - for (i = 0; i < num_args; i++) - obj = Fcons (va_arg (va, Lisp_Object), obj); - va_end (va); - return Fnreverse (obj); + + if (num_args > 0) + { + va_list va; + Lisp_Object last; + int i; + + va_start (va, num_args); + last = obj = Fcons (va_arg (va, Lisp_Object), Qnil); + for (i = 1; i < num_args; i++) + last = XCDR (last) = Fcons (va_arg (va, Lisp_Object), Qnil); + va_end (va); + } + return obj; } /* Return a list of arbitrary length, with length specified and an array
--- a/src/dired.c Tue Mar 29 17:28:34 2011 +0100 +++ b/src/dired.c Tue Mar 29 15:59:56 2011 -0600 @@ -845,14 +845,13 @@ (filename)) { /* This function can GC. GC checked 1997.06.04. */ - Lisp_Object values[12]; Lisp_Object directory = Qnil; struct stat s; char modes[10]; - Lisp_Object handler; - struct gcpro gcpro1, gcpro2; + Lisp_Object handler, mode, modestring = Qnil, size, gid; + struct gcpro gcpro1, gcpro2, gcpro3; - GCPRO2 (filename, directory); + GCPRO3 (filename, directory, modestring); filename = Fexpand_file_name (filename, Qnil); /* If the file name has special constructs in it, @@ -893,49 +892,54 @@ switch (s.st_mode & S_IFMT) { default: - values[0] = Qnil; + mode = Qnil; break; case S_IFDIR: - values[0] = Qt; + mode = Qt; break; #ifdef S_IFLNK case S_IFLNK: - values[0] = Ffile_symlink_p (filename); + mode = Ffile_symlink_p (filename); break; #endif } - values[1] = make_int (s.st_nlink); - values[2] = make_int (s.st_uid); - values[3] = make_int (s.st_gid); - values[4] = make_time (s.st_atime); - values[5] = make_time (s.st_mtime); - values[6] = make_time (s.st_ctime); #ifndef HAVE_BIGNUM - values[7] = make_integer (NUMBER_FITS_IN_AN_EMACS_INT (s.st_size) ? - (EMACS_INT)s.st_size : -1); + size = make_integer (NUMBER_FITS_IN_AN_EMACS_INT (s.st_size) ? + (EMACS_INT)s.st_size : -1); #else - values[7] = make_integer (s.st_size); -#endif + size = make_integer (s.st_size); +#endif filemodestring (&s, modes); - values[8] = make_string ((Ibyte *) modes, 10); + modestring = make_string ((Ibyte *) modes, 10), + #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ { struct stat sdir; if (!NILP (directory) && qxe_stat (XSTRING_DATA (directory), &sdir) == 0) - values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; + gid = (sdir.st_gid != s.st_gid) ? Qt : Qnil; else /* if we can't tell, assume worst */ - values[9] = Qt; + gid = Qt; } #else /* file gid will be egid */ - values[9] = (s.st_gid != getegid ()) ? Qt : Qnil; + gid = (s.st_gid != getegid ()) ? Qt : Qnil; #endif /* BSD4_2 or BSD4_3 */ - values[10] = make_int (s.st_ino); - values[11] = make_int (s.st_dev); - UNGCPRO; - return Flist (countof (values), values); + + RETURN_UNGCPRO (listn (12, + mode, + make_int (s.st_nlink), + make_int (s.st_uid), + make_int (s.st_gid), + make_time (s.st_atime), + make_time (s.st_mtime), + make_time (s.st_ctime), + size, + modestring, + gid, + make_int (s.st_ino), + make_int (s.st_dev))); }
--- a/src/editfns.c Tue Mar 29 17:28:34 2011 +0100 +++ b/src/editfns.c Tue Mar 29 15:59:56 2011 -0600 @@ -1102,29 +1102,28 @@ time_t time_spec; struct tm save_tm; struct tm *decoded_time; - Lisp_Object list_args[9]; if (! lisp_to_time (specified_time, &time_spec)) invalid_argument ("Invalid time specification", Qunbound); decoded_time = localtime (&time_spec); - list_args[0] = make_int (decoded_time->tm_sec); - list_args[1] = make_int (decoded_time->tm_min); - list_args[2] = make_int (decoded_time->tm_hour); - list_args[3] = make_int (decoded_time->tm_mday); - list_args[4] = make_int (decoded_time->tm_mon + 1); - list_args[5] = make_int (decoded_time->tm_year + 1900); - list_args[6] = make_int (decoded_time->tm_wday); - list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; /* Make a copy, in case gmtime modifies the struct. */ save_tm = *decoded_time; decoded_time = gmtime (&time_spec); - if (decoded_time == 0) - list_args[8] = Qnil; - else - list_args[8] = make_int (difftm (&save_tm, decoded_time)); - return Flist (9, list_args); + + return listn(9, + make_int (save_tm.tm_sec), + make_int (save_tm.tm_min), + make_int (save_tm.tm_hour), + make_int (save_tm.tm_mday), + make_int (save_tm.tm_mon + 1), + make_int (save_tm.tm_year + 1900), + make_int (save_tm.tm_wday), + save_tm.tm_isdst ? Qt : Qnil, + (decoded_time == NULL) + ? Qnil + : make_int (difftm (&save_tm, decoded_time))); } static void set_time_zone_rule (Extbyte *tzstring);
--- a/src/faces.c Tue Mar 29 17:28:34 2011 +0100 +++ b/src/faces.c Tue Mar 29 15:59:56 2011 -0600 @@ -2227,26 +2227,11 @@ debug_x_faces = 0; #endif - { - Lisp_Object syms[20]; - int n = 0; - - syms[n++] = Qforeground; - syms[n++] = Qbackground; - syms[n++] = Qfont; - syms[n++] = Qdisplay_table; - syms[n++] = Qbackground_pixmap; - syms[n++] = Qbackground_placement; - syms[n++] = Qunderline; - syms[n++] = Qstrikethru; - syms[n++] = Qhighlight; - syms[n++] = Qdim; - syms[n++] = Qblinking; - syms[n++] = Qreverse; - - Vbuilt_in_face_specifiers = Flist (n, syms); - staticpro (&Vbuilt_in_face_specifiers); - } + Vbuilt_in_face_specifiers = + listu (Qforeground, Qbackground, Qfont, Qdisplay_table, Qbackground_pixmap, + Qbackground_placement, Qunderline, Qstrikethru, Qhighlight, Qdim, + Qblinking, Qreverse, Qunbound); + staticpro (&Vbuilt_in_face_specifiers); } void