diff options
author | bwarken <bwarken> | 2006-09-11 16:06:18 +0000 |
---|---|---|
committer | bwarken <bwarken> | 2006-09-11 16:06:18 +0000 |
commit | 082a9c5a62952aed15db21709a5cd9b3a31de617 (patch) | |
tree | e1b443016c12decf11d6be25b6982aa368b7707b /contrib | |
parent | 94978e3def72718458b21ba9be9fd7f240545575 (diff) | |
download | groff-082a9c5a62952aed15db21709a5cd9b3a31de617.tar.gz |
Update groffer 0.9.25
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/groffer/ChangeLog | 164 | ||||
-rw-r--r-- | contrib/groffer/README | 8 | ||||
-rw-r--r-- | contrib/groffer/groffer.man | 225 | ||||
-rw-r--r-- | contrib/groffer/groffer.sh | 14 | ||||
-rw-r--r-- | contrib/groffer/groffer2.sh | 1275 | ||||
-rw-r--r-- | contrib/groffer/version.sh | 7 |
6 files changed, 1261 insertions, 432 deletions
diff --git a/contrib/groffer/ChangeLog b/contrib/groffer/ChangeLog index 8aeb7d21..6704b590 100644 --- a/contrib/groffer/ChangeLog +++ b/contrib/groffer/ChangeLog @@ -1,7 +1,145 @@ +2006-11-08 Bernd Warken ________________________________________________________________ - * release of groffer 0.9.24 + * release of groffer 0.9.25 + + ### Version information + + * groffer2.sh: + - version(): Add groffer to the version information; replace the + call of `groff --version'. + + ### Configuration Files + + * groffer.sh: Fix the configuration handling by removing all + quotes. Arguments are ended by the end of the line. + + * groffer.man: Fix the section on the configuration files. + + ### Options + + * groffer2.sh: + - $_OPTS_GROFF_SHORT_NA: Add `-k' as new groff option. + - main_pars_args(): Add X options `--ft', `--bordercolor', + `--borderwidth'. + - usage(): Add `--debug-filenames'. Remove `*-viewer-tty'. + Correct first line after call of version(). + - main_parse_MANOPT(): Fix `-h', `-t', and `-u' as options without + argument. + + * groffer.man: + - Add documentation to `--fn', `--ft', `--bordercolor', + `--borderwidth'. + - Remove the `--*-viewer-tty' options. These options are still + supported by the groffer program, but they aren't needed any + more. + + ### soelim: Allow manpath and compressed files in .so requests, as + ### man does. + + * groffer2.sh: + - $_FILESPEC_IS_MAN: New variable for storing if a filespec is for + searching a man page. + - to_tmp(): Rewrite. For existing file as filespec argument, add + call of `soelim' with the corresponding `-I dir' before the call + of `grog'. For man paged, uncompress and store the files from .so + requests; replace the requests with the stored file names. + - _do_man_so() of to_tmp(): New function to handle the file of a + .so request. + - man_get(): For man pages without extension, add special search + strategy. + + * README: Add the .so handling to the Compatiblity section. + + ### Print file names debug + + * groffer2.sh: + - $_OPT_LOCATION: Replace this variable by + $_DEBUG_PRINT_FILENAMES. + - register_file(): Move file name printing and call to basename to + register_title(). + - _do_man_so() of to_tmp(): Add file name printing for man pages. + + ### modes + + * groffer2.sh: + - $_DEFAULT_MODES: New set of default modes in the sequence 'pdf', + 'html', 'ps', 'x', 'dvi', and 'tty'. That is done because the `x' + mode viewers `gxditview' and `xditview' are very bad programs. + - _make_pdf() of main_display(): If pdf format can not be + generated use Postscript mode (ps) instead for display. + - $_PDF_DID_NOT_WORK, $_PDF_HAS_PS2PDF, $_PDF_HAS_GS: New + variables for pdf mode to avoid several runs. + - $_VIEWER_TTY_TTY, $_VIEWER_TTY_X: Add these variables for the + viewers in tty mode. + - main_display(): Rewrite tty mode by using where_is_prog() to add + options to `less' from the command line. + + * groffer.man: + - Add this information. + - Adjust the viewers in `SEE ALSO'. + + ### Check viewer option for programs running in X Window + + * groffer2.sh: + - _check_X_prog() of main_set_mode(): New function for checking if + a program of a command line argument is in the list for X for this + mode. + - _get_first_prog() of main_set_mode(): Use where_is_prog(); + change the output to the same 3-element list as _check_X_prog(). + - _obj_set_vars() of main_set_mode(): New function for setting + some variables in several modes. Argument is the 3-element list + from _check_X_prog() or _get_first_prog(). + - _process_mode() of main_set_mode(): Remove part with + list_has_not_prog(). This is better done by _check_X_prog(). + - main_set_mode(): Use _check_X_prog() in different modes. + Correct several modes. Add reset of $_VIEWER_BACKGROUND at the + beginning of the loop of default modes. + + ### Allow man pages with space characters + + * groffer2.sh: + - man_is_man(): Fix grep calls. + - list_from_file(): New function that reads the lines of a file as + list elements. + - man_get(): Fix `case' applications by double-quoting all + variables. Use list_from_file() instead of setting with `cat'. + Add further tests. + - _do_man_so() of to_tmp(): Use list_from_file() instead of + setting with `cat'. + + ### Allow program names with space + + * groffer2.sh: + - is_prog(), is_not_program(): Change to exactly one argument with + possible spaces and arguments. Fix all calls. + - where_is_prog(): Change to exactly one argument. Change + variable prefix to `wip'. Rewrite it to support programs with + spaces and arguments. Return a list with 3 elements: the + program's directory, the program name, and the given arguments. + - main_display(): Correct tty mode. + + ### Further fixes + + * groffer2.sh: + - main_setup(): Fix func_check. + - clean_up(): Add variable to avoid several prints. + - where_is_prog(): Remove possible arguments from program + argument. + - obj_from_output(): As return value take the return value of the + called function. + - is_not_empty(): Rename of is_non_emtpy(). + - $_VIEWER_BACKGROUND: Rename $_VIEWER_TERMINAL and reverse its + values. + - list_has_prog(), list_has_not_prog(): Remove these functions, + they are no longer needed. + + * groffer.man: + - Add `--print' in OPTION OVERVIEW. + - Correct many entries with the non-breaking `\%' construct. 2006-07-28 Bernd Warken + ________________________________________________________________ + * release of groffer 0.9.24 ### Extent long option abbreviation to abbreviations before each `-'. @@ -141,11 +279,10 @@ * Makefile.sub: Add DESTDIR to install and uninstall targets to support staged installations. +2005-09-14 Bernd Warken ________________________________________________________________ * release of groffer 0.9.23 -2005-09-14 Bernd Warken - ### Increase the speed for the search of man pages Run `find' on all man directories and ask this with `grep' instead @@ -267,11 +404,10 @@ - Fix section `Error handling'. - Add section `Speed'. +2005-08-22 Bernd Warken ________________________________________________________________ * release of groffer 0.9.22 -2005-08-22 Bernd Warken - ### `--whatis' Produce a `groff' output and allow wild cards on filespec @@ -509,11 +645,10 @@ as $(srcdir)/groffer2.sh, so it will install when building in a different directory from the source. +2005-08-02 Bernd Warken ________________________________________________________________ * release of groffer 0.9.21 -2005-08-02 Bernd Warken - ### @...@ constructs * groffer.sh: @@ -691,11 +826,10 @@ * ChangeLog: Remove final spaces. +2005-07-30 Bernd Warken ________________________________________________________________ * release of groffer 0.9.20 -2005-07-30 Bernd Warken - ### Split groffer.sh into two files groffer.sh and groffer2.sh. * groffer.sh: @@ -722,11 +856,10 @@ - Documentation of the splitting of the script. - Document the possible abbreviation of options. +2005-07-07 Bernd Warken ________________________________________________________________ * release of groffer 0.9.19 -2005-07-07 Bernd Warken - * groffer.sh: extensions - `mode x': Mode for the equivalent options `--x', `--mode x', `--X' `--mode X', and the default mode. The default assumes a @@ -774,11 +907,10 @@ - Add information on the default devices in `x mode'. - Minor corrections. +2005-07-01 Bernd Warken ________________________________________________________________ * release of groffer 0.9.18 -2005-07-01 Bernd Warken - * groffer.sh: further shell compatibility - `echo': Remove options and possible options of `echo' by preceding the argument with a character `x' that is removed by @@ -837,11 +969,10 @@ * Makefile.sub: Readd `@g@'. +2005-06-23 Bernd Warken ________________________________________________________________ * release of groffer 0.9.17 -2005-06-23 Bernd Warken - * groffer.sh: get rid of `local' in functions (it is not POSIX) - Replace local variables by variable names with a special prefix that is an abbreviation of the corresponding function name (quasi- @@ -873,11 +1004,10 @@ * README-SH: Information of `Portable shells' in info autoconf. +2005-06-19 Bernd Warken ________________________________________________________________ * release of groffer 0.9.16 -2005-06-19 Bernd Warken - * groffer.sh: Place each `then', `else', and `do' on a line of its own because some shells do not support the mixture mode. diff --git a/contrib/groffer/README b/contrib/groffer/README index 09085a59..f00a41a2 100644 --- a/contrib/groffer/README +++ b/contrib/groffer/README @@ -71,6 +71,10 @@ Compatibility or Bourne style shell that supports shell functions. See file `README_SH' for more information. +`groffer' is compatible with the `man' program. It supports .so +requests based on the man path and compressed files. That's more than +`groff' does. + Mailing lists @@ -87,10 +91,10 @@ package for more details on these mailing lists. ####### License -Last update: 28 Jul 2006 +Last update: 04 Sep 2006 Copyright (C) 2003,2004,2005,2006 Free Software Foundation, Inc. -Written by Bernd Warken +Written by Bernd Warken. This file is part of `groffer', which is part of `groff'. diff --git a/contrib/groffer/groffer.man b/contrib/groffer/groffer.man index 9d52e6c3..0454bf47 100644 --- a/contrib/groffer/groffer.man +++ b/contrib/groffer/groffer.man @@ -15,7 +15,7 @@ groffer.1 - man page for groffer (section 1). Source file position: <groff_source_top>/contrib/groffer/groffer.man Installed position: $prefix/share/man/man1/groffer.1 -Last update: 28 Jul 2006 +Last update: 05 Sep 2006 Source file position: <groff-source>/contrib/groffer/groffer.man .. @@ -727,7 +727,7 @@ behaviors. . This can be done either in configuration files, with the shell environment variable -.BR \%$GROFFER_OPT , +.Env_var \%$GROFFER_OPT , or on the command line. . . @@ -877,12 +877,12 @@ are accepted as well. .I X Window Toolkit options .RS .P -.Opt_[alt] -- bd pixels +.Opt_[alt] -- bd -- bordercolor pixels .Opt_[alt] -- bg -- background color -.Opt_[alt] -- bw pixels +.Opt_[alt] -- bw -- borderwidth pixels .Opt_[alt] -- display X-display .Opt_[alt] -- fg -- foreground color -.Opt_[alt] -- ft -- font font_name +.Opt_[alt] -- fn -- ft -- font font_name .Opt_[alt] -- geometry size_pos .Opt_[alt] -- resolution value .Opt_[alt] -- rv @@ -907,6 +907,7 @@ are accepted as well. .Opt_[alt] -- debug\-tmpdir .Opt_[alt] -- debug\-user .Opt_[alt] -- do\-nothing +.Opt_[alt] -- print text .Opt_[alt] -- shell prog .Opt_[alt] - Q -- source .Opt_[alt] - V @@ -1066,30 +1067,34 @@ If none of these mode and viewer options is specified tries to find a suitable display mode automatically. . The default modes are -.I mode x -with -.B gxditview -in \%\f[CR]X\~Window\f[] and +.IR "mode pdf" , +.IR "mode ps" , +.IR "mode html" , +.IR "mode x" , +and +.I "mode dvi" +in \%\f[CR]X\~Window\f[] with different viewers and .I mode tty with device .I latin1 under .B less -on a terminal; a series of other modes are tested if the programs for -the main default mode do not exist. +on a terminal; other modes are tested if the programs for the main +default mode do not exist. . . .P In \%\f[CR]X\~Window\f[], -.B groffer -can run the viewer as an independent program in the background. +many programs create their own window when called. +.B \%groffer +can run these viewers as an independent program in the background. . -As this does not work in text mode on a terminal there must be a +As this does not work in text mode on a terminal (tty) there must be a way to know which viewers are \%\f[CR]X\~Window\f[] graphical programs. . The -.B groffer +.B \%groffer script has a small set of information on some viewer names. . If a viewer argument of the command\-line chooses an element that is @@ -1109,9 +1114,9 @@ combination of the options .Opt_long mode=ps and .Opt_long ps\-viewer=less -show the content of the +shows the content of the .I Postscript -output with the pager +output, the source code, with the pager .BR less . . . @@ -1125,7 +1130,7 @@ Reset all configuration from previously processed command line options to the default values. . This is useful to wipe out all former options of the configuration, in -.Env_var $GROFFER_OPT , +.Env_var \%$GROFFER_OPT , and restart option processing using only the rest of the command line. . . @@ -1152,7 +1157,7 @@ Equivalent to . . .Opt_def -- dvi\-viewer prog -Choose an \%\f[CR]X\~Window\f[] viewer program for +Choose a viewer program for .IR \%dvi\~mode . . This can be a file name or a program to be searched in @@ -1179,8 +1184,8 @@ Equivalent to . . .Opt_def -- html\-viewer -Choose an \%\f[CR]X\~Window\f[] web browser program for viewing in -.I \%html\~mode . +Choose a web browser program for viewing in +.IR \%html\~mode . . It can be the path name of an executable file or a program in .Env_var $PATH . @@ -1260,29 +1265,25 @@ By default, the input is formatted by using the Postscript device, then it is transformed into the PDF file format using .BR \%gs (1), -and finally displayed either with the -BR \%acroread (1), -.BR \%xpdf (1), -or some other -.I \%pdf -viewer program. +or +.BR ps2pdf (1). +If that's not possible, the +.I Postscript mode (ps) +is used instead. +. +Finally it is displayed using different viewer programs. . .I \%pdf has a big advantage because the text is displayed graphically and is searchable as well. . -But as the transformation takes a considerable amount of time, this -mode is not suitable as a default device for the -.I \%auto\~mode . -. . .TP .Header_CB ps Display formatted input in a Postscript viewer program. . -By default, the formatted input is displayed with the -.BR \%ghostview (@MAN1EXT@) -program. +By default, the formatted input is displayed in one of many viewer +programs. . . .TP @@ -1398,7 +1399,7 @@ Equivalent to . . .Opt_def -- pdf\-viewer prog -Choose an \%\f[CR]X\~Window\f[] viewer program for +Choose a viewer program for .IR \%pdf\~mode . . This can be a file name or a program to be searched in @@ -1412,7 +1413,7 @@ Equivalent to . . .Opt_def -- ps\-viewer prog -Choose an \%\f[CR]X\~Window\f[] viewer program for +Choose a viewer program for .IR \%ps\~mode . . This can be a file name or a program to be searched in @@ -1467,7 +1468,7 @@ Equivalent to . . .Opt_def -- X\-viewer -- x\-viewer prog -Choose an \%\f[CR]X\~Window\f[] viewer program for +Choose a viewer program for .IR \%x\~mode . Suitable viewer programs are .BR \%gxditview (@MAN1EXT@) @@ -1851,7 +1852,7 @@ are documented. The full set of long and short options of the \f[CR]GNU\f[] .B man program can be passed via the environment variable -.Env_var $MANOPT ; +.Env_var \%$MANOPT ; see .BR \%man (1) if your system has \f[CR]GNU\f[] @@ -2001,7 +2002,8 @@ Set the background color of the viewer window. . . .Opt_def -- bd pixels -Specifies the color of the border surrounding the viewer window. +This is equivalent to +.Opt_long bordercolor . . . .Opt_def -- bg color @@ -2010,6 +2012,15 @@ This is equivalent to . . .Opt_def -- bw pixels +This is equivalent to +.Opt_long borderwidth . +. +. +.Opt_def -- bordercolor pixels +Specifies the color of the border surrounding the viewer window. +. +. +.Opt_def -- borderwidth pixels Specifies the width in pixels of the border surrounding the viewer window. . @@ -2029,6 +2040,11 @@ This is equivalent to .Opt_short foreground . . . +.Opt_def -- fn font_name +This is equivalent to +.Opt_long font . +. +. .Opt_def -- font font_name Set the font used by the viewer window. . @@ -2037,7 +2053,7 @@ The argument is an \%\f[CR]X\~Window\f[] font name. . .Opt_def -- ft font_name This is equivalent to -.Opt_long ft . +.Opt_long font . . . .Opt_def -- geometry size_pos @@ -2128,7 +2144,7 @@ by large amounts. . . .Opt_def -- debug\-keep -Enable two debugging information, the printing of the name of the +Enable two debugging informations, the printing of the name of the temporary directory and the keeping of the temporary files. . . @@ -2217,7 +2233,7 @@ the display program for viewing the output with its arguments, . .Topic the active parameters from the config files, the arguments in -.Env_var $GROFFER_OPT , +.Env_var \%$GROFFER_OPT , and the arguments of the command line, . .Topic @@ -2535,7 +2551,7 @@ environment (or similar implementations within other windowing environments). . The environment variable -.Env_var $DISPLAY +.Env_var \%$DISPLAY and the option .Opt_long display are used for specifying the \%\f[CR]X\~Window\f[] display to be used. @@ -2652,7 +2668,7 @@ The pager to be used can be specified by one of the options and .Opt_long tty\-viewer , or by the environment variable -.Env_var $PAGER . +.Env_var \%$PAGER . If all of this is not used the .BR \%less (1) program with the option @@ -2828,14 +2844,14 @@ This overwrites the other methods. . .Topic If this is not available the environment variable -.Env_var $MANPATH +.Env_var \%$MANPATH is searched. . . .Topic If this is empty, the program tries to read it from the environment variable -.Env_var $MANOPT . +.Env_var \%$MANOPT . . . .Topic @@ -2881,16 +2897,16 @@ that is from highest to lowest precedence: .Opt_long locale . .Topic -.Env_var $GROFFER_OPT +.Env_var \%$GROFFER_OPT . .Topic -.Env_var $MANOPT +.Env_var \%$MANOPT . .Topic .Env_var $LCALL . .Topic -.Env_var $LC_MESSAGES +.Env_var \%$LC_MESSAGES . .Topic .Env_var $LANG . @@ -2938,7 +2954,7 @@ Several operating systems can be given by appending their names, separated by a comma. . This is then specified by the environment variable -.Env_var $SYSTEM +.Env_var \%$SYSTEM or by the command line option .Opt_long systems . The precedence is similar to the locale case above from highest to @@ -2948,13 +2964,13 @@ Topic .Opt_long systems . .Topic -.Env_var $GROFFER_OPT +.Env_var \%$GROFFER_OPT . .Topic -.Env_var $MANOPT +.Env_var \%$MANOPT . .Topic -.Env_var $SYSTEM . +.Env_var \%$SYSTEM . . . .P @@ -2975,7 +2991,7 @@ argument, several sections as a colon-separated list in command line option .Opt_long sections or environment variable -.Env_var $MANSECT . +.Env_var \%$MANSECT . . When no section was specified a set of standard sections is searched until a suitable @@ -2991,7 +3007,7 @@ This is a postfix that acts like a subsection. It can be specified by .Opt_long extension or environment variable -.Env_var $EXTENSION . +.Env_var \%$EXTENSION . . . .P @@ -3046,7 +3062,7 @@ and some standard system variables are honored. .\" -------------------------------------------------------------------- . .TP -.Env_var $GROFFER_OPT +.Env_var \%$GROFFER_OPT Store options for a run of .BR \%groffer . . @@ -3079,7 +3095,7 @@ The following variables have a special meaning for . . .TP -.Env_var $DISPLAY +.Env_var \%$DISPLAY If this variable is set this indicates that the \%\f[CR]X\~Window\f[] system is running. . @@ -3098,9 +3114,9 @@ can be started on the second monitor by the command . . .TP -.Env_var $LC_ALL +.Env_var \%$LC_ALL .TP+ -.Env_var $LC_MESSAGES +.Env_var \%$LC_MESSAGES .TP+ .Env_var $LANG If one of these variables is set (in the above sequence), its content @@ -3137,7 +3153,7 @@ This is the same behavior as when all 3\~variables are unset. . . .TP -.Env_var $PAGER +.Env_var \%$PAGER This variable can be used to set the pager for the tty output. . For example, to disable the use of a pager completely set this @@ -3177,7 +3193,7 @@ The following variable has a direct meaning for the program. . .TP -.Env_var $GROFF_TMPDIR +.Env_var \%$GROFF_TMPDIR If the value of this variable is an existing, writable directory, .B \%groffer uses it for storing its temporary files, just as @@ -3204,12 +3220,12 @@ but the user interface is the same. The .B man environment variables can be overwritten by options provided with -.Env_var $MANOPT , +.Env_var \%$MANOPT , which in turn is overwritten by the command line. . . .TP -.Env_var $EXTENSION +.Env_var \%$EXTENSION Restrict the search for .I \%man\~pages to files having this extension. @@ -3220,7 +3236,7 @@ see there for details. . . .TP -.Env_var $MANOPT +.Env_var \%$MANOPT This variable contains options as a preset for .BR \%man (1). As not all of these are relevant for @@ -3236,7 +3252,7 @@ given on the command line. . . .TP -.Env_var $MANPATH +.Env_var \%$MANPATH If set, this variable contains the directories in which the .I \%man\~page trees are stored. @@ -3246,7 +3262,7 @@ This is overridden by option . . .TP -.Env_var $MANSECT +.Env_var \%$MANSECT If this is a colon separated list of section names, the search for .I \%man\~pages is restricted to those manual sections in that order. @@ -3256,7 +3272,7 @@ This is overridden by option . . .TP -.Env_var $SYSTEM +.Env_var \%$SYSTEM If this is set to a comma separated list of names these are interpreted as .I \%man\~page @@ -3269,7 +3285,7 @@ see there for details. . .P The environment variable -.Env_var $MANROFFSEQ +.Env_var \%$MANROFFSEQ is ignored by .B \%groffer because the necessary preprocessors are determined automatically. @@ -3285,17 +3301,17 @@ program can be preconfigured by two configuration files. . . .TP -.File_name /etc/groff/groffer.conf +.File_name \%/etc/groff/groffer.conf System-wide configuration file for .BR \%groffer . . . .TP -.File_name $HOME/.groff/groffer.conf +.File_name \%$HOME/.groff/groffer.conf User-specific configuration file for .BR \%groffer , where -.Env_var $HOME +.Env_var \%$HOME denotes the user's home directory. . This file is called after the system-wide configuration file to enable @@ -3303,15 +3319,14 @@ overriding by the user. . . .P -The precedence of option delivery is given in the following. -. -The configuration file in +Both files are handled for the configuration, but the configuration +file in .File_name /etc -has the lowest precedence; it is overwritten by the configuration file -in the home directory; both configuration files are overwritten by the -environment variable -.Env_var $GROFFER_OPT ; -everything is overwritten by the command line. +comes first; it is overwritten by the configuration file in the home +directory; both configuration files are overwritten by the environment +variable +.Env_var \%$GROFFER_OPT ; +everything is overwritten by the command line arguments. . . .P @@ -3333,28 +3348,30 @@ This easily allows to set general options that should be used with any call of .BR \%groffer . . -Each line can represent a single short option, a short option cluster, -or a long option with two minus signs, eventually with an argument. . -The argument can be appended either after a space character or an -equal sign -.RB ` = '. -The argument can be surrounded by quotes, but this is not necessary. +.P +If a lines starts with a double minus it represents a +.B \%groffer +long option; everything behind the first equal sign +.RB ` = ' +or space character up to the end of the line is interpreted as its +argument. . -The options from these lines are collected and prepended to the -existing value of -.Env_var $GROFFER_OPT -at the end of each configuration file. +A line starting with a single minus represents a short options cluster +with or without a final argument. +. +It is not necessary to use quotes in these lines; quotes are just +ignored. . . .P -After the transformation of the minus lines, the configuration files -have been transferred into a shell script that is called within -.B \%groffer -using the `\c -.CB \.\~\c -.IR \%filename ' -shell syntax. +The lines starting with a minus are changed into a prepend to the +existing value of +.Env_var \%$GROFFER_OPT . +. +So the configuration files will be transferred into a shell script +that is called within +.BR \%groffer . . . .P @@ -3392,7 +3409,7 @@ Some shells run much faster than the standard shell. . .P As an example, consider the following configuration file in -.File_name ~/.groff/groffer.conf , +.File_name \%~/.groff/groffer.conf , say. . .P @@ -3405,7 +3422,7 @@ say. \-\-shell=ksh \-\-foreground=DarkBlue \-\-resolution=100 -\-\-x\-viewer='gxditview \-geometry 900x1200' +\-\-x\-viewer=gxditview \-geometry 900x1200 # # some shell commands if test "$DISPLAY" = ""; then @@ -3473,7 +3490,7 @@ This geometry is suitable for a resolution of . .Topic If the environment variable -.Env_var $DISPLAY +.Env_var \%$DISPLAY is empty set it to .IR localhost:0.0 . . @@ -3954,7 +3971,9 @@ Viewers for . . .P +.BR \%kpdf (1), .BR \%kghostview (1), +.BR \%evince (1), .BR \%ggv (1), .BR \%gv (1), .BR \%ghostview (1), @@ -3967,12 +3986,13 @@ Viewers for . . .P +.BR \%kpdf (1), .BR \%acroread (1), +.BR \%evince (1), .BR \%xpdf (1), .BR \%gpdf (1), .BR \%kghostview (1), -.BR \%ggv (1), -.BR \%kpdf (1) +.BR \%ggv (1) .RS Viewers for .BR \%groffer 's @@ -3993,7 +4013,10 @@ Viewers for . .P .BR \%konqueror (1), +.BR \%epiphany (1), +.BR \%firefox (1), .BR \%mozilla (1), +.BR \%netscape (1), .BR \%lynx (1) .RS Web-browsers for diff --git a/contrib/groffer/groffer.sh b/contrib/groffer/groffer.sh index 47a6bdda..ad5ade05 100644 --- a/contrib/groffer/groffer.sh +++ b/contrib/groffer/groffer.sh @@ -3,12 +3,13 @@ # groffer - display groff files # Source file position: <groff-source>/contrib/groffer/groffer.sh +# Installed position: <prefix>/bin/groffer # Copyright (C) 2001,2002,2003,2004,2005,2006 # Free Software Foundation, Inc. # Written by Bernd Warken -# Last update: 28 Jul 2006 +# Last update: 14 Aug 2006 # This file is part of `groffer', which is part of `groff'. @@ -154,21 +155,22 @@ do # Delete leading and final space s/^['"${_SP}${_TAB}"']*// s/['"${_SP}${_TAB}"']*$// -# Print all shell commands +# Print all lines with shell commands, those not starting with - /^[^-]/p +# Remove all single and double quotes +s/['"${_SQ}"'"]//g # Replace empty arguments s/^\(-[^ ]*\)=$/o="${o} \1 '"${_SQ}${_SQ}"'"/p # Replace division between option and argument by single space s/[='"${_SP}${_TAB}"']['"${_SP}${_TAB}"']*/'"${_SP}"'/ # Handle lines without spaces s/^\(-[^'"${_SP}"']*\)$/o="${o} \1"/p -# Print options that have their argument encircled with single quotes -/^-[^ ]* '"${_SQ}"'.*'"${_SQ}"'$/s/^.*$/o="${o} &"/p -# Replace encircled double quotes by single quotes and print the result -s/^\(-[^ ]*\) "\(.*\)"$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p # Encircle the remaining arguments with single quotes s/^\(-[^ ]*\) \(.*\)$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p ')" + + # Remove leading space + o="$(echo "$o" | sed -e 's/^ *//')"; if test _"${o}"_ != __ then if test _"{GROFFER_OPT}"_ = __ diff --git a/contrib/groffer/groffer2.sh b/contrib/groffer/groffer2.sh index 9f88df49..bfccb193 100644 --- a/contrib/groffer/groffer2.sh +++ b/contrib/groffer/groffer2.sh @@ -12,7 +12,7 @@ # Free Software Foundation, Inc. # Written by Bernd Warken -# Last update: 28 Jul 2006 +# Last update: 11 Sep 2006 # This file is part of `groffer', which is part of `groff'. @@ -182,7 +182,7 @@ then else _DEBUG_FUNC_CHECK='no'; fi; -#_DEBUG_FUNC_CHECK='no'; # disable function checking +_DEBUG_FUNC_CHECK='no'; # disable function checking #_DEBUG_FUNC_CHECK='yes'; # enable function checking export _DEBUG_STACKS; @@ -408,7 +408,7 @@ return_var="func_pop; return"; # add number, e.g. `eval "${return_var} $n' export _DEFAULT_MODES; -_DEFAULT_MODES="'x' 'ps' 'tty'"; +_DEFAULT_MODES="'pdf' 'html' 'ps' 'x' 'dvi' 'tty'"; export _DEFAULT_RESOLUTION; _DEFAULT_RESOLUTION='75'; @@ -424,6 +424,8 @@ export _VIEWER_PDF_TTY; # viewer program for pdf mode in tty export _VIEWER_PDF_X; # viewer program for pdf mode in X export _VIEWER_PS_TTY; # viewer program for ps mode in tty export _VIEWER_PS_X; # viewer program for ps mode in X +export _VIEWER_TTY_TTY; # viewer program for X/x mode in tty +export _VIEWER_TTY_X; # viewer program for X/x mode in X export _VIEWER_X_TTY; # viewer program for X/x mode in tty export _VIEWER_X_X; # viewer program for X/x mode in X _VIEWER_DVI_TTY=""; @@ -437,6 +439,8 @@ _VIEWER_PDF_X="'kpdf' 'acroread' 'evince' 'xpdf -z 150' 'gpdf' \ _VIEWER_PS_TTY=""; _VIEWER_PS_X="'kpdf' 'kghostview --scale 1.45' 'evince' 'ggv' 'gv' \ 'ghostview' 'gs_x11,gs'"; +_VIEWER_TTY_TTY="'less -r -R' 'more' 'pager'"; +_VIEWER_TTY_X="'xless'"; _VIEWER_X_TTY=""; _VIEWER_X_X="'gxditview' 'xditview'"; @@ -527,7 +531,7 @@ _OPTS_GROFFER_LONG_ARG="\ ##### groffer options inhereted from groff -_OPTS_GROFF_SHORT_NA="'a' 'b' 'c' 'C' 'e' 'E' 'g' 'G' 'i' 'l' 'N' 'p' \ +_OPTS_GROFF_SHORT_NA="'a' 'b' 'c' 'C' 'e' 'E' 'g' 'G' 'i' 'k' 'l' 'N' 'p' \ 'R' 's' 'S' 't' 'U' 'z'"; _OPTS_GROFF_SHORT_ARG="'d' 'f' 'F' 'I' 'L' 'm' 'M' 'n' 'o' 'P' 'r' \ 'w' 'W'"; @@ -597,6 +601,7 @@ export _DISPLAY_PROG; # Viewer program to be used for display. export _DISPLAY_ARGS; # X resources for the viewer program. export _FILEARGS; # Stores filespec parameters. export _FILESPEC_ARG; # Stores the actual filespec parameter. +export _FILESPEC_IS_MAN; # filespec is for searching a man page export _FUNC_STACK; # Store debugging information. export _MACRO_PACKAGES; # groff's macro packages. export _MACRO_PKG; # Macro package for each found file. @@ -626,6 +631,10 @@ export _MANOPT_PATH; # $MANOPT --manpath export _MANOPT_PAGER; # $MANOPT --pager export _MANOPT_SEC; # $MANOPT --sections export _MANOPT_SYS; # $MANOPT --systems +# variables for mode pdf +export _PDF_DID_NOT_WORK; +export _PDF_HAS_GS; +export _PDF_HAS_PS2PDF; # _OPT_* as parsed from groffer command line export _OPT_ALL; # display all suitable man pages. export _OPT_APROPOS; # call `apropos' program. @@ -642,7 +651,6 @@ export _OPT_FN; # set font in some modes. export _OPT_GEOMETRY; # set size and position of viewer in X. export _OPT_ICONIC; # -iconic option for X viewers. export _OPT_LANG; # set language for man pages -export _OPT_LOCATION; # print processed file names to stderr export _OPT_MODE; # values: X, tty, Q, Z, "" export _OPT_MANPATH; # manual setting of path for man-pages export _OPT_PAGER; # specify paging program for tty mode @@ -667,7 +675,7 @@ export _OPT_WHATIS; # print the man description export _OPT_XRM; # specify X resource. export _OPT_Z; # groff option -Z. export _OUTPUT_FILE_NAME; # output generated, see main_set_res..() -export _VIEWER_TERMINAL; # viewer options for terminal (--*-viewer-tty) +export _VIEWER_BACKGROUND; # viewer shall be run in the background or not # _TMP_* temporary directory and files export _TMP_DIR; # groffer directory for temporary files export _TMP_CAT; # stores concatenation of everything @@ -696,6 +704,10 @@ _TMP_MAN=''; _TMP_CONF=''; _TMP_STDIN=''; +# variables for mode pdf +_PDF_DID_NOT_WORK='no'; +_PDF_HAS_GS='no'; +_PDF_HAS_PS2PDF='no'; ######################################################################## # reset () @@ -761,7 +773,6 @@ reset() _OPT_GEOMETRY=''; _OPT_ICONIC='no'; _OPT_LANG=''; - _OPT_LOCATION='no'; _OPT_MODE=''; _OPT_MANPATH=''; _OPT_PAGER=''; @@ -785,7 +796,7 @@ reset() _OPT_WHATIS='no'; _OPT_XRM=''; _OPT_Z='no'; - _VIEWER_TERMINAL='no'; + _VIEWER_BACKGROUND='yes'; } reset; @@ -837,21 +848,28 @@ EOF # # Clean up at exit. # +cu_already='no'; clean_up() { cd "${_START_DIR}" >"${_NULL_DEV}" 2>&1; if test _${_DEBUG_KEEP_FILES}_ = _yes_ then + if test _"$cu_already"_ = _yes_ + then + eval "${return_ok}"; + fi; + cu_already=yes; echo2 "Kept temporary directory ${_TMP_DIR}." else if test _"${_TMP_DIR}"_ != __ then - if test -d "${_TMP_DIR}" || test -f "${_TMP_DIR}" + if test -e "${_TMP_DIR}" then rm -f -r "${_TMP_DIR}" >${_NULL_DEV} 2>&1; fi; fi; fi; + eval "${return_ok}"; } # clean_up() @@ -1070,10 +1088,14 @@ base_name() ;; esac; case "${bn_name}" in - /|'') + '') eval ${_UNSET} bn_name; eval "${return_bad}"; ;; + /) + # this is like `basename' does + echo1 '/'; + ;; */*) # delete everything before and including the last slash `/'. echo1 "${bn_name}" | sed -e 's|^.*//*\([^/]*\)$|\1|'; @@ -1148,36 +1170,67 @@ fi; ######################################################################## -landmark '4: dirname()*'; +landmark '4: dir_name()*'; ######################################################################## ####################################################################### -# dirname_append (<dir> <name>) +# dir_name (<name>) +# +# Get the directory name of <name> +# +# Arguments : 1 +# Output : the directory part of <name> +# +# Variable prefix: dn +# +dir_name() +{ + func_check dir_name = 1 "$@"; + obj_from_output dn_name dir_name_chop "$1"; + case "${dn_name}" in + ''|.) + echo1 '.'; + ;; + /) + echo1 '/'; + ;; + */*) + echo1 "$(echo1 "${dn_name}" | sed 's#/*[^/][^/]*$##')"; + ;; + *) + echo1 "${dn_name}"; + ;; + esac; + eval "${return_ok}"; +} # dir_name() + + +####################################################################### +# dir_name_append (<dir> <name>) # # Append `name' to `dir' with clean handling of `/'. # # Arguments : 2 # Output : the generated new directory name <dir>/<name> # -dirname_append() +dir_name_append() { - func_check dirname_append = 2 "$@"; + func_check dir_name_append = 2 "$@"; if is_empty "$1" then - error "dirname_append(): first argument is empty."; - fi; - if is_empty "$2" + echo1 "$2"; + elif is_empty "$2" then echo1 "$1"; else - dirname_chop "$1"/"$2"; + dir_name_chop "$1"/"$2"; fi; eval "${return_ok}"; } ######################################################################## -# dirname_chop (<name>) +# dir_name_chop (<name>) # # Remove unnecessary slashes from directory name. # @@ -1186,9 +1239,9 @@ dirname_append() # # Variable prefix: dc # -dirname_chop() +dir_name_chop() { - func_check dirname_chop = 1 "$@"; + func_check dir_name_chop = 1 "$@"; # replace all multiple slashes by a single slash `/'. dc_res="$(echo1 "$1" | sed -e 's|///*|/|g')"; exit_test; @@ -1634,7 +1687,7 @@ s/^[-+][0-9][0-9]*$/ok/p ######################################################################## -# is_non_empty_file (<file_name>) +# is_not_empty_file (<file_name>) # # Test whether `file_name' is a non-empty existing file. # @@ -1643,15 +1696,15 @@ s/^[-+][0-9][0-9]*$/ok/p # `0' if arg1 is a non-empty existing file # `1' otherwise # -is_non_empty_file() +is_not_empty_file() { - func_check is_non_empty_file '=' 1 "$@"; + func_check is_not_empty_file '=' 1 "$@"; if is_file "$1" && test -s "$1" then eval "${return_yes}"; fi; eval "${return_no}"; -} # is_non_empty_file() +} # is_not_empty_file() ######################################################################## @@ -1729,27 +1782,19 @@ is_not_file() ######################################################################## -# is_not_prog ([<name> [<arg>*]]) +# is_not_prog (<progrm>) # -# Verify that arg is a not program in $PATH. +# Verify that <program> is not a program in $PATH. # -# Arguments : >=0 (empty allowed) -# more args are ignored, this allows to specify progs with arguments +# Arguments : 1, <program> can have spaces and arguments. # is_not_prog() { - func_check is_not_prog '>=' 0 "$@"; - case "$#" in - 0) - eval "${return_yes}"; - ;; - *) - if where_is_prog "$1" >${_NULL_DEV} - then - eval "${return_no}"; - fi; - ;; - esac + func_check is_not_prog '=' 1 "$@"; + if where_is_prog "$1" >${_NULL_DEV} + then + eval "${return_no}"; + fi; eval "${return_yes}"; } # is_not_prog() @@ -1807,21 +1852,15 @@ is_not_yes() ######################################################################## -# is_prog ([<name> [<arg>*]]) +# is_prog (<program>) # # Determine whether <name> is a program in $PATH # -# Arguments : >=0 (empty allowed) -# <arg>* are ignored, this allows to specify progs with arguments. +# Arguments : 1, <program> can have spaces and arguments. # is_prog() { - func_check is_prog '>=' 0 "$@"; - case "$#" in - 0) - eval "${return_no}"; - ;; - esac; + func_check is_prog '=' 1 "$@"; if where_is_prog "$1" >${_NULL_DEV} then eval "${return_yes}"; @@ -2532,6 +2571,44 @@ _search_abbrev() ######################################################################## +# list_from_file (<list_name> <file_name>) +# +# Extrect the lines from <file_name> and store them as elements to list +# <list_name>. +# +# Arguments: 2 +# <list_name>: a variable name for output, a list of single-quoted elts +# <file_name>: the name of an existing file +# +# Variable prefix: lff +# +list_from_file() +{ + func_check list_from_file '=' 2 "$@"; + if is_not_file "$2" + then + eval "${return_bad}"; + fi; + lff_n="$(wc -l "$2" | eval sed -e "'s/^[ ${_TAB}]*\([0-9]\+\).*$/\1/'")"; + eval "$1"="''"; + if obj lff_n is_equal 0 + then + eval "${return_good}"; + fi; + lff_i=0; + while obj lff_i is_not_equal "${lff_n}" + do + lff_i="$(expr "${lff_i}" + 1)"; + list_append "$1" "$(eval sed -n -e "'${lff_i}p +${lff_i}q'" "'$2'")"; + done; + eval "${_UNSET}" lff_i; + eval "${_UNSET}" lff_n; + eval "${return_good}"; +} # list_from_file() + + +######################################################################## # list_from_split (<string> <separator>) # # In <string>, escape all white space characters and replace each @@ -2719,52 +2796,6 @@ list_has_not() ######################################################################## -# list_has_not_prog (<list_name> <prog> [<arg>...]) -# -# Test whether the list <list_name> has neither an element <prog> nor an -# element that starts with the word <prog>. -# -# Arguments: >=2 -# <list_name>: a variable name for a list of single-quoted elements -# <prog>: some sequence of characters. -# <arg>: ignored -# -list_has_not_prog() -{ - func_check list_has_not_prog '>=' 2 "$@"; - if list_has "$1" "$2" || list_has_abbrev "$1" "$2"' ' - then - eval "${return_no}"; - else - eval "${return_yes}"; - fi; -} - - -######################################################################## -# list_has_prog (<list_name> <prog> [<arg>...]) -# -# Test whether the list <list_name> has an element <prog> or an element -# that starts with the word <prog>. -# -# Arguments: >=2 -# <list_name>: a variable name for a list of single-quoted elements -# <prog>: some sequence of characters. -# <arg>: ignored -# -list_has_prog() -{ - func_check list_has_prog '>=' 2 "$@"; - if list_has "$1" "$2" || list_has_abbrev "$1" "$2"' ' - then - eval "${return_yes}"; - else - eval "${return_no}"; - fi; -} - - -######################################################################## # list_single_from_abbrev (<list-var> <abbrev>) # # Check whether the list has an element starting with <abbrev>. If @@ -2813,6 +2844,7 @@ has multiple options: --${lsfa_element} and --${i}."; ;; esac; done; +# list_single_from_abbrev() obj lsfa_element echo1; eval "${_UNSET}" lsfa_abbrev; eval "${_UNSET}" lsfa_element; @@ -2941,10 +2973,12 @@ man_get() then error 'man_get(): $_TMP_MANSPEC does not suit to the arguments '"$*".; fi; +### man_get() if obj _MAN_ALL is_yes then - eval set x $(cat "${_TMP_MANSPEC}"); + list_from_file mg_list "${_TMP_MANSPEC}"; + eval set x ${mg_list}; shift; mg_ok='no'; mg_list=''; @@ -2982,17 +3016,41 @@ man_get() else m="${_MAN_SEC_LIST}"; # from --sections fi; +### man_get() for s in $(eval set x $m; shift; echo1 "$@") do mg_s="$s"; - eval set x $(cat "${_TMP_MANSPEC}"); + list_from_file mg_list "${_TMP_MANSPEC}"; + eval set x ${mg_list}; shift; + if obj mg_ext is_empty + then + for f + do + mg_f="$f"; + case "${mg_f}" in +*/man"${mg_s}"/"${mg_name}"."${mg_s}"|*/man"${mg_s}"/"${mg_name}"."${mg_s}".*) + if obj mg_f is_file + then + to_tmp "${mg_f}" && register_title "${mg_name}(${mg_s})"; + eval ${_UNSET} mg_ext; + eval ${_UNSET} mg_f; + eval ${_UNSET} mg_list; + eval ${_UNSET} mg_name; + eval ${_UNSET} mg_s; + eval ${_UNSET} mg_sec; + eval "${return_ok}"; + fi; + ;; + esac; # "$mg_f" + done; # for f + fi; # mg_ext is_empty ### man_get() for f do mg_f="$f"; case "${mg_f}" in - */man$s/${mg_name}.${mg_s}${mg_ext}*) + */man"${mg_s}"/"${mg_name}"."${mg_s}""${mg_ext}"*) if obj mg_f is_file then to_tmp "${mg_f}" && register_title "${mg_name}(${mg_s})"; @@ -3005,33 +3063,82 @@ man_get() eval "${return_ok}"; fi; ;; - esac; # "$f" + esac; # "$mg_f" done; # for f done; # for s else # $mg_sec is not empty, do with section - eval set x $(cat "${_TMP_MANSPEC}"); + list_from_file mg_list "${_TMP_MANSPEC}"; + eval set x ${mg_list}; shift; - for f - do - mg_f="$f"; + if obj mg_ext is_empty + then + for f + do + mg_f="$f"; ### man_get() - case "$f" in - */man${mg_sec}/${mg_name}.${mg_sec}${mg_ext}*) - if obj mg_f is_file - then - obj mg_f to_tmp && \ - register_title "${mg_name}(${mg_sec}${mg_ext})"; - eval ${_UNSET} mg_ext; - eval ${_UNSET} mg_f; - eval ${_UNSET} mg_list; - eval ${_UNSET} mg_name; - eval ${_UNSET} mg_s; - eval ${_UNSET} mg_sec; - eval "${return_ok}"; - fi; - ;; - esac; - done; # for f + case "${mg_f}" in +*/man"${mg_sec}"/"${mg_name}"."${mg_sec}"|\ +*/man"${mg_sec}"/"${mg_name}"."${mg_sec}".*) + if obj mg_f is_file + then + obj mg_f to_tmp && \ + register_title "${mg_name}(${mg_sec})"; + eval ${_UNSET} mg_ext; + eval ${_UNSET} mg_f; + eval ${_UNSET} mg_list; + eval ${_UNSET} mg_name; + eval ${_UNSET} mg_s; + eval ${_UNSET} mg_sec; + eval "${return_ok}"; + fi; + ;; + esac; + done; # for f + else # mg_ext is not empty + for f + do + mg_f="$f"; +### man_get() + case "${mg_f}" in +*/man"${mg_sec}"/"${mg_name}"."${mg_sec}""${mg_ext}"|\ +*/man"${mg_sec}"/"${mg_name}"."${mg_sec}""${mg_ext}".*) + if obj mg_f is_file + then + obj mg_f to_tmp && \ + register_title "${mg_name}(${mg_sec}${mg_ext})"; + eval ${_UNSET} mg_ext; + eval ${_UNSET} mg_f; + eval ${_UNSET} mg_list; + eval ${_UNSET} mg_name; + eval ${_UNSET} mg_s; + eval ${_UNSET} mg_sec; + eval "${return_ok}"; + fi; + ;; + esac; + done; # for f + for f + do + mg_f="$f"; +### man_get() + case "${mg_f}" in + */man"${mg_sec}"/"${mg_name}"."${mg_sec}""${mg_ext}"*) + if obj mg_f is_file + then + obj mg_f to_tmp && \ + register_title "${mg_name}(${mg_sec}${mg_ext})"; + eval ${_UNSET} mg_ext; + eval ${_UNSET} mg_f; + eval ${_UNSET} mg_list; + eval ${_UNSET} mg_name; + eval ${_UNSET} mg_s; + eval ${_UNSET} mg_sec; + eval "${return_ok}"; + fi; + ;; + esac; + done; # for f + fi; fi; # $mg_sec fi; # $_MAN_ALL @@ -3048,7 +3155,7 @@ man_get() ######################################################################## # man_is_man (<man-name> [<section> [<extension>]]) # -# Test whether <man-name> exits as man page. +# Test whether <man-name> exists as man page. # # Globals: in: $_TMP_MAN, $_MAN_SEC_CHARS, $_TMP_DIR, $_MAN_EXT, # $_MAN_AUTO_SEC_CHARS @@ -3090,10 +3197,10 @@ man_is_man() if obj mim_sec is_empty then m="${_MAN_AUTO_SEC_CHARS}"; - grep '/man'"$m/$1"'\.'"$m${mim_ext}" \ + eval grep "'/man$m/$1\.$m${mim_ext}'" \ "${_TMP_MAN}" > "${_TMP_MANSPEC}"; else - grep '/man'"${mim_sec}/$1"'\.'"${mim_sec}${mim_ext}" \ + eval grep "'/man${mim_sec}/$1\.${mim_sec}${mim_ext}'" \ "${_TMP_MAN}" > "${_TMP_MANSPEC}"; fi; fi; @@ -3134,7 +3241,7 @@ man_is_man() # man_setup() { - func_check main_man_setup '=' 0 "$@"; + func_check man_setup '=' 0 "$@"; if obj _MAN_IS_SETUP is_yes then @@ -3332,7 +3439,7 @@ manpath_add_lang_sys() shift; for p do - obj_from_output mals_dir dirname_append "${p}" "${mals_lang}"; + obj_from_output mals_dir dir_name_append "${p}" "${mals_lang}"; if obj mals_dir is_dir then list_append mals_lang_path "${mals_dir}"; @@ -3374,7 +3481,7 @@ _manpath_add_sys() shift; for p do - obj_from_output _mas_dir dirname_append "${p}" "${_mas_sys}"; + obj_from_output _mas_dir dir_name_append "${p}" "${_mas_sys}"; if obj _mas_dir is_dir then list_append mals_mp "${_mas_dir}"; @@ -3519,7 +3626,7 @@ obj_data() # obj_from_output (<object> <call_name> <arg>...) # # Run '$<object>="$(<call_name> <arg>...)"' to set the result of a -# function call to a global variable. +# function call to a global variable. Variables are not stored. # # Arguments: >=2 # <object>: a variable name @@ -3535,13 +3642,14 @@ obj_from_output() if is_empty "$1" then error "obj_from_output(): variable name is empty."; - elif is_empty "$2" + fi; + if is_empty "$2" then error "obj_from_output(): function name is empty." - else - ofo_result_name="$1"; fi; + ofo_result_name="$1"; shift; + ofo_return=0; if is_equal "$#" 0 then eval "${ofo_result_name}"'=""'; @@ -3552,12 +3660,15 @@ obj_from_output() list_append ofo_list "$i"; done; eval "${ofo_result_name}"'="$('"${ofo_list}"')"'; + ofo_return="$?"; exit_test; fi; + r="${ofo_return}"; eval ${_UNSET} ofo_list; + eval ${_UNSET} ofo_return; eval ${_UNSET} ofo_result_name; - eval "${return_ok}"; -} + eval "${return_var} $r"; +} # obj_from_output() ######################################################################## @@ -3636,7 +3747,7 @@ path_clean() then case "${pc_i}" in ?*/) - pc_res="${pc_res}:$(dirname_chop "${pc_i}")"; + pc_res="${pc_res}:$(dir_name_chop "${pc_i}")"; exit_test; ;; *) @@ -3751,17 +3862,10 @@ register_file() if is_equal "$1" '-' then to_tmp "${_TMP_STDIN}" && register_title 'stdin'; - if obj _DEBUG_PRINT_FILENAMES is_yes - then - echo2 "file: standard input"; - fi; else - to_tmp "$1" && register_title "$(base_name "$1")"; +# to_tmp "$1" && register_title "$(base_name "$1")"; + to_tmp "$1" && register_title "$1"; exit_test; - if obj _DEBUG_PRINT_FILENAMES is_yes - then - echo2 "file: $1"; - fi; fi; eval "${return_ok}"; } # register_file() @@ -3784,6 +3888,21 @@ register_title() eval "${return_ok}"; fi; + if obj _DEBUG_PRINT_FILENAMES is_yes + then + if is_equal "$1" 'stdin' + then + echo2 "file: standard input"; + else + if obj _FILESPEC_IS_MAN is_yes + then + echo2 "file title: $1"; + else + echo2 "file: $1"; + fi; + fi; + fi; + case "${_REG_TITLE_LIST}" in *\ *\ *\ *) eval "${return_ok}"; @@ -3824,9 +3943,7 @@ register_title() ######################################################################## # rm_file (<file_name>) # -# Remove file if $_DEBUG_KEEP_FILES allows it. -# -# Globals: $_DEBUG_KEEP_FILES +# Remove file. # rm_file() { @@ -4087,21 +4204,44 @@ to_tmp() func_check to_tmp '=' 1 "$@"; if obj _TMP_CAT is_empty then - error 'to_tmp_line(): $_TMP_CAT is not yet set'; + error 'to_tmp(): $_TMP_CAT is not yet set'; fi; tt_1="$1"; if is_file "${tt_1}" then - if obj _OPT_LOCATION is_yes - then - echo2 "${tt_1}"; - fi; + tt_dir="$(dir_name "${tt_1}")"; if obj _OPT_WHATIS is_yes then whatis_filename "${tt_1}" >>"${_TMP_CAT}"; else tt_file="${_TMP_DIR}/,file"; - cat_z "${tt_1}" >"${tt_file}"; + if obj _FILESPEC_IS_MAN is_yes + then + if obj _DEBUG_PRINT_FILENAMES is_yes + then + echo2 "file: ${tt_1}"; + fi; + tt_tmp="${_TMP_DIR}/,tmp"; + cat_z "${tt_1}" >"${tt_file}"; + tt_sofile="${_TMP_DIR}/,so:"; + grep '^\.[ ]*so[ ]' "${tt_file}" | + sed -e 's/^\.[ ]*so[ ]*//' >"${tt_tmp}"; + list_from_file tt_list "${tt_tmp}"; + eval set x ${tt_list}; + shift; + for i in "$@" + do + tt_i="$i"; + tt_sofile="${tt_sofile}"'x'; + _do_man_so "${tt_i}"; + done; + rm_file "${tt_tmp}"; + mv "${tt_file}" "${tt_tmp}"; + cat "${tt_tmp}" | soelim -I "${tt_dir}" >"${tt_file}"; + rm_file "${tt_tmp}"; + else # $_FILESPEC_IS_MAN ist not yes + cat_z "${tt_1}" | soelim -I "${tt_dir}" >"${tt_file}"; + fi; obj_from_output tt_grog grog "${tt_file}"; case " ${tt_grog} " in *\ -m*) @@ -4132,9 +4272,13 @@ s/ -mm\([^ ]\)/ -m\1/g "of ${_MACRO_PKG}." rm_file_with_debug "${tt_file}"; eval ${_UNSET} tt_1; + eval ${_UNSET} tt_dir; eval ${_UNSET} tt_file; eval ${_UNSET} tt_grog; eval ${_UNSET} tt_i; + eval ${_UNSET} tt_sofound; + eval ${_UNSET} tt_list; + eval ${_UNSET} tt_tmp; eval "${return_bad}"; ;; ### to_tmp() @@ -4156,13 +4300,114 @@ s/ -mm\([^ ]\)/ -m\1/g error "to_tmp(): could not read file \`${tt_1}'."; fi; eval ${_UNSET} tt_1; + eval ${_UNSET} tt_dir; eval ${_UNSET} tt_file; eval ${_UNSET} tt_grog; eval ${_UNSET} tt_i; + eval ${_UNSET} tt_sofound; + eval ${_UNSET} tt_list; + eval ${_UNSET} tt_tmp; eval "${return_ok}"; } # to_tmp() +############# +# _do_man_so (<so_arg>) +# +# Handle single .so file name for man pages +# +# Globals from to_tmp(): $tt_tmp, $tt_sofile, $tt_file +# Globals: $_TMP_MAN +# +# Variable prefix: dms +# +_do_man_so() { + func_check _do_man_so '=' 1 "$@"; + _dms_so="$1"; # evt. with `\ ' + _dms_soname="$(echo ${tt_i} | sed -e 's/\\[ ]/ /g')"; # without `\ ' + case "${_dms_soname}" in + /*) # absolute path + if test -f "${_dms_soname}" + then + eval "${return_ok}"; + fi; + if test -f "${_dms_soname}"'.gz' + then + _dms_sofound="${_dms_soname}"'.gz'; + elif test -f "${_dms_soname}"'.Z' + then + _dms_sofound="${_dms_soname}"'.Z'; + elif test -f "${_dms_soname}"'.bz2' + then + _dms_sofound="${_dms_soname}"'.bz2'; + else + eval ${_UNSET} _dms_sofound; + eval "${return_ok}"; + fi; + ;; +# _do_man_so() of to_tmp() + *) # relative to man path + eval grep "'/${_dms_soname}\$'" "${_TMP_MAN}" >"${tt_tmp}"; + if is_empty_file "${tt_tmp}" + then + eval grep "'/${_dms_soname}.gz\$'" "${_TMP_MAN}" >"${tt_tmp}"; + if is_empty_file "${tt_tmp}" + then + eval grep "'/${_dms_soname}.Z\$'" "${_TMP_MAN}" >"${tt_tmp}"; + if is_empty_file "${tt_tmp}" + then + eval grep "'/${_dms_soname}.bz2\$'" "${_TMP_MAN}" >"${tt_tmp}"; + fi; + fi; + fi; + if is_empty_file "${tt_tmp}" + then + eval "${return_ok}"; + fi; + _dms_done='no'; + list_from_file _dms_list "${tt_tmp}"; + eval set x ${_dms_list}; + shift; + for i + do + _dms_sofound="$i"; + if obj _dms_sofound is_empty + then + continue; + fi; + _dms_done='yes'; + break; + done; +# _do_man_so() of to_tmp() + if obj _dms_done is_not_yes + then + eval ${_UNSET} _dms_done; + eval ${_UNSET} _dms_sofound; + eval "${return_ok}"; + fi; + ;; + esac; + if obj _DEBUG_PRINT_FILENAMES is_yes + then + echo2 "file from .so: ${tt_1}"; + fi; + cat_z "${_dms_sofound}" >"${tt_sofile}"; + _dms_esc="$(echo ${_dms_so} | sed -e 's/\\/\\\\/')"; + cat "${tt_file}" | eval sed -e \ +"'s#^\\.[ ]*so[ ]*\(${_dms_so}\|${_dms_esc}\|${_dms_soname}\)[ ]*\$'"\ +"'#.so ${tt_sofile}#'" \ + >"${tt_tmp}"; + rm_file "${tt_file}"; + mv "${tt_tmp}" "${tt_file}"; + eval "${return_ok}"; + eval ${_UNSET} _dms_done; + eval ${_UNSET} _dms_esc; + eval ${_UNSET} _dms_so; + eval ${_UNSET} _dms_sofound; + eval ${_UNSET} _dms_soname; +} # _do_man_so() of to_tmp() + + ######################################################################## # to_tmp_line ([<text>]) # @@ -4195,7 +4440,7 @@ trap_set() ######################################################################## # trap_unset () -# + # disable trap on signal 0. # trap_unset() @@ -4216,9 +4461,10 @@ usage() func_check usage = 0 "$@"; echo; version; - echo1 'Usage: groffer [option]... [filespec]...'; cat <<EOF +Usage: groffer [option]... [filespec]... + Display roff files, standard input, and/or Unix manual pages with a X Window viewer or in several text modes. All input is decompressed on-the-fly with all formats that gzip can handle. @@ -4262,7 +4508,7 @@ The most important groffer long options are --help display this helping output. --html display in a web browser. --html-viewer=program - choose the web browser for html mode. + choose a web browser for html mode. --man check file parameters first whether they are man pages. --mode=auto|dvi|groff|html|pdf|ps|source|text|tty|www|x|X choose display mode. @@ -4296,17 +4542,12 @@ Long options of GNU "man": --sections=s1:s2:..., --systems=s1,s2,..., --where, ... Development options that are not useful for normal usage: ---debug, --debug-all, --debug-func, --debug-not-func, --debug-keep, ---debug-lm, --debug-params, --debug-shell, --debug-stacks, +--debug, --debug-all, --debug-filenames, --debug-func, --debug-not-func, +--debug-keep, --debug-lm, --debug-params, --debug-shell, --debug-stacks, --debug-tmpdir, --debug-user, --do-nothing, --print=text, --shell=prog EOF -#Viewer programs for the different modes that run on the terminal: -#--dvi-viewer-tty=prog, --html-viewer-tty=prog, --pdf-viewer-tty=prog, -#--ps-viewer-tty=prog, --tty-viewer-tty=prog, --X-viewer-tty=prog, -#--x-viewer-tty=prog, --www-viewer-tty=prog - eval "${return_ok}"; } @@ -4325,12 +4566,10 @@ version() y="$(echo "${_LAST_UPDATE}" | sed -e 's/^.* //')"; echo1 "Copyright (C) $y Free Software Foundation, Inc." cat <<EOF -GNU groff comes with ABSOLUTELY NO WARRANTY. +GNU groff and groffer come with ABSOLUTELY NO WARRANTY. You may redistribute copies of groff and its subprograms under the terms of the GNU General Public License. EOF - # also display groff's version, but not the called subprograms - # groff -v 2>&1 | sed -e '/^ *$/q' | sed -e '1s/^/is part of /'; eval "${return_ok}"; } @@ -4539,7 +4778,7 @@ whatis_header() else eval "${return_bad}"; fi; -} +} # whatis_header() ######################################################################## @@ -4547,54 +4786,202 @@ whatis_header() # # Output path of a program if in $PATH. # -# Arguments : >=1 (empty allowed) -# more args are ignored, this allows to specify progs with arguments +# Arguments : 1, <program> can have spaces and arguments. +# Output : list of 2 elements: prog name (with directory) and arguments # Return : `0' if arg1 is a program in $PATH, `1' otherwise. # -# Variable prefix: w +# Variable prefix: wip # where_is_prog() { - func_check where_is_prog '>=' 1 "$@"; - w_arg="$1"; - if obj w_arg is_empty + func_check where_is_prog '=' 1 "$@"; + if is_empty "$1" then - eval ${_UNSET} w_arg; eval "${return_bad}"; fi; - case "${w_arg}" in - */*) - eval ${_UNSET} w_arg; - eval ${_UNSET} w_file; - if test -f "${w_arg}" && test -x "${w_arg}" + + # Remove disturbing multiple spaces and tabs + wip_1="$(echo1 "$1" | sed -e 's/[ ][ ]*/ /g' | \ + sed -e 's/\(\\\)* / /g' | sed -e 's/^ //' | sed -e 's/ $//')"; + wip_noarg="$(echo1 "${wip_1}" | sed -e 's/ -.*$//')"; + exit_test; + + if obj wip_noarg is_empty + then + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_noarg; + eval "${return_bad}"; + fi; + + case "${wip_1}" in + *\ -*) + wip_args="$(echo1 "${wip_1}" | + eval sed -e "'s#^${wip_noarg} ##'")"; + exit_test; + ;; + *) + wip_args=''; + ;; + esac; + + wip_result=''; +# where_is_prog() + + # test whether $wip_noarg has directory, so it is not tested with $PATH + case "${wip_noarg}" in + */*) + if test -f "${wip_noarg}" && test -x "${wip_noarg}" + then + list_append wip_result "${wip_noarg}" "${wip_args}"; + exit_test; + obj wip_result echo1; + exit_test; + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_args; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; + eval "${return_ok}"; + fi; + + # now $wip_noarg (with /) is not an executable file + + # test name with space + obj_from_output wip_name base_name "${wip_noarg}"; + obj_from_output wip_dir dir_name "${wip_noarg}"; + case "${wip_name}" in + *\ *) + wip_base="$(echo1 "${wip_name}" | sed -e 's/ .*$//')"; + exit_test; + obj_from_output wip_file dir_name_append "${wip_dir}" "${wip_base}"; + exit_test; +# where_is_prog() + if test -f "${wip_file}" && test -x "${wip_file}" then + wip_baseargs="$(echo1 "${wip_name}" | + eval sed -e "'s#^${wip_base} ##'")"; + exit_test; + if obj wip_args is_empty + then + wip_args="${wip_baseargs}"; + else + wip_args="${wip_baseargs} ${wip_args}"; + fi; + + list_append wip_result "${wip_file}" "${wip_args}"; + exit_test; + obj wip_result echo1; + exit_test; + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_args; + eval ${_UNSET} wip_base; + eval ${_UNSET} wip_baseargs; + eval ${_UNSET} wip_dir; + eval ${_UNSET} wip_file; + eval ${_UNSET} wip_name; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; eval "${return_ok}"; - else - eval "${return_bad}"; - fi; - ;; - esac; + fi; # test ${wip_file} + ;; + esac; # end of test name with space + +# where_is_prog() + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_args; + eval ${_UNSET} wip_base; + eval ${_UNSET} wip_dir; + eval ${_UNSET} wip_name; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; + eval "${return_bad}"; + ;; + esac; # test of $wip_noarg on path with directory + + + # now $wip_noarg does not have a /, so it is checked with $PATH. + eval set x "$(path_list "${PATH}")"; exit_test; shift; - for p + + # test path with $win_noarg, evt. with spaces + for d do - case "$p" in - */) w_file=${p}${w_arg}; ;; - *) w_file=${p}/${w_arg}; ;; - esac; - if test -f "${w_file}" && test -x "${w_file}" + wip_dir="$d"; + obj_from_output wip_file dir_name_append "${wip_dir}" "${wip_noarg}"; +# where_is_prog() + + # test $win_file on executable file + if test -f "${wip_file}" && test -x "${wip_file}" then - obj w_file echo1; - eval ${_UNSET} w_arg; - eval ${_UNSET} w_file; + list_append wip_result "${wip_file}" "${wip_args}"; + exit_test; + obj wip_result echo1; + exit_test; + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_dir; + eval ${_UNSET} wip_file; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; eval "${return_ok}"; - fi; - done; - eval ${_UNSET} w_arg; - eval ${_UNSET} w_file; + fi; # test $win_file on executable file + done; # test path with $win_prog with spaces + + case "${wip_noarg}" in + *\ *) + # test on path with base name without space + wip_base="$(echo1 "${wip_noarg}" | sed -e 's/^\([^ ]*\) .*$/\1/')"; + exit_test; + for d + do + wip_dir="$d"; + obj_from_output wip_file dir_name_append "${wip_dir}" "${wip_base}"; + exit_test; +# where_is_prog() + + # test $win_file on executable file + if test -f "${wip_file}" && test -x "${wip_file}" + then + wip_baseargs="$(echo1 "${wip_noarg}" | + sed -e 's/[^ ]* \(.*\)$/\1/')"; + exit_test; + if obj wip_args is_empty + then + wip_args="${wip_baseargs}"; + else + wip_args="${wip_args} ${wip_baseargs}"; + fi; + list_append wip_result "${wip_file}" "${wip_args}"; + exit_test; + obj wip_result echo1; + exit_test; + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_args; + eval ${_UNSET} wip_base; + eval ${_UNSET} wip_baseargs; + eval ${_UNSET} wip_dir; + eval ${_UNSET} wip_file; + eval ${_UNSET} wip_name; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; + eval "${return_ok}"; + fi; # test of $wip_file on executable file + done; # test path with base name without space +# where_is_prog() + ;; + esac; # test of $wip_noarg on space + + eval ${_UNSET} wip_1; + eval ${_UNSET} wip_args; + eval ${_UNSET} wip_base; + eval ${_UNSET} wip_baseargs; + eval ${_UNSET} wip_dir; + eval ${_UNSET} wip_file; + eval ${_UNSET} wip_name; + eval ${_UNSET} wip_noarg; + eval ${_UNSET} wip_result; eval "${return_bad}"; -} +} # where_is_prog() ######################################################################## @@ -4730,7 +5117,7 @@ main_parse_MANOPT() s/^'"${_SPACE_SED}"'*// s/'"${_SPACE_SED}"'*$// ')"; - exit_test; + exit_test; fi; if obj MANOPT is_empty then @@ -4775,7 +5162,6 @@ s/'"${_SPACE_SED}"'*$// ;; -h|--help) do_nothing; - shift; ;; -k|--apropos) # groffer's --apropos takes an argument, but man's does not, so @@ -4815,7 +5201,6 @@ s/'"${_SPACE_SED}"'*$// ;; -t|--troff) do_nothing; - shift; ;; -T|--device) list_append mpm_list '-T' "$1"; @@ -4824,7 +5209,6 @@ s/'"${_SPACE_SED}"'*$// ### main_parse_MANOPT() -u|--update) do_nothing; - shift; ;; -V|--version) do_nothing; @@ -4965,7 +5349,7 @@ main_parse_args() --auto) # the default automatic mode _OPT_MODE=''; ;; - --bd) # border color for viewers, arg; + --bd|--bordercolor) # border color for viewers, arg; _OPT_BD="$1"; shift; ;; @@ -4973,7 +5357,7 @@ main_parse_args() _OPT_BG="$1"; shift; ;; - --bw) # border width for viewers, arg; + --bw|--borderwidth) # border width for viewers, arg; _OPT_BW="$1"; shift; ;; @@ -5020,7 +5404,7 @@ main_parse_args() _OPT_FG="$1"; shift; ;; - --fn|--font) # set font for viewers, arg; + --fn|--ft|--font) # set font for viewers, arg; _OPT_FN="$1"; shift; ;; @@ -5058,7 +5442,7 @@ main_parse_args() _MAN_ENABLE='no'; ;; --location|--where) # print file locations to stderr - _OPT_LOCATION='yes'; + _DEBUG_PRINT_FILENAMES='yes'; ;; --man) # force all file params to be man pages _MAN_ENABLE='yes'; @@ -5111,7 +5495,7 @@ main_parse_args() esac; ;; --no-location) # disable former call to `--location' - _OPT_LOCATION='yes'; + _DEBUG_PRINT_FILENAMES='no'; ;; --no-man) # disable search for man pages # the same as --local-file @@ -5132,12 +5516,12 @@ main_parse_args() _OPT_MODE='pdf'; ;; ### main_parse_args() - --pdf-viewer) # viewer program for ps mode; arg - _OPT_VIEWER_PDF_TTY=""; + --pdf-viewer) # viewer program for pdf mode; arg _OPT_VIEWER_PDF="$1"; + _OPT_VIEWER_PDF_TTY=""; shift; ;; - --pdf-viewer-tty) # viewer program for ps mode in tty; arg + --pdf-viewer-tty) # viewer program for pdf mode in tty; arg _OPT_VIEWER_PDF=""; _OPT_VIEWER_PDF_TTY="$1"; shift; @@ -5386,7 +5770,7 @@ main_set_mode() ### main_set_mode() if is_not_X then - _VIEWER_TERMINAL='yes'; + _VIEWER_BACKGROUND='no'; fi; case "${_OPT_MODE}" in @@ -5467,41 +5851,54 @@ main_set_mode() esac; # only viewer modes are left + eval set x "${msm_modes}"; shift; while is_greater_than "$#" 0 do - m="$1"; + msm_1="$1"; shift; - case "$m" in + + if is_X + then + _VIEWER_BACKGROUND='yes'; + else + _VIEWER_BACKGROUND='no'; + fi; + + case "${msm_1}" in dvi) - if obj _OPT_VIEWER_DVI is_not_empty + if obj _OPT_VIEWER_DVI is_empty then - msm_viewer="${_OPT_VIEWER_DVI}"; - else obj_from_output msm_viewer _get_first_prog _VIEWER_DVI_X; + else + obj_from_output msm_viewer _check_X_prog _OPT_VIEWER_DVI _VIEWER_DVI_X; fi; - if obj msm_viewer is_empty - then - error 'main_set_mode(): No viewer for dvi mode available.'; - fi; -### main_set_mode() if is_not_equal "$?" 0 then continue; fi; - _DISPLAY_PROG="${msm_viewer}"; + if obj msm_viewer is_empty + then + if is_equal "$#" 0 + then + error 'main_set_mode(): No viewer for dvi mode available.'; + else + continue; + fi; + fi; +### main_set_mode() + _obj_set_vars msm_viewer; _DISPLAY_MODE="dvi"; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; eval "${return_ok}"; ;; html) - if obj _OPT_VIEWER_HTML is_not_empty + if obj _OPT_VIEWER_HTML is_empty then - msm_viewer="${_OPT_VIEWER_HTML}"; - else if is_X then msm_viewers="${_VIEWER_HTML_X}"; @@ -5509,40 +5906,74 @@ main_set_mode() msm_viewers="${_VIEWER_HTML_TTY}"; fi; obj_from_output msm_viewer _get_first_prog msm_viewers; - fi; - if obj msm_viewer is_empty - then - error 'main_set_mode(): No viewer for html mode available.'; + else + obj_from_output msm_viewer \ + _check_X_prog _OPT_VIEWER_HTML _VIEWER_HTML_X; fi; if is_not_equal "$?" 0 then continue; fi; + if obj msm_viewer is_empty + then + if is_equal "$#" 0 + then + error 'main_set_mode(): No viewer for html mode available.'; + else + continue; + fi; + fi; ### main_set_mode() - _DISPLAY_PROG="${msm_viewer}"; + _obj_set_vars msm_viewer; _DISPLAY_MODE=html; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; eval "${return_ok}"; ;; pdf) - if obj _OPT_VIEWER_PDF is_not_empty + if obj _PDF_DID_NOT_WORK is_yes then - msm_viewer="${_OPT_VIEWER_PDF}"; - else - obj_from_output msm_viewer _get_first_prog _VIEWER_PDF_X; + if is_equal "$#" 0 + then + error 'main_set_mode(): pdf mode did not work.'; + else + continue; + fi; fi; - if obj msm_viewer is_empty + if is_prog ps2pdf + then + _PDF_HAS_PS2PDF='yes'; + fi; + if is_prog gs then - error 'main_set_mode(): No viewer for pdf mode available.'; + _PDF_HAS_GS='yes'; + fi; + if obj _OPT_VIEWER_PDF is_empty + then + obj_from_output msm_viewer _get_first_prog _VIEWER_PDF_X; + else + obj_from_output msm_viewer _check_X_prog _OPT_VIEWER_PDF _VIEWER_PDF_X; fi; if is_not_equal "$?" 0 then + _PDF_DID_NOT_WORK='yes'; continue; fi; - _DISPLAY_PROG="${msm_viewer}"; + if obj msm_viewer is_empty + then + _PDF_DID_NOT_WORK='yes'; + if is_equal "$#" 0 + then + error 'main_set_mode(): No viewer for pdf mode available.'; + else + continue; + fi; + fi; + _obj_set_vars msm_viewer; _DISPLAY_MODE="pdf"; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5550,22 +5981,28 @@ main_set_mode() ;; ### main_set_mode() ps) - if obj _OPT_VIEWER_PS is_not_empty + if obj _OPT_VIEWER_PS is_empty then - msm_viewer="${_OPT_VIEWER_PS}"; - else obj_from_output msm_viewer _get_first_prog _VIEWER_PS_X; - fi; - if obj msm_viewer is_empty - then - error 'main_set_mode(): No viewer for ps mode available.'; + else + obj_from_output msm_viewer _check_X_prog _OPT_VIEWER_PS _VIEWER_PS_X; fi; if is_not_equal "$?" 0 then continue; fi; - _DISPLAY_PROG="${msm_viewer}"; + if obj msm_viewer is_empty + then + if is_equal "$#" 0 + then + error 'main_set_mode(): No viewer for ps mode available.'; + else + continue; + fi; + fi; + _obj_set_vars msm_viewer; _DISPLAY_MODE="ps"; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5573,6 +6010,7 @@ main_set_mode() ;; text) _DISPLAY_MODE='text'; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5581,28 +6019,35 @@ main_set_mode() ### main_set_mode() tty) _DISPLAY_MODE='tty'; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; eval "${return_ok}"; ;; x) - if obj _OPT_VIEWER_X is_not_empty + if obj _OPT_VIEWER_X is_empty then - msm_viewer="${_OPT_VIEWER_X}"; - else obj_from_output msm_viewer _get_first_prog _VIEWER_X_X; - fi; - if obj msm_viewer is_empty - then - error 'main_set_mode(): No viewer for x mode available.'; + else + obj_from_output msm_viewer _check_X_prog _OPT_VIEWER_X _VIEWER_X_X; fi; if is_not_equal "$?" 0 then continue; fi; - _DISPLAY_PROG="${msm_viewer}"; + if obj msm_viewer is_empty + then + if is_equal "$#" 0 + then + error 'main_set_mode(): No viewer for x mode available.'; + else + continue; + fi; + fi; + _obj_set_vars msm_viewer; _DISPLAY_MODE='x'; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5611,6 +6056,7 @@ main_set_mode() ### main_set_mode() X) _DISPLAY_MODE='X'; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5618,6 +6064,7 @@ main_set_mode() ;; esac; done; + eval ${_UNSET} msm_1; eval ${_UNSET} msm_modes; eval ${_UNSET} msm_viewer; eval ${_UNSET} msm_viewers; @@ -5625,45 +6072,92 @@ main_set_mode() } # main_set_mode() +# _obj_set_vars (<3-list-obj>) +# +# Set $_DISPLAY_PROG and $_DISPLAY_ARGS with the list elements. +# +# Argument: 1, expect list with 3 elements from _get_first_prog() or +# _check_X_prog() +# +_obj_set_vars() +{ + func_check _set_vars '=' 1 "$@"; + eval a='"${'"$1"'}"'; + eval set x "$a"; + shift; + if is_not_equal "$#" 3 + then + error "_set_vars(): argument is not a list with 3 elements: $a"; + fi; + + if is_empty "$1" + then + error "_set_vars(): program name is empty in the list: $1"; + fi; + _DISPLAY_PROG="$1"; + + if is_not_empty "$2" + then + if obj _DISPLAY_ARGS is_empty + then + _DISPLAY_ARGS="$2"; + else + _DISPLAY_ARGS="${_DISPLAY_ARGS} $2"; + fi; + fi; + case "$3" in + yes|no) + _VIEWER_BACKGROUND="$3"; + ;; + *) + error "_set_vars(): wrong value for $_VIEWER_BACKGROUND in the list: $3"; + ;; + esac; +} # _obj_set_vars() of main_set_mode() + + # _process_mode (<MODE>) +# +# Do some things for a given mode. This is used by several modes. +# +# Argument: 1, a mode name in upper-case +# _process_mode() { + func_check _process_mode '=' 1 "$@"; if eval obj _OPT_VIEWER_"$1"_TTY is_not_empty then - _VIEWER_TERMINAL='yes'; + exit_test; + _VIEWER_BACKGROUND='no'; eval _OPT_VIEWER_"$1"='"${_OPT_VIEWER_'"$1"'_TTY}"'; - elif eval obj _OPT_VIEWER_"$1" is_not_empty - then - if eval list_has_not_prog _VIEWER_"$1"_X '"${_OPT_VIEWER_'"$1"'}"' - then - _VIEWER_TERMINAL='yes'; - fi; fi; + exit_test; if is_not_X && \ eval obj _OPT_VIEWER_"$1" is_empty && \ eval obj _VIEWER_"$1"_TTY is_empty then + exit_test; _OPT_MODE=''; fi; + exit_test; } # _process_mode() of main_set_mode() -# _get_first_prog (<prog> ...) +# _get_first_prog (<prog_list_name>) # -# Retrieve from arguments the first existing program in $PATH. +# Retrieve from the elements of the list in the argument the first +# existing program in $PATH. # Local function for main_set_mode(). # # Return : `1' if none found, `0' if found. -# Output : the argument that succeded. +# Output : the argument that succeeded, under where_is_prog(), and +# the value of $_VIEWER_BACKGROUND. # # Variable prefix: _gfp # _get_first_prog() { - if is_equal "$#" 0 - then - return "${_BAD}"; - fi; + func_check _get_first_prog '=' 1 "$@"; eval x='"${'"$1"'}"'; eval set x "$x"; shift; @@ -5674,19 +6168,141 @@ _get_first_prog() then continue; fi; - if eval is_prog "${_gfp_i}" + obj_from_output _gfp_result where_is_prog "${_gfp_i}"; + exit_test; + if is_equal "$?" 0 && obj _gfp_result is_not_empty then + list_append _gfp_result "${_VIEWER_BACKGROUND}"; + obj _gfp_result echo1; exit_test; - obj _gfp_i echo1; eval ${_UNSET} _gfp_i; - return "${_GOOD}"; + eval ${_UNSET} _gfp_result; + eval "${return_good}"; fi; done; eval ${_UNSET} _gfp_i; - return "${_BAD}"; + eval ${_UNSET} _gfp_result; + eval "${return_bad}"; } # _get_first_prog() of main_set_mode() +# _check_X_prog (<prog_name> <X_prog_list_name>) +# +# Check whether the content of <prog_name> without its arguments is +# in the list <X_prog_list_name>. If so the option is output with the +# arguments of the list element, its corresponding arguments, and the +# value yes/no of $_VIEWER_BACKGROUND. +# Local function for main_set_mode(). +# +# Return : `1' if not a part of the list, `0' if found in the list. +# Output : 3-element list, the option with arguments changed by +# where_is_prog(), and the value of $_VIEWER_BACKGROUND. +# +# Globals: $_VIEWER_BACKGROUND +# +# Variable prefix: _cXp +# +_check_X_prog() +{ + func_check _check_X_prog '=' 2 "$@"; + eval _cXp_1='"${'"$1"'}"'; + eval _cXp_2='"${'"$2"'}"'; + + obj_from_output _cXp_list1 where_is_prog "${_cXp_1}"; + if is_not_equal "$?" 0 || obj _cXp_list1 is_empty + then + exit_test; + echo2 "_check_X_prog(): '${_cXp_1}' is not an existing program."; + eval ${_UNSET} _cXp_1; + eval ${_UNSET} _cXp_2; + eval ${_UNSET} _cXp_list1; + eval "${return_bad}"; + fi; + exit_test; + + if obj _VIEWER_BACKGROUND is_not_yes + then # no mode for X Window, so do not check it + list_append _cXp_list1 "${_VIEWER_BACKGROUND}"; + obj _cXp_list1 echo1; + eval ${_UNSET} _cXp_1; + eval ${_UNSET} _cXp_2; + eval ${_UNSET} _cXp_list1; + eval "${return_good}"; + fi; + + eval set x ${_cXp_list1}; + _cXp_prog1="$2"; + _cXp_args1="$3"; + +# _check_X_prog() of main_set_mode() + eval set x "${_cXp_2}"; + shift; + for i + do + _cXp_i="$i"; + obj_from_output _cXp_list2 where_is_prog "${_cXp_i}"; + if is_not_equal "$?" 0 || obj _cXp_list2 is_empty + then + exit_test; + continue; + fi; + exit_test; + _cXp_prog2="$(eval set x ${_cXp_list2}; echo1 "$2")"; + + if is_not_equal "${_cXp_prog1}" "${_cXp_prog2}" + then + exit_test; + continue; + fi; + exit_test; + + # equal, prog found + + _cXp_args2="$(eval set x ${_cXp_list2}; echo1 "$3")"; + if obj _cXp_args2 is_not_empty + then + if obj _cXp_args1 is_empty + then + _cXp_args1="${_cXp_args2}"; + else + _cXp_args1="${_cXp_args2} ${_cXp_args1}"; + fi; + fi; +# _check_X_prog() of main_set_mode() + + _cXp_list1=''; + list_append _cXp_list1 \ + "${_cXp_prog1}" "${_cXp_args1}" "${_VIEWER_BACKGROUND}"; + exit_test; + echo1 "${_cXp_list1}"; + eval ${_UNSET} _cXp_1; + eval ${_UNSET} _cXp_2; + eval ${_UNSET} _cXp_i; + eval ${_UNSET} _cXp_args1; + eval ${_UNSET} _cXp_list1; + eval ${_UNSET} _cXp_prog1; + eval ${_UNSET} _cXp_args2; + eval ${_UNSET} _cXp_list2; + eval ${_UNSET} _cXp_prog2; + eval "${return_good}"; + done; # for vars in list + + _VIEWER_BACKGROUND='no'; + list_append _cXp_list1 "${_VIEWER_BACKGROUND}"; + echo1 "${_cXp_list1}"; + eval ${_UNSET} _cXp_1; + eval ${_UNSET} _cXp_2; + eval ${_UNSET} _cXp_i; + eval ${_UNSET} _cXp_args1; + eval ${_UNSET} _cXp_list1; + eval ${_UNSET} _cXp_prog1; + eval ${_UNSET} _cXp_args2; + eval ${_UNSET} _cXp_list2; + eval ${_UNSET} _cXp_prog2; + eval "${return_good}"; +} # _check_X_prog() of main_set_mode() + + ####################################################################### # main_do_fileargs () # @@ -5717,11 +6333,13 @@ main_do_fileargs() eval set x "${_FILEARGS}"; shift; eval ${_UNSET} _FILEARGS; +### main_do_fileargs() while is_greater_than "$#" 0 do mdfa_filespec="$1"; _FILESPEC_ARG="$1"; shift; + _FILESPEC_IS_MAN='no'; _TMP_MANSPEC=''; _SPECIAL_FILESPEC='no'; @@ -5773,6 +6391,7 @@ main_do_fileargs() ;; # now it must be a man page pattern esac; +### main_do_fileargs() if obj _MACRO_PKG is_not_empty && obj _MACRO_PKG is_not_equal '-man' then echo2 "${mdfa_filespec} is not a file, man pages are ignored "\ @@ -5794,6 +6413,8 @@ main_do_fileargs() fi; ### main_do_fileargs() man_setup; + _FILESPEC_IS_MAN='yes'; + # check whether filespec is a man page if obj mdfa_filespec man_is_man then @@ -5866,6 +6487,7 @@ main_do_fileargs() fi; ;; esac; +### main_do_fileargs() # check on "s name", where "s" is a section with or without an extension if is_not_empty "$1" @@ -5897,6 +6519,7 @@ main_do_fileargs() fi; fi; +### main_do_fileargs() echo2 "${mdfa_filespec} ${mdfa_errmsg}"; continue; done; @@ -5949,8 +6572,9 @@ main_set_resources() fi; _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}${msr_n}"; shift; - done; + done; # until $# is 0 ### main_set_resources() + case "${_OUTPUT_FILE_NAME}" in '') _OUTPUT_FILE_NAME='-'; @@ -6171,14 +6795,14 @@ main_display() export md_groggy; export md_modefile; - if obj _TMP_CAT is_non_empty_file + if obj _TMP_CAT is_empty_file then - md_modefile="${_OUTPUT_FILE_NAME}"; - else echo2 'groffer: empty input.'; clean_up; eval ${_UNSET} md_modefile; eval "${return_ok}"; + else + md_modefile="${_OUTPUT_FILE_NAME}"; fi; # go to the temporary directory to be able to access internal data files @@ -6226,29 +6850,74 @@ wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}"; then _do_opt_V; tmp_cat | eval "${md_groggy}" "${md_addopts}"; - else - md_pager=''; + else # $_DISPLAY_MODE is 'tty' ### main_display() - for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \ - 'less -r -R' 'more' 'pager' 'cat' + md_pager=''; + for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" do - md_p="$p"; - if eval is_prog ${md_p} - then # no "" for is_prog() allows args for $p - md_pager="${md_p}"; - break; + if obj p is_empty + then + continue; + fi; + obj_from_output md_pager where_is_prog "$p"; + if is_not_equal "$?" 0 || obj md_pager is_empty + then + md_pager=''; + continue; fi; + eval set x $md_pager; + shift; + case "$1" in + */less) + if is_empty "$2" + then + md_pager="$1"' -r -R'; + else + md_pager="$1"' -r -R '"$2"; + fi; + ;; +### main_display() + *) + if is_empty "$2" + then + md_pager="$1"; + else + md_pager="$1 $2"; + fi; + ;; + esac; + break; done; if obj md_pager is_empty then + eval set x ${_VIEWER_TTY_TTY} ${_VIEWER_TTY_X} 'cat'; + shift; + # that is: 'less -r -R' 'more' 'pager' 'xless' 'cat' + for p + do + if obj p is_empty + then + continue; + fi; + md_p="$p"; + if is_prog "${md_p}" + then + md_pager="${md_p}"; + break; + fi; + done; + fi; +### main_display() + if obj md_pager is_empty + then error 'main_display(): no pager program found for tty mode'; fi; _do_opt_V; tmp_cat | eval "${md_groggy}" "${md_addopts}" | \ eval "${md_pager}"; - fi; + fi; # $_DISPLAY_MODE clean_up; - ;; + ;; # text|tty) source) tmp_cat; clean_up; @@ -6407,22 +7076,15 @@ _do_display() eval "$1"; fi; obj _TMP_CAT rm_file_with_debug; - if obj _VIEWER_TERMINAL is_yes # for programs that run on tty + if obj _VIEWER_BACKGROUND is_not_yes # for programs that run on tty then - eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "\"${md_modefile}\""; + eval "'${_DISPLAY_PROG}'" ${_DISPLAY_ARGS} "\"${md_modefile}\""; else - case "${_DISPLAY_PROG}" in -# lynx\ *|less\ *|more\ *) # programs known to run on the terminal -# eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "\"${md_modefile}\""; -# ;; - *) - trap_unset; - { - trap_set; - eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "\"${md_modefile}\""; - } & - ;; - esac; + trap_unset; + { + trap_set; + eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "\"${md_modefile}\""; + } & fi; fi; eval "${return_ok}"; @@ -6476,15 +7138,22 @@ _make_pdf() _mp_psfile="${md_modefile}"; md_modefile="${md_modefile}.pdf"; obj md_modefile rm_file; - if gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ - -sOutputFile="${md_modefile}" -c save pop -f "${_mp_psfile}" + if obj _PDF_HAS_PS2PDF is_yes && ps2pdf "${_mp_psfile}" "${md_modefile}"; then :; - elif ps2pdf "${_mp_psfile}" "${md_modefile}" + elif obj _PDF_HAS_GS && gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ + -sOutputFile="${md_modefile}" -c save pop -f "${_mp_psfile}"; then :; else - error '_make_pdf(): could not transform into pdf format.'; + _PDF_DID_NOT_WORK='yes'; + echo2 '_make_pdf(): Could not transform into pdf format. '\ +'The Postscript mode (ps) is used instead.'; + _OPT_MODE='ps'; + main_set_mode; + main_set_resources; + main_display; + exit; fi; obj _mp_psfile rm_file_with_debug; eval ${_UNSET} _mp_psfile; diff --git a/contrib/groffer/version.sh b/contrib/groffer/version.sh index 7eb48c9d..10a70efd 100644 --- a/contrib/groffer/version.sh +++ b/contrib/groffer/version.sh @@ -2,7 +2,8 @@ # groffer - display groff files -# Source file position: <groff-source>/contrib/groffer/groffer.sh +# Source file position: <groff-source>/contrib/groffer/version.sh +# Installed position: <prefix>/lib/groff/groffer/version.sh # Copyright (C) 2001,2002,2003,2004,2005,2006 # Free Software Foundation, Inc. @@ -31,8 +32,8 @@ export _PROGRAM_VERSION; export _LAST_UPDATE; -_PROGRAM_VERSION='0.9.24'; -_LAST_UPDATE='28 Jul 2006'; +_PROGRAM_VERSION='0.9.25'; +_LAST_UPDATE='11 Sep 2006'; # this setting of the groff version is only used before make is run, # otherwise @VERSION@ will set it, see groffer.sh. |