aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/doc.c2
-rw-r--r--src/doprnt.c38
3 files changed, 36 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e54b2862523..567c1251480 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12011-04-27 Paul Eggert <eggert@cs.ucla.edu>
2
3 * doprnt.c (doprnt): Support "ll" length modifier, for long long.
4
12011-04-27 Juanma Barranquero <lekktu@gmail.com> 52011-04-27 Juanma Barranquero <lekktu@gmail.com>
2 6
3 * makefile.w32-in: Update dependencies. 7 * makefile.w32-in: Update dependencies.
diff --git a/src/doc.c b/src/doc.c
index d27fa3f792d..3832eb3708d 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -347,6 +347,8 @@ string is passed through `substitute-command-keys'. */)
347 { 347 {
348 if (XSUBR (fun)->doc == 0) 348 if (XSUBR (fun)->doc == 0)
349 return Qnil; 349 return Qnil;
350 /* FIXME: This is not portable, as it assumes that string
351 pointers have the top bit clear. */
350 else if ((EMACS_INT) XSUBR (fun)->doc >= 0) 352 else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
351 doc = build_string (XSUBR (fun)->doc); 353 doc = build_string (XSUBR (fun)->doc);
352 else 354 else
diff --git a/src/doprnt.c b/src/doprnt.c
index 92e2d627432..a6becc7454f 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -70,7 +70,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70 %<flags><width><precision><length>character 70 %<flags><width><precision><length>character
71 71
72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length 72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length
73 modifier is l. 73 modifier is empty or l or ll.
74 74
75 The + flag character inserts a + before any positive number, while a space 75 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, %o, 76 inserts a space before any positive number; these flags only affect %d, %o,
@@ -81,9 +81,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
81 81
82 The l (lower-case letter ell) length modifier is a `long' data type 82 The l (lower-case letter ell) length modifier is a `long' data type
83 modifier: it is supported for %d, %o, and %x conversions of integral 83 modifier: it is supported for %d, %o, and %x conversions of integral
84 arguments, must immediately preced the conversion specifier, and means that 84 arguments, must immediately precede the conversion specifier, and means that
85 the respective argument is to be treated as `long int' or `unsigned long 85 the respective argument is to be treated as `long int' or `unsigned long
86 int'. The EMACS_INT data type should use this modifier. 86 int'. Similarly, ll (two letter ells) means to use `long long int' or
87 `unsigned long long int'; this can be used only on hosts that have
88 these two types. The empty length modifier means to use `int' or
89 `unsigned int'. EMACS_INT arguments should use the pI macro, which
90 expands to whatever length modifier is needed for the target host.
87 91
88 The width specifier supplies a lower limit for the length of the printed 92 The width specifier supplies a lower limit for the length of the printed
89 representation. The padding, if any, normally goes on the left, but it goes 93 representation. The padding, if any, normally goes on the left, but it goes
@@ -208,8 +212,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
208 ; 212 ;
209 else if (*fmt == 'l') 213 else if (*fmt == 'l')
210 { 214 {
211 long_flag = 1; 215 long_flag = 1 + (fmt + 1 < format_end && fmt[1] == 'l');
212 fmt++; 216 fmt += long_flag;
213 break; 217 break;
214 } 218 }
215 else 219 else
@@ -240,7 +244,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
240 { 244 {
241 default: 245 default:
242 error ("Invalid format operation %%%s%c", 246 error ("Invalid format operation %%%s%c",
243 long_flag ? "l" : "", fmt[-1]); 247 "ll" + 2 - long_flag, fmt[-1]);
244 248
245/* case 'b': */ 249/* case 'b': */
246 case 'l': 250 case 'l':
@@ -249,7 +253,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
249 int i; 253 int i;
250 long l; 254 long l;
251 255
252 if (long_flag) 256 if (1 < long_flag)
257 {
258#ifdef HAVE_LONG_LONG_INT
259 long long ll = va_arg (ap, long long);
260 sprintf (sprintf_buffer, fmtcpy, ll);
261#else
262 abort ();
263#endif
264 }
265 else if (long_flag)
253 { 266 {
254 l = va_arg(ap, long); 267 l = va_arg(ap, long);
255 sprintf (sprintf_buffer, fmtcpy, l); 268 sprintf (sprintf_buffer, fmtcpy, l);
@@ -270,7 +283,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
270 unsigned u; 283 unsigned u;
271 unsigned long ul; 284 unsigned long ul;
272 285
273 if (long_flag) 286 if (1 < long_flag)
287 {
288#ifdef HAVE_UNSIGNED_LONG_LONG_INT
289 unsigned long long ull = va_arg (ap, unsigned long long);
290 sprintf (sprintf_buffer, fmtcpy, ull);
291#else
292 abort ();
293#endif
294 }
295 else if (long_flag)
274 { 296 {
275 ul = va_arg(ap, unsigned long); 297 ul = va_arg(ap, unsigned long);
276 sprintf (sprintf_buffer, fmtcpy, ul); 298 sprintf (sprintf_buffer, fmtcpy, ul);