From 5168c6a990e886be01f9dad043e8cc74d29b8c90 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sat, 23 Sep 2000 01:43:13 +0000 Subject: [PATCH] * fixhlp.c: Removed. * Makefile.in: Removed all references to fixhlp.c --- src/ChangeLog | 5 + src/Makefile.in | 7 +- src/fixhlp.c | 243 ------------------------------------------------ 3 files changed, 8 insertions(+), 247 deletions(-) delete mode 100644 src/fixhlp.c diff --git a/src/ChangeLog b/src/ChangeLog index 10f537085..e27b8ac4e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2000-09-22 Pavel Roskin + + * fixhlp.c: Removed. + * Makefile.in: Removed all references to fixhlp.c + 2000-09-14 Pavel Roskin * features.h: Joined with textconf.h to avoid name clash with diff --git a/src/Makefile.in b/src/Makefile.in index bbf5e461f..61c4d389b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -57,8 +57,7 @@ OBJS = dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o \ DISTFILES = \ $(HDRS) $(SRCS) Makefile.in TODO ChangeLog OChangeLog man2hlp.c \ - gindex.pl cons.saver.c ncurses.patch mc.hlp depend.awk \ - fixhlp.c mfmt.c + gindex.pl cons.saver.c ncurses.patch mc.hlp depend.awk mfmt.c all: mc mcmfmt $(srcdir)/mc.hlp @saver_target@ Makefile @@ -97,7 +96,7 @@ TAGS: $(SRCS) etags $(SRCS) clean: - $(RMF) mc cons.saver man2hlp fixhlp *.o core a.out mc.html mcmfmt + $(RMF) mc cons.saver man2hlp *.o core a.out mc.html mcmfmt realclean: clean $(RMF) .depend @@ -106,7 +105,7 @@ realclean: clean distclean: $(RMF) $(srcdir)/*~ $(srcdir)/mc $(srcdir)/cons.saver - $(RMF) $(srcdir)/man2hlp $(srcdir)/fixhlp $(srcdir)/*.o $(srcdir)/core + $(RMF) $(srcdir)/man2hlp $(srcdir)/*.o $(srcdir)/core $(RMF) $(srcdir)/a.out $(srcdir)/mc.html -if test $(srcdir) = .; then $(MAKE) realclean; fi $(RMF) $(srcdir)/Makefile diff --git a/src/fixhlp.c b/src/fixhlp.c deleted file mode 100644 index 23569d7b4..000000000 --- a/src/fixhlp.c +++ /dev/null @@ -1,243 +0,0 @@ -/* HLP converter - Copyright (C) 1994, 1995 Janne Kukonlehto - Copyright (C) 1995 Jakub Jelinek - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include -#include -#include -#include -#include -#include "global.h" -#include "help.h" - -static int width; /* Output width in characters */ -static int col = 0; /* Current output column */ -static FILE *toc_file; /* TOC file */ -static int out_row = 1; /* Current output row */ -static int in_row = 0; /* Current input row */ -static int indent = 1; -static int curindent = 1; -static int freshnl = 1; -static int firstlen = 0; -static int verbatim = 0; - -/* Report error in input */ -void print_error (char *message) -{ - fprintf (stderr, "fixhlp: %s at row %d\n", message, in_row); -} - -/* Change output line */ -void newline (void) -{ - out_row ++; - col = indent; - curindent = indent; - printf("\n%*s", indent, ""); - freshnl = 1; - firstlen = 0; -} - -/* Calculate the length of string */ -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 i; /* Index */ - int c; /* Current character */ - int len = 0; /* Result: the length of the string */ - - for (i = 0; i < strlen (buffer); i ++) - { - c = buffer [i]; - if (c == CHAR_LINK_POINTER) - link_flag = 1; /* Link target name starts */ - else if (c == CHAR_LINK_END) - link_flag = 0; /* Link target name ends */ - else if (c == CHAR_NODE_END){ - /* Node anchor name starts */ - anchor_flag = 1; - /* Ugly hack to prevent loss of one space */ - len ++; - } - /* Don't add control characters to the length */ - if (c < 32) - continue; - /* Attempt to handle backslash quoting */ - /* Increase length if not inside anchor name or link target name */ - if (!anchor_flag && !link_flag) - len ++; - if (anchor_flag && c == ']'){ - /* Node anchor name ends */ - anchor_flag = 0; - } - } - return len; -} - -/* Output the string */ -void print_string (char *buffer) -{ - int len; /* The length of current word */ - char *p; - - /* Split into words */ - if (verbatim) { - printf ("%s", buffer); - newline (); - return; - } - p = strchr (buffer, CHAR_LINK_POINTER); - if (p) { - char *q; - - *p = 0; - print_string (buffer); - q = strchr (p + 1, CHAR_LINK_END); - if (q) { - *q = 0; - printf ("%c%s%c", CHAR_LINK_POINTER, p + 1, CHAR_LINK_END); - print_string (q + 1); - } else { - /* Error, but try to handle it somehow */ - printf ("%c", CHAR_LINK_END); - } - return; - } - buffer = strtok (buffer, " \t\n"); - /* Repeat for each word */ - while (buffer){ - /* Skip empty strings */ - if (strlen (buffer) > 0){ - len = string_len (buffer); - /* Change the line if about to break the right margin */ - if (col + len >= width) - newline (); - /* Words are separated by spaces */ - if (col > curindent){ - printf (" "); - col ++; - } - printf ("%s", buffer); - /* Increase column */ - col += len; - } - /* Get the next word */ - buffer = strtok (NULL, " \t\n"); - } /* while */ - if (freshnl) { - firstlen = col - curindent; - freshnl = 0; - } -} - -/* Like print_string but with printf-like syntax */ -void printf_string (char *format, ...) -{ - va_list args; - char buffer [BUF_LARGE]; - - va_start (args, format); - vsprintf (buffer, format, args); - va_end (args); - print_string (buffer); -} - -int main (int argc, char **argv) -{ - int len; /* Length of input line */ - char buffer [BUF_LARGE]; /* Input line */ - char *p; - int ignore_newline = 0; - - /* Validity check for arguments */ - if (argc != 3 || (width = atoi (argv[1])) <= 10){ - fprintf (stderr, _("Usage: fixhlp \n")); - return 3; - } - - if ((toc_file = fopen (argv[2], "w")) == NULL) { - fprintf (stderr, _("fixhlp: Cannot open toc for writing")); - return 4; - } - fprintf (toc_file, _("\04[Contents]\n Topics:\n\n")); - - /* Repeat for each input line */ - while (!feof (stdin)){ - /* Read a line */ - if (!fgets (buffer, sizeof(buffer), stdin)){ - break; - } - in_row ++; - len = strlen (buffer); - /* Remove terminating newline */ - if (buffer [len-1] == '\n') - { - len --; - buffer [len] = 0; - } - if (!buffer[0]) { - if (ignore_newline) - ignore_newline = 0; - else - newline (); - } else { - if (buffer [0] == 4 && buffer [1] == '[') { - for (p = buffer + 2; *p == ' '; p++); - fprintf (toc_file, "%*s\01 %s \02%s\03\n", p - buffer + 1, "", p, p); - printf ("\04[%s]\n %s", p, p); - } else if (buffer [0] == CHAR_RESERVED && buffer [1] == '"') { - continue; - } else { - char *p, *q; - int i; - - for (p = buffer, q = strchr (p, CHAR_RESERVED); q != NULL; - p = q + 1, q = strchr (p, CHAR_RESERVED)) { - *q = 0; - if (*p) - print_string (p); - q++; - if (*q == '/') - ignore_newline = 1; - else if (*q == 'v') - verbatim = 1; - else if (*q == 'n') - verbatim = 0; - else { - indent = *q - '0'; - if (ignore_newline) { - i = firstlen; - if (i > indent - curindent - 1) - ignore_newline = 0; - else { - i = indent - curindent - i - 1; - printf ("%*s", i, ""); - col += i; - } - } - } - } - print_string (p); - } - } - } - - /* All done */ - newline (); - return 0; -}