X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fhtml.c;h=f0b4f5fdfb0f5698de0030bd30371b7e2715cfba;hb=97d6c6f6b1922621ca013668eba9a9a9f71d60fe;hp=c647f34b5726cd86f71281a6772118d38d962081;hpb=4944c86a9318bc5b5578ab145a95c116ffd2c9fd;p=pspp diff --git a/src/html.c b/src/html.c index c647f34b57..f0b4f5fdfb 100644 --- a/src/html.c +++ b/src/html.c @@ -21,7 +21,8 @@ #if !NO_HTML #include -#include +#include "htmlP.h" +#include "error.h" #include #include #include @@ -35,7 +36,6 @@ #include "error.h" #include "filename.h" #include "getline.h" -#include "htmlP.h" #include "output.h" #include "som.h" #include "tab.h" @@ -45,19 +45,19 @@ static int postopen (struct file_ext *); static int preclose (struct file_ext *); -int -html_open_global (struct outp_class *this unused) +static int +html_open_global (struct outp_class *this UNUSED) { return 1; } -int -html_close_global (struct outp_class *this unused) +static int +html_close_global (struct outp_class *this UNUSED) { return 1; } -int +static int html_preopen_driver (struct outp_driver *this) { struct html_driver_ext *x; @@ -87,7 +87,7 @@ html_preopen_driver (struct outp_driver *this) return 1; } -int +static int html_postopen_driver (struct outp_driver *this) { struct html_driver_ext *x = this->ext; @@ -105,7 +105,7 @@ html_postopen_driver (struct outp_driver *this) return 1; } -int +static int html_close_driver (struct outp_driver *this) { struct html_driver_ext *x = this->ext; @@ -141,7 +141,7 @@ static struct outp_option option_tab[] = }; static struct outp_option_info option_info; -void +static void html_option (struct outp_driver *this, const char *key, const struct string *val) { struct html_driver_ext *x = this->ext; @@ -168,16 +168,13 @@ html_option (struct outp_driver *this, const char *key, const struct string *val break; default: assert (0); + abort (); } if (*dest) free (*dest); *dest = xstrdup (ds_value (val)); } break; -#if __CHECKER__ - case 42000: - assert (0); -#endif default: assert (0); } @@ -362,7 +359,7 @@ preclose (struct file_ext *f) return 1; } -int +static int html_open_page (struct outp_driver *this) { struct html_driver_ext *x = this->ext; @@ -382,7 +379,7 @@ html_open_page (struct outp_driver *this) return !ferror (x->file.file); } -int +static int html_close_page (struct outp_driver *this) { struct html_driver_ext *x = this->ext; @@ -394,7 +391,7 @@ html_close_page (struct outp_driver *this) static void output_tab_table (struct outp_driver *, struct tab_table *); -void +static void html_submit (struct outp_driver *this, struct som_table *s) { extern struct som_table_class tab_table_class; @@ -413,26 +410,6 @@ html_submit (struct outp_driver *this, struct som_table *s) assert (0); } -/* Emit HTML to FILE to change from *OLD_ATTR attributes to NEW_ATTR. - Sets *OLD_ATTR to NEW_ATTR when done. */ -static void -change_attributes (FILE *f, int *old_attr, int new_attr) -{ - if (*old_attr == new_attr) - return; - - if (*old_attr & OUTP_F_B) - fputs ("", f); - if (*old_attr & OUTP_F_I) - fputs ("", f); - if (new_attr & OUTP_F_I) - fputs ("", f); - if (new_attr & OUTP_F_B) - fputs ("", f); - - *old_attr = new_attr; -} - /* Write string S of length LEN to file F, escaping characters as necessary for HTML. */ static void @@ -440,7 +417,6 @@ escape_string (FILE *f, char *s, int len) { char *ep = &s[len]; char *bp, *cp; - int attr = 0; for (bp = cp = s; bp < ep; bp = cp) { @@ -466,9 +442,6 @@ escape_string (FILE *f, char *s, int len) assert (0); } } - - if (attr) - change_attributes (f, &attr, 0); } /* Write table T to THIS output driver. */ @@ -477,8 +450,6 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) { struct html_driver_ext *x = this->ext; - tab_hit++; - if (t->nr == 1 && t->nc == 1) { fputs ("

", x->file.file); @@ -501,7 +472,6 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) { int r; - struct len_string *cc = t->cc; unsigned char *ct = t->ct; for (r = 0; r < t->nr; r++) @@ -509,15 +479,22 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) int c; fputs (" \n", x->file.file); - for (c = 0; c < t->nc; c++, cc++, ct++) + for (c = 0; c < t->nc; c++, ct++) { + struct len_string *cc; int tag; char header[128]; char *cp; + struct tab_joined_cell *j = NULL; - if ((*ct & TAB_JOIN) - && ((struct tab_joined_cell *) ls_value (cc))->hit == tab_hit) - continue; + cc = t->cc + c + r * t->nc; + if (*ct & TAB_JOIN) + { + j = (struct tab_joined_cell *) ls_value (cc); + cc = &j->contents; + if (j->x1 != c || j->y1 != r) + continue; + } if (r < t->t || r >= t->nr - t->b || c < t->l || c >= t->nc - t->r) @@ -543,31 +520,30 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) if (*ct & TAB_JOIN) { - struct tab_joined_cell *j = - (struct tab_joined_cell *) ls_value (cc); - j->hit = tab_hit; - if (j->x2 - j->x1 > 1) cp = spprintf (cp, " COLSPAN=%d", j->x2 - j->x1); if (j->y2 - j->y1 > 1) cp = spprintf (cp, " ROWSPAN=%d", j->y2 - j->y1); + + cc = &j->contents; } strcpy (cp, ">"); fputs (header, x->file.file); - { - char *s = ls_value (cc); - size_t l = ls_length (cc); - - while (l && isspace ((unsigned char) *s)) - { - l--; - s++; - } + if ( ! (*ct & TAB_EMPTY) ) + { + char *s = ls_value (cc); + size_t l = ls_length (cc); + + while (l && isspace ((unsigned char) *s)) + { + l--; + s++; + } - escape_string (x->file.file, s, l); - } + escape_string (x->file.file, s, l); + } fprintf (x->file.file, "\n", tag); }