aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-04-27 11:22:21 -0700
committerPaul Eggert2011-04-27 11:22:21 -0700
commite810457d006d336b26335fae512d15a1c445b9cd (patch)
tree62e379535266b580c1b79286c8b8c9862e2dc65a
parent2a782793a8596e6724207474bd7545684c83591d (diff)
downloademacs-e810457d006d336b26335fae512d15a1c445b9cd.tar.gz
emacs-e810457d006d336b26335fae512d15a1c445b9cd.zip
* doprnt.c (doprnt): Support "ll" length modifier, for long long.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/doprnt.c31
2 files changed, 32 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e2ac23256a7..b23904a3575 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 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change) 52011-04-27 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change)
2 6
3 * buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Adjust to aliasing 7 * buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Adjust to aliasing
diff --git a/src/doprnt.c b/src/doprnt.c
index 3ac1d9963a9..229ad06e057 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -80,7 +80,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
80 The l (lower-case letter ell) flag is a `long' data type modifier: it is 80 The l (lower-case letter ell) flag is a `long' data type modifier: it is
81 supported for %d, %o, and %x conversions of integral arguments, and means 81 supported for %d, %o, and %x conversions of integral arguments, and means
82 that the respective argument is to be treated as `long int' or `unsigned 82 that the respective argument is to be treated as `long int' or `unsigned
83 long int'. The EMACS_INT data type should use this modifier. 83 long int'. ll means to use 'long long'. EMACS_INT arguments
84 should use the pI macro, which expands to whatever length modifier
85 is needed for the target host, e.g., "", "l", "ll".
84 86
85 The width specifier supplies a lower limit for the length of the printed 87 The width specifier supplies a lower limit for the length of the printed
86 representation. The padding, if any, normally goes on the left, but it goes 88 representation. The padding, if any, normally goes on the left, but it goes
@@ -205,6 +207,11 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
205 else if (*fmt == 'l') 207 else if (*fmt == 'l')
206 { 208 {
207 long_flag = 1; 209 long_flag = 1;
210 if (fmt[1] == 'l')
211 {
212 long_flag = 2;
213 fmt++;
214 }
208 if (!strchr ("dox", fmt[1])) 215 if (!strchr ("dox", fmt[1]))
209 /* %l as conversion specifier, not as modifier. */ 216 /* %l as conversion specifier, not as modifier. */
210 break; 217 break;
@@ -244,7 +251,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
244 int i; 251 int i;
245 long l; 252 long l;
246 253
247 if (long_flag) 254 if (1 < long_flag)
255 {
256#ifdef HAVE_LONG_LONG_INT
257 long long ll = va_arg (ap, long long);
258 sprintf (sprintf_buffer, fmtcpy, ll);
259#else
260 abort ();
261#endif
262 }
263 else if (long_flag)
248 { 264 {
249 l = va_arg(ap, long); 265 l = va_arg(ap, long);
250 sprintf (sprintf_buffer, fmtcpy, l); 266 sprintf (sprintf_buffer, fmtcpy, l);
@@ -265,7 +281,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
265 unsigned u; 281 unsigned u;
266 unsigned long ul; 282 unsigned long ul;
267 283
268 if (long_flag) 284 if (1 < long_flag)
285 {
286#ifdef HAVE_UNSIGNED_LONG_LONG_INT
287 unsigned long long ull = va_arg (ap, unsigned long long);
288 sprintf (sprintf_buffer, fmtcpy, ull);
289#else
290 abort ();
291#endif
292 }
293 else if (long_flag)
269 { 294 {
270 ul = va_arg(ap, unsigned long); 295 ul = va_arg(ap, unsigned long);
271 sprintf (sprintf_buffer, fmtcpy, ul); 296 sprintf (sprintf_buffer, fmtcpy, ul);