From 85c47cd98ceaf5797e501f54f7757cefe35ba0d3 Mon Sep 17 00:00:00 2001 From: wl Date: Sat, 31 Dec 2005 08:26:57 +0000 Subject: Integrate preconv into the groff binary. Changes based on a patch from Michail Vidiassov. * src/roff/groff/pipeline.h (MAX_COMMANDS): Increase by 1. * src/roff/groff/groff.cpp (PRECONV_INDEX): New macro. (SOELIM_INDEX): Updated. (help, synopsis): Updated. (main): Add command line options `-k' and `-K enc' to select encoding. Add support for GROFF_ENCODING environment variable. * src/roff/groff/groff.man: Updated and revised. Start with autoconf support for preconv. * configure.ac: Call AC_C_BIGENDIAN. * configure, src/include/config.hin: Regenerated. --- src/roff/groff/groff.cpp | 54 ++++++++++----- src/roff/groff/groff.man | 171 +++++++++++++++++++++++++++++++++++++--------- src/roff/groff/pipeline.h | 4 +- 3 files changed, 177 insertions(+), 52 deletions(-) (limited to 'src/roff/groff') diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp index 5e187573..d8cbea1c 100644 --- a/src/roff/groff/groff.cpp +++ b/src/roff/groff/groff.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989-2000, 2001, 2002, 2003, 2004 +/* Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -51,7 +51,8 @@ extern "C" { #endif /* NEED_DECLARATION_PUTENV */ // The number of commands must be in sync with MAX_COMMANDS in pipeline.h -const int SOELIM_INDEX = 0; +const int PRECONV_INDEX = 0; +const int SOELIM_INDEX = PRECONV_INDEX + 1; const int REFER_INDEX = SOELIM_INDEX + 1; const int GRAP_INDEX = REFER_INDEX + 1; const int PIC_INDEX = GRAP_INDEX + 1; @@ -110,6 +111,7 @@ int main(int argc, char **argv) setbuf(stderr, stderr_buf); assert(NCOMMANDS <= MAX_COMMANDS); string Pargs, Largs, Fargs; + int Kflag = 0; int vflag = 0; int Vflag = 0; int zflag = 0; @@ -119,6 +121,7 @@ int main(int argc, char **argv) int safer_flag = 1; int opt; const char *command_prefix = getenv("GROFF_COMMAND_PREFIX"); + const char *encoding = getenv("GROFF_ENCODING"); if (!command_prefix) command_prefix = PROG_PREFIX; commands[TROFF_INDEX].set_name(command_prefix, "troff"); @@ -127,9 +130,10 @@ int main(int argc, char **argv) { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; - while ((opt = getopt_long(argc, argv, - "abcCd:eEf:F:gGhiI:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ", - long_options, NULL)) + while ((opt = getopt_long( + argc, argv, + "abcCd:eEf:F:gGhiI:lkK:L:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ", + long_options, NULL)) != EOF) { char buf[3]; buf[0] = '-'; @@ -149,6 +153,13 @@ int main(int argc, char **argv) Pargs += optarg; Pargs += '\0'; break; + case 'K': + commands[PRECONV_INDEX].append_arg("-e", optarg); + Kflag = 1; + // fall through + case 'k': + commands[PRECONV_INDEX].set_name(command_prefix, "preconv"); + break; case 't': commands[TBL_INDEX].set_name(command_prefix, "tbl"); break; @@ -185,16 +196,15 @@ int main(int argc, char **argv) break; case 'v': vflag = 1; - { - printf("GNU groff version %s\n", Version_string); - printf("Copyright (C) 2004 Free Software Foundation, Inc.\n" - "GNU groff comes with ABSOLUTELY NO WARRANTY.\n" - "You may redistribute copies of groff and its subprograms\n" - "under the terms of the GNU General Public License.\n" - "For more information about these matters, see the file named COPYING.\n"); - printf("\ncalled subprograms:\n\n"); - fflush(stdout); - } + printf("GNU groff version %s\n", Version_string); + printf( + "Copyright (C) 2005 Free Software Foundation, Inc.\n" + "GNU groff comes with ABSOLUTELY NO WARRANTY.\n" + "You may redistribute copies of groff and its subprograms\n" + "under the terms of the GNU General Public License.\n" + "For more information about these matters, see the file named COPYING.\n"); + printf("\ncalled subprograms:\n\n"); + fflush(stdout); commands[POST_INDEX].append_arg(buf); // fall through case 'C': @@ -284,6 +294,11 @@ int main(int argc, char **argv) break; } } + if (encoding) { + commands[PRECONV_INDEX].set_name(command_prefix, "preconv"); + if (!Kflag && *encoding) + commands[PRECONV_INDEX].append_arg("-e", encoding); + } if (safer_flag) commands[PIC_INDEX].append_arg("-S"); else @@ -309,7 +324,8 @@ int main(int argc, char **argv) } if (postdriver) commands[POST_INDEX].set_name(postdriver); - int gxditview_flag = postdriver && strcmp(xbasename(postdriver), GXDITVIEW) == 0; + int gxditview_flag = postdriver + && strcmp(xbasename(postdriver), GXDITVIEW) == 0; if (gxditview_flag && argc - optind == 1) { commands[POST_INDEX].append_arg("-title"); commands[POST_INDEX].append_arg(argv[optind]); @@ -690,9 +706,9 @@ char **possible_command::get_argv() void synopsis(FILE *stream) { fprintf(stream, -"usage: %s [-abceghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]\n" +"usage: %s [-abceghiklpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]\n" " [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]\n" -" [-Larg] [-Idir] [files...]\n", +" [-Karg] [-Larg] [-Idir] [files...]\n", program_name); } @@ -701,6 +717,7 @@ void help() synopsis(stdout); fputs("\n" "-h\tprint this message\n" +"-k\tpreprocess with preconv\n" "-t\tpreprocess with tbl\n" "-p\tpreprocess with pic\n" "-e\tpreprocess with eqn\n" @@ -737,6 +754,7 @@ void help() "-S\tenable safer mode (the default)\n" "-U\tenable unsafe mode\n" "-Idir\tsearch dir for soelim, troff, and grops. Implies -s\n" +"-Karg\tuse arg as input encoding. Implies -k\n" "\n", stdout); exit(0); diff --git a/src/roff/groff/groff.man b/src/roff/groff/groff.man index 9e6a4ace..714e8670 100644 --- a/src/roff/groff/groff.man +++ b/src/roff/groff/groff.man @@ -1,7 +1,7 @@ .ig groff.man -Last update: 01 Jul 2005 +Last update: 30 Dec 2005 Copyright (C) 1989, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Rewritten in 2002 by Bernd Warken @@ -52,15 +52,15 @@ FDL in the main directory of the groff source package. .\" -------------------------------------------------------------------- .\" Begin of macro definitions .de c -.\" this is like a comment request when escape mechanism is off +. \" this is like a comment request when escape mechanism is off .. .eo . .c -------------------------------------------------------------------- .de TP+ -.br -.ns -.TP \$1 +. br +. ns +. TP \$1 .. .c -------------------------------------------------------------------- .c Like TP, but if specified indent is more than half @@ -241,11 +241,12 @@ groff \- front-end for the groff document formatting system . .ad l .Synopsis groff -.ShortOpt[] abcegilpstzCEGNRSUVXZ +.ShortOpt[] abcegiklpstzCEGNRSUVXZ .ShortOpt[] d cs .ShortOpt[] f fam .ShortOpt[] F dir .ShortOpt[] I dir +.ShortOpt[] K arg .ShortOpt[] L arg .ShortOpt[] m name .ShortOpt[] M dir @@ -388,13 +389,35 @@ and escapes). The current directory is always searched first. This option may be specified more than once; -the directories will be searched in the order specified. +the directories are searched in the order specified. No directory search is performed for files specified using an absolute path. This option implies the .ShortOpt s option. . . +.OptDef k +Preprocess with +.BR preconv . +This is run before any other preprocessor. +. +Please refer to +.BR preconv 's +manual page for its behaviour if no +.ShortOpt K +option is specified. +. +. +.OptDef K "" arg +Set input encoding used by +.B preconv +to +.IR arg . +. +Implies +.ShortOpt k . +. +. .OptDef l Send the output to a spooler program for printing. . @@ -627,7 +650,7 @@ Output the pipeline that would be run by .BR groff (as a wrapper program) on the standard output, but do not execute it. If given more than once, -the commands will be both printed on the standard error and run. +the commands are both printed on the standard error and run. . . .OptDef X @@ -674,7 +697,7 @@ for example .OptDef z Suppress output generated by .BR @g@troff . -Only error messages will be printed. +Only error messages are printed. . . .OptDef Z @@ -873,35 +896,47 @@ program is an allround-viewer for groff files and man pages. The groff preprocessors are reimplementations of the classical preprocessors with moderate extensions. . -The preprocessors distributed with the +The standard preprocessors distributed with the .I groff package are . .TP .BR @g@eqn (@MAN1EXT@) for mathematical formul\(ae, +. .TP .BR @g@grn (@MAN1EXT@) for including .BR gremlin (1) pictures, +. .TP .BR @g@pic (@MAN1EXT@) for drawing diagrams, +. .TP .BR \%@g@refer (@MAN1EXT@) for bibliographic references, +. .TP .BR \%@g@soelim (@MAN1EXT@) for including macro files from standard locations, . .P and +. .TP .BR @g@tbl (@MAN1EXT@) for tables. . .P +A new preprocessor not available in classical troff is +.BR \%preconv (@MAN1EXT@) +which converts various input encodings to something groff can understand. +. +It is always run first before any other preprocessor. +. +.P Besides these, there are some internal preprocessors that are automatically run with some devices. . @@ -1062,7 +1097,7 @@ see . In roff, the output targets are called .IR devices . -A device can be a piece of hardware, e.g. a printer, or a software +A device can be a piece of hardware, e.g., a printer, or a software file format. . A device is specified by the option @@ -1077,7 +1112,7 @@ character set. . .TP .B cp1047 -Text output using the EBCDIC code page IBM cp1047 (e.g. OS/390 Unix). +Text output using the EBCDIC code page IBM cp1047 (e.g., OS/390 Unix). . .TP .B dvi @@ -1117,6 +1152,7 @@ encoding; see .BR \%xditview (1x) and .BR \%gxditview (@MAN1EXT@). +. A variant for a 12\|pt document base font is .BR \%X75-12 . . @@ -1126,6 +1162,7 @@ A variant for a 12\|pt document base font is .BR \%xditview (1x) and .BR \%gxditview (@MAN1EXT@). +. A variant for a 12\|pt document base font is .BR \%X100-12 . . @@ -1153,12 +1190,14 @@ groff provides 3\~hardware postprocessors: .TP .BR \%grolbp (@MAN1EXT@) for some Canon printers, +. .TP .BR \%grolj4 (@MAN1EXT@) for printers compatible to the HP LaserJet\~4 and PCL5, +. .TP .BR \%grotty (@MAN1EXT@) -for text output using various encodings, e.g. on text-oriented +for text output using various encodings, e.g., on text-oriented terminals or line-printers. . .P @@ -1176,9 +1215,11 @@ formats are .TP .BR \%grodvi (@MAN1EXT@) for the DVI format, +. .TP .BR \%grohtml (@MAN1EXT@) for HTML format, +. .TP .BR grops (@MAN1EXT@) for PostScript. @@ -1204,6 +1245,22 @@ Add information to troff font description files for use with groff. Create font description files for PostScript device. . .TP +.BR \%eqn2graph (@MAN1EXT@) +Convert an +.B eqn +image into a cropped image. +. +.TP +.BR \%gdiffmk (@MAN1EXT@) +Mark differences between groff, nroff, or troff files. +. +.TP +.BR \%grap2graph (@MAN1EXT@) +Convert a +.B grap +diagram into a cropped bitmap image. +. +.TP .BR \%groffer (@MAN1EXT@) General viewer program for groff files and man pages. . @@ -1216,7 +1273,7 @@ The groff X viewer, the GNU version of xditview. Create font description files for lj4 device. . .TP -.BR \%indxbib (@MAN1EXT@) +.BR \%@g@indxbib (@MAN1EXT@) Make inverted index for bibliographic databases. . .TP @@ -1224,14 +1281,25 @@ Make inverted index for bibliographic databases. Search bibliographic databases. . .TP -.BR \%lookbib (@MAN1EXT@) +.BR \%@g@lookbib (@MAN1EXT@) Interactively search bibliographic databases. . .TP +.BR \%pdfroff (@MAN1EXT@) +Create PDF documents using +.BR groff . +. +.TP .BR \%pfbtops (@MAN1EXT@) Translate a PostScript font in .pfb format to ASCII. . .TP +.BR \%pic2graph (@MAN1EXT@) +Convert a +.B pic +diagram into a cropped image. +. +.TP .BR \%tfmtodit (@MAN1EXT@) Create font description files for TeX DVI device. . @@ -1239,6 +1307,10 @@ Create font description files for TeX DVI device. .BR \%xditview (1x) roff viewer distributed with X window. . +.TP +.BR \%xtotroff (@MAN1EXT@) +Convert X font metrics into GNU troff font metrics. +. . .\" -------------------------------------------------------------------- .SH ENVIRONMENT @@ -1249,17 +1321,19 @@ colon; this may vary depending on the operating system. . For example, DOS and Windows use a semicolon instead. . +. .TP .EnvVar GROFF_BIN_PATH This search path, followed by .EnvVar $PATH , -will be used for commands that are executed by +is used for commands that are executed by .BR groff . . If it is not set then the directory where the groff binaries were installed is prepended to .EnvVar PATH . . +. .TP .EnvVar GROFF_COMMAND_PREFIX When there is a need to run different roff implementations at the same @@ -1292,7 +1366,7 @@ More exactly, if it is set to prefix .I xxx then .B groff -as a wrapper program will internally call +as a wrapper program internally calls .IB xxx troff instead of .BR troff . @@ -1315,6 +1389,37 @@ itself) since they are unique to the groff package. . . .TP +.EnvVar GROFF_ENCODING +The value of this environment value is passed to the +.B preconv +preprocessor to select the encoding of input files. +. +Setting this option implies +.BR groff 's +command line option +.ShortOpt k +(this is, +.B groff +actually always calls +.BR preconv ). +. +If set without a value, +.B groff +calls +.B preconv +without arguments. +. +An explicit +.ShortOpt K +command line option overrides the value of +.EnvVar GROFF_ENCODING . +. +See +.BR preconv (@MAN1EXT@) +for details. +. +. +.TP .EnvVar GROFF_FONT_PATH A list of directories in which to search for the .BI dev name @@ -1341,11 +1446,11 @@ for more details. . .TP .EnvVar GROFF_TMPDIR -The directory in which temporary files will be created. +The directory in which temporary files are created. . If this is not set but the environment variable .EnvVar TMPDIR -instead, temporary files will be created in the directory +instead, temporary files are created in the directory .EnvVar $TMPDIR . On MS-DOS and Windows\ 32 platforms, the environment variables .EnvVar TMP @@ -1356,7 +1461,7 @@ and and .EnvVar TMPDIR . . -Otherwise, temporary files will be created in +Otherwise, temporary files are created in .BR /tmp . The .BR \%@g@refer (@MAN1EXT@), @@ -1422,8 +1527,9 @@ before reading the macro sets and any input. . .TP .B troffrc-end -Final startup file for troff, it is parsed after all macro sets have -been read. +Final startup file for troff. +. +It is parsed after all macro sets have been read. . . .TP @@ -1517,7 +1623,7 @@ calling .\" -------------------------------------------------------------------- . .P -On EBCDIC hosts (e.g. OS/390 Unix), output devices +On EBCDIC hosts (e.g., OS/390 Unix), output devices .B ascii and .B latin1 @@ -1530,7 +1636,7 @@ is not available on ASCII based operating systems. .P Report bugs to bug-groff@gnu.org. . -Include a complete, self-contained example that will allow the bug to +Include a complete, self-contained example that allows the bug to be reproduced, and say which version of groff you are using. . . @@ -1621,10 +1727,8 @@ Free Documentation License (FDL). . The .IR "groff info file" -contains all information on the groff system within a single document. -. -Beneath the detailed documentation of all aspects, it provides -examples and background information. +contains all information on the groff system within a single document, +providing many examples and background information. . See .BR info (1) @@ -1658,6 +1762,7 @@ Roff preprocessors: .BR \%@g@eqn (@MAN1EXT@), .BR \%@g@grn (@MAN1EXT@), .BR \%@g@pic (@MAN1EXT@), +.BR \%preconv (@MAN1EXT@), .BR \%@g@refer (@MAN1EXT@), .BR \%@g@soelim (@MAN1EXT@), .BR \%@g@tbl (@MAN1EXT@), @@ -1677,9 +1782,7 @@ Roff formatter programs: .BR ditroff (@MAN7EXT@). . .TP -The -.I intermediate output -language: +The intermediate output language: .BR \%groff_out (@MAN7EXT@). . .TP @@ -1711,15 +1814,19 @@ The following utilities are available: .BR \%addftinfo (@MAN1EXT@), .BR \%afmtodit (@MAN1EXT@), .BR \%eqn2graph (@MAN1EXT@), +.BR \%gdiffmk (@MAN1EXT@), .BR \%grap2graph (@MAN1EXT@), .BR \%groffer (@MAN1EXT@), .BR \%gxditview (@MAN1EXT@), .BR \%hpftodit (@MAN1EXT@), .BR \%@g@indxbib (@MAN1EXT@), +.BR \%lkbib (@MAN1EXT@), .BR \%@g@lookbib (@MAN1EXT@), +.BR \%pdfroff (@MAN1EXT@), .BR \%pfbtops (@MAN1EXT@), .BR \%pic2graph (@MAN1EXT@), -.BR \%tfmtodit (@MAN1EXT@). +.BR \%tfmtodit (@MAN1EXT@), +.BR \%xtotroff (@MAN1EXT@). . .cp \n[groff_C] . diff --git a/src/roff/groff/pipeline.h b/src/roff/groff/pipeline.h index 77bb11a0..81bb0af6 100644 --- a/src/roff/groff/pipeline.h +++ b/src/roff/groff/pipeline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2005 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -25,7 +25,7 @@ extern "C" { #endif /* run_pipeline can handle at most this many commands */ -#define MAX_COMMANDS 12 +#define MAX_COMMANDS 13 /* Children exit with this status if execvp fails. */ #define EXEC_FAILED_EXIT_STATUS 0xff -- cgit v1.2.1