comparison src/fns.c @ 454:d7a9135ec789 r21-2-42

Import from CVS: tag r21-2-42
author cvs
date Mon, 13 Aug 2007 11:40:54 +0200
parents 576fb035e263
children e7ef97881643
comparison
equal deleted inserted replaced
453:270b05afd845 454:d7a9135ec789
54 54
55 Lisp_Object Qstring_lessp; 55 Lisp_Object Qstring_lessp;
56 Lisp_Object Qidentity; 56 Lisp_Object Qidentity;
57 57
58 static int internal_old_equal (Lisp_Object, Lisp_Object, int); 58 static int internal_old_equal (Lisp_Object, Lisp_Object, int);
59 Lisp_Object safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth);
59 60
60 static Lisp_Object 61 static Lisp_Object
61 mark_bit_vector (Lisp_Object obj) 62 mark_bit_vector (Lisp_Object obj)
62 { 63 {
63 return Qnil; 64 return Qnil;
861 Second arg VECP causes vectors to be copied, too. Strings and bit vectors 862 Second arg VECP causes vectors to be copied, too. Strings and bit vectors
862 are not copied. 863 are not copied.
863 */ 864 */
864 (arg, vecp)) 865 (arg, vecp))
865 { 866 {
867 return safe_copy_tree (arg, vecp, 0);
868 }
869
870 Lisp_Object
871 safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth)
872 {
873 if (depth > 200)
874 signal_simple_error ("Stack overflow in copy-tree", arg);
875
866 if (CONSP (arg)) 876 if (CONSP (arg))
867 { 877 {
868 Lisp_Object rest; 878 Lisp_Object rest;
869 rest = arg = Fcopy_sequence (arg); 879 rest = arg = Fcopy_sequence (arg);
870 while (CONSP (rest)) 880 while (CONSP (rest))
871 { 881 {
872 Lisp_Object elt = XCAR (rest); 882 Lisp_Object elt = XCAR (rest);
873 QUIT; 883 QUIT;
874 if (CONSP (elt) || VECTORP (elt)) 884 if (CONSP (elt) || VECTORP (elt))
875 XCAR (rest) = Fcopy_tree (elt, vecp); 885 XCAR (rest) = safe_copy_tree (elt, vecp, depth + 1);
876 if (VECTORP (XCDR (rest))) /* hack for (a b . [c d]) */ 886 if (VECTORP (XCDR (rest))) /* hack for (a b . [c d]) */
877 XCDR (rest) = Fcopy_tree (XCDR (rest), vecp); 887 XCDR (rest) = safe_copy_tree (XCDR (rest), vecp, depth +1);
878 rest = XCDR (rest); 888 rest = XCDR (rest);
879 } 889 }
880 } 890 }
881 else if (VECTORP (arg) && ! NILP (vecp)) 891 else if (VECTORP (arg) && ! NILP (vecp))
882 { 892 {
886 for (j = 0; j < i; j++) 896 for (j = 0; j < i; j++)
887 { 897 {
888 Lisp_Object elt = XVECTOR_DATA (arg) [j]; 898 Lisp_Object elt = XVECTOR_DATA (arg) [j];
889 QUIT; 899 QUIT;
890 if (CONSP (elt) || VECTORP (elt)) 900 if (CONSP (elt) || VECTORP (elt))
891 XVECTOR_DATA (arg) [j] = Fcopy_tree (elt, vecp); 901 XVECTOR_DATA (arg) [j] = safe_copy_tree (elt, vecp, depth + 1);
892 } 902 }
893 } 903 }
894 return arg; 904 return arg;
895 } 905 }
896 906