diff options
| author | Karl Heuer | 1994-11-15 02:05:04 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-11-15 02:05:04 +0000 |
| commit | 6cb9cafb122bed8ba17617c6890dad6d55e0723c (patch) | |
| tree | f7038859a850b71bea8ab6b92ed8593b1843c826 /src | |
| parent | e202fa3405af38c0dd70f4146d8b796c86df3328 (diff) | |
| download | emacs-6cb9cafb122bed8ba17617c6890dad6d55e0723c.tar.gz emacs-6cb9cafb122bed8ba17617c6890dad6d55e0723c.zip | |
(internal_equal): Use new overlay substructure.
Simplify by returning int.
(Fequal): Use new interface to internal_equal.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 61 |
1 files changed, 34 insertions, 27 deletions
| @@ -37,7 +37,7 @@ extern Lisp_Object Flookup_key (); | |||
| 37 | Lisp_Object Qstring_lessp, Qprovide, Qrequire; | 37 | Lisp_Object Qstring_lessp, Qprovide, Qrequire; |
| 38 | Lisp_Object Qyes_or_no_p_history; | 38 | Lisp_Object Qyes_or_no_p_history; |
| 39 | 39 | ||
| 40 | static Lisp_Object internal_equal (); | 40 | static int internal_equal (); |
| 41 | 41 | ||
| 42 | DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, | 42 | DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, |
| 43 | "Return the argument unchanged.") | 43 | "Return the argument unchanged.") |
| @@ -868,65 +868,72 @@ Symbols must match exactly.") | |||
| 868 | (o1, o2) | 868 | (o1, o2) |
| 869 | register Lisp_Object o1, o2; | 869 | register Lisp_Object o1, o2; |
| 870 | { | 870 | { |
| 871 | return internal_equal (o1, o2, 0); | 871 | return internal_equal (o1, o2, 0) ? Qt : Qnil; |
| 872 | } | 872 | } |
| 873 | 873 | ||
| 874 | static Lisp_Object | 874 | static int |
| 875 | internal_equal (o1, o2, depth) | 875 | internal_equal (o1, o2, depth) |
| 876 | register Lisp_Object o1, o2; | 876 | register Lisp_Object o1, o2; |
| 877 | int depth; | 877 | int depth; |
| 878 | { | 878 | { |
| 879 | if (depth > 200) | 879 | if (depth > 200) |
| 880 | error ("Stack overflow in equal"); | 880 | error ("Stack overflow in equal"); |
| 881 | do_cdr: | 881 | tail_recurse: |
| 882 | QUIT; | 882 | QUIT; |
| 883 | if (EQ (o1, o2)) return Qt; | 883 | if (EQ (o1, o2)) return 1; |
| 884 | #ifdef LISP_FLOAT_TYPE | 884 | #ifdef LISP_FLOAT_TYPE |
| 885 | if (FLOATP (o1) && FLOATP (o2)) | 885 | if (FLOATP (o1) && FLOATP (o2)) |
| 886 | return (extract_float (o1) == extract_float (o2)) ? Qt : Qnil; | 886 | return (extract_float (o1) == extract_float (o2)); |
| 887 | #endif | 887 | #endif |
| 888 | if (XTYPE (o1) != XTYPE (o2)) return Qnil; | 888 | if (XTYPE (o1) != XTYPE (o2)) return 0; |
| 889 | if (MISCP (o1) && XMISC (o1)->type != XMISC (o2)->type) return Qnil; | 889 | if (MISCP (o1) && XMISC (o1)->type != XMISC (o2)->type) return 0; |
| 890 | if (CONSP (o1) || OVERLAYP (o1)) | 890 | if (CONSP (o1)) |
| 891 | { | ||
| 892 | if (!internal_equal (XCONS (o1)->car, XCONS (o2)->car, depth + 1)) | ||
| 893 | return 0; | ||
| 894 | o1 = XCONS (o1)->cdr; | ||
| 895 | o2 = XCONS (o2)->cdr; | ||
| 896 | goto tail_recurse; | ||
| 897 | } | ||
| 898 | if (OVERLAYP (o1)) | ||
| 891 | { | 899 | { |
| 892 | Lisp_Object v1; | 900 | if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o1), depth + 1) |
| 893 | v1 = internal_equal (Fcar (o1), Fcar (o2), depth + 1); | 901 | || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o1), depth + 1)) |
| 894 | if (NILP (v1)) | 902 | return 0; |
| 895 | return v1; | 903 | o1 = XOVERLAY (o1)->plist; |
| 896 | o1 = Fcdr (o1), o2 = Fcdr (o2); | 904 | o2 = XOVERLAY (o2)->plist; |
| 897 | goto do_cdr; | 905 | goto tail_recurse; |
| 898 | } | 906 | } |
| 899 | if (MARKERP (o1)) | 907 | if (MARKERP (o1)) |
| 900 | { | 908 | { |
| 901 | return ((XMARKER (o1)->buffer == XMARKER (o2)->buffer | 909 | return (XMARKER (o1)->buffer == XMARKER (o2)->buffer |
| 902 | && (XMARKER (o1)->buffer == 0 | 910 | && (XMARKER (o1)->buffer == 0 |
| 903 | || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos)) | 911 | || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos)); |
| 904 | ? Qt : Qnil); | ||
| 905 | } | 912 | } |
| 906 | if (VECTORP (o1) || COMPILEDP (o1)) | 913 | if (VECTORP (o1) || COMPILEDP (o1)) |
| 907 | { | 914 | { |
| 908 | register int index; | 915 | register int index; |
| 909 | if (XVECTOR (o1)->size != XVECTOR (o2)->size) | 916 | if (XVECTOR (o1)->size != XVECTOR (o2)->size) |
| 910 | return Qnil; | 917 | return 0; |
| 911 | for (index = 0; index < XVECTOR (o1)->size; index++) | 918 | for (index = 0; index < XVECTOR (o1)->size; index++) |
| 912 | { | 919 | { |
| 913 | Lisp_Object v, v1, v2; | 920 | Lisp_Object v1, v2; |
| 914 | v1 = XVECTOR (o1)->contents [index]; | 921 | v1 = XVECTOR (o1)->contents [index]; |
| 915 | v2 = XVECTOR (o2)->contents [index]; | 922 | v2 = XVECTOR (o2)->contents [index]; |
| 916 | v = internal_equal (v1, v2, depth + 1); | 923 | if (!internal_equal (v1, v2, depth + 1)) |
| 917 | if (NILP (v)) return v; | 924 | return 0; |
| 918 | } | 925 | } |
| 919 | return Qt; | 926 | return 1; |
| 920 | } | 927 | } |
| 921 | if (STRINGP (o1)) | 928 | if (STRINGP (o1)) |
| 922 | { | 929 | { |
| 923 | if (XSTRING (o1)->size != XSTRING (o2)->size) | 930 | if (XSTRING (o1)->size != XSTRING (o2)->size) |
| 924 | return Qnil; | 931 | return 0; |
| 925 | if (bcmp (XSTRING (o1)->data, XSTRING (o2)->data, XSTRING (o1)->size)) | 932 | if (bcmp (XSTRING (o1)->data, XSTRING (o2)->data, XSTRING (o1)->size)) |
| 926 | return Qnil; | 933 | return 0; |
| 927 | return Qt; | 934 | return 1; |
| 928 | } | 935 | } |
| 929 | return Qnil; | 936 | return 0; |
| 930 | } | 937 | } |
| 931 | 938 | ||
| 932 | DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, | 939 | DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, |