X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=NKF.mod%2FNKF.xs;h=5b1c9c7c4ab969b4ff1be692f8c07796ada21283;hb=88b848edfbddd42ebf2be54d3615c35402606726;hp=66e1b31e6c575a1b34cfa07d8f194efc40c8fb4f;hpb=77f805827d1b510479e4db96b61cf5d9893d9257;p=nkf%2Fnkf.git diff --git a/NKF.mod/NKF.xs b/NKF.mod/NKF.xs index 66e1b31..5b1c9c7 100644 --- a/NKF.mod/NKF.xs +++ b/NKF.mod/NKF.xs @@ -95,7 +95,10 @@ nkf_putchar_grow(unsigned int c) #define PERL_XS 1 #include "../utf8tbl.c" +#undef SP #include "../nkf.c" +#undef SP +#define SP sp /* perl's CORE/pp.h */ /* package defenition */ @@ -134,8 +137,46 @@ nkf(...) data = SvPV(ST(argc),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 * +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; /* allocate the result buffer */ @@ -166,3 +207,10 @@ nkf(...) OUTPUT: RETVAL +SV* +inputcode(...) + CODE: + RETVAL = newSV(strlen(input_codename) + 1); + sv_setpv(RETVAL, input_codename); + OUTPUT: + RETVAL