diff options
| author | Paul Eggert | 2011-04-27 15:29:33 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-04-27 15:29:33 -0700 |
| commit | 54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e (patch) | |
| tree | 9d2fdec724dec1b168c7b6fe5155e30282090909 /src | |
| parent | 8f41de3a66a32996d77512569eae74c926a81c84 (diff) | |
| parent | fc3b729195fbe5297aa23320f83adb11225b6ded (diff) | |
| download | emacs-54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e.tar.gz emacs-54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e.zip | |
Merge from mainline.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/coding.c | 5 | ||||
| -rw-r--r-- | src/doprnt.c | 62 | ||||
| -rw-r--r-- | src/eval.c | 3 |
4 files changed, 52 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b23904a3575..939e11ed61c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -2,6 +2,19 @@ | |||
| 2 | 2 | ||
| 3 | * doprnt.c (doprnt): Support "ll" length modifier, for long long. | 3 | * doprnt.c (doprnt): Support "ll" length modifier, for long long. |
| 4 | 4 | ||
| 5 | 2011-04-27 Eli Zaretskii <eliz@gnu.org> | ||
| 6 | |||
| 7 | Improve `doprnt' and its usage. (Bug#8545) | ||
| 8 | * doprnt.c (doprnt): Make sure `format' is never accessed beyond | ||
| 9 | `format_end'. Remove support for %l as a conversion specifier. | ||
| 10 | Don't use xrealloc. Improve diagnostics when the %l size modifier | ||
| 11 | is used. Update the commentary. | ||
| 12 | |||
| 13 | * eval.c (verror): Simplify calculation of size_t. | ||
| 14 | |||
| 15 | * coding.c (Ffind_operation_coding_system): Fix diagnostic error | ||
| 16 | messages. | ||
| 17 | |||
| 5 | 2011-04-27 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change) | 18 | 2011-04-27 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change) |
| 6 | 19 | ||
| 7 | * buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Adjust to aliasing | 20 | * buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Adjust to aliasing |
| @@ -21,7 +34,7 @@ | |||
| 21 | Remove unused local. | 34 | Remove unused local. |
| 22 | (emacs_gnutls_write): Don't use uninitialized rtnval if nbyte <= 0. | 35 | (emacs_gnutls_write): Don't use uninitialized rtnval if nbyte <= 0. |
| 23 | 36 | ||
| 24 | lisp.h: Fix a problem with aliasing and vector headers. (Bug#8546) | 37 | * lisp.h: Fix a problem with aliasing and vector headers. (Bug#8546) |
| 25 | GCC 4.6.0 optimizes based on type-based alias analysis. For | 38 | GCC 4.6.0 optimizes based on type-based alias analysis. For |
| 26 | example, if b is of type struct buffer * and v of type struct | 39 | example, if b is of type struct buffer * and v of type struct |
| 27 | Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size | 40 | Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size |
| @@ -213,7 +226,7 @@ | |||
| 213 | supposed to be handshaking. (Bug#8556) | 226 | supposed to be handshaking. (Bug#8556) |
| 214 | Reported by Paul Eggert <eggert@cs.ucla.edu>. | 227 | Reported by Paul Eggert <eggert@cs.ucla.edu>. |
| 215 | 228 | ||
| 216 | 2011-04-26 Daniel Colascione <dan.colascione@gmail.com> | 229 | 2011-04-26 Daniel Colascione <dan.colascione@gmail.com> |
| 217 | 230 | ||
| 218 | * lisp.h (Qdebug): List symbol. | 231 | * lisp.h (Qdebug): List symbol. |
| 219 | * eval.c (Qdebug): Restore global linkage. | 232 | * eval.c (Qdebug): Restore global linkage. |
| @@ -469,8 +482,8 @@ | |||
| 469 | define if USE_GTK || USE_X_TOOLKIT. | 482 | define if USE_GTK || USE_X_TOOLKIT. |
| 470 | (SET_SAVED_BUTTON_EVENT): Define only if USE_X_TOOLKIT || USE_GTK. | 483 | (SET_SAVED_BUTTON_EVENT): Define only if USE_X_TOOLKIT || USE_GTK. |
| 471 | * xterm.h (x_dispatch_event): Extern only if USE_X_TOOLKIT. | 484 | * xterm.h (x_dispatch_event): Extern only if USE_X_TOOLKIT. |
| 472 | * xterm.c, xterm.h (x_mouse_leave): Bring this function back, but only if | 485 | * xterm.c, xterm.h (x_mouse_leave): Bring this function back, but only |
| 473 | defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK. | 486 | if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK. |
| 474 | 487 | ||
| 475 | * xmenu.c (menu_help_callback): Pointer type fixes. | 488 | * xmenu.c (menu_help_callback): Pointer type fixes. |
| 476 | Use const pointers when pointing at readonly data. Avoid pointer | 489 | Use const pointers when pointing at readonly data. Avoid pointer |
diff --git a/src/coding.c b/src/coding.c index c14a41036ac..c129c94203c 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -9282,14 +9282,15 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) | |||
| 9282 | || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) | 9282 | || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) |
| 9283 | error ("Invalid first argument"); | 9283 | error ("Invalid first argument"); |
| 9284 | if (nargs < 1 + XFASTINT (target_idx)) | 9284 | if (nargs < 1 + XFASTINT (target_idx)) |
| 9285 | error ("Too few arguments for operation: %s", | 9285 | error ("Too few arguments for operation `%s'", |
| 9286 | SDATA (SYMBOL_NAME (operation))); | 9286 | SDATA (SYMBOL_NAME (operation))); |
| 9287 | target = args[XFASTINT (target_idx) + 1]; | 9287 | target = args[XFASTINT (target_idx) + 1]; |
| 9288 | if (!(STRINGP (target) | 9288 | if (!(STRINGP (target) |
| 9289 | || (EQ (operation, Qinsert_file_contents) && CONSP (target) | 9289 | || (EQ (operation, Qinsert_file_contents) && CONSP (target) |
| 9290 | && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) | 9290 | && STRINGP (XCAR (target)) && BUFFERP (XCDR (target))) |
| 9291 | || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) | 9291 | || (EQ (operation, Qopen_network_stream) && INTEGERP (target)))) |
| 9292 | error ("Invalid %"pI"dth argument", XFASTINT (target_idx) + 1); | 9292 | error ("Invalid argument %"pI"d of operation `%s'", |
| 9293 | XFASTINT (target_idx) + 1, SDATA (SYMBOL_NAME (operation))); | ||
| 9293 | if (CONSP (target)) | 9294 | if (CONSP (target)) |
| 9294 | target = XCAR (target); | 9295 | target = XCAR (target); |
| 9295 | 9296 | ||
diff --git a/src/doprnt.c b/src/doprnt.c index 229ad06e057..cc4e5daebf3 100644 --- a/src/doprnt.c +++ b/src/doprnt.c | |||
| @@ -55,7 +55,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 55 | %s means print a string argument. | 55 | %s means print a string argument. |
| 56 | %S is silently treated as %s, for loose compatibility with `Fformat'. | 56 | %S is silently treated as %s, for loose compatibility with `Fformat'. |
| 57 | %d means print a `signed int' argument in decimal. | 57 | %d means print a `signed int' argument in decimal. |
| 58 | %l means print a `long int' argument in decimal. | ||
| 59 | %o means print an `unsigned int' argument in octal. | 58 | %o means print an `unsigned int' argument in octal. |
| 60 | %x means print an `unsigned int' argument in hex. | 59 | %x means print an `unsigned int' argument in hex. |
| 61 | %e means print a `double' argument in exponential notation. | 60 | %e means print a `double' argument in exponential notation. |
| @@ -65,24 +64,28 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 65 | %c means print a `signed int' argument as a single character. | 64 | %c means print a `signed int' argument as a single character. |
| 66 | %% means produce a literal % character. | 65 | %% means produce a literal % character. |
| 67 | 66 | ||
| 68 | A %-sequence may contain optional flag, width, and precision specifiers, as | 67 | A %-sequence may contain optional flag, width, and precision specifiers, and |
| 69 | follows: | 68 | a length modifier, as follows: |
| 70 | 69 | ||
| 71 | %<flags><width><precision>character | 70 | %<flags><width><precision><length>character |
| 72 | 71 | ||
| 73 | where flags is [+ -0l], width is [0-9]+, and precision is .[0-9]+ | 72 | where flags is [+ -0l], width is [0-9]+, and precision is .[0-9]+ |
| 74 | 73 | ||
| 75 | The + flag character inserts a + before any positive number, while a space | 74 | The + flag character inserts a + before any positive number, while a space |
| 76 | inserts a space before any positive number; these flags only affect %d, %l, | 75 | inserts a space before any positive number; these flags only affect %d, %o, |
| 77 | %o, %x, %e, %f, and %g sequences. The - and 0 flags affect the width | 76 | %x, %e, %f, and %g sequences. The - and 0 flags affect the width specifier, |
| 78 | specifier, as described below. | 77 | as described below. For signed numerical arguments only, the ` ' (space) |
| 79 | 78 | flag causes the result to be prefixed with a space character if it does not | |
| 80 | The l (lower-case letter ell) flag is a `long' data type modifier: it is | 79 | start with a sign (+ or -). |
| 81 | supported for %d, %o, and %x conversions of integral arguments, and means | 80 | |
| 82 | that the respective argument is to be treated as `long int' or `unsigned | 81 | The l (lower-case letter ell) length modifier is a `long' data type |
| 83 | long int'. ll means to use 'long long'. EMACS_INT arguments | 82 | modifier: it is supported for %d, %o, and %x conversions of integral |
| 84 | should use the pI macro, which expands to whatever length modifier | 83 | arguments, must immediately precede the conversion specifier, and means that |
| 85 | is needed for the target host, e.g., "", "l", "ll". | 84 | the respective argument is to be treated as `long int' or `unsigned long |
| 85 | int'. Similarly, ll (two letter ells) means to use `long long int' or | ||
| 86 | `unsigned long long int'. The empty length modifier means to use `int' or | ||
| 87 | `unsigned int'. EMACS_INT arguments should use the pI macro, which | ||
| 88 | expands to whatever length modifier is needed for the target host. | ||
| 86 | 89 | ||
| 87 | The width specifier supplies a lower limit for the length of the printed | 90 | The width specifier supplies a lower limit for the length of the printed |
| 88 | representation. The padding, if any, normally goes on the left, but it goes | 91 | representation. The padding, if any, normally goes on the left, but it goes |
| @@ -168,7 +171,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 168 | bufsize--; | 171 | bufsize--; |
| 169 | 172 | ||
| 170 | /* Loop until end of format string or buffer full. */ | 173 | /* Loop until end of format string or buffer full. */ |
| 171 | while (fmt != format_end && bufsize > 0) | 174 | while (fmt < format_end && bufsize > 0) |
| 172 | { | 175 | { |
| 173 | if (*fmt == '%') /* Check for a '%' character */ | 176 | if (*fmt == '%') /* Check for a '%' character */ |
| 174 | { | 177 | { |
| @@ -180,7 +183,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 180 | /* Copy this one %-spec into fmtcpy. */ | 183 | /* Copy this one %-spec into fmtcpy. */ |
| 181 | string = fmtcpy; | 184 | string = fmtcpy; |
| 182 | *string++ = '%'; | 185 | *string++ = '%'; |
| 183 | while (1) | 186 | while (fmt < format_end) |
| 184 | { | 187 | { |
| 185 | *string++ = *fmt; | 188 | *string++ = *fmt; |
| 186 | if ('0' <= *fmt && *fmt <= '9') | 189 | if ('0' <= *fmt && *fmt <= '9') |
| @@ -190,7 +193,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 190 | %1.1000f and %1000.1f both might need 1000+ bytes. | 193 | %1.1000f and %1000.1f both might need 1000+ bytes. |
| 191 | Parse the width or precision, checking for overflow. */ | 194 | Parse the width or precision, checking for overflow. */ |
| 192 | size_t n = *fmt - '0'; | 195 | size_t n = *fmt - '0'; |
| 193 | while ('0' <= fmt[1] && fmt[1] <= '9') | 196 | while (fmt < format_end |
| 197 | && '0' <= fmt[1] && fmt[1] <= '9') | ||
| 194 | { | 198 | { |
| 195 | if (n >= SIZE_MAX / 10 | 199 | if (n >= SIZE_MAX / 10 |
| 196 | || n * 10 > SIZE_MAX - (fmt[1] - '0')) | 200 | || n * 10 > SIZE_MAX - (fmt[1] - '0')) |
| @@ -206,20 +210,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 206 | ; | 210 | ; |
| 207 | else if (*fmt == 'l') | 211 | else if (*fmt == 'l') |
| 208 | { | 212 | { |
| 209 | long_flag = 1; | 213 | long_flag = 1 + (fmt + 1 < fmt_end && fmt[1] == 'l'); |
| 210 | if (fmt[1] == 'l') | 214 | fmt += long_flag; |
| 211 | { | 215 | break; |
| 212 | long_flag = 2; | ||
| 213 | fmt++; | ||
| 214 | } | ||
| 215 | if (!strchr ("dox", fmt[1])) | ||
| 216 | /* %l as conversion specifier, not as modifier. */ | ||
| 217 | break; | ||
| 218 | } | 216 | } |
| 219 | else | 217 | else |
| 220 | break; | 218 | break; |
| 221 | fmt++; | 219 | fmt++; |
| 222 | } | 220 | } |
| 221 | if (fmt > format_end) | ||
| 222 | fmt = format_end; | ||
| 223 | *string = 0; | 223 | *string = 0; |
| 224 | 224 | ||
| 225 | /* Make the size bound large enough to handle floating point formats | 225 | /* Make the size bound large enough to handle floating point formats |
| @@ -232,9 +232,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 232 | if (size_bound > size_allocated) | 232 | if (size_bound > size_allocated) |
| 233 | { | 233 | { |
| 234 | if (big_buffer) | 234 | if (big_buffer) |
| 235 | big_buffer = (char *) xrealloc (big_buffer, size_bound); | 235 | xfree (big_buffer); |
| 236 | else | 236 | big_buffer = (char *) xmalloc (size_bound); |
| 237 | big_buffer = (char *) xmalloc (size_bound); | ||
| 238 | sprintf_buffer = big_buffer; | 237 | sprintf_buffer = big_buffer; |
| 239 | size_allocated = size_bound; | 238 | size_allocated = size_bound; |
| 240 | } | 239 | } |
| @@ -242,7 +241,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 242 | switch (*fmt++) | 241 | switch (*fmt++) |
| 243 | { | 242 | { |
| 244 | default: | 243 | default: |
| 245 | error ("Invalid format operation %%%c", fmt[-1]); | 244 | error ("Invalid format operation %%%s%c", |
| 245 | long_flag ? "l" : "", fmt[-1]); | ||
| 246 | 246 | ||
| 247 | /* case 'b': */ | 247 | /* case 'b': */ |
| 248 | case 'l': | 248 | case 'l': |
| @@ -398,7 +398,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format, | |||
| 398 | char *save_bufptr = bufptr; | 398 | char *save_bufptr = bufptr; |
| 399 | 399 | ||
| 400 | do { *bufptr++ = *fmt++; } | 400 | do { *bufptr++ = *fmt++; } |
| 401 | while (--bufsize > 0 && !CHAR_HEAD_P (*fmt)); | 401 | while (fmt < format_end && --bufsize > 0 && !CHAR_HEAD_P (*fmt)); |
| 402 | if (!CHAR_HEAD_P (*fmt)) | 402 | if (!CHAR_HEAD_P (*fmt)) |
| 403 | { | 403 | { |
| 404 | bufptr = save_bufptr; | 404 | bufptr = save_bufptr; |
diff --git a/src/eval.c b/src/eval.c index 8716ad78468..bcbbf740153 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1994,8 +1994,7 @@ verror (const char *m, va_list ap) | |||
| 1994 | { | 1994 | { |
| 1995 | char buf[4000]; | 1995 | char buf[4000]; |
| 1996 | size_t size = sizeof buf; | 1996 | size_t size = sizeof buf; |
| 1997 | size_t size_max = | 1997 | size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX); |
| 1998 | min (MOST_POSITIVE_FIXNUM, min (INT_MAX, SIZE_MAX - 1)) + 1; | ||
| 1999 | size_t mlen = strlen (m); | 1998 | size_t mlen = strlen (m); |
| 2000 | char *buffer = buf; | 1999 | char *buffer = buf; |
| 2001 | size_t used; | 2000 | size_t used; |