/* Conversion of files between different charsets and surfaces.
- Copyright © 1999, 2000 Free Software Foundation, Inc.
+ Copyright © 1999, 2000, 2001, 2008 Free Software Foundation, Inc.
Contributed by François Pinard <pinard@iro.umontreal.ca>, 1999,
and Bruno Haible <haible@clisp.cons.org>, 2000.
#define BUFFER_SIZE 2048
static bool
-wrapped_transform (iconv_t conversion, iconv_t conversion_to_utf8,
- RECODE_SUBTASK subtask)
+wrapped_transform (iconv_t conversion, RECODE_SUBTASK subtask)
{
- int input_char = get_byte (subtask);
- char input_buffer[BUFFER_SIZE];
char output_buffer[BUFFER_SIZE];
- size_t input_left;
- size_t output_left;
- char *input;
- char *output;
- char *cursor;
- size_t converted;
- int saved_errno;
-
- cursor = input_buffer;
- while (cursor > input_buffer || input_char != EOF)
- {
- /* Fill the input buffer as much as possible. */
- while (input_char != EOF && cursor < input_buffer + BUFFER_SIZE)
- {
- *cursor++ = input_char;
- input_char = get_byte (subtask);
- }
-
- /* We have at least some input. */
- assert (cursor > input_buffer);
-
- /* Convert accumulated input into the output buffer. */
- input_left = cursor - input_buffer;
- input = input_buffer;
- output_left = BUFFER_SIZE;
- output = output_buffer;
- converted
- = iconv (conversion, &input, &input_left, &output, &output_left);
-
- /* Send the converted result, to free the output buffer. */
- saved_errno = errno;
- for (cursor = output_buffer; cursor < output; cursor++)
- put_byte (*cursor, subtask);
- errno = saved_errno;
-
- /* Analyze the iconv return value. */
- if (converted == (size_t)(-1) && errno != E2BIG)
- {
- if (errno == EILSEQ)
- {
- /* Fail if the user requested reversible conversions. */
- RETURN_IF_NOGO (RECODE_NOT_CANONICAL, subtask);
-
- /* An invalid multibyte sequence was encountered in the
- input, or a conversion error occurred. Distinguish the
- two cases by use of conversion_to_utf8. In the first
- case, skip one byte. In the second case, skip the entire
- character.
- FIXME: This heuristic does not work well with stateful
- encodings like ISO-2022-JP. */
- char tmp_buf[6];
- size_t tmp_input_left;
- size_t tmp_output_left;
- char *tmp_input;
- char *tmp_output;
-
- RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
+ char input_buffer[BUFFER_SIZE];
+ int input_char = get_byte (subtask);
+ char *cursor = input_buffer;
+ bool drain_first = false;
- assert (input_left > 0);
-
- tmp_input_left = input_left;
- tmp_input = input;
- tmp_output_left = sizeof (tmp_buf);
- tmp_output = tmp_buf;
- iconv (conversion_to_utf8,
- &tmp_input, &tmp_input_left,
- &tmp_output, &tmp_output_left);
- /* Reset conversion_to_utf8 to the initial state. */
- iconv (conversion_to_utf8, NULL, NULL, NULL, NULL);
- if (tmp_input > input)
- {
- /* Conversion error. Skip the entire character. */
- input = tmp_input;
- input_left = tmp_input_left;
- }
- else
+ while (true)
+ {
+ /* The output buffer is fully avaible at this point. */
+
+ char *input = input_buffer;
+ char *output = output_buffer;
+ size_t input_left = 0;
+ size_t output_left = BUFFER_SIZE;
+ int saved_errno = 0;
+ size_t converted;
+
+ if (drain_first)
+ {
+ /* Drain all accumulated partial state and emit output
+ to return to the initial shift state. */
+ converted = iconv (conversion, NULL, NULL, &output, &output_left);
+ if (converted == (size_t) -1)
+ saved_errno = errno;
+ }
+
+ if (saved_errno == 0)
+ {
+ /* Continue filling the input buffer. */
+ while (input_char != EOF && cursor < input_buffer + BUFFER_SIZE)
+ {
+ *cursor++ = input_char;
+ input_char = get_byte (subtask);
+ }
+
+ if (cursor == input_buffer)
+ {
+ if (output == output_buffer)
{
- /* Invalid input. Skip one byte. */
- input++;
- input_left--;
+ /* All work has been done, just make sure we drained. */
+ if (drain_first)
+ break;
+ drain_first = true;
+ continue;
}
-
- /* Reset conversion state. (Why?) */
- output_left = BUFFER_SIZE;
- output = output_buffer;
- converted
- = iconv (conversion, NULL, NULL, &output, &output_left);
- /* We don't expect E2BIG here: the buffer is large enough. */
- assert (converted != (size_t)(-1));
- for (cursor = output_buffer; cursor < output; cursor++)
- put_byte (*cursor, subtask);
- }
- else if (errno == EINVAL)
- {
- /* Incomplete multibyte sequence. */
- if (input + input_left < input_buffer + BUFFER_SIZE
- && input_char == EOF)
- {
- /* Incomplete multibyte sequence at end of input. */
- RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
- break;
- }
- /* Otherwise, we shift the remaining input and see whether the
- error persists in the next round. */
- }
- else
- {
- recode_perror (subtask->task->request->outer, "iconv ()");
- SET_SUBTASK_ERROR (RECODE_SYSTEM_ERROR, subtask);
- SUBTASK_RETURN (subtask);
- }
- }
-
- /* If there was no progress, we have a bug in either iconv or the
- above logic. */
- if (!(input > input_buffer))
- {
- recode_error (subtask->task->request->outer,
- "iconv.c internal error 154");
- SET_SUBTASK_ERROR (RECODE_INTERNAL_ERROR, subtask);
- SUBTASK_RETURN (subtask);
- }
- assert (input > input_buffer);
-
- /* Shift back the unconverted part of the input buffer.
- memcpy() doesn't do here, because the regions might overlap.
- memmove() isn't worth it, because we rarely have to move more
- than 12 bytes. */
- if (input > input_buffer && input_left > 0)
- {
- cursor = input_buffer;
- do
- *cursor++ = *input++;
- while (--input_left > 0);
- }
+ }
+ else
+ {
+ /* Convert accumulated input and add it to the output buffer. */
+ input = input_buffer;
+ input_left = cursor - input_buffer;
+ converted = iconv (conversion,
+ &input, &input_left,
+ &output, &output_left);
+ if (converted == (size_t) -1)
+ saved_errno = errno;
+ }
+ }
+
+ /* Send the converted result, so freeing the output buffer. */
+ for (cursor = output_buffer; cursor < output; cursor++)
+ put_byte (*cursor, subtask);
+
+ /* Act according to the outcome of the iconv call. */
+
+ drain_first = false;
+ if (saved_errno != 0 && saved_errno != E2BIG)
+ if (saved_errno == EILSEQ)
+ {
+ /* Invalid input. Skip one byte. */
+ RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
+ assert (input_left > 0);
+ input++;
+ input_left--;
+ /* Why is draining required? */
+ drain_first = true;
+ }
+ else if (saved_errno == EINVAL)
+ {
+ if (input + input_left < input_buffer + BUFFER_SIZE
+ && input_char == EOF)
+ /* Incomplete multibyte sequence at end of input. */
+ RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
+ }
+ else
+ {
+ recode_perror (subtask->task->request->outer, "iconv ()");
+ RETURN_IF_NOGO (RECODE_SYSTEM_ERROR, subtask);
+ }
+
+ /* Move back any unprocessed part of the input buffer. */
+ for (cursor = input_buffer; input_left != 0; input_left--)
+ *cursor++ = *input++;
}
- /* Drain all accumulated partial state and emit output to return to the
- initial shift state. */
- output_left = BUFFER_SIZE;
- output = output_buffer;
- converted = iconv (conversion, NULL, NULL, &output, &output_left);
- /* We don't expect E2BIG here: the buffer is large enough. */
- assert (converted != (size_t)(-1));
- for (cursor = output_buffer; cursor < output; cursor++)
- put_byte (*cursor, subtask);
-
SUBTASK_RETURN (subtask);
}
{
RECODE_CONST_STEP step = subtask->step;
iconv_t conversion = iconv_open (step->after->name, step->before->name);
- iconv_t conversion_to_utf8 = iconv_open ("UTF-8", step->before->name);
bool status;
- if (conversion == (iconv_t) -1 || conversion_to_utf8 == (iconv_t) -1)
+ if (conversion == (iconv_t) -1)
{
SET_SUBTASK_ERROR (RECODE_SYSTEM_ERROR, subtask);
SUBTASK_RETURN (subtask);
}
- status = wrapped_transform (conversion, conversion_to_utf8, subtask);
+ status = wrapped_transform (conversion, subtask);
iconv_close (conversion);
- iconv_close (conversion_to_utf8);
return status;
}
-/* Generated by Pyrex 0.9.6.4 on Sat Mar 8 22:48:53 2008 */
+/* Generated by Pyrex 0.9.6.4 on Sun Mar 9 16:41:44 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
static PyObject *__pyx_n_AUTO_ABORT_FLAG;
static PyObject *__pyx_n_NO_ICONV_FLAG;
static PyObject *__pyx_n_False;
-static PyObject *__pyx_n_global_outer;
static int __pyx_f_6Recode_5Outer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_6Recode_5Outer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
return __pyx_r;
}
+static PyObject *__pyx_n_scan;
+static PyObject *__pyx_n_string;
+
+static PyObject *__pyx_f_6Recode_5Outer_recode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_6Recode_5Outer_recode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ char *__pyx_v_command;
+ char *__pyx_v_input;
+ PyObject *__pyx_v_request;
+ PyObject *__pyx_r;
+ PyObject *__pyx_1 = 0;
+ PyObject *__pyx_2 = 0;
+ PyObject *__pyx_3 = 0;
+ static char *__pyx_argnames[] = {"command","input",0};
+ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ss", __pyx_argnames, &__pyx_v_command, &__pyx_v_input)) return 0;
+ Py_INCREF(__pyx_v_self);
+ __pyx_v_request = Py_None; Py_INCREF(Py_None);
+
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":629 */
+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_self);
+ PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
+ __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6Recode_Request), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;}
+ Py_DECREF(__pyx_1); __pyx_1 = 0;
+ Py_DECREF(__pyx_v_request);
+ __pyx_v_request = __pyx_2;
+ __pyx_2 = 0;
+
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":630 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_request, __pyx_n_scan); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;}
+ __pyx_2 = PyString_FromString(__pyx_v_command); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;}
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
+ __pyx_2 = 0;
+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;}
+ Py_DECREF(__pyx_1); __pyx_1 = 0;
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":631 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_request, __pyx_n_string); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}
+ __pyx_3 = PyString_FromString(__pyx_v_input); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
+ __pyx_3 = 0;
+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}
+ Py_DECREF(__pyx_1); __pyx_1 = 0;
+ Py_DECREF(__pyx_2); __pyx_2 = 0;
+ __pyx_r = __pyx_3;
+ __pyx_3 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; Py_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1:;
+ Py_XDECREF(__pyx_1);
+ Py_XDECREF(__pyx_2);
+ Py_XDECREF(__pyx_3);
+ __Pyx_AddTraceback("Recode.Outer.recode");
+ __pyx_r = 0;
+ __pyx_L0:;
+ Py_DECREF(__pyx_v_request);
+ Py_DECREF(__pyx_v_self);
+ return __pyx_r;
+}
+
static int __pyx_f_6Recode_7Request___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_6Recode_7Request___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
struct __pyx_obj_6Recode_Outer *__pyx_v_outer = 0;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_outer)) return -1;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_outer);
- if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outer), __pyx_ptype_6Recode_Outer, 1, "outer")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;}
+ if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outer), __pyx_ptype_6Recode_Outer, 1, "outer")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; goto __pyx_L1;}
((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request = recode_new_request(__pyx_v_outer->outer);
__pyx_r = 0;
Py_INCREF(__pyx_v_flag);
__pyx_v_previous = Py_None; Py_INCREF(Py_None);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":639 */
- __pyx_1 = PyInt_FromLong((((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->verbose_flag != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":645 */
+ __pyx_1 = PyInt_FromLong((((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->verbose_flag != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}
Py_DECREF(__pyx_v_previous);
__pyx_v_previous = __pyx_1;
__pyx_1 = 0;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":640 */
- __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":646 */
+ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
Py_INCREF(__pyx_v_flag);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_flag);
- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = ((enum __pyx_t_6Recode_bool)PyInt_AsLong(__pyx_3)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
+ __pyx_4 = ((enum __pyx_t_6Recode_bool)PyInt_AsLong(__pyx_3)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->verbose_flag = __pyx_4;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":641 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":647 */
Py_INCREF(__pyx_v_previous);
__pyx_r = __pyx_v_previous;
goto __pyx_L0;
Py_INCREF(__pyx_v_self);
__pyx_v_ok = Py_None; Py_INCREF(Py_None);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":644 */
- __pyx_1 = PyInt_FromLong(recode_scan_request(((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request,__pyx_v_text)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":650 */
+ __pyx_1 = PyInt_FromLong(recode_scan_request(((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request,__pyx_v_text)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}
Py_DECREF(__pyx_v_ok);
__pyx_v_ok = __pyx_1;
__pyx_1 = 0;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":645 */
- __pyx_2 = PyObject_IsTrue(__pyx_v_ok); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":651 */
+ __pyx_2 = PyObject_IsTrue(__pyx_v_ok); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; goto __pyx_L1;}
__pyx_3 = (!__pyx_2);
if (__pyx_3) {
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}
__Pyx_Raise(__pyx_1, 0, 0);
Py_DECREF(__pyx_1); __pyx_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
Py_INCREF(__pyx_v_self);
__pyx_v_list = Py_None; Py_INCREF(Py_None);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":649 */
- __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":655 */
+ __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;}
Py_DECREF(__pyx_v_list);
__pyx_v_list = __pyx_1;
__pyx_1 = 0;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":652 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":658 */
__pyx_2 = ((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->sequence_length;
for (__pyx_v_counter = 0; __pyx_v_counter < __pyx_2; ++__pyx_v_counter) {
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":653 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":659 */
__pyx_v_step = (((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->sequence_array[__pyx_v_counter]);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":654 */
- __pyx_1 = PyObject_GetAttr(__pyx_v_list, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
- __pyx_3 = PyString_FromString(__pyx_v_step.before->name); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
- __pyx_4 = PyString_FromString(__pyx_v_step.after->name); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":660 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_list, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
+ __pyx_3 = PyString_FromString(__pyx_v_step.before->name); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
+ __pyx_4 = PyString_FromString(__pyx_v_step.after->name); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
__pyx_3 = 0;
__pyx_4 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
__pyx_5 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
}
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":655 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":661 */
Py_INCREF(__pyx_v_list);
__pyx_r = __pyx_v_list;
goto __pyx_L0;
Py_INCREF(__pyx_v_self);
__pyx_v_ok = Py_None; Py_INCREF(Py_None);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":660 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":666 */
__pyx_v_outer = ((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request->outer;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":661 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":667 */
__pyx_v_saved = __pyx_v_outer->iconv_pivot->ignore;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":662 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":668 */
__pyx_v_outer->iconv_pivot->ignore = __pyx_e_6Recode_true;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":663 */
- __pyx_1 = PyInt_FromLong(recode_format_table(((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request,((enum recode_programming_language)__pyx_v_language),__pyx_v_charset)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":669 */
+ __pyx_1 = PyInt_FromLong(recode_format_table(((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request,((enum recode_programming_language)__pyx_v_language),__pyx_v_charset)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; goto __pyx_L1;}
Py_DECREF(__pyx_v_ok);
__pyx_v_ok = __pyx_1;
__pyx_1 = 0;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":665 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":671 */
__pyx_v_outer->iconv_pivot->ignore = __pyx_v_saved;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":666 */
- __pyx_2 = PyObject_IsTrue(__pyx_v_ok); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":672 */
+ __pyx_2 = PyObject_IsTrue(__pyx_v_ok); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; goto __pyx_L1;}
__pyx_3 = (!__pyx_2);
if (__pyx_3) {
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
__Pyx_Raise(__pyx_1, 0, 0);
Py_DECREF(__pyx_1); __pyx_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s", __pyx_argnames, &__pyx_v_text)) return 0;
Py_INCREF(__pyx_v_self);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":671 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":677 */
__pyx_v_result = recode_string(((struct __pyx_obj_6Recode_Request *)__pyx_v_self)->request,__pyx_v_text);
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":672 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":678 */
__pyx_1 = (__pyx_v_result == NULL);
if (__pyx_1) {
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":674 */
- __pyx_2 = PyString_FromString(__pyx_v_result); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":680 */
+ __pyx_2 = PyString_FromString(__pyx_v_result); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
return __pyx_r;
}
-static PyObject *__pyx_n_scan;
-static PyObject *__pyx_n_string;
-
-static PyObject *__pyx_f_6Recode_recode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_f_6Recode_recode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- char *__pyx_v_text;
- char *__pyx_v_string;
- PyObject *__pyx_v_request;
- PyObject *__pyx_r;
- PyObject *__pyx_1 = 0;
- PyObject *__pyx_2 = 0;
- PyObject *__pyx_3 = 0;
- static char *__pyx_argnames[] = {"text","string",0};
- if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ss", __pyx_argnames, &__pyx_v_text, &__pyx_v_string)) return 0;
- __pyx_v_request = Py_None; Py_INCREF(Py_None);
-
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":693 */
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_global_outer); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
- __pyx_1 = 0;
- __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6Recode_Request), __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}
- Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_DECREF(__pyx_v_request);
- __pyx_v_request = __pyx_1;
- __pyx_1 = 0;
-
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":694 */
- __pyx_2 = PyObject_GetAttr(__pyx_v_request, __pyx_n_scan); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
- __pyx_1 = PyString_FromString(__pyx_v_text); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
- __pyx_1 = 0;
- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}
- Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_DECREF(__pyx_3); __pyx_3 = 0;
- Py_DECREF(__pyx_1); __pyx_1 = 0;
-
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":695 */
- __pyx_2 = PyObject_GetAttr(__pyx_v_request, __pyx_n_string); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
- __pyx_3 = PyString_FromString(__pyx_v_string); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
- PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
- __pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; goto __pyx_L1;}
- Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_r = __pyx_3;
- __pyx_3 = 0;
- goto __pyx_L0;
-
- __pyx_r = Py_None; Py_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1:;
- Py_XDECREF(__pyx_1);
- Py_XDECREF(__pyx_2);
- Py_XDECREF(__pyx_3);
- __Pyx_AddTraceback("Recode.recode");
- __pyx_r = 0;
- __pyx_L0:;
- Py_DECREF(__pyx_v_request);
- return __pyx_r;
-}
-
static __Pyx_InternTabEntry __pyx_intern_tab[] = {
{&__pyx_n_ALIAS_FIND_AS_CHARSET, "ALIAS_FIND_AS_CHARSET"},
{&__pyx_n_ALIAS_FIND_AS_EITHER, "ALIAS_FIND_AS_EITHER"},
{&__pyx_n_USER_ERROR, "USER_ERROR"},
{&__pyx_n_append, "append"},
{&__pyx_n_error, "error"},
- {&__pyx_n_global_outer, "global_outer"},
{&__pyx_n_int, "int"},
{&__pyx_n_scan, "scan"},
{&__pyx_n_string, "string"},
{"all_surfaces", (PyCFunction)__pyx_f_6Recode_5Outer_all_surfaces, METH_VARARGS|METH_KEYWORDS, 0},
{"concise_charset", (PyCFunction)__pyx_f_6Recode_5Outer_concise_charset, METH_VARARGS|METH_KEYWORDS, 0},
{"full_charset", (PyCFunction)__pyx_f_6Recode_5Outer_full_charset, METH_VARARGS|METH_KEYWORDS, 0},
+ {"recode", (PyCFunction)__pyx_f_6Recode_5Outer_recode, METH_VARARGS|METH_KEYWORDS, 0},
{0, 0, 0, 0}
};
};
static struct PyMethodDef __pyx_methods[] = {
- {"recode", (PyCFunction)__pyx_f_6Recode_recode, METH_VARARGS|METH_KEYWORDS, 0},
{0, 0, 0, 0}
};
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
- PyObject *__pyx_5 = 0;
__pyx_init_filenames();
__pyx_m = Py_InitModule4("Recode", __pyx_methods, 0, 0, PYTHON_API_VERSION);
if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
if (PyType_Ready(&__pyx_type_6Recode_Outer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; goto __pyx_L1;}
if (PyObject_SetAttrString(__pyx_m, "Outer", (PyObject *)&__pyx_type_6Recode_Outer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; goto __pyx_L1;}
__pyx_ptype_6Recode_Outer = &__pyx_type_6Recode_Outer;
- if (PyType_Ready(&__pyx_type_6Recode_Request) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;}
- if (PyObject_SetAttrString(__pyx_m, "Request", (PyObject *)&__pyx_type_6Recode_Request) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;}
+ if (PyType_Ready(&__pyx_type_6Recode_Request) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;}
+ if (PyObject_SetAttrString(__pyx_m, "Request", (PyObject *)&__pyx_type_6Recode_Request) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;}
__pyx_ptype_6Recode_Request = &__pyx_type_6Recode_Request;
/* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":489 */
__pyx_k5 = __pyx_4;
__pyx_4 = 0;
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":690 */
- __pyx_5 = PyObject_CallObject(((PyObject*)__pyx_ptype_6Recode_Outer), 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; goto __pyx_L1;}
- if (PyObject_SetAttr(__pyx_m, __pyx_n_global_outer, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; goto __pyx_L1;}
- Py_DECREF(__pyx_5); __pyx_5 = 0;
-
- /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":692 */
+ /* "/bpi/phenix/home/pinard/entretien/recode/tests/Recode.pyx":675 */
return;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_2);
Py_XDECREF(__pyx_3);
Py_XDECREF(__pyx_4);
- Py_XDECREF(__pyx_5);
__Pyx_AddTraceback("Recode");
}