nkfのGitリポジトリのforkです。
Revision | a4f55f2c8e3aa2dae185490bb34c553818750394 (tree) |
---|---|
Time | 2022-03-15 13:48:11 |
Author | NARUSE, Yui <nurse@user...> |
Commiter | GitHub |
Merge pull request #8 from slic-io/devlop
fix: python3 extention ABI # variant when parsing warning
@@ -20,6 +20,8 @@ Changes. | ||
20 | 20 | ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. |
21 | 21 | ***************************************************************************/ |
22 | 22 | |
23 | +#define PY_SSIZE_T_CLEAN | |
24 | + | |
23 | 25 | #include "Python.h" |
24 | 26 | #include <setjmp.h> |
25 | 27 |
@@ -33,7 +35,7 @@ Changes. | ||
33 | 35 | #undef FALSE |
34 | 36 | #define putchar(c) pynkf_putchar(c) |
35 | 37 | |
36 | -static int pynkf_ibufsize, pynkf_obufsize; | |
38 | +static Py_ssize_t pynkf_ibufsize, pynkf_obufsize; | |
37 | 39 | static unsigned char *pynkf_inbuf, *pynkf_outbuf; |
38 | 40 | static int pynkf_icount,pynkf_ocount; |
39 | 41 | static unsigned char *pynkf_iptr, *pynkf_optr; |
@@ -62,7 +64,7 @@ pynkf_ungetc(int c, FILE *f) | ||
62 | 64 | static void |
63 | 65 | pynkf_putchar(int c) |
64 | 66 | { |
65 | - size_t size; | |
67 | + Py_ssize_t size; | |
66 | 68 | unsigned char *p; |
67 | 69 | |
68 | 70 | if (pynkf_guess_flag) { |
@@ -89,7 +91,7 @@ pynkf_putchar(int c) | ||
89 | 91 | #include "../nkf.c" |
90 | 92 | |
91 | 93 | static PyObject * |
92 | -pynkf_convert(unsigned char* str, int strlen, char* opts, int optslen) | |
94 | +pynkf_convert(unsigned char* str, Py_ssize_t strlen, char* opts, Py_ssize_t optslen) | |
93 | 95 | { |
94 | 96 | PyObject * res; |
95 | 97 |
@@ -157,12 +159,12 @@ static | ||
157 | 159 | PyObject *pynkf_nkf(PyObject *self, PyObject *args) |
158 | 160 | { |
159 | 161 | unsigned char *str; |
160 | - int strlen; | |
162 | + Py_ssize_t strlen; | |
161 | 163 | char *opts; |
162 | - int optslen; | |
164 | + Py_ssize_t optslen; | |
163 | 165 | PyObject* res; |
164 | 166 | |
165 | - if (!PyArg_ParseTuple(args, "s#y#", &opts, &optslen, &str, &strlen)) { | |
167 | + if (!PyArg_ParseTuple(args, "s#s#", &opts, &optslen, &str, &strlen)) { | |
166 | 168 | return NULL; |
167 | 169 | } |
168 | 170 | res = pynkf_convert(str, strlen, opts, optslen); |
@@ -178,7 +180,7 @@ PyObject *pynkf_guess(PyObject *self, PyObject *args) | ||
178 | 180 | int strlen; |
179 | 181 | PyObject* res; |
180 | 182 | |
181 | - if (!PyArg_ParseTuple(args, "y#", &str, &strlen)) { | |
183 | + if (!PyArg_ParseTuple(args, "s#", &str, &strlen)) { | |
182 | 184 | return NULL; |
183 | 185 | } |
184 | 186 | res = pynkf_convert_guess(str, strlen); |