aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-12-30 06:50:01 +0000
committerRichard M. Stallman1994-12-30 06:50:01 +0000
commitca0569ad39d56be9edb911d93b741e33d5f71c98 (patch)
treec35e43ca1ff02a987f3f3d2c3d87106668fe9663 /src
parent7c06ac2bfaa05716f686104c58906c412958b463 (diff)
downloademacs-ca0569ad39d56be9edb911d93b741e33d5f71c98.tar.gz
emacs-ca0569ad39d56be9edb911d93b741e33d5f71c98.zip
(print): Get size of compiled function as pseudovector.
Use a switch statement again.
Diffstat (limited to 'src')
-rw-r--r--src/print.c303
1 files changed, 161 insertions, 142 deletions
diff --git a/src/print.c b/src/print.c
index 416cd32ce1b..cb0b6c9fb70 100644
--- a/src/print.c
+++ b/src/print.c
@@ -745,22 +745,25 @@ print (obj, printcharfun, escapeflag)
745 } 745 }
746#endif /* MAX_PRINT_CHARS */ 746#endif /* MAX_PRINT_CHARS */
747 747
748 if (INTEGERP (obj)) 748 switch (XGCTYPE (obj))
749 { 749 {
750 case Lisp_Int:
750 sprintf (buf, "%d", XINT (obj)); 751 sprintf (buf, "%d", XINT (obj));
751 strout (buf, -1, printcharfun); 752 strout (buf, -1, printcharfun);
752 } 753 break;
754
753#ifdef LISP_FLOAT_TYPE 755#ifdef LISP_FLOAT_TYPE
754 else if (FLOATP (obj)) 756 case Lisp_Float:
755 { 757 {
756 char pigbuf[350]; /* see comments in float_to_string */ 758 char pigbuf[350]; /* see comments in float_to_string */
757 759
758 float_to_string (pigbuf, XFLOAT(obj)->data); 760 float_to_string (pigbuf, XFLOAT(obj)->data);
759 strout (pigbuf, -1, printcharfun); 761 strout (pigbuf, -1, printcharfun);
760 } 762 }
763 break;
761#endif 764#endif
762 else if (STRINGP (obj)) 765
763 { 766 case Lisp_String:
764 if (!escapeflag) 767 if (!escapeflag)
765 print_string (obj, printcharfun); 768 print_string (obj, printcharfun);
766 else 769 else
@@ -814,41 +817,43 @@ print (obj, printcharfun, escapeflag)
814 817
815 UNGCPRO; 818 UNGCPRO;
816 } 819 }
817 } 820 break;
818 else if (SYMBOLP (obj))
819 {
820 register int confusing;
821 register unsigned char *p = XSYMBOL (obj)->name->data;
822 register unsigned char *end = p + XSYMBOL (obj)->name->size;
823 register unsigned char c;
824
825 if (p != end && (*p == '-' || *p == '+')) p++;
826 if (p == end)
827 confusing = 0;
828 else
829 {
830 while (p != end && *p >= '0' && *p <= '9')
831 p++;
832 confusing = (end == p);
833 }
834 821
835 p = XSYMBOL (obj)->name->data; 822 case Lisp_Symbol:
836 while (p != end) 823 {
837 { 824 register int confusing;
838 QUIT; 825 register unsigned char *p = XSYMBOL (obj)->name->data;
839 c = *p++; 826 register unsigned char *end = p + XSYMBOL (obj)->name->size;
840 if (escapeflag) 827 register unsigned char c;
841 { 828
842 if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' || 829 if (p != end && (*p == '-' || *p == '+')) p++;
843 c == '(' || c == ')' || c == ',' || c =='.' || c == '`' || 830 if (p == end)
844 c == '[' || c == ']' || c == '?' || c <= 040 || confusing) 831 confusing = 0;
845 PRINTCHAR ('\\'), confusing = 0; 832 else
846 } 833 {
847 PRINTCHAR (c); 834 while (p != end && *p >= '0' && *p <= '9')
848 } 835 p++;
849 } 836 confusing = (end == p);
850 else if (CONSP (obj)) 837 }
851 { 838
839 p = XSYMBOL (obj)->name->data;
840 while (p != end)
841 {
842 QUIT;
843 c = *p++;
844 if (escapeflag)
845 {
846 if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' ||
847 c == '(' || c == ')' || c == ',' || c =='.' || c == '`' ||
848 c == '[' || c == ']' || c == '?' || c <= 040 || confusing)
849 PRINTCHAR ('\\'), confusing = 0;
850 }
851 PRINTCHAR (c);
852 }
853 }
854 break;
855
856 case Lisp_Cons:
852 /* If deeper than spec'd depth, print placeholder. */ 857 /* If deeper than spec'd depth, print placeholder. */
853 if (INTEGERP (Vprint_level) 858 if (INTEGERP (Vprint_level)
854 && print_depth > XINT (Vprint_level)) 859 && print_depth > XINT (Vprint_level))
@@ -885,27 +890,82 @@ print (obj, printcharfun, escapeflag)
885 } 890 }
886 PRINTCHAR (')'); 891 PRINTCHAR (')');
887 } 892 }
888 } 893 break;
889 else if (COMPILEDP (obj) || VECTORP (obj)) 894
890 { 895 case Lisp_Vectorlike:
891 if (COMPILEDP (obj)) 896 if (PROCESSP (obj))
892 PRINTCHAR ('#'); 897 {
893 PRINTCHAR ('['); 898 if (escapeflag)
894 { 899 {
895 register int i; 900 strout ("#<process ", -1, printcharfun);
896 register Lisp_Object tem; 901 print_string (XPROCESS (obj)->name, printcharfun);
897 for (i = 0; i < XVECTOR (obj)->size; i++) 902 PRINTCHAR ('>');
903 }
904 else
905 print_string (XPROCESS (obj)->name, printcharfun);
906 }
907 else if (SUBRP (obj))
908 {
909 strout ("#<subr ", -1, printcharfun);
910 strout (XSUBR (obj)->symbol_name, -1, printcharfun);
911 PRINTCHAR ('>');
912 }
913#ifndef standalone
914 else if (WINDOWP (obj))
915 {
916 strout ("#<window ", -1, printcharfun);
917 sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number));
918 strout (buf, -1, printcharfun);
919 if (!NILP (XWINDOW (obj)->buffer))
920 {
921 strout (" on ", -1, printcharfun);
922 print_string (XBUFFER (XWINDOW (obj)->buffer)->name, printcharfun);
923 }
924 PRINTCHAR ('>');
925 }
926 else if (WINDOW_CONFIGURATIONP (obj))
927 {
928 strout ("#<window-configuration>", -1, printcharfun);
929 }
930#ifdef MULTI_FRAME
931 else if (FRAMEP (obj))
932 {
933 strout ((FRAME_LIVE_P (XFRAME (obj))
934 ? "#<frame " : "#<dead frame "),
935 -1, printcharfun);
936 print_string (XFRAME (obj)->name, printcharfun);
937 sprintf (buf, " 0x%lx", (unsigned long) (XFRAME (obj)));
938 strout (buf, -1, printcharfun);
939 PRINTCHAR ('>');
940 }
941#endif
942#endif /* not standalone */
943 else
944 {
945 int size = XVECTOR (obj)->size;
946 if (COMPILEDP (obj))
947 {
948 PRINTCHAR ('#');
949 size &= PSEUDOVECTOR_SIZE_MASK;
950 }
951
952 PRINTCHAR ('[');
898 { 953 {
899 if (i) PRINTCHAR (' '); 954 register int i;
900 tem = XVECTOR (obj)->contents[i]; 955 register Lisp_Object tem;
901 print (tem, printcharfun, escapeflag); 956 for (i = 0; i < size; i++)
957 {
958 if (i) PRINTCHAR (' ');
959 tem = XVECTOR (obj)->contents[i];
960 print (tem, printcharfun, escapeflag);
961 }
902 } 962 }
903 } 963 PRINTCHAR (']');
904 PRINTCHAR (']'); 964 }
905 } 965 break;
966
906#ifndef standalone 967#ifndef standalone
907 else if (BUFFERP (obj)) 968 case Lisp_Buffer:
908 {
909 if (NILP (XBUFFER (obj)->name)) 969 if (NILP (XBUFFER (obj)->name))
910 strout ("#<killed buffer>", -1, printcharfun); 970 strout ("#<killed buffer>", -1, printcharfun);
911 else if (escapeflag) 971 else if (escapeflag)
@@ -916,92 +976,51 @@ print (obj, printcharfun, escapeflag)
916 } 976 }
917 else 977 else
918 print_string (XBUFFER (obj)->name, printcharfun); 978 print_string (XBUFFER (obj)->name, printcharfun);
919 } 979 break;
920 else if (PROCESSP (obj)) 980
921 { 981 case Lisp_Misc:
922 if (escapeflag) 982 if (MARKERP (obj))
923 { 983 {
924 strout ("#<process ", -1, printcharfun); 984 strout ("#<marker ", -1, printcharfun);
925 print_string (XPROCESS (obj)->name, printcharfun); 985 if (!(XMARKER (obj)->buffer))
986 strout ("in no buffer", -1, printcharfun);
987 else
988 {
989 sprintf (buf, "at %d", marker_position (obj));
990 strout (buf, -1, printcharfun);
991 strout (" in ", -1, printcharfun);
992 print_string (XMARKER (obj)->buffer->name, printcharfun);
993 }
926 PRINTCHAR ('>'); 994 PRINTCHAR ('>');
927 } 995 }
928 else 996 else if (OVERLAYP (obj))
929 print_string (XPROCESS (obj)->name, printcharfun);
930 }
931 else if (WINDOWP (obj))
932 {
933 strout ("#<window ", -1, printcharfun);
934 sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number));
935 strout (buf, -1, printcharfun);
936 if (!NILP (XWINDOW (obj)->buffer))
937 { 997 {
938 strout (" on ", -1, printcharfun); 998 strout ("#<overlay ", -1, printcharfun);
939 print_string (XBUFFER (XWINDOW (obj)->buffer)->name, printcharfun); 999 if (!(XMARKER (OVERLAY_START (obj))->buffer))
940 } 1000 strout ("in no buffer", -1, printcharfun);
941 PRINTCHAR ('>'); 1001 else
942 } 1002 {
943 else if (WINDOW_CONFIGURATIONP (obj)) 1003 sprintf (buf, "from %d to %d in ",
944 { 1004 marker_position (OVERLAY_START (obj)),
945 strout ("#<window-configuration>", -1, printcharfun); 1005 marker_position (OVERLAY_END (obj)));
946 } 1006 strout (buf, -1, printcharfun);
947#ifdef MULTI_FRAME 1007 print_string (XMARKER (OVERLAY_START (obj))->buffer->name,
948 else if (FRAMEP (obj)) 1008 printcharfun);
949 { 1009 }
950 strout ((FRAME_LIVE_P (XFRAME (obj)) 1010 PRINTCHAR ('>');
951 ? "#<frame " : "#<dead frame "),
952 -1, printcharfun);
953 print_string (XFRAME (obj)->name, printcharfun);
954 sprintf (buf, " 0x%lx", (unsigned long) (XFRAME (obj)));
955 strout (buf, -1, printcharfun);
956 PRINTCHAR ('>');
957 }
958#endif
959 else if (MARKERP (obj))
960 {
961 strout ("#<marker ", -1, printcharfun);
962 if (!(XMARKER (obj)->buffer))
963 strout ("in no buffer", -1, printcharfun);
964 else
965 {
966 sprintf (buf, "at %d", marker_position (obj));
967 strout (buf, -1, printcharfun);
968 strout (" in ", -1, printcharfun);
969 print_string (XMARKER (obj)->buffer->name, printcharfun);
970 }
971 PRINTCHAR ('>');
972 }
973 else if (OVERLAYP (obj))
974 {
975 strout ("#<overlay ", -1, printcharfun);
976 if (!(XMARKER (OVERLAY_START (obj))->buffer))
977 strout ("in no buffer", -1, printcharfun);
978 else
979 {
980 sprintf (buf, "from %d to %d in ",
981 marker_position (OVERLAY_START (obj)),
982 marker_position (OVERLAY_END (obj)));
983 strout (buf, -1, printcharfun);
984 print_string (XMARKER (OVERLAY_START (obj))->buffer->name,
985 printcharfun);
986 } 1011 }
987 PRINTCHAR ('>');
988 }
989#endif /* standalone */ 1012#endif /* standalone */
990 else if (SUBRP (obj)) 1013
991 { 1014 default:
992 strout ("#<subr ", -1, printcharfun); 1015 {
993 strout (XSUBR (obj)->symbol_name, -1, printcharfun); 1016 /* We're in trouble if this happens!
994 PRINTCHAR ('>'); 1017 Probably should just abort () */
995 } 1018 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, printcharfun);
996 else 1019 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
997 { 1020 strout (buf, -1, printcharfun);
998 /* We're in trouble if this happens! 1021 strout (" Save your buffers immediately and please report this bug>",
999 Probably should just abort () */ 1022 -1, printcharfun);
1000 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, printcharfun); 1023 }
1001 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
1002 strout (buf, -1, printcharfun);
1003 strout (" Save your buffers immediately and please report this bug>",
1004 -1, printcharfun);
1005 } 1024 }
1006 1025
1007 print_depth--; 1026 print_depth--;