diff --git a/src/ChangeLog b/src/ChangeLog index 9b05fe293..58338a40d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2001-08-15 Pavel Roskin + * man2hlp.c: Remove HTML support. Remove old link support. + Warning fixes. + (print_string): Handle backslashes in verbatim mode too. + * main.c (setup_pre) [HAVE_CHARSET]: Fix compilation with ncurses. diff --git a/src/man2hlp.c b/src/man2hlp.c index 1469f4154..22010e2d8 100644 --- a/src/man2hlp.c +++ b/src/man2hlp.c @@ -29,7 +29,6 @@ static int width; /* Output width in characters */ static int col = 0; /* Current output column */ static int out_row = 1; /* Current output row */ static int in_row = 0; /* Current input row */ -static int old_heading_level = 0;/* Level of the last heading */ static int no_split_flag = 0; /* Flag: Don't split section on next ".SH" */ static int skip_flag = 0; /* Flag: Skip this section. 0 = don't skip, @@ -39,13 +38,13 @@ static int link_flag = 0; /* Flag: Next line is a link */ static int verbatim_flag = 0; /* Flag: Copy input to output verbatim */ /* Report error in input */ -void print_error (char *message) +static void print_error (char *message) { fprintf (stderr, "man2hlp: %s in file \"%s\" at row %d\n", message, filename, in_row); } /* Change output line */ -void newline (void) +static void newline (void) { out_row ++; col = 0; @@ -53,12 +52,12 @@ void newline (void) } /* Calculate the length of string */ -int string_len (char *buffer) +static int string_len (char *buffer) { static int anchor_flag = 0; /* Flag: Inside hypertext anchor name */ static int link_flag = 0; /* Flag: Inside hypertext link target name */ int backslash_flag = 0; /* Flag: Backslash quoting */ - int i; /* Index */ + unsigned int i; /* Index */ int c; /* Current character */ int len = 0; /* Result: the length of the string */ @@ -96,11 +95,11 @@ int string_len (char *buffer) } /* Output the string */ -void print_string (char *buffer) +static void print_string (char *buffer) { - int len; /* The length of current word */ - int i; /* Index */ - int c; /* Current character */ + int len; /* The length of current word */ + unsigned int i; /* Index */ + int c; /* Current character */ int backslash_flag = 0; /* Skipping lines? */ @@ -108,11 +107,17 @@ void print_string (char *buffer) return; /* Copying verbatim? */ if (verbatim_flag){ - printf("%s", buffer); - return; - } - if (width){ - /* HLP format */ + /* Attempt to handle backslash quoting */ + for (i = 0; i < strlen (buffer); i++){ + c = buffer [i]; + if (c == '\\' && !backslash_flag){ + backslash_flag = 1; + continue; + } + backslash_flag = 0; + printf ("%c", c); + } + } else { /* Split into words */ buffer = strtok (buffer, " \t\n"); /* Repeat for each word */ @@ -145,26 +150,11 @@ void print_string (char *buffer) /* Get the next word */ buffer = strtok (NULL, " \t\n"); } /* while */ - } else { - /* HTML format */ - if (strlen (buffer) > 0){ - /* Attempt to handle backslash quoting */ - for (i = 0; i < strlen (buffer); i++) - { - c = buffer [i]; - if (c == '\\' && !backslash_flag){ - backslash_flag = 1; - continue; - } - backslash_flag = 0; - printf ("%c", c); - } - } - } /* if (width) */ + } } /* Like print_string but with printf-like syntax */ -void printf_string (char *format, ...) +static void printf_string (char *format, ...) { va_list args; char buffer [BUFFER_SIZE]; @@ -176,9 +166,9 @@ void printf_string (char *format, ...) } /* Handle all the roff dot commands */ -void handle_command (char *buffer) +static void handle_command (char *buffer) { - int i, len, heading_level; + int len, heading_level; /* Get the command name */ strtok (buffer, " \t"); @@ -211,18 +201,10 @@ void handle_command (char *buffer) print_error ("Syntax error: .SH: odd heading level"); if (no_split_flag){ /* Don't start a new section */ - if (width){ - /* HLP format */ - newline (); - print_string (buffer); - newline (); - newline (); - } else { - /* HTML format */ - newline (); - printf_string ("

%s

", buffer); - newline (); - } + newline (); + print_string (buffer); + newline (); + newline (); no_split_flag = 0; } else if (skip_flag){ @@ -231,38 +213,12 @@ void handle_command (char *buffer) } else { /* Start a new section */ - if (width){ - /* HLP format */ - printf ("%c[%s]", CHAR_NODE_END, buffer); - col ++; - newline (); - print_string (buffer + heading_level); - newline (); - newline (); - } else { - /* HTML format */ - if (buffer [0]){ - if (heading_level > old_heading_level){ - for (i = old_heading_level; i < heading_level; i += 2) - printf (""); - } - old_heading_level = heading_level; - printf_string ("%s", - heading_level / 2 + 2, buffer + heading_level, - buffer + heading_level, heading_level / 2 + 2); - newline (); - printf ("
  • %s\n", - buffer + heading_level, buffer + heading_level); - } else { - for (i = 0; i < old_heading_level; i += 2) - printf (""); - old_heading_level = 0; - printf ("

    "); - old_heading_level = 0; - printf ("
    \n"); - print_string ("
    "); - newline (); - } fclose (file); return 0; }