+2008-02-22 François Pinard <pinard@iro.umontreal.ca>
+
+ Repair all Flex steps, which were broken since version 3.6.
+ * mergelex.py: Provide a rather dumb YY_INPUT using get_byte,
+ and set yy_init to zero in all generated routines.
+ * recodext.h: Within Flex, use both get_byte_helper and
+ put_byte_helper, not only put_byte_helper.
+ * task.c (get_byte_helper) [!INLINE_HARDER]: Compile as well.
+ Properly declare the argument as a subtask, not as a task.
+
2008-02-21 François Pinard <pinard@iro.umontreal.ca>
* Makefile.am (recode.1): Use --name calling help2man.
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
/* This file is generated automatically by `mergelex.py'. */
-#define YY_NO_UNPUT
#include "common.h"
static RECODE_CONST_REQUEST request;
static RECODE_SUBTASK subtask;
+#define YY_INPUT(buf, result, max_size) { int c = get_byte (subtask); result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); }
+
void texte_latin1_diaeresis PARAMS ((void));
{
subtask = subtask_argument;
request = subtask->task->request;
- yy_init = 1;
+ yy_init = 0;
yyin = subtask->input.file;
yyout = subtask->output.file;
BEGIN ascii_latin1;
{
subtask = subtask_argument;
request = subtask->task->request;
- yy_init = 1;
+ yy_init = 0;
yyin = subtask->input.file;
yyout = subtask->output.file;
BEGIN latex_latin1;
{
subtask = subtask_argument;
request = subtask->task->request;
- yy_init = 1;
+ yy_init = 0;
yyin = subtask->input.file;
yyout = subtask->output.file;
BEGIN texte_latin1;
import re, sys
# Initial comments.
-section0 = ["/* This file is generated automatically by `mergelex.py'. */\n"]
+section0 = [
+"/* This file is generated automatically by `mergelex.py'. */\n"]
+
# Flex and C declarations.
-section1 = ["\n"
- "%option noyywrap\n"
- "%{\n"
- '#define YY_NO_UNPUT\n'
- '#include "common.h"\n'
- "static RECODE_CONST_REQUEST request;\n"
- "static RECODE_SUBTASK subtask;\n"
- "%}\n"]
+section1 = '''\
+
+%option noyywrap
+%{
+#include "common.h"
+static RECODE_CONST_REQUEST request;
+static RECODE_SUBTASK subtask;
+
+#define YY_INPUT(buf, result, max_size) \
+ { \
+ int c = get_byte (subtask); \
+ result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
+ }
+%}
+'''.splitlines(True)
+
# Flex rules.
-section2 = ["%%\n"
- "<<EOF>> { return 1; }\n"]
+section2 = '''\
+%%
+<<EOF>> { return 1; }
+'''.splitlines(True)
+
# Rest of C code.
-section3 = ["%%\n"]
+section3 = ['%%\n']
within_C_code = False
definitions = {}
if match:
section = 1
step_name = match.group(1)
- section3.append(
- '\n'
- 'static bool\n'
- 'transform_%s (RECODE_SUBTASK subtask_argument)\n'
- '{\n'
- ' subtask = subtask_argument;\n'
- ' request = subtask->task->request;\n'
- ' yy_init = 1;\n'
- ' yyin = subtask->input.file;\n'
- ' yyout = subtask->output.file;\n'
- ' BEGIN %s;\n'
- ' return yylex ();\n'
- '}\n'
+ section3.append('''\
+
+static bool
+transform_%s (RECODE_SUBTASK subtask_argument)
+{
+ subtask = subtask_argument;
+ request = subtask->task->request;
+ yy_init = 0;
+ yyin = subtask->input.file;
+ yyout = subtask->output.file;
+ BEGIN %s;
+ return yylex ();
+}
+'''
% (step_name, step_name))
continue
/* Giving a name to the ASCII character assigned to position 0. */
#define NUL '\0'
+#ifdef FLEX_SCANNER
+# if !INLINE_HARDER
+# undef USE_HELPERS
+# define USE_HELPERS 1
+# endif
+#endif
+
#if USE_HELPERS
# define get_byte(Subtask) \
#ifdef FLEX_SCANNER
-# if !INLINE_HARDER
-
-# undef put_byte
-# define put_byte(Byte, Subtask) \
- put_byte_helper ((Byte), (Subtask))
-
-# endif
-
# define PUT_NON_DIACRITIC_BYTE(Byte, Subtask) \
if (request->diacritics_only) \
ECHO; \
| Read one byte from the input text of TASK, or EOF is none remain. |
`-------------------------------------------------------------------*/
-/* This function is directly called by get_byte whenever USE_HELPERS is
- defined. Otherwise, get_byte does everything necessary and this routine
- is not needed. */
+/* This function is directly called by get_byte whenever USE_HELPERS
+ is defined, and also from within generated Flex code unless
+ INLINE_HARDER is defined. Otherwise, get_byte does everything
+ necessary and this routine is not needed. */
-#if USE_HELPERS
+#if USE_HELPERS || !INLINE_HARDER
int
-get_byte_helper (RECODE_TASK task)
+get_byte_helper (RECODE_SUBTASK subtask)
{
- if (task->input.file)
- return getc (task->input.file);
- else if (task->input.cursor == task->input.limit)
+ if (subtask->input.file)
+ return getc (subtask->input.file);
+ else if (subtask->input.cursor == subtask->input.limit)
return EOF;
else
- return (unsigned char) *task->input.cursor++;
+ return (unsigned char) *subtask->input.cursor++;
}
-#endif /* USE_HELPERS */
+#endif /* USE_HELPERS || !INLINE_HARDER */
/*-----------------------------------------.
| Write BYTE on the output text for TASK. |
`-----------------------------------------*/
-/* This function is directly called by put_byte whenever USE_HELPERS is
- defined. It is also called when the output buffer needs to be
- reallocated, which put_byte does not know how to handle itself. Note
- that when INLINE_HARDER is not defined, USE_HELPERS is implied for Flex
- generated code. */
+/* This function is directly called by put_byte whenever USE_HELPERS
+ is defined, and also from within generated Flex code unless
+ INLINE_HARDER is defined. It is also called when the output
+ buffer needs to be reallocated, which put_byte does not know
+ how to handle itself. */
void
put_byte_helper (int byte, RECODE_SUBTASK subtask)