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

yamaken at freedesktop.org yamaken at freedesktop.org
Sat Jan 14 09:36:33 PST 2006


Author: yamaken
Date: 2006-01-14 09:36:29 -0800 (Sat, 14 Jan 2006)
New Revision: 2915

Modified:
   branches/r5rs/sigscheme/src/error.c
   branches/r5rs/sigscheme/src/read.c
   branches/r5rs/sigscheme/src/sigscheme.h
   branches/r5rs/sigscheme/src/sigschemeinternal.h
   branches/r5rs/sigscheme/src/write.c
Log:
* This commit fix warnings

* sigscheme/src/sigscheme.h
  - (SCM_ASSERT, SCM_ENSURE): Follow the change of scm_die()
  - (scm_die): Change return type to void
* sigscheme/src/error.c
  - (scm_p_inspect_error): Suppress warning
  - (scm_die): Change return type to void
* sigscheme/src/read.c
  - (read_list): Suppress warning
  - (parse_unicode_sequence): Fix broken error detection
  - (read_unicode_sequence): Simplify
  - (parse_number): Rename a local variable
* sigscheme/src/write.c
  - (write_constant): Add false assertion
* sigscheme/src/sigschemeinternal.h
  - (LBUF_INIT, LBUF_FREE, LBUF_ALLOC, LBUF_REALLOC, LBUF_EXTEND):
    Cast to void *


Modified: branches/r5rs/sigscheme/src/error.c
===================================================================
--- branches/r5rs/sigscheme/src/error.c	2006-01-14 16:46:27 UTC (rev 2914)
+++ branches/r5rs/sigscheme/src/error.c	2006-01-14 17:36:29 UTC (rev 2915)
@@ -255,6 +255,8 @@
         objs        = MUST_POP_ARG(rest);
         trace_stack = MUST_POP_ARG(rest);
         ASSERT_NO_MORE_ARG(rest);
+    } else {
+        trace_stack = scm_trace_stack();
     }
 
     if (scm_debug_categories() & SCM_DBG_ERRMSG) {
@@ -269,11 +271,8 @@
         scm_port_newline(scm_err);
     }
 
-    if (scm_debug_categories() & SCM_DBG_BACKTRACE) {
-        if (!ERROBJP(err_obj))
-            trace_stack = scm_trace_stack();
+    if (scm_debug_categories() & SCM_DBG_BACKTRACE)
         scm_show_backtrace(trace_stack);
-    }
 
     return SCM_UNDEF;
 }
@@ -288,7 +287,7 @@
     return SCM_UNDEF;
 }
 
-scm_bool
+void
 scm_die(const char *msg, const char *filename, int line)
 {
     char *reason;
@@ -301,7 +300,6 @@
 
     scm_fatal_error(reason);
     /* NOTREACHED */
-    return scm_true;  /* dummy value for boolean expression */
 }
 
 void

Modified: branches/r5rs/sigscheme/src/read.c
===================================================================
--- branches/r5rs/sigscheme/src/read.c	2006-01-14 16:46:27 UTC (rev 2914)
+++ branches/r5rs/sigscheme/src/read.c	2006-01-14 17:36:29 UTC (rev 2915)
@@ -361,8 +361,7 @@
     CDBG((SCM_DBG_PARSER, "read_list"));
     basecport = SCM_PORT_TRY_DYNAMIC_CAST(ScmBaseCharPort,
                                           SCM_PORT_IMPL(port));
-    if (basecport)
-        start_line = ScmBaseCharPort_line_number(basecport);
+    start_line = (basecport) ? ScmBaseCharPort_line_number(basecport) : -1;
 
     for (lst = SCM_NULL, SCM_QUEUE_POINT_TO(q, lst);; SCM_QUEUE_ADD(q, elm)) {
         c = skip_comment_and_space(port);
@@ -427,12 +426,16 @@
 parse_unicode_sequence(const char *seq, int len)
 {
     int c;
-    char *first_nondigit;
+    char *end;
 
     /* reject ordinary char literal and invalid signed hexadecimal */
     if (len < 3 || !isxdigit(seq[1]))
         return -1;
 
+    c = strtol(&seq[1], &end, 16);
+    if (*end)
+        return -1;
+
     switch (seq[0]) {
     case 'x':
         /* #\x<x><x> : <x> = a hexadecimal digit (ignore case) */
@@ -442,21 +445,24 @@
 
     case 'u':
         /* #\u<x><x><x><x> : Unicode char of BMP */
-        if (len != 5 || (0xd800 <= c && c <= 0xdfff))
+        if (len != 5)
             ERR("invalid Unicode sequence. conform \\u<x><x><x><x>");
         break;
 
     case 'U':
         /* #\U<x><x><x><x><x><x><x><x> : Unicode char of BMP or SMP */
-        if (len != 9 || (0xd800 <= c && c <= 0xdfff) || 0x10ffff < c)
+        if (len != 9)
             ERR("invalid Unicode sequence. conform \\U<x><x><x><x><x><x><x><x>");
         break;
 
     default:
         return -1;
     }
-    c = strtol(&seq[1], &first_nondigit, 16);
-    return (*first_nondigit) ? -1 : c;
+
+    if ((0xd800 <= c && c <= 0xdfff) || 0x10ffff < c)
+        ERR("invalid Unicode value");
+
+    return c;
 }
 
 static int
@@ -471,7 +477,6 @@
     case 'U': len = 8; break;
     default:
         SCM_ASSERT(scm_false);
-        break;
     }
     seq[0] = prefix;
     read_sequence(port, &seq[1], len);
@@ -699,7 +704,7 @@
 parse_number(ScmObj port, char *buf, size_t buf_size, char prefix)
 {
     int radix, number;
-    char *first_nondigit;
+    char *end;
 
     switch (prefix) {
     case 'b': radix = 2;  break;
@@ -710,8 +715,8 @@
         goto err;
     }
 
-    number = strtol(buf, &first_nondigit, radix);
-    if (*first_nondigit)
+    number = strtol(buf, &end, radix);
+    if (*end)
         goto err;
 
     return MAKE_INT(number);

Modified: branches/r5rs/sigscheme/src/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/src/sigscheme.h	2006-01-14 16:46:27 UTC (rev 2914)
+++ branches/r5rs/sigscheme/src/sigscheme.h	2006-01-14 17:36:29 UTC (rev 2915)
@@ -103,7 +103,7 @@
 #if SCM_CHICKEN_DEBUG
 /* allows survival recovery */
 #define SCM_ASSERT(cond)                                                     \
-    ((cond) || scm_die("assertion failed", __FILE__, __LINE__))
+    ((cond) || (scm_die("assertion failed", __FILE__, __LINE__), 1))
 #else /* SCM_CHICKEN_DEBUG */
 #include <assert.h>
 #define SCM_ASSERT(cond) (assert(cond))
@@ -112,7 +112,7 @@
 #define SCM_ASSERT(cond)
 #endif /* SCM_DEBUG */
 #define SCM_ENSURE(cond)                                                     \
-    ((cond) || scm_die("invalid condition", __FILE__, __LINE__))
+    ((cond) || (scm_die("invalid condition", __FILE__, __LINE__), 1))
 
 #define SCM_ENSURE_PROPER_LIST_TERMINATION(term, lst)                        \
     (NULLP(term) || (ERR_OBJ("proper list required but got", (lst)), 1))
@@ -1068,7 +1068,7 @@
 int  scm_predefined_debug_categories(void);
 void scm_categorized_debug(int category, const char *msg, ...);
 void scm_debug(const char *msg, ...);
-scm_bool scm_die(const char *msg, const char *filename, int line);
+void scm_die(const char *msg, const char *filename, int line) SCM_NORETURN;
 void scm_error(const char *msg, ...) SCM_NORETURN;
 void scm_error_obj(const char *funcname, const char *msg,
                    ScmObj obj) SCM_NORETURN;

Modified: branches/r5rs/sigscheme/src/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-01-14 16:46:27 UTC (rev 2914)
+++ branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-01-14 17:36:29 UTC (rev 2915)
@@ -416,19 +416,19 @@
 #define LBUF_EXT_CNT(lbuf)   ((lbuf).extended_cnt)
 
 #define LBUF_INIT(lbuf, init_buf, init_size)                                 \
-    scm_lbuf_init((struct ScmLBuf_void_ *)&(lbuf), (init_buf), (init_size))
+    scm_lbuf_init((void *)&(lbuf), (init_buf), (init_size))
 
 #define LBUF_FREE(lbuf)                                                      \
-    scm_lbuf_free((struct ScmLBuf_void_ *)&(lbuf))
+    scm_lbuf_free((void *)&(lbuf))
 
 #define LBUF_ALLOC(lbuf, size)                                               \
-    scm_lbuf_alloc((struct ScmLBuf_void_ *)&(lbuf), (size))
+    scm_lbuf_alloc((void *)&(lbuf), (size))
 
 #define LBUF_REALLOC(lbuf, size)                                             \
-    scm_lbuf_realloc((struct ScmLBuf_void_ *)&(lbuf), (size))
+    scm_lbuf_realloc((void *)&(lbuf), (size))
 
 #define LBUF_EXTEND(lbuf, f, least_size)                                     \
-    scm_lbuf_extend((struct ScmLBuf_void_ *)&(lbuf), (f), (least_size))
+    scm_lbuf_extend((void *)&(lbuf), (f), (least_size))
 
 void scm_lbuf_init(struct ScmLBuf_void_ *lbuf,
                    void *init_buf, size_t init_size);

Modified: branches/r5rs/sigscheme/src/write.c
===================================================================
--- branches/r5rs/sigscheme/src/write.c	2006-01-14 16:46:27 UTC (rev 2914)
+++ branches/r5rs/sigscheme/src/write.c	2006-01-14 17:36:29 UTC (rev 2915)
@@ -462,6 +462,8 @@
         str = "#<unbound>";
     else if (EQ(obj, SCM_UNDEF))
         str = "#<undef>";
+    else
+        SCM_ASSERT(scm_false);
 
     scm_port_puts(port, str);
 }



More information about the uim-commit mailing list