Mercurial > hg > xemacs-beta
comparison src/fns.c @ 16:0293115a14e9 r19-15b91
Import from CVS: tag r19-15b91
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:49:20 +0200 |
parents | 9ee227acff29 |
children | 859a2309aef8 |
comparison
equal
deleted
inserted
replaced
15:ad457d5f7d04 | 16:0293115a14e9 |
---|---|
1842 This function does order-insensitive comparisons of the property lists: | 1842 This function does order-insensitive comparisons of the property lists: |
1843 For example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal. | 1843 For example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal. |
1844 Comparison between values is done using `eq'. See also `plists-equal'. | 1844 Comparison between values is done using `eq'. See also `plists-equal'. |
1845 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 1845 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
1846 a nil value is ignored. This feature is a virus that has infected | 1846 a nil value is ignored. This feature is a virus that has infected |
1847 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 1847 old Lisp implementations, but should not be used except for backward |
1848 old Lisps), but should not be used except for backward compatibility. | 1848 compatibility. |
1849 */ ) | 1849 */ ) |
1850 (a, b, nil_means_not_present) | 1850 (a, b, nil_means_not_present) |
1851 Lisp_Object a, b, nil_means_not_present; | 1851 Lisp_Object a, b, nil_means_not_present; |
1852 { | 1852 { |
1853 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, -1) | 1853 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, -1) |
1860 function does order-insensitive comparisons of the property lists: For | 1860 function does order-insensitive comparisons of the property lists: For |
1861 example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal. | 1861 example, the property lists '(a 1 b 2) and '(b 2 a 1) are equal. |
1862 Comparison between values is done using `equal'. See also `plists-eq'. | 1862 Comparison between values is done using `equal'. See also `plists-eq'. |
1863 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 1863 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
1864 a nil value is ignored. This feature is a virus that has infected | 1864 a nil value is ignored. This feature is a virus that has infected |
1865 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 1865 old Lisp implementations, but should not be used except for backward |
1866 old Lisps), but should not be used except for backward compatibility. | 1866 compatibility. |
1867 */ ) | 1867 */ ) |
1868 (a, b, nil_means_not_present) | 1868 (a, b, nil_means_not_present) |
1869 Lisp_Object a, b, nil_means_not_present; | 1869 Lisp_Object a, b, nil_means_not_present; |
1870 { | 1870 { |
1871 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, 1) | 1871 return (plists_differ (a, b, !NILP (nil_means_not_present), 0, 1) |
1881 Comparison between values is done using `eq'. See also `plists-equal'. | 1881 Comparison between values is done using `eq'. See also `plists-equal'. |
1882 A lax property list is like a regular one except that comparisons between | 1882 A lax property list is like a regular one except that comparisons between |
1883 keywords is done using `equal' instead of `eq'. | 1883 keywords is done using `equal' instead of `eq'. |
1884 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 1884 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
1885 a nil value is ignored. This feature is a virus that has infected | 1885 a nil value is ignored. This feature is a virus that has infected |
1886 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 1886 old Lisp implementations, but should not be used except for backward |
1887 old Lisps), but should not be used except for backward compatibility. | 1887 compatibility. |
1888 */ ) | 1888 */ ) |
1889 (a, b, nil_means_not_present) | 1889 (a, b, nil_means_not_present) |
1890 Lisp_Object a, b, nil_means_not_present; | 1890 Lisp_Object a, b, nil_means_not_present; |
1891 { | 1891 { |
1892 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, -1) | 1892 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, -1) |
1901 Comparison between values is done using `equal'. See also `plists-eq'. | 1901 Comparison between values is done using `equal'. See also `plists-eq'. |
1902 A lax property list is like a regular one except that comparisons between | 1902 A lax property list is like a regular one except that comparisons between |
1903 keywords is done using `equal' instead of `eq'. | 1903 keywords is done using `equal' instead of `eq'. |
1904 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 1904 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
1905 a nil value is ignored. This feature is a virus that has infected | 1905 a nil value is ignored. This feature is a virus that has infected |
1906 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 1906 old Lisp implementations, but should not be used except for backward |
1907 old Lisps), but should not be used except for backward compatibility. | 1907 compatibility. |
1908 */ ) | 1908 */ ) |
1909 (a, b, nil_means_not_present) | 1909 (a, b, nil_means_not_present) |
1910 Lisp_Object a, b, nil_means_not_present; | 1910 Lisp_Object a, b, nil_means_not_present; |
1911 { | 1911 { |
1912 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, 1) | 1912 return (plists_differ (a, b, !NILP (nil_means_not_present), 1, 1) |
2331 Destructively remove any duplicate entries from a plist. | 2331 Destructively remove any duplicate entries from a plist. |
2332 In such cases, the first entry applies. | 2332 In such cases, the first entry applies. |
2333 | 2333 |
2334 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 2334 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
2335 a nil value is removed. This feature is a virus that has infected | 2335 a nil value is removed. This feature is a virus that has infected |
2336 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 2336 old Lisp implementations, but should not be used except for backward |
2337 old Lisps), but should not be used except for backward compatibility. | 2337 compatibility. |
2338 | 2338 |
2339 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the | 2339 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the |
2340 return value may not be EQ to the passed-in value, so make sure to | 2340 return value may not be EQ to the passed-in value, so make sure to |
2341 `setq' the value back into where it came from. | 2341 `setq' the value back into where it came from. |
2342 */ ) | 2342 */ ) |
2437 Destructively remove any duplicate entries from a lax plist. | 2437 Destructively remove any duplicate entries from a lax plist. |
2438 In such cases, the first entry applies. | 2438 In such cases, the first entry applies. |
2439 | 2439 |
2440 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with | 2440 If optional arg NIL-MEANS-NOT-PRESENT is non-nil, then a property with |
2441 a nil value is removed. This feature is a virus that has infected | 2441 a nil value is removed. This feature is a virus that has infected |
2442 old Lisp implementations (and thus E-Lisp, due to RMS's enamorment with | 2442 old Lisp implementations, but should not be used except for backward |
2443 old Lisps), but should not be used except for backward compatibility. | 2443 compatibility. |
2444 | 2444 |
2445 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the | 2445 The new plist is returned. If NIL-MEANS-NOT-PRESENT is given, the |
2446 return value may not be EQ to the passed-in value, so make sure to | 2446 return value may not be EQ to the passed-in value, so make sure to |
2447 `setq' the value back into where it came from. | 2447 `setq' the value back into where it came from. |
2448 */ ) | 2448 */ ) |
3030 Thus, \" \" as SEP results in spaces between the values returned by FN. | 3030 Thus, \" \" as SEP results in spaces between the values returned by FN. |
3031 */ ) | 3031 */ ) |
3032 (fn, seq, sep) | 3032 (fn, seq, sep) |
3033 Lisp_Object fn, seq, sep; | 3033 Lisp_Object fn, seq, sep; |
3034 { | 3034 { |
3035 Lisp_Object len; | 3035 int len = XINT (Flength (seq)); |
3036 int leni; | |
3037 int nargs; | 3036 int nargs; |
3038 Lisp_Object *args; | 3037 Lisp_Object *args; |
3039 int i; | 3038 int i; |
3040 struct gcpro gcpro1; | 3039 struct gcpro gcpro1; |
3041 | 3040 |
3042 len = Flength (seq); | 3041 nargs = len + len - 1; |
3043 leni = XINT (len); | |
3044 nargs = leni + leni - 1; | |
3045 if (nargs < 0) return build_string (""); | 3042 if (nargs < 0) return build_string (""); |
3046 | 3043 |
3047 args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); | 3044 args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); |
3048 | 3045 |
3049 GCPRO1 (sep); | 3046 GCPRO1 (sep); |
3050 mapcar1 (leni, args, fn, seq); | 3047 mapcar1 (len, args, fn, seq); |
3051 UNGCPRO; | 3048 UNGCPRO; |
3052 | 3049 |
3053 for (i = leni - 1; i >= 0; i--) | 3050 for (i = len - 1; i >= 0; i--) |
3054 args[i + i] = args[i]; | 3051 args[i + i] = args[i]; |
3055 | 3052 |
3056 for (i = 1; i < nargs; i += 2) | 3053 for (i = 1; i < nargs; i += 2) |
3057 args[i] = sep; | 3054 args[i] = sep; |
3058 | 3055 |
3065 SEQUENCE may be a list, a vector, a bit vector, or a string. | 3062 SEQUENCE may be a list, a vector, a bit vector, or a string. |
3066 */ ) | 3063 */ ) |
3067 (fn, seq) | 3064 (fn, seq) |
3068 Lisp_Object fn, seq; | 3065 Lisp_Object fn, seq; |
3069 { | 3066 { |
3070 Lisp_Object len; | 3067 int len = XINT (Flength (seq)); |
3071 int leni; | 3068 Lisp_Object *args = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
3072 Lisp_Object *args; | 3069 |
3073 | 3070 mapcar1 (len, args, fn, seq); |
3074 len = Flength (seq); | 3071 |
3075 leni = XINT (len); | 3072 return Flist (len, args); |
3076 args = (Lisp_Object *) alloca (leni * sizeof (Lisp_Object)); | |
3077 | |
3078 mapcar1 (leni, args, fn, seq); | |
3079 | |
3080 return Flist (leni, args); | |
3081 } | 3073 } |
3082 | 3074 |
3083 DEFUN ("mapc-internal", Fmapc_internal, Smapc_internal, 2, 2, 0 /* | 3075 DEFUN ("mapc-internal", Fmapc_internal, Smapc_internal, 2, 2, 0 /* |
3084 Apply FUNCTION to each element of SEQUENCE. | 3076 Apply FUNCTION to each element of SEQUENCE. |
3085 SEQUENCE may be a list, a vector, a bit vector, or a string. | 3077 SEQUENCE may be a list, a vector, a bit vector, or a string. |
3087 which is more efficient if you do not use the results. | 3079 which is more efficient if you do not use the results. |
3088 */ ) | 3080 */ ) |
3089 (fn, seq) | 3081 (fn, seq) |
3090 Lisp_Object fn, seq; | 3082 Lisp_Object fn, seq; |
3091 { | 3083 { |
3092 Lisp_Object len; | 3084 mapcar1 (XINT (Flength (seq)), 0, fn, seq); |
3093 int leni; | |
3094 | |
3095 len = Flength (seq); | |
3096 leni = XINT (len); | |
3097 | |
3098 mapcar1 (leni, 0, fn, seq); | |
3099 | 3085 |
3100 return Qnil; | 3086 return Qnil; |
3101 } | 3087 } |
3102 | 3088 |
3103 | 3089 |
3143 This function looks at the value of the variable `features'. | 3129 This function looks at the value of the variable `features'. |
3144 */ ) | 3130 */ ) |
3145 (feature) | 3131 (feature) |
3146 Lisp_Object feature; | 3132 Lisp_Object feature; |
3147 { | 3133 { |
3148 Lisp_Object tem; | |
3149 CHECK_SYMBOL (feature); | 3134 CHECK_SYMBOL (feature); |
3150 tem = Fmemq (feature, Vfeatures); | 3135 return NILP (Fmemq (feature, Vfeatures)) ? Qnil : Qt; |
3151 return (NILP (tem)) ? Qnil : Qt; | |
3152 } | 3136 } |
3153 | 3137 |
3154 DEFUN ("provide", Fprovide, Sprovide, 1, 1, 0 /* | 3138 DEFUN ("provide", Fprovide, Sprovide, 1, 1, 0 /* |
3155 Announce that FEATURE is a feature of the current Emacs. | 3139 Announce that FEATURE is a feature of the current Emacs. |
3156 This function updates the value of the variable `features'. | 3140 This function updates the value of the variable `features'. |