OSDN Git Service

man2html: Handle table format spec which consists of only '_'.
authorAkihiro MOTOKI <amotoki@gmail.com>
Wed, 19 Oct 2011 17:43:51 +0000 (02:43 +0900)
committerAkihiro MOTOKI <amotoki@gmail.com>
Wed, 19 Oct 2011 18:31:24 +0000 (03:31 +0900)
Before this commit, a data line corresponding to the table
format specification which consists of only '_' is disappeared
during conversion by man2html. For example, in signal(7)
a first row next to the title disappears after HTML conversion.

This commit adds a function to check if a table format spec for
a current row has one or more data item and during scanning data
items scan_table() skips such a table format spec without data items.

admin/man-1.6g/man2html/man2html.c

index 86d5040..c44a69b 100644 (file)
@@ -848,6 +848,21 @@ next_row(TABLEROW *tr)
     }
 }
 
     }
 }
 
+/* Check if the specified row contain at least one data item.
+   1: has data item
+   0: no data item
+ */
+static int
+row_has_data(TABLEROW *currow) {
+  TABLEITEM *curfield;
+  curfield = currow->first;
+  while (curfield) {
+    if (curfield->align != '_') return 1;
+    curfield = curfield->next;
+  }
+  return 0;
+}
+
 char itemreset[20]="\\fR\\s0";
 
 static char *
 char itemreset[20]="\\fR\\s0";
 
 static char *
@@ -932,7 +947,9 @@ scan_table(char *c) {
                    } while (curfield && curfield->align=='S');
                }
                if (c[1]=='\n') {
                    } while (curfield && curfield->align=='S');
                }
                if (c[1]=='\n') {
-                   currow=next_row(currow);
+                   do {
+                       currow=next_row(currow);
+                   } while (!row_has_data(currow));
                    curfield=currow->first;
                }
                c=c+2;
                    curfield=currow->first;
                }
                c=c+2;
@@ -955,7 +972,9 @@ scan_table(char *c) {
            } else
                if (g) free(g);
            if (c[-1]=='\n') {
            } else
                if (g) free(g);
            if (c[-1]=='\n') {
-               currow=next_row(currow);
+               do {
+                   currow=next_row(currow);
+               } while (!row_has_data(currow));
                curfield=currow->first;
            }
        } else if (*c=='.' && c[1]=='T' && c[2]=='&' && c[-1]=='\n') {
                curfield=currow->first;
            }
        } else if (*c=='.' && c[1]=='T' && c[2]=='&' && c[-1]=='\n') {
@@ -968,7 +987,9 @@ scan_table(char *c) {
            hr->prev=currow;
            currow->next=hr;
            currow=hr;
            hr->prev=currow;
            currow->next=hr;
            currow=hr;
-           next_row(currow);
+           do {
+               currow=next_row(currow);
+           } while (!row_has_data(currow));
            curfield=currow->first;
        } else if (*c=='.' && c[1]=='T' && c[2]=='E' && c[-1]=='\n') {
            finished=1;
            curfield=currow->first;
        } else if (*c=='.' && c[1]=='T' && c[2]=='E' && c[-1]=='\n') {
            finished=1;
@@ -1009,7 +1030,9 @@ scan_table(char *c) {
            if (i) *c=itemsep;
            c=h;
            if (c[-1]=='\n') {
            if (i) *c=itemsep;
            c=h;
            if (c[-1]=='\n') {
-               currow=next_row(currow);
+               do {
+                   currow=next_row(currow);
+               } while (!row_has_data(currow));
                curfield=currow->first;
            }
        }
                curfield=currow->first;
            }
        }