[uim-commit] r3080 - branches/r5rs/sigscheme/src

yamaken at freedesktop.org yamaken at freedesktop.org
Thu Feb 2 06:26:18 PST 2006


Author: yamaken
Date: 2006-02-02 06:26:13 -0800 (Thu, 02 Feb 2006)
New Revision: 3080

Modified:
   branches/r5rs/sigscheme/src/load.c
   branches/r5rs/sigscheme/src/sigschemeinternal.h
   branches/r5rs/sigscheme/src/string.c
   branches/r5rs/sigscheme/src/write.c
Log:
* sigscheme/src/sigschemeinternal.h
  - (ICHAR_CONTROLP): New macro
* sigscheme/src/string.c
  - Exclude ctype.h
  - (scm_p_make_string, scm_p_string_setd, strcasecmp,
    scm_p_string_filld): Simplify with ichar macros
* sigscheme/src/load.c
  - Exclude ctype.h
  - (parse_script_prelude): Simplify with ICHAR_ASCIIP()
* sigscheme/src/write.c
  - Exclude ctype.h
  - (write_char): Simplify with ICHAR_CONTROLP()


Modified: branches/r5rs/sigscheme/src/load.c
===================================================================
--- branches/r5rs/sigscheme/src/load.c	2006-02-02 14:02:00 UTC (rev 3079)
+++ branches/r5rs/sigscheme/src/load.c	2006-02-02 14:26:13 UTC (rev 3080)
@@ -39,7 +39,6 @@
 =======================================*/
 #include <stddef.h>
 #include <stdio.h>
-#include <ctype.h>
 #include <string.h>
 
 /*=======================================
@@ -224,13 +223,14 @@
 static char **
 parse_script_prelude(ScmObj port)
 {
-    int argc, c, len, line_len;
+    scm_ichar_t c;
+    int argc, len, line_len;
     char **argv, *arg, *p;
     char line[SCRIPT_PRELUDE_MAXLEN];
 
     for (p = line; p < &line[SCRIPT_PRELUDE_MAXLEN]; p++) {
         c = scm_port_get_char(port);
-        if (!isascii(c))
+        if (!ICHAR_ASCIIP(c))
             PLAIN_ERR("non-ASCII char appeared in UNIX script prelude");
         if (c == SCM_NEWLINE_STR[0]) {
             *p = '\0';

Modified: branches/r5rs/sigscheme/src/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-02-02 14:02:00 UTC (rev 3079)
+++ branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-02-02 14:26:13 UTC (rev 3080)
@@ -461,9 +461,10 @@
 #define ICHAR_CLASS(c)                                                       \
     (ICHAR_ASCIIP(c) ? scm_char_class_table[c] : SCM_CH_NONASCII)
 
+#define ICHAR_CONTROLP(c)    ((0 <= (c) && (c) <= 31) || (c) == 127)
+#define ICHAR_WHITESPACEP(c) ((c) == ' ' || ('\t' <= (c) && (c) <= '\r'))
+#define ICHAR_NUMERICP(c)    ('0' <= (c) && (c) <= '9')
 #define ICHAR_ALPHABETICP(c) (ICHAR_UPPER_CASEP(c) || ICHAR_LOWER_CASEP(c))
-#define ICHAR_NUMERICP(c)    ('0' <= (c) && (c) <= '9')
-#define ICHAR_WHITESPACEP(c) ((c) == ' ' || ('\t' <= (c) && (c) <= '\r'))
 #define ICHAR_UPPER_CASEP(c) ('A' <= (c) && (c) <= 'Z')
 #define ICHAR_LOWER_CASEP(c) ('a' <= (c) && (c) <= 'z')
 

Modified: branches/r5rs/sigscheme/src/string.c
===================================================================
--- branches/r5rs/sigscheme/src/string.c	2006-02-02 14:02:00 UTC (rev 3079)
+++ branches/r5rs/sigscheme/src/string.c	2006-02-02 14:26:13 UTC (rev 3080)
@@ -38,7 +38,6 @@
 /*=======================================
   System Include
 =======================================*/
-#include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -140,7 +139,7 @@
     for (dst = str; dst < &str[ch_len * len]; dst += ch_len)
         memcpy(dst, ch_str, ch_len);
 #else
-    SCM_ASSERT(isascii(filler_val));
+    SCM_ASSERT(ICHAR_ASCIIP(filler_val));
     str = scm_malloc(len + sizeof(""));
     for (dst = str; dst < &str[len];)
         *dst++ = filler_val;
@@ -274,7 +273,7 @@
     SCM_STRING_SET_STR(str, new_str);
 #else
     ch_val = SCM_CHAR_VALUE(ch);
-    SCM_ASSERT(isascii(ch_val));
+    SCM_ASSERT(ICHAR_ASCIIP(ch_val));
     c_str[idx] = ch_val;
 #endif
 
@@ -298,10 +297,8 @@
         if (!c1 && !c2)
             return 0;
 
-        if (isascii(c1))
-            c1 = tolower(c1);
-        if (isascii(c2))
-            c2 = tolower(c2);
+        c1 = ICHAR_FOLDCASE(c1);
+        c2 = ICHAR_FOLDCASE(c2);
         
         if (c1 > c2)
             return 1;
@@ -711,7 +708,7 @@
     SCM_STRING_SET_STR(str, new_str);
 #else
     ch_val = SCM_CHAR_VALUE(ch);
-    SCM_ASSERT(isascii(ch_val));
+    SCM_ASSERT(ICHAR_ASCIIP(ch_val));
     c_str = SCM_STRING_STR(str);
     for (dst = c_str; dst < &c_str[str_len]; dst++)
         *dst = ch_val;

Modified: branches/r5rs/sigscheme/src/write.c
===================================================================
--- branches/r5rs/sigscheme/src/write.c	2006-02-02 14:02:00 UTC (rev 3079)
+++ branches/r5rs/sigscheme/src/write.c	2006-02-02 14:26:13 UTC (rev 3080)
@@ -39,7 +39,6 @@
 =======================================*/
 #include <stdio.h>
 #include <stdarg.h>
-#include <ctype.h>
 #include <string.h>
 
 /*=======================================
@@ -264,7 +263,7 @@
         }
 
         /* other control chars are printed in hexadecimal form */
-        if (isascii(c) && iscntrl(c)) {
+        if (ICHAR_CONTROLP(c)) {
             scm_port_printf(port, "x%02x", (int)c);
             return;
         }



More information about the uim-commit mailing list