From 39326aaa5750f17b2e2741fe082c373abc110615 Mon Sep 17 00:00:00 2001 From: Marc Ewing Date: Sun, 8 Mar 1998 21:24:45 +0000 Subject: Misc cleanups of gnome-helpwin, gnome-info2html, gnome-man2html, my bogus 1998-03-08 Marc Ewing * Misc cleanups of gnome-helpwin, gnome-info2html, gnome-man2html, my bogus function casts. * Rework some of docobj to handle binary data. Now the raw/conv data is *not* NULL terminated! * Added simple (stupid) http transport. --- components/help/converters/gnome-info2html2/data.h | 6 - components/help/converters/gnome-info2html2/html.c | 6 +- components/help/converters/gnome-info2html2/main.c | 6 + .../converters/gnome-man2html2/gnome-man2html.c | 156 +-------------------- 4 files changed, 10 insertions(+), 164 deletions(-) diff --git a/components/help/converters/gnome-info2html2/data.h b/components/help/converters/gnome-info2html2/data.h index 581e4ca56..60a2ce747 100644 --- a/components/help/converters/gnome-info2html2/data.h +++ b/components/help/converters/gnome-info2html2/data.h @@ -4,12 +4,6 @@ /* data.h - first cut at data structures for info2html filter */ /* many of these are motivated by the source code to the 'info' program */ -/* be quiet or not? */ -static int be_quiet=1; - -/* line_number we're on */ -static int work_line_number; - /* file we're working on */ char work_filename[1024]; diff --git a/components/help/converters/gnome-info2html2/html.c b/components/help/converters/gnome-info2html2/html.c index 90c2e2fb9..802a4b874 100644 --- a/components/help/converters/gnome-info2html2/html.c +++ b/components/help/converters/gnome-info2html2/html.c @@ -202,10 +202,10 @@ void html_error( char *s, char *p, char *q ) void dump_html_for_node( NODE *node ) { - char *destdir; - char *destfile; +/* char *destdir; */ +/* char *destfile; */ char *escaped_nodename; - char *converted_nodename; +/* char *converted_nodename; */ char *contents_start, *contents_end; char *header_name; char *p, *q, *r, *skippnt; diff --git a/components/help/converters/gnome-info2html2/main.c b/components/help/converters/gnome-info2html2/main.c index a490a24b6..4bae84aac 100644 --- a/components/help/converters/gnome-info2html2/main.c +++ b/components/help/converters/gnome-info2html2/main.c @@ -10,6 +10,12 @@ #include "utils.h" #include "version.h" +/* be quiet or not? */ +static int be_quiet=1; + +/* line_number we're on */ +static int work_line_number; + int main(int argc, char **argv) { diff --git a/components/help/converters/gnome-man2html2/gnome-man2html.c b/components/help/converters/gnome-man2html2/gnome-man2html.c index 05bb0fa1c..bf40671ea 100644 --- a/components/help/converters/gnome-man2html2/gnome-man2html.c +++ b/components/help/converters/gnome-man2html2/gnome-man2html.c @@ -157,20 +157,6 @@ */ #define free(x) -static char *sections = "123456789nl"; - - -static char -*strgrow(char *old, int len) -{ - char *new = realloc(old, (strlen(old) + len + 1) * sizeof(char)); - if (!new) { - fprintf(stderr, "man2html: out of memory"); - exit(EXIT_FAILURE); - } - return new; -} - static char *stralloc(int len) { @@ -183,17 +169,6 @@ static char return new; } -static char -*strduplicate(char *from) -{ -/* Some systems don't have strdup so lets use our own - which can also - * check for out of memory. - */ - char *new = stralloc(strlen(from)); - strcpy(new, from); - return new; -} - static char *strmaxcpy(char *to, char *from, int n) { /* Assumes space for n plus a null */ @@ -203,19 +178,6 @@ static char return to; } -static char -*strmaxcat(char *to, char *from, int n) -{ /* Assumes space for n plus a null */ - int to_len = strlen(to); - if (to_len < n) { - int from_len = strlen(from); - int cp = (to_len + from_len <= n) ? from_len : n - to_len; - strncpy(to + to_len, from, cp); - to[to_len + cp] = '\0'; - } - return to; -} - static char *strlimitcpy(char *to, char *from, int n, int limit) { /* Assumes space for limit plus a null */ @@ -225,36 +187,6 @@ static char return to; } -static char -*escape_input(char *str) -/* takes string and escapes all metacharacters. should be used before - including string in system() or similar call. */ -{ - int i,j = 0; - static char new[NULL_TERMINATED(MED_STR_MAX)]; - - if (strlen(str) * 2 + 1 > MED_STR_MAX) { - fprintf(stderr, - "man2html: escape_input - str too long:\n%-80s...\n", - str); - exit(EXIT_FAILURE); - } - - for (i = 0; i < strlen(str); i++) { - if (!( ((str[i] >= 'A') && (str[i] <= 'Z')) || - ((str[i] >= 'a') && (str[i] <= 'z')) || - ((str[i] >= '0') && (str[i] <= '9')) )) { - new[j] = '\\'; - j++; - } - new[j] = str[i]; - j++; - } - new[j] = '\0'; - return new; -} - - /* below this you should not change anything unless you know a lot ** about this program or about troff. */ @@ -3677,98 +3609,12 @@ static char return ret; } - -static char *sectionname=NULL; -static STRDEF *foundpages=NULL; - -static void get_man_config() -{ -#ifdef MAN_CONFIG - FILE *config = NULL; - int num_paths = 1; /* Zero is reserved for searches */ - int num_zcats = 0; - char buffer[NULL_TERMINATED(MED_STR_MAX + 1)]; - /* Allow for adding a "/" */ - - config = fopen(MAN_CONFIG, "r"); - if (!config) - return; /* Assume no config. */ - - while (fgets(buffer, MED_STR_MAX, config)) { - char *dir, *line = buffer; - line = line + strspn(line, " \t"); /* Skip spaces and tabs */ - if (num_paths < MAX_MAN_PATHS - && strncmp("MANPATH", line, 7) == 0 - && (dir = strchr(line, '/'))) { /* dir points to start - of dir-name */ - char *end_dir = strpbrk(dir, " \t\n") ; - if (end_dir) { /* End of dir name. */ - (*end_dir) = '/'; /* Replace newline/space - with "/" */ - (*(end_dir + 1)) = '\0'; - } - manpath[num_paths] = strduplicate(dir); - num_paths++; - } -#ifndef DISABLE_ZCATS - else if (num_zcats < MAX_ZCATS - && *line == '.') { - char *sp, *new; - line[strlen(line) - 1] = '\0'; /* Remove newline */ - zcats[num_zcats] = strduplicate(line); - sp = strpbrk(zcats[num_zcats], " \t"); - if (sp) { /* Chop off trailing spaces */ - (*sp) = '\0'; - num_zcats++; - } else { - free(zcats[num_zcats]); - } - } -#endif - } - if (num_paths != 0) { /* Mark new end of paths list */ - manpath[num_paths] = NULL; - } -#ifndef DISABLE_ZCATS - if (num_zcats != 0) { /* Mark new end of zcats list */ - zcats[num_zcats] = NULL; - } -#endif - -#ifndef UNSECURE_MANPATH - /* Make sure settable first path is - * a valid path. - */ - - if (strcmp(manpath[0], "/") != 0) { - /* Something other than default */ - int i; - for (i = 1; manpath[i]; i++) { - /* Set - see if it is a valid prefix */ - if (strncmp(manpath[i], manpath[0], - strlen(manpath[i])) == 0) { - break; /* valid */ - } - } - /* Also check for .. */ - if (!manpath[i] || - strstr(manpath[0], "..") != NULL) { /* invalid */ - fprintf(stderr, "man2html: invalid -M path: " - "%s\n", manpath[0]); - manpath[0] = manpath[1]; - } - } -#endif - fclose(config); -#endif -} - void main(int argc, char **argv) { char *t=NULL; int i;char *buf; - char *h, *fullname; + char *h = '\0'; STRDEF *stdf; -- cgit v1.2.1