Lisp_Object Qstandard_output;
-Lisp_Object Qtemp_buffer_setup_hook;
+static Lisp_Object Qtemp_buffer_setup_hook;
/* These are used to print like we read. */
-Lisp_Object Qfloat_output_format;
+static Lisp_Object Qfloat_output_format;
#include <math.h>
#endif
/* Avoid actual stack overflow in print. */
-int print_depth;
+static int print_depth;
/* Level of nesting inside outputting backquote in new style. */
-int new_backquote_output;
+static int new_backquote_output;
/* Detect most circularities to print finite output. */
#define PRINT_CIRCLE 200
-Lisp_Object being_printed[PRINT_CIRCLE];
+static Lisp_Object being_printed[PRINT_CIRCLE];
/* When printing into a buffer, first we put the text in this
block, then insert it all at once. */
-char *print_buffer;
+static char *print_buffer;
/* Size allocated in print_buffer. */
-EMACS_INT print_buffer_size;
+static EMACS_INT print_buffer_size;
/* Chars stored in print_buffer. */
-EMACS_INT print_buffer_pos;
+static EMACS_INT print_buffer_pos;
/* Bytes stored in print_buffer. */
-EMACS_INT print_buffer_pos_byte;
+static EMACS_INT print_buffer_pos_byte;
Lisp_Object Qprint_escape_newlines;
-Lisp_Object Qprint_escape_multibyte, Qprint_escape_nonascii;
+static Lisp_Object Qprint_escape_multibyte, Qprint_escape_nonascii;
/* Vprint_number_table is a table, that keeps objects that are going to
be printed, to allow use of #n= and #n# to express sharing.
N the object has been printed so we can refer to it as #N#.
print_number_index holds the largest N already used.
N has to be striclty larger than 0 since we need to distinguish -N. */
-int print_number_index;
-void print_interval (INTERVAL interval, Lisp_Object printcharfun);
+static int print_number_index;
+static void print_interval (INTERVAL interval, Lisp_Object printcharfun);
/* GDB resets this to zero on W32 to disable OutputDebugString calls. */
int print_output_debug_flag EXTERNALLY_VISIBLE = 1;
EMACS_INT bytes;
chars = SBYTES (string);
- bytes = parse_str_to_multibyte (SDATA (string), chars);
+ bytes = count_size_as_multibyte (SDATA (string), chars);
if (chars < bytes)
{
newstr = make_uninit_multibyte_string (chars, bytes);
specbind (Qstandard_output, buf);
}
-
-/* FIXME: Use Lisp's with-output-to-temp-buffer instead! */
-Lisp_Object
-internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args)
-{
- int count = SPECPDL_INDEX ();
- Lisp_Object buf, val;
- struct gcpro gcpro1;
-
- GCPRO1 (args);
- record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
- temp_output_buffer_setup (bufname);
- buf = Vstandard_output;
- UNGCPRO;
-
- val = (*function) (args);
-
- GCPRO1 (val);
- temp_output_buffer_show (buf);
- UNGCPRO;
-
- return unbind_to (count, val);
-}
\f
static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
static void print_preprocess (Lisp_Object obj);
/* This function is never called. Its purpose is to prevent
print_output_debug_flag from being optimized away. */
+extern void debug_output_compilation_hack (int) EXTERNALLY_VISIBLE;
void
debug_output_compilation_hack (int x)
{
#define WITH_REDIRECT_DEBUGGING_OUTPUT 1
-FILE *initial_stderr_stream = NULL;
+static FILE *initial_stderr_stream = NULL;
DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugging_output,
1, 2,
fprintf (stderr, "\r\n");
}
+void safe_debug_print (Lisp_Object) EXTERNALLY_VISIBLE;
void
safe_debug_print (Lisp_Object arg)
{
if (valid > 0)
debug_print (arg);
else
- fprintf (stderr, "#<%s_LISP_OBJECT 0x%08lx>\r\n",
+ fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
!valid ? "INVALID" : "SOME",
- (unsigned long) XHASH (arg)
- );
+ XHASH (arg));
}
\f
else
write_string_1 ("peculiar error", -1, stream);
- for (i = 0; CONSP (tail); tail = XCDR (tail), i++)
+ for (i = 0; CONSP (tail); tail = XCDR (tail), i = 1)
{
Lisp_Object obj;
Maybe a better way to do that is to copy elements to
a new hash table. */
struct Lisp_Hash_Table *h = XHASH_TABLE (Vprint_number_table);
- int i;
+ EMACS_INT i;
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
if (!NILP (HASH_HASH (h, i))
goto loop;
case Lisp_Vectorlike:
- size = XVECTOR (obj)->size;
+ size = ASIZE (obj);
if (size & PSEUDOVECTOR_FLAG)
size &= PSEUDOVECTOR_SIZE_MASK;
for (i = 0; i < size; i++)
Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil);
if (INTEGERP (num))
{
- int n = XINT (num);
+ EMACS_INT n = XINT (num);
if (n < 0)
{ /* Add a prefix #n= if OBJ has not yet been printed;
that is, its status field is nil. */
- sprintf (buf, "#%d=", -n);
+ sprintf (buf, "#%"pI"d=", -n);
strout (buf, -1, -1, printcharfun);
/* OBJ is going to be printed. Remember that fact. */
Fputhash (obj, make_number (- n), Vprint_number_table);
else
{
/* Just print #n# if OBJ has already been printed. */
- sprintf (buf, "#%d#", n);
+ sprintf (buf, "#%"pI"d#", n);
strout (buf, -1, -1, printcharfun);
return;
}
switch (XTYPE (obj))
{
case_Lisp_Int:
- if (sizeof (int) == sizeof (EMACS_INT))
- sprintf (buf, "%d", (int) XINT (obj));
- else if (sizeof (long) == sizeof (EMACS_INT))
- sprintf (buf, "%ld", (long) XINT (obj));
- else
- abort ();
+ sprintf (buf, "%"pI"d", XINT (obj));
strout (buf, -1, -1, printcharfun);
break;
print_string (obj, printcharfun);
else
{
- register EMACS_INT i, i_byte;
+ register EMACS_INT i_byte;
struct gcpro gcpro1;
unsigned char *str;
EMACS_INT size_byte;
str = SDATA (obj);
size_byte = SBYTES (obj);
- for (i = 0, i_byte = 0; i_byte < size_byte;)
+ for (i_byte = 0; i_byte < size_byte;)
{
/* Here, we must convert each multi-byte form to the
corresponding character code before handing it to PRINTCHAR. */
PRINTCHAR ('#');
PRINTCHAR ('&');
- sprintf (buf, "%ld", (long) XBOOL_VECTOR (obj)->size);
+ sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size);
strout (buf, -1, -1, printcharfun);
PRINTCHAR ('\"');
else if (WINDOWP (obj))
{
strout ("#<window ", -1, -1, printcharfun);
- sprintf (buf, "%ld", (long) XFASTINT (XWINDOW (obj)->sequence_number));
+ sprintf (buf, "%"pI"d", XFASTINT (XWINDOW (obj)->sequence_number));
strout (buf, -1, -1, printcharfun);
if (!NILP (XWINDOW (obj)->buffer))
{
strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun);
PRINTCHAR (' ');
sprintf (buf, "%ld/%ld", (long) h->count,
- (long) XVECTOR (h->next)->size);
+ (long) ASIZE (h->next));
strout (buf, -1, -1, printcharfun);
}
sprintf (buf, " 0x%lx", (unsigned long) h);
#s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
/* Always print the size. */
sprintf (buf, "#s(hash-table size %ld",
- (long) XVECTOR (h->next)->size);
+ (long) ASIZE (h->next));
strout (buf, -1, -1, printcharfun);
if (!NILP (h->test))
? "#<frame " : "#<dead frame "),
-1, -1, printcharfun);
print_string (XFRAME (obj)->name, printcharfun);
- sprintf (buf, " 0x%lx", (unsigned long) (XFRAME (obj)));
+ sprintf (buf, " %p", XFRAME (obj));
strout (buf, -1, -1, printcharfun);
PRINTCHAR ('>');
}
}
else
{
- EMACS_INT size = XVECTOR (obj)->size;
+ EMACS_INT size = ASIZE (obj);
if (COMPILEDP (obj))
{
PRINTCHAR ('#');
strout ("in no buffer", -1, -1, printcharfun);
else
{
- sprintf (buf, "at %ld", (long)marker_position (obj));
+ sprintf (buf, "at %"pI"d", marker_position (obj));
strout (buf, -1, -1, printcharfun);
strout (" in ", -1, -1, printcharfun);
print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun);
strout ("in no buffer", -1, -1, printcharfun);
else
{
- sprintf (buf, "from %ld to %ld in ",
- (long)marker_position (OVERLAY_START (obj)),
- (long)marker_position (OVERLAY_END (obj)));
+ sprintf (buf, "from %"pI"d to %"pI"d in ",
+ marker_position (OVERLAY_START (obj)),
+ marker_position (OVERLAY_END (obj)));
strout (buf, -1, -1, printcharfun);
print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name),
printcharfun);
case Lisp_Misc_Save_Value:
strout ("#<save_value ", -1, -1, printcharfun);
- sprintf(buf, "ptr=0x%08lx int=%d",
- (unsigned long) XSAVE_VALUE (obj)->pointer,
+ sprintf(buf, "ptr=%p int=%"pD"d",
+ XSAVE_VALUE (obj)->pointer,
XSAVE_VALUE (obj)->integer);
strout (buf, -1, -1, printcharfun);
PRINTCHAR ('>');
if (MISCP (obj))
sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj));
else if (VECTORLIKEP (obj))
- sprintf (buf, "(PVEC 0x%08x)", (int) XVECTOR (obj)->size);
+ sprintf (buf, "(PVEC 0x%08lx)", (unsigned long) ASIZE (obj));
else
sprintf (buf, "(0x%02x)", (int) XTYPE (obj));
strout (buf, -1, -1, printcharfun);