[Python-checkins] python/dist/src/Modules _iconv_codec.c,1.10,1.11
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Tue, 18 Feb 2003 08:11:15 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv29960
Modified Files:
_iconv_codec.c
Log Message:
Fold some long lines.
Change fatal errors during module initialization into RuntimeErrors.
Index: _iconv_codec.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_iconv_codec.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** _iconv_codec.c 10 Feb 2003 20:48:35 -0000 1.10
--- _iconv_codec.c 18 Feb 2003 16:11:11 -0000 1.11
***************
*** 145,149 ****
while (inplen > 0) {
! if (iconv(self->enchdl, (char**)&inp, &inplen, &out, &outlen) == (size_t)-1) {
char reason[128];
int errpos;
--- 145,151 ----
while (inplen > 0) {
! if (iconv(self->enchdl, (char**)&inp, &inplen, &out, &outlen)
! == (size_t)-1)
! {
char reason[128];
int errpos;
***************
*** 248,253 ****
newpos = inputlen + newpos;
if (newpos < 0 || newpos > inputlen) {
! PyErr_Format(PyExc_IndexError, "position %ld from error handler"
! " out of bounds", newpos);
goto errorexit;
}
--- 250,256 ----
newpos = inputlen + newpos;
if (newpos < 0 || newpos > inputlen) {
! PyErr_Format(PyExc_IndexError,
! "position %ld from error handler out of bounds",
! newpos);
goto errorexit;
}
***************
*** 477,482 ****
newpos = inplen_total + newpos;
if (newpos < 0 || newpos > inplen_total) {
! PyErr_Format(PyExc_IndexError, "position %ld from error handler"
! " out of bounds", newpos);
goto errorexit;
}
--- 480,486 ----
newpos = inplen_total + newpos;
if (newpos < 0 || newpos > inplen_total) {
! PyErr_Format(PyExc_IndexError,
! "position %ld from error handler out of bounds",
! newpos);
goto errorexit;
}
***************
*** 497,501 ****
finalsize = (int)(out - out_top);
if (finalsize != outlen_total) {
! if (PyUnicode_Resize(&outputobj, finalsize / Py_UNICODE_SIZE) == -1)
goto errorexit;
}
--- 501,506 ----
finalsize = (int)(out - out_top);
if (finalsize != outlen_total) {
! if (PyUnicode_Resize(&outputobj, finalsize / Py_UNICODE_SIZE)
! == -1)
goto errorexit;
}
***************
*** 669,680 ****
iconv_t hdl = iconv_open(UNICODE_ENCODING, "ASCII");
! if (hdl == (iconv_t)-1)
! Py_FatalError("can't initialize the _iconv_codec module: iconv_open() failed");
res = iconv(hdl, &inptr, &insize, &outptr, &outsize);
! if (res == (size_t)-1)
! Py_FatalError("can't initialize the _iconv_codec module: iconv() failed");
! /* Check whether conv() returned native endianess or not for the chosen encoding */
if (out == 0x1)
byteswap = 0;
--- 674,692 ----
iconv_t hdl = iconv_open(UNICODE_ENCODING, "ASCII");
! if (hdl == (iconv_t)-1) {
! PyErr_SetString(PyExc_RuntimeError,
! "can't initialize the _iconv_codec module: iconv_open() failed");
! return;
! }
res = iconv(hdl, &inptr, &insize, &outptr, &outsize);
! if (res == (size_t)-1) {
! PyErr_SetString(PyExc_RuntimeError,
! "can't initialize the _iconv_codec module: iconv() failed");
! return;
! }
! /* Check whether conv() returned native endianess or not for the chosen
! encoding */
if (out == 0x1)
byteswap = 0;
***************
*** 685,690 ****
#endif
byteswap = 1;
! else
! Py_FatalError("can't initialize the _iconv_codec module: mixed endianess");
iconv_close(hdl);
--- 697,706 ----
#endif
byteswap = 1;
! else {
! iconv_close(hdl);
! PyErr_SetString(PyExc_RuntimeError,
! "can't initialize the _iconv_codec module: mixed endianess");
! return;
! }
iconv_close(hdl);
***************
*** 698,702 ****
if (PyErr_Occurred())
! Py_FatalError("can't initialize the _iconv_codec module");
}
--- 714,719 ----
if (PyErr_Occurred())
! PyErr_SetString(PyExc_RuntimeError,
! "can't initialize the _iconv_codec module");
}