[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] simple-print
From: |
Daniel Skarda |
Subject: |
[patch] simple-print |
Date: |
30 May 2001 15:04:32 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Hello,
few days ago I got quite confused - format did not respect my formating
string. Later I found that I forgot to type (use-modules (ice-9 format)).
To safe other guile users from similar surprise I patched simple-format so it
is more compatible with format from (ice-9 format)
Dan
--- print.c.old Wed May 30 14:36:52 2001
+++ print.c Wed May 30 14:32:32 2001
@@ -942,25 +942,43 @@
for (p = start; p != end; ++p)
if (*p == '~')
{
- if (!SCM_CONSP (args))
- continue;
-
if (++p == end)
- continue;
-
- if (*p == 'A' || *p == 'a')
- writingp = 0;
- else if (*p == 'S' || *p == 's')
- writingp = 1;
- else
- continue;
+ break;
+
+ switch (*p)
+ {
+ case 'A': case 'a':
+ writingp = 0;
+ break;
+ case 'S': case 's':
+ writingp = 1;
+ break;
+ case '~':
+ scm_lfwrite (start, p - start, destination);
+ start = p + 1;
+ continue;
+ default:
+ scm_misc_error (s_scm_simple_format,
+ "FORMAT: Unsupported format option ~~~A - use (ice-9 format)
instead",
+ SCM_LIST1 (SCM_MAKE_CHAR (*p)));
+
+ }
+
+ if (!SCM_CONSP (args))
+ scm_misc_error (s_scm_simple_format, "FORMAT: Missing argument for
~~~A",
+ SCM_LIST1 (SCM_MAKE_CHAR (*p)));
+
scm_lfwrite (start, p - start - 1, destination);
scm_prin1 (SCM_CAR (args), destination, writingp);
args = SCM_CDR (args);
start = p + 1;
}
+
scm_lfwrite (start, p - start, destination);
+ if (args != SCM_EOL)
+ scm_misc_error (s_scm_simple_format,
+ "FORMAT: ~A superfluous arguments", SCM_LIST1 (scm_length
(args)));
if (fReturnString)
answer = scm_strport_to_string (destination);
- [patch] simple-print,
Daniel Skarda <=