Mercurial > emacs
comparison src/print.c @ 110548:f7b98576d87f
Fix all EMACS_INT/int conversion errors in print.c (and related files).
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Fri, 24 Sep 2010 17:01:03 +0200 |
parents | c4c8e4a16194 |
children | 3b57f0a3b766 |
comparison
equal
deleted
inserted
replaced
110547:a6fc92a6d443 | 110548:f7b98576d87f |
---|---|
94 /* When printing into a buffer, first we put the text in this | 94 /* When printing into a buffer, first we put the text in this |
95 block, then insert it all at once. */ | 95 block, then insert it all at once. */ |
96 char *print_buffer; | 96 char *print_buffer; |
97 | 97 |
98 /* Size allocated in print_buffer. */ | 98 /* Size allocated in print_buffer. */ |
99 int print_buffer_size; | 99 EMACS_INT print_buffer_size; |
100 /* Chars stored in print_buffer. */ | 100 /* Chars stored in print_buffer. */ |
101 int print_buffer_pos; | 101 EMACS_INT print_buffer_pos; |
102 /* Bytes stored in print_buffer. */ | 102 /* Bytes stored in print_buffer. */ |
103 int print_buffer_pos_byte; | 103 EMACS_INT print_buffer_pos_byte; |
104 | 104 |
105 /* Maximum length of list to print in full; noninteger means | 105 /* Maximum length of list to print in full; noninteger means |
106 effectively infinity */ | 106 effectively infinity */ |
107 | 107 |
108 Lisp_Object Vprint_length; | 108 Lisp_Object Vprint_length; |
175 Use PRINTCHAR to output one character, | 175 Use PRINTCHAR to output one character, |
176 or call strout to output a block of characters. */ | 176 or call strout to output a block of characters. */ |
177 | 177 |
178 #define PRINTDECLARE \ | 178 #define PRINTDECLARE \ |
179 struct buffer *old = current_buffer; \ | 179 struct buffer *old = current_buffer; \ |
180 int old_point = -1, start_point = -1; \ | 180 EMACS_INT old_point = -1, start_point = -1; \ |
181 int old_point_byte = -1, start_point_byte = -1; \ | 181 EMACS_INT old_point_byte = -1, start_point_byte = -1; \ |
182 int specpdl_count = SPECPDL_INDEX (); \ | 182 int specpdl_count = SPECPDL_INDEX (); \ |
183 int free_print_buffer = 0; \ | 183 int free_print_buffer = 0; \ |
184 int multibyte = !NILP (current_buffer->enable_multibyte_characters); \ | 184 int multibyte = !NILP (current_buffer->enable_multibyte_characters); \ |
185 Lisp_Object original | 185 Lisp_Object original |
186 | 186 |
340 | 340 |
341 In the case where PRINTCHARFUN is nil, it is safe for PTR to point | 341 In the case where PRINTCHARFUN is nil, it is safe for PTR to point |
342 to data in a Lisp string. Otherwise that is not safe. */ | 342 to data in a Lisp string. Otherwise that is not safe. */ |
343 | 343 |
344 static void | 344 static void |
345 strout (const char *ptr, int size, int size_byte, Lisp_Object printcharfun, | 345 strout (const char *ptr, EMACS_INT size, EMACS_INT size_byte, |
346 int multibyte) | 346 Lisp_Object printcharfun, int multibyte) |
347 { | 347 { |
348 if (size < 0) | 348 if (size < 0) |
349 size_byte = size = strlen (ptr); | 349 size_byte = size = strlen (ptr); |
350 | 350 |
351 if (NILP (printcharfun)) | 351 if (NILP (printcharfun)) |
428 static void | 428 static void |
429 print_string (Lisp_Object string, Lisp_Object printcharfun) | 429 print_string (Lisp_Object string, Lisp_Object printcharfun) |
430 { | 430 { |
431 if (EQ (printcharfun, Qt) || NILP (printcharfun)) | 431 if (EQ (printcharfun, Qt) || NILP (printcharfun)) |
432 { | 432 { |
433 int chars; | 433 EMACS_INT chars; |
434 | 434 |
435 if (print_escape_nonascii) | 435 if (print_escape_nonascii) |
436 string = string_escape_byte8 (string); | 436 string = string_escape_byte8 (string); |
437 | 437 |
438 if (STRING_MULTIBYTE (string)) | 438 if (STRING_MULTIBYTE (string)) |
444 { | 444 { |
445 /* If unibyte string STRING contains 8-bit codes, we must | 445 /* If unibyte string STRING contains 8-bit codes, we must |
446 convert STRING to a multibyte string containing the same | 446 convert STRING to a multibyte string containing the same |
447 character codes. */ | 447 character codes. */ |
448 Lisp_Object newstr; | 448 Lisp_Object newstr; |
449 int bytes; | 449 EMACS_INT bytes; |
450 | 450 |
451 chars = SBYTES (string); | 451 chars = SBYTES (string); |
452 bytes = parse_str_to_multibyte (SDATA (string), chars); | 452 bytes = parse_str_to_multibyte (SDATA (string), chars); |
453 if (chars < bytes) | 453 if (chars < bytes) |
454 { | 454 { |
462 chars = SBYTES (string); | 462 chars = SBYTES (string); |
463 | 463 |
464 if (EQ (printcharfun, Qt)) | 464 if (EQ (printcharfun, Qt)) |
465 { | 465 { |
466 /* Output to echo area. */ | 466 /* Output to echo area. */ |
467 int nbytes = SBYTES (string); | 467 EMACS_INT nbytes = SBYTES (string); |
468 char *buffer; | 468 char *buffer; |
469 | 469 |
470 /* Copy the string contents so that relocation of STRING by | 470 /* Copy the string contents so that relocation of STRING by |
471 GC does not cause trouble. */ | 471 GC does not cause trouble. */ |
472 USE_SAFE_ALLOCA; | 472 USE_SAFE_ALLOCA; |
488 else | 488 else |
489 { | 489 { |
490 /* Otherwise, string may be relocated by printing one char. | 490 /* Otherwise, string may be relocated by printing one char. |
491 So re-fetch the string address for each character. */ | 491 So re-fetch the string address for each character. */ |
492 int i; | 492 int i; |
493 int size = SCHARS (string); | 493 EMACS_INT size = SCHARS (string); |
494 int size_byte = SBYTES (string); | 494 EMACS_INT size_byte = SBYTES (string); |
495 struct gcpro gcpro1; | 495 struct gcpro gcpro1; |
496 GCPRO1 (string); | 496 GCPRO1 (string); |
497 if (size == size_byte) | 497 if (size == size_byte) |
498 for (i = 0; i < size; i++) | 498 for (i = 0; i < size; i++) |
499 PRINTCHAR (SREF (string, i)); | 499 PRINTCHAR (SREF (string, i)); |
866 You can call print while debugging emacs, and pass it this function | 866 You can call print while debugging emacs, and pass it this function |
867 to make it write to the debugging output. */) | 867 to make it write to the debugging output. */) |
868 (Lisp_Object character) | 868 (Lisp_Object character) |
869 { | 869 { |
870 CHECK_NUMBER (character); | 870 CHECK_NUMBER (character); |
871 putc (XINT (character), stderr); | 871 putc ((int) XINT (character), stderr); |
872 | 872 |
873 #ifdef WINDOWSNT | 873 #ifdef WINDOWSNT |
874 /* Send the output to a debugger (nothing happens if there isn't one). */ | 874 /* Send the output to a debugger (nothing happens if there isn't one). */ |
875 if (print_output_debug_flag) | 875 if (print_output_debug_flag) |
876 { | 876 { |
1428 } | 1428 } |
1429 if (NILP (Vprint_charset_text_property) | 1429 if (NILP (Vprint_charset_text_property) |
1430 || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) | 1430 || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) |
1431 { | 1431 { |
1432 int i, c; | 1432 int i, c; |
1433 int charpos = interval->position; | 1433 EMACS_INT charpos = interval->position; |
1434 int bytepos = string_char_to_byte (string, charpos); | 1434 EMACS_INT bytepos = string_char_to_byte (string, charpos); |
1435 Lisp_Object charset; | 1435 Lisp_Object charset; |
1436 | 1436 |
1437 charset = XCAR (XCDR (val)); | 1437 charset = XCAR (XCDR (val)); |
1438 for (i = 0; i < LENGTH (interval); i++) | 1438 for (i = 0; i < LENGTH (interval); i++) |
1439 { | 1439 { |
1564 else | 1564 else |
1565 { | 1565 { |
1566 register int i, i_byte; | 1566 register int i, i_byte; |
1567 struct gcpro gcpro1; | 1567 struct gcpro gcpro1; |
1568 unsigned char *str; | 1568 unsigned char *str; |
1569 int size_byte; | 1569 EMACS_INT size_byte; |
1570 /* 1 means we must ensure that the next character we output | 1570 /* 1 means we must ensure that the next character we output |
1571 cannot be taken as part of a hex character escape. */ | 1571 cannot be taken as part of a hex character escape. */ |
1572 int need_nonhex = 0; | 1572 int need_nonhex = 0; |
1573 int multibyte = STRING_MULTIBYTE (obj); | 1573 int multibyte = STRING_MULTIBYTE (obj); |
1574 | 1574 |
1682 { | 1682 { |
1683 register int confusing; | 1683 register int confusing; |
1684 register unsigned char *p = SDATA (SYMBOL_NAME (obj)); | 1684 register unsigned char *p = SDATA (SYMBOL_NAME (obj)); |
1685 register unsigned char *end = p + SBYTES (SYMBOL_NAME (obj)); | 1685 register unsigned char *end = p + SBYTES (SYMBOL_NAME (obj)); |
1686 register int c; | 1686 register int c; |
1687 int i, i_byte, size_byte; | 1687 int i, i_byte; |
1688 EMACS_INT size_byte; | |
1688 Lisp_Object name; | 1689 Lisp_Object name; |
1689 | 1690 |
1690 name = SYMBOL_NAME (obj); | 1691 name = SYMBOL_NAME (obj); |
1691 | 1692 |
1692 if (p != end && (*p == '-' || *p == '+')) p++; | 1693 if (p != end && (*p == '-' || *p == '+')) p++; |
1801 | 1802 |
1802 obj = XCDR (obj); | 1803 obj = XCDR (obj); |
1803 } | 1804 } |
1804 | 1805 |
1805 { | 1806 { |
1806 int print_length, i; | 1807 EMACS_INT print_length; |
1808 int i; | |
1807 Lisp_Object halftail = obj; | 1809 Lisp_Object halftail = obj; |
1808 | 1810 |
1809 /* Negative values of print-length are invalid in CL. | 1811 /* Negative values of print-length are invalid in CL. |
1810 Treat them like nil, as CMUCL does. */ | 1812 Treat them like nil, as CMUCL does. */ |
1811 if (NATNUMP (Vprint_length)) | 1813 if (NATNUMP (Vprint_length)) |
1896 else if (BOOL_VECTOR_P (obj)) | 1898 else if (BOOL_VECTOR_P (obj)) |
1897 { | 1899 { |
1898 register int i; | 1900 register int i; |
1899 register unsigned char c; | 1901 register unsigned char c; |
1900 struct gcpro gcpro1; | 1902 struct gcpro gcpro1; |
1901 int size_in_chars | 1903 EMACS_INT size_in_chars |
1902 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) | 1904 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) |
1903 / BOOL_VECTOR_BITS_PER_CHAR); | 1905 / BOOL_VECTOR_BITS_PER_CHAR); |
1904 | 1906 |
1905 GCPRO1 (obj); | 1907 GCPRO1 (obj); |
1906 | 1908 |
1982 PRINTCHAR ('>'); | 1984 PRINTCHAR ('>'); |
1983 } | 1985 } |
1984 else if (HASH_TABLE_P (obj)) | 1986 else if (HASH_TABLE_P (obj)) |
1985 { | 1987 { |
1986 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); | 1988 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
1987 int i, real_size, size; | 1989 int i; |
1990 EMACS_INT real_size, size; | |
1988 #if 0 | 1991 #if 0 |
1989 strout ("#<hash-table", -1, -1, printcharfun, 0); | 1992 strout ("#<hash-table", -1, -1, printcharfun, 0); |
1990 if (SYMBOLP (h->test)) | 1993 if (SYMBOLP (h->test)) |
1991 { | 1994 { |
1992 PRINTCHAR (' '); | 1995 PRINTCHAR (' '); |
2148 | 2151 |
2149 PRINTCHAR ('['); | 2152 PRINTCHAR ('['); |
2150 { | 2153 { |
2151 register int i; | 2154 register int i; |
2152 register Lisp_Object tem; | 2155 register Lisp_Object tem; |
2153 int real_size = size; | 2156 EMACS_INT real_size = size; |
2154 | 2157 |
2155 /* Don't print more elements than the specified maximum. */ | 2158 /* Don't print more elements than the specified maximum. */ |
2156 if (NATNUMP (Vprint_length) | 2159 if (NATNUMP (Vprint_length) |
2157 && XFASTINT (Vprint_length) < size) | 2160 && XFASTINT (Vprint_length) < size) |
2158 size = XFASTINT (Vprint_length); | 2161 size = XFASTINT (Vprint_length); |