diff options
| author | Jim Blandy | 1993-07-07 10:22:05 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-07-07 10:22:05 +0000 |
| commit | 50aa2f903214029eabee4b5420eddd594394e111 (patch) | |
| tree | c137b880590ef61801244c70bb7c9a935a7667d8 /src | |
| parent | 82a82d4881e577d717c483ca9c7255e4d3bd8997 (diff) | |
| download | emacs-50aa2f903214029eabee4b5420eddd594394e111.tar.gz emacs-50aa2f903214029eabee4b5420eddd594394e111.zip | |
* editfns.c (Fformat): Since floats occupy two elements in the
argument list passed to doprnt, we must use separate indices for
the array of arguments passed to Fformat, and the array of
arguments to be passed to doprnt.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/editfns.c b/src/editfns.c index 93b7c405cd1..78f1b1a710a 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1394,29 +1394,34 @@ Use %% to put a single % into the output.") | |||
| 1394 | 1394 | ||
| 1395 | { | 1395 | { |
| 1396 | register int nstrings = n + 1; | 1396 | register int nstrings = n + 1; |
| 1397 | |||
| 1398 | /* Allocate twice as many strings as we have %-escapes; floats occupy | ||
| 1399 | two slots, and we're not sure how many of those we have. */ | ||
| 1397 | register unsigned char **strings | 1400 | register unsigned char **strings |
| 1398 | = (unsigned char **) alloca (nstrings * sizeof (unsigned char *)); | 1401 | = (unsigned char **) alloca (2 * nstrings * sizeof (unsigned char *)); |
| 1402 | int i; | ||
| 1399 | 1403 | ||
| 1404 | i = 0; | ||
| 1400 | for (n = 0; n < nstrings; n++) | 1405 | for (n = 0; n < nstrings; n++) |
| 1401 | { | 1406 | { |
| 1402 | if (n >= nargs) | 1407 | if (n >= nargs) |
| 1403 | strings[n] = (unsigned char *) ""; | 1408 | strings[i++] = (unsigned char *) ""; |
| 1404 | else if (XTYPE (args[n]) == Lisp_Int) | 1409 | else if (XTYPE (args[n]) == Lisp_Int) |
| 1405 | /* We checked above that the corresponding format effector | 1410 | /* We checked above that the corresponding format effector |
| 1406 | isn't %s, which would cause MPV. */ | 1411 | isn't %s, which would cause MPV. */ |
| 1407 | strings[n] = (unsigned char *) XINT (args[n]); | 1412 | strings[i++] = (unsigned char *) XINT (args[n]); |
| 1408 | #ifdef LISP_FLOAT_TYPE | 1413 | #ifdef LISP_FLOAT_TYPE |
| 1409 | else if (XTYPE (args[n]) == Lisp_Float) | 1414 | else if (XTYPE (args[n]) == Lisp_Float) |
| 1410 | { | 1415 | { |
| 1411 | union { double d; int half[2]; } u; | 1416 | union { double d; int half[2]; } u; |
| 1412 | 1417 | ||
| 1413 | u.d = XFLOAT (args[n])->data; | 1418 | u.d = XFLOAT (args[n])->data; |
| 1414 | strings[n++] = (unsigned char *) u.half[0]; | 1419 | strings[i++] = (unsigned char *) u.half[0]; |
| 1415 | strings[n] = (unsigned char *) u.half[1]; | 1420 | strings[i++] = (unsigned char *) u.half[1]; |
| 1416 | } | 1421 | } |
| 1417 | #endif | 1422 | #endif |
| 1418 | else | 1423 | else |
| 1419 | strings[n] = XSTRING (args[n])->data; | 1424 | strings[i++] = XSTRING (args[n])->data; |
| 1420 | } | 1425 | } |
| 1421 | 1426 | ||
| 1422 | /* Format it in bigger and bigger buf's until it all fits. */ | 1427 | /* Format it in bigger and bigger buf's until it all fits. */ |
| @@ -1425,7 +1430,7 @@ Use %% to put a single % into the output.") | |||
| 1425 | buf = (char *) alloca (total + 1); | 1430 | buf = (char *) alloca (total + 1); |
| 1426 | buf[total - 1] = 0; | 1431 | buf[total - 1] = 0; |
| 1427 | 1432 | ||
| 1428 | length = doprnt (buf, total + 1, strings[0], end, nargs, strings + 1); | 1433 | length = doprnt (buf, total + 1, strings[0], end, i-1, strings + 1); |
| 1429 | if (buf[total - 1] == 0) | 1434 | if (buf[total - 1] == 0) |
| 1430 | break; | 1435 | break; |
| 1431 | 1436 | ||