[uim-commit] r1834 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Oct 9 11:43:49 PDT 2005
Author: yamaken
Date: 2005-10-09 11:43:46 -0700 (Sun, 09 Oct 2005)
New Revision: 1834
Modified:
branches/r5rs/sigscheme/TODO
branches/r5rs/sigscheme/config.h
branches/r5rs/sigscheme/debug.c
branches/r5rs/sigscheme/io.c
branches/r5rs/sigscheme/read.c
branches/r5rs/sigscheme/sigschemeinternal.h
Log:
* This commit adds a base to simplify special character
handlings. Subsequent works are needed. Anyone?
* sigscheme/config.h
- (SCM_USE_SRFI75_NAMED_CHARS): New macro
* sigscheme/sigschemeinternal.h
- (struct ScmSpecialCharInfo_, ScmSpecialCharInfo): New type
- (Scm_special_char_table): New decl
* sigscheme/io.c
- (Scm_special_char_table): New variable
* sigscheme/read.c
- (read_char, read_string): Add FIXME comment
* sigscheme/debug.c
- (print_char, print_string): Ditto
* sigscheme/TODO
- Update
Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/TODO 2005-10-09 18:43:46 UTC (rev 1834)
@@ -14,6 +14,8 @@
API for such purpose is existing, use it
- [uim] Implement string-escape as same as trunk
+* Add integer->char and char->integer procedures
+
* Fix invalid storage model assumption of ScmOp_append() and qquote_internal()
with ScmRef
@@ -48,6 +50,8 @@
* Replace all Scm_ErrorObj() in procedures and syntaxes with ERR_OBJ
+* Simplify special character handlings with Scm_special_char_table
+
* Reorganize SCM_SHIFT*() macros to complement POP_ARG() macro
* Change procedure and syntax registration from dumb function invocation
Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/config.h 2005-10-09 18:43:46 UTC (rev 1834)
@@ -48,6 +48,7 @@
#define SCM_USE_SRFI34 1 /* use SRFI-34 exception handling for programs */
#define SCM_USE_SRFI38 1 /* use SRFI-38 'write-with-shared-structure' */
#define SCM_USE_SRFI60 1 /* use SRFI-60 integers as bits */
+#define SCM_USE_SRFI75_NAMED_CHARS 1 /* use named characters of SRFI-75 R6RS unicode data */
#define SCM_COMPAT_SIOD 1 /* use SIOD compatible features */
#define SCM_COMPAT_SIOD_BUGS 1 /* emulate the buggy behaviors of SIOD */
Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/debug.c 2005-10-09 18:43:46 UTC (rev 1834)
@@ -292,6 +292,7 @@
{
switch (otype) {
case AS_WRITE:
+ /* FIXME: Simplify with Scm_special_char_table */
/*
* in write, character objects are written using the #\ notation.
*/
@@ -333,6 +334,7 @@
*/
SCM_PORT_PRINT(port, "\""); /* first doublequote */
for (i = 0; i < size; i++) {
+ /* FIXME: Simplify with Scm_special_char_table */
c = str[i];
switch (c) {
case '\"': SCM_PORT_PRINT(port, "\\\""); break;
Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/io.c 2005-10-09 18:43:46 UTC (rev 1834)
@@ -60,6 +60,33 @@
static const char *lib_path = NULL;
+const ScmSpecialCharInfo Scm_special_char_table[] = {
+ /* printable characters */
+ {'\"', "\\\"", "\""},
+ {'\\', "\\\\", "\\"},
+ {' ', " ", "space"}, /* R5RS */
+#if 0
+ /* to avoid portability problem, we should not support #\Space and so on */
+ {' ', " ", "Space"},
+#endif
+
+ /* control characters */
+ {'\n', "\\n", "newline"}, /* R5RS */
+#if SCM_USE_SRFI75_NAMED_CHARS
+ {'\0', "\\0", "nul"},
+ {'\a', "\\a", "alarm"},
+ {'\b', "\\b", "backspace"},
+ {'\t', "\\t", "tab"},
+ {'\n', "\\n", "linefeed"},
+ {'\v', "\\v", "vtab"},
+ {'\f', "\\f", "page"},
+ {'\r', "\\r", "return"},
+ {'\x1b', "\\x1b", "esc"},
+ {'\x7f', "\\x7f", "delete"},
+#endif /* SCM_USE_SRFI75_NAMED_CHARS */
+ {0, NULL, NULL}
+};
+
/*=======================================
File Local Function Declarations
=======================================*/
Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/read.c 2005-10-09 18:43:46 UTC (rev 1834)
@@ -295,6 +295,7 @@
CDBG((SCM_DBG_PARSER, "read_char : ch = %s", ch));
+ /* FIXME: Simplify with Scm_special_char_table */
/* check special sequence "space" and "newline" */
if (strcmp(ch, "space") == 0) {
ch[0] = ' ';
@@ -338,6 +339,7 @@
return Scm_NewStringCopying(stringbuf);
case '\\':
+ /* FIXME: Simplify with Scm_special_char_table */
/*
* (R5RS) 6.3.5 String
* A double quote can be written inside a string only by
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-10-08 00:42:23 UTC (rev 1833)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-10-09 18:43:46 UTC (rev 1834)
@@ -45,7 +45,7 @@
#include "sigscheme.h"
/*=======================================
- Struct Declarations
+ Type Definitions
=======================================*/
/* for debugging */
struct trace_frame {
@@ -54,6 +54,13 @@
ScmObj env;
};
+typedef struct ScmSpecialCharInfo_ ScmSpecialCharInfo;
+struct ScmSpecialCharInfo_ {
+ unsigned int code; /* character code as ASCII/Unicode */
+ const char *esc_seq; /* escape sequence as string */
+ const char *lex_rep; /* lexical representation as character object */
+};
+
/*=======================================
Variable Declarations
=======================================*/
@@ -68,6 +75,7 @@
extern ScmObj scm_current_output_port;
extern ScmObj scm_current_error_port;
extern ScmObj SigScm_features;
+extern const ScmSpecialCharInfo Scm_special_char_table[];
/* datas.c */
#if SCM_USE_VALUECONS
More information about the uim-commit
mailing list