Thread: [KoCo-CVS] [Commit] cjkcodecs/src Makefile map_cp932.c map_generic.c.in map_jisx0208.c map_jisx0212.
Brought to you by:
perky
|
From: Hye-Shik C. <pe...@us...> - 2003-04-22 21:04:36
|
perky 03/04/22 14:04:34
Modified: src cjkcommon.h map_cp932.h map_jisx0208.h
map_jisx0212.h
Added: src Makefile map_cp932.c map_generic.c.in
map_jisx0208.c map_jisx0212.c
Log:
Add dummy map providers for japanese.
Revision Changes Path
1.2 +10 -3 cjkcodecs/src/cjkcommon.h
Index: cjkcommon.h
===================================================================
RCS file: /cvsroot/koco/cjkcodecs/src/cjkcommon.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cjkcommon.h 22 Apr 2003 20:05:58 -0000 1.1
+++ cjkcommon.h 22 Apr 2003 21:04:31 -0000 1.2
@@ -26,19 +26,26 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cjkcommon.h,v 1.1 2003/04/22 20:05:58 perky Exp $
+ * $Id: cjkcommon.h,v 1.2 2003/04/22 21:04:31 perky Exp $
*/
#ifndef _CJKCOMMON_H_
#define _CJKCOMMON_H_
+typedef unsigned short DBCHAR;
+#define UNIINV Py_UNICODE_REPLACEMENT_CHARACTER
+#define NOCHAR 0xFFFF
+
struct dbcs_index {
const Py_UNICODE *map;
unsigned char bottom, top;
};
-#define UNIINV Py_UNICODE_REPLACEMENT_CHARACTER
-#define NOCHAR 0xFFFF
+struct dbcs_map {
+ const char *charset;
+ DBCHAR **encmap;
+ const struct dbcs_index *decmap;
+};
#define JISX0208_C1_BOTTOM 0x21
#define JISX0208_C1_TOP 0x74
1.3 +1 -1 cjkcodecs/src/map_cp932.h
Index: map_cp932.h
===================================================================
RCS file: /cvsroot/koco/cjkcodecs/src/map_cp932.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- map_cp932.h 22 Apr 2003 20:05:58 -0000 1.2
+++ map_cp932.h 22 Apr 2003 21:04:31 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: map_cp932.h,v 1.2 2003/04/22 20:05:58 perky Exp $
+ * $Id: map_cp932.h,v 1.3 2003/04/22 21:04:31 perky Exp $
*/
static const Py_UNICODE __cp932_decmap_81[108] = { /* 81::5F-CA */
@@ -147,7 +147,7 @@
0x9d6b, 0xfa2d, 0x9e19, 0x9ed1,
};
-static const struct dbcs_index *cp932_decmap[128] = {
+static const struct dbcs_index cp932_decmap[128] = {
/* 0x80 */ {0, 0, 0},
/* 0x81 */ {__cp932_decmap_81, 0x5f, 0xca},
/* 0x82 */ {0, 0, 0},
1.3 +1 -1 cjkcodecs/src/map_jisx0208.h
Index: map_jisx0208.h
===================================================================
RCS file: /cvsroot/koco/cjkcodecs/src/map_jisx0208.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- map_jisx0208.h 22 Apr 2003 20:05:58 -0000 1.2
+++ map_jisx0208.h 22 Apr 2003 21:04:33 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: map_jisx0208.h,v 1.2 2003/04/22 20:05:58 perky Exp $
+ * $Id: map_jisx0208.h,v 1.3 2003/04/22 21:04:33 perky Exp $
*/
static const Py_UNICODE __jisx0208_decmap_21[94] = { /* 21::21-7E */
@@ -1123,7 +1123,7 @@
0x582f, 0x69c7, 0x9059, 0x7464, 0x51dc, 0x7199,
};
-static const struct dbcs_index *jisx0208_decmap[128] = {
+static const struct dbcs_index jisx0208_decmap[128] = {
/* 0x00 */ {0, 0, 0},
/* 0x01 */ {0, 0, 0},
/* 0x02 */ {0, 0, 0},
1.3 +1 -1 cjkcodecs/src/map_jisx0212.h
Index: map_jisx0212.h
===================================================================
RCS file: /cvsroot/koco/cjkcodecs/src/map_jisx0212.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- map_jisx0212.h 22 Apr 2003 20:05:59 -0000 1.2
+++ map_jisx0212.h 22 Apr 2003 21:04:33 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: map_jisx0212.h,v 1.2 2003/04/22 20:05:59 perky Exp $
+ * $Id: map_jisx0212.h,v 1.3 2003/04/22 21:04:33 perky Exp $
*/
static const Py_UNICODE __jisx0212_decmap_22[67] = { /* 22::2F-71 */
@@ -996,7 +996,7 @@
0x9fa2, 0x9fa3, 0x9fa5,
};
-static const struct dbcs_index *jisx0212_decmap[128] = {
+static const struct dbcs_index jisx0212_decmap[128] = {
/* 0x00 */ {0, 0, 0},
/* 0x01 */ {0, 0, 0},
/* 0x02 */ {0, 0, 0},
1.1 cjkcodecs/src/Makefile
Index: Makefile
===================================================================
# Makefile: maintenance tool set
#
# Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>.
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
#
# $Id: Makefile,v 1.1 2003/04/22 21:04:31 perky Exp $
#
GENERIC_CHARSETS= cp932 jisx0208 jisx0212
all: genericmaps
genericmaps:
for cset in ${GENERIC_CHARSETS}; do \
CSET=`echo $$cset|tr "[:lower:]" "[:upper:]"`; \
sed -e "s/%%CHARSET%%/$$CSET/g" \
-e "s/%%charset%%/$$cset/g" map_generic.c.in \
> map_$$cset.c; \
done
1.1 cjkcodecs/src/map_cp932.c
Index: map_cp932.c
===================================================================
/*
* map_cp932.c: CP932 Map Provider
*
* Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $Id: map_cp932.c,v 1.1 2003/04/22 21:04:31 perky Exp $
*/
#include "Python.h"
#include "cjkcommon.h"
#include "map_cp932.h"
static DBCHAR *__encode_map[256];
static struct dbcs_map __map_entry = {
"cp932",
__encode_map,
cp932_decmap
};
static int
init_maps(void)
{
const struct dbcs_index *umap;
unsigned char c1, c2;
int i;
for (i = 0; i < 256; i++)
__encode_map[i] = NULL;
for (c1 = CP932_C1_BOTTOM; c1 <= CP932_C2_BOTTOM; c1++) {
umap = &cp932_decmap[c1 & 0x7f];
if (umap->map == NULL)
continue;
for (c2 = umap->bottom; c2 <= umap->top; c2++) {
Py_UNICODE uni;
int upage, i;
uni = umap->map[c2 - umap->bottom];
if (uni == UNIINV)
continue;
upage = uni >> 8;
if (__encode_map[upage] == NULL) {
__encode_map[upage] = PyMem_New(DBCHAR, 256);
if (__encode_map[upage] == NULL)
goto errorexit;
for (i = 0; i <= 255; i++)
__encode_map[upage][i] = NOCHAR;
}
if (__encode_map[upage][uni & 0xff] == NOCHAR)
__encode_map[upage][uni & 0xff] = c1 << 8 | c2;
}
}
return 0;
errorexit:
for (i = 0; i < 256; i++) {
if (__encode_map[i] != NULL)
PyMem_Del(__encode_map[i]);
}
return -1;
}
static struct PyMethodDef __methods[] = {
{NULL, NULL},
};
void
initmap_cp932(void)
{
PyObject *m;
m = Py_InitModule("map_cp932", __methods);
PyModule_AddObject(m, "__map",
PyCObject_FromVoidPtr(&__map_entry, NULL));
if (PyErr_Occurred() || init_maps())
Py_FatalError("can't initialize the map_cp932 module");
}
/*
* ex: ts=8 sts=4 et
*/
1.1 cjkcodecs/src/map_generic.c.in
Index: map_generic.c.in
===================================================================
/*
* map_%%charset%%.c: %%CHARSET%% Map Provider
*
* Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $Id: map_generic.c.in,v 1.1 2003/04/22 21:04:33 perky Exp $
*/
#include "Python.h"
#include "cjkcommon.h"
#include "map_%%charset%%.h"
static DBCHAR *__encode_map[256];
static struct dbcs_map __map_entry = {
"%%charset%%",
__encode_map,
%%charset%%_decmap
};
static int
init_maps(void)
{
const struct dbcs_index *umap;
unsigned char c1, c2;
int i;
for (i = 0; i < 256; i++)
__encode_map[i] = NULL;
for (c1 = %%CHARSET%%_C1_BOTTOM; c1 <= %%CHARSET%%_C2_BOTTOM; c1++) {
umap = &%%charset%%_decmap[c1 & 0x7f];
if (umap->map == NULL)
continue;
for (c2 = umap->bottom; c2 <= umap->top; c2++) {
Py_UNICODE uni;
int upage, i;
uni = umap->map[c2 - umap->bottom];
if (uni == UNIINV)
continue;
upage = uni >> 8;
if (__encode_map[upage] == NULL) {
__encode_map[upage] = PyMem_New(DBCHAR, 256);
if (__encode_map[upage] == NULL)
goto errorexit;
for (i = 0; i <= 255; i++)
__encode_map[upage][i] = NOCHAR;
}
if (__encode_map[upage][uni & 0xff] == NOCHAR)
__encode_map[upage][uni & 0xff] = c1 << 8 | c2;
}
}
return 0;
errorexit:
for (i = 0; i < 256; i++) {
if (__encode_map[i] != NULL)
PyMem_Del(__encode_map[i]);
}
return -1;
}
static struct PyMethodDef __methods[] = {
{NULL, NULL},
};
void
initmap_%%charset%%(void)
{
PyObject *m;
m = Py_InitModule("map_%%charset%%", __methods);
PyModule_AddObject(m, "__map",
PyCObject_FromVoidPtr(&__map_entry, NULL));
if (PyErr_Occurred() || init_maps())
Py_FatalError("can't initialize the map_%%charset%% module");
}
/*
* ex: ts=8 sts=4 et
*/
1.1 cjkcodecs/src/map_jisx0208.c
Index: map_jisx0208.c
===================================================================
/*
* map_jisx0208.c: JISX0208 Map Provider
*
* Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $Id: map_jisx0208.c,v 1.1 2003/04/22 21:04:33 perky Exp $
*/
#include "Python.h"
#include "cjkcommon.h"
#include "map_jisx0208.h"
static DBCHAR *__encode_map[256];
static struct dbcs_map __map_entry = {
"jisx0208",
__encode_map,
jisx0208_decmap
};
static int
init_maps(void)
{
const struct dbcs_index *umap;
unsigned char c1, c2;
int i;
for (i = 0; i < 256; i++)
__encode_map[i] = NULL;
for (c1 = JISX0208_C1_BOTTOM; c1 <= JISX0208_C2_BOTTOM; c1++) {
umap = &jisx0208_decmap[c1 & 0x7f];
if (umap->map == NULL)
continue;
for (c2 = umap->bottom; c2 <= umap->top; c2++) {
Py_UNICODE uni;
int upage, i;
uni = umap->map[c2 - umap->bottom];
if (uni == UNIINV)
continue;
upage = uni >> 8;
if (__encode_map[upage] == NULL) {
__encode_map[upage] = PyMem_New(DBCHAR, 256);
if (__encode_map[upage] == NULL)
goto errorexit;
for (i = 0; i <= 255; i++)
__encode_map[upage][i] = NOCHAR;
}
if (__encode_map[upage][uni & 0xff] == NOCHAR)
__encode_map[upage][uni & 0xff] = c1 << 8 | c2;
}
}
return 0;
errorexit:
for (i = 0; i < 256; i++) {
if (__encode_map[i] != NULL)
PyMem_Del(__encode_map[i]);
}
return -1;
}
static struct PyMethodDef __methods[] = {
{NULL, NULL},
};
void
initmap_jisx0208(void)
{
PyObject *m;
m = Py_InitModule("map_jisx0208", __methods);
PyModule_AddObject(m, "__map",
PyCObject_FromVoidPtr(&__map_entry, NULL));
if (PyErr_Occurred() || init_maps())
Py_FatalError("can't initialize the map_jisx0208 module");
}
/*
* ex: ts=8 sts=4 et
*/
1.1 cjkcodecs/src/map_jisx0212.c
Index: map_jisx0212.c
===================================================================
/*
* map_jisx0212.c: JISX0212 Map Provider
*
* Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $Id: map_jisx0212.c,v 1.1 2003/04/22 21:04:33 perky Exp $
*/
#include "Python.h"
#include "cjkcommon.h"
#include "map_jisx0212.h"
static DBCHAR *__encode_map[256];
static struct dbcs_map __map_entry = {
"jisx0212",
__encode_map,
jisx0212_decmap
};
static int
init_maps(void)
{
const struct dbcs_index *umap;
unsigned char c1, c2;
int i;
for (i = 0; i < 256; i++)
__encode_map[i] = NULL;
for (c1 = JISX0212_C1_BOTTOM; c1 <= JISX0212_C2_BOTTOM; c1++) {
umap = &jisx0212_decmap[c1 & 0x7f];
if (umap->map == NULL)
continue;
for (c2 = umap->bottom; c2 <= umap->top; c2++) {
Py_UNICODE uni;
int upage, i;
uni = umap->map[c2 - umap->bottom];
if (uni == UNIINV)
continue;
upage = uni >> 8;
if (__encode_map[upage] == NULL) {
__encode_map[upage] = PyMem_New(DBCHAR, 256);
if (__encode_map[upage] == NULL)
goto errorexit;
for (i = 0; i <= 255; i++)
__encode_map[upage][i] = NOCHAR;
}
if (__encode_map[upage][uni & 0xff] == NOCHAR)
__encode_map[upage][uni & 0xff] = c1 << 8 | c2;
}
}
return 0;
errorexit:
for (i = 0; i < 256; i++) {
if (__encode_map[i] != NULL)
PyMem_Del(__encode_map[i]);
}
return -1;
}
static struct PyMethodDef __methods[] = {
{NULL, NULL},
};
void
initmap_jisx0212(void)
{
PyObject *m;
m = Py_InitModule("map_jisx0212", __methods);
PyModule_AddObject(m, "__map",
PyCObject_FromVoidPtr(&__map_entry, NULL));
if (PyErr_Occurred() || init_maps())
Py_FatalError("can't initialize the map_jisx0212 module");
}
/*
* ex: ts=8 sts=4 et
*/
|