diff options
author | Marc Espie <espie@cvs.openbsd.org> | 1999-01-11 16:38:16 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 1999-01-11 16:38:16 +0000 |
commit | 33f48d5efec336d91bc14868b6603b6e53804e89 (patch) | |
tree | e1b0250475483d3c1404da35563e0743a5e2924d /gnu/usr.bin/texinfo/makeinfo | |
parent | 99605a9e62a5b339ff09bd970d377cb20fc4a159 (diff) |
Upgrade to 3.12, merge with OpenBSD changes.
Diffstat (limited to 'gnu/usr.bin/texinfo/makeinfo')
-rw-r--r-- | gnu/usr.bin/texinfo/makeinfo/Makefile.am | 2 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/makeinfo/makeinfo.c | 161 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/makeinfo/makeinfo.h | 62 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/makeinfo/multi.c | 192 |
4 files changed, 219 insertions, 198 deletions
diff --git a/gnu/usr.bin/texinfo/makeinfo/Makefile.am b/gnu/usr.bin/texinfo/makeinfo/Makefile.am index 3e341fb62cc..4668600367f 100644 --- a/gnu/usr.bin/texinfo/makeinfo/Makefile.am +++ b/gnu/usr.bin/texinfo/makeinfo/Makefile.am @@ -1,5 +1,5 @@ ## Makefile.am for texinfo/makeinfo. -## $Id: Makefile.am,v 1.1 1997/08/01 22:00:54 kstailey Exp $ +## $Id: Makefile.am,v 1.2 1999/01/11 16:38:11 espie Exp $ ## Run automake in .. to produce Makefile.in from this. bin_PROGRAMS = makeinfo diff --git a/gnu/usr.bin/texinfo/makeinfo/makeinfo.c b/gnu/usr.bin/texinfo/makeinfo/makeinfo.c index 91898aec115..ae44121aa82 100644 --- a/gnu/usr.bin/texinfo/makeinfo/makeinfo.c +++ b/gnu/usr.bin/texinfo/makeinfo/makeinfo.c @@ -1,7 +1,8 @@ /* Makeinfo -- convert Texinfo source files into Info files. - $Id: makeinfo.c,v 1.4 1997/08/04 15:28:20 kstailey Exp $ + $Id: makeinfo.c,v 1.5 1999/01/11 16:38:11 espie Exp $ - Copyright (C) 1987, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98 + Free Software Foundation, Inc. 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 @@ -115,6 +116,9 @@ int must_start_paragraph = 0; /* Nonzero means a string is in execution, as opposed to a file. */ static int executing_string = 0; +/* Nonzero means a macro string is in execution, as opposed to a file. */ +static int me_executing_string = 0; + #if defined (HAVE_MACROS) /* If non-NULL, this is an output stream to write the full macro expansion of the input text to. The result is another texinfo file, but @@ -1082,10 +1086,11 @@ main (argc, argv) case 'V': /* User requested version info. */ print_version_info (); - puts (_("Copyright (C) 1996 Free Software Foundation, Inc.\n\ + printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ There is NO warranty. You may redistribute this software\n\ under the terms of the GNU General Public License.\n\ -For more information about these matters, see the files named COPYING.")); +For more information about these matters, see the files named COPYING.\n"), + "1998"); exit (NO_ERROR); break; @@ -1143,7 +1148,7 @@ For more information about these matters, see the files named COPYING.")); void print_version_info () { - printf (_("makeinfo (GNU %s %s) %d.%d\n"), PACKAGE, VERSION, + printf ("makeinfo (GNU %s %s) %d.%d\n", PACKAGE, VERSION, major_version, minor_version); } @@ -1188,10 +1193,10 @@ Options:\n\ --verbose report about what is being done.\n\ --version display version information and exit.\n\ \n\ -Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\ +Email bug reports to bug-texinfo@gnu.org.\n\ "), - progname, paragraph_start_indent, - fill_column, max_error_level, reference_warning_limit); + progname, max_error_level, fill_column, + paragraph_start_indent, reference_warning_limit); exit (exit_value); } @@ -1248,8 +1253,8 @@ find_and_load (filename) if (file < 0) goto error_exit; - /* Load the file. */ - result = (char *)xmalloc (1 + file_size); + /* Load the file, with enough room for a newline and a null. */ + result = xmalloc (file_size + 2); /* VMS stat lies about the st_size value. The actual number of readable bytes is always less than this value. The arcane @@ -1291,10 +1296,10 @@ find_and_load (filename) line_number = 1; /* Not strictly necessary. This magic prevents read_token () from doing extra unnecessary work each time it is called (that is a lot of times). - The SIZE_OF_INPUT_TEXT is one past the actual end of the text. */ + SIZE_OF_INPUT_TEXT is one past the actual end of the text. */ input_text[size_of_input_text] = '\n'; - /* Strictly necessary. */ - input_text[size_of_input_text+1] = '\0'; + /* This, on the other hand, is always necessary. */ + input_text[size_of_input_text+1] = 0; return (result); } @@ -1335,7 +1340,7 @@ popfile () filestack = filestack->next; /* Make sure that commands with braces have been satisfied. */ - if (!executing_string) + if (!executing_string && !me_executing_string) discard_braces (); /* Get the top of the stack into the globals. */ @@ -1819,7 +1824,7 @@ get_until_in_line (expand, match, string) `execution_strings' array. This happens when processing the (synthetic) Overview-Footnotes node in the Texinfo manual. */ - if (expand && !executing_string) + if (expand && !executing_string && !me_executing_string) { char *xp; unsigned xp_len, new_len; @@ -1835,12 +1840,15 @@ get_until_in_line (expand, match, string) xp_len = strlen (xp); free (str); - /* Plunk the expansion into the middle of input_text. */ - str = xstrdup (input_text + limit); - new_len = input_text_offset + xp_len + strlen (str) + 1; + /* Plunk the expansion into the middle of `input_text' -- + which is terminated by a newline, not a null. */ + str = xmalloc (real_bottom - limit + 1); + strncpy (str, input_text + limit, real_bottom - limit + 1); + new_len = input_text_offset + xp_len + real_bottom - limit + 1; input_text = xrealloc (input_text, new_len); strcpy (input_text + input_text_offset, xp); - strcat (input_text, str); + strncpy (input_text + input_text_offset + xp_len, str, + real_bottom - limit + 1); free (str); free (xp); @@ -3975,7 +3983,7 @@ cm_today (arg) { time_t timer = time (0); struct tm *ts = localtime (&timer); - add_word_args (_("%d %s %d"), ts->tm_mday, _(months[ts->tm_mon]), + add_word_args ("%d %s %d", ts->tm_mday, _(months[ts->tm_mon]), ts->tm_year + 1900); } } @@ -4162,7 +4170,7 @@ insert_and_underscore (with_char) no_indent = 1; #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) append_to_expansion_output (input_text_offset + 1); #endif /* HAVE_MACROS */ @@ -4170,7 +4178,7 @@ insert_and_underscore (with_char) starting_pos = output_position + output_paragraph_offset; #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) { char *temp1 = (char *) xmalloc (2 + strlen (temp)); sprintf (temp1, "%s\n", temp); @@ -4314,7 +4322,7 @@ cm_top () { TAG_ENTRY *tag = tag_table; - line_error (_("There already is a node having %ctop as a section"), + line_error (_("Node with %ctop as a section already exists"), COMMAND_PREFIX); while (tag != (TAG_ENTRY *)NULL) @@ -4732,7 +4740,7 @@ cm_node () current_footnote_number = 1; #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) append_to_expansion_output (input_text_offset + 1); #endif /* HAVE_MACROS */ @@ -4745,7 +4753,7 @@ cm_node () printf (_("Formatting node %s...\n"), node); #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); #endif /* HAVE_MACROS */ @@ -4755,7 +4763,7 @@ cm_node () add_word_args ("\037\nFile: %s, Node: ", pretty_output_filename); #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) me_execute_string (node); else #endif /* HAVE_MACROS */ @@ -4936,7 +4944,7 @@ cm_node () #if defined (HAVE_MACROS) /* Insert the correct args if we are expanding macros, and the node's pointers weren't defaulted. */ - if (macro_expansion_output_stream && !defaulting) + if (macro_expansion_output_stream && !executing_string && !defaulting) { char *temp; int op_orig = output_paragraph_offset; @@ -5835,7 +5843,7 @@ cm_uref (arg, start_pos, end_pos) if (arg == END) { char *comma; - char *arg = &output_paragraph[start_pos]; + char *arg = (char *) &output_paragraph[start_pos]; output_paragraph[end_pos] = 0; output_column -= end_pos - start_pos; @@ -5879,7 +5887,7 @@ cm_email (arg, start_pos, end_pos) if (arg == END) { char *comma; - char *arg = &output_paragraph[start_pos]; + char *arg = (char *) &output_paragraph[start_pos]; output_paragraph[end_pos] = 0; output_column -= end_pos - start_pos; @@ -6316,8 +6324,8 @@ cm_value (arg, start_pos, end_pos) { if (arg == END) { - char *name, *value; - name = &output_paragraph[start_pos]; + char *name = (char *) &output_paragraph[start_pos]; + char *value; output_paragraph[end_pos] = 0; name = xstrdup (name); value = set_p (name); @@ -6625,13 +6633,10 @@ expansion (str, implicit_code) /* Inhibit any real output. */ int start = output_paragraph_offset; int saved_paragraph_is_open = paragraph_is_open; - FILE *saved_macro_expansion_output_stream = macro_expansion_output_stream; inhibit_output_flushing (); - macro_expansion_output_stream = NULL; paragraph_is_open = 1; execute_string (implicit_code ? "@code{%s}" : "%s", str); - macro_expansion_output_stream = saved_macro_expansion_output_stream; uninhibit_output_flushing (); /* Copy the expansion from the buffer. */ @@ -7270,29 +7275,27 @@ defun_internal (type, x_p) current_indent -= default_indentation_increment; close_single_paragraph (); - if (!macro_expansion_output_stream) - /* Make an entry in the appropriate index unless we are just - expanding macros. */ - switch (base_type) - { - case deffn: - case deftypefn: - execute_string ("%cfindex %s\n", COMMAND_PREFIX, defined_name); - break; - case defvr: - case deftypevr: - case defcv: - execute_string ("%cvindex %s\n", COMMAND_PREFIX, defined_name); - break; - case defop: - case deftypemethod: - execute_string ("%cfindex %s on %s\n", - COMMAND_PREFIX, defined_name, type_name); - break; - case deftp: - execute_string ("%ctindex %s\n", COMMAND_PREFIX, defined_name); - break; - } + /* Make an entry in the appropriate index. */ + switch (base_type) + { + case deffn: + case deftypefn: + execute_string ("%cfindex %s\n", COMMAND_PREFIX, defined_name); + break; + case defvr: + case deftypevr: + case defcv: + execute_string ("%cvindex %s\n", COMMAND_PREFIX, defined_name); + break; + case defop: + case deftypemethod: + execute_string ("%cfindex %s on %s\n", + COMMAND_PREFIX, defined_name, type_name); + break; + case deftp: + execute_string ("%ctindex %s\n", COMMAND_PREFIX, defined_name); + break; + } /* Deallocate the token list. */ scan_args = defun_args; @@ -7564,7 +7567,7 @@ cm_include () char *filename; #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) me_append_before_this_command (); #endif /* HAVE_MACROS */ @@ -7572,7 +7575,7 @@ cm_include () get_rest_of_line (&filename); #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); #endif /* HAVE_MACROS */ @@ -7610,7 +7613,7 @@ cm_include () else { #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); #endif /* HAVE_MACROS */ reader_loop (); @@ -7938,7 +7941,7 @@ index_add_arg (name) which = tem ? tem->write_index : -1; #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) append_to_expansion_output (input_text_offset + 1); #endif /* HAVE_MACROS */ @@ -7946,7 +7949,7 @@ index_add_arg (name) ignore_blank_line (); #if defined (HAVE_MACROS) - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) { int op_orig; @@ -8438,12 +8441,12 @@ cm_footnote () char *marker; char *note; - if (macro_expansion_output_stream) - append_to_expansion_output (input_text_offset + 1); /* include the { */ - get_until ("{", &marker); canon_white (marker); + if (macro_expansion_output_stream && !executing_string) + append_to_expansion_output (input_text_offset + 1); /* include the { */ + /* Read the argument in braces. */ if (curchar () != '{') { @@ -8485,7 +8488,7 @@ cm_footnote () /* Must write the macro-expanded argument to the macro expansion output stream. This is like the case in index_add_arg. */ - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) { int op_orig; @@ -8856,10 +8859,10 @@ apply (named, actuals, body) } else { /* not a parameter, restore \'s */ - char *trailer = body[i] ? "/" : ""; - len += 1 + strlen (trailer); - text = (char *)xmalloc (1 + len); - sprintf (text, "\\%s%s", param, trailer); + i = body[i] ? (i - 1) : i; + len++; + text = xmalloc (1 + len); + sprintf (text, "\\%s", param); } if ((2 + strlen (param)) < len) @@ -8890,7 +8893,7 @@ execute_macro (def) int num_args; char *execution_string = (char *)NULL; - if (macro_expansion_output_stream && !me_inhibit_expansion) + if (macro_expansion_output_stream && !executing_string && !me_inhibit_expansion) me_append_before_this_command (); /* Find out how many arguments this macro definition takes. */ @@ -8913,7 +8916,7 @@ execute_macro (def) if (def->body) { - if (macro_expansion_output_stream && !me_inhibit_expansion) + if (macro_expansion_output_stream && !executing_string && !me_inhibit_expansion) { remember_itext (input_text, input_text_offset); me_execute_string (execution_string); @@ -8941,7 +8944,7 @@ cm_macro () body_size = 0; body_index = 0; - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) me_append_before_this_command (); skip_whitespace (); @@ -9138,7 +9141,7 @@ cm_macro () add_macro (name, arglist, body, input_filename, defining_line, flags); - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); } @@ -9149,7 +9152,7 @@ cm_unmacro () char *line, *name; MACRO_DEF *def; - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) me_append_before_this_command (); get_rest_of_line (&line); @@ -9183,7 +9186,7 @@ cm_unmacro () free (line); free (name); - if (macro_expansion_output_stream) + if (macro_expansion_output_stream && !executing_string) remember_itext (input_text, input_text_offset); } @@ -9286,10 +9289,10 @@ me_execute_string (execution_string) remember_itext (execution_string, 0); - executing_string++; + me_executing_string++; reader_loop (); popfile (); - executing_string--; + me_executing_string--; } /* Append the text which appears in input_text from the last offset to @@ -9309,7 +9312,7 @@ append_to_expansion_output (offset) } if (!itext) - itext = remember_itext (input_text, 0); + return; if (offset > itext->offset) { diff --git a/gnu/usr.bin/texinfo/makeinfo/makeinfo.h b/gnu/usr.bin/texinfo/makeinfo/makeinfo.h index 78fda8c4492..258c7c9c833 100644 --- a/gnu/usr.bin/texinfo/makeinfo/makeinfo.h +++ b/gnu/usr.bin/texinfo/makeinfo/makeinfo.h @@ -1,7 +1,7 @@ /* makeinfo.h -- Declarations for Makeinfo. - $Id: makeinfo.h,v 1.1 1996/12/15 21:39:27 downsj Exp $ + $Id: makeinfo.h,v 1.2 1999/01/11 16:38:13 espie Exp $ - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 97 Free Software Foundation, Inc. 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 @@ -35,12 +35,14 @@ enum insertion_type { - menu, detailmenu, quotation, lisp, smalllisp, example, smallexample, - display, itemize, format, enumerate, cartouche, multitable, table, - ftable, vtable, group, ifinfo, flushleft, flushright, ifset, - ifclear, deffn, defun, defmac, defspec, defvr, defvar, defopt, - deftypefn, deftypefun, deftypevr, deftypevar, defcv, defivar, defop, - defmethod, deftypemethod, deftp, direntry, bad_type + cartouche, defcv, deffn, defivar, defmac, defmethod, + defop, defopt, defspec, deftp, deftypefn, deftypefun, + deftypemethod, deftypevar, deftypevr, defun, defvar, + defvr, detailmenu, direntry, display, enumerate, example, + flushleft, flushright, format, ftable, group, ifclear, + ifinfo, ifnothtml, ifnottex, ifset, itemize, lisp, menu, + multitable, quotation, smallexample, smalllisp, table, vtable, + bad_type }; DECLARE (int, insertion_level, 0); @@ -48,13 +50,13 @@ DECLARE (int, insertion_level, 0); #if defined (COMPILING_MAKEINFO) char *insertion_type_names[] = { - "menu", "detailmenu", "quotation", "lisp", "smalllisp", "example", - "smallexample", "display", "itemize", "format", "enumerate", - "cartouche", "multitable", "table", "ftable", "vtable", "group", - "ifinfo", "flushleft", "flushright", "ifset", "ifclear", "deffn", - "defun", "defmac", "defspec", "defvr", "defvar", "defopt", - "deftypefn", "deftypefun", "deftypevr", "deftypevar", "defcv", - "defivar", "defop", "defmethod", "deftypemethod", "deftp", "direntry", + "cartouche", "defcv", "deffn", "defivar", "defmac", "defmethod", + "defop", "defopt", "defspec", "deftp", "deftypefn", "deftypefun", + "deftypemethod", "deftypevar", "deftypevr", "defun", "defvar", + "defvr", "detailmenu", "direntry", "display", "enumerate", "example", + "flushleft", "flushright", "format", "ftable", "group", "ifclear", + "ifinfo", "ifnothtml", "ifnottex", "ifset", "itemize", "lisp", "menu", + "multitable", "quotation", "smallexample", "smalllisp", "table", "vtable", "bad_type" }; #endif @@ -107,15 +109,15 @@ DECLARE (int, line_number, 0); #define curchar() input_text[input_text_offset] /* **************************************************************** */ -/* */ -/* Global Defines */ -/* */ +/* */ +/* Global Defines */ +/* */ /* **************************************************************** */ /* Error levels */ #define NO_ERROR 0 -#define SYNTAX 2 -#define FATAL 4 +#define SYNTAX 2 +#define FATAL 4 /* C's standard macros don't check to make sure that the characters being changed are within range. So I have to check explicitly. */ @@ -164,29 +166,29 @@ DECLARE (int, line_number, 0); #define SPLIT_SIZE_THRESHOLD 70000 /* What's good enough for Stallman... */ #define DEFAULT_SPLIT_SIZE 50000 /* Is probably good enough for me. */ -DECLARE (int, splitting, 1); /* Defaults to true for now. */ +DECLARE (int, splitting, 1); /* Defaults to true for now. */ typedef void COMMAND_FUNCTION (); /* So I can say COMMAND_FUNCTION *foo; */ #define command_char(c) ((!whitespace(c)) && \ - ((c) != '\n') && \ - ((c) != '{') && \ - ((c) != '}') && \ - ((c) != '=')) + ((c) != '\n') && \ + ((c) != '{') && \ + ((c) != '}') && \ + ((c) != '=')) #define skip_whitespace() \ while ((input_text_offset != size_of_input_text) && \ - whitespace (curchar())) \ + whitespace (curchar())) \ input_text_offset++ #define skip_whitespace_and_newlines() \ do { \ while ((input_text_offset != size_of_input_text) && \ - (whitespace (curchar ()) || (curchar () == '\n'))) \ + (whitespace (curchar ()) || (curchar () == '\n'))) \ { \ - if (curchar () == '\n') \ - line_number++; \ - input_text_offset++; \ + if (curchar () == '\n') \ + line_number++; \ + input_text_offset++; \ } \ } while (0) diff --git a/gnu/usr.bin/texinfo/makeinfo/multi.c b/gnu/usr.bin/texinfo/makeinfo/multi.c index 273f1461013..ff6358cb6d3 100644 --- a/gnu/usr.bin/texinfo/makeinfo/multi.c +++ b/gnu/usr.bin/texinfo/makeinfo/multi.c @@ -1,7 +1,7 @@ -/* multi.c -- Multitable stuff for makeinfo. - $Id: multi.c,v 1.1 1996/12/15 21:39:29 downsj Exp $ +/* multi.c -- multitable stuff for makeinfo. + $Id: multi.c,v 1.2 1999/01/11 16:38:13 espie Exp $ - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 97 Free Software Foundation, Inc. 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 @@ -17,10 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stdio.h> +#include "system.h" #include "makeinfo.h" -#define MAXCOLS 100 /* remove this limit later @@ */ +#define MAXCOLS 100 /* remove this limit later @@ */ /* @@ -38,7 +38,7 @@ * `select_output_environment' function switches from one output * environment to another. * - * Environment #0 (i.e. element #0 of the table) is the regular + * Environment #0 (i.e., element #0 of the table) is the regular * environment that is used when we're not formatting a multitable. * * Environment #N (where N = 1,2,3,...) is the env. for column #N of @@ -55,7 +55,7 @@ struct env int paragraph_is_open; int current_indent; int fill_column; -} envs[MAXCOLS]; /* the environment table */ +} envs[MAXCOLS]; /* the environment table */ /* index in environment table of currently selected environment */ static int current_env_no; @@ -67,6 +67,40 @@ static int last_column; to be drawn, separating rows and columns in the current multitable. */ static int hsep, vsep; +/* Output a row. Have to keep `output_position' up-to-date for each + character we output, or the tags table will be off, leading to + chopped-off output files and undefined nodes (because they're in the + wrong file, etc.). Perhaps it would be better to accumulate this + value somewhere and add it once at the end of the table, or return it + as the value, but this seems simplest. */ +static void +out_char (ch) + int ch; +{ + extern int output_position; + putc (ch, output_stream); + output_position++; +} + + +void +draw_horizontal_separator () +{ + int i, j, s; + + for (s = 0; s < envs[0].current_indent; s++) + out_char (' '); + if (vsep) + out_char ('+'); + for (i = 1; i <= last_column; i++) { + for (j = 0; j <= envs[i].fill_column; j++) + out_char ('-'); + if (vsep) + out_char ('+'); + } + out_char ('\n'); +} + void do_multitable () { @@ -116,7 +150,7 @@ setup_multitable_parameters () char *params = insertion_stack->item_function; int nchars; float columnfrac; - char command[200]; + char command[200]; /* naughty, should be no fixed limits */ int i = 1; /* We implement @hsep and @vsep even though TeX doesn't. @@ -129,22 +163,32 @@ setup_multitable_parameters () params++; if (*params == '@') { - sscanf (params, "%s%n", command, &nchars); + sscanf (params, "%200s", command); + nchars = strlen (command); params += nchars; if (strcmp (command, "@hsep") == 0) - hsep++; + hsep++; else if (strcmp (command, "@vsep") == 0) - vsep++; + vsep++; else if (strcmp (command, "@columnfractions") == 0) { - /* Clobber old environments and create new ones, - starting at #1. Environment #0 is the normal standard output, - so we don't mess with it. */ - for ( ; i <= MAXCOLS; i++) { - if (sscanf (params, "%f%n", &columnfrac, &nchars) < 1) - goto done; - params += nchars; - setup_output_environment (i, (int) (columnfrac * fill_column + .5)); - } + /* Clobber old environments and create new ones, starting at #1. + Environment #0 is the normal output, so don't mess with it. */ + for ( ; i <= MAXCOLS; i++) { + if (sscanf (params, "%f", &columnfrac) < 1) + goto done; + /* Unfortunately, can't use %n since some m68k-hp-bsd libc + doesn't support it. So skip whitespace (preceding the + number) and then non-whitespace (the number). */ + while (*params && (*params == ' ' || *params == '\t')) + params++; + /* Hmm, but what what @columnfractions 3foo. Well, I suppose + it's invalid input anyway. */ + while (*params && *params != ' ' && *params != '\t' + && *params != '\n' && *params != '@') + params++; + setup_output_environment (i, + (int) (columnfrac * (fill_column - current_indent) + .5)); + } } } else if (*params == '{') { @@ -154,18 +198,17 @@ setup_multitable_parameters () } /* This gives us two spaces between columns. Seems reasonable. Really should expand the text, though, so a template of - `@code{foo}' has a width of three, not ten. Also have to match - braces, then. */ + `@code{foo}' has a width of five, not ten. Also have to match + braces, then. How to take into account current_indent here? */ setup_output_environment (i++, params++ - start); } else { - warning ("ignoring stray text `%s' after @multitable", params); + warning (_("ignoring stray text `%s' after @multitable"), params); break; } } done: - flush_output (); inhibit_output_flushing (); @@ -227,12 +270,12 @@ select_output_environment (n) } /* advance to the next environment number */ -int +void nselect_next_environment () { if (current_env_no >= last_column) { - line_error ("Too many columns in multitable item (max %d)", last_column); - return 1; + line_error (_("Too many columns in multitable item (max %d)"), last_column); + return; } select_output_environment (current_env_no + 1); } @@ -240,12 +283,25 @@ nselect_next_environment () static void output_multitable_row (); +/* do anything needed at the beginning of processing a + multitable column. */ +void +init_column () +{ + /* don't indent 1st paragraph in the item */ + cm_noindent (); + + /* throw away possible whitespace after @item or @tab command */ + skip_whitespace (); +} + /* start a new item (row) of a multitable */ +int multitable_item () { if (!multitable_active) { /* impossible, I think. */ - error ("multitable item not in active multitable"); + error (_("multitable item not in active multitable")); exit (1); } if (current_env_no > 0) { @@ -254,7 +310,7 @@ multitable_item () /* start at column 1 */ select_output_environment (1); if (!output_paragraph) { - line_error ("Cannot select column #%d in multitable", current_env_no); + line_error (_("Cannot select column #%d in multitable"), current_env_no); exit (FATAL); } @@ -263,38 +319,10 @@ multitable_item () return 0; } -/* do anything needed at the beginning of processing a - multitable column. */ -init_column () -{ - /* don't indent 1st paragraph in the item */ - cm_noindent (); - - /* throw away possible whitespace after @item or @tab command */ - skip_whitespace (); -} - -/* Output a row. Have to keep `output_position' up-to-date for each - character we output, or the tags table will be off, leading to - chopped-off output files and undefined nodes (because they're in the - wrong file, etc.). Perhaps it would be better to accumulate this - value somewhere and add it once at the end of the table, or return it - as the value, but this seems simplest. */ - -static void -out_char (ch) - int ch; -{ - extern int output_position; - putc (ch, output_stream); - output_position++; -} - - static void output_multitable_row () { - int i, j, remaining; + int i, j, s, remaining; /* offset in the output paragraph of the next char needing to be output for that column. */ @@ -325,29 +353,34 @@ output_multitable_row () /* first, see if there is any work to do */ for (i = 1; i <= last_column; i++) { if (CHAR_ADDR (0) < envs[i].output_paragraph_offset) { - remaining = 1; - break; + remaining = 1; + break; } } if (!remaining) break; - + + for (s = 0; s < envs[0].current_indent; s++) + out_char (' '); + if (vsep) out_char ('|'); for (i = 1; i <= last_column; i++) { + for (s = 0; i < envs[i].current_indent; s++) + out_char (' '); for (j = 0; CHAR_ADDR (j) < envs[i].output_paragraph_offset; j++) { - if (CHAR_AT (j) == '\n') - break; - out_char (CHAR_AT (j)); + if (CHAR_AT (j) == '\n') + break; + out_char (CHAR_AT (j)); } - offset[i] += j + 1; /* skip last text plus skip the newline */ + offset[i] += j + 1; /* skip last text plus skip the newline */ for (; j <= envs[i].fill_column; j++) - out_char (' '); + out_char (' '); if (vsep) - out_char ('|'); /* draw column separator */ + out_char ('|'); /* draw column separator */ } - out_char ('\n'); /* end of line */ + out_char ('\n'); /* end of line */ } if (hsep) @@ -363,27 +396,12 @@ output_multitable_row () #undef CHAR_AT #undef CHAR_ADDR -int -draw_horizontal_separator () -{ - int i, j; - if (vsep) - out_char ('+'); - for (i = 1; i <= last_column; i++) { - for (j = 0; j <= envs[i].fill_column; j++) - out_char ('-'); - if (vsep) - out_char ('+'); - } - out_char ('\n'); -} - /* select a new column in current row of multitable */ void cm_tab () { if (!multitable_active) - error ("ignoring @tab outside of multitable"); + error (_("ignoring @tab outside of multitable")); nselect_next_environment (); init_column (); @@ -394,8 +412,6 @@ cm_tab () void end_multitable () { - int i; - output_multitable_row (); /* Multitables cannot be nested. Otherwise, we'd have to save the @@ -409,10 +425,10 @@ end_multitable () uninhibit_output_flushing (); #if 0 - printf ("** Multicolumn output from last row:\n"); + printf (_("** Multicolumn output from last row:\n")); for (i = 1; i <= last_column; i++) { select_output_environment (i); - printf ("* column #%d: output = %s\n", i, output_paragraph); + printf (_("* column #%d: output = %s\n"), i, output_paragraph); } #endif } |