aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fns.c126
1 files changed, 74 insertions, 52 deletions
diff --git a/src/fns.c b/src/fns.c
index e75493dd334..7af6cbbed0a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5,7 +5,7 @@ This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify 6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by 7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option) 8the Free Software Foundation; either version 2, or (at your option)
9any later version. 9any later version.
10 10
11GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
@@ -879,67 +879,89 @@ internal_equal (o1, o2, depth)
879{ 879{
880 if (depth > 200) 880 if (depth > 200)
881 error ("Stack overflow in equal"); 881 error ("Stack overflow in equal");
882
882 tail_recurse: 883 tail_recurse:
883 QUIT; 884 QUIT;
884 if (EQ (o1, o2)) return 1; 885 if (EQ (o1, o2))
886 return 1;
887 if (XTYPE (o1) != XTYPE (o2))
888 return 0;
889
890 switch (XTYPE (o1))
891 {
885#ifdef LISP_FLOAT_TYPE 892#ifdef LISP_FLOAT_TYPE
886 if (FLOATP (o1) && FLOATP (o2)) 893 case Lisp_Float:
887 return (extract_float (o1) == extract_float (o2)); 894 return (extract_float (o1) == extract_float (o2));
888#endif 895#endif
889 if (XTYPE (o1) != XTYPE (o2)) return 0; 896
890 if (MISCP (o1) && XMISC (o1)->type != XMISC (o2)->type) return 0; 897 case Lisp_Cons:
891 if (CONSP (o1)) 898 {
892 { 899 if (!internal_equal (XCONS (o1)->car, XCONS (o2)->car, depth + 1))
893 if (!internal_equal (XCONS (o1)->car, XCONS (o2)->car, depth + 1)) 900 return 0;
894 return 0; 901 o1 = XCONS (o1)->cdr;
895 o1 = XCONS (o1)->cdr; 902 o2 = XCONS (o2)->cdr;
896 o2 = XCONS (o2)->cdr; 903 goto tail_recurse;
897 goto tail_recurse; 904 }
898 } 905
899 if (OVERLAYP (o1)) 906 case Lisp_Misc:
900 { 907 if (MISCP (o1) && XMISC (o1)->type != XMISC (o2)->type)
901 if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o1), depth + 1)
902 || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o1), depth + 1))
903 return 0;
904 o1 = XOVERLAY (o1)->plist;
905 o2 = XOVERLAY (o2)->plist;
906 goto tail_recurse;
907 }
908 if (MARKERP (o1))
909 {
910 return (XMARKER (o1)->buffer == XMARKER (o2)->buffer
911 && (XMARKER (o1)->buffer == 0
912 || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos));
913 }
914 if (VECTORP (o1) || COMPILEDP (o1))
915 {
916 register int index;
917 if (XVECTOR (o1)->size != XVECTOR (o2)->size)
918 return 0; 908 return 0;
919 for (index = 0; index < XVECTOR (o1)->size; index++) 909 if (OVERLAYP (o1))
920 { 910 {
921 Lisp_Object v1, v2; 911 if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o1),
922 v1 = XVECTOR (o1)->contents [index]; 912 depth + 1)
923 v2 = XVECTOR (o2)->contents [index]; 913 || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o1),
924 if (!internal_equal (v1, v2, depth + 1)) 914 depth + 1))
925 return 0; 915 return 0;
916 o1 = XOVERLAY (o1)->plist;
917 o2 = XOVERLAY (o2)->plist;
918 goto tail_recurse;
926 } 919 }
927 return 1; 920 if (MARKERP (o1))
928 } 921 {
929 if (STRINGP (o1)) 922 return (XMARKER (o1)->buffer == XMARKER (o2)->buffer
930 { 923 && (XMARKER (o1)->buffer == 0
931 if (XSTRING (o1)->size != XSTRING (o2)->size) 924 || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos));
932 return 0; 925 }
933 if (bcmp (XSTRING (o1)->data, XSTRING (o2)->data, XSTRING (o1)->size)) 926 break;
934 return 0; 927
928 case Lisp_Vectorlike:
929 if ((VECTORP (o1) && VECTORP (o2))
930 ||
931 (COMPILEDP (o1) && COMPILEDP (o2)))
932 {
933 register int index;
934 if (XVECTOR (o1)->size != XVECTOR (o2)->size)
935 return 0;
936 for (index = 0; index < XVECTOR (o1)->size; index++)
937 {
938 Lisp_Object v1, v2;
939 v1 = XVECTOR (o1)->contents [index];
940 v2 = XVECTOR (o2)->contents [index];
941 if (!internal_equal (v1, v2, depth + 1))
942 return 0;
943 }
944 return 1;
945 }
946 break;
947
948 case Lisp_String:
949 if (STRINGP (o1))
950 {
951 if (XSTRING (o1)->size != XSTRING (o2)->size)
952 return 0;
953 if (bcmp (XSTRING (o1)->data, XSTRING (o2)->data,
954 XSTRING (o1)->size))
955 return 0;
935#ifdef USE_TEXT_PROPERTIES 956#ifdef USE_TEXT_PROPERTIES
936 /* If the strings have intervals, verify they match; 957 /* If the strings have intervals, verify they match;
937 if not, they are unequal. */ 958 if not, they are unequal. */
938 if ((XSTRING (o1)->intervals != 0 || XSTRING (o2)->intervals != 0) 959 if ((XSTRING (o1)->intervals != 0 || XSTRING (o2)->intervals != 0)
939 && ! compare_string_intervals (o1, o2)) 960 && ! compare_string_intervals (o1, o2))
940 return 0; 961 return 0;
941#endif 962#endif
942 return 1; 963 return 1;
964 }
943 } 965 }
944 return 0; 966 return 0;
945} 967}