OSDN Git Service

自動判別の状態を保持したまま変換を続ける nkf_continue を追加
authorRei FURUKAWA <rei_furukawa@users.sourceforge.jp>
Sun, 5 Oct 2003 16:25:59 +0000 (16:25 +0000)
committerRei FURUKAWA <rei_furukawa@users.sourceforge.jp>
Sun, 5 Oct 2003 16:25:59 +0000 (16:25 +0000)
NKF.mod/NKF.pm
NKF.mod/NKF.xs

index 1912169..2ad79b6 100644 (file)
@@ -34,9 +34,9 @@ require DynaLoader;
 # names by default without a very good reason. Use EXPORT_OK instead.
 # Do not simply export all your public functions/methods/constants.
 @EXPORT = qw(
-       nkf     
+       nkf     nkf_continue    inputcode
 );
-$VERSION = '2.00';
+$VERSION = '2.03';
 
 bootstrap NKF $VERSION;
 
index 66e1b31..626b634 100644 (file)
@@ -166,3 +166,54 @@ nkf(...)
     OUTPUT:
     RETVAL
 
+SV *
+nkf_continue(...)
+    PROTOTYPE: @
+    PREINIT:
+    char *data;
+    STRLEN rlen;
+    CODE:
+
+    /* Get input data pointer from the last variable. */
+    data = SvPV(ST(0),i_len);
+    input_ctr = 0;
+
+    if(x0201_f == WISH_TRUE)
+         x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
+
+    /* allocate the result buffer */
+
+    /* During conversion, stirngs length may grow. This is the unit */
+    /* of growth */
+    incsize = INCSIZE; 
+    rlen = i_len+INCSIZE;
+    result = newSV(rlen);
+    input  = data;
+
+    /* SvPV(result,o_len) does not work here. */
+    output = SvPVX(result);
+    o_len = rlen;
+    output_ctr = 0;
+
+    /* Convestion */
+    kanji_convert(NULL);
+    nkf_putchar(0);     /* Null terminator */
+
+    RETVAL = result;
+    SvPOK_on(RETVAL);       
+    /* We cannot use 
+          SvCUR_set(RETVAL, strlen(output)); 
+       because output can contain \0. 
+     */
+    SvCUR_set(RETVAL, output_ctr - 1);
+
+    OUTPUT:
+    RETVAL
+
+SV*
+inputcode(...)
+    CODE:
+    RETVAL = newSV(strlen(input_codename) + 1);
+    sv_setpv(RETVAL, input_codename);
+    OUTPUT:
+    RETVAL