aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-04-27 15:29:33 -0700
committerPaul Eggert2011-04-27 15:29:33 -0700
commit54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e (patch)
tree9d2fdec724dec1b168c7b6fe5155e30282090909
parent8f41de3a66a32996d77512569eae74c926a81c84 (diff)
parentfc3b729195fbe5297aa23320f83adb11225b6ded (diff)
downloademacs-54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e.tar.gz
emacs-54b8e3f7753cdd63ba6dac998d56fcd34dd59d8e.zip
Merge from mainline.
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/calendar/icalendar.el119
-rw-r--r--nt/ChangeLog9
-rw-r--r--nt/config.nt14
-rw-r--r--nt/inc/inttypes.h30
-rw-r--r--src/ChangeLog21
-rw-r--r--src/coding.c5
-rw-r--r--src/doprnt.c62
-rw-r--r--src/eval.c3
9 files changed, 203 insertions, 76 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e6517f77b32..94e0ecafc3d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12011-04-27 Niels Giesen <niels.giesen@gmail.com>
2
3 * calendar/icalendar.el (diary-lib): Add require statement.
4 (icalendar--create-uid): Read out a uid from a text-property on
5 the first character in the entry. This allows for code to add its
6 own uid to the entry.
7 (icalendar--convert-float-to-ical): Add export of
8 `diary-float'-entries save for those with the optional DAY
9 argument.
10
12011-04-27 Daniel Colascione <dan.colascione@gmail.com> 112011-04-27 Daniel Colascione <dan.colascione@gmail.com>
2 12
3 * subr.el (shell-quote-argument): Use alternate escaping strategy 13 * subr.el (shell-quote-argument): Use alternate escaping strategy
@@ -7,7 +17,7 @@
7 17
8 * cus-start.el (all): Define customization for debug-on-event. 18 * cus-start.el (all): Define customization for debug-on-event.
9 19
102011-04-26 Daniel Colascione <dan.colascione@gmail.com> 202011-04-26 Daniel Colascione <dan.colascione@gmail.com>
11 21
12 * subr.el (shell-quote-argument): Escape correctly under Windows. 22 * subr.el (shell-quote-argument): Escape correctly under Windows.
13 23
@@ -65,7 +75,7 @@
65 (gnutls-negotiate): Adjust `gnutls-negotiate' declaration. 75 (gnutls-negotiate): Adjust `gnutls-negotiate' declaration.
66 * subr.el (shell-quote-argument): Escape correctly under Windows. 76 * subr.el (shell-quote-argument): Escape correctly under Windows.
67 77
682011-04-24 Daniel Colascione <dan.colascione@gmail.com> 782011-04-24 Daniel Colascione <dan.colascione@gmail.com>
69 79
70 * progmodes/cc-engine.el (c-forward-decl-or-cast-1): 80 * progmodes/cc-engine.el (c-forward-decl-or-cast-1):
71 Use correct match group (bug#8438). 81 Use correct match group (bug#8438).
@@ -131,7 +141,7 @@
131 * image-mode.el (image-type, image-mode-map, image-minor-mode-map) 141 * image-mode.el (image-type, image-mode-map, image-minor-mode-map)
132 (image-toggle-display): Doc fix. 142 (image-toggle-display): Doc fix.
133 143
1342011-04-23 Stephen Berman <stephen.berman@gmx.net> 1442011-04-23 Stephen Berman <stephen.berman@gmx.net>
135 145
136 * textmodes/page.el (what-page): Use line-number-at-pos to 146 * textmodes/page.el (what-page): Use line-number-at-pos to
137 calculate line number (Bug#6825). 147 calculate line number (Bug#6825).
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index ca88548138b..03456ba36f2 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -34,6 +34,8 @@
34;; week of the year 2000 when they are exported. 34;; week of the year 2000 when they are exported.
35;; - Yearly diary entries are assumed to occur the first time in the year 35;; - Yearly diary entries are assumed to occur the first time in the year
36;; 1900 when they are exported. 36;; 1900 when they are exported.
37;; - Float diary entries are assumed to occur the first time on the
38;; day when they are exported.
37 39
38;;; History: 40;;; History:
39 41
@@ -241,6 +243,7 @@ code for the event, and your personal domain name."
241;; all the other libs we need 243;; all the other libs we need
242;; ====================================================================== 244;; ======================================================================
243(require 'calendar) 245(require 'calendar)
246(require 'diary-lib)
244 247
245;; ====================================================================== 248;; ======================================================================
246;; misc 249;; misc
@@ -925,27 +928,30 @@ ENTRY-FULL is the full diary entry string. CONTENTS is the
925current iCalendar object, as a string. Increase 928current iCalendar object, as a string. Increase
926`icalendar--uid-count'. Returns the UID string." 929`icalendar--uid-count'. Returns the UID string."
927 (let ((uid icalendar-uid-format)) 930 (let ((uid icalendar-uid-format))
928 931 (if
929 (setq uid (replace-regexp-in-string 932 ;; Allow other apps (such as org-mode) to create its own uid
930 "%c" 933 (get-text-property 0 'uid entry-full)
931 (format "%d" icalendar--uid-count) 934 (setq uid (get-text-property 0 'uid entry-full))
932 uid t t)) 935 (setq uid (replace-regexp-in-string
933 (setq icalendar--uid-count (1+ icalendar--uid-count)) 936 "%c"
934 (setq uid (replace-regexp-in-string 937 (format "%d" icalendar--uid-count)
935 "%t" 938 uid t t))
936 (format "%d%d%d" (car (current-time)) 939 (setq icalendar--uid-count (1+ icalendar--uid-count))
937 (cadr (current-time)) 940 (setq uid (replace-regexp-in-string
938 (car (cddr (current-time)))) 941 "%t"
939 uid t t)) 942 (format "%d%d%d" (car (current-time))
940 (setq uid (replace-regexp-in-string 943 (cadr (current-time))
941 "%h" 944 (car (cddr (current-time))))
942 (format "%d" (abs (sxhash entry-full))) uid t t)) 945 uid t t))
943 (setq uid (replace-regexp-in-string 946 (setq uid (replace-regexp-in-string
944 "%u" (or user-login-name "UNKNOWN_USER") uid t t)) 947 "%h"
945 (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents) 948 (format "%d" (abs (sxhash entry-full))) uid t t))
946 (substring contents (match-beginning 1) (match-end 1)) 949 (setq uid (replace-regexp-in-string
947 "DTSTART"))) 950 "%u" (or user-login-name "UNKNOWN_USER") uid t t))
948 (setq uid (replace-regexp-in-string "%s" dtstart uid t t))) 951 (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents)
952 (substring contents (match-beginning 1) (match-end 1))
953 "DTSTART")))
954 (setq uid (replace-regexp-in-string "%s" dtstart uid t t))))
949 955
950 ;; Return the UID string 956 ;; Return the UID string
951 uid)) 957 uid))
@@ -1545,18 +1551,65 @@ entries. ENTRY-MAIN is the first line of the diary entry."
1545 nil)) 1551 nil))
1546 1552
1547(defun icalendar--convert-float-to-ical (nonmarker entry-main) 1553(defun icalendar--convert-float-to-ical (nonmarker entry-main)
1548 "Convert float diary entry to icalendar format -- unsupported! 1554 "Convert float diary entry to icalendar format -- partially unsupported!
1549 1555
1550FIXME! 1556 FIXME! DAY from diary-float yet unimplemented.
1551 1557
1552NONMARKER is a regular expression matching the start of non-marking 1558 NONMARKER is a regular expression matching the start of non-marking
1553entries. ENTRY-MAIN is the first line of the diary entry." 1559 entries. ENTRY-MAIN is the first line of the diary entry."
1554 (if (string-match (concat nonmarker 1560 (if (string-match (concat nonmarker "%%\\((diary-float .+\\) ?$") entry-main)
1555 "%%(diary-float \\([^)]+\\))\\s-*\\(.*?\\) ?$") 1561 (with-temp-buffer
1556 entry-main) 1562 (insert (match-string 1 entry-main))
1557 (progn 1563 (goto-char (point-min))
1558 (icalendar--dmsg "diary-float %s" entry-main) 1564 (let* ((sexp (read (current-buffer))) ;using `read' here
1559 (error "`diary-float' is not supported yet")) 1565 ;easier than regexp
1566 ;matching, esp. with
1567 ;different forms of
1568 ;MONTH
1569 (month (nth 1 sexp))
1570 (dayname (nth 2 sexp))
1571 (n (nth 3 sexp))
1572 (day (nth 4 sexp))
1573 (summary
1574 (replace-regexp-in-string
1575 "\\(^\s+\\|\s+$\\)" ""
1576 (buffer-substring (point) (point-max)))))
1577
1578 (when day
1579 (progn
1580 (icalendar--dmsg "diary-float %s" entry-main)
1581 (error "Don't know if or how to implement day in `diary-float'")))
1582
1583 (list (concat
1584 ;;Start today (yes this is an arbitrary choice):
1585 "\nDTSTART;VALUE=DATE:"
1586 (format-time-string "%Y%m%d" (current-time))
1587 ;;BUT remove today if `diary-float'
1588 ;;expression does not hold true for today:
1589 (when
1590 (null (let ((date (calendar-current-date))
1591 (entry entry-main))
1592 (diary-float month dayname n)))
1593 (concat
1594 "\nEXDATE;VALUE=DATE:"
1595 (format-time-string "%Y%m%d" (current-time))))
1596 "\nRRULE:"
1597 (if (or (numberp month) (listp month))
1598 "FREQ=YEARLY;BYMONTH="
1599 "FREQ=MONTHLY")
1600 (when
1601 (listp month)
1602 (mapconcat
1603 (lambda (m)
1604 (number-to-string m))
1605 (cadr month) ","))
1606 (when
1607 (numberp month)
1608 (number-to-string month))
1609 ";BYDAY="
1610 (number-to-string n)
1611 (aref icalendar--weekday-array dayname))
1612 summary)))
1560 ;; no match 1613 ;; no match
1561 nil)) 1614 nil))
1562 1615
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 0d03d508557..4c0543ee008 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,9 +1,16 @@
12011-04-27 Eli Zaretskii <eliz@gnu.org>
2
3 * inc/inttypes.h: New file.
4
5 * config.nt (HAVE_DECL_STRTOULL, HAVE_DECL_STRTOUMAX)
6 (HAVE_STRTOULL, HAVE_STRTOUMAX): New macros.
7
12011-04-27 Daniel Colascione <dan.colascione@gmail.com> 82011-04-27 Daniel Colascione <dan.colascione@gmail.com>
2 9
3 * cmdproxy.c (try_dequote_cmdline): Notice variable substitutions 10 * cmdproxy.c (try_dequote_cmdline): Notice variable substitutions
4 inside quotation marks and bail out. 11 inside quotation marks and bail out.
5 12
62011-04-26 Daniel Colascione <dan.colascione@gmail.com> 132011-04-26 Daniel Colascione <dan.colascione@gmail.com>
7 14
8 * cmdproxy.c (try_dequote_cmdline): New function. 15 * cmdproxy.c (try_dequote_cmdline): New function.
9 (main): Use it. 16 (main): Use it.
diff --git a/nt/config.nt b/nt/config.nt
index 74217c9c048..a159234be7d 100644
--- a/nt/config.nt
+++ b/nt/config.nt
@@ -299,6 +299,20 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
299/* Define to 1 if you have the `localtime_r' function. */ 299/* Define to 1 if you have the `localtime_r' function. */
300#undef HAVE_LOCALTIME_R 300#undef HAVE_LOCALTIME_R
301 301
302/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
303 don't. */
304#define HAVE_DECL_STRTOULL 1
305
306/* Define to 1 if you have the declaration of `strtoumax', and to 0 if you
307 don't. */
308#define HAVE_DECL_STRTOUMAX 1
309
310/* Define to 1 if you have the `strtoull' function. */
311#define HAVE_STRTOULL 1
312
313/* Define to 1 if you have the `strtoumax' function. */
314#define HAVE_STRTOUMAX 1
315
302/* Define if you have the 'wchar_t' type. */ 316/* Define if you have the 'wchar_t' type. */
303#define HAVE_WCHAR_T 1 317#define HAVE_WCHAR_T 1
304 318
diff --git a/nt/inc/inttypes.h b/nt/inc/inttypes.h
new file mode 100644
index 00000000000..8f9c6ede760
--- /dev/null
+++ b/nt/inc/inttypes.h
@@ -0,0 +1,30 @@
1/* Replacement inntypes.h file for building GNU Emacs on Windows with MSVC.
2
3Copyright (C) 2011 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef _REPL_INTTYPES_H
21#define _REPL_INTTYPES_H
22
23#ifdef __MINGW32__
24#include_next <inttypes.h>
25#else /* !__MINGW32__ */
26#define uintmax_t unsigned __int64
27#define strtoumax _strtoui64
28#endif /* !__MINGW32__ */
29
30#endif
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
52011-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
52011-04-27 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change) 182011-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
2162011-04-26 Daniel Colascione <dan.colascione@gmail.com> 2292011-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;