Mercurial > emacs
comparison src/fns.c @ 10405:609f34c0c7bc
(internal_equal): Once again use a switch.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 12 Jan 1995 21:01:31 +0000 |
parents | 9dd21ecf6b0f |
children | b3c03881e6f6 |
comparison
equal
deleted
inserted
replaced
10404:631f1dac6f7a | 10405:609f34c0c7bc |
---|---|
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 1, or (at your option) | 8 the Free Software Foundation; either version 2, or (at your option) |
9 any later version. | 9 any later version. |
10 | 10 |
11 GNU Emacs is distributed in the hope that it will be useful, | 11 GNU Emacs is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
877 register Lisp_Object o1, o2; | 877 register Lisp_Object o1, o2; |
878 int depth; | 878 int 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; |
901 o1 = XCONS (o1)->cdr; | |
902 o2 = XCONS (o2)->cdr; | |
903 goto tail_recurse; | |
904 } | |
905 | |
906 case Lisp_Misc: | |
907 if (MISCP (o1) && XMISC (o1)->type != XMISC (o2)->type) | |
894 return 0; | 908 return 0; |
895 o1 = XCONS (o1)->cdr; | 909 if (OVERLAYP (o1)) |
896 o2 = XCONS (o2)->cdr; | 910 { |
897 goto tail_recurse; | 911 if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o1), |
898 } | 912 depth + 1) |
899 if (OVERLAYP (o1)) | 913 || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o1), |
900 { | 914 depth + 1)) |
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; | |
919 for (index = 0; index < XVECTOR (o1)->size; index++) | |
920 { | |
921 Lisp_Object v1, v2; | |
922 v1 = XVECTOR (o1)->contents [index]; | |
923 v2 = XVECTOR (o2)->contents [index]; | |
924 if (!internal_equal (v1, v2, depth + 1)) | |
925 return 0; | 915 return 0; |
926 } | 916 o1 = XOVERLAY (o1)->plist; |
927 return 1; | 917 o2 = XOVERLAY (o2)->plist; |
928 } | 918 goto tail_recurse; |
929 if (STRINGP (o1)) | 919 } |
930 { | 920 if (MARKERP (o1)) |
931 if (XSTRING (o1)->size != XSTRING (o2)->size) | 921 { |
932 return 0; | 922 return (XMARKER (o1)->buffer == XMARKER (o2)->buffer |
933 if (bcmp (XSTRING (o1)->data, XSTRING (o2)->data, XSTRING (o1)->size)) | 923 && (XMARKER (o1)->buffer == 0 |
934 return 0; | 924 || XMARKER (o1)->bufpos == XMARKER (o2)->bufpos)); |
925 } | |
926 break; | |
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 } |
946 | 968 |
947 DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, | 969 DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, |