Commit bb7046b2 authored by Michaël Cadilhac's avatar Michaël Cadilhac
Browse files

2005-09-09 Michael Cadilhac <michael.cadilhac@lrde.epita.fr>

	* src/monoburg.h: Add a `with_line' variable which tells if
	`#line' directives have to be output.
	* src/main.c (parse_options): Parse the option.
	* src/parser.y: Output `#line' directives accordingly.
parent 690ce725
2005-09-09 Michael Cadilhac <michael.cadilhac@lrde.epita.fr>
* src/monoburg.h: Add a `with_line' variable which tells if
`#line' directives have to be output.
* src/main.c (parse_options): Parse the option.
* src/parser.y: Output `#line' directives accordingly.
2005-09-09 Michael Cadilhac <michael.cadilhac@lrde.epita.fr>
* src/parser.h: Use `GList' for namespaces and include related
......
......@@ -32,6 +32,7 @@ static char *header_define = NULL;
static char *cfile = NULL;
static char *deffile = NULL;
static GList *infiles = NULL;
gboolean with_line = FALSE;
gboolean with_glib = TRUE;
gboolean with_exported_symbols = TRUE;
gboolean with_references = FALSE;
......@@ -118,6 +119,8 @@ static void parse_options (int argc, char **argv)
"Set FILE to be the output source code file.", "FILE" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version,
"Output version number and quit.", NULL },
{ "with-line", 'l', 0, G_OPTION_ARG_NONE, &with_line,
"Output `#line' directives.", NULL },
{ "without-glib", 0, 0, G_OPTION_ARG_NONE, &without_glib,
"Output a glib independent code.", NULL },
{ "without-exported-symbols", 0, 0, G_OPTION_ARG_NONE, &without_exported_symbols,
......@@ -201,8 +204,8 @@ int main (int argc, char **argv)
exit (-1);
}
input.filename = infile;
output ("#line %d \"%s\"\n", 1, infile);
if (with_line)
output ("#line %d \"%s\"\n", 1, infile);
yyparse ();
reset_parser ();
......
......@@ -25,6 +25,7 @@
# include <config.h>
# include <glib.h>
extern gboolean with_line;
extern gboolean with_glib;
extern gboolean with_exported_symbols;
extern gboolean with_references;
......
......@@ -158,7 +158,7 @@ fgets_inc(char *s, int size)
free (LASTINPUT->filename);
fclose (LASTINPUT->fd);
inputs = g_list_delete_link (inputs, g_list_last (inputs));
if (state != 1)
if (state != 1 && with_line)
output ("#line %d \"%s\"\n",
LASTINPUT->yylineno + 1,
LASTINPUT->filename);
......@@ -192,7 +192,7 @@ fgets_inc(char *s, int size)
yyerror ("`%%include %s': %s",
filename, strerror(errno));
}
if (state != 1)
if (state != 1 && with_line)
output ("#line %d \"%s\"\n", 1, path);
new_include->yylineno = 0;
new_include->filename = strdup (path);
......@@ -356,8 +356,9 @@ nextchar ()
void
yyparsetail (void)
{
output ("#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
if (with_line)
output ("#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
while (fgets_inc (input, sizeof (input)))
output ("%s", input);
}
......@@ -447,8 +448,9 @@ yylex (void)
unsigned i = 0, d = 1;
static char buf [100000];
i = sprintf (buf, "#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
if (with_line)
i = sprintf (buf, "#line %d \"%s\"\n", LASTINPUT->yylineno,
LASTINPUT->filename);
while (d && (c = nextchar ())) {
buf [i++] = c;
assert (i < sizeof (buf));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment