* src/print-xml.c (escape_bufs): New static global variable

replacing...
(xml_escape_n): ... the static local variable buf here.
(print_xml): Free memory for escape_bufs.
* src/reduce.c (reduce_xml): XML-escape terminal symbol tags.
This commit is contained in:
Joel E. Denny
2007-09-29 22:36:38 +00:00
parent d782395d52
commit 34cdeddfa5
3 changed files with 19 additions and 9 deletions

View File

@@ -1,3 +1,11 @@
2007-09-29 Joel E. Denny <jdenny@ces.clemson.edu>
* src/print-xml.c (escape_bufs): New static global variable
replacing...
(xml_escape_n): ... the static local variable buf here.
(print_xml): Free memory for escape_bufs.
* src/reduce.c (reduce_xml): XML-escape terminal symbol tags.
2007-09-25 Joel E. Denny <jdenny@ces.clemson.edu> 2007-09-25 Joel E. Denny <jdenny@ces.clemson.edu>
Replace `%push-parser' and `%push-pull-parser' with Replace `%push-parser' and `%push-pull-parser' with

View File

@@ -43,6 +43,12 @@
#include "tables.h" #include "tables.h"
static bitset no_reduce_set; static bitset no_reduce_set;
struct escape_buf
{
char *ptr;
size_t size;
};
static struct escape_buf escape_bufs[2];
/*----------------------------. /*----------------------------.
@@ -516,12 +522,6 @@ xml_printf (FILE *out, int level, char const *fmt, ...)
fputc ('\n', out); fputc ('\n', out);
} }
struct escape_buf
{
char *ptr;
size_t size;
};
static char const * static char const *
xml_escape_string (struct escape_buf *buf, char const *str) xml_escape_string (struct escape_buf *buf, char const *str)
{ {
@@ -553,8 +553,7 @@ xml_escape_string (struct escape_buf *buf, char const *str)
char const * char const *
xml_escape_n (int n, char const *str) xml_escape_n (int n, char const *str)
{ {
static struct escape_buf buf[2]; return xml_escape_string (escape_bufs + n, str);
return xml_escape_string (buf + n, str);
} }
char const * char const *
@@ -608,5 +607,8 @@ print_xml (void)
xml_puts (out, 0, "</bison-xml-report>"); xml_puts (out, 0, "</bison-xml-report>");
free (escape_bufs[0].ptr);
free (escape_bufs[1].ptr);
xfclose (out); xfclose (out);
} }

View File

@@ -418,7 +418,7 @@ reduce_xml (FILE *out, int level)
b = true; b = true;
xml_printf (out, level + 3, xml_printf (out, level + 3,
"<terminal>%s</terminal>", "<terminal>%s</terminal>",
symbols[i]->tag); xml_escape (symbols[i]->tag));
} }
if (b) if (b)
xml_puts (out, level + 2, "</terminals>"); xml_puts (out, level + 2, "</terminals>");