diff options
| author | Tom Tromey | 2013-06-03 12:25:05 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-06-03 12:25:05 -0600 |
| commit | 68359abba96d7ec4db8aab3d3dd9cf1105c3bab5 (patch) | |
| tree | 862703e7e1a1888170136a8296a5750d6b2ae2eb /src/print.c | |
| parent | cbcba8ce7f980b01c18c0fd561ef6687b1361507 (diff) | |
| parent | e2d8a6f0a229b4ebe26484b892ec4f14888f58b6 (diff) | |
| download | emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.tar.gz emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.zip | |
merge from trunk; clean up some issues
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/src/print.c b/src/print.c index 74fab475ac0..979b732a057 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -227,9 +227,9 @@ printchar (unsigned int ch, Lisp_Object fun) | |||
| 227 | if (NILP (fun)) | 227 | if (NILP (fun)) |
| 228 | { | 228 | { |
| 229 | ptrdiff_t incr = len - (print_buffer_size - print_buffer_pos_byte); | 229 | ptrdiff_t incr = len - (print_buffer_size - print_buffer_pos_byte); |
| 230 | if (0 < incr) | 230 | if (incr > 0) |
| 231 | print_buffer = | 231 | print_buffer = xpalloc (print_buffer, &print_buffer_size, |
| 232 | xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); | 232 | incr, -1, 1); |
| 233 | memcpy (print_buffer + print_buffer_pos_byte, str, len); | 233 | memcpy (print_buffer + print_buffer_pos_byte, str, len); |
| 234 | print_buffer_pos += 1; | 234 | print_buffer_pos += 1; |
| 235 | print_buffer_pos_byte += len; | 235 | print_buffer_pos_byte += len; |
| @@ -273,7 +273,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte, | |||
| 273 | if (NILP (printcharfun)) | 273 | if (NILP (printcharfun)) |
| 274 | { | 274 | { |
| 275 | ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte); | 275 | ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte); |
| 276 | if (0 < incr) | 276 | if (incr > 0) |
| 277 | print_buffer = xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); | 277 | print_buffer = xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); |
| 278 | memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte); | 278 | memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte); |
| 279 | print_buffer_pos += size; | 279 | print_buffer_pos += size; |
| @@ -1769,10 +1769,10 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 1769 | strout ("#<window ", -1, -1, printcharfun); | 1769 | strout ("#<window ", -1, -1, printcharfun); |
| 1770 | len = sprintf (buf, "%p", XWINDOW (obj)); | 1770 | len = sprintf (buf, "%p", XWINDOW (obj)); |
| 1771 | strout (buf, len, len, printcharfun); | 1771 | strout (buf, len, len, printcharfun); |
| 1772 | if (!NILP (XWINDOW (obj)->buffer)) | 1772 | if (BUFFERP (XWINDOW (obj)->contents)) |
| 1773 | { | 1773 | { |
| 1774 | strout (" on ", -1, -1, printcharfun); | 1774 | strout (" on ", -1, -1, printcharfun); |
| 1775 | print_string (BVAR (XBUFFER (XWINDOW (obj)->buffer), name), | 1775 | print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name), |
| 1776 | printcharfun); | 1776 | printcharfun); |
| 1777 | } | 1777 | } |
| 1778 | PRINTCHAR ('>'); | 1778 | PRINTCHAR ('>'); |
| @@ -2078,17 +2078,15 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 2078 | 2078 | ||
| 2079 | strout ("#<save-value ", -1, -1, printcharfun); | 2079 | strout ("#<save-value ", -1, -1, printcharfun); |
| 2080 | 2080 | ||
| 2081 | if (v->area) | 2081 | if (v->save_type == SAVE_TYPE_MEMORY) |
| 2082 | { | 2082 | { |
| 2083 | ptrdiff_t amount = v->data[1].integer; | 2083 | ptrdiff_t amount = v->data[1].integer; |
| 2084 | 2084 | ||
| 2085 | #if GC_MARK_STACK | 2085 | #if GC_MARK_STACK |
| 2086 | 2086 | ||
| 2087 | /* If GC_MARK_STACK, valid_lisp_object_p is quite reliable, | 2087 | /* valid_lisp_object_p is reliable, so try to print up |
| 2088 | and so we try to print up to 8 objects we have saved. | 2088 | to 8 saved objects. This code is rarely used, so |
| 2089 | Although valid_lisp_object_p is slow, this shouldn't be | 2089 | it's OK that valid_lisp_object_p is slow. */ |
| 2090 | a real bottleneck because we do not use this code under | ||
| 2091 | normal circumstances. */ | ||
| 2092 | 2090 | ||
| 2093 | int limit = min (amount, 8); | 2091 | int limit = min (amount, 8); |
| 2094 | Lisp_Object *area = v->data[0].pointer; | 2092 | Lisp_Object *area = v->data[0].pointer; |
| @@ -2113,9 +2111,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 2113 | 2111 | ||
| 2114 | #else /* not GC_MARK_STACK */ | 2112 | #else /* not GC_MARK_STACK */ |
| 2115 | 2113 | ||
| 2116 | /* If !GC_MARK_STACK, we have no reliable way to find | 2114 | /* There is no reliable way to determine whether the objects |
| 2117 | whether Lisp_Object pointers points to an initialized | 2115 | are initialized, so do not try to print them. */ |
| 2118 | objects, and so we do not ever trying to print them. */ | ||
| 2119 | 2116 | ||
| 2120 | i = sprintf (buf, "with %"pD"d objects", amount); | 2117 | i = sprintf (buf, "with %"pD"d objects", amount); |
| 2121 | strout (buf, i, i, printcharfun); | 2118 | strout (buf, i, i, printcharfun); |
| @@ -2124,33 +2121,37 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 2124 | } | 2121 | } |
| 2125 | else | 2122 | else |
| 2126 | { | 2123 | { |
| 2127 | /* Print each `data[N]' slot according to its type. */ | 2124 | /* Print each slot according to its type. */ |
| 2128 | 2125 | int index; | |
| 2129 | #define PRINTX(index) \ | 2126 | for (index = 0; index < SAVE_VALUE_SLOTS; index++) |
| 2130 | do { \ | 2127 | { |
| 2131 | i = 0; \ | 2128 | if (index) |
| 2132 | if (v->type ## index == SAVE_UNUSED) \ | 2129 | PRINTCHAR (' '); |
| 2133 | i = sprintf (buf, "<unused>"); \ | ||
| 2134 | else if (v->type ## index == SAVE_INTEGER) \ | ||
| 2135 | i = sprintf (buf, "<integer %"pD"d>", v->data[index].integer); \ | ||
| 2136 | else if (v->type ## index == SAVE_POINTER) \ | ||
| 2137 | i = sprintf (buf, "<pointer %p>", v->data[index].pointer); \ | ||
| 2138 | else /* SAVE_OBJECT */ \ | ||
| 2139 | print_object (v->data[index].object, printcharfun, escapeflag); \ | ||
| 2140 | if (i) \ | ||
| 2141 | strout (buf, i, i, printcharfun); \ | ||
| 2142 | } while (0) | ||
| 2143 | |||
| 2144 | PRINTX (0); | ||
| 2145 | PRINTCHAR (' '); | ||
| 2146 | PRINTX (1); | ||
| 2147 | PRINTCHAR (' '); | ||
| 2148 | PRINTX (2); | ||
| 2149 | PRINTCHAR (' '); | ||
| 2150 | PRINTX (3); | ||
| 2151 | 2130 | ||
| 2152 | #undef PRINTX | 2131 | switch (save_type (v, index)) |
| 2132 | { | ||
| 2133 | case SAVE_UNUSED: | ||
| 2134 | i = sprintf (buf, "<unused>"); | ||
| 2135 | break; | ||
| 2136 | |||
| 2137 | case SAVE_POINTER: | ||
| 2138 | i = sprintf (buf, "<pointer %p>", | ||
| 2139 | v->data[index].pointer); | ||
| 2140 | break; | ||
| 2141 | |||
| 2142 | case SAVE_INTEGER: | ||
| 2143 | i = sprintf (buf, "<integer %"pD"d>", | ||
| 2144 | v->data[index].integer); | ||
| 2145 | break; | ||
| 2146 | |||
| 2147 | case SAVE_OBJECT: | ||
| 2148 | print_object (v->data[index].object, printcharfun, | ||
| 2149 | escapeflag); | ||
| 2150 | continue; | ||
| 2151 | } | ||
| 2153 | 2152 | ||
| 2153 | strout (buf, i, i, printcharfun); | ||
| 2154 | } | ||
| 2154 | } | 2155 | } |
| 2155 | PRINTCHAR ('>'); | 2156 | PRINTCHAR ('>'); |
| 2156 | } | 2157 | } |
| @@ -2201,7 +2202,16 @@ print_interval (INTERVAL interval, Lisp_Object printcharfun) | |||
| 2201 | print_object (interval->plist, printcharfun, 1); | 2202 | print_object (interval->plist, printcharfun, 1); |
| 2202 | } | 2203 | } |
| 2203 | 2204 | ||
| 2204 | 2205 | /* Initialize debug_print stuff early to have it working from the very | |
| 2206 | beginning. */ | ||
| 2207 | |||
| 2208 | void | ||
| 2209 | init_print_once (void) | ||
| 2210 | { | ||
| 2211 | DEFSYM (Qexternal_debugging_output, "external-debugging-output"); | ||
| 2212 | defsubr (&Sexternal_debugging_output); | ||
| 2213 | } | ||
| 2214 | |||
| 2205 | void | 2215 | void |
| 2206 | syms_of_print (void) | 2216 | syms_of_print (void) |
| 2207 | { | 2217 | { |
| @@ -2333,12 +2343,10 @@ priorities. */); | |||
| 2333 | defsubr (&Sprint); | 2343 | defsubr (&Sprint); |
| 2334 | defsubr (&Sterpri); | 2344 | defsubr (&Sterpri); |
| 2335 | defsubr (&Swrite_char); | 2345 | defsubr (&Swrite_char); |
| 2336 | defsubr (&Sexternal_debugging_output); | ||
| 2337 | #ifdef WITH_REDIRECT_DEBUGGING_OUTPUT | 2346 | #ifdef WITH_REDIRECT_DEBUGGING_OUTPUT |
| 2338 | defsubr (&Sredirect_debugging_output); | 2347 | defsubr (&Sredirect_debugging_output); |
| 2339 | #endif | 2348 | #endif |
| 2340 | 2349 | ||
| 2341 | DEFSYM (Qexternal_debugging_output, "external-debugging-output"); | ||
| 2342 | DEFSYM (Qprint_escape_newlines, "print-escape-newlines"); | 2350 | DEFSYM (Qprint_escape_newlines, "print-escape-newlines"); |
| 2343 | DEFSYM (Qprint_escape_multibyte, "print-escape-multibyte"); | 2351 | DEFSYM (Qprint_escape_multibyte, "print-escape-multibyte"); |
| 2344 | DEFSYM (Qprint_escape_nonascii, "print-escape-nonascii"); | 2352 | DEFSYM (Qprint_escape_nonascii, "print-escape-nonascii"); |