* another symbol-printing fix
@ 2003-12-02 0:45 Paul Jarc
2004-01-05 18:55 ` Paul Jarc
0 siblings, 1 reply; 3+ messages in thread
From: Paul Jarc @ 2003-12-02 0:45 UTC (permalink / raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 498 bytes --]
Squashing more bugs for weird symbol names.
* print.c (scm_print_symbol_name): Handle #{`foo}#, #{,foo}#,
and #{.}# specially.
This is still not complete, though. There are still problem cases
like #{0.0}#, #{-i}#, etc. Rather than trying to duplicate all the
number-detection logic from scm_lreadr, maybe it would be best to
handle just the few non-numeric special cases, and then try
scm_i_mem2number(); if that returns non-#f, treat the symbol name as
weird. I'll work on a patch.
paul
[-- Attachment #2: print-symbol-special.patch --]
[-- Type: text/x-patch, Size: 699 bytes --]
Index: guile-core/libguile/print.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/print.c,v
retrieving revision 1.157
diff -u -r1.157 print.c
--- guile-core/libguile/print.c 30 Nov 2003 00:57:14 -0000 1.157
+++ guile-core/libguile/print.c 2 Dec 2003 00:39:33 -0000
@@ -324,7 +324,8 @@
* name we've looked at so far. */
int all_digits = 1;
- if (len == 0 || str[0] == '\'' || str[0] == ':' || str[len-1] == ':')
+ if (len == 0 || str[0] == '\'' || str[0] == '`' || str[0] == ',' ||
+ str[0] == ':' || str[len-1] == ':' || (str[0] == '.' && len == 1))
{
scm_lfwrite ("#{", 2, port);
weird = 1;
[-- Attachment #3: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: another symbol-printing fix
2003-12-02 0:45 another symbol-printing fix Paul Jarc
@ 2004-01-05 18:55 ` Paul Jarc
2004-01-10 22:28 ` Marius Vollmer
0 siblings, 1 reply; 3+ messages in thread
From: Paul Jarc @ 2004-01-05 18:55 UTC (permalink / raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 574 bytes --]
I wrote:
> * print.c (scm_print_symbol_name): Handle #{`foo}#, #{,foo}#,
> and #{.}# specially.
>
> This is still not complete, though. There are still problem cases
> like #{0.0}#, #{-i}#, etc.
This patch handles those numeric cases. It incorporates and overrides
my earlier patch. After this, there are no remaining buggy cases to
solve, AFAIK: any symbol, no matter how strange, should be able to be
written and re-read, resulting in the same symbol.
* print.c (scm_print_symbol_name): Handle #{`foo}#, #{,foo}#,
#{.}#, and all numeric strings specially.
paul
[-- Attachment #2: print-numbers.patch --]
[-- Type: text/x-patch, Size: 2435 bytes --]
Index: guile-core/libguile/print.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/print.c,v
retrieving revision 1.157
diff -u -r1.157 print.c
--- guile-core/libguile/print.c 30 Nov 2003 00:57:14 -0000 1.157
+++ guile-core/libguile/print.c 5 Jan 2004 18:46:45 -0000
@@ -39,6 +39,7 @@
#include "libguile/strports.h"
#include "libguile/vectors.h"
#include "libguile/lang.h"
+#include "libguile/numbers.h"
#include "libguile/validate.h"
#include "libguile/print.h"
@@ -315,16 +316,16 @@
* weird because of other characters, backslahes need to be escaped too.
* The first time we see a backslash, we set maybe_weird, and mw_pos points
* to the backslash. Then if the name turns out to be weird, we re-process
- * everything starting from mw_pos. */
+ * everything starting from mw_pos.
+ * We could instead make backslashes always weird. This is not necessary
+ * to ensure that the output is (read)-able, but it would make this code
+ * simpler and faster. */
int maybe_weird = 0;
size_t mw_pos = 0;
- /* If the name is purely numeric, then it's weird as a whole, even though
- * none of the individual characters is weird. But we won't know this
- * until we reach the end of the name. This flag describes the part of the
- * name we've looked at so far. */
- int all_digits = 1;
- if (len == 0 || str[0] == '\'' || str[0] == ':' || str[len-1] == ':')
+ if (len == 0 || str[0] == '\'' || str[0] == '`' || str[0] == ',' ||
+ str[0] == ':' || str[len-1] == ':' || (str[0] == '.' && len == 1) ||
+ !SCM_FALSEP (scm_i_mem2number(str, len, 10)))
{
scm_lfwrite ("#{", 2, port);
weird = 1;
@@ -344,7 +345,6 @@
case '#':
case SCM_WHITE_SPACES:
case SCM_LINE_INCREMENTORS:
- all_digits = 0;
weird_handler:
if (maybe_weird)
{
@@ -367,7 +367,6 @@
pos = end + 1;
break;
case '\\':
- all_digits = 0;
if (weird)
goto weird_handler;
if (!maybe_weird)
@@ -376,18 +375,9 @@
mw_pos = pos;
}
break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- break;
default:
- all_digits = 0;
break;
}
- if (all_digits)
- {
- scm_lfwrite ("#{", 2, port);
- weird = 1;
- }
if (pos < end)
scm_lfwrite (str + pos, end - pos, port);
if (weird)
[-- Attachment #3: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: another symbol-printing fix
2004-01-05 18:55 ` Paul Jarc
@ 2004-01-10 22:28 ` Marius Vollmer
0 siblings, 0 replies; 3+ messages in thread
From: Marius Vollmer @ 2004-01-10 22:28 UTC (permalink / raw)
prj@po.cwru.edu (Paul Jarc) writes:
>> This is still not complete, though. There are still problem cases
>> like #{0.0}#, #{-i}#, etc.
>
> This patch handles those numeric cases. [...]
Applied, thanks! (Good thing I'm so slow, eh? ;-)
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-10 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-02 0:45 another symbol-printing fix Paul Jarc
2004-01-05 18:55 ` Paul Jarc
2004-01-10 22:28 ` Marius Vollmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).