/[groff]/groff/contrib/groffer/groffer2.sh
ViewVC logotype

Diff of /groff/contrib/groffer/groffer2.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by wl, Tue Aug 23 09:57:09 2005 UTC revision 1.4 by bwarken, Wed Sep 14 01:11:28 2005 UTC
# Line 12  Line 12 
12  # Free Software Foundation, Inc.  # Free Software Foundation, Inc.
13  # Written by Bernd Warken  # Written by Bernd Warken
14    
15  # Last update: 22 August 2005  # Last update: 14 Sep 2005
16    
17  # This file is part of `groffer', which is part of `groff'.  # This file is part of `groffer', which is part of `groff'.
18    
# Line 92  fi; Line 92  fi;
92  ########################################################################  ########################################################################
93  # Test of sed program; test in groffer.sh is not valid here.  # Test of sed program; test in groffer.sh is not valid here.
94  #  #
95  if test _"$(echo red | sed -e 's/r/s/')"_ != _sed_  if test _"$(echo xTesTx \
96               | sed -n -e 's/^.\([Tt]e*x*sTT*\).*$/\1/p' \
97               | sed -e 's|T|t|g')"_ != _test_
98  then  then
99    echo 'The sed program did not work.' >&2;    echo 'The sed program did not work.' >&2;
100    exit "${_ERROR}";    exit "${_ERROR}";
# Line 100  fi; Line 102  fi;
102    
103    
104  ########################################################################  ########################################################################
105    # Test of `cat'.
106    #
107    if test _"$(echo test | cat)"_ != _test_
108    then
109      error 'Test of "cat" command failed.';
110    fi;
111    
112    
113    ########################################################################
114  # Test of function definitions.  # Test of function definitions.
115  #  #
116  _t_e_s_t_f_u_n_c_()  _t_e_s_t_f_u_n_c_()
# Line 117  fi; Line 128  fi;
128    
129    
130  ########################################################################  ########################################################################
131    # landmark (<text>)
132    #
133    # Print <text> to standard error as a debugging aid.
134    #
135    # Globals: $_DEBUG_LM
136    #
137    landmark()
138    {
139      if test _"${_DEBUG_LM}"_ = _yes_
140      then
141        echo "LM: $*" >&2;
142      fi;
143    } # landmark()
144    
145    
146    ########################################################################
147    # test for compression.
148    export _HAS_COMPRESSION;
149    export _HAS_BZIP;
150    if test _"$(echo 'test' | gzip -c -d -f - 2>${_NULL_DEV})"_ = _test_
151    then
152      _HAS_COMPRESSION='yes';
153      if echo 'test' | bzip2 -c 2>${_NULL_DEV} | bzip2 -t 2>${_NULL_DEV} \
154         && test _"$(echo 'test' | bzip2 -c 2>${_NULL_DEV} \
155                                 | bzip2 -d -c 2>${_NULL_DEV})"_ \
156                 = _test_
157      then
158        _HAS_BZIP='yes';
159      else
160        _HAS_BZIP='no';
161      fi;
162    else
163      _HAS_COMPRESSION='no';
164      _HAS_BZIP='no';
165    fi;
166    
167    
168    ########################################################################
169  #                    debug - diagnostic messages  #                    debug - diagnostic messages
170  ########################################################################  ########################################################################
171    
172    export _DEBUG_FUNC_CHECK;
173    if test _"${_BEFORE_MAKE}"_ = _yes_
174    then
175      _DEBUG_FUNC_CHECK='yes';
176    else
177      _DEBUG_FUNC_CHECK='no';
178    fi;
179    #_DEBUG_FUNC_CHECK='no';        # disable function checking
180    #_DEBUG_FUNC_CHECK='yes';       # enable function checking
181    
182  export _DEBUG_STACKS;  export _DEBUG_STACKS;
183  _DEBUG_STACKS='no';             # disable stack output in each function  _DEBUG_STACKS='no';             # disable stack output in each function
184  #_DEBUG_STACKS='yes';           # enable stack output in each function  #_DEBUG_STACKS='yes';           # enable stack output in each function
185    
186    export _DEBUG_USER_WITH_STACK;
187    _DEBUG_USER_WITH_STACK='no';    # disable stack dump in error_user()
188    #_DEBUG_USER_WITH_STACK='yes';  # enable stack dump in error_user()
189    
190  export _DEBUG_LM;  export _DEBUG_LM;
191  _DEBUG_LM='no';                 # disable landmark messages  _DEBUG_LM='no';                 # disable landmark messages
192  #_DEBUG_LM='yes';               # enable landmark messages  #_DEBUG_LM='yes';               # enable landmark messages
# Line 144  export _DEBUG_PRINT_TMPDIR; Line 207  export _DEBUG_PRINT_TMPDIR;
207  _DEBUG_PRINT_TMPDIR='no';       # disable printing of the temporary dir  _DEBUG_PRINT_TMPDIR='no';       # disable printing of the temporary dir
208  #_DEBUG_PRINT_TMPDIR='yes';     # enable printing of the temporary dir  #_DEBUG_PRINT_TMPDIR='yes';     # enable printing of the temporary dir
209    
210  export _DEBUG_USER_WITH_STACK;  export _DEBUG_PRINT_FILENAMES;
211  _DEBUG_USER_WITH_STACK='no';    # disable stack dump in error_user()  _DEBUG_PRINT_FILENAMES='no';    # disable printing of the found file names
212  #_DEBUG_USER_WITH_STACK='yes';  # enable stack dump in error_user()  #_DEBUG_PRINT_FILENAMES='yes';  # enable printing of the found file names
213    
214  # determine all --debug* options  # determine all --debug* options
215  case " $*" in  case " $*" in
216  *\ --debug*)  *\ --debug*)
217    case " $* " in    case " $* " in
218    *' --debug '*)    *' --debug '*)
219        _DEBUG_FUNC_CHECK='yes';
220      # _DEBUG_STACKS='yes';      # _DEBUG_STACKS='yes';
221        _DEBUG_USER_WITH_STACK='yes';
222      # _DEBUG_LM='yes';      # _DEBUG_LM='yes';
223      _DEBUG_KEEP_FILES='yes';      _DEBUG_KEEP_FILES='yes';
224      _DEBUG_PRINT_PARAMS='yes';      _DEBUG_PRINT_PARAMS='yes';
225      _DEBUG_PRINT_SHELL='yes';      _DEBUG_PRINT_SHELL='yes';
226      _DEBUG_PRINT_TMPDIR='yes';      _DEBUG_PRINT_TMPDIR='yes';
227      _DEBUG_USER_WITH_STACK='yes';      _DEBUG_PRINT_FILENAMES='yes';
228      ;;      ;;
229    esac;    esac;
230    d=' --debug-all --debug-keep --debug-lm --debug-params --debug-shell '\    d=' --debug-all --debug-filenames --debug-func --debug-not-func '\
231  '--debug-stacks --debug-tmpdir --debug-user ';  '--debug-keep --debug-lm --debug-params --debug-shell --debug-stacks '\
232    '--debug-tmpdir --debug-user ';
233    for i    for i
234    do    do
235      case "$i" in      case "$i" in
# Line 183  EOF Line 249  EOF
249        case "$s" in        case "$s" in
250        '') continue; ;;        '') continue; ;;
251        --debug-all)        --debug-all)
252            _DEBUG_FUNC_CHECK='yes';
253          _DEBUG_STACKS='yes';          _DEBUG_STACKS='yes';
254            _DEBUG_USER_WITH_STACK='yes';
255          _DEBUG_LM='yes';          _DEBUG_LM='yes';
256          _DEBUG_KEEP_FILES='yes';          _DEBUG_KEEP_FILES='yes';
257          _DEBUG_PRINT_PARAMS='yes';          _DEBUG_PRINT_PARAMS='yes';
258          _DEBUG_PRINT_SHELL='yes';          _DEBUG_PRINT_SHELL='yes';
259          _DEBUG_PRINT_TMPDIR='yes';          _DEBUG_PRINT_TMPDIR='yes';
260          _DEBUG_USER_WITH_STACK='yes';          _DEBUG_PRINT_FILENAMES='yes';
261            _DEBUG_PRINT_FILENAMES='yes';
262            ;;
263          --debug-filenames)
264            _DEBUG_PRINT_FILENAMES='yes';
265          ;;          ;;
266          --debug-func)
267            _DEBUG_FUNC_CHECK='yes';
268            ;;
269          --debug-not-func)
270            _DEBUG_FUNC_CHECK='no';
271            _DEBUG_STACKS='no';
272            _DEBUG_USER_WITH_STACK='no';
273            ;;
274        --debug-keep)        --debug-keep)
275          _DEBUG_PRINT_TMPDIR='yes';          _DEBUG_PRINT_TMPDIR='yes';
276          _DEBUG_KEEP_FILES='yes';          _DEBUG_KEEP_FILES='yes';
# Line 220  EOF Line 300  EOF
300    ;;    ;;
301  esac;  esac;
302    
303    if test _"${_DEBUG_STACKS}"_ = _yes_ || \
304       test _"${_DEBUG_USER_WITH_STACK}"_ = _yes_
305    then
306      _DEBUG_FUNC_CHECK='yes';
307    fi
308    
309  if test _"${_DEBUG_PRINT_PARAMS}"_ = _yes_  if test _"${_DEBUG_PRINT_PARAMS}"_ = _yes_
310  then  then
311    echo "parameters: $@" >&2;    echo "parameters: $@" >&2;
# Line 245  fi; Line 331  fi;
331  #                       Environment Variables  #                       Environment Variables
332  ########################################################################  ########################################################################
333    
334    landmark "1: environment variables";
335    
336  # Environment variables that exist only for this file start with an  # Environment variables that exist only for this file start with an
337  # underscore letter.  Global variables to this file are written in  # underscore letter.  Global variables to this file are written in
338  # upper case letters, e.g. $_GLOBAL_VARIABLE; temporary variables  # upper case letters, e.g. $_GLOBAL_VARIABLE; temporary variables
# Line 298  return_var="func_pop; return"; # add num Line 386  return_var="func_pop; return"; # add num
386    
387    
388  export _DEFAULT_MODES;  export _DEFAULT_MODES;
389  _DEFAULT_MODES='x,ps,tty';  _DEFAULT_MODES="'x' 'ps' 'tty'";
390  export _DEFAULT_RESOLUTION;  export _DEFAULT_RESOLUTION;
391  _DEFAULT_RESOLUTION='75';  _DEFAULT_RESOLUTION='75';
392    
# Line 313  export _VIEWER_HTML_X;         # viewer program Line 401  export _VIEWER_HTML_X;         # viewer program
401  export _VIEWER_PDF;             # viewer program for pdf mode  export _VIEWER_PDF;             # viewer program for pdf mode
402  export _VIEWER_PS;              # viewer program for ps mode  export _VIEWER_PS;              # viewer program for ps mode
403  export _VIEWER_X;               # viewer program for X mode  export _VIEWER_X;               # viewer program for X mode
404  _VIEWER_DVI='kdvi,xdvi,dvilx';  _VIEWER_DVI="'kdvi' 'xdvi' 'dvilx'";
405  _VIEWER_HTML_TTY='lynx';  _VIEWER_HTML_TTY="'lynx' 'w3m'";
406  _VIEWER_HTML_X='konqueror,mozilla,netscape,galeon,opera,amaya,arena';  _VIEWER_HTML_X="'konqueror' 'mozilla' 'netscape' 'galeon' 'opera' \
407  _VIEWER_PDF='kghostview --scale 1.45,ggv,xpdf,acroread,kpdf';  'amaya' 'arena'";
408  _VIEWER_PS='kghostview --scale 1.45,ggv,gv,ghostview,gs_x11,gs';  _VIEWER_PDF="'kghostview --scale 1.45' 'ggv' 'xpdf' 'acroread' 'kpdf'";
409  _VIEWER_X='gxditview,xditview';  _VIEWER_PS="'kghostview --scale 1.45' 'ggv' 'gv' 'ghostview' 'gs_x11,gs'";
410    _VIEWER_X="'gxditview' 'xditview'";
411    
412  # Search automatically in standard sections `1' to `8', and in the  # Search automatically in standard sections `1' to `8', and in the
413  # traditional sections `9', `n', and `o'.  On many systems, there  # traditional sections `9', `n', and `o'.  On many systems, there
# Line 387  _OPTS_GROFFER_SHORT_ARG="'T'"; Line 476  _OPTS_GROFFER_SHORT_ARG="'T'";
476    
477  _OPTS_GROFFER_LONG_NA="'auto' \  _OPTS_GROFFER_LONG_NA="'auto' \
478  'apropos' 'apropos-data' 'apropos-devel' 'apropos-progs' \  'apropos' 'apropos-data' 'apropos-devel' 'apropos-progs' \
479  'debug' 'debug-all' 'debug-keep' 'debug-lm' 'debug-params' 'debug-shell' \  'debug' 'debug-all' 'debug-filenames' \
480  'debug-stacks' 'debug-tmpdir' 'debug-user' 'default' 'do-nothing' 'dvi' \  'debug-func' 'debug-not-func' 'debug-keep' 'debug-lm' \
481  'groff' 'help' 'intermediate-output' 'html' 'man' \  'debug-params' 'debug-shell' 'debug-stacks' 'debug-tmpdir' 'debug-user' \
482  'no-location' 'no-man' 'no-special' 'pdf' 'ps' 'rv' 'source' \  'default' 'do-nothing' 'dvi' 'groff' 'help' 'intermediate-output' 'html' \
483  'text' 'text-device' \  'man' 'no-location' 'no-man' 'no-special' 'pdf' 'ps' 'rv' 'source' \
484  'tty' 'tty-device' 'version' 'whatis' 'where' 'www' 'x' 'X'";  'text' 'text-device' 'tty' 'tty-device' \
485    'version' 'whatis' 'where' 'www' 'x' 'X'";
486    
487  _OPTS_GROFFER_LONG_ARG="\  _OPTS_GROFFER_LONG_ARG="\
488  'default-modes' 'device' 'dvi-viewer' 'dvi-viewer-tty' 'extension' 'fg' \  'default-modes' 'device' 'dvi-viewer' 'dvi-viewer-tty' 'extension' 'fg' \
# Line 468  export _ADDOPTS_POST;          # Transp. options Line 558  export _ADDOPTS_POST;          # Transp. options
558  export _ADDOPTS_X;              # Transp. options X postproc (`eval').  export _ADDOPTS_X;              # Transp. options X postproc (`eval').
559  export _APROPOS_PROG;           # Program to run apropos.  export _APROPOS_PROG;           # Program to run apropos.
560  export _APROPOS_SECTIONS;       # Sections for different --apropos-*.  export _APROPOS_SECTIONS;       # Sections for different --apropos-*.
 export _DEFAULT_MODES;          # Set default modes.  
561  export _DISPLAY_MODE;           # Display mode.  export _DISPLAY_MODE;           # Display mode.
562  export _DISPLAY_PROG;           # Viewer program to be used for display.  export _DISPLAY_PROG;           # Viewer program to be used for display.
563  export _DISPLAY_ARGS;           # X resources for the viewer program.  export _DISPLAY_ARGS;           # X resources for the viewer program.
# Line 476  export _FILEARGS;              # Stores filespec par Line 565  export _FILEARGS;              # Stores filespec par
565  export _FILESPEC_ARG;           # Stores the actual filespec parameter.  export _FILESPEC_ARG;           # Stores the actual filespec parameter.
566  export _FUNC_STACK;             # Store debugging information.  export _FUNC_STACK;             # Store debugging information.
567  export _REGISTERED_TITLE;       # Processed file names.  export _REGISTERED_TITLE;       # Processed file names.
 # _HAS_* from availability tests  
 export _HAS_COMPRESSION;        # `yes' if gzip compression is available  
 export _HAS_BZIP;               # `yes' if bzip2 compression is available  
568  # _MAN_* finally used configuration of man searching  # _MAN_* finally used configuration of man searching
569  export _MAN_ALL;                # search all man pages per filespec  export _MAN_ALL;                # search all man pages per filespec
570  export _MAN_ENABLE;             # enable search for man pages  export _MAN_ENABLE;             # enable search for man pages
# Line 487  export _MAN_FORCE;             # force file paramet Line 573  export _MAN_FORCE;             # force file paramet
573  export _MAN_IS_SETUP;           # setup man variables only once  export _MAN_IS_SETUP;           # setup man variables only once
574  export _MAN_LANG;               # language for man pages  export _MAN_LANG;               # language for man pages
575  export _MAN_LANG2;              # language for man pages  export _MAN_LANG2;              # language for man pages
576  export _MAN_LANG_DONE;          # language dirs added to man path  export _MAN_PATH;               # search path for man pages as a list
 export _MAN_PATH;               # search path for man pages  
577  export _MAN_SEC;                # sections for man pages; sep. `:'  export _MAN_SEC;                # sections for man pages; sep. `:'
578  export _MAN_SEC_DONE;           # sections added to man path  export _MAN_SYS;                # system names for man pages as a list
 export _MAN_SYS;                # system names for man pages; sep. `,'  
 export _MAN_SYS;                # system names added to man path  
579  # _MANOPT_* as parsed from $MANOPT  # _MANOPT_* as parsed from $MANOPT
580  export _MANOPT_ALL;             # $MANOPT --all  export _MANOPT_ALL;             # $MANOPT --all
581  export _MANOPT_EXTENSION;       # $MANOPT --extension  export _MANOPT_EXTENSION;       # $MANOPT --extension
# Line 528  export _OPT_TITLE;             # title for gxditvie Line 611  export _OPT_TITLE;             # title for gxditvie
611  export _OPT_TEXT_DEVICE;        # set device for tty mode.  export _OPT_TEXT_DEVICE;        # set device for tty mode.
612  export _OPT_V;                  # groff option -V.  export _OPT_V;                  # groff option -V.
613  export _OPT_VIEWER_DVI;         # viewer program for dvi mode  export _OPT_VIEWER_DVI;         # viewer program for dvi mode
614    export _OPT_VIEWER_DVI_TTY;     # viewer program for dvi mode not in X
615    export _OPT_VIEWER_HTML;        # viewer program for html mode
616    export _OPT_VIEWER_HTML_TTY;    # viewer program for html mode not in X
617  export _OPT_VIEWER_PDF;         # viewer program for pdf mode  export _OPT_VIEWER_PDF;         # viewer program for pdf mode
618    export _OPT_VIEWER_PDF_TTY;     # viewer program for pdf mode not in X
619  export _OPT_VIEWER_PS;          # viewer program for ps mode  export _OPT_VIEWER_PS;          # viewer program for ps mode
620  export _OPT_VIEWER_HTML;        # viewer program for html mode  export _OPT_VIEWER_PS_TTY;      # viewer program for ps mode not in X
621  export _OPT_VIEWER_X;           # viewer program for x mode  export _OPT_VIEWER_X;           # viewer program for x mode
622    export _OPT_VIEWER_X_TTY;       # viewer program for x mode not in X
623  export _OPT_WHATIS;             # print the man description  export _OPT_WHATIS;             # print the man description
624  export _OPT_XRM;                # specify X resource.  export _OPT_XRM;                # specify X resource.
625  export _OPT_Z;                  # groff option -Z.  export _OPT_Z;                  # groff option -Z.
# Line 540  export _VIEWER_TERMINAL;       # viewer option Line 628  export _VIEWER_TERMINAL;       # viewer option
628  # _TMP_* temporary directory and files  # _TMP_* temporary directory and files
629  export _TMP_DIR;                # groffer directory for temporary files  export _TMP_DIR;                # groffer directory for temporary files
630  export _TMP_CAT;                # stores concatenation of everything  export _TMP_CAT;                # stores concatenation of everything
631    export _TMP_MAN;                # stores find of man path
632    export _TMP_MANSPEC;            # filters man pages with filespec
633  export _TMP_STDIN;              # stores stdin, if any  export _TMP_STDIN;              # stores stdin, if any
634    
635  # these variables are preset in section `Preset' after the rudim. test  # these variables are preset in section `Preset' after the rudim. test
# Line 557  _START_DIR="$(pwd)"; Line 647  _START_DIR="$(pwd)";
647    
648  _FILEARGS='';  _FILEARGS='';
649    
 # _HAS_* from availability tests  
 _HAS_COMPRESSION='';  
 _HAS_BZIP='';  
   
650  # _TMP_* temporary files  # _TMP_* temporary files
651  _TMP_DIR='';  _TMP_DIR='';
652  _TMP_CAT='';  _TMP_CAT='';
653    _TMP_MAN='';
654  _TMP_CONF='';  _TMP_CONF='';
655  _TMP_STDIN='';  _TMP_STDIN='';
656    
# Line 600  reset() Line 687  reset()
687    _MAN_LANG2='';    _MAN_LANG2='';
688    _MAN_PATH='';    _MAN_PATH='';
689    _MAN_SEC='';    _MAN_SEC='';
   _MAN_SEC_DONE='no';  
690    _MAN_SYS='';    _MAN_SYS='';
   _MAN_SYS_DONE='no';  
691    
692    # _MANOPT_* as parsed from $MANOPT    # _MANOPT_* as parsed from $MANOPT
693    _MANOPT_ALL='no';    _MANOPT_ALL='no';
# Line 644  reset() Line 729  reset()
729    _OPT_VIEWER_PS='';    _OPT_VIEWER_PS='';
730    _OPT_VIEWER_HTML='';    _OPT_VIEWER_HTML='';
731    _OPT_VIEWER_X='';    _OPT_VIEWER_X='';
732      _OPT_VIEWER_DVI_TTY='';
733      _OPT_VIEWER_PDF_TTY='';
734      _OPT_VIEWER_PS_TTY='';
735      _OPT_VIEWER_HTML_TTY='';
736      _OPT_VIEWER_X_TTY='';
737    _OPT_WHATIS='no';    _OPT_WHATIS='no';
738    _OPT_XRM='';    _OPT_XRM='';
739    _OPT_Z='no';    _OPT_Z='no';
# Line 654  reset; Line 744  reset;
744    
745    
746  ########################################################################  ########################################################################
747  #          Functions for error handling and debugging  #              Preliminary functions for error handling
748  ########################################################################  ########################################################################
749    
750    landmark "2: preliminary functions";
751    
752    # These functions do not have a func-check frame.  Basically they could be
753    # moved to the functions in alphabetical order.
754    
755  ##############  ##############
756  # echo1 (<text>*)  # echo1 (<text>*)
# Line 670  echo1() Line 764  echo1()
764    cat <<EOF    cat <<EOF
765  $@  $@
766  EOF  EOF
767  }  } # echo1()
768    
769    
770  ##############  ##############
# Line 685  echo2() Line 779  echo2()
779    cat >&2 <<EOF    cat >&2 <<EOF
780  $@  $@
781  EOF  EOF
782  }  } # echo2()
783    
784    
 ##############  
 # landmark (<text>)  
 #  
 # Print <text> to standard error as a debugging aid.  
 #  
 # Globals: $_DEBUG_LM  
 #  
 landmark()  
 {  
   if test _"${_DEBUG_LM}"_ = _yes_  
   then  
     echo2 "LM: $*";  
   fi;  
 }  
   
 landmark "1: debugging functions";  
785    
786    
787  ##############  ##############
# Line 726  clean_up() Line 804  clean_up()
804        fi;        fi;
805      fi;      fi;
806    fi;    fi;
807  }  } # clean_up()
808    
809    
810  #############  #############
# Line 737  clean_up() Line 815  clean_up()
815  diag()  diag()
816  {  {
817    echo2 '>>>>>'"$*";    echo2 '>>>>>'"$*";
818  }  } # diag()
819    
820    
821  #############  #############
# Line 759  error() Line 837  error()
837      : >"${_TMP_DIR}"/,error;      : >"${_TMP_DIR}"/,error;
838    fi;    fi;
839    exit "${_ERROR}";    exit "${_ERROR}";
840  }  } # error()
841    
842    
843  #############  #############
# Line 788  error_user() Line 866  error_user()
866      : >"${_TMP_DIR}"/,error;      : >"${_TMP_DIR}"/,error;
867    fi;    fi;
868    exit "${_ERROR}";    exit "${_ERROR}";
869  }  } # error_user()
870    
871    
872    
873  #############  #############
# Line 808  exit_test() Line 887  exit_test()
887    then    then
888      exit ${_ERROR};      exit ${_ERROR};
889    fi;    fi;
890  }  } # exit_test()
   
   
 #############  
 # func_check (<func_name> <rel_op> <nr_args> "$@")  
 #  
 # Check number of arguments and register to _FUNC_STACK.  
 #  
 # Arguments: >=3  
 #   <func_name>: name of the calling function.  
 #   <rel_op>:    a relational operator: = != < > <= >=  
 #   <nr_args>:   number of arguments to be checked against <operator>  
 #   "$@":        the arguments of the calling function.  
 #  
 # Variable prefix: fc  
 #  
 func_check()  
 {  
   if test "$#" -lt 3  
   then  
     error 'func_check() needs at least 3 arguments.';  
   fi;  
   fc_fname="$1";  
   case "$3" in  
     1)  
       fc_nargs="$3";  
       fc_s='';  
       ;;  
     0|[2-9])  
       fc_nargs="$3";  
       fc_s='s';  
       ;;  
     *)  
       error "func_check(): third argument must be a digit.";  
       ;;  
   esac;  
   case "$2" in  
     '='|'-eq')  
       fc_op='-eq';  
       fc_comp='exactly';  
       ;;  
     '>='|'-ge')  
       fc_op='-ge';  
       fc_comp='at least';  
       ;;  
     '<='|'-le')  
       fc_op='-le';  
       fc_comp='at most';  
       ;;  
     '<'|'-lt')  
       fc_op='-lt';  
       fc_comp='less than';  
       ;;  
     '>'|'-gt')  
       fc_op='-gt';  
       fc_comp='more than';  
       ;;  
     '!='|'-ne')  
       fc_op='-ne';  
       fc_comp='not';  
       ;;  
     *)  
       error \  
         'func_check(): second argument is not a relational operator.';  
       ;;  
   esac;  
   shift;  
   shift;  
   shift;  
   if test "$#" "${fc_op}" "${fc_nargs}"  
   then  
     do_nothing;  
   else  
     error "func_check(): \  
 ${fc_fname}"'() needs '"${fc_comp} ${fc_nargs}"' argument'"${fc_s}"'.';  
   fi;  
   func_push "${fc_fname}";  
   if test _"${_DEBUG_STACKS}"_ = _yes_  
   then  
     echo2 '+++ '"${fc_fname} $@";  
     echo2 '>>> '"${_FUNC_STACK}";  
   fi;  
   eval ${_UNSET} fc_comp;  
   eval ${_UNSET} fc_fname;  
   eval ${_UNSET} fc_nargs;  
   eval ${_UNSET} fc_op;  
   eval ${_UNSET} fc_s;  
 }  
   
   
 #############  
 # func_pop ()  
 #  
 # Retrieve the top element from the stack.  
 #  
 # The stack elements are separated by `!'; the popped element is  
 # identical to the original element, except that all `!' characters  
 # were removed.  
 #  
 # Arguments: 1  
 #  
 func_pop()  
 {  
   if test "$#" -ne 0  
   then  
     error 'func_pop() does not have arguments.';  
   fi;  
   case "${_FUNC_STACK}" in  
   '')  
     if test _"${_DEBUG_STACKS}"_ = _yes_  
     then  
       error 'func_pop(): stack is empty.';  
     fi;  
     ;;  
   *!*)  
     # split at first bang `!'.  
     _FUNC_STACK="$(echo1 "${_FUNC_STACK}" | sed -e 's/^[^!]*!//')";  
     exit_test;  
     ;;  
   *)  
     _FUNC_STACK='';  
     ;;  
   esac;  
   if test _"${_DEBUG_STACKS}"_ = _yes_  
   then  
     echo2 '<<< '"${_FUNC_STACK}";  
   fi;  
 }  
   
   
 #############  
 # func_push (<element>)  
 #  
 # Store another element to stack.  
 #  
 # The stack elements are separated by `!'; if <element> contains a `!'  
 # it is removed first.  
 #  
 # Arguments: 1  
 #  
 # Variable prefix: fp  
 #  
 func_push()  
 {  
   if test "$#" -ne 1  
   then  
     error 'func_push() needs 1 argument.';  
   fi;  
   case "$1" in  
   *'!'*)  
     # remove all bangs `!'.  
     fp_element="$(echo1 "$1" | sed -e 's/!//g')";  
     exit_test;  
     ;;  
   *)  
     fp_element="$1";  
     ;;  
   esac;  
   if test _"${_FUNC_STACK}"_ = __  
   then  
     _FUNC_STACK="${fp_element}";  
   else  
     _FUNC_STACK="${fp_element}!${_FUNC_STACK}";  
   fi;  
   eval ${_UNSET} fp_element;  
 }  
   
   
 #############  
 # func_stack_dump ()  
 #  
 # Print the content of the stack.  Ignore the arguments.  
 #  
 func_stack_dump()  
 {  
   diag 'call stack: '"${_FUNC_STACK}";  
 }  
   
   
 ########################################################################  
 #                        System Test  
 ########################################################################  
   
 landmark "2: system test";  
   
 # Test the availability of the system utilities used in this script.  
   
   
 ########################################################################  
 # Test of function `sed'.  
 #  
   
 if test _"$(echo xTesTx \  
            | sed -e 's/^.\([Tt]e*x*sTT*\).*$/\1/' \  
            | sed -e 's|T|t|g')"_ != _test_  
 then  
   error 'Test of "sed" command failed.';  
 fi;  
   
   
 ########################################################################  
 # Test of function `cat'.  
 #  
 if test _"$(echo test | cat)"_ != _test_  
 then  
   error 'Test of "cat" command failed.';  
 fi;  
   
   
 ########################################################################  
 # Test for compression.  
 #  
 if test _"$(echo 'test' | gzip -c -d -f - 2>${_NULL_DEV})"_ = _test_  
 then  
   _HAS_COMPRESSION='yes';  
   if echo1 'test' | bzip2 -c 2>${_NULL_DEV} | bzip2 -t 2>${_NULL_DEV} \  
      && test _"$(echo 'test' | bzip2 -c 2>${_NULL_DEV} \  
                              | bzip2 -d -c 2>${_NULL_DEV})"_ \  
              = _test_  
   then  
     _HAS_BZIP='yes';  
   else  
     _HAS_BZIP='no';  
   fi;  
 else  
   _HAS_COMPRESSION='no';  
   _HAS_BZIP='no';  
 fi;  
891    
892    
893  ########################################################################  ########################################################################
894  #       Definition of normal Functions in alphabetical order  #       Definition of normal Functions in alphabetical order
895  ########################################################################  ########################################################################
896    
897  landmark "3: functions";  landmark "3: functions";
898    
899  ########################################################################  ########################################################################
# Line 1237  dirname_append() Line 1090  dirname_append()
1090    func_check dirname_append = 2 "$@";    func_check dirname_append = 2 "$@";
1091    if is_empty "$1"    if is_empty "$1"
1092    then    then
1093      error "dir_append(): first argument is empty.";      error "dirname_append(): first argument is empty.";
1094    fi;    fi;
1095    if is_empty "$2"    if is_empty "$2"
1096    then    then
# Line 1434  do_nothing() Line 1287  do_nothing()
1287  # defined above  # defined above
1288    
1289    
1290  ########################################################################  if test _"${_DEBUG_FUNC_CHECK}"_ = _yes_
1291  # func_check (<func_name> <rel_op> <nr_args> "$@")  then
 #  
 # Check number of arguments and register to _FUNC_STACK.  
 #  
 # Arguments: >=3  
 #   <func_name>: name of the calling function.  
 #   <rel_op>:    a relational operator: = != < > <= >=  
 #   <nr_args>:   number of arguments to be checked against <operator>  
 #   "$@":        the arguments of the calling function.  
 #  
 # defined above  
1292    
1293  #########################################################################    #############
1294  # func_pop ()    # func_check (<func_name> <rel_op> <nr_args> "$@")
1295  #    #
1296  # Delete the top element from the function call stack.    # Check number of arguments and register to _FUNC_STACK.
1297  #    #
1298  # defined above    # Arguments: >=3
1299      #   <func_name>: name of the calling function.
1300      #   <rel_op>:    a relational operator: = != < > <= >=
1301      #   <nr_args>:   number of arguments to be checked against <operator>
1302      #   "$@":        the arguments of the calling function.
1303      #
1304      # Variable prefix: fc
1305      #
1306      func_check()
1307      {
1308        if test "$#" -lt 3
1309        then
1310          error 'func_check() needs at least 3 arguments.';
1311        fi;
1312        fc_fname="$1";
1313        case "$3" in
1314        1)
1315          fc_nargs="$3";
1316          fc_s='';
1317          ;;
1318        0|[2-9])
1319          fc_nargs="$3";
1320          fc_s='s';
1321          ;;
1322        *)
1323          error "func_check(): third argument must be a digit.";
1324          ;;
1325        esac;
1326        case "$2" in
1327        '='|'-eq')
1328          fc_op='-eq';
1329          fc_comp='exactly';
1330          ;;
1331        '>='|'-ge')
1332          fc_op='-ge';
1333          fc_comp='at least';
1334          ;;
1335        '<='|'-le')
1336          fc_op='-le';
1337          fc_comp='at most';
1338          ;;
1339        '<'|'-lt')
1340          fc_op='-lt';
1341          fc_comp='less than';
1342          ;;
1343        '>'|'-gt')
1344          fc_op='-gt';
1345          fc_comp='more than';
1346          ;;
1347        '!='|'-ne')
1348          fc_op='-ne';
1349          fc_comp='not';
1350          ;;
1351        *)
1352          error \
1353            'func_check(): second argument is not a relational operator.';
1354          ;;
1355        esac;
1356        shift;
1357        shift;
1358        shift;
1359        if test "$#" "${fc_op}" "${fc_nargs}"
1360        then
1361          do_nothing;
1362        else
1363          error "func_check(): \
1364    ${fc_fname}"'() needs '"${fc_comp} ${fc_nargs}"' argument'"${fc_s}"'.';
1365        fi;
1366        func_push "${fc_fname}";
1367        if test _"${_DEBUG_STACKS}"_ = _yes_
1368        then
1369          echo2 '+++ '"${fc_fname} $@";
1370          echo2 '>>> '"${_FUNC_STACK}";
1371        fi;
1372        eval ${_UNSET} fc_comp;
1373        eval ${_UNSET} fc_fname;
1374        eval ${_UNSET} fc_nargs;
1375        eval ${_UNSET} fc_op;
1376        eval ${_UNSET} fc_s;
1377      } # func_check()
1378    
1379    
1380      #############
1381      # func_pop ()
1382      #
1383      # Retrieve the top element from the stack.
1384      #
1385      # The stack elements are separated by `!'; the popped element is
1386      # identical to the original element, except that all `!' characters
1387      # were removed.
1388      #
1389      # Arguments: 1
1390      #
1391      func_pop()
1392      {
1393        if test "$#" -ne 0
1394        then
1395          error 'func_pop() does not have arguments.';
1396        fi;
1397        case "${_FUNC_STACK}" in
1398        '')
1399          if test _"${_DEBUG_STACKS}"_ = _yes_
1400          then
1401            error 'func_pop(): stack is empty.';
1402          fi;
1403          ;;
1404        *!*)
1405          # split at first bang `!'.
1406          _FUNC_STACK="$(echo1 "${_FUNC_STACK}" | sed -e 's/^[^!]*!//')";
1407          exit_test;
1408          ;;
1409        *)
1410          _FUNC_STACK='';
1411          ;;
1412        esac;
1413        if test _"${_DEBUG_STACKS}"_ = _yes_
1414        then
1415          echo2 '<<< '"${_FUNC_STACK}";
1416        fi;
1417      } # func_pop()
1418    
1419    
1420  ########################################################################    #############
1421  # func_push (<element>)    # func_push (<element>)
1422  #    #
1423  # Store another element to function call stack.    # Store another element to stack.
1424  #    #
1425  # defined above    # The stack elements are separated by `!'; if <element> contains a `!'
1426      # it is removed first.
1427      #
1428      # Arguments: 1
1429      #
1430      # Variable prefix: fp
1431      #
1432      func_push()
1433      {
1434        if test "$#" -ne 1
1435        then
1436          error 'func_push() needs 1 argument.';
1437        fi;
1438        case "$1" in
1439        *'!'*)
1440          # remove all bangs `!'.
1441          fp_element="$(echo1 "$1" | sed -e 's/!//g')";
1442          exit_test;
1443          ;;
1444        *)
1445          fp_element="$1";
1446          ;;
1447        esac;
1448        if test _"${_FUNC_STACK}"_ = __
1449        then
1450          _FUNC_STACK="${fp_element}";
1451        else
1452          _FUNC_STACK="${fp_element}!${_FUNC_STACK}";
1453        fi;
1454        eval ${_UNSET} fp_element;
1455      } # func_push()
1456    
1457    
1458  ########################################################################    #############
1459  # func_stack_dump ()    # func_stack_dump ()
1460  #    #
1461  # Print the content of the stack.    # Print the content of the stack.  Ignore the arguments.
1462  #    #
1463  # defined above    func_stack_dump()
1464      {
1465        diag 'call stack: '"${_FUNC_STACK}";
1466      } # func_stack_dump()
1467    
1468    else
1469    
1470      func_check() { return; }
1471      func_pop() { return; }
1472      func_push() { return; }
1473      func_stack_dump() { return; }
1474    
1475    fi;
1476    
1477    
1478  ########################################################################  ########################################################################
# Line 1518  landmark '5: is_*()'; Line 1522  landmark '5: is_*()';
1522  is_dir()  is_dir()
1523  {  {
1524    func_check is_dir '=' 1 "$@";    func_check is_dir '=' 1 "$@";
1525    if test _"$1"_ != __ && test -d "$1" && test -r "$1"    if is_not_empty "$1" && test -d "$1" && test -r "$1"
1526    then    then
1527      eval "${return_yes}";      eval "${return_yes}";
1528    fi;    fi;
# Line 1576  is_equal() Line 1580  is_equal()
1580  is_existing()  is_existing()
1581  {  {
1582    func_check is_existing '=' 1 "$@";    func_check is_existing '=' 1 "$@";
1583    if test _"$1"_ = __    if is_empty "$1"
1584    then    then
1585      eval "${return_no}";      eval "${return_no}";
1586    fi;    fi;
# Line 1608  is_file() Line 1612  is_file()
1612    
1613    
1614  ########################################################################  ########################################################################
1615    # is_greater_than (<string1> <string2>)
1616    #
1617    # Test whether `string1' is greater than <string2>.
1618    #
1619    # Arguments : 2
1620    # Return    : `0' if <string1> is a greater integer than <string2>,
1621    #             `1' otherwise.
1622    #
1623    is_greater_than()
1624    {
1625      func_check is_greater_than '=' 2 "$@";
1626      if is_integer "$1" && is_integer "$2" && test "$1" -gt "$2"
1627      then
1628        eval "${return_yes}";
1629      fi;
1630      eval "${return_no}";
1631    }
1632    
1633    
1634    ########################################################################
1635    # is_integer (<string>)
1636    #
1637    # Test whether `string' is an integer.
1638    #
1639    # Arguments : 1
1640    # Return    : `0' if argument is an integer, `1' otherwise.
1641    #
1642    is_integer()
1643    {
1644      func_check is_integer '=' 1 "$@";
1645      if is_equal "$(echo1 "$1" | sed -n -e '
1646    s/^[0-9][0-9]*$/ok/p
1647    s/^[-+][0-9][0-9]*$/ok/p
1648    ')" 'ok'
1649      then
1650        eval "${return_yes}";
1651      fi;
1652      eval "${return_no}";
1653    }
1654    
1655    
1656    ########################################################################
1657  # is_non_empty_file (<file_name>)  # is_non_empty_file (<file_name>)
1658  #  #
1659  # Test whether `file_name' is a non-empty existing file.  # Test whether `file_name' is a non-empty existing file.
# Line 1753  is_not_writable() Line 1799  is_not_writable()
1799  #  #
1800  is_not_X()  is_not_X()
1801  {  {
1802    func_check is_X '=' 0 "$@";    func_check is_not_X '=' 0 "$@";
1803    if obj DISPLAY is_empty    if obj DISPLAY is_empty
1804    then    then
1805      eval "${return_yes}";      eval "${return_yes}";
# Line 1816  is_prog() Line 1862  is_prog()
1862  is_writable()  is_writable()
1863  {  {
1864    func_check is_writable '>=' 1 "$@";    func_check is_writable '>=' 1 "$@";
1865    if test _"$1"_ = __    if is_empty "$1"
1866    then    then
1867      eval "${return_no}";      eval "${return_no}";
1868    fi;    fi;
# Line 1919  list_append() Line 1965  list_append()
1965  {  {
1966    func_check list_append '>=' 2 "$@";    func_check list_append '>=' 2 "$@";
1967    la_name="$1";    la_name="$1";
1968    eval la_list='"${'$1'}"';    eval la_list='"${'"$1"'}"';
1969    shift;    shift;
1970    for s    for s
1971    do    do
# Line 1998  list_append() Line 2044  list_append()
2044  list_from_cmdline()  list_from_cmdline()
2045  {  {
2046    func_check list_from_cmdline '>=' 1 "$@";    func_check list_from_cmdline '>=' 1 "$@";
2047    lfc_short_n="$(obj_data "$1"_SHORT_NA)";  # short options, no argument    # short options, no argument
2048    lfc_short_a="$(obj_data "$1"_SHORT_ARG)"; # short options, with argument    obj_from_output lfc_short_n obj_data "$1"_SHORT_NA;
2049    lfc_long_n="$(obj_data "$1"_LONG_NA)";    # long options, no argument    # short options, with argument
2050    lfc_long_a="$(obj_data "$1"_LONG_ARG)";   # long options, with argument    obj_from_output lfc_short_a obj_data "$1"_SHORT_ARG;
2051    exit_test;    # long options, no argument
2052      obj_from_output lfc_long_n obj_data "$1"_LONG_NA;
2053      # long options, with argument
2054      obj_from_output lfc_long_a obj_data "$1"_LONG_ARG;
2055    if obj lfc_short_n is_empty    if obj lfc_short_n is_empty
2056    then    then
2057      error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.';      error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.';
# Line 2035  list_from_cmdline() Line 2084  list_from_cmdline()
2084    
2085    lfc_fparams='';    lfc_fparams='';
2086    lfc_result='';    lfc_result='';
2087    while test "$#" -ge 1    while is_greater_than "$#" 0
2088    do    do
2089      lfc_arg="$1";      lfc_arg="$1";
2090      shift;      shift;
# Line 2048  list_from_cmdline() Line 2097  list_from_cmdline()
2097        # extract option by deleting from the first '=' to the end        # extract option by deleting from the first '=' to the end
2098        lfc_abbrev="$(echo1 "${lfc_with_equal}" | \        lfc_abbrev="$(echo1 "${lfc_with_equal}" | \
2099                      sed -e 's/^\([^=]*\)=.*$/\1/')";                      sed -e 's/^\([^=]*\)=.*$/\1/')";
2100        lfc_opt="$(list_single_from_abbrev lfc_long_a "${lfc_abbrev}")";        obj_from_output lfc_opt \
2101        exit_test;          list_single_from_abbrev lfc_long_a "${lfc_abbrev}";
2102        if obj lfc_opt is_empty        if obj lfc_opt is_empty
2103        then        then
2104          error_user "--${lfc_abbrev} is not an option.";          error_user "--${lfc_abbrev} is not an option.";
# Line 2068  list_from_cmdline() Line 2117  list_from_cmdline()
2117        then        then
2118          lfc_opt="${lfc_abbrev}";          lfc_opt="${lfc_abbrev}";
2119        else        else
2120          exit_test;          obj_from_output lfc_opt \
2121          lfc_opt="$(list_single_from_abbrev lfc_long_n "${lfc_abbrev}")";            list_single_from_abbrev lfc_long_n "${lfc_abbrev}";
         exit_test;  
2122          if obj lfc_opt is_not_empty && is_not_equal "$#" 0          if obj lfc_opt is_not_empty && is_not_equal "$#" 0
2123          then          then
2124            a="$(list_single_from_abbrev lfc_long_a "${lfc_abbrev}")";            obj_from_output a \
2125            exit_test;              list_single_from_abbrev lfc_long_a "${lfc_abbrev}";
2126            if obj a is_not_empty            if obj a is_not_empty
2127            then            then
2128              error_user "The abbreviation ${lfc_arg} \              error_user "The abbreviation ${lfc_arg} \
# Line 2088  has multiple options: --${lfc_opt} and - Line 2136  has multiple options: --${lfc_opt} and -
2136          list_append lfc_result "--${lfc_opt}";          list_append lfc_result "--${lfc_opt}";
2137          continue;          continue;
2138        fi;        fi;
2139        lfc_opt="$(list_single_from_abbrev lfc_long_a "${lfc_abbrev}")";        obj_from_output lfc_opt \
2140        exit_test;          list_single_from_abbrev lfc_long_a "${lfc_abbrev}";
2141        if obj lfc_opt is_not_empty        if obj lfc_opt is_not_empty
2142        then        then
2143          # long option with argument          # long option with argument
2144          if test "$#" -le 0          if is_equal "$#" 0
2145          then          then
2146            error_user "no argument for option --${lfc_opt}."            error_user "no argument for option --${lfc_opt}."
2147          fi;          fi;
# Line 2122  has multiple options: --${lfc_opt} and - Line 2170  has multiple options: --${lfc_opt} and -
2170          then          then
2171            if obj lfc_rest is_empty            if obj lfc_rest is_empty
2172            then            then
2173              if test "$#" -ge 1              if is_greater_than "$#" 0
2174              then              then
2175                list_append lfc_result "-${lfc_optchar}" "$1";                list_append lfc_result "-${lfc_optchar}" "$1";
2176                shift;                shift;
# Line 2157  has multiple options: --${lfc_opt} and - Line 2205  has multiple options: --${lfc_opt} and -
2205    then    then
2206      lfc_result="${lfc_result} ${lfc_fparams}";      lfc_result="${lfc_result} ${lfc_fparams}";
2207    fi;    fi;
2208    if test "$#" -gt 0    if is_greater_than "$#" 0
2209    then    then
2210      list_append lfc_result "$@";      list_append lfc_result "$@";
2211    fi;    fi;
# Line 2194  has multiple options: --${lfc_opt} and - Line 2242  has multiple options: --${lfc_opt} and -
2242  list_from_split()  list_from_split()
2243  {  {
2244    func_check list_from_split = 2 "$@";    func_check list_from_split = 2 "$@";
2245      if is_empty "$1"
2246    # precede each space or tab by a backslash `\' (doubled for `sed')    then
2247    lfs_s="$(echo1 "$1" | sed -e 's/\('"${_SPACE_SED}"'\)/\\\1/g')";      eval "${return_ok}";
2248    exit_test;    fi;
   
   # replace split character of string by the list separator ` ' (space).  
2249    case "$2" in    case "$2" in
2250      /)                          # cannot use normal `sed' separator    ?)
2251        echo1 "${lfs_s}" | sed -e 's|'"$2"'| |g';      lfs_splitter="$2";
2252        ;;      ;;
2253      ?)                          # use normal `sed' separator    '\:')
2254        echo1 "${lfs_s}" | sed -e 's/'"$2"'/ /g';      lfs_splitter=':';
2255        ;;
2256      *)
2257        error "list_from_split: split argument $2 must be a single character.";
2258        ;;
2259      esac;
2260      lfs_list='';
2261      lfs_rest="$1";
2262      while :
2263      do
2264        case "${lfs_rest}" in
2265        *"${lfs_splitter}"*)
2266          case "${lfs_splitter}" in
2267          /)
2268            lfs_elt="$(echo1 ${lfs_rest} | sed -e \
2269              's|^\([^'"${lfs_splitter}"']*\)'"${lfs_splitter}"'.*|\1|')";
2270            lfs_rest="$(echo1 ${lfs_rest} | sed -e \
2271              's|^[^'"${lfs_splitter}"']*'"${lfs_splitter}"'\(.*\)$|\1|')";
2272            ;;
2273          *)
2274            lfs_elt="$(echo1 ${lfs_rest} | sed -e \
2275              's/^\([^'"${lfs_splitter}"']*\)'"${lfs_splitter}"'.*/\1/')";
2276            lfs_rest="$(echo1 ${lfs_rest} | sed -e \
2277              's/^[^'"${lfs_splitter}"']*'"${lfs_splitter}"'\(.*\)$/\1/')";
2278            ;;
2279          esac;
2280          list_append lfs_list "${lfs_elt}"
2281          continue;
2282        ;;        ;;
2283      ??*)      *)
2284        error 'list_from_split(): separator must be a single character.';        list_append lfs_list "${lfs_rest}"
2285          break
2286        ;;        ;;
2287    esac;      esac;
2288    eval ${_UNSET} lfs_s;    done
2289      echo1 "${lfs_list}";
2290    
2291      eval ${_UNSET} lfs_elt;
2292      eval ${_UNSET} lfs_list;
2293      eval ${_UNSET} lfs_rest;
2294      eval ${_UNSET} lfs_splitter;
2295    eval "${return_ok}";    eval "${return_ok}";
2296  }  } # list_from_split()
2297    
2298    
2299  ########################################################################  ########################################################################
# Line 2245  list_get() Line 2325  list_get()
2325  s/^'"${_SPACE_SED}"'*//  s/^'"${_SPACE_SED}"'*//
2326  s/'"${_SPACE_SED}"'*$//  s/'"${_SPACE_SED}"'*$//
2327  ')";  ')";
   exit_test;  
2328    case "${lg_list}" in    case "${lg_list}" in
2329    '')    '')
2330      eval ${_UNSET} lg_list;      eval ${_UNSET} lg_list;
# Line 2262  s/'"${_SPACE_SED}"'*$// Line 2341  s/'"${_SPACE_SED}"'*$//
2341    esac;    esac;
2342    eval ${_UNSET} lg_list;    eval ${_UNSET} lg_list;
2343    eval "${return_ok}";    eval "${return_ok}";
2344  }  } # list_get()
2345    
2346    
2347  ########################################################################  ########################################################################
# Line 2299  list_has() Line 2378  list_has()
2378      eval "${_UNSET}" lh_element;      eval "${_UNSET}" lh_element;
2379      eval "${return_no}";      eval "${return_no}";
2380    fi;    fi;
2381  }  } # list_has()
2382    
2383    
2384  ########################################################################  ########################################################################
# Line 2325  list_has_abbrev() Line 2404  list_has_abbrev()
2404    case "$2" in    case "$2" in
2405      \'*)      \'*)
2406        lha_element="$(echo1 "$2" | sed -e 's/'"${_SQ}"'$//')";        lha_element="$(echo1 "$2" | sed -e 's/'"${_SQ}"'$//')";
       exit_test;  
2407        ;;        ;;
2408      *) lha_element="'$2"; ;;      *)
2409          lha_element="'$2";
2410          ;;
2411    esac;    esac;
2412    if string_contains " ${lha_list}" " ${lha_element}"    if string_contains " ${lha_list}" " ${lha_element}"
2413    then    then
# Line 2340  list_has_abbrev() Line 2420  list_has_abbrev()
2420      eval "${return_no}";      eval "${return_no}";
2421    fi;    fi;
2422    eval "${return_ok}";    eval "${return_ok}";
2423  }  } # list_has_abbrev()
2424    
2425    
2426  ########################################################################  ########################################################################
# Line 2377  list_has_not() Line 2457  list_has_not()
2457      eval "${_UNSET}" lhn_element;      eval "${_UNSET}" lhn_element;
2458      eval "${return_yes}";      eval "${return_yes}";
2459    fi;    fi;
2460    } # list_has_not()
2461    
2462    
2463    ########################################################################
2464    # list_has_not_prog (<list_name> <prog> [<arg>...])
2465    #
2466    # Test whether the list <list_name> has neither an element <prog> nor an
2467    # element that starts with the word <prog>.
2468    #
2469    # Arguments: >=2
2470    #   <list_name>: a variable name for a list of single-quoted elements
2471    #   <prog>:      some sequence of characters.
2472    #   <arg>:       ignored
2473    #
2474    list_has_not_prog()
2475    {
2476      func_check list_has_not_prog '>=' 2 "$@";
2477      if list_has "$1" "$2" || list_has_abbrev "$1" "$2"' '
2478      then
2479        eval "${return_no}";
2480      else
2481        eval "${return_yes}";
2482      fi;
2483    }
2484    
2485    
2486    ########################################################################
2487    # list_has_prog (<list_name> <prog> [<arg>...])
2488    #
2489    # Test whether the list <list_name> has an element <prog> or an element
2490    # that starts with the word <prog>.
2491    #
2492    # Arguments: >=2
2493    #   <list_name>: a variable name for a list of single-quoted elements
2494    #   <prog>:      some sequence of characters.
2495    #   <arg>:       ignored
2496    #
2497    list_has_prog()
2498    {
2499      func_check list_has_prog '>=' 2 "$@";
2500      if list_has "$1" "$2" || list_has_abbrev "$1" "$2"' '
2501      then
2502        eval "${return_yes}";
2503      else
2504        eval "${return_no}";
2505      fi;
2506  }  }
2507    
2508    
# Line 2440  has multiple options: --${lsfa_element} Line 2566  has multiple options: --${lsfa_element}
2566      eval "${_UNSET}" lsfa_list;      eval "${_UNSET}" lsfa_list;
2567      eval "${return_no}";      eval "${return_no}";
2568    fi;    fi;
2569  }  } # list_single_from_abbrev()
2570    
2571    
2572    ########################################################################
2573    # lists_combine (<list1> <list2> ...)
2574    #
2575    # Combine several lists to a single list.  All arguments are list names.
2576    #
2577    # Output: the combined list
2578    #
2579    # Variable prefix: lc
2580    #
2581    lists_combine()
2582    {
2583      func_check lists_combine '>=' 2 "$@";
2584      lc_list='';
2585      for i
2586      do
2587        eval lc_arg='"${'"$i"'}"';
2588        case "${lc_arg}" in
2589        '') :; ;;
2590        "'"*"'")
2591          if obj lc_list is_empty
2592          then
2593            lc_list="${lc_arg}";
2594          else
2595            lc_list="${lc_list} ${lc_arg}";
2596          fi;
2597          ;;
2598        *)
2599          error 'lists_combine: $'"$i"' is not a list.';
2600          ;;
2601        esac;
2602      done;
2603      obj lc_list echo1;
2604      eval "${_UNSET}" lc_arg;
2605      eval "${_UNSET}" lc_list;
2606      eval "${return_ok}";
2607    } # lists_combine()
2608    
2609    
2610  ########################################################################  ########################################################################
# Line 2468  landmark '7: man_*()'; Line 2632  landmark '7: man_*()';
2632  #  #
2633  man_do_filespec()  man_do_filespec()
2634  {  {
2635    func_check man_do_filespec = 1 "$@";    func_check man_do_filespec '=' 1 "$@";
2636    if obj _MAN_PATH is_empty    if obj _MAN_PATH is_empty
2637    then    then
2638      eval "${return_bad}";      eval "${return_bad}";
# Line 2491  man_do_filespec() Line 2655  man_do_filespec()
2655    man:?*\(?*\))                 # man:name(section)    man:?*\(?*\))                 # man:name(section)
2656      mdf_name="$(echo1 "${mdf_spec}" \      mdf_name="$(echo1 "${mdf_spec}" \
2657                  | sed -e 's/^man:\(..*\)(\(..*\))$/\1/')";                  | sed -e 's/^man:\(..*\)(\(..*\))$/\1/')";
2658      mdf_section="$(echo1 "${mdf_spec}" \      mdf_section="$(echo1 "${mdf_spec}" | \
2659                     | sed -e 's/^man:\(..*\)(\(..*\))$/\2/')";                     sed -e 's/^man:\(..*\)(\(..*\))$/\2/')";
2660      exit_test;      exit_test;
2661      ;;      ;;
2662    man:?*.${_MAN_AUTO_SEC_CHARS}) # man:name.section    man:?*.${_MAN_AUTO_SEC_CHARS}) # man:name.section
2663      mdf_name="$(echo1 "${mdf_spec}" \      mdf_name="$(echo1 "${mdf_spec}" \
2664                  | sed -e 's/^man:\(..*\)\..$/\1/')";                  | sed -e 's/^man:\(..*\)\..$/\1/')";
2665      mdf_section="$(echo1 "${mdf_spec}" \      mdf_section="$(echo1 "${mdf_spec}" | \
2666                     | sed -e 's/^.*\(.\)$/\1/')";                     sed -e 's/^.*\(.\)$/\1/')";
2667      exit_test;      exit_test;
2668      ;;      ;;
2669    man:?*)                       # man:name    man:?*)                       # man:name
# Line 2533  man_do_filespec() Line 2697  man_do_filespec()
2697      eval "${return_bad}";      eval "${return_bad}";
2698    fi;    fi;
2699    mdf_got_one='no';    mdf_got_one='no';
2700    
2701      obj _TMP_MANSPEC rm_file_with_debug;
2702      _TMP_MANSPEC="$(tmp_create "filespec_${mdf_name}")";
2703      grep /"${mdf_name}"'\.' "${_TMP_MAN}" > "${_TMP_MANSPEC}";
2704      if obj _TMP_MANSPEC is_non_empty_file
2705      then
2706        :;
2707      else
2708        eval ${_UNSET} mdf_got_one;
2709        eval ${_UNSET} mdf_name;
2710        eval ${_UNSET} mdf_section;
2711        eval ${_UNSET} mdf_spec;
2712        eval "${return_bad}";
2713      fi;
2714    
2715    if obj mdf_section is_empty    if obj mdf_section is_empty
2716    then    then
2717      if obj _OPT_SECTIONS is_empty      if obj _OPT_SECTIONS is_empty
# Line 2618  man_register_file() Line 2797  man_register_file()
2797      error 'man_register_file(): file name is empty';      error 'man_register_file(): file name is empty';
2798    fi;    fi;
2799    to_tmp "$1";    to_tmp "$1";
2800      if obj _DEBUG_PRINT_FILENAMES is_yes
2801      then
2802        echo2 'man page: '"$1";
2803      fi;
2804    case "$#" in    case "$#" in
2805      2)      2)
2806         register_title "man:$2";         register_title "man:$2";
# Line 2629  man_register_file() Line 2812  man_register_file()
2812         ;;         ;;
2813    esac;    esac;
2814    eval "${return_ok}";    eval "${return_ok}";
2815  }  } # man_register_file()
2816    
2817    
2818  ########################################################################  ########################################################################
# Line 2645  man_register_file() Line 2828  man_register_file()
2828  #  #
2829  man_search_section()  man_search_section()
2830  {  {
2831    func_check man_search_section = 2 "$@";    func_check man_search_section '=' 2 "$@";
2832    if obj _MAN_PATH is_empty    if obj _MAN_PATH is_empty || is_empty "$1" || is_empty "$2"
   then  
     eval "${return_bad}";  
   fi;  
   if is_empty "$1"  
   then  
     eval "${return_bad}";  
   fi;  
   if is_empty "$2"  
2833    then    then
2834      eval "${return_bad}";      eval "${return_bad}";
2835    fi;    fi;
2836    mss_name="$1";    mss_name="$1";
2837    mss_section="$2";    mss_section="$2";
   eval set x "$(path_split "${_MAN_PATH}")";  
   exit_test;  
   shift;  
2838    mss_got_one='no';    mss_got_one='no';
2839    if obj _MAN_EXT is_empty  
2840      mss_section1="$(echo1 "$2" | sed -e 's/^\(.\).*$/\1/')";
2841      # $_MAN_EXT might be empty
2842      mss_files="$(eval grep \
2843        "'/man${mss_section1}/${mss_name}.${mss_section}${_MAN_EXT}'" \
2844        "'${_TMP_MANSPEC}'")";
2845      if obj mss_files is_not_empty
2846    then    then
2847      for d      # for f in $mss_files
2848        for f in $(eval set x ${mss_files}; shift; echo1 "$@")
2849      do      do
2850        mss_dir="$(dirname_append "$d" "man${mss_section}")";        mss_f="$f";
2851        exit_test;        if obj mss_f is_file
       if obj mss_dir is_dir  
2852        then        then
2853          mss_prefix="$(\          if is_yes "${mss_got_one}"
           dirname_append "${mss_dir}" "${mss_name}.${mss_section}")";  
         if obj _OPT_WHATIS is_yes  
2854          then          then
2855            mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} |            register_file "${mss_f}";
2856                         sed -e '\| found|s|.*||'          elif obj _MAN_ALL is_yes
                        )";  
         else  
           mss_files="$(eval ls "'${mss_prefix}'"'*' 2>${_NULL_DEV} |  
                        sed -e '\| found|s|.*||'  
                        )";  
         fi;  
         exit_test;  
         if obj mss_files is_not_empty  
2857          then          then
2858            # for f in $mss_files            man_register_file "${mss_f}" "${mss_name}";
2859            for f in $(eval set x ${mss_files}; shift; echo1 "$@")          else
2860            do            man_register_file "${mss_f}" "${mss_name}" "${mss_section}";
2861              exit_test;            eval ${_UNSET} mss_f;
2862              mss_f="$f";            eval ${_UNSET} mss_files;
2863              if obj mss_f is_file            eval ${_UNSET} mss_got_one;
2864              then            eval ${_UNSET} mss_name;
2865                if is_yes "${mss_got_one}"            eval ${_UNSET} mss_section;
2866                then            eval ${_UNSET} mss_section1;
2867                  register_file "${mss_f}";            eval "${return_good}";
               elif obj _MAN_ALL is_yes  
               then  
                 man_register_file "${mss_f}" "${mss_name}";  
               else  
                 man_register_file "${mss_f}" "${mss_name}" "${mss_section}";  
                 eval ${_UNSET} mss_dir;  
                 eval ${_UNSET} mss_ext;  
                 eval ${_UNSET} mss_f;  
                 eval ${_UNSET} mss_files;  
                 eval ${_UNSET} mss_got_one;  
                 eval ${_UNSET} mss_name;  
                 eval ${_UNSET} mss_prefix;  
                 eval ${_UNSET} mss_section;  
                 eval "${return_good}";  
               fi;  
               mss_got_one='yes';  
             fi;  
           done;  
         fi;  
       fi;  
     done;  
   else  
     mss_ext="${_MAN_EXT}";  
     # check for directory name having trailing extension  
     for d  
     do  
       mss_dir="$(dirname_append $d man${mss_section}${mss_ext})";  
       exit_test;  
       if obj mss_dir is_dir  
       then  
         mss_prefix=\  
           "$(dirname_append "${mss_dir}" "${mss_name}.${mss_section}")";  
         mss_files="$( eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} |  
                      sed -e '\|not found|s|.*||'  
                      )";  
         exit_test;  
         if obj mss_files is_not_empty  
         then  
           # for f in $mss_files  
           for f in $(eval set x ${mss_files}; shift; echo1 "$@")  
           do  
             mss_f="$f";  
             if obj mss_f is_file  
             then  
               if is_yes "${mss_got_one}"  
               then  
                 register_file "${mss_f}";  
               elif obj _MAN_ALL is_yes  
               then  
                 man_register_file "${mss_f}" "${mss_name}";  
               else  
                 man_register_file "${mss_f}" "${mss_name}" "${mss_section}";  
                 eval ${_UNSET} mss_dir;  
                 eval ${_UNSET} mss_ext;  
                 eval ${_UNSET} mss_f;  
                 eval ${_UNSET} mss_files;  
                 eval ${_UNSET} mss_got_one;  
                 eval ${_UNSET} mss_name;  
                 eval ${_UNSET} mss_prefix;  
                 eval ${_UNSET} mss_section;  
                 eval "${return_good}";  
               fi;  
               mss_got_one='yes';  
             fi;  
           done;  
         fi;  
       fi;  
     done;  
     # check for files with extension in directories without extension  
     for d  
     do  
       mss_dir="$(dirname_append "$d" "man${mss_section}")";  
       exit_test;  
       if obj mss_dir is_dir  
       then  
         mss_prefix="$(dirname_append "${mss_dir}" \  
                         "${mss_name}.${mss_section}${mss_ext}")";  
         mss_files="$(eval ls "${mss_prefix}"'*' 2>${_NULL_DEV} |  
                      sed -e '\|not found|s|.*||'  
                      )";  
         exit_test;  
         if obj mss_files is_not_empty  
         then  
           # for f in $mss_files  
           for f in $(eval set x ${mss_files}; shift; echo1 "$@")  
           do  
             mss_f="$f";  
             if obj mss_f is_file  
             then  
               if is_yes "${mss_got_one}"  
               then  
                 register_file "${mss_f}";  
               elif obj _MAN_ALL is_yes  
               then  
                 man_register_file "${mss_f}" "${mss_name}";  
               else  
                 man_register_file "${mss_f}" "${mss_name}" "${mss_section}";  
                 eval ${_UNSET} mss_dir;  
                 eval ${_UNSET} mss_ext;  
                 eval ${_UNSET} mss_f;  
                 eval ${_UNSET} mss_files;  
                 eval ${_UNSET} mss_got_one;  
                 eval ${_UNSET} mss_name;  
                 eval ${_UNSET} mss_prefix;  
                 eval ${_UNSET} mss_section;  
                 eval "${return_good}";  
               fi;  
               mss_got_one='yes';  
             fi;  
           done;  
2868          fi;          fi;
2869            mss_got_one='yes';
2870        fi;        fi;
2871      done;      done;
2872    fi;    fi;
2873    if obj _MAN_ALL is_yes && is_yes "${mss_got_one}"    if obj _MAN_ALL is_yes && is_yes "${mss_got_one}"
2874    then    then
     eval ${_UNSET} mss_dir;  
     eval ${_UNSET} mss_ext;  
2875      eval ${_UNSET} mss_f;      eval ${_UNSET} mss_f;
2876      eval ${_UNSET} mss_files;      eval ${_UNSET} mss_files;
2877      eval ${_UNSET} mss_got_one;      eval ${_UNSET} mss_got_one;
2878      eval ${_UNSET} mss_name;      eval ${_UNSET} mss_name;
     eval ${_UNSET} mss_prefix;  
2879      eval ${_UNSET} mss_section;      eval ${_UNSET} mss_section;
2880        eval ${_UNSET} mss_section1;
2881      eval "${return_good}";      eval "${return_good}";
2882    fi;    fi;
   eval ${_UNSET} mss_dir;  
   eval ${_UNSET} mss_ext;  
2883    eval ${_UNSET} mss_f;    eval ${_UNSET} mss_f;
2884    eval ${_UNSET} mss_files;    eval ${_UNSET} mss_files;
2885    eval ${_UNSET} mss_got_one;    eval ${_UNSET} mss_got_one;
2886    eval ${_UNSET} mss_name;    eval ${_UNSET} mss_name;
   eval ${_UNSET} mss_prefix;  
2887    eval ${_UNSET} mss_section;    eval ${_UNSET} mss_section;
2888      eval ${_UNSET} mss_section1;
2889    eval "${return_bad}";    eval "${return_bad}";
2890  } # man_search_section()  } # man_search_section()
2891    
# Line 2861  man_search_section() Line 2916  man_search_section()
2916  #  #
2917  man_setup()  man_setup()
2918  {  {
2919    func_check main_man_setup = 0 "$@";    func_check main_man_setup '=' 0 "$@";
2920    
2921    if obj _MAN_IS_SETUP is_yes    if obj _MAN_IS_SETUP is_yes
2922    then    then
# Line 2875  man_setup() Line 2930  man_setup()
2930    fi;    fi;
2931    
2932    # determine basic path for man pages    # determine basic path for man pages
2933    _MAN_PATH="$(get_first_essential \    obj_from_output ms_path \
2934                 "${_OPT_MANPATH}" "${_MANOPT_PATH}" "${MANPATH}")";      get_first_essential "${_OPT_MANPATH}" "${_MANOPT_PATH}" "${MANPATH}";
2935    exit_test;    if obj ms_path is_empty && is_prog 'manpath'
   if obj _MAN_PATH is_empty  
2936    then    then
2937      manpath_set_from_path;      obj_from_output ms_path manpath 2>${_NULL_DEV}; # not always available
   else  
     _MAN_PATH="$(path_clean "${_MAN_PATH}")";  
     exit_test;  
2938    fi;    fi;
2939    if obj _MAN_PATH is_empty    if obj ms_path is_empty
2940    then    then
2941      if is_prog 'manpath'      manpath_set_from_path;
2942      then    else
2943        _MAN_PATH="$(manpath 2>${_NULL_DEV})"; # not always available      obj_from_output _MAN_PATH path_list "${ms_path}";
       exit_test;  
     fi;  
2944    fi;    fi;
2945    if obj _MAN_PATH is_empty    if obj _MAN_PATH is_empty
2946    then    then
2947      _MAN_ENABLE="no";      _MAN_ENABLE="no";
2948        eval ${_UNSET} ms_path;
2949      eval "${return_ok}";      eval "${return_ok}";
2950    fi;    fi;
2951    
2952    _MAN_ALL="$(get_first_essential "${_OPT_ALL}" "${_MANOPT_ALL}")";    obj_from_output _MAN_ALL \
2953    exit_test;      get_first_essential "${_OPT_ALL}" "${_MANOPT_ALL}";
2954    if obj _MAN_ALL is_empty    if obj _MAN_ALL is_empty
2955    then    then
2956      _MAN_ALL='no';      _MAN_ALL='no';
2957    fi;    fi;
2958    
2959    _MAN_SYS="$(get_first_essential \    ms_sys="$(get_first_essential \
2960                "${_OPT_SYSTEMS}" "${_MANOPT_SYS}" "${SYSTEM}")";                "${_OPT_SYSTEMS}" "${_MANOPT_SYS}" "${SYSTEM}")";
2961    ms_lang="$(get_first_essential \    if obj ms_sys is_not_empty
2962             "${_OPT_LANG}" "${LC_ALL}" "${LC_MESSAGES}" "${LANG}")";    then
2963    exit_test;      obj_from_output _MAN_SYS list_from_split "${ms_sys}" ',';
2964      fi;
2965    
2966      obj_from_output ms_lang get_first_essential \
2967               "${_OPT_LANG}" "${LC_ALL}" "${LC_MESSAGES}" "${LANG}";
2968    case "${ms_lang}" in    case "${ms_lang}" in
2969      C|POSIX)      C|POSIX)
2970        _MAN_LANG="";        _MAN_LANG="";
# Line 2920  man_setup() Line 2974  man_setup()
2974        _MAN_LANG="${ms_lang}";        _MAN_LANG="${ms_lang}";
2975        _MAN_LANG2="";        _MAN_LANG2="";
2976        ;;        ;;
2977        ??)
2978          _MAN_LANG="${ms_lang}";
2979          _MAN_LANG2="${ms_lang}";
2980          ;;
2981      *)      *)
2982        _MAN_LANG="${ms_lang}";        _MAN_LANG="${ms_lang}";
2983        # get first two characters of $ms_lang        # get first two characters of $ms_lang
# Line 2927  man_setup() Line 2985  man_setup()
2985        exit_test;        exit_test;
2986        ;;        ;;
2987    esac;    esac;
2988    # from now on, use only $_LANG, forget about $_OPT_LANG, $LC_*.    # from now on, use only $_MAN_LANG*, forget about $_OPT_LANG, $LC_*.
2989    
2990    manpath_add_lang_sys;         # this is very slow    manpath_add_lang_sys;
2991    
2992    _MAN_SEC="$(get_first_essential \    obj_from_output _MAN_SEC get_first_essential \
2993                "${_OPT_SECT}" "${_MANOPT_SEC}" "${MANSEC}")";                  "${_OPT_SECT}" "${_MANOPT_SEC}" "${MANSEC}";
2994    exit_test;    obj_from_output _MAN_EXT get_first_essential \
2995    if obj _MAN_PATH is_empty                  "${_OPT_EXTENSION}" "${_MANOPT_EXTENSION}";
2996    
2997      _TMP_MAN="$(tmp_create man)";
2998    
2999      eval set x "${_MAN_PATH}";
3000      shift;
3001      if is_not_equal "$#" 0
3002    then    then
3003      _MAN_ENABLE="no";      for i
3004      eval ${_UNSET} ms_lang;      do
3005      eval "${return_ok}";        for j in "$i"/man*
3006          do
3007            find "$j" >>"${_TMP_MAN}";
3008          done
3009        done;
3010    fi;    fi;
3011    
   _MAN_EXT="$(get_first_essential \  
               "${_OPT_EXTENSION}" "${_MANOPT_EXTENSION}")";  
   exit_test;  
3012    eval ${_UNSET} ms_lang;    eval ${_UNSET} ms_lang;
3013      eval ${_UNSET} ms_list;
3014      eval ${_UNSET} ms_path;
3015      eval ${_UNSET} ms_sys;
3016    eval "${return_ok}";    eval "${return_ok}";
3017  } # man_setup()  } # man_setup()
3018    
# Line 2961  landmark '8: manpath_*()'; Line 3029  landmark '8: manpath_*()';
3029  # Arguments : 0  # Arguments : 0
3030  # Output    : none  # Output    : none
3031  # Globals:  # Globals:
3032  #   in:     $_MAN_SYS: has the form `os1,os2,...', a comma separated  #   in:     $_MAN_SYS: a list of names of operating systems.
 #             list of names of operating systems.  
3033  #           $_MAN_LANG and $_MAN_LANG2: each a single name  #           $_MAN_LANG and $_MAN_LANG2: each a single name
3034  #   in/out: $_MAN_PATH: has the form `dir1:dir2:...', a colon  #   in/out: $_MAN_PATH: list of directories which shall have the `man?'
3035  #             separated list of directories.  #             subdirectories.
3036  #  #
3037  # Variable prefix: mals  # Variable prefix: mals
3038  #  #
3039  manpath_add_lang_sys()  manpath_add_lang_sys()
3040  {  {
3041    func_check manpath_add_lang_sys = 0 "$@";    func_check manpath_add_lang_sys '=' 0 "$@";
3042    if obj _MAN_PATH is_empty    if obj _MAN_PATH is_empty
3043    then    then
3044      eval "${return_ok}";      eval "${return_ok}";
3045    fi;    fi;
3046    # twice test both sys and lang    if obj _MAN_SYS is_empty
3047    eval set x "$(path_split "${_MAN_PATH}")";    then
3048    shift;      mals_mp="${_MAN_PATH}";
3049    exit_test;    else
3050    mals_mp='';      mals_mp='';
3051    for p      eval set x "${_MAN_SYS}";
3052    do                            # loop on man path directories      shift;
3053      mals_mp="$(_manpath_add_lang_sys_single "${mals_mp}" "$p")";      for s
3054      exit_test;      do
3055    done;        _manpath_add_sys "$s";
3056    eval set x "$(path_split "${mals_mp}")";      done;
3057    shift;    fi;
3058    exit_test;  
3059    for p    if obj mals_mp is_not_empty
3060    do                            # loop on man path directories    then
3061      mals_mp="$(_manpath_add_lang_sys_single "${mals_mp}" "$p")";      mals_lang_path='';
3062      exit_test;      for i in "$_MAN_LANG" "$_MAN_LANG2"
3063    done;      do
3064    _MAN_PATH="$(path_chop "${mals_mp}")";        mals_lang="$i";
3065    exit_test;        eval set x "${mals_mp}";
3066          shift;
3067          for p
3068          do
3069            obj_from_output mals_dir dirname_append "${p}" "${mals_lang}";
3070            if obj mals_dir is_dir
3071            then
3072              list_append mals_lang_path "${mals_dir}";
3073            fi;
3074          done;
3075        done;
3076        obj_from_output mals_mp lists_combine mals_lang_path mals_mp;
3077      fi;
3078    
3079      _MAN_PATH="${mals_mp}";
3080      eval ${_UNSET} mals_dir;
3081      eval ${_UNSET} mals_lang;
3082      eval ${_UNSET} mals_lang_path;
3083    eval ${_UNSET} mals_mp;    eval ${_UNSET} mals_mp;
3084    eval "${return_ok}";    eval "${return_ok}";
3085  }  } # manpath_add_lang_sys()
3086    
3087    
3088  # To the directory in $1 append existing sys/lang subdirectories  # one argument, a system name
 # Function is necessary to split the OS list.  
 #  
 # globals: in: $_MAN_SYS, $_MAN_LANG, $_MAN_LANG2  
 # argument: 2: `man_path' and `dir'  
 # output: colon-separated path of the retrieved subdirectories  
3089  #  #
3090  # Variable prefix: _mals  # Globals: $_MAN_PATH, $mals_mp
3091  #  #
3092  _manpath_add_lang_sys_single()  # Variable prefix: _mas
3093    #
3094    _manpath_add_sys()
3095  {  {
3096    func_check _manpath_add_lang_sys_single = 2 "$@";    func_check _manpath_add_sys '=' 1 "$@";
3097    _mals_res="$1";    case "$1" in
3098    _mals_parent="$2";    '')
3099    eval set x "$(list_from_split "${_MAN_SYS}" ',')";      :;
3100    shift;      ;;
3101    exit_test;    man)
3102    for d in "$@" "${_MAN_LANG}" "${_MAN_LANG2}"      obj_from_output mals_mp lists_combine mals_mp _MAN_PATH;
3103    do      ;;
3104      _mals_dir="$(dirname_append "${_mals_parent}" "$d")";    *)
3105      exit_test;      _mas_sys="$1";
3106      if obj _mals_res path_not_contains "${_mals_dir}" && \      eval set x "${_MAN_PATH}";
3107         obj _mals_dir is_dir      shift;
3108      then      for p
3109        _mals_res="${_mals_res}:${_mals_dir}";      do
3110      fi;        obj_from_output _mas_dir dirname_append "${p}" "${_mas_sys}";
3111    done;        if obj _mas_dir is_dir
3112    if path_not_contains "${_mals_res}" "${_mals_parent}"        then
3113    then          list_append mals_mp "${_mas_dir}";
3114      _mals_res="${_mals_res}:${_mals_parent}";        fi;
3115    fi;      done;
3116    path_chop "${_mals_res}";      ;;
3117    eval ${_UNSET} _mals_dir;    esac;
3118    eval ${_UNSET} _mals_parent;    eval ${_UNSET} _mas_dir;
3119    eval ${_UNSET} _mals_res;    eval ${_UNSET} _mas_sys;
3120    eval "${return_ok}";    eval "${return_ok}";
3121  }  } # _manpath_add_sys() of manpath_add_lang_sys()
   
 # end manpath_add_lang_sys ()  
3122    
3123    
3124  ########################################################################  ########################################################################
# Line 3057  _manpath_add_lang_sys_single() Line 3136  _manpath_add_lang_sys_single()
3136  #  #
3137  manpath_set_from_path()  manpath_set_from_path()
3138  {  {
3139    func_check manpath_set_from_path = 0 "$@";    func_check manpath_set_from_path '=' 0 "$@";
3140    
3141    msfp_manpath='';    msfp_manpath='';
3142    
3143    # get a basic man path from $PATH    # get a basic man path from $PATH
3144    if obj PATH is_not_empty    if obj PATH is_not_empty
3145    then    then
3146      eval set x "$(path_split "${PATH}")";      # delete the final `/bin' part
3147        p="$(echo1 "${PATH}" | sed -e 's|//*bin/*:|:|g')";
3148        obj_from_output msfp_list path_list "$p";
3149        # append some default directories
3150        for b in /usr/local /usr/local /usr /usr \
3151               /usr/X11R6 /usr/openwin \
3152               /opt /opt/gnome /opt/kde
3153        do
3154          msfp_base="$b";
3155          if list_has_not msfp_list "${msfp_base}" && obj msfp_base is_dir
3156          then
3157            list_append msfp_list "${msfp_base}";
3158          fi;
3159        done;
3160        eval set x "${msfp_list}";
3161      shift;      shift;
     exit_test;  
3162      for d      for d
3163      do      do
3164        # delete the final `/bin' part        # including empty for former `/bin'.
3165        msfp_base="$(echo1 "$d" | sed -e 's|//*bin/*$||')";        msfp_base="$d";
3166        exit_test;        for e in /share/man /share/MAN /man /MAN
       for e in /share/man /man  
3167        do        do
3168          msfp_mandir="${msfp_base}$e";          msfp_mandir="${msfp_base}$e";
3169          if test -d "${msfp_mandir}" && test -r "${msfp_mandir}"          if obj msfp_mandir is_dir
3170          then          then
3171            msfp_manpath="${msfp_manpath}:${msfp_mandir}";            list_append msfp_manpath "${msfp_mandir}";
3172          fi;          fi;
3173        done;        done;
3174      done;      done;
3175    fi;    fi;
3176    
   # append some default directories  
   for d in /usr/local/share/man /usr/local/man \  
            /usr/share/man /usr/man \  
            /usr/X11R6/man /usr/openwin/man \  
            /opt/share/man /opt/man \  
            /opt/gnome/man /opt/kde/man  
   do  
     msfp_d="$d";  
     if obj msfp_manpath path_not_contains "${msfp_d}" && obj mfsp_d is_dir  
     then  
       msfp_manpath="${msfp_manpath}:${mfsp_d}";  
     fi;  
   done;  
   
3177    _MAN_PATH="${msfp_manpath}";    _MAN_PATH="${msfp_manpath}";
3178    eval ${_UNSET} msfp_base;    eval ${_UNSET} msfp_base;
3179    eval ${_UNSET} msfp_d;    eval ${_UNSET} msfp_list;
3180    eval ${_UNSET} msfp_mandir;    eval ${_UNSET} msfp_mandir;
3181    eval ${_UNSET} msfp_manpath;    eval ${_UNSET} msfp_manpath;
3182    eval "${return_ok}";    eval "${return_ok}";
# Line 3164  obj_data() Line 3241  obj_data()
3241    then    then
3242      error "obj_data(): object name is empty."      error "obj_data(): object name is empty."
3243    fi;    fi;
3244    eval od_res='"${'$1'}"';    eval od_res='"${'"$1"'}"';
3245    obj od_res echo1;    obj od_res echo1;
3246    eval ${_UNSET} od_res;    eval ${_UNSET} od_res;
3247    eval "${return_ok}";    eval "${return_ok}";
# Line 3190  obj_from_output() Line 3267  obj_from_output()
3267    func_check obj_from_output '>=' 2 "$@";    func_check obj_from_output '>=' 2 "$@";
3268    if is_empty "$1"    if is_empty "$1"
3269    then    then
3270      error "res(): variable name is empty.";      error "obj_from_output: variable name is empty.";
3271    elif is_empty "$2"    elif is_empty "$2"
3272    then    then
3273      error "res(): function name is empty."      error "obj_from_output: function name is empty."
3274    else    else
3275      ofo_result_name="$1";      ofo_result_name="$1";
3276    fi;    fi;
3277    shift;    shift;
3278    eval "${ofo_result_name}"'="$('"$@"')"';    eval "${ofo_result_name}"'="$('"$@"')"';
3279    exit_test;    eval ${_UNSET} ofo_result_name;
3280    eval "${return_ok}";    eval "${return_ok}";
3281  }  }
3282    
# Line 3246  s/:::*/:/g Line 3323  s/:::*/:/g
3323  s/:*$//  s/:*$//
3324  ';  ';
3325    eval "${return_ok}";    eval "${return_ok}";
3326  }  } # path_chop()
3327    
3328    
3329  ########################################################################  ########################################################################
# Line 3267  path_clean() Line 3344  path_clean()
3344      error 'path_clean() needs 1 argument.';      error 'path_clean() needs 1 argument.';
3345    fi;    fi;
3346    pc_arg="$1";    pc_arg="$1";
3347    eval set x "$(path_split "${pc_arg}")";    eval set x "$(path_list "${pc_arg}")";
3348    exit_test;    exit_test;
3349    shift;    shift;
3350    pc_res="";    pc_res="";
# Line 3280  path_clean() Line 3357  path_clean()
3357      then      then
3358        case "${pc_i}" in        case "${pc_i}" in
3359        ?*/)        ?*/)
3360          pc_res="${pc_res}$(dirname_chop "${pc_i}")";          pc_res="${pc_res}:$(dirname_chop "${pc_i}")";
3361          exit_test;          exit_test;
3362          ;;          ;;
3363        *)        *)
3364          pc_res="${pc_res}:${pc_i}";          pc_res="${pc_res}:${pc_i}";
         exit_test;  
3365          ;;          ;;
3366        esac;        esac;
3367      fi;      fi;
3368    done;    done;
3369      path_chop "${pc_res}";
3370    eval ${_UNSET} pc_arg;    eval ${_UNSET} pc_arg;
3371    eval ${_UNSET} pc_i;    eval ${_UNSET} pc_i;
3372    eval ${_UNSET} pc_res;    eval ${_UNSET} pc_res;
3373    if path_chop "${pc_res}"    eval "${return_ok}";
3374    then  } # path_clean()
     eval "${return_ok}";  
   else  
     eval "${return_bad}";  
   fi;  
 }  
3375    
3376    
3377  ########################################################################  ########################################################################
# Line 3346  path_not_contains() Line 3418  path_not_contains()
3418    
3419    
3420  ########################################################################  ########################################################################
3421  # path_split (<path>)  # path_list (<path>)
3422  #  #
3423  # In `path' escape white space and replace each colon by a space.  # In `path' escape white space and replace each colon by a space.
3424  #  #
3425  # Arguments: 1: a colon-separated path  # Arguments: 1: a colon-separated path
3426  # Output:    the resulting list, process with `eval set'  # Output:    the resulting list, process with `eval set'
3427  #  #
3428  path_split()  path_list()
3429  {  {
3430    func_check path_split = 1 "$@";    func_check path_list = 1 "$@";
3431    list_from_split "$1" ':';    list_from_split "$1" '\:';
3432    eval "${return_ok}";    eval "${return_ok}";
3433  }  }
3434    
# Line 3384  register_file() Line 3456  register_file()
3456    then    then
3457      to_tmp "${_TMP_STDIN}";      to_tmp "${_TMP_STDIN}";
3458      register_title 'stdin';      register_title 'stdin';
3459        if obj _DEBUG_PRINT_FILENAMES is_yes
3460        then
3461          echo2 "file: standard input";
3462        fi;
3463    else    else
3464      to_tmp "$1";      to_tmp "$1";
3465      register_title "$(base_name "$1")";      register_title "$(base_name "$1")";
3466      exit_test;      exit_test;
3467        if obj _DEBUG_PRINT_FILENAMES is_yes
3468        then
3469          echo2 "file: $1";
3470        fi;
3471    fi;    fi;
3472    eval "${return_ok}";    eval "${return_ok}";
3473  } # register_file()  } # register_file()
# Line 3417  register_title() Line 3497  register_title()
3497    esac;    esac;
3498    
3499    # remove directory part    # remove directory part
3500    rt_title="$(base_name "$1")";    obj_from_output rt_title base_name "$1";
3501    # replace space characters by `_'    # replace space characters by `_'
3502    rt_title="$(echo1 "${rt_title}" | sed -e 's/[         ]/_/g')";    rt_title="$(echo1 "${rt_title}" | sed -e 's/[         ]/_/g')";
3503    # remove extension `.bz2'    # remove extension `.bz2'
# Line 3426  register_title() Line 3506  register_title()
3506    rt_title="$(echo1 "${rt_title}" | sed -e 's/\.gz$//')";    rt_title="$(echo1 "${rt_title}" | sed -e 's/\.gz$//')";
3507    # remove extension `.Z'    # remove extension `.Z'
3508    rt_title="$(echo1 "${rt_title}" | sed -e 's/\.Z$//')";    rt_title="$(echo1 "${rt_title}" | sed -e 's/\.Z$//')";
   exit_test;  
3509    
3510    if obj rt_title is_empty    if obj rt_title is_empty
3511    then    then
# Line 3688  tmp_cat() Line 3767  tmp_cat()
3767  tmp_create()  tmp_create()
3768  {  {
3769    func_check tmp_create '<=' 1 "$@";    func_check tmp_create '<=' 1 "$@";
3770    # the output file does not have `,' as first character, so these are    if obj _TMP_DIR is_empty || obj _TMP_DIR is_not_dir
3771    # different names from the output file.    then
3772    tc_tmp="${_TMP_DIR}/,$1";      error 'tmp_create: there is no temporary directory.';
3773    : >"${tc_tmp}"    else
3774    obj tc_tmp echo1;      # the output file does not have `,' as first character, so these are
3775        # different names from the output file.
3776        tc_tmp="${_TMP_DIR}/,$1";
3777        obj tc_tmp rm_file;
3778        : >"${tc_tmp}"
3779        obj tc_tmp echo1;
3780      fi;
3781    eval ${_UNSET} tc_tmp;    eval ${_UNSET} tc_tmp;
3782    eval "${return_ok}";    eval "${return_ok}";
3783  }  }
# Line 3850  The most important groffer long options Line 3935  The most important groffer long options
3935  --x-viewer=prog   choose viewer program for x mode (X mode).  --x-viewer=prog   choose viewer program for x mode (X mode).
3936  --X-viewer=prog   same as "--xviewer".  --X-viewer=prog   same as "--xviewer".
3937    
 Development options that are not useful for normal usage:  
 --debug, --debug-all, --debug-keep, --debug-lm, --debug-params,  
 --debug-shell, --debug-stacks, --debug-tmpdir, --debug-user,  
 --do-nothing, --print=text  
   
 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, --X-viewer-tty=prog,  
 --x-viewer-tty=prog, --www-viewer-tty=prog  
   
3938  The usual X Windows toolkit options transformed into GNU long options:  The usual X Windows toolkit options transformed into GNU long options:
3939  --background=color, --bd=size, --bg=color, --bordercolor=color,  --background=color, --bd=size, --bg=color, --bordercolor=color,
3940  --borderwidth=size, --bw=size, --display=Xdisplay, --fg=color,  --borderwidth=size, --bw=size, --display=Xdisplay, --fg=color,
# Line 3871  Long options of GNU "man": Line 3946  Long options of GNU "man":
3946  --local-file=name, --location, --manpath=dir1:dir2:...,  --local-file=name, --location, --manpath=dir1:dir2:...,
3947  --sections=s1:s2:..., --systems=s1,s2,..., --where, ...  --sections=s1:s2:..., --systems=s1,s2,..., --where, ...
3948    
3949    Development options that are not useful for normal usage:
3950    --debug, --debug-all, --debug-func, --debug-not-func, --debug-keep,
3951    --debug-lm, --debug-params, --debug-shell, --debug-stacks,
3952    --debug-tmpdir, --debug-user, --do-nothing, --print=text
3953    
3954  EOF  EOF
3955    
3956    #Viewer programs for the different modes that run on the terminal:
3957    #--dvi-viewer-tty=prog, --html-viewer-tty=prog, --pdf-viewer-tty=prog,
3958    #--ps-viewer-tty=prog, --tty-viewer-tty=prog, --X-viewer-tty=prog,
3959    #--x-viewer-tty=prog, --www-viewer-tty=prog
3960    
3961    eval "${return_ok}";    eval "${return_ok}";
3962  }  }
3963    
3964    
3965    
3966  ########################################################################  ########################################################################
3967  # version ()  # version ()
3968  #  #
# Line 4094  where_is() Line 4181  where_is()
4181        fi;        fi;
4182        ;;        ;;
4183    esac;    esac;
4184    eval set x "$(path_split "${PATH}")";    eval set x "$(path_list "${PATH}")";
4185    exit_test;    exit_test;
4186    shift;    shift;
4187    for p    for p
# Line 4176  main_init() Line 4263  main_init()
4263        mi_tdir_="${_TMP_DIR}"_;        mi_tdir_="${_TMP_DIR}"_;
4264        mi_n=1;        mi_n=1;
4265        mi_tdir_n="${mi_tdir_}${mi_n}";        mi_tdir_n="${mi_tdir_}${mi_n}";
4266    ### main_init()
4267        while obj mi_tdir_n is_existing        while obj mi_tdir_n is_existing
4268        do        do
4269          if obj mi_tdir_n rm_tree          if obj mi_tdir_n rm_tree
# Line 4209  main_init() Line 4297  main_init()
4297      error "main_init: \      error "main_init: \
4298  Couldn't create a directory for storing temporary files.";  Couldn't create a directory for storing temporary files.";
4299    fi;    fi;
4300    ### main_init()
4301    if obj _DEBUG_PRINT_TMPDIR is_yes    if obj _DEBUG_PRINT_TMPDIR is_yes
4302    then    then
4303      echo2 "temporary directory: ${_TMP_DIR}";      echo2 "temporary directory: ${_TMP_DIR}";
4304    fi;    fi;
4305    
4306    _TMP_CAT="$(tmp_create groffer_cat)";    obj_from_output _TMP_CAT tmp_create groffer_cat;
4307    _TMP_STDIN="$(tmp_create groffer_input)";    obj_from_output _TMP_STDIN tmp_create groffer_input;
   exit_test;  
4308    
4309    eval ${_UNSET} mi_dir;    eval ${_UNSET} mi_dir;
4310    eval ${_UNSET} mi_n;    eval ${_UNSET} mi_n;
# Line 4272  s/'"${_SPACE_SED}"'*$// Line 4360  s/'"${_SPACE_SED}"'*$//
4360      -a|--all)      -a|--all)
4361        list_append mpm_list '--all';        list_append mpm_list '--all';
4362        ;;        ;;
4363    ### main_parse_MANOPT()
4364      -c|--catman)      -c|--catman)
4365        do_nothing;        do_nothing;
4366        shift;        shift;
# Line 4306  s/'"${_SPACE_SED}"'*$// Line 4395  s/'"${_SPACE_SED}"'*$//
4395        list_append mpm_list '--locale' "$1";        list_append mpm_list '--locale' "$1";
4396        shift;        shift;
4397        ;;        ;;
4398    ### main_parse_MANOPT()
4399      -m|--systems)      -m|--systems)
4400        list_append mpm_list '--systems' "$1";        list_append mpm_list '--systems' "$1";
4401        shift;        shift;
# Line 4338  s/'"${_SPACE_SED}"'*$// Line 4428  s/'"${_SPACE_SED}"'*$//
4428        list_append mpm_list '-T' "$1";        list_append mpm_list '-T' "$1";
4429        shift;        shift;
4430        ;;        ;;
4431    ### main_parse_MANOPT()
4432      -u|--update)      -u|--update)
4433        do_nothing;        do_nothing;
4434        shift;        shift;
# Line 4383  s/'"${_SPACE_SED}"'*$// Line 4474  s/'"${_SPACE_SED}"'*$//
4474  main_parse_args()  main_parse_args()
4475  {  {
4476    func_check main_parse_args '>=' 0 "$@";    func_check main_parse_args '>=' 0 "$@";
4477    _ALL_PARAMS="$(list_from_cmdline _OPTS_CMDLINE "$@")";    obj_from_output _ALL_PARAMS list_from_cmdline _OPTS_CMDLINE "$@";
   exit_test;  
4478    if obj _DEBUG_PRINT_PARAMS is_yes    if obj _DEBUG_PRINT_PARAMS is_yes
4479    then    then
4480      echo2 "parameters: ${_ALL_PARAMS}";      echo2 "parameters: ${_ALL_PARAMS}";
# Line 4413  main_parse_args() Line 4503  main_parse_args()
4503      -Q|--source)                # output source code (`Quellcode').      -Q|--source)                # output source code (`Quellcode').
4504        _OPT_MODE='source';        _OPT_MODE='source';
4505        ;;        ;;
4506    ### main_parse_args()
4507      -T|--device|--troff-device) # device; arg      -T|--device|--troff-device) # device; arg
4508        _OPT_DEVICE="$1";        _OPT_DEVICE="$1";
4509        _check_device_with_mode;        _check_device_with_mode;
# Line 4429  main_parse_args() Line 4520  main_parse_args()
4520        _OPT_Z='yes';        _OPT_Z='yes';
4521        ;;        ;;
4522      -X)      -X)
4523        if is_X        _OPT_MODE=X;
       then  
         _OPT_MODE=X;  
       fi;  
4524        ;;        ;;
4525      -?)      -?)
4526        # delete leading `-'        # delete leading `-'
# Line 4445  main_parse_args() Line 4533  main_parse_args()
4533        then        then
4534          list_append _ADDOPTS_GROFF "${mpa_opt}" "$1";          list_append _ADDOPTS_GROFF "${mpa_opt}" "$1";
4535          shift;          shift;
4536    ### main_parse_args()
4537        else        else
4538          error "main_parse_args(): Unknown option : \`$1'";          error "main_parse_args(): Unknown option : \`$1'";
4539        fi;        fi;
# Line 4472  main_parse_args() Line 4561  main_parse_args()
4561        _APROPOS_SECTIONS='168';        _APROPOS_SECTIONS='168';
4562        _OPT_WHATIS='no';        _OPT_WHATIS='no';
4563        ;;        ;;
4564    ### main_parse_args()
4565      --ascii)      --ascii)
4566        list_append _ADDOPTS_GROFF '-mtty-char';        list_append _ADDOPTS_GROFF '-mtty-char';
4567        if obj _OPT_MODE is_empty        if obj _OPT_MODE is_empty
# Line 4494  main_parse_args() Line 4584  main_parse_args()
4584        _OPT_BW="$1";        _OPT_BW="$1";
4585        shift;        shift;
4586        ;;        ;;
4587      --debug|--debug-all|--debug-keep|--debug-lm|--debug-params|\      --debug|--debug-all|--debug-filenames|--debug-func|--debug-not-func|\
4588  --debug-shell|--debug-stacks|--debug-tmpdir|--debug-user)  --debug-keep|--debug-lm|--debug-params|--debug-shell|--debug-stacks|\
4589    --debug-tmpdir|--debug-user)
4590        # debug is handled at the beginning        # debug is handled at the beginning
4591        :;        :;
4592        ;;        ;;
4593      --default)                  # reset variables to default      --default)                  # reset variables to default
4594        reset;        reset;
4595        ;;        ;;
4596    ### main_parse_args()
4597      --default-modes)            # sequence of modes in auto mode; arg      --default-modes)            # sequence of modes in auto mode; arg
4598        _OPT_DEFAULT_MODES="$1";        _OPT_DEFAULT_MODES="$1";
4599        shift;        shift;
# Line 4514  main_parse_args() Line 4606  main_parse_args()
4606        _OPT_DO_NOTHING='yes';        _OPT_DO_NOTHING='yes';
4607        ;;        ;;
4608      --dvi)      --dvi)
4609        if is_X        _OPT_MODE='dvi';
       then  
         _OPT_MODE='dvi';  
       fi;  
4610        ;;        ;;
4611      --dvi-viewer)               # viewer program for dvi mode; arg      --dvi-viewer)               # viewer program for dvi mode; arg
4612        _VIEWER_TERMINAL='no';        _OPT_VIEWER_DVI_TTY="";
4613        _OPT_VIEWER_DVI="$1";        _OPT_VIEWER_DVI="$1";
4614        shift;        shift;
4615        ;;        ;;
4616      --dvi-viewer-tty)           # viewer program for dvi mode in tty; arg      --dvi-viewer-tty)           # viewer program for dvi mode in tty; arg
4617        _VIEWER_TERMINAL='yes';        _OPT_VIEWER_DVI="";
4618        _OPT_VIEWER_DVI="$1";        _OPT_VIEWER_DVI_TTY="$1";
4619        shift;        shift;
4620        ;;        ;;
4621      --extension)                # the extension for man pages, arg      --extension)                # the extension for man pages, arg
4622        _OPT_EXTENSION="$1";        _OPT_EXTENSION="$1";
4623        shift;        shift;
4624        ;;        ;;
4625    ### main_parse_args()
4626      --fg|--foreground)          # foreground color for viewers, arg;      --fg|--foreground)          # foreground color for viewers, arg;
4627        _OPT_FG="$1";        _OPT_FG="$1";
4628        shift;        shift;
# Line 4552  main_parse_args() Line 4642  main_parse_args()
4642        _OPT_MODE=html;        _OPT_MODE=html;
4643        ;;        ;;
4644      --html-viewer|--www-viewer) # viewer program for html mode; arg      --html-viewer|--www-viewer) # viewer program for html mode; arg
4645        _VIEWER_TERMINAL='no';        _OPT_VIEWER_HTML_TTY="";
4646        _OPT_VIEWER_HTML="$1";        _OPT_VIEWER_HTML="$1";
4647        shift;        shift;
4648        ;;        ;;
4649      --html-viewer-tty|--www-viewer-tty) # viewer for html mode in tty; arg      --html-viewer-tty|--www-viewer-tty) # viewer for html mode in tty; arg
4650        _VIEWER_TERMINAL='yes';        _OPT_VIEWER_HTML="";
4651        _OPT_VIEWER_HTML="$1";        _OPT_VIEWER_HTML_TTY="$1";
4652        shift;        shift;
4653        ;;        ;;
4654      --iconic)                   # start viewers as icons      --iconic)                   # start viewers as icons
4655        _OPT_ICONIC='yes';        _OPT_ICONIC='yes';
4656        ;;        ;;
4657    ### main_parse_args()
4658      --locale)                   # set language for man pages, arg      --locale)                   # set language for man pages, arg
4659        # argument is xx[_territory[.codeset[@modifier]]] (ISO 639,...)        # argument is xx[_territory[.codeset[@modifier]]] (ISO 639,...)
4660        _OPT_LANG="$1";        _OPT_LANG="$1";
# Line 4595  main_parse_args() Line 4686  main_parse_args()
4686        groff)                    # pass input to plain groff        groff)                    # pass input to plain groff
4687          _OPT_MODE='groff';          _OPT_MODE='groff';
4688          ;;          ;;
4689    ### main_parse_args()
4690        html|www)                 # display with a web browser        html|www)                 # display with a web browser
4691          _OPT_MODE='html';          _OPT_MODE='html';
4692          ;;          ;;
4693        dvi)                      # display with xdvi viewer        dvi)                      # display with xdvi viewer
4694          if is_X          _OPT_MODE='dvi';
         then  
           _OPT_MODE='dvi';  
         fi;  
4695          ;;          ;;
4696        pdf)                      # display with PDF viewer        pdf)                      # display with PDF viewer
4697          if is_X          _OPT_MODE='pdf';
         then  
           _OPT_MODE='pdf';  
         fi;  
4698          ;;          ;;
4699        ps)                       # display with Postscript viewer        ps)                       # display with Postscript viewer
4700          if is_X          _OPT_MODE='ps';
         then  
           _OPT_MODE='ps';  
         fi;  
4701          ;;          ;;
4702        text)                     # output on terminal        text)                     # output on terminal
4703          _OPT_MODE='text';          _OPT_MODE='text';
# Line 4623  main_parse_args() Line 4706  main_parse_args()
4706          _OPT_MODE='tty';          _OPT_MODE='tty';
4707          ;;          ;;
4708        X|x)                      # output on X roff viewer        X|x)                      # output on X roff viewer
4709          if is_X          _OPT_MODE='x';
         then  
           _OPT_MODE='x';  
         fi;  
4710          ;;          ;;
4711    ### main_parse_args()
4712        Q|source)                 # display source code        Q|source)                 # display source code
4713          _OPT_MODE="source";          _OPT_MODE="source";
4714          ;;          ;;
# Line 4651  main_parse_args() Line 4732  main_parse_args()
4732        ;;        ;;
4733      --pager|--tty-viewer|--tty-viewer-tty)      --pager|--tty-viewer|--tty-viewer-tty)
4734        # set paging program for tty mode, arg        # set paging program for tty mode, arg
       _VIEWER_TERMINAL='yes';  
4735        _OPT_PAGER="$1";        _OPT_PAGER="$1";
4736        shift;        shift;
4737        ;;        ;;
4738      --pdf)      --pdf)
4739        if is_X        _OPT_MODE='pdf';
       then  
         _OPT_MODE='pdf';  
       fi;  
4740        ;;        ;;
4741    ### main_parse_args()
4742      --pdf-viewer)               # viewer program for ps mode; arg      --pdf-viewer)               # viewer program for ps mode; arg
4743        _VIEWER_TERMINAL='no';        _OPT_VIEWER_PDF_TTY="";
4744        _OPT_VIEWER_PDF="$1";        _OPT_VIEWER_PDF="$1";
4745        shift;        shift;
4746        ;;        ;;
4747      --pdf-viewer-tty)           # viewer program for ps mode in tty; arg      --pdf-viewer-tty)           # viewer program for ps mode in tty; arg
4748        _VIEWER_TERMINAL='yes';        _OPT_VIEWER_PDF="";
4749        _OPT_VIEWER_PDF="$1";        _OPT_VIEWER_PDF_TTY="$1";
4750        shift;        shift;
4751        ;;        ;;
4752      --print)                    # for argument test      --print)                    # for argument test
# Line 4676  main_parse_args() Line 4754  main_parse_args()
4754        shift;        shift;
4755        ;;        ;;
4756      --ps)      --ps)
4757        if is_X        _OPT_MODE='ps';
       then  
         _OPT_MODE='ps';  
       fi;  
4758        ;;        ;;
4759      --ps-viewer)                # viewer program for ps mode; arg      --ps-viewer)                # viewer program for ps mode; arg
4760        _VIEWER_TERMINAL='no';        _OPT_VIEWER_PS_TTY="";
4761        _OPT_VIEWER_PS="$1";        _OPT_VIEWER_PS="$1";
4762        shift;        shift;
4763        ;;        ;;
4764      --ps-viewer-tty)            # viewer program for ps mode in tty; arg      --ps-viewer-tty)            # viewer program for ps mode in tty; arg
4765        _VIEWER_TERMINAL='yes';        _OPT_VIEWER_PS="";
4766        _OPT_VIEWER_PS="$1";        _OPT_VIEWER_PS_TTY="$1";
4767        shift;        shift;
4768        ;;        ;;
4769    ### main_parse_args()
4770      --resolution)               # set resolution for X devices, arg      --resolution)               # set resolution for X devices, arg
4771        mpa_arg="$1";        mpa_arg="$1";
4772        shift;        shift;
# Line 4720  only resoutions of 75 or 100 dpi are sup Line 4796  only resoutions of 75 or 100 dpi are sup
4796        # already done during the first run; so ignore the argument        # already done during the first run; so ignore the argument
4797        shift;        shift;
4798        ;;        ;;
4799    ### main_parse_args()
4800      --systems)                  # man pages for different OS's, arg      --systems)                  # man pages for different OS's, arg
4801        # argument is a comma-separated list        # argument is a comma-separated list
4802        _OPT_SYSTEMS="$1";        _OPT_SYSTEMS="$1";
# Line 4745  only resoutions of 75 or 100 dpi are sup Line 4822  only resoutions of 75 or 100 dpi are sup
4822        _OPT_APROPOS='no';        _OPT_APROPOS='no';
4823        ;;        ;;
4824      --X|--x)      --X|--x)
4825        if is_X        _OPT_MODE=x;
       then  
         _OPT_MODE=x;  
       fi;  
4826        ;;        ;;
4827    ### main_parse_args()
4828      --xrm)                      # pass X resource string, arg;      --xrm)                      # pass X resource string, arg;
4829        list_append _OPT_XRM "$1";        list_append _OPT_XRM "$1";
4830        shift;        shift;
4831        ;;        ;;
4832      --x-viewer|--X-viewer)      # viewer program for x mode; arg      --x-viewer|--X-viewer)      # viewer program for x mode; arg
4833        _VIEWER_TERMINAL='no';        _OPT_VIEWER_X_TTY="";
4834        _OPT_VIEWER_X="$1";        _OPT_VIEWER_X="$1";
4835        shift;        shift;
4836        ;;        ;;
4837      --x-viewer-tty|--X-viewer-tty) # viewer program for x mode in tty; arg      --x-viewer-tty|--X-viewer-tty) # viewer program for x mode in tty; arg
4838        _VIEWER_TERMINAL='yes';        _OPT_VIEWER_X="";
4839        _OPT_VIEWER_X="$1";        _OPT_VIEWER_X_TTY="$1";
4840        shift;        shift;
4841        ;;        ;;
4842      *)      *)
4843        error 'main_parse_args(): error on argument parsing : '"\`$*'";        error 'main_parse_args(): unknown option '"\`${mpa_opt}'.";
4844        ;;        ;;
4845      esac;      esac;
4846    done;    done;
# Line 4776  only resoutions of 75 or 100 dpi are sup Line 4851  only resoutions of 75 or 100 dpi are sup
4851      leave;      leave;
4852    fi;    fi;
4853    
4854    ### main_parse_args()
4855      case "$_OPT_DEFAULT_MODES" in
4856      '') :; ;;
4857      *,*)
4858        obj_from_output _OPT_DEFAULT_MODES \
4859          obj _OPT_DEFAULT_MODES list_from_split ',';
4860        ;;
4861      *) :; ;;
4862      esac;
4863    
4864    # Remaining arguments are file names (filespecs).    # Remaining arguments are file names (filespecs).
4865    # Save them to list $_FILEARGS    # Save them to list $_FILEARGS
4866    if is_equal "$#" 0    if is_equal "$#" 0
# Line 4882  main_set_mode() Line 4967  main_set_mode()
4967      eval "${return_ok}";      eval "${return_ok}";
4968    fi;    fi;
4969    
4970    if obj _OPT_MODE is_equal 'source'  ### main_set_mode()
4971      case "${_OPT_MODE}" in
4972      dvi)
4973        if obj _OPT_VIEWER_DVI_TTY is_not_empty
4974        then
4975          _VIEWER_TERMINAL='yes';
4976          _OPT_VIEWER_DVI="${_OPT_VIEWER_DVI_TTY}";
4977        elif obj _OPT_VIEWER_DVI is_not_empty
4978        then
4979          if list_has_not_prog _VIEWER_DVI ${_OPT_VIEWER_DVI}
4980          then
4981            _VIEWER_TERMINAL='yes';
4982          fi;
4983        fi;
4984        if obj _OPT_VIEWER_DVI is_empty && is_not_X && \
4985           obj _VIEWER_DVI_TTY is_empty
4986        then
4987          _OPT_MODE='';
4988        fi;
4989        ;;
4990      html)
4991        if obj _OPT_VIEWER_HTML_TTY is_not_empty
4992        then
4993          _VIEWER_TERMINAL='yes';
4994          _OPT_VIEWER_HTML="${_OPT_VIEWER_HTML_TTY}";
4995        elif obj _OPT_VIEWER_HTML is_not_empty
4996        then
4997          if list_has_not_prog _VIEWER_HTML ${_OPT_VIEWER_HTML}
4998          then
4999            _VIEWER_TERMINAL='yes';
5000          fi;
5001        fi;
5002        if obj _OPT_VIEWER_HTML is_empty && is_not_X && \
5003           obj _VIEWER_HTML_TTY is_empty
5004        then
5005          _OPT_MODE='';
5006        fi;
5007        ;;
5008      pdf)
5009        if obj _OPT_VIEWER_PDF_TTY is_not_empty
5010        then
5011          _VIEWER_TERMINAL='yes';
5012          _OPT_VIEWER_PDF="${_OPT_VIEWER_PDF_TTY}";
5013        elif obj _OPT_VIEWER_PDF is_not_empty
5014        then
5015          if list_has_not_prog _VIEWER_PDF ${_OPT_VIEWER_PDF}
5016          then
5017            _VIEWER_TERMINAL='yes';
5018          fi;
5019        fi;
5020        if obj _OPT_VIEWER_PDF is_empty && is_not_X && \
5021           obj _VIEWER_PDF_TTY is_empty
5022        then
5023          _OPT_MODE='';
5024        fi;
5025        ;;
5026    ### main_set_mode()
5027      ps)
5028        if obj _OPT_VIEWER_PS_TTY is_not_empty
5029        then
5030          _VIEWER_TERMINAL='yes';
5031          _OPT_VIEWER_PS="${_OPT_VIEWER_PS_TTY}";
5032        elif obj _OPT_VIEWER_PS is_not_empty
5033        then
5034          if list_has_not_prog _VIEWER_PS ${_OPT_VIEWER_PS}
5035          then
5036            _VIEWER_TERMINAL='yes';
5037          fi;
5038        fi;
5039        if obj _OPT_VIEWER_PS is_empty && is_not_X && \
5040           obj _VIEWER_PS_TTY is_empty
5041        then
5042          _OPT_MODE='';
5043        fi;
5044        ;;
5045      x)
5046        if obj _OPT_VIEWER_X_TTY is_not_empty
5047        then
5048          _VIEWER_TERMINAL='yes';
5049          _OPT_VIEWER_X="${_OPT_VIEWER_X_TTY}";
5050        elif obj _OPT_VIEWER_X is_not_empty
5051        then
5052          if list_has_not_prog _VIEWER_X ${_OPT_VIEWER_X}
5053          then
5054            _VIEWER_TERMINAL='yes';
5055          fi;
5056        fi;
5057        if obj _OPT_VIEWER_X is_empty && is_not_X && \
5058           obj _VIEWER_X_TTY is_empty
5059        then
5060          _OPT_MODE='';
5061        fi;
5062        ;;
5063      esac;
5064      if is_not_X
5065    then    then
5066      _DISPLAY_MODE='source';      _VIEWER_TERMINAL='yes';
     eval ${_UNSET} msm_modes;  
     eval ${_UNSET} msm_viewer;  
     eval ${_UNSET} msm_viewers;  
     eval "${return_ok}";  
5067    fi;    fi;
5068    
5069    ### main_set_mode()
5070    case "${_OPT_MODE}" in    case "${_OPT_MODE}" in
5071    '')                           # automatic mode    '')                           # automatic mode
5072      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
# Line 4915  main_set_mode() Line 5091  main_set_mode()
5091        eval ${_UNSET} msm_viewers;        eval ${_UNSET} msm_viewers;
5092        eval "${return_ok}";        eval "${return_ok}";
5093        ;;        ;;
5094    ### main_set_mode()
5095      esac;      esac;
5096      if is_not_X      if is_not_X
5097      then      then
# Line 4932  main_set_mode() Line 5109  main_set_mode()
5109        msm_modes="${_OPT_DEFAULT_MODES}";        msm_modes="${_OPT_DEFAULT_MODES}";
5110      fi;      fi;
5111      ;;      ;;
5112      source)
5113        _DISPLAY_MODE='source';
5114        eval ${_UNSET} msm_modes;
5115        eval ${_UNSET} msm_viewer;
5116        eval ${_UNSET} msm_viewers;
5117        eval "${return_ok}";
5118        ;;
5119    text)    text)
5120      _DISPLAY_MODE='text';      _DISPLAY_MODE='text';
5121      eval ${_UNSET} msm_modes;      eval ${_UNSET} msm_modes;
# Line 4946  main_set_mode() Line 5130  main_set_mode()
5130      eval ${_UNSET} msm_viewers;      eval ${_UNSET} msm_viewers;
5131      eval "${return_ok}";      eval "${return_ok}";
5132      ;;      ;;
5133    ### main_set_mode()
5134    html)    html)
5135      _DISPLAY_MODE='html';      _DISPLAY_MODE='html';
5136      msm_modes="${_OPT_MODE}";      msm_modes="${_OPT_MODE}";
# Line 4960  main_set_mode() Line 5145  main_set_mode()
5145    esac;    esac;
5146    
5147    # only viewer modes are left    # only viewer modes are left
5148    eval set x "$(list_from_split "${msm_modes}" ',')";    eval set x "${msm_modes}";
   exit_test;  
5149    shift;    shift;
5150    while test "$#" -gt 0    while is_greater_than "$#" 0
5151    do    do
5152      m="$1";      m="$1";
5153      shift;      shift;
# Line 4973  main_set_mode() Line 5157  main_set_mode()
5157        then        then
5158          msm_viewer="${_OPT_VIEWER_DVI}";          msm_viewer="${_OPT_VIEWER_DVI}";
5159        else        else
5160          msm_viewer="$(_get_first_prog "$_VIEWER_DVI}")";          obj_from_output msm_viewer _get_first_prog _VIEWER_DVI;
         exit_test;  
5161        fi;        fi;
5162        if obj msm_viewer is_empty        if obj msm_viewer is_empty
5163        then        then
5164          error 'No viewer for dvi mode available.';          error 'No viewer for dvi mode available.';
5165        fi;        fi;
5166    ### main_set_mode()
5167        if is_not_equal "$?" 0        if is_not_equal "$?" 0
5168        then        then
5169          continue;          continue;
# Line 5002  main_set_mode() Line 5186  main_set_mode()
5186          else          else
5187            msm_viewers="${_VIEWER_HTML_TTY}";            msm_viewers="${_VIEWER_HTML_TTY}";
5188          fi;          fi;
5189          msm_viewer="$(_get_first_prog "${msm_viewers}")";          obj_from_output msm_viewer _get_first_prog msm_viewers;
         exit_test;  
5190        fi;        fi;
5191        if obj msm_viewer is_empty        if obj msm_viewer is_empty
5192        then        then
# Line 5013  main_set_mode() Line 5196  main_set_mode()
5196        then        then
5197          continue;          continue;
5198        fi;        fi;
5199    ### main_set_mode()
5200        _DISPLAY_PROG="${msm_viewer}";        _DISPLAY_PROG="${msm_viewer}";
5201        _DISPLAY_MODE=html;        _DISPLAY_MODE=html;
5202        eval ${_UNSET} msm_modes;        eval ${_UNSET} msm_modes;
# Line 5025  main_set_mode() Line 5209  main_set_mode()
5209        then        then
5210          msm_viewer="${_OPT_VIEWER_PDF}";          msm_viewer="${_OPT_VIEWER_PDF}";
5211        else        else
5212          msm_viewer="$(_get_first_prog "${_VIEWER_PDF}")";          obj_from_output msm_viewer _get_first_prog _VIEWER_PDF;
         exit_test;  
5213        fi;        fi;
5214        if obj msm_viewer is_empty        if obj msm_viewer is_empty
5215        then        then
# Line 5043  main_set_mode() Line 5226  main_set_mode()
5226        eval ${_UNSET} msm_viewers;        eval ${_UNSET} msm_viewers;
5227        eval "${return_ok}";        eval "${return_ok}";
5228        ;;        ;;
5229    ### main_set_mode()
5230      ps)      ps)
5231        if obj _OPT_VIEWER_PS is_not_empty        if obj _OPT_VIEWER_PS is_not_empty
5232        then        then
5233          msm_viewer="${_OPT_VIEWER_PS}";          msm_viewer="${_OPT_VIEWER_PS}";
5234        else        else
5235          msm_viewer="$(_get_first_prog "${_VIEWER_PS}")";          obj_from_output msm_viewer _get_first_prog _VIEWER_PS;
         exit_test;  
5236        fi;        fi;
5237        if obj msm_viewer is_empty        if obj msm_viewer is_empty
5238        then        then
# Line 5061  main_set_mode() Line 5244  main_set_mode()
5244        fi;        fi;
5245        _DISPLAY_PROG="${msm_viewer}";        _DISPLAY_PROG="${msm_viewer}";
5246        _DISPLAY_MODE="ps";        _DISPLAY_MODE="ps";
5247       eval ${_UNSET} msm_modes;        eval ${_UNSET} msm_modes;
5248        eval ${_UNSET} msm_viewer;        eval ${_UNSET} msm_viewer;
5249        eval ${_UNSET} msm_viewers;        eval ${_UNSET} msm_viewers;
5250        eval "${return_ok}";        eval "${return_ok}";
# Line 5073  main_set_mode() Line 5256  main_set_mode()
5256        eval ${_UNSET} msm_viewers;        eval ${_UNSET} msm_viewers;
5257        eval "${return_ok}";        eval "${return_ok}";
5258        ;;        ;;
5259    ### main_set_mode()
5260      tty)      tty)
5261        _DISPLAY_MODE='tty';        _DISPLAY_MODE='tty';
5262        eval ${_UNSET} msm_modes;        eval ${_UNSET} msm_modes;
# Line 5085  main_set_mode() Line 5269  main_set_mode()
5269        then        then
5270          msm_viewer="${_OPT_VIEWER_X}";          msm_viewer="${_OPT_VIEWER_X}";
5271        else        else
5272          msm_viewer="$(_get_first_prog "${_VIEWER_X}")";          obj_from_output msm_viewer _get_first_prog _VIEWER_X;
         exit_test;  
5273        fi;        fi;
5274        if obj msm_viewer is_empty        if obj msm_viewer is_empty
5275        then        then
# Line 5103  main_set_mode() Line 5286  main_set_mode()
5286        eval ${_UNSET} msm_viewers;        eval ${_UNSET} msm_viewers;
5287        eval "${return_ok}";        eval "${return_ok}";
5288        ;;        ;;
5289    ### main_set_mode()
5290      X)      X)
5291        _DISPLAY_MODE='X';        _DISPLAY_MODE='X';
5292        eval ${_UNSET} msm_modes;        eval ${_UNSET} msm_modes;
# Line 5119  main_set_mode() Line 5303  main_set_mode()
5303  } # main_set_mode()  } # main_set_mode()
5304    
5305    
5306  # _get_first_prog (<proglist>)  # _get_first_prog (<prog> ...)
5307  #  #
5308  # Retrieve first argument that represents an existing program in $PATH.  # Retrieve from arguments the first existing program in $PATH.
5309  # Local function for main_set_mode().  # Local function for main_set_mode().
5310  #  #
 # Arguments: 1; a comma-separated list of commands (with options),  
 #               like $_VIEWER_*.  
 #  
5311  # Return  : `1' if none found, `0' if found.  # Return  : `1' if none found, `0' if found.
5312  # Output  : the argument that succeded.  # Output  : the argument that succeded.
5313  #  #
# Line 5136  _get_first_prog() Line 5317  _get_first_prog()
5317  {  {
5318    if is_equal "$#" 0    if is_equal "$#" 0
5319    then    then
     error "_get_first_prog() needs 1 argument.";  
   fi;  
   if is_empty "$1"  
   then  
5320      return "${_BAD}";      return "${_BAD}";
5321    fi;    fi;
5322    eval set x "$(list_from_split "$1" ',')";    eval x='"${'"$1"'}"';
5323    exit_test;    eval set x "$x";
5324    shift;    shift;
5325    for i    for i
5326    do    do
# Line 5152  _get_first_prog() Line 5329  _get_first_prog()
5329      then      then
5330        continue;        continue;
5331      fi;      fi;
5332      if eval is_prog "$(get_first_essential ${_gfp_i})"      if eval is_prog "${_gfp_i}"
5333      then      then
5334        exit_test;        exit_test;
5335        obj _gfp_i echo1;        obj _gfp_i echo1;
# Line 5183  main_do_fileargs() Line 5360  main_do_fileargs()
5360    shift;    shift;
5361    eval ${_UNSET} _FILEARGS;    eval ${_UNSET} _FILEARGS;
5362    # temporary storage of all input to $_TMP_CAT    # temporary storage of all input to $_TMP_CAT
5363    while test "$#" -ge 2    while is_greater_than "$#" 1
5364    do    do
5365      # test for `s name' arguments, with `s' a 1-char standard section      # test for `s name' arguments, with `s' a 1-char standard section
5366      mdfa_filespec="$1";      mdfa_filespec="$1";
# Line 5202  main_do_fileargs() Line 5379  main_do_fileargs()
5379        register_file '-'        register_file '-'
5380        continue;        continue;
5381        ;;        ;;
5382    ### main_do_fileargs()
5383      ?)      ?)
5384        if obj _OPT_APROPOS is_yes        if obj _OPT_APROPOS is_yes
5385        then        then
# Line 5232  main_do_fileargs() Line 5410  main_do_fileargs()
5410          continue;          continue;
5411        fi;        fi;
5412        ;;        ;;
5413    ### main_do_fileargs()
5414      *)      *)
5415        special_filespec;        special_filespec;
5416        if obj _OPT_APROPOS is_yes        if obj _OPT_APROPOS is_yes
# Line 5243  main_do_fileargs() Line 5422  main_do_fileargs()
5422        ;;        ;;
5423      esac;      esac;
5424    done;                         # end of `s name' test    done;                         # end of `s name' test
5425    while test "$#" -gt 0    while is_greater_than "$#" 0
5426    do    do
5427      mdfa_filespec="$1";      mdfa_filespec="$1";
5428      _FILESPEC_ARG="$1";      _FILESPEC_ARG="$1";
# Line 5276  main_set_resources() Line 5455  main_set_resources()
5455    func_check main_set_resources = 0 "$@";    func_check main_set_resources = 0 "$@";
5456    # $msr_prog   viewer program    # $msr_prog   viewer program
5457    # $msr_rl     resource list    # $msr_rl     resource list
5458    msr_title="$(get_first_essential \    obj_from_output msr_title \
5459                   "${_OPT_TITLE}" "${_REGISTERED_TITLE}")";      get_first_essential "${_OPT_TITLE}" "${_REGISTERED_TITLE}";
   exit_test;  
5460    _OUTPUT_FILE_NAME='';    _OUTPUT_FILE_NAME='';
5461    eval set x "${msr_title}";    eval set x "${msr_title}";
5462    shift;    shift;
# Line 5305  main_set_resources() Line 5483  main_set_resources()
5483      _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}${msr_n}";      _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}${msr_n}";
5484      shift;      shift;
5485    done;    done;
5486    ### main_set_resources()
5487    case "${_OUTPUT_FILE_NAME}" in    case "${_OUTPUT_FILE_NAME}" in
5488    '')    '')
5489      _OUTPUT_FILE_NAME='-';      _OUTPUT_FILE_NAME='-';
# Line 5327  main_set_resources() Line 5506  main_set_resources()
5506    
5507    eval set x "${_DISPLAY_PROG}";    eval set x "${_DISPLAY_PROG}";
5508    shift;    shift;
5509    msr_prog="$(base_name "$1")";    obj_from_output msr_prog base_name "$1";
   exit_test;  
5510    shift;    shift;
5511    if test $# != 0    if is_greater_than $# 0
5512    then    then
5513      if obj _DISPLAY_PROG is_empty      if obj _DISPLAY_PROG is_empty
5514      then      then
# Line 5339  main_set_resources() Line 5517  main_set_resources()
5517        _DISPLAY_ARGS="$* ${_DISPLAY_ARGS}";        _DISPLAY_ARGS="$* ${_DISPLAY_ARGS}";
5518      fi;      fi;
5519    fi;    fi;
5520    ### main_set_resources()
5521    msr_rl='';    msr_rl='';
5522    if obj _OPT_BD is_not_empty    if obj _OPT_BD is_not_empty
5523    then    then
# Line 5370  main_set_resources() Line 5549  main_set_resources()
5549        ;;        ;;
5550      esac;      esac;
5551    fi;    fi;
5552    ### main_set_resources()
5553    if obj _OPT_FG is_not_empty    if obj _OPT_FG is_not_empty
5554    then    then
5555      case "${msr_prog}" in      case "${msr_prog}" in
# Line 5403  main_set_resources() Line 5583  main_set_resources()
5583        ;;        ;;
5584      esac;      esac;
5585    fi;    fi;
5586    ### main_set_resources()
5587    if is_empty "${_OPT_RESOLUTION}"    if is_empty "${_OPT_RESOLUTION}"
5588    then    then
5589      _OPT_RESOLUTION="${_DEFAULT_RESOLUTION}";      _OPT_RESOLUTION="${_DEFAULT_RESOLUTION}";
# Line 5433  main_set_resources() Line 5614  main_set_resources()
5614          list_append msr_rl '-z' '104';          list_append msr_rl '-z' '104';
5615          # '100' corresponds to 72dpi          # '100' corresponds to 72dpi
5616          ;;          ;;
5617    ### main_set_resources()
5618        100)        100)
5619          list_append msr_rl '-z' '139';          list_append msr_rl '-z' '139';
5620          ;;          ;;
# Line 5466  main_set_resources() Line 5648  main_set_resources()
5648        do        do
5649          list_append msr_rl '-xrm' "$i";          list_append msr_rl '-xrm' "$i";
5650        done;        done;
5651    ### main_set_resources()
5652        ;;        ;;
5653      esac;      esac;
5654    fi;    fi;
# Line 5531  main_display() Line 5714  main_display()
5714      exit_test;      exit_test;
5715      _do_opt_V;      _do_opt_V;
5716    
5717    ### main_display()
5718      obj md_modefile rm_file;      obj md_modefile rm_file;
5719      mv "${_TMP_CAT}" "${md_modefile}";      mv "${_TMP_CAT}" "${md_modefile}";
5720      trap_unset;      trap_unset;
# Line 5543  main_display() Line 5727  main_display()
5727    text|tty)    text|tty)
5728      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
5729      '')      '')
5730        md_device="$(get_first_essential \        obj_from_output md_device \
5731                       "${_OPT_TEXT_DEVICE}" "${_DEFAULT_TTY_DEVICE}")";          get_first_essential "${_OPT_TEXT_DEVICE}" "${_DEFAULT_TTY_DEVICE}";
       exit_test;  
5732        ;;        ;;
5733      ascii|cp1047|latin1|utf8)      ascii|cp1047|latin1|utf8)
5734        md_device="${_OPT_DEVICE}";        md_device="${_OPT_DEVICE}";
# Line 5564  wrong device for ${_DISPLAY_MODE} mode: Line 5747  wrong device for ${_DISPLAY_MODE} mode:
5747        tmp_cat | eval "${md_groggy}" "${md_addopts}";        tmp_cat | eval "${md_groggy}" "${md_addopts}";
5748      else      else
5749        md_pager='';        md_pager='';
5750    ### main_display()
5751        for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \        for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \
5752                 'less -r -R' 'more' 'pager' 'cat'                 'less -r -R' 'more' 'pager' 'cat'
5753        do        do
# Line 5591  wrong device for ${_DISPLAY_MODE} mode: Line 5775  wrong device for ${_DISPLAY_MODE} mode:
5775    
5776    #### viewer modes    #### viewer modes
5777    
5778    ### main_display()
5779    dvi)    dvi)
5780      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
5781      ''|dvi) do_nothing; ;;      ''|dvi) do_nothing; ;;
# Line 5617  wrong device for ${_DISPLAY_MODE} mode: Line 5802  wrong device for ${_DISPLAY_MODE} mode:
5802      exit_test;      exit_test;
5803      _do_display;      _do_display;
5804      ;;      ;;
5805    ### main_display()
5806    pdf)    pdf)
5807      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
5808      ''|ps)      ''|ps)
# Line 5646  wrong device for ${_DISPLAY_MODE} mode: Line 5832  wrong device for ${_DISPLAY_MODE} mode:
5832      exit_test;      exit_test;
5833      _do_display;      _do_display;
5834      ;;      ;;
5835    ### main_display()
5836    x)    x)
5837      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
5838      X*)      X*)
# Line 5674  wrong device for ${_DISPLAY_MODE} mode: Line 5861  wrong device for ${_DISPLAY_MODE} mode:
5861      exit_test;      exit_test;
5862      _do_display;      _do_display;
5863      ;;      ;;
5864    ### main_display()
5865    X)    X)
5866      case "${_OPT_DEVICE}" in      case "${_OPT_DEVICE}" in
5867      '')      '')

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26