X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Ffns.c;h=e3bce639c2474f64ae1cc493dae4f110cf30bf19;hb=3aca7317dd930beecbddba646284279744087e69;hp=d5f5ae3fe83f484ca9f109b360bb24873e3709ed;hpb=3e447015251ce6dcde843cbed10d9033d5538622;p=chise%2Fxemacs-chise.git- diff --git a/src/fns.c b/src/fns.c index d5f5ae3..e3bce63 100644 --- a/src/fns.c +++ b/src/fns.c @@ -115,8 +115,8 @@ static size_t size_bit_vector (const void *lheader) { Lisp_Bit_Vector *v = (Lisp_Bit_Vector *) lheader; - return offsetof (Lisp_Bit_Vector, - bits[BIT_VECTOR_LONG_STORAGE (bit_vector_length (v))]); + return FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_Bit_Vector, bits, + BIT_VECTOR_LONG_STORAGE (bit_vector_length (v))); } static const struct lrecord_description bit_vector_description[] = { @@ -3115,6 +3115,49 @@ the spiffy Common Lisp arguments. You should normally use `mapc'. } + + +DEFUN ("replace-list", Freplace_list, 2, 2, 0, /* +Destructively replace the list OLD with NEW. +This is like (copy-sequence NEW) except that it reuses the +conses in OLD as much as possible. If OLD and NEW are the same +length, no consing will take place. +*/ + (old, new)) +{ + Lisp_Object tail, oldtail = old, prevoldtail = Qnil; + + EXTERNAL_LIST_LOOP (tail, new) + { + if (!NILP (oldtail)) + { + CHECK_CONS (oldtail); + XCAR (oldtail) = XCAR (tail); + } + else if (!NILP (prevoldtail)) + { + XCDR (prevoldtail) = Fcons (XCAR (tail), Qnil); + prevoldtail = XCDR (prevoldtail); + } + else + old = oldtail = Fcons (XCAR (tail), Qnil); + + if (!NILP (oldtail)) + { + prevoldtail = oldtail; + oldtail = XCDR (oldtail); + } + } + + if (!NILP (prevoldtail)) + XCDR (prevoldtail) = Qnil; + else + old = Qnil; + + return old; +} + + /* #### this function doesn't belong in this file! */ DEFUN ("load-average", Fload_average, 0, 1, 0, /* @@ -3186,10 +3229,13 @@ Examples: (featurep '(or (and xemacs 19.15) (and emacs 19.34))) => ; Non-nil on XEmacs 19.15 and later, or FSF Emacs 19.34 and later. + (featurep '(and xemacs 21.02)) + => ; Non-nil on XEmacs 21.2 and later. + NOTE: The advanced arguments of this function (anything other than a symbol) are not yet supported by FSF Emacs. If you feel they are useful for supporting multiple Emacs variants, lobby Richard Stallman at -. +. */ (fexp)) { @@ -3719,6 +3765,8 @@ Lisp_Object Qyes_or_no_p; void syms_of_fns (void) { + INIT_LRECORD_IMPLEMENTATION (bit_vector); + defsymbol (&Qstring_lessp, "string-lessp"); defsymbol (&Qidentity, "identity"); defsymbol (&Qyes_or_no_p, "yes-or-no-p"); @@ -3798,6 +3846,7 @@ syms_of_fns (void) DEFSUBR (Fmapvector); DEFSUBR (Fmapc_internal); DEFSUBR (Fmapconcat); + DEFSUBR (Freplace_list); DEFSUBR (Fload_average); DEFSUBR (Ffeaturep); DEFSUBR (Frequire);