comparison src/fns.c @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 15872534500d
children 2d532a89d707
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
174 if (!COMPILED_FUNCTIONP (seq)) 174 if (!COMPILED_FUNCTIONP (seq))
175 return XINT (Flength (seq)); 175 return XINT (Flength (seq));
176 else 176 else
177 { 177 {
178 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (seq); 178 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (seq);
179 179
180 return (b->flags.interactivep ? COMPILED_INTERACTIVE : 180 return (b->flags.interactivep ? COMPILED_INTERACTIVE :
181 b->flags.domainp ? COMPILED_DOMAIN : 181 b->flags.domainp ? COMPILED_DOMAIN :
182 COMPILED_DOC_STRING) 182 COMPILED_DOC_STRING)
183 + 1; 183 + 1;
184 } 184 }
206 206
207 retry: 207 retry:
208 if (STRINGP (obj)) 208 if (STRINGP (obj))
209 return make_int (string_char_length (XSTRING (obj))); 209 return make_int (string_char_length (XSTRING (obj)));
210 else if (VECTORP (obj)) 210 else if (VECTORP (obj))
211 return make_int (vector_length (XVECTOR (obj))); 211 return make_int (XVECTOR_LENGTH (obj));
212 else if (BIT_VECTORP (obj)) 212 else if (BIT_VECTORP (obj))
213 return make_int (bit_vector_length (XBIT_VECTOR (obj))); 213 return make_int (bit_vector_length (XBIT_VECTOR (obj)));
214 else if (CONSP (obj)) 214 else if (CONSP (obj))
215 { 215 {
216 for (i = 0, tail = obj; !NILP (tail); i++) 216 for (i = 0, tail = obj; !NILP (tail); i++)
217 { 217 {
218 QUIT; 218 QUIT;
219 tail = Fcdr (tail); 219 tail = Fcdr (tail);
220 } 220 }
221 221
222 return (make_int (i)); 222 return make_int (i);
223 } 223 }
224 else if (NILP (obj)) 224 else if (NILP (obj))
225 { 225 {
226 return (Qzero); 226 return Qzero;
227 } 227 }
228 else 228 else
229 { 229 {
230 check_losing_bytecode ("length", obj); 230 check_losing_bytecode ("length", obj);
231 obj = wrong_type_argument (Qsequencep, obj); 231 obj = wrong_type_argument (Qsequencep, obj);
367 return string_char (p1, i) < string_char (p2, i) ? Qt : Qnil; 367 return string_char (p1, i) < string_char (p2, i) ? Qt : Qnil;
368 } 368 }
369 #endif /* not I18N2, or MULE */ 369 #endif /* not I18N2, or MULE */
370 /* Can't do i < len2 because then comparison between "foo" and "foo^@" 370 /* Can't do i < len2 because then comparison between "foo" and "foo^@"
371 won't work right in I18N2 case */ 371 won't work right in I18N2 case */
372 return ((end < len2) ? Qt : Qnil); 372 return end < len2 ? Qt : Qnil;
373 } 373 }
374 } 374 }
375 375
376 DEFUN ("string-modified-tick", Fstring_modified_tick, 1, 1, 0, /* 376 DEFUN ("string-modified-tick", Fstring_modified_tick, 1, 1, 0, /*
377 Return STRING's tick counter, incremented for each change to the string. 377 Return STRING's tick counter, incremented for each change to the string.
608 else 608 else
609 { 609 {
610 check_losing_bytecode ("concat", seq); 610 check_losing_bytecode ("concat", seq);
611 args[argnum] = wrong_type_argument (Qsequencep, seq); 611 args[argnum] = wrong_type_argument (Qsequencep, seq);
612 } 612 }
613 613
614 if (args_mse) 614 if (args_mse)
615 { 615 {
616 if (STRINGP (seq)) 616 if (STRINGP (seq))
617 args_mse[argnum].string = seq; 617 args_mse[argnum].string = seq;
618 else 618 else
720 { 720 {
721 elt = make_char (charptr_emchar (string_source_ptr)); 721 elt = make_char (charptr_emchar (string_source_ptr));
722 INC_CHARPTR (string_source_ptr); 722 INC_CHARPTR (string_source_ptr);
723 } 723 }
724 else if (VECTORP (seq)) 724 else if (VECTORP (seq))
725 elt = vector_data (XVECTOR (seq))[thisindex]; 725 elt = XVECTOR_DATA (seq)[thisindex];
726 else if (BIT_VECTORP (seq)) 726 else if (BIT_VECTORP (seq))
727 elt = make_int (bit_vector_bit (XBIT_VECTOR (seq), 727 elt = make_int (bit_vector_bit (XBIT_VECTOR (seq),
728 thisindex)); 728 thisindex));
729 else 729 else
730 elt = Felt (seq, make_int (thisindex)); 730 elt = Felt (seq, make_int (thisindex));
738 XCAR (tail) = elt; 738 XCAR (tail) = elt;
739 prev = tail; 739 prev = tail;
740 tail = XCDR (tail); 740 tail = XCDR (tail);
741 } 741 }
742 else if (VECTORP (val)) 742 else if (VECTORP (val))
743 vector_data (XVECTOR (val))[toindex++] = elt; 743 XVECTOR_DATA (val)[toindex++] = elt;
744 else if (BIT_VECTORP (val)) 744 else if (BIT_VECTORP (val))
745 { 745 {
746 CHECK_BIT (elt); 746 CHECK_BIT (elt);
747 set_bit_vector_bit (XBIT_VECTOR (val), toindex++, XINT (elt)); 747 set_bit_vector_bit (XBIT_VECTOR (val), toindex++, XINT (elt));
748 } 748 }
776 } 776 }
777 777
778 if (!NILP (prev)) 778 if (!NILP (prev))
779 XCDR (prev) = last_tail; 779 XCDR (prev) = last_tail;
780 780
781 RETURN_UNGCPRO (val); 781 RETURN_UNGCPRO (val);
782 } 782 }
783 783
784 DEFUN ("copy-alist", Fcopy_alist, 1, 1, 0, /* 784 DEFUN ("copy-alist", Fcopy_alist, 1, 1, 0, /*
785 Return a copy of ALIST. 785 Return a copy of ALIST.
786 This is an alist which represents the same mapping from objects to objects, 786 This is an alist which represents the same mapping from objects to objects,
832 rest = XCDR (rest); 832 rest = XCDR (rest);
833 } 833 }
834 } 834 }
835 else if (VECTORP (arg) && ! NILP (vecp)) 835 else if (VECTORP (arg) && ! NILP (vecp))
836 { 836 {
837 int i = vector_length (XVECTOR (arg)); 837 int i = XVECTOR_LENGTH (arg);
838 int j; 838 int j;
839 arg = Fcopy_sequence (arg); 839 arg = Fcopy_sequence (arg);
840 for (j = 0; j < i; j++) 840 for (j = 0; j < i; j++)
841 { 841 {
842 Lisp_Object elt = vector_data (XVECTOR (arg)) [j]; 842 Lisp_Object elt = XVECTOR_DATA (arg) [j];
843 QUIT; 843 QUIT;
844 if (CONSP (elt) || VECTORP (elt)) 844 if (CONSP (elt) || VECTORP (elt))
845 vector_data (XVECTOR (arg)) [j] = Fcopy_tree (elt, vecp); 845 XVECTOR_DATA (arg) [j] = Fcopy_tree (elt, vecp);
846 } 846 }
847 } 847 }
848 return arg; 848 return arg;
849 } 849 }
850 850
868 bfr = charcount_to_bytecount (XSTRING_DATA (string), ccfr); 868 bfr = charcount_to_bytecount (XSTRING_DATA (string), ccfr);
869 bto = charcount_to_bytecount (XSTRING_DATA (string), ccto); 869 bto = charcount_to_bytecount (XSTRING_DATA (string), ccto);
870 val = make_string (XSTRING_DATA (string) + bfr, bto - bfr); 870 val = make_string (XSTRING_DATA (string) + bfr, bto - bfr);
871 /* Copy any applicable extent information into the new string: */ 871 /* Copy any applicable extent information into the new string: */
872 copy_string_extents (val, string, 0, bfr, bto - bfr); 872 copy_string_extents (val, string, 0, bfr, bto - bfr);
873 return (val); 873 return val;
874 } 874 }
875 875
876 DEFUN ("subseq", Fsubseq, 2, 3, 0, /* 876 DEFUN ("subseq", Fsubseq, 2, 3, 0, /*
877 Return a subsequence of SEQ, starting at index FROM and ending before TO. 877 Return a subsequence of SEQ, starting at index FROM and ending before TO.
878 TO may be nil or omitted; then the subsequence runs to the end of SEQ. 878 TO may be nil or omitted; then the subsequence runs to the end of SEQ.
896 else 896 else
897 { 897 {
898 check_losing_bytecode ("subseq", seq); 898 check_losing_bytecode ("subseq", seq);
899 seq = wrong_type_argument (Qsequencep, seq); 899 seq = wrong_type_argument (Qsequencep, seq);
900 } 900 }
901 901
902 len = XINT (Flength (seq)); 902 len = XINT (Flength (seq));
903 CHECK_INT (from); 903 CHECK_INT (from);
904 f = XINT (from); 904 f = XINT (from);
905 if (f < 0) 905 if (f < 0)
906 f = len + f; 906 f = len + f;
911 CHECK_INT (to); 911 CHECK_INT (to);
912 t = XINT (to); 912 t = XINT (to);
913 if (t < 0) 913 if (t < 0)
914 t = len + t; 914 t = len + t;
915 } 915 }
916 916
917 if (!(0 <= f && f <= t && t <= len)) 917 if (!(0 <= f && f <= t && t <= len))
918 args_out_of_range_3 (seq, make_int (f), make_int (t)); 918 args_out_of_range_3 (seq, make_int (f), make_int (t));
919 919
920 if (VECTORP (seq)) 920 if (VECTORP (seq))
921 { 921 {
922 Lisp_Object result = make_vector (t - f, Qnil); 922 Lisp_Object result = make_vector (t - f, Qnil);
923 int i; 923 int i;
924 Lisp_Object *in_elts = vector_data (XVECTOR (seq)); 924 Lisp_Object *in_elts = XVECTOR_DATA (seq);
925 Lisp_Object *out_elts = vector_data (XVECTOR (result)); 925 Lisp_Object *out_elts = XVECTOR_DATA (result);
926 926
927 for (i = f; i < t; i++) 927 for (i = f; i < t; i++)
928 out_elts[i - f] = in_elts[i]; 928 out_elts[i - f] = in_elts[i];
929 return result; 929 return result;
930 } 930 }
996 /* #### Utterly, completely, fucking disgusting. 996 /* #### Utterly, completely, fucking disgusting.
997 * #### The whole point of "elt" is that it operates on 997 * #### The whole point of "elt" is that it operates on
998 * #### sequences, and does error- (bounds-) checking. 998 * #### sequences, and does error- (bounds-) checking.
999 */ 999 */
1000 if (CONSP (tem)) 1000 if (CONSP (tem))
1001 return (XCAR (tem)); 1001 return XCAR (tem);
1002 else 1002 else
1003 #if 1 1003 #if 1
1004 /* This is The Way It Has Always Been. */ 1004 /* This is The Way It Has Always Been. */
1005 return Qnil; 1005 return Qnil;
1006 #else 1006 #else
1009 #endif 1009 #endif
1010 } 1010 }
1011 else if (STRINGP (seq) 1011 else if (STRINGP (seq)
1012 || VECTORP (seq) 1012 || VECTORP (seq)
1013 || BIT_VECTORP (seq)) 1013 || BIT_VECTORP (seq))
1014 return (Faref (seq, n)); 1014 return Faref (seq, n);
1015 #ifdef LOSING_BYTECODE 1015 #ifdef LOSING_BYTECODE
1016 else if (COMPILED_FUNCTIONP (seq)) 1016 else if (COMPILED_FUNCTIONP (seq))
1017 { 1017 {
1018 int idx = XINT (n); 1018 int idx = XINT (n);
1019 if (idx < 0) 1019 if (idx < 0)
1025 { 1025 {
1026 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (seq); 1026 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (seq);
1027 switch (idx) 1027 switch (idx)
1028 { 1028 {
1029 case COMPILED_ARGLIST: 1029 case COMPILED_ARGLIST:
1030 return (b->arglist); 1030 return b->arglist;
1031 case COMPILED_BYTECODE: 1031 case COMPILED_BYTECODE:
1032 return (b->bytecodes); 1032 return b->bytecodes;
1033 case COMPILED_CONSTANTS: 1033 case COMPILED_CONSTANTS:
1034 return (b->constants); 1034 return b->constants;
1035 case COMPILED_STACK_DEPTH: 1035 case COMPILED_STACK_DEPTH:
1036 return (make_int (b->maxdepth)); 1036 return make_int (b->maxdepth);
1037 case COMPILED_DOC_STRING: 1037 case COMPILED_DOC_STRING:
1038 return (compiled_function_documentation (b)); 1038 return compiled_function_documentation (b);
1039 case COMPILED_DOMAIN: 1039 case COMPILED_DOMAIN:
1040 return (compiled_function_domain (b)); 1040 return compiled_function_domain (b);
1041 case COMPILED_INTERACTIVE: 1041 case COMPILED_INTERACTIVE:
1042 if (b->flags.interactivep) 1042 if (b->flags.interactivep)
1043 return (compiled_function_interactive (b)); 1043 return compiled_function_interactive (b);
1044 /* if we return nil, can't tell interactive with no args 1044 /* if we return nil, can't tell interactive with no args
1045 from noninteractive. */ 1045 from noninteractive. */
1046 goto lose; 1046 goto lose;
1047 default: 1047 default:
1048 goto lose; 1048 goto lose;
1745 if (!NILP (list)) 1745 if (!NILP (list))
1746 list = wrong_type_argument (Qconsp, list); 1746 list = wrong_type_argument (Qconsp, list);
1747 return new; 1747 return new;
1748 } 1748 }
1749 1749
1750 static Lisp_Object list_merge (Lisp_Object org_l1, Lisp_Object org_l2, 1750 static Lisp_Object list_merge (Lisp_Object org_l1, Lisp_Object org_l2,
1751 Lisp_Object lisp_arg, 1751 Lisp_Object lisp_arg,
1752 int (*pred_fn) (Lisp_Object, Lisp_Object, 1752 int (*pred_fn) (Lisp_Object, Lisp_Object,
1753 Lisp_Object lisp_arg)); 1753 Lisp_Object lisp_arg));
1754 1754
1755 Lisp_Object 1755 Lisp_Object
1756 list_sort (Lisp_Object list, 1756 list_sort (Lisp_Object list,
1757 Lisp_Object lisp_arg, 1757 Lisp_Object lisp_arg,
1758 int (*pred_fn) (Lisp_Object, Lisp_Object, 1758 int (*pred_fn) (Lisp_Object, Lisp_Object,
1759 Lisp_Object lisp_arg)) 1759 Lisp_Object lisp_arg))
1760 { 1760 {
1761 Lisp_Object front, back; 1761 Lisp_Object front, back;
1762 Lisp_Object len, tem; 1762 Lisp_Object len, tem;
1781 return list_merge (front, back, lisp_arg, pred_fn); 1781 return list_merge (front, back, lisp_arg, pred_fn);
1782 } 1782 }
1783 1783
1784 1784
1785 static int 1785 static int
1786 merge_pred_function (Lisp_Object obj1, Lisp_Object obj2, 1786 merge_pred_function (Lisp_Object obj1, Lisp_Object obj2,
1787 Lisp_Object pred) 1787 Lisp_Object pred)
1788 { 1788 {
1789 Lisp_Object tmp; 1789 Lisp_Object tmp;
1790 1790
1791 /* prevents the GC from happening in call2 */ 1791 /* prevents the GC from happening in call2 */
1796 make_int (gc_currently_forbidden)); 1796 make_int (gc_currently_forbidden));
1797 gc_currently_forbidden = 1; 1797 gc_currently_forbidden = 1;
1798 tmp = call2 (pred, obj1, obj2); 1798 tmp = call2 (pred, obj1, obj2);
1799 unbind_to (speccount, Qnil); 1799 unbind_to (speccount, Qnil);
1800 1800
1801 if (NILP (tmp)) 1801 if (NILP (tmp))
1802 return -1; 1802 return -1;
1803 else 1803 else
1804 return 1; 1804 return 1;
1805 } 1805 }
1806 1806
1814 { 1814 {
1815 return list_sort (list, pred, merge_pred_function); 1815 return list_sort (list, pred, merge_pred_function);
1816 } 1816 }
1817 1817
1818 Lisp_Object 1818 Lisp_Object
1819 merge (Lisp_Object org_l1, Lisp_Object org_l2, 1819 merge (Lisp_Object org_l1, Lisp_Object org_l2,
1820 Lisp_Object pred) 1820 Lisp_Object pred)
1821 { 1821 {
1822 return list_merge (org_l1, org_l2, pred, merge_pred_function); 1822 return list_merge (org_l1, org_l2, pred, merge_pred_function);
1823 } 1823 }
1824 1824
1825 1825
1826 static Lisp_Object 1826 static Lisp_Object
1827 list_merge (Lisp_Object org_l1, Lisp_Object org_l2, 1827 list_merge (Lisp_Object org_l1, Lisp_Object org_l2,
1828 Lisp_Object lisp_arg, 1828 Lisp_Object lisp_arg,
1829 int (*pred_fn) (Lisp_Object, Lisp_Object, Lisp_Object lisp_arg)) 1829 int (*pred_fn) (Lisp_Object, Lisp_Object, Lisp_Object lisp_arg))
1830 { 1830 {
1831 Lisp_Object value; 1831 Lisp_Object value;
1832 Lisp_Object tail; 1832 Lisp_Object tail;
1833 Lisp_Object tem; 1833 Lisp_Object tem;
1840 value = Qnil; 1840 value = Qnil;
1841 1841
1842 /* It is sufficient to protect org_l1 and org_l2. 1842 /* It is sufficient to protect org_l1 and org_l2.
1843 When l1 and l2 are updated, we copy the new values 1843 When l1 and l2 are updated, we copy the new values
1844 back into the org_ vars. */ 1844 back into the org_ vars. */
1845 1845
1846 GCPRO4 (org_l1, org_l2, lisp_arg, value); 1846 GCPRO4 (org_l1, org_l2, lisp_arg, value);
1847 1847
1848 while (1) 1848 while (1)
1849 { 1849 {
1850 if (NILP (l1)) 1850 if (NILP (l1))
1895 So (a 1 b 2) would be equal to (b 2 a 1). 1895 So (a 1 b 2) would be equal to (b 2 a 1).
1896 1896
1897 NIL_MEANS_NOT_PRESENT is as in `plists-eq' etc. 1897 NIL_MEANS_NOT_PRESENT is as in `plists-eq' etc.
1898 LAXP means use `equal' for comparisons. 1898 LAXP means use `equal' for comparisons.
1899 */ 1899 */
1900 int 1900 int
1901 plists_differ (Lisp_Object a, Lisp_Object b, int nil_means_not_present, 1901 plists_differ (Lisp_Object a, Lisp_Object b, int nil_means_not_present,
1902 int laxp, int depth) 1902 int laxp, int depth)
1903 { 1903 {
1904 int eqp = (depth == -1); /* -1 as depth means us eq, not equal. */ 1904 int eqp = (depth == -1); /* -1 as depth means us eq, not equal. */
1905 int la, lb, m, i, fill; 1905 int la, lb, m, i, fill;
2070 void 2070 void
2071 internal_plist_put (Lisp_Object *plist, Lisp_Object property, 2071 internal_plist_put (Lisp_Object *plist, Lisp_Object property,
2072 Lisp_Object value) 2072 Lisp_Object value)
2073 { 2073 {
2074 Lisp_Object tail = *plist; 2074 Lisp_Object tail = *plist;
2075 2075
2076 for (; !NILP (tail); tail = XCDR (XCDR (tail))) 2076 for (; !NILP (tail); tail = XCDR (XCDR (tail)))
2077 { 2077 {
2078 struct Lisp_Cons *c = XCONS (tail); 2078 struct Lisp_Cons *c = XCONS (tail);
2079 if (EQ (c->car, property)) 2079 if (EQ (c->car, property))
2080 { 2080 {
2183 Lisp_Object *tortsave = *tortoise; 2183 Lisp_Object *tortsave = *tortoise;
2184 2184
2185 /* Note that our "fixing" may be more brutal than necessary, 2185 /* Note that our "fixing" may be more brutal than necessary,
2186 but it's the user's own problem, not ours. if they went in and 2186 but it's the user's own problem, not ours. if they went in and
2187 manually fucked up a plist. */ 2187 manually fucked up a plist. */
2188 2188
2189 for (i = 0; i < 2; i++) 2189 for (i = 0; i < 2; i++)
2190 { 2190 {
2191 /* This is a standard iteration of a defensive-loop-checking 2191 /* This is a standard iteration of a defensive-loop-checking
2192 loop. We just do it twice because we want to advance past 2192 loop. We just do it twice because we want to advance past
2193 both the property and its value. 2193 both the property and its value.
2352 PLIST is a property list, which is a list of the form 2352 PLIST is a property list, which is a list of the form
2353 \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value 2353 \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value
2354 corresponding to the given PROP, or DEFAULT if PROP is not 2354 corresponding to the given PROP, or DEFAULT if PROP is not
2355 one of the properties on the list. 2355 one of the properties on the list.
2356 */ 2356 */
2357 (plist, prop, defalt)) /* Cant spel in C */ 2357 (plist, prop, default_))
2358 { 2358 {
2359 Lisp_Object val = external_plist_get (&plist, prop, 0, ERROR_ME); 2359 Lisp_Object val = external_plist_get (&plist, prop, 0, ERROR_ME);
2360 if (UNBOUNDP (val)) 2360 if (UNBOUNDP (val))
2361 return defalt; 2361 return default_;
2362 return val; 2362 return val;
2363 } 2363 }
2364 2364
2365 DEFUN ("plist-put", Fplist_put, 3, 3, 0, /* 2365 DEFUN ("plist-put", Fplist_put, 3, 3, 0, /*
2366 Change value in PLIST of PROP to VAL. 2366 Change value in PLIST of PROP to VAL.
2420 goto start_over; 2420 goto start_over;
2421 } 2421 }
2422 2422
2423 return Qnil; 2423 return Qnil;
2424 } 2424 }
2425 2425
2426 DEFUN ("valid-plist-p", Fvalid_plist_p, 1, 1, 0, /* 2426 DEFUN ("valid-plist-p", Fvalid_plist_p, 1, 1, 0, /*
2427 Given a plist, return non-nil if its format is correct. 2427 Given a plist, return non-nil if its format is correct.
2428 If it returns nil, `check-valid-plist' will signal an error when given 2428 If it returns nil, `check-valid-plist' will signal an error when given
2429 the plist; that means it's a malformed or circular plist or has non-symbols 2429 the plist; that means it's a malformed or circular plist or has non-symbols
2430 as keywords. 2430 as keywords.
2498 VALUE1 PROP2 VALUE2...), where comparions between properties is done 2498 VALUE1 PROP2 VALUE2...), where comparions between properties is done
2499 using `equal' instead of `eq'. This function returns the value 2499 using `equal' instead of `eq'. This function returns the value
2500 corresponding to the given PROP, or DEFAULT if PROP is not one of the 2500 corresponding to the given PROP, or DEFAULT if PROP is not one of the
2501 properties on the list. 2501 properties on the list.
2502 */ 2502 */
2503 (lax_plist, prop, defalt)) /* Cant spel in C */ 2503 (lax_plist, prop, default_))
2504 { 2504 {
2505 Lisp_Object val = external_plist_get (&lax_plist, prop, 1, ERROR_ME); 2505 Lisp_Object val = external_plist_get (&lax_plist, prop, 1, ERROR_ME);
2506 if (UNBOUNDP (val)) 2506 if (UNBOUNDP (val))
2507 return defalt; 2507 return default_;
2508 return val; 2508 return val;
2509 } 2509 }
2510 2510
2511 DEFUN ("lax-plist-put", Flax_plist_put, 3, 3, 0, /* 2511 DEFUN ("lax-plist-put", Flax_plist_put, 3, 3, 0, /*
2512 Change value in LAX-PLIST of PROP to VAL. 2512 Change value in LAX-PLIST of PROP to VAL.
2626 2626
2627 /* Symbol plists are directly accessible, so we need to protect against 2627 /* Symbol plists are directly accessible, so we need to protect against
2628 invalid property list structure */ 2628 invalid property list structure */
2629 2629
2630 static Lisp_Object 2630 static Lisp_Object
2631 symbol_getprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object defalt) 2631 symbol_getprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object default_)
2632 { 2632 {
2633 Lisp_Object val = external_plist_get (&XSYMBOL (sym)->plist, propname, 2633 Lisp_Object val = external_plist_get (&XSYMBOL (sym)->plist, propname,
2634 0, ERROR_ME); 2634 0, ERROR_ME);
2635 if (UNBOUNDP (val)) 2635 if (UNBOUNDP (val))
2636 return defalt; 2636 return default_;
2637 return val; 2637 return val;
2638 } 2638 }
2639 2639
2640 static void 2640 static void
2641 symbol_putprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object value) 2641 symbol_putprop (Lisp_Object sym, Lisp_Object propname, Lisp_Object value)
2670 return ptr; 2670 return ptr;
2671 } 2671 }
2672 2672
2673 Lisp_Object 2673 Lisp_Object
2674 string_getprop (struct Lisp_String *s, Lisp_Object property, 2674 string_getprop (struct Lisp_String *s, Lisp_Object property,
2675 Lisp_Object defalt) 2675 Lisp_Object default_)
2676 { 2676 {
2677 Lisp_Object val = external_plist_get (string_plist_ptr (s), property, 0, 2677 Lisp_Object val = external_plist_get (string_plist_ptr (s), property, 0,
2678 ERROR_ME); 2678 ERROR_ME);
2679 if (UNBOUNDP (val)) 2679 if (UNBOUNDP (val))
2680 return defalt; 2680 return default_;
2681 return val; 2681 return val;
2682 } 2682 }
2683 2683
2684 void 2684 void
2685 string_putprop (struct Lisp_String *s, Lisp_Object property, 2685 string_putprop (struct Lisp_String *s, Lisp_Object property,
2702 2702
2703 DEFUN ("get", Fget, 2, 3, 0, /* 2703 DEFUN ("get", Fget, 2, 3, 0, /*
2704 Return the value of OBJECT's PROPNAME property. 2704 Return the value of OBJECT's PROPNAME property.
2705 This is the last VALUE stored with `(put OBJECT PROPNAME VALUE)'. 2705 This is the last VALUE stored with `(put OBJECT PROPNAME VALUE)'.
2706 If there is no such property, return optional third arg DEFAULT 2706 If there is no such property, return optional third arg DEFAULT
2707 (which defaults to `nil'). OBJECT can be a symbol, face, extent, 2707 \(which defaults to `nil'). OBJECT can be a symbol, face, extent,
2708 or string. See also `put', `remprop', and `object-plist'. 2708 or string. See also `put', `remprop', and `object-plist'.
2709 */ 2709 */
2710 (object, propname, defalt)) /* Cant spel in C */ 2710 (object, propname, default_))
2711 { 2711 {
2712 Lisp_Object val; 2712 Lisp_Object val;
2713 2713
2714 /* Various places in emacs call Fget() and expect it not to quit, 2714 /* Various places in emacs call Fget() and expect it not to quit,
2715 so don't quit. */ 2715 so don't quit. */
2716 2716
2717 /* It's easiest to treat symbols specially because they may not 2717 /* It's easiest to treat symbols specially because they may not
2718 be an lrecord */ 2718 be an lrecord */
2719 if (SYMBOLP (object)) 2719 if (SYMBOLP (object))
2720 val = symbol_getprop (object, propname, defalt); 2720 val = symbol_getprop (object, propname, default_);
2721 else if (STRINGP (object)) 2721 else if (STRINGP (object))
2722 val = string_getprop (XSTRING (object), propname, defalt); 2722 val = string_getprop (XSTRING (object), propname, default_);
2723 else if (LRECORDP (object)) 2723 else if (LRECORDP (object))
2724 { 2724 {
2725 CONST struct lrecord_implementation 2725 CONST struct lrecord_implementation
2726 *imp = XRECORD_LHEADER (object)->implementation; 2726 *imp = XRECORD_LHEADER (object)->implementation;
2727 if (imp->getprop) 2727 if (imp->getprop)
2728 { 2728 {
2729 val = (imp->getprop) (object, propname); 2729 val = (imp->getprop) (object, propname);
2730 if (UNBOUNDP (val)) 2730 if (UNBOUNDP (val))
2731 val = defalt; 2731 val = default_;
2732 } 2732 }
2733 else 2733 else
2734 goto noprops; 2734 goto noprops;
2735 } 2735 }
2736 else 2736 else
2867 do_cdr: 2867 do_cdr:
2868 QUIT; 2868 QUIT;
2869 if (EQ_WITH_EBOLA_NOTICE (o1, o2)) 2869 if (EQ_WITH_EBOLA_NOTICE (o1, o2))
2870 return 1; 2870 return 1;
2871 /* Note that (equal 20 20.0) should be nil */ 2871 /* Note that (equal 20 20.0) should be nil */
2872 else if (XTYPE (o1) != XTYPE (o2)) 2872 else if (XTYPE (o1) != XTYPE (o2))
2873 return 0; 2873 return 0;
2874 else if (CONSP (o1)) 2874 else if (CONSP (o1))
2875 { 2875 {
2876 if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1)) 2876 if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1))
2877 return 0; 2877 return 0;
2881 } 2881 }
2882 2882
2883 #ifndef LRECORD_VECTOR 2883 #ifndef LRECORD_VECTOR
2884 else if (VECTORP (o1)) 2884 else if (VECTORP (o1))
2885 { 2885 {
2886 int indecks; 2886 int indice;
2887 int len = vector_length (XVECTOR (o1)); 2887 int len = XVECTOR_LENGTH (o1);
2888 if (len != vector_length (XVECTOR (o2))) 2888 if (len != XVECTOR_LENGTH (o2))
2889 return 0; 2889 return 0;
2890 for (indecks = 0; indecks < len; indecks++) 2890 for (indice = 0; indice < len; indice++)
2891 { 2891 {
2892 Lisp_Object v1, v2; 2892 Lisp_Object v1, v2;
2893 v1 = vector_data (XVECTOR (o1)) [indecks]; 2893 v1 = XVECTOR_DATA (o1) [indice];
2894 v2 = vector_data (XVECTOR (o2)) [indecks]; 2894 v2 = XVECTOR_DATA (o2) [indice];
2895 if (!internal_equal (v1, v2, depth + 1)) 2895 if (!internal_equal (v1, v2, depth + 1))
2896 return 0; 2896 return 0;
2897 } 2897 }
2898 return 1; 2898 return 1;
2899 } 2899 }
2937 do_cdr: 2937 do_cdr:
2938 QUIT; 2938 QUIT;
2939 if (HACKEQ_UNSAFE (o1, o2)) 2939 if (HACKEQ_UNSAFE (o1, o2))
2940 return 1; 2940 return 1;
2941 /* Note that (equal 20 20.0) should be nil */ 2941 /* Note that (equal 20 20.0) should be nil */
2942 else if (XTYPE (o1) != XTYPE (o2)) 2942 else if (XTYPE (o1) != XTYPE (o2))
2943 return 0; 2943 return 0;
2944 else if (CONSP (o1)) 2944 else if (CONSP (o1))
2945 { 2945 {
2946 if (!internal_old_equal (XCAR (o1), XCAR (o2), depth + 1)) 2946 if (!internal_old_equal (XCAR (o1), XCAR (o2), depth + 1))
2947 return 0; 2947 return 0;
2951 } 2951 }
2952 2952
2953 #ifndef LRECORD_VECTOR 2953 #ifndef LRECORD_VECTOR
2954 else if (VECTORP (o1)) 2954 else if (VECTORP (o1))
2955 { 2955 {
2956 int indecks; 2956 int indice;
2957 int len = vector_length (XVECTOR (o1)); 2957 int len = XVECTOR_LENGTH (o1);
2958 if (len != vector_length (XVECTOR (o2))) 2958 if (len != XVECTOR_LENGTH (o2))
2959 return 0; 2959 return 0;
2960 for (indecks = 0; indecks < len; indecks++) 2960 for (indice = 0; indice < len; indice++)
2961 { 2961 {
2962 Lisp_Object v1, v2; 2962 if (!internal_old_equal (XVECTOR_DATA (o1) [indice],
2963 v1 = vector_data (XVECTOR (o1)) [indecks]; 2963 XVECTOR_DATA (o2) [indice],
2964 v2 = vector_data (XVECTOR (o2)) [indecks]; 2964 depth + 1))
2965 if (!internal_old_equal (v1, v2, depth + 1))
2966 return 0; 2965 return 0;
2967 } 2966 }
2968 return 1; 2967 return 1;
2969 } 2968 }
2970 #endif /* !LRECORD_VECTOR */ 2969 #endif /* !LRECORD_VECTOR */
2986 return 0; 2985 return 0;
2987 else if (imp1->equal == 0) 2986 else if (imp1->equal == 0)
2988 /* EQ-ness of the objects was noticed above */ 2987 /* EQ-ness of the objects was noticed above */
2989 return 0; 2988 return 0;
2990 else 2989 else
2991 return ((imp1->equal) (o1, o2, depth)); 2990 return (imp1->equal) (o1, o2, depth);
2992 } 2991 }
2993 2992
2994 return 0; 2993 return 0;
2995 } 2994 }
2996 2995
3028 (array, item)) 3027 (array, item))
3029 { 3028 {
3030 retry: 3029 retry:
3031 if (STRINGP (array)) 3030 if (STRINGP (array))
3032 { 3031 {
3033 Charcount size; 3032 Charcount len;
3034 Charcount i; 3033 Charcount i;
3035 Emchar charval; 3034 Emchar charval;
3036 struct Lisp_String *s; 3035 struct Lisp_String *s;
3037 CHECK_CHAR_COERCE_INT (item); 3036 CHECK_CHAR_COERCE_INT (item);
3038 CHECK_IMPURE (array); 3037 CHECK_IMPURE (array);
3039 charval = XCHAR (item); 3038 charval = XCHAR (item);
3040 s = XSTRING (array); 3039 s = XSTRING (array);
3041 size = string_char_length (s); 3040 len = string_char_length (s);
3042 for (i = 0; i < size; i++) 3041 for (i = 0; i < len; i++)
3043 set_string_char (s, i, charval); 3042 set_string_char (s, i, charval);
3044 bump_string_modiff (array); 3043 bump_string_modiff (array);
3045 } 3044 }
3046 else if (VECTORP (array)) 3045 else if (VECTORP (array))
3047 { 3046 {
3048 Lisp_Object *p; 3047 Lisp_Object *p;
3049 int size; 3048 int len;
3050 int i; 3049 int i;
3051 CHECK_IMPURE (array); 3050 CHECK_IMPURE (array);
3052 size = vector_length (XVECTOR (array)); 3051 len = XVECTOR_LENGTH (array);
3053 p = vector_data (XVECTOR (array)); 3052 p = XVECTOR_DATA (array);
3054 for (i = 0; i < size; i++) 3053 for (i = 0; i < len; i++)
3055 p[i] = item; 3054 p[i] = item;
3056 } 3055 }
3057 else if (BIT_VECTORP (array)) 3056 else if (BIT_VECTORP (array))
3058 { 3057 {
3059 struct Lisp_Bit_Vector *v; 3058 struct Lisp_Bit_Vector *v;
3060 int size; 3059 int len;
3061 int i; 3060 int i;
3062 CHECK_BIT (item); 3061 CHECK_BIT (item);
3063 CHECK_IMPURE (array); 3062 CHECK_IMPURE (array);
3064 v = XBIT_VECTOR (array); 3063 v = XBIT_VECTOR (array);
3065 size = bit_vector_length (v); 3064 len = bit_vector_length (v);
3066 for (i = 0; i < size; i++) 3065 for (i = 0; i < len; i++)
3067 set_bit_vector_bit (v, i, XINT (item)); 3066 set_bit_vector_bit (v, i, XINT (item));
3068 } 3067 }
3069 else 3068 else
3070 { 3069 {
3071 array = wrong_type_argument (Qarrayp, array); 3070 array = wrong_type_argument (Qarrayp, array);
3098 in Emacs on freshly created stuff (e.g. you see the idiom 3097 in Emacs on freshly created stuff (e.g. you see the idiom
3099 nconc2 (Fcopy_sequence (foo), bar) a lot). So we help those 3098 nconc2 (Fcopy_sequence (foo), bar) a lot). So we help those
3100 callers out by protecting the args ourselves to save them 3099 callers out by protecting the args ourselves to save them
3101 a lot of temporary-variable grief. */ 3100 a lot of temporary-variable grief. */
3102 3101
3102 again:
3103
3103 GCPRO1 (args[0]); 3104 GCPRO1 (args[0]);
3104 gcpro1.nvars = nargs; 3105 gcpro1.nvars = nargs;
3105 3106
3106 val = Qnil; 3107 val = Qnil;
3107 3108
3108 for (argnum = 0; argnum < nargs; argnum++) 3109 for (argnum = 0; argnum < nargs; argnum++)
3109 { 3110 {
3110 tem = args[argnum]; 3111 tem = args[argnum];
3114 val = tem; 3115 val = tem;
3115 3116
3116 if (argnum + 1 == nargs) break; 3117 if (argnum + 1 == nargs) break;
3117 3118
3118 if (!CONSP (tem)) 3119 if (!CONSP (tem))
3119 tem = wrong_type_argument (Qlistp, tem); 3120 {
3121 tem = wrong_type_argument (Qlistp, tem);
3122 goto again;
3123 }
3120 3124
3121 while (CONSP (tem)) 3125 while (CONSP (tem))
3122 { 3126 {
3123 tail = tem; 3127 tail = tem;
3124 tem = XCDR (tail); 3128 tem = XCDR (tail);
3168 3172
3169 if (VECTORP (seq)) 3173 if (VECTORP (seq))
3170 { 3174 {
3171 for (i = 0; i < leni; i++) 3175 for (i = 0; i < leni; i++)
3172 { 3176 {
3173 dummy = vector_data (XVECTOR (seq))[i]; 3177 dummy = XVECTOR_DATA (seq)[i];
3174 result = call1 (fn, dummy); 3178 result = call1 (fn, dummy);
3175 if (vals) 3179 if (vals)
3176 vals[i] = result; 3180 vals[i] = result;
3177 } 3181 }
3178 } 3182 }
3233 mapcar1 (len, args, fn, seq); 3237 mapcar1 (len, args, fn, seq);
3234 UNGCPRO; 3238 UNGCPRO;
3235 3239
3236 for (i = len - 1; i >= 0; i--) 3240 for (i = len - 1; i >= 0; i--)
3237 args[i + i] = args[i]; 3241 args[i + i] = args[i];
3238 3242
3239 for (i = 1; i < nargs; i += 2) 3243 for (i = 1; i < nargs; i += 2)
3240 args[i] = sep; 3244 args[i] = sep;
3241 3245
3242 return Fconcat (nargs, args); 3246 return Fconcat (nargs, args);
3243 } 3247 }
3356 if (featurep_emacs_version == 0.0) 3360 if (featurep_emacs_version == 0.0)
3357 { 3361 {
3358 featurep_emacs_version = XINT (Vemacs_major_version) + 3362 featurep_emacs_version = XINT (Vemacs_major_version) +
3359 (XINT (Vemacs_minor_version) / 100.0); 3363 (XINT (Vemacs_minor_version) / 100.0);
3360 } 3364 }
3361 return (featurep_emacs_version >= d) ? Qt : Qnil; 3365 return featurep_emacs_version >= d ? Qt : Qnil;
3362 } 3366 }
3363 else if (CONSP(fexp)) 3367 else if (CONSP(fexp))
3364 { 3368 {
3365 Lisp_Object tem; 3369 Lisp_Object tem;
3366 3370