[KoCo-CVS] [Commit] KoreanCodecs/src hangul.c
Brought to you by:
perky
From: Chang <pe...@us...> - 2002-05-01 11:10:46
|
perky 02/05/01 04:10:44 Modified: src hangul.c Log: - Test long unicode string for ishangul, isJaeum, isMoeum Suggested by: Lee Gang-Seong <gs...@gw...> Revision Changes Path 1.11 +27 -21 KoreanCodecs/src/hangul.c Index: hangul.c =================================================================== RCS file: /cvsroot/koco/KoreanCodecs/src/hangul.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- hangul.c 29 Apr 2002 14:24:25 -0000 1.10 +++ hangul.c 1 May 2002 11:10:43 -0000 1.11 @@ -4,14 +4,14 @@ * KoreanCodecs Hangul Module C Implementation * * Author : Hye-Shik Chang <pe...@fa...> - * Date : $Date: 2002/04/29 14:24:25 $ + * Date : $Date: 2002/05/01 11:10:43 $ * Created : 25 April 2002 * - * $Revision: 1.10 $ + * $Revision: 1.11 $ */ static char *version = -"$Id: hangul.c,v 1.10 2002/04/29 14:24:25 perky Exp $"; +"$Id: hangul.c,v 1.11 2002/05/01 11:10:43 perky Exp $"; #include "Python.h" @@ -109,17 +109,19 @@ hangul_isJaeum(PyObject *self, PyObject *args) { Py_UNICODE *code; - int codelen; + int codelen, istrue = 0; if (!PyArg_ParseTuple(args, "u#:isJaeum", &code, &codelen)) return NULL; - if (codelen < 1) { - PyErr_Format(PyExc_ValueError, "need not null unicode string"); - return NULL; - } + if (codelen) + for (istrue = 1; codelen--; code++) + if (!isJaeum(*code)) { + istrue = 0; + break; + } - if (isJaeum(*code)) { + if (istrue) { Py_INCREF(Py_True); return Py_True; } @@ -135,17 +137,19 @@ hangul_isMoeum(PyObject *self, PyObject *args) { Py_UNICODE *code; - int codelen; + int codelen, istrue = 0; if (!PyArg_ParseTuple(args, "u#:isMoeum", &code, &codelen)) return NULL; - if (codelen < 1) { - PyErr_Format(PyExc_ValueError, "need not null unicode string"); - return NULL; - } + if (codelen) + for (istrue = 1; codelen--; code++) + if (!isMoeum(*code)) { + istrue = 0; + break; + } - if (isMoeum(*code)) { + if (istrue) { Py_INCREF(Py_True); return Py_True; } @@ -161,17 +165,19 @@ hangul_ishangul(PyObject *self, PyObject *args) { Py_UNICODE *code; - int codelen; + int codelen, istrue = 0; if (!PyArg_ParseTuple(args, "u#:ishangul", &code, &codelen)) return NULL; - if (codelen < 1) { - PyErr_Format(PyExc_ValueError, "need not null unicode string"); - return NULL; - } + if (codelen) + for (istrue = 1; codelen--; code++) + if (!(isHangulSyllable(*code) || isJaeum(*code) || isMoeum(*code))) { + istrue = 0; + break; + } - if (isHangulSyllable(*code) || isJaeum(*code) || isMoeum(*code)) { + if (istrue) { Py_INCREF(Py_True); return Py_True; } |