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

yamaken at freedesktop.org yamaken at freedesktop.org
Sun Oct 30 09:23:51 PST 2005


Author: yamaken
Date: 2005-10-30 09:23:47 -0800 (Sun, 30 Oct 2005)
New Revision: 1901

Added:
   branches/r5rs/sigscheme/encoding.h
Modified:
   branches/r5rs/sigscheme/encoding.c
   branches/r5rs/sigscheme/sigscheme.h
   branches/r5rs/sigscheme/sigschemetype-compact.h
   branches/r5rs/sigscheme/sigschemetype.h
Log:
* This commit reorganizes encoding-related things into encoding.h

* sigscheme/encoding.c
  - #include "encoding.h"
  - include some other files in portable way
* sigscheme/sigscheme.h
  - (Scm_mb_scan_char, Scm_mb_strlen, Scm_mb_bare_c_strlen,
    Scm_mb_substring, Scm_mb_strref): Move to encoding.h
* sigscheme/sigschemetype.h
  - (SCM_MBS_SET_STR, SCM_MBS_GET_STR, SCM_MBS_SET_SIZE,
    SCM_MBS_GET_SIZE, SCM_MBCINFO_SET_SIZE, SCM_MBCINFO_GET_SIZE,
    SCM_MBCINFO_CLEAR_STATE, SCM_MBCINFO_SET_STATE,
    SCM_MBCINFO_GET_STATE, SCM_MBCINFO_CLEAR_FLAG,
    SCM_MBCINFO_SET_ERROR, SCM_MBCINFO_SET_INCOMPLETE,
    SCM_MBCINFO_ERRORP, SCM_MBCINFO_INCOMPLETEP, SCM_MBCINFO_INIT,
    SCM_MBS_GET_STATE, SCM_MBS_SET_STATE, SCM_MBS_CLEAR_STATE,
    SCM_MBS_INIT, SCM_MBS_SKIP_CHAR): Move to encoding.h
  - (ScmMultibyteState, ScmMultibyteCharInfo, ScmMultibyteString): Ditto
* sigscheme/sigschemetype-compact.h
  - (SCM_MBS_SET_STR, SCM_MBS_GET_STR, SCM_MBS_SET_SIZE,
    SCM_MBS_GET_SIZE, SCM_MBCINFO_SET_SIZE, SCM_MBCINFO_GET_SIZE,
    SCM_MBCINFO_CLEAR_STATE, SCM_MBCINFO_SET_STATE,
    SCM_MBCINFO_GET_STATE, SCM_MBCINFO_CLEAR_FLAG,
    SCM_MBCINFO_SET_ERROR, SCM_MBCINFO_SET_INCOMPLETE,
    SCM_MBCINFO_ERRORP, SCM_MBCINFO_INCOMPLETEP, SCM_MBCINFO_INIT,
    SCM_MBS_GET_STATE, SCM_MBS_SET_STATE, SCM_MBS_CLEAR_STATE,
    SCM_MBS_INIT, SCM_MBS_SKIP_CHAR): Move to encoding.h
  - (ScmMultibyteState, ScmMultibyteCharInfo, ScmMultibyteString): Ditto
* sigscheme/encoding.h
  - New file
  - (SCM_ENCODING_USE_WITH_SIGSCHEME): New macro
  - (SCM_MBS_SET_STR, SCM_MBS_GET_STR, SCM_MBS_SET_SIZE,
    SCM_MBS_GET_SIZE, SCM_MBCINFO_SET_SIZE, SCM_MBCINFO_GET_SIZE,
    SCM_MBCINFO_CLEAR_STATE, SCM_MBCINFO_SET_STATE,
    SCM_MBCINFO_GET_STATE, SCM_MBCINFO_CLEAR_FLAG,
    SCM_MBCINFO_SET_ERROR, SCM_MBCINFO_SET_INCOMPLETE,
    SCM_MBCINFO_ERRORP, SCM_MBCINFO_INCOMPLETEP, SCM_MBCINFO_INIT,
    SCM_MBS_GET_STATE, SCM_MBS_SET_STATE, SCM_MBS_CLEAR_STATE,
    SCM_MBS_INIT, SCM_MBS_SKIP_CHAR): Move from sigschemetype*.h
  - (ScmMultibyteState, ScmMultibyteCharInfo, ScmMultibyteString): Ditto
  - (Scm_mb_scan_char, Scm_mb_strlen, Scm_mb_bare_c_strlen,
    Scm_mb_substring, Scm_mb_strref): Move from sigscheme.h


Modified: branches/r5rs/sigscheme/encoding.c
===================================================================
--- branches/r5rs/sigscheme/encoding.c	2005-10-30 17:05:09 UTC (rev 1900)
+++ branches/r5rs/sigscheme/encoding.c	2005-10-30 17:23:47 UTC (rev 1901)
@@ -1,6 +1,6 @@
 /*===========================================================================
  *  FileName : encoding.c
- *  About    : handling encoding
+ *  About    : Character encoding handling
  *
  *  Copyright (C) 2005      by Kazuki Ohta (mover at hct.zaq.ne.jp)
  *
@@ -37,15 +37,22 @@
  * authors, Tomohiro KUBOTA, et al. */
 
 
+/* This file is going to be portable. Don't depend on SigScheme if possible. */
+
 /*=======================================
   System Include
 =======================================*/
+#include <stdlib.h>
+#include <string.h>
 
 /*=======================================
   Local Include
 =======================================*/
+#include "encoding.h"
+#if SCM_ENCODING_USE_WITH_SIGSCHEME
 #include "sigscheme.h"
 #include "sigschemeinternal.h"
+#endif
 
 /*=======================================
   File Local Functions

Added: branches/r5rs/sigscheme/encoding.h
===================================================================
--- branches/r5rs/sigscheme/encoding.h	2005-10-30 17:05:09 UTC (rev 1900)
+++ branches/r5rs/sigscheme/encoding.h	2005-10-30 17:23:47 UTC (rev 1901)
@@ -0,0 +1,137 @@
+/*===========================================================================
+ *  FileName : encoding.h
+ *  About    : Character encoding handling
+ *
+ *  Copyright (C) 2005      by Kazuki Ohta (mover at hct.zaq.ne.jp)
+ *
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. Neither the name of authors nor the names of its contributors
+ *     may be used to endorse or promote products derived from this software
+ *     without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ *  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+===========================================================================*/
+
+/* This file is going to be portable. Don't depend on SigScheme if possible. */
+
+#ifndef __SCM_ENCODING_H
+#define __SCM_ENCODING_H
+
+/*=======================================
+  System Include
+=======================================*/
+
+/*=======================================
+  Local Include
+=======================================*/
+
+/*=======================================
+  Macro Definitions
+=======================================*/
+#define SCM_ENCODING_USE_WITH_SIGSCHEME 1
+
+#define SCM_MBS_SET_STR(mbs, s)         ((mbs).str = (s))
+#define SCM_MBS_GET_STR(mbs)            ((mbs).str)
+#define SCM_MBS_SET_SIZE(mbs, siz)      ((mbs).size = (siz))
+#define SCM_MBS_GET_SIZE(mbs)           ((mbs).size)
+
+#define SCM_MBCINFO_SET_SIZE SCM_MBS_SET_SIZE
+#define SCM_MBCINFO_GET_SIZE SCM_MBS_GET_SIZE
+#define SCM_MBCINFO_CLEAR_STATE SCM_MBS_CLEAR_STATE
+#define SCM_MBCINFO_SET_STATE SCM_MBS_SET_STATE
+#define SCM_MBCINFO_GET_STATE SCM_MBS_GET_STATE
+#define SCM_MBCINFO_CLEAR_FLAG(inf)     ((inf).flag = 0)
+#define SCM_MBCINFO_SET_ERROR(inf)      ((inf).flag |= 1)
+#define SCM_MBCINFO_SET_INCOMPLETE(inf) ((inf).flag |= 2)
+#define SCM_MBCINFO_ERRORP(inf)         ((inf).flag & 1)
+#define SCM_MBCINFO_INCOMPLETEP(inf)    ((inf).flag & 2)
+#define SCM_MBCINFO_INIT(inf)  (SCM_MBCINFO_SET_SIZE((inf), 0),  \
+                                SCM_MBCINFO_CLEAR_STATE(inf),    \
+                                SCM_MBCINFO_CLEAR_FLAG(inf))
+
+
+#if SCM_USE_STATEFUL_ENCODING
+#define SCM_MBS_GET_STATE(mbs)        ((mbs).state)
+#define SCM_MBS_SET_STATE(mbs, stat)  ((mbs).state = (stat))
+#define SCM_MBS_CLEAR_STATE(mbs)      ((mbs).state = 0)
+#else
+#define SCM_MBS_GET_STATE(mbs)        0
+#define SCM_MBS_SET_STATE(mbs, stat)  0
+#define SCM_MBS_CLEAR_STATE(mbs)      0
+#endif
+#define SCM_MBS_INIT(mbs)  (SCM_MBS_SET_STR((mbs), NULL), \
+                            SCM_MBS_SET_SIZE((mbs), 0),   \
+                            SCM_MBS_CLEAR_STATE(mbs))
+#define SCM_MBS_SKIP_CHAR(mbs, inf)                                           \
+    (SCM_MBS_SET_STR((mbs), SCM_MBS_GET_STR(mbs) + SCM_MBCINFO_GET_SIZE(inf)),\
+     SCM_MBS_SET_SIZE((mbs),                                                  \
+                      SCM_MBS_GET_SIZE(mbs) - SCM_MBCINFO_GET_SIZE(inf)),     \
+     SCM_MBS_SET_STATE((mbs), SCM_MBCINFO_GET_STATE(inf)))
+
+/*=======================================
+  Type Definitions
+=======================================*/
+/* This type will actually contain some encoding-dependent enum value.
+ * It might as well be defined as mbstate_t if we're using libc. */
+typedef int ScmMultibyteState;
+
+/* Metadata of a multibyte character.  These are usually allocated on
+   stack or register, so we'll make liberal use of space. */
+typedef struct {
+    const char *start;
+    int flag;
+    int size;
+
+#if SCM_USE_STATEFUL_ENCODING
+    /* Shift state at the *end* of the described character. */
+    ScmMultibyteState state;
+#endif
+} ScmMultibyteCharInfo;
+
+typedef struct {
+    const char *str;
+
+    /* Only the size is stored because ScmObj caches the length, and
+     * we'll have to traverse from the beginning all the time
+     * anyway. */
+    int size;
+#if SCM_USE_STATEFUL_ENCODING
+    ScmMultibyteState state;
+#endif
+} ScmMultibyteString;
+
+/*=======================================
+   Variable Declarations
+=======================================*/
+extern ScmMultibyteCharInfo (*Scm_mb_scan_char)(ScmMultibyteString mbs);
+
+/*=======================================
+   Function Declarations
+=======================================*/
+int Scm_mb_strlen(ScmMultibyteString mbs);
+int Scm_mb_bare_c_strlen(const char *str);
+ScmMultibyteString Scm_mb_substring(ScmMultibyteString str, int i, int len);
+#define Scm_mb_strref(str, i) (Scm_mb_substring((str), (i), 1))
+
+
+#endif /* __SCM_ENCODING_H */

Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h	2005-10-30 17:05:09 UTC (rev 1900)
+++ branches/r5rs/sigscheme/sigscheme.h	2005-10-30 17:23:47 UTC (rev 1901)
@@ -50,6 +50,7 @@
    Local Include
 =======================================*/
 #include "config.h"
+#include "encoding.h"
 
 /*=======================================
    Macro Declarations
@@ -561,13 +562,6 @@
 ScmObj ScmOp_delete_file(ScmObj filepath);
 #endif
 
-/* encoding.c */
-int Scm_mb_strlen(ScmMultibyteString mbs);
-int Scm_mb_bare_c_strlen(const char *str);
-ScmMultibyteString Scm_mb_substring(ScmMultibyteString str, int i, int len);
-#define Scm_mb_strref(str, i) (Scm_mb_substring((str), (i), 1))
-extern ScmMultibyteCharInfo (*Scm_mb_scan_char)(ScmMultibyteString mbs);
-
 /* read.c */
 ScmObj SigScm_Read(ScmObj port);
 ScmObj SigScm_Read_Char(ScmObj port);

Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h	2005-10-30 17:05:09 UTC (rev 1900)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h	2005-10-30 17:23:47 UTC (rev 1901)
@@ -218,77 +218,6 @@
 };
 
 /*=======================================
-   Multibyte encoding support
-=======================================*/
-
-/* This type will actually contain some encoding-dependent enum value.
- * It might as well be defined as mbstate_t if we're using libc. */
-typedef int ScmMultibyteState;
-
-/* Metadata of a multibyte character.  These are usually allocated on
-   stack or register, so we'll make liberal use of space. */
-typedef struct {
-    const char *start;
-    int flag;
-    int size;
-
-#if SCM_USE_STATEFUL_ENCODING
-    /* Shift state at the *end* of the described character. */
-    ScmMultibyteState state;
-#endif
-} ScmMultibyteCharInfo;
-
-typedef struct {
-    const char *str;
-
-    /* Only the size is stored because ScmObj caches the length, and
-     * we'll have to traverse from the beginning all the time
-     * anyway. */
-    int size;
-#if SCM_USE_STATEFUL_ENCODING
-    ScmMultibyteState state;
-#endif
-} ScmMultibyteString;
-
-#define SCM_MBS_SET_STR(mbs, s)         ((mbs).str = (s))
-#define SCM_MBS_GET_STR(mbs)            ((mbs).str)
-#define SCM_MBS_SET_SIZE(mbs, siz)      ((mbs).size = (siz))
-#define SCM_MBS_GET_SIZE(mbs)           ((mbs).size)
-
-#define SCM_MBCINFO_SET_SIZE SCM_MBS_SET_SIZE
-#define SCM_MBCINFO_GET_SIZE SCM_MBS_GET_SIZE
-#define SCM_MBCINFO_CLEAR_STATE SCM_MBS_CLEAR_STATE
-#define SCM_MBCINFO_SET_STATE SCM_MBS_SET_STATE
-#define SCM_MBCINFO_GET_STATE SCM_MBS_GET_STATE
-#define SCM_MBCINFO_CLEAR_FLAG(inf)     ((inf).flag = 0)
-#define SCM_MBCINFO_SET_ERROR(inf)      ((inf).flag |= 1)
-#define SCM_MBCINFO_SET_INCOMPLETE(inf) ((inf).flag |= 2)
-#define SCM_MBCINFO_ERRORP(inf)         ((inf).flag & 1)
-#define SCM_MBCINFO_INCOMPLETEP(inf)    ((inf).flag & 2)
-#define SCM_MBCINFO_INIT(inf)  (SCM_MBCINFO_SET_SIZE((inf), 0),  \
-                                SCM_MBCINFO_CLEAR_STATE(inf),    \
-                                SCM_MBCINFO_CLEAR_FLAG(inf))
-
-
-#if SCM_USE_STATEFUL_ENCODING
-#define SCM_MBS_GET_STATE(mbs)        ((mbs).state)
-#define SCM_MBS_SET_STATE(mbs, stat)  ((mbs).state = (stat))
-#define SCM_MBS_CLEAR_STATE(mbs)      ((mbs).state = 0)
-#else
-#define SCM_MBS_GET_STATE(mbs)        0
-#define SCM_MBS_SET_STATE(mbs, stat)  0
-#define SCM_MBS_CLEAR_STATE(mbs)      0
-#endif
-#define SCM_MBS_INIT(mbs)  (SCM_MBS_SET_STR((mbs), NULL), \
-                            SCM_MBS_SET_SIZE((mbs), 0),   \
-                            SCM_MBS_CLEAR_STATE(mbs))
-#define SCM_MBS_SKIP_CHAR(mbs, inf)                                           \
-    (SCM_MBS_SET_STR((mbs), SCM_MBS_GET_STR(mbs) + SCM_MBCINFO_GET_SIZE(inf)),\
-     SCM_MBS_SET_SIZE((mbs),                                                  \
-                      SCM_MBS_GET_SIZE(mbs) - SCM_MBCINFO_GET_SIZE(inf)),     \
-     SCM_MBS_SET_STATE((mbs), SCM_MBCINFO_GET_STATE(inf)))
-
-/*=======================================
    Masks Offsets, and Tags
 =======================================*/
 #define SCM_GCBIT_WIDTH     1

Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h	2005-10-30 17:05:09 UTC (rev 1900)
+++ branches/r5rs/sigscheme/sigschemetype.h	2005-10-30 17:23:47 UTC (rev 1901)
@@ -248,79 +248,6 @@
 };
 
 /*=======================================
-   Multibyte encoding support
-=======================================*/
-
-/* This type will actually contain some encoding-dependent enum value.
- * It might as well be defined as mbstate_t if we're using libc. */
-typedef int ScmMultibyteState;
-
-/* Metadata of a multibyte character.  These are usually allocated on
-   stack or register, so we'll make liberal use of space. */
-typedef struct {
-    const char *start;
-    int flag;
-    int size;
-
-#if SCM_USE_STATEFUL_ENCODING
-    /* Shift state at the *end* of the described character. */
-    ScmMultibyteState state;
-#endif
-} ScmMultibyteCharInfo;
-
-typedef struct {
-    const char *str;
-
-    /* Only the size is stored because ScmObj caches the length, and
-     * we'll have to traverse from the beginning all the time
-     * anyway. */
-    int size;
-#if SCM_USE_STATEFUL_ENCODING
-    ScmMultibyteState state;
-#endif
-} ScmMultibyteString;
-
-#define SCM_MBS_SET_STR(mbs, s)         ((mbs).str = (s))
-#define SCM_MBS_GET_STR(mbs)            ((mbs).str)
-#define SCM_MBS_SET_SIZE(mbs, siz)      ((mbs).size = (siz))
-#define SCM_MBS_GET_SIZE(mbs)           ((mbs).size)
-
-#define SCM_MBCINFO_SET_SIZE SCM_MBS_SET_SIZE
-#define SCM_MBCINFO_GET_SIZE SCM_MBS_GET_SIZE
-#define SCM_MBCINFO_CLEAR_STATE SCM_MBS_CLEAR_STATE
-#define SCM_MBCINFO_SET_STATE SCM_MBS_SET_STATE
-#define SCM_MBCINFO_GET_STATE SCM_MBS_GET_STATE
-#define SCM_MBCINFO_CLEAR_FLAG(inf)     ((inf).flag = 0)
-#define SCM_MBCINFO_SET_ERROR(inf)      ((inf).flag |= 1)
-#define SCM_MBCINFO_SET_INCOMPLETE(inf) ((inf).flag |= 2)
-#define SCM_MBCINFO_ERRORP(inf)         ((inf).flag & 1)
-#define SCM_MBCINFO_INCOMPLETEP(inf)    ((inf).flag & 2)
-#define SCM_MBCINFO_INIT(inf)  (SCM_MBCINFO_SET_SIZE((inf), 0),  \
-                                SCM_MBCINFO_CLEAR_STATE(inf),    \
-                                SCM_MBCINFO_CLEAR_FLAG(inf))
-
-
-#if SCM_USE_STATEFUL_ENCODING
-#define SCM_MBS_GET_STATE(mbs)        ((mbs).state)
-#define SCM_MBS_SET_STATE(mbs, stat)  ((mbs).state = (stat))
-#define SCM_MBS_CLEAR_STATE(mbs)      ((mbs).state = 0)
-#else
-#define SCM_MBS_GET_STATE(mbs)        0
-#define SCM_MBS_SET_STATE(mbs, stat)  0
-#define SCM_MBS_CLEAR_STATE(mbs)      0
-#endif
-#define SCM_MBS_INIT(mbs)  (SCM_MBS_SET_STR((mbs), NULL), \
-                            SCM_MBS_SET_SIZE((mbs), 0),   \
-                            SCM_MBS_CLEAR_STATE(mbs))
-#define SCM_MBS_SKIP_CHAR(mbs, inf)                                           \
-    (SCM_MBS_SET_STR((mbs), SCM_MBS_GET_STR(mbs) + SCM_MBCINFO_GET_SIZE(inf)),\
-     SCM_MBS_SET_SIZE((mbs),                                                  \
-                      SCM_MBS_GET_SIZE(mbs) - SCM_MBCINFO_GET_SIZE(inf)),     \
-     SCM_MBS_SET_STATE((mbs), SCM_MBCINFO_GET_STATE(inf)))
-
-
-
-/*=======================================
    Accessors For Scheme Objects
 =======================================*/
 /* ScmObj Global Attribute */



More information about the uim-commit mailing list