From 34cdeddfa54df8c85b20bf013a0b82053a5148f2 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Sat, 29 Sep 2007 22:36:38 +0000 Subject: [PATCH] * 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. --- ChangeLog | 8 ++++++++ src/print-xml.c | 18 ++++++++++-------- src/reduce.c | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae91903b..358179b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-29 Joel E. Denny + + * 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 Replace `%push-parser' and `%push-pull-parser' with diff --git a/src/print-xml.c b/src/print-xml.c index acc481ce..81f4d803 100644 --- a/src/print-xml.c +++ b/src/print-xml.c @@ -43,6 +43,12 @@ #include "tables.h" 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); } -struct escape_buf -{ - char *ptr; - size_t size; -}; - static char const * 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 * xml_escape_n (int n, char const *str) { - static struct escape_buf buf[2]; - return xml_escape_string (buf + n, str); + return xml_escape_string (escape_bufs + n, str); } char const * @@ -608,5 +607,8 @@ print_xml (void) xml_puts (out, 0, ""); + free (escape_bufs[0].ptr); + free (escape_bufs[1].ptr); + xfclose (out); } diff --git a/src/reduce.c b/src/reduce.c index 0f17bb05..2e309a44 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -418,7 +418,7 @@ reduce_xml (FILE *out, int level) b = true; xml_printf (out, level + 3, "%s", - symbols[i]->tag); + xml_escape (symbols[i]->tag)); } if (b) xml_puts (out, level + 2, ""); -- 2.45.2