[uim-commit] r1473 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Sun Sep 11 13:26:11 PDT 2005


Author: yamaken
Date: 2005-09-11 13:26:08 -0700 (Sun, 11 Sep 2005)
New Revision: 1473

Modified:
   branches/r5rs/sigscheme/error.c
   branches/r5rs/sigscheme/operations-srfi23.c
   branches/r5rs/sigscheme/sigschemeinternal.h
Log:
* This commit unifies the error message header printing.

  Such unification prevents careless-bug, careless-inconsistency, and
  allows fast and easy implementation change without code-breaking
  risk and being bothered, even if the code is only one line.

  Favor such anti-copy-and-paste coding habit!

* sigscheme/sigschemeinternal.h
  - (SigScm_ShowErrorHeader): New function
  - Add a FIXME comment about inappropriate naming convention for
    global symbols
* sigscheme/error.c
  - (SCM_ERR_HEADER): New macro
  - (SigScm_ShowErrorHeader): New function
  - (SigScm_Die):
    * Replace hard-coded error header with SigScm_ShowErrorHeader()
    * Fix message destination from stdout to scm_current_error_port
  - (SigScm_Error):
    * Replace error header printing with SigScm_ShowErrorHeader()
    * Add a FIXME comment about the responsibility for printing "\n"
  - (SigScm_ErrorObj): Replace error header printing with
    SigScm_ShowErrorHeader()
* sigscheme/operations-srfi23.c
  - (ScmOp_SRFI23_error): Ditto


Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c	2005-09-11 18:36:49 UTC (rev 1472)
+++ branches/r5rs/sigscheme/error.c	2005-09-11 20:26:08 UTC (rev 1473)
@@ -58,6 +58,7 @@
 /*=======================================
   File Local Macro Declarations
 =======================================*/
+#define SCM_ERR_HEADER "Error: "
 
 /*=======================================
   Variable Declarations
@@ -72,8 +73,13 @@
   Function Implementations
 =======================================*/
 int SigScm_Die(const char *msg, const char *filename, int line) {
+    /* prepend header */
+    SigScm_ShowErrorHeader();
+
     /* show message */
-    printf("Error: SigScheme Died : %s (file : %s, line : %d)\n", msg, filename, line);
+    fprintf(SCM_PORTINFO_FILE(scm_current_error_port),
+            "SigScheme Died : %s (file : %s, line : %d)\n",
+            msg, filename, line);
 
     /* show backtrace */
     SigScm_ShowBacktrace();
@@ -88,13 +94,21 @@
 {
     va_list va;
 
-    /* prepend message */
-    fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "Error: ");
+    /* prepend header */
+    SigScm_ShowErrorHeader();
 
     /* show message */
     va_start(va, msg);
     vfprintf(SCM_PORTINFO_FILE(scm_current_error_port), msg, va);
     va_end(va);
+#if 0
+    /*
+     * FIXME: this function should always append "\n" to ensure that an error
+     * message forms a line message, instead of delegating the responsibility
+     * to caller. Otherwise subsequent error messages may be broken.
+     */
+    fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "\n");
+#endif
 
     /* show backtrace */
     SigScm_ShowBacktrace();
@@ -106,7 +120,7 @@
 void SigScm_ErrorObj(const char *msg, ScmObj obj)
 {
     /* prepend header */
-    fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "Error: ");
+    SigScm_ShowErrorHeader();
 
     /* print msg */
     fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "%s", msg);
@@ -136,3 +150,8 @@
         fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "\n");
     }
 }
+
+void SigScm_ShowErrorHeader(void)
+{
+    fprintf(SCM_PORTINFO_FILE(scm_current_error_port), SCM_ERR_HEADER);
+}

Modified: branches/r5rs/sigscheme/operations-srfi23.c
===================================================================
--- branches/r5rs/sigscheme/operations-srfi23.c	2005-09-11 18:36:49 UTC (rev 1472)
+++ branches/r5rs/sigscheme/operations-srfi23.c	2005-09-11 20:26:08 UTC (rev 1473)
@@ -72,8 +72,8 @@
         SigScm_ErrorObj("error : first argument should be string but got ",
                         CAR(args));
     
-    /* prepend message */
-    fprintf(SCM_PORTINFO_FILE(scm_current_error_port), "Error: ");
+    /* prepend header */
+    SigScm_ShowErrorHeader();
 
     /* show message */
     fprintf(SCM_PORTINFO_FILE(scm_current_error_port),

Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h	2005-09-11 18:36:49 UTC (rev 1472)
+++ branches/r5rs/sigscheme/sigschemeinternal.h	2005-09-11 20:26:08 UTC (rev 1473)
@@ -290,11 +290,17 @@
 =======================================*/
 /* eval.c */
 /* environment related functions */
+/*
+ * FIXME: add a 'SCM' prefix to these functions since the symbols will be
+ * global. See objdump -TC libsscm.so.
+ */
 ScmObj extend_environment(ScmObj vars, ScmObj vals, ScmObj env);
 ScmObj add_environment(ScmObj var, ScmObj val, ScmObj env);
 ScmObj lookup_environment(ScmObj var, ScmObj env);
 ScmObj lookup_frame(ScmObj var, ScmObj frame);
 ScmObj symbol_value(ScmObj var, ScmObj env);
 
+/* error.c */
+void SigScm_ShowErrorHeader(void);
 
 #endif /* __SIGSCHEMEINTERNAL_H */



More information about the uim-commit mailing list