[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/print.c [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/print.c [emacs-unicode-2] |
Date: |
Mon, 28 Jun 2004 03:55:31 -0400 |
Index: emacs/src/print.c
diff -c emacs/src/print.c:1.190.2.7 emacs/src/print.c:1.190.2.8
*** emacs/src/print.c:1.190.2.7 Fri Apr 16 12:50:49 2004
--- emacs/src/print.c Mon Jun 28 07:29:23 2004
***************
*** 1,5 ****
/* Lisp object printing and output streams.
! Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 01, 2003
Free Software Foundation, Inc.
This file is part of GNU Emacs.
--- 1,5 ----
/* Lisp object printing and output streams.
! Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 01, 03, 2004
Free Software Foundation, Inc.
This file is part of GNU Emacs.
***************
*** 601,606 ****
--- 601,608 ----
eassert (current_buffer->overlays_after == NULL);
current_buffer->enable_multibyte_characters
= buffer_defaults.enable_multibyte_characters;
+ specbind (Qinhibit_read_only, Qt);
+ specbind (Qinhibit_modification_hooks, Qt);
Ferase_buffer ();
XSETBUFFER (buf, current_buffer);
***************
*** 789,795 ****
if (SBYTES (object) == SCHARS (object))
STRING_SET_UNIBYTE (object);
! /* Note that this won't make prepare_to_modify_buffer call
ask-user-about-supersession-threat because this buffer
does not visit a file. */
Ferase_buffer ();
--- 791,797 ----
if (SBYTES (object) == SCHARS (object))
STRING_SET_UNIBYTE (object);
! /* Note that this won't make prepare_to_modify_buffer call
ask-user-about-supersession-threat because this buffer
does not visit a file. */
Ferase_buffer ();
***************
*** 927,933 ****
doc: /* Redirect debugging output (stderr stream) to file FILE.
If FILE is nil, reset target to the initial stderr stream.
Optional arg APPEND non-nil (interactively, with prefix arg) means
! append to existing target file. */)
(file, append)
Lisp_Object file, append;
{
--- 929,935 ----
doc: /* Redirect debugging output (stderr stream) to file FILE.
If FILE is nil, reset target to the initial stderr stream.
Optional arg APPEND non-nil (interactively, with prefix arg) means
! append to existing target file. */)
(file, append)
Lisp_Object file, append;
{
***************
*** 1218,1224 ****
register Lisp_Object printcharfun;
int escapeflag;
{
- print_depth = 0;
old_backquote_output = 0;
/* Reset print_number_index and Vprint_number_table only when
--- 1220,1225 ----
***************
*** 1238,1243 ****
--- 1239,1245 ----
start = index = print_number_index;
/* Construct Vprint_number_table.
This increments print_number_index for the objects added. */
+ print_depth = 0;
print_preprocess (obj);
/* Remove unnecessary objects, which appear only once in OBJ;
***************
*** 1262,1267 ****
--- 1264,1270 ----
print_number_index = index;
}
+ print_depth = 0;
print_object (obj, printcharfun, escapeflag);
}
***************
*** 1278,1283 ****
--- 1281,1306 ----
{
int i;
EMACS_INT size;
+ int loop_count = 0;
+ Lisp_Object halftail;
+
+ /* Avoid infinite recursion for circular nested structure
+ in the case where Vprint_circle is nil. */
+ if (NILP (Vprint_circle))
+ {
+ for (i = 0; i < print_depth; i++)
+ if (EQ (obj, being_printed[i]))
+ return;
+ being_printed[print_depth] = obj;
+ }
+
+ /* Give up if we go so deep that print_object will get an error. */
+ /* See similar code in print_object. */
+ if (print_depth >= PRINT_CIRCLE)
+ return;
+
+ print_depth++;
+ halftail = obj;
loop:
if (STRINGP (obj) || CONSP (obj) || VECTORP (obj)
***************
*** 1338,1345 ****
--- 1361,1375 ----
break;
case Lisp_Cons:
+ /* Use HALFTAIL and LOOP_COUNT to detect circular lists,
+ just as in print_object. */
+ if (loop_count && EQ (obj, halftail))
+ break;
print_preprocess (XCAR (obj));
obj = XCDR (obj);
+ loop_count++;
+ if (!(loop_count & 1))
+ halftail = XCDR (halftail);
goto loop;
case Lisp_Vectorlike:
***************
*** 1354,1359 ****
--- 1384,1390 ----
break;
}
}
+ print_depth--;
}
static void
***************
*** 1457,1463 ****
register Lisp_Object printcharfun;
int escapeflag;
{
! char buf[30];
QUIT;
--- 1488,1494 ----
register Lisp_Object printcharfun;
int escapeflag;
{
! char buf[40];
QUIT;
***************
*** 1511,1516 ****
--- 1542,1548 ----
print_depth++;
+ /* See similar code in print_preprocess. */
if (print_depth > PRINT_CIRCLE)
error ("Apparently circular structure being printed");
#ifdef MAX_PRINT_CHARS
***************
*** 1876,1893 ****
register unsigned char c;
struct gcpro gcpro1;
int size_in_chars
! = (XBOOL_VECTOR (obj)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
GCPRO1 (obj);
PRINTCHAR ('#');
PRINTCHAR ('&');
! if (sizeof (int) == sizeof (EMACS_INT))
! sprintf (buf, "%d", XBOOL_VECTOR (obj)->size);
! else if (sizeof (long) == sizeof (EMACS_INT))
! sprintf (buf, "%ld", XBOOL_VECTOR (obj)->size);
! else
! abort ();
strout (buf, -1, -1, printcharfun, 0);
PRINTCHAR ('\"');
--- 1908,1921 ----
register unsigned char c;
struct gcpro gcpro1;
int size_in_chars
! = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
! / BOOL_VECTOR_BITS_PER_CHAR);
GCPRO1 (obj);
PRINTCHAR ('#');
PRINTCHAR ('&');
! sprintf (buf, "%ld", (long) XBOOL_VECTOR (obj)->size);
strout (buf, -1, -1, printcharfun, 0);
PRINTCHAR ('\"');
***************
*** 1917,1922 ****
--- 1945,1958 ----
PRINTCHAR ('\\');
PRINTCHAR ('f');
}
+ else if (c > '\177')
+ {
+ /* Use octal escapes to avoid encoding issues. */
+ PRINTCHAR ('\\');
+ PRINTCHAR ('0' + ((c >> 6) & 3));
+ PRINTCHAR ('0' + ((c >> 3) & 7));
+ PRINTCHAR ('0' + (c & 7));
+ }
else
{
if (c == '\"' || c == '\\')
***************
*** 1937,1943 ****
else if (WINDOWP (obj))
{
strout ("#<window ", -1, -1, printcharfun, 0);
! sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number));
strout (buf, -1, -1, printcharfun, 0);
if (!NILP (XWINDOW (obj)->buffer))
{
--- 1973,1979 ----
else if (WINDOWP (obj))
{
strout ("#<window ", -1, -1, printcharfun, 0);
! sprintf (buf, "%ld", (long) XFASTINT (XWINDOW
(obj)->sequence_number));
strout (buf, -1, -1, printcharfun, 0);
if (!NILP (XWINDOW (obj)->buffer))
{
***************
*** 1958,1965 ****
PRINTCHAR (' ');
strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun, 0);
PRINTCHAR (' ');
! sprintf (buf, "%d/%d", XFASTINT (h->count),
! XVECTOR (h->next)->size);
strout (buf, -1, -1, printcharfun, 0);
}
sprintf (buf, " 0x%lx", (unsigned long) h);
--- 1994,2001 ----
PRINTCHAR (' ');
strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun, 0);
PRINTCHAR (' ');
! sprintf (buf, "%ld/%ld", (long) XFASTINT (h->count),
! (long) XVECTOR (h->next)->size);
strout (buf, -1, -1, printcharfun, 0);
}
sprintf (buf, " 0x%lx", (unsigned long) h);
***************
*** 2082,2088 ****
break;
case Lisp_Misc_Intfwd:
! sprintf (buf, "#<intfwd to %d>", *XINTFWD (obj)->intvar);
strout (buf, -1, -1, printcharfun, 0);
break;
--- 2118,2124 ----
break;
case Lisp_Misc_Intfwd:
! sprintf (buf, "#<intfwd to %ld>", (long) *XINTFWD (obj)->intvar);
strout (buf, -1, -1, printcharfun, 0);
break;
- [Emacs-diffs] Changes to emacs/src/print.c [emacs-unicode-2],
Miles Bader <=