From: Ben Pfaff Date: Wed, 3 Sep 2014 04:10:35 +0000 (-0700) Subject: html: Format new-lines as line breaks. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=d1d0556e538bf04cb0b991b7acb205c144a2f826 html: Format new-lines as line breaks. Otherwise all the lines run together in SYSFILE INFO output in particular. --- diff --git a/src/output/html.c b/src/output/html.c index 8d20a61b37..3e85b3d968 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -68,7 +68,7 @@ static void html_output_table (struct html_driver *, const struct table *, const char *caption); static void escape_string (FILE *file, const char *text, size_t length, - const char *space); + const char *space, const char *newline); static void print_title_tag (FILE *file, const char *name, const char *content); @@ -201,7 +201,7 @@ print_title_tag (FILE *file, const char *name, const char *content) if (content != NULL) { fprintf (file, "<%s>", name); - escape_string (file, content, strlen (content), " "); + escape_string (file, content, strlen (content), " ", " - "); fprintf (file, "\n", name); } } @@ -276,7 +276,7 @@ html_submit (struct output_driver *driver, case TEXT_ITEM_COMMAND_OPEN: fprintf (html->file, "
file, s, strlen (s), "_"); + escape_string (html->file, s, strlen (s), "_", "
"); fprintf (html->file, "\">"); print_title_tag (html->file, "H3", s); break; @@ -291,7 +291,7 @@ html_submit (struct output_driver *driver, case TEXT_ITEM_SYNTAX: fprintf (html->file, "
");
-          escape_string (html->file, s, strlen (s), " ");
+          escape_string (html->file, s, strlen (s), " ", "
"); fprintf (html->file, "
\n"); break; @@ -327,19 +327,23 @@ html_submit (struct output_driver *driver, } } -/* Write LENGTH characters in TEXT to file F, escaping characters - as necessary for HTML. Spaces are replaced by SPACE, which - should be " " or " ". */ +/* Write LENGTH characters in TEXT to file F, escaping characters as necessary + for HTML. Spaces are replaced by SPACE, which should be " " or " " + New-lines are replaced by NEWLINE, which might be "
" or "\n" or + something else appropriate. */ static void escape_string (FILE *file, const char *text, size_t length, - const char *space) + const char *space, const char *newline) { while (length-- > 0) { char c = *text++; switch (c) { + case '\n': + fputs (newline, file); + break; case '&': fputs ("&", file); break; @@ -382,7 +386,7 @@ html_output_table (struct html_driver *html, if (caption != NULL) { fputs (" ", html->file); - escape_string (html->file, caption, strlen (caption), " "); + escape_string (html->file, caption, strlen (caption), " ", "
"); fputs ("\n", html->file); } @@ -470,13 +474,13 @@ html_output_table (struct html_driver *html, if (c->options & TAB_FIX) { fputs ("", html->file); - escape_string (html->file, s, strlen (s), " "); + escape_string (html->file, s, strlen (s), " ", "
"); fputs ("
", html->file); } else { s += strspn (s, CC_SPACES); - escape_string (html->file, s, strlen (s), " "); + escape_string (html->file, s, strlen (s), " ", "
"); } if (c->options & TAB_EMPH) fputs ("", html->file);