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

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

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

revision 1.27 by wl, Mon Jun 20 19:27:41 2005 UTC revision 1.28 by wl, Fri Jun 24 19:52:39 2005 UTC
# Line 25  Line 25 
25  # Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.  # Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
26    
27  _PROGRAM_NAME='groffer';  _PROGRAM_NAME='groffer';
28  _PROGRAM_VERSION='0.9.16';  _PROGRAM_VERSION='0.9.17';
29  _LAST_UPDATE='19 Jun 2005';  _LAST_UPDATE='23 Jun 2005';
30    
31    
32  ########################################################################  ########################################################################
# Line 76  then Line 76  then
76    # _get_opt_shell ("$@")    # _get_opt_shell ("$@")
77    #    #
78    # Determine whether `--shell' was specified in $GROFF_OPT or in $*;    # Determine whether `--shell' was specified in $GROFF_OPT or in $*;
79    # if so echo its argument.    # if so, echo its argument.
80      #
81      # Variable prefix: _gos
82    #    #
83    _get_opt_shell()    _get_opt_shell()
84    {    {
     local i;  
     local _sh;  
85      case " ${GROFFER_OPT} $*" in      case " ${GROFFER_OPT} $*" in
86        *\ --shell\ *|*\ --shell=*)        *\ --shell\ *|*\ --shell=*)
87          (          (
88            eval set -- "${GROFFER_OPT}" '"$@"';            eval set x "${GROFFER_OPT}" '"$@"';
89            _sh='';            shift;
90            for i in "$@";            _gos_sh='';
91              for i;
92            do            do
93              case "$1" in              case "$1" in
94                --shell)                --shell)
95                  if test "$#" -ge 2;                  if test "$#" -ge 2;
96                  then                  then
97                    _sh="$2";                    _gos_sh="$2";
98                    shift;                    shift;
99                  fi;                  fi;
100                  ;;                  ;;
101                --shell=?*)                --shell=?*)
102                  # delete up to first `=' character                  # delete up to first `=' character
103                  _sh="$(echo -n "$1" | sed -e 's/^[^=]*=//')";                  _gos_sh="$(echo -n "$1" | sed -e 's/^[^=]*=//')";
104                  ;;                  ;;
105              esac;              esac;
106              shift;              shift;
107            done;            done;
108            echo -n "${_sh}";            echo -n "${_gos_sh}";
109          )          )
110          ;;          ;;
111      esac;      esac;
112        unset _gos_sh;
113    }    }
114    
115    
# Line 209  _DEBUG_LM='no';                        # disable landmark mes Line 211  _DEBUG_LM='no';                        # disable landmark mes
211    
212  # characters  # characters
213    
 export _BQUOTE;  
 export _BSLASH;  
 export _DQUOTE;  
 export _NEWLINE;  
 export _LBRACK;  
 export _LPAR;  
 export _RBRACK;  
 export _RPAR;  
214  export _SPACE;  export _SPACE;
215  export _SQUOTE;  export _SQUOTE;
216  export _TAB;  export _TAB;
217    
 _BQUOTE='`';  
 _BSLASH='\';  
 _DQUOTE='"';  
 _NEWLINE='  
 ';  
 _LBRACK='[';  
 _LPAR='(';  
 _RBRACK=']';  
 _RPAR=')';  
218  _SPACE=' ';  _SPACE=' ';
219  _SQUOTE="'";  _SQUOTE="'";
220  _TAB='  ';  _TAB='  ';
# Line 253  _NO="${_BAD}"; Line 238  _NO="${_BAD}";
238  _YES="${_GOOD}";  _YES="${_GOOD}";
239  _OK="${_GOOD}";  _OK="${_GOOD}";
240    
241  # quasi-functions, call with `eval'  # quasi-functions, call with `eval', e.g `eval "${return_ok}"'
242  export return_ok;  export return_ok;
243  export return_good;  export return_good;
244  export return_bad;  export return_bad;
245  export return_yes;  export return_yes;
246  export return_no;  export return_no;
247  export return_error;  export return_error;
248    export return_var;
249  return_ok="func_pop; return ${_OK}";  return_ok="func_pop; return ${_OK}";
250  return_good="func_pop; return ${_GOOD}";  return_good="func_pop; return ${_GOOD}";
251  return_bad="func_pop; return ${_BAD}";  return_bad="func_pop; return ${_BAD}";
252  return_yes="func_pop; return ${_YES}";  return_yes="func_pop; return ${_YES}";
253  return_no="func_pop; return ${_NO}";  return_no="func_pop; return ${_NO}";
254  return_error="func_pop; return ${_ERROR}";  return_error="func_pop; return ${_ERROR}";
255    return_var="func_pop; return";  # add number, e.g. `eval "${return_var} $n'
256    
257    
258  export _DEFAULT_MODES;  export _DEFAULT_MODES;
# Line 430  export _FUNC_STACK;            # Store debugging i Line 417  export _FUNC_STACK;            # Store debugging i
417  export _REGISTERED_TITLE;       # Processed file names.  export _REGISTERED_TITLE;       # Processed file names.
418  # _HAS_* from availability tests  # _HAS_* from availability tests
419  export _HAS_COMPRESSION;        # `yes' if compression is available  export _HAS_COMPRESSION;        # `yes' if compression is available
 export _HAS_OPTS_GNU;           # `yes' if GNU `getopt' is available  
 export _HAS_OPTS_POSIX;         # `yes' if POSIX `getopts' is available  
420  # _MAN_* finally used configuration of man searching  # _MAN_* finally used configuration of man searching
421  export _MAN_ALL;                # search all man pages per filespec  export _MAN_ALL;                # search all man pages per filespec
422  export _MAN_ENABLE;             # enable search for man pages  export _MAN_ENABLE;             # enable search for man pages
# Line 439  export _MAN_EXT;               # extension for man pa Line 424  export _MAN_EXT;               # extension for man pa
424  export _MAN_FORCE;              # force file parameter to be man pages  export _MAN_FORCE;              # force file parameter to be man pages
425  export _MAN_IS_SETUP;           # setup man variables only once  export _MAN_IS_SETUP;           # setup man variables only once
426  export _MAN_LANG;               # language for man pages  export _MAN_LANG;               # language for man pages
427    export _MAN_LANG2;              # language for man pages
428  export _MAN_LANG_DONE;          # language dirs added to man path  export _MAN_LANG_DONE;          # language dirs added to man path
429  export _MAN_PATH;               # search path for man pages  export _MAN_PATH;               # search path for man pages
430  export _MAN_SEC;                # sections for man pages; sep. `:'  export _MAN_SEC;                # sections for man pages; sep. `:'
# Line 547  _FILEARGS=''; Line 533  _FILEARGS='';
533    
534  # _HAS_* from availability tests  # _HAS_* from availability tests
535  _HAS_COMPRESSION='';  _HAS_COMPRESSION='';
 _HAS_OPTS_GNU='';  
 _HAS_OPTS_POSIX='';  
536    
537  # _TMP_* temporary files  # _TMP_* temporary files
538  _TMP_DIR='';  _TMP_DIR='';
# Line 583  reset() Line 567  reset()
567    _MAN_FORCE='no';              # first local file, then search man page    _MAN_FORCE='no';              # first local file, then search man page
568    _MAN_IS_SETUP='no';    _MAN_IS_SETUP='no';
569    _MAN_LANG='';    _MAN_LANG='';
570    _MAN_LANG_DONE='no';    _MAN_LANG2='';
571    _MAN_PATH='';    _MAN_PATH='';
572    _MAN_SEC='';    _MAN_SEC='';
573    _MAN_SEC_DONE='no';    _MAN_SEC_DONE='no';
# Line 721  diag() Line 705  diag()
705  #  #
706  # Print an error message to standard error; exit with an error condition  # Print an error message to standard error; exit with an error condition
707  #  #
708    # Variable prefix: err
709    #
710  error()  error()
711  {  {
712    local i;    err_code="${_ERROR}";
   local _code;  
   _code="${_ERROR}";  
713    case "$#" in    case "$#" in
714      0) true; ;;      0) true; ;;
715      1) echo2 'groffer error: '"$1"; ;;      1) echo2 'groffer error: '"$1"; ;;
716      2)      2)
717        echo2 'groffer error: '"$1";        echo2 'groffer error: '"$1";
718        _code="$2";        err_code="$2";
719        ;;        ;;
720      *) echo2 'groffer error: wrong number of arguments in error().'; ;;      *) echo2 'groffer error: wrong number of arguments in error().'; ;;
721    esac;    esac;
# Line 742  error() Line 726  error()
726    clean_up;    clean_up;
727    kill "${_PROCESS_ID}" >${_NULL_DEV} 2>&1;    kill "${_PROCESS_ID}" >${_NULL_DEV} 2>&1;
728    kill -9 "${_PROCESS_ID}" >${_NULL_DEV} 2>&1;    kill -9 "${_PROCESS_ID}" >${_NULL_DEV} 2>&1;
729    exit "${_code}";    n="${err_code}";
730      unset err_code;
731      exit "$n";
732  }  }
733    
734    
# Line 753  error() Line 739  error()
739  #  #
740  abort()  abort()
741  {  {
742    error "Program aborted.";    error "abort(): Program aborted.";
743    exit 1;    exit 1;
744  }  }
745    
# Line 769  abort() Line 755  abort()
755  #   <nr_args>:   number of arguments to be checked against <operator>  #   <nr_args>:   number of arguments to be checked against <operator>
756  #   "$@":        the arguments of the calling function.  #   "$@":        the arguments of the calling function.
757  #  #
758    # Variable prefix: fc
759    #
760  func_check()  func_check()
761  {  {
   local _comp;  
   local _fname;  
   local _nargs;  
   local _op;  
   local _s;  
762    if test "$#" -lt 3;    if test "$#" -lt 3;
763    then    then
764      error 'func_check() needs at least 3 arguments.';      error 'func_check() needs at least 3 arguments.';
765    fi;    fi;
766    _fname="$1";    fc_fname="$1";
767    case "$3" in    case "$3" in
768      1)      1)
769        _nargs="$3";        fc_nargs="$3";
770        _s='';        fc_s='';
771        ;;        ;;
772      0|[2-9])      0|[2-9])
773        _nargs="$3";        fc_nargs="$3";
774        _s='s';        fc_s='s';
775        ;;        ;;
776      *)      *)
777        error "func_check(): third argument must be a digit.";        error "func_check(): third argument must be a digit.";
# Line 796  func_check() Line 779  func_check()
779    esac;    esac;
780    case "$2" in    case "$2" in
781      '='|'-eq')      '='|'-eq')
782        _op='-eq';        fc_op='-eq';
783        _comp='exactly';        fc_comp='exactly';
784        ;;        ;;
785      '>='|'-ge')      '>='|'-ge')
786        _op='-ge';        fc_op='-ge';
787        _comp='at least';        fc_comp='at least';
788        ;;        ;;
789      '<='|'-le')      '<='|'-le')
790        _op='-le';        fc_op='-le';
791        _comp='at most';        fc_comp='at most';
792        ;;        ;;
793      '<'|'-lt')      '<'|'-lt')
794        _op='-lt';        fc_op='-lt';
795        _comp='less than';        fc_comp='less than';
796        ;;        ;;
797      '>'|'-gt')      '>'|'-gt')
798        _op='-gt';        fc_op='-gt';
799        _comp='more than';        fc_comp='more than';
800        ;;        ;;
801      '!='|'-ne')      '!='|'-ne')
802        _op='-ne';        fc_op='-ne';
803        _comp='not';        fc_comp='not';
804        ;;        ;;
805      *)      *)
806        error \        error \
# Line 825  func_check() Line 808  func_check()
808        ;;        ;;
809    esac;    esac;
810    shift 3;    shift 3;
811    if test "$#" "${_op}" "${_nargs}";    if test "$#" "${fc_op}" "${fc_nargs}";
812    then    then
813      do_nothing;      do_nothing;
814    else    else
815      error \      error "func_check(): \
816        "${_fname}"'() needs '"${_comp} ${_nargs}"' argument'"${_s}"'.';  ${fc_fname}"'() needs '"${fc_comp} ${fc_nargs}"' argument'"${fc_s}"'.';
817    fi;    fi;
818    if test _"${_DEBUG}"_ = _yes_;    if test _"${_DEBUG}"_ = _yes_;
819    then    then
820      func_push "${_fname} $*";      func_push "${fc_fname} $*";
821    fi;    fi;
822      unset fc_comp;
823      unset fc_fname;
824      unset fc_nargs;
825      unset fc_op;
826      unset fc_s;
827  }  }
828    
829    
# Line 885  func_pop() Line 873  func_pop()
873  #  #
874  # Arguments: 1  # Arguments: 1
875  #  #
876    # Variable prefix: fp
877    #
878  func_push()  func_push()
879  {  {
   local _element;  
880    if test _"${_DEBUG}"_ = _yes_;    if test _"${_DEBUG}"_ = _yes_;
881    then    then
882      if test "$#" -ne 1;      if test "$#" -ne 1;
# Line 897  func_push() Line 886  func_push()
886      case "$1" in      case "$1" in
887        *'!'*)        *'!'*)
888          # remove all bangs `!'.          # remove all bangs `!'.
889          _element="$(echo -n "$1" | sed -e 's/!//g')";          fp_element="$(echo -n "$1" | sed -e 's/!//g')";
890          ;;          ;;
891        *)        *)
892          _element="$1";          fp_element="$1";
893          ;;          ;;
894      esac;      esac;
895      if test _"${_FUNC_STACK}"_ = __;      if test _"${_FUNC_STACK}"_ = __;
896      then      then
897        _FUNC_STACK="${_element}";        _FUNC_STACK="${fp_element}";
898      else      else
899        _FUNC_STACK="${_element}!${_FUNC_STACK}";        _FUNC_STACK="${fp_element}!${_FUNC_STACK}";
900      fi;      fi;
901    fi;    fi;
902      unset fp_element;
903  }  }
904    
905    
# Line 949  landmark "2: system test"; Line 939  landmark "2: system test";
939    
940    
941  ########################################################################  ########################################################################
942  # Test of `true'.  # Test of `true' and `false'.
943  #  #
944  if true >${_NULL_DEV} 2>&1;  _res="$(true 2>&1)";
945    if test "$?" != 0 || test -n "${_res}";
946  then  then
   true;  
 else  
947    true()    true()
948    {    {
949      return "${_GOOD}";      return "${_GOOD}";
950    }    }
951    fi;
952    _res="$(false 2>&1)";
953    if test "$?" = 0 || test -n "${_res}";
954    then
955    false()    false()
956    {    {
957      return "${_BAD}";      return "${_BAD}";
# Line 984  else Line 976  else
976    }    }
977  fi;  fi;
978  unset _test;  unset _test;
979    unset _res;
 ########################################################################  
 # Test of builtin `local'  
 #  
   
 _t_e_s_t_f_u_n_c_()  
 {  
   local _test >${_NULL_DEV} 2>&1 || return "${_BAD}";  
 }  
   
 if _t_e_s_t_f_u_n_c_;  
 then  
   :  
 else  
   local()  
   {  
     if test _"$1"_ != __;  
     then  
       error "overriding global variable \`$1' with local value.";  
     fi;  
   }  
 fi;  
   
   
 ########################################################################  
 # Test of global setting in functions  
 #  
 _global='outside';  
 _clobber='outside';  
   
 _t_e_s_t_f_u_n_c_()  
 {  
   local _clobber;  
   _global='inside';  
   _clobber='inside';  
 }  
   
 _t_e_s_t_f_u_n_c_;  
 if test _"${_global}"_ != _inside_ || test _"${_clobber}"_ != _outside_;  
 then  
   error "Cannot assign to global variables from within functions.";  
 fi;  
   
 unset _global;  
 unset _clobber;  
   
980    
981  ########################################################################  ########################################################################
982  # Test of function `sed'.  # Test of function `sed'.
# Line 1037  unset _clobber; Line 984  unset _clobber;
984    
985  if test _"$(echo xTesTx \  if test _"$(echo xTesTx \
986             | sed -e 's/^.\([Tt]e*x*sTT*\).*$/\1/' \             | sed -e 's/^.\([Tt]e*x*sTT*\).*$/\1/' \
987             | sed -e '\|T|s|T|t|g')"_ != _test_;             | sed -e 's|T|t|g')"_ != _test_;
988  then  then
989    error 'Test of "sed" command failed.';    error 'Test of "sed" command failed.';
990  fi;  fi;
# Line 1074  fi; Line 1021  fi;
1021    
1022    
1023  ########################################################################  ########################################################################
 _t_e_s_t_f_u_n_c_()  
 {  
   :  
 }  
   
   
 ########################################################################  
1024  #       Definition of normal Functions in alphabetical order  #       Definition of normal Functions in alphabetical order
1025  ########################################################################  ########################################################################
1026  landmark "3: functions";  landmark "3: functions";
# Line 1123  apropos_run() { Line 1063  apropos_run() {
1063  # Arguments : 1  # Arguments : 1
1064  # Output    : the file name part (without slashes)  # Output    : the file name part (without slashes)
1065  #  #
1066    # Variable prefix: bn
1067    #
1068  base_name()  base_name()
1069  {  {
1070    func_check base_name = 1 "$@";    func_check base_name = 1 "$@";
1071    local f;    bn_name="$1";
1072    f="$1";    case "${bn_name}" in
   case "$f" in  
1073      */)      */)
1074        # delete all final slashes        # delete all final slashes
1075        f="$(echo -n "$f" | sed -e '\|.*|s|//*$||')";        bn_name="$(echo -n "${bn_name}" | sed -e 's|//*$||')";
1076        ;;        ;;
1077    esac;    esac;
1078    case "$f" in    case "${bn_name}" in
1079      /|'')      /|'')
1080          unset bn_name;
1081        eval "${return_bad}";        eval "${return_bad}";
1082        ;;        ;;
1083      */*)      */*)
1084        # delete everything before and including the last slash `/'.        # delete everything before and including the last slash `/'.
1085        echo -n "$f" | sed -e '\|.*|s|^.*//*\([^/]*\)$|\1|';        echo -n "${bn_name}" | sed -e 's|^.*//*\([^/]*\)$|\1|';
1086        ;;        ;;
1087      *)      *)
1088        echo -n "$f";        echo -n "${bn_name}";
1089        ;;        ;;
1090    esac;    esac;
1091      unset bn_name;
1092    eval "${return_ok}";    eval "${return_ok}";
1093  }  }
1094    
# Line 1225  landmark '4: dirname()*'; Line 1168  landmark '4: dirname()*';
1168  dirname_append()  dirname_append()
1169  {  {
1170    func_check dirname_append = 2 "$@";    func_check dirname_append = 2 "$@";
   local _res;  
1171    if is_empty "$1";    if is_empty "$1";
1172    then    then
1173      error "dir_append(): first argument is empty.";      error "dir_append(): first argument is empty.";
# Line 1248  dirname_append() Line 1190  dirname_append()
1190  # Argument: 1, a directory name.  # Argument: 1, a directory name.
1191  # Output:   path without double, or trailing slashes.  # Output:   path without double, or trailing slashes.
1192  #  #
1193    # Variable prefix: dc
1194    #
1195  dirname_chop()  dirname_chop()
1196  {  {
1197    func_check dirname_chop = 1 "$@";    func_check dirname_chop = 1 "$@";
   local _arg;  
   local _res;  
   local _sep;  
1198    # replace all multiple slashes by a single slash `/'.    # replace all multiple slashes by a single slash `/'.
1199    _res="$(echo -n "$1" | sed -e '\|.*|s|///*|/|g')";    dc_res="$(echo -n "$1" | sed -e 's|///*|/|g')";
1200    case "${_res}" in    case "${dc_res}" in
1201      ?*/)      ?*/)
1202        # remove trailing slash '/';        # remove trailing slash '/';
1203        echo -n "${_res}" | sed -e '\|.*|s|/$||';        echo -n "${dc_res}" | sed -e 's|/$||';
1204        ;;        ;;
1205      *) echo -n "${_res}"; ;;      *) echo -n "${dc_res}"; ;;
1206    esac;    esac;
1207      unset dc_res;
1208    eval "${return_ok}";    eval "${return_ok}";
1209  }  }
1210    
# Line 1288  dirname_chop() Line 1230  dirname_chop()
1230  # Output  : none  # Output  : none
1231  # Return  : $_GOOD if found, ${_BAD} otherwise.  # Return  : $_GOOD if found, ${_BAD} otherwise.
1232  #  #
1233    # Variable prefix: df
1234    #
1235  do_filearg()  do_filearg()
1236  {  {
1237    func_check do_filearg = 1 "$@";    func_check do_filearg = 1 "$@";
1238    local _filespec;    df_filespec="$1";
   local i;  
   _filespec="$1";  
1239    # store sequence into positional parameters    # store sequence into positional parameters
1240    case "${_filespec}" in    case "${df_filespec}" in
1241      '')      '')
1242           unset df_filespec;
1243         eval "${return_good}";         eval "${return_good}";
1244         ;;         ;;
1245      '-')      '-')
1246        register_file '-';        register_file '-';
1247          unset df_filespec;
1248        eval "${return_good}";        eval "${return_good}";
1249        ;;        ;;
1250      */*)                        # with directory part; so no man search      */*)                        # with directory part; so no man search
1251        set -- 'File';        set 'File';
1252        ;;        ;;
1253      *)      *)
1254        if obj _MAN_ENABLE is_yes;        if obj _MAN_ENABLE is_yes;
1255        then        then
1256          if obj _MAN_FORCE is_yes;          if obj _MAN_FORCE is_yes;
1257          then          then
1258            set -- 'Manpage' 'File';            set 'Manpage' 'File';
1259          else          else
1260            set -- 'File' 'Manpage';            set 'File' 'Manpage';
1261          fi;          fi;
1262        else        else
1263          set -- 'File';          set 'File';
1264        fi;        fi;
1265        ;;        ;;
1266    esac;    esac;
1267    for i in "$@";    for i;
1268    do    do
1269      case "$i" in      case "$i" in
1270        File)        File)
1271          if test -f "${_filespec}";          if test -f "${df_filespec}";
1272          then          then
1273            if test -r "${_filespec}";            if test -r "${df_filespec}";
1274            then            then
1275              register_file "${_filespec}";              register_file "${df_filespec}";
1276                unset df_filespec;
1277              eval "${return_good}";              eval "${return_good}";
1278            else            else
1279              echo2 "could not read \`${_filespec}'";              echo2 "could not read \`${df_filespec}'";
1280                unset df_filespec;
1281              eval "${return_bad}";              eval "${return_bad}";
1282            fi;            fi;
1283          else          else
# Line 1343  do_filearg() Line 1289  do_filearg()
1289          then          then
1290            man_setup;            man_setup;
1291          fi;          fi;
1292          if man_do_filespec "${_filespec}";          if man_do_filespec "${df_filespec}";
1293          then          then
1294              unset df_filespec;
1295            eval "${return_good}";            eval "${return_good}";
1296          else          else
1297            continue;            continue;
# Line 1352  do_filearg() Line 1299  do_filearg()
1299          ;;          ;;
1300      esac;      esac;
1301    done;    done;
1302      unset df_filespec;
1303    eval "${return_bad}";    eval "${return_bad}";
1304  } # do_filearg()  } # do_filearg()
1305    
# Line 1436  do_nothing() Line 1384  do_nothing()
1384  # Return  : `1' if all arguments are empty, `0' if found.  # Return  : `1' if all arguments are empty, `0' if found.
1385  # Output  : the retrieved non-empty argument.  # Output  : the retrieved non-empty argument.
1386  #  #
1387    # Variable prefix: gfe
1388    #
1389  get_first_essential()  get_first_essential()
1390  {  {
1391    func_check get_first_essential '>=' 0 "$@";    func_check get_first_essential '>=' 0 "$@";
   local i;  
1392    if is_equal "$#" 0;    if is_equal "$#" 0;
1393    then    then
1394      eval "${return_ok}";      eval "${return_ok}";
1395    fi;    fi;
1396    for i in "$@";    for i;
1397    do    do
1398      if obj i is_not_empty;      gfe_var="$i";
1399        if obj gfe_var is_not_empty;
1400      then      then
1401        echo -n "$i";        echo -n "${gfe_var}";
1402          unset gfe_var;
1403        eval "${return_ok}";        eval "${return_ok}";
1404      fi;      fi;
1405    done;    done;
1406      unset gfe_var;
1407    eval "${return_bad}";    eval "${return_bad}";
1408  }  }
1409    
# Line 1801  landmark '6: list_*()'; Line 1753  landmark '6: list_*()';
1753  # data consists of space-separated single-quoted elements.  So a list  # data consists of space-separated single-quoted elements.  So a list
1754  # has the form "'first' 'second' '...' 'last'".  See list_append() for  # has the form "'first' 'second' '...' 'last'".  See list_append() for
1755  # more details on the list structure.  The array elements of `list'  # more details on the list structure.  The array elements of `list'
1756  # can be get by `set -- $list`.  # can be get by `set x $list; shift`.
1757    
1758    
1759  ########################################################################  ########################################################################
# Line 1814  landmark '6: list_*()'; Line 1766  landmark '6: list_*()';
1766  #   if <list> is empty:  "'<element>' '...'"  #   if <list> is empty:  "'<element>' '...'"
1767  #   otherwise:           "$list '<element>' ..."  #   otherwise:           "$list '<element>' ..."
1768  #  #
1769    # Variable prefix: la
1770    #
1771  list_append()  list_append()
1772  {  {
1773    func_check list_append '>=' 2 "$@";    func_check list_append '>=' 2 "$@";
1774    local _element;    la_name="$1";
1775    local _list;    eval la_list='"${'$1'}"';
   local _name;  
   _name="$1";  
   eval _list='"${'$1'}"';  
1776    shift;    shift;
1777    for s in "$@";    for s;
1778    do    do
1779      case "$s" in      la_s="$s";
1780        case "${la_s}" in
1781      *\'*)      *\'*)
1782        # escape each single quote by replacing each        # escape each single quote by replacing each
1783        # "'" (squote) by "'\''" (squote bslash squote squote);        # "'" (squote) by "'\''" (squote bslash squote squote);
1784        # note that the backslash must be doubled in the following `sed'        # note that the backslash must be doubled in the following `sed'
1785        _element="$(echo -n "$s" | sed -e 's/'"${_SQUOTE}"'/&\\&&/g')";        la_element="$(echo -n "${la_s}" | sed -e 's/'"${_SQUOTE}"'/&\\&&/g')";
1786        ;;        ;;
1787      '')        '')  
1788        _element="";        la_element="";
1789        ;;        ;;
1790      *)      *)
1791        _element="$s";        la_element="${la_s}";
1792        ;;        ;;
1793      esac;      esac;
1794      if obj _list is_empty;      if obj la_list is_empty;
1795      then      then
1796        _list="'${_element}'";        la_list="'${la_element}'";
1797      else      else
1798        _list="${_list} '${_element}'";        la_list="${la_list} '${la_element}'";
1799      fi;      fi;
1800    done;    done;
1801    eval "${_name}"='"${_list}"';    eval "${la_name}"='"${la_list}"';
1802      unset la_element;
1803      unset la_list;
1804      unset la_name;
1805      unset la_s;
1806    eval "${return_ok}";    eval "${return_ok}";
1807  }  }
1808    
# Line 1878  list_append() Line 1834  list_append()
1834  #     '-a' '-b' '-c' 'arg' '--long' 'larg' '--' 'f1' 'f2'  #     '-a' '-b' '-c' 'arg' '--long' 'larg' '--' 'f1' 'f2'
1835  #  #
1836  #   Use this function in the following way:  #   Use this function in the following way:
1837  #     eval set -- "$(args_norm PRE_NAME "$@")";  #     eval set x "$(args_norm PRE_NAME "$@")";
1838    #     shift;
1839  #     while test "$1" != '--'; do  #     while test "$1" != '--'; do
1840  #       case "$1" in  #       case "$1" in
1841  #       ...  #       ...
# Line 1888  list_append() Line 1845  list_append()
1845  #     shift;         #skip '--'  #     shift;         #skip '--'
1846  #     # all positional parameters ("$@") left are file name parameters.  #     # all positional parameters ("$@") left are file name parameters.
1847  #  #
1848    # Variable prefix: lfc
1849    #
1850  list_from_cmdline()  list_from_cmdline()
1851  {  {
1852    func_check list_from_cmdline '>=' 1 "$@";    func_check list_from_cmdline '>=' 1 "$@";
1853    local _fparams;    lfc_short_n="$(obj_data "$1"_SHORT_NA)";  # short options, no argument
1854    local _fn;    lfc_short_a="$(obj_data "$1"_SHORT_ARG)"; # short options, with argument
1855    local _short_a;    lfc_long_n="$(obj_data "$1"_LONG_NA)";    # long options, no argument
1856    local _short_n;    lfc_long_a="$(obj_data "$1"_LONG_ARG)";   # long options, with argument
1857    local _long_a;    if obj lfc_short_n is_empty;
   local _long_n;  
   local _result;  
   _short_n="$(obj_data "$1"_SHORT_NA)";  # short options, no argument  
   _short_a="$(obj_data "$1"_SHORT_ARG)"; # short options, with argument  
   _long_n="$(obj_data "$1"_LONG_NA)";    # long options, no argument  
   _long_a="$(obj_data "$1"_LONG_ARG)";   # long options, with argument  
   if obj _short_n is_empty;  
1858    then    then
1859      error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.';      error 'list_from_cmdline(): no $'"$1"'_SHORT_NA options.';
1860    fi;    fi;
1861    if obj _short_a is_empty;    if obj lfc_short_a is_empty;
1862    then    then
1863      error 'list_from_cmdline(): no $'"$1"'_SHORT_ARG options.';      error 'list_from_cmdline(): no $'"$1"'_SHORT_ARG options.';
1864    fi;    fi;
1865    if obj _long_n is_empty;    if obj lfc_long_n is_empty;
1866    then    then
1867      error 'list_from_cmdline(): no $'"$1"'_LONG_NA options.';      error 'list_from_cmdline(): no $'"$1"'_LONG_NA options.';
1868    fi;    fi;
1869    if obj _long_a is_empty;    if obj lfc_long_a is_empty;
1870    then    then
1871      error 'list_from_cmdline(): no $'"$1"'_LONG_ARG options.';      error 'list_from_cmdline(): no $'"$1"'_LONG_ARG options.';
1872    fi;    fi;
1873    shift;    shift;
1874    _fn='list_from_cmdline():';    # for error messages    lfc_fn='list_from_cmdline():';         # for error messages
1875    if is_equal "$#" 0;    if is_equal "$#" 0;
1876    then    then
1877      echo -n "'--'";      echo -n "'--'";
1878        unset lfc_fparams;
1879        unset lfc_fn;
1880        unset lfc_short_a;
1881        unset lfc_short_n;
1882        unset lfc_long_a;
1883        unset lfc_long_n;
1884        unset lfc_result;
1885      eval "${return_ok}";      eval "${return_ok}";
1886    fi;    fi;
1887    _fparams='';    lfc_fparams='';
1888    _result='';    lfc_result='';
1889    while test "$#" -ge 1;    while test "$#" -ge 1;
1890    do    do
1891      _arg="$1";      lfc_arg="$1";
1892      shift;      shift;
1893      case "$_arg" in      case "${lfc_arg}" in
1894        --) break; ;;        --) break; ;;
1895        --?*)        --?*)
1896          # delete leading '--';          # delete leading '--';
1897          _opt="$(echo -n "${_arg}" | sed -e 's/^..//')";          lfc_opt="$(echo -n "${lfc_arg}" | sed -e 's/^..//')";
1898          if list_has _long_n "${_opt}";          if list_has lfc_long_n "${lfc_opt}";
1899          then          then
1900            # long option, no argument            # long option, no argument
1901            list_append _result "--${_opt}";            list_append lfc_result "--${lfc_opt}";
1902            continue;            continue;
1903          fi;          fi;
1904          # test on `--opt=arg'          # test on `--opt=arg'
1905          if string_contains "${_opt}" '=';          if string_contains "${lfc_opt}" '=';
1906          then          then
1907            # extract option by deleting from the first '=' to the end            # extract option by deleting from the first '=' to the end
1908            _lopt="$(echo -n "${_opt}" | sed -e 's/=.*$//')";            lfc_lopt="$(echo -n "${lfc_opt}" | sed -e 's/=.*$//')";
1909            if list_has _long_a "${_lopt}";            if list_has lfc_long_a "${lfc_lopt}";
1910            then            then
1911              # get the option argument by deleting up to first `='              # get the option argument by deleting up to first `='
1912              _optarg="$(echo -n "${_opt}" | sed -e 's/^[^=]*=//')";              lfc_optarg="$(echo -n "${lfc_opt}" | sed -e 's/^[^=]*=//')";
1913              list_append _result "--${_lopt}" "${_optarg}";              list_append lfc_result "--${lfc_lopt}" "${lfc_optarg}";
1914              continue;              continue;
1915            fi;            fi;
1916          fi;          fi;
1917          if list_has _long_a "${_opt}";          if list_has lfc_long_a "${lfc_opt}";
1918          then          then
1919            # long option with argument            # long option with argument
1920            if test "$#" -le 0;            if test "$#" -le 0;
1921            then            then
1922              error "${_fn} no argument for option --${_opt}."              error "list_from_cmdline(): \
1923    ${lfc_fn} no argument for option --${lfc_opt}."
1924            fi;            fi;
1925            list_append _result "--${_opt}" "$1";            list_append lfc_result "--${lfc_opt}" "$1";
1926            shift;            shift;
1927            continue;            continue;
1928          fi;          fi;
1929          error "${_fn} --${_opt} is not an option."          error "list_from_cmdline(): ${lfc_fn} --${lfc_opt} is not an option."
1930          ;;          ;;
1931        -?*)                      # short option (cluster)        -?*)                      # short option (cluster)
1932          # delete leading `-';          # delete leading `-';
1933          _rest="$(echo -n "${_arg}" | sed -e 's/^-//')";          lfc_rest="$(echo -n "${lfc_arg}" | sed -e 's/^-//')";
1934          while obj _rest is_not_empty;          while obj lfc_rest is_not_empty;
1935          do          do
1936            # get next short option from cluster (first char of $_rest)            # get next short option from cluster (first char of $lfc_rest)
1937            _optchar="$(echo -n "${_rest}" | sed -e 's/^\(.\).*$/\1/')";            lfc_optchar="$(echo -n "${lfc_rest}" | sed -e 's/^\(.\).*$/\1/')";
1938            # remove first character from ${_rest};            # remove first character from ${lfc_rest};
1939            _rest="$(echo -n "${_rest}" | sed -e 's/^.//')";            lfc_rest="$(echo -n "${lfc_rest}" | sed -e 's/^.//')";
1940            if list_has _short_n "${_optchar}";            if list_has lfc_short_n "${lfc_optchar}";
1941            then            then
1942              list_append _result "-${_optchar}";              list_append lfc_result "-${lfc_optchar}";
1943              continue;              continue;
1944            elif list_has _short_a "${_optchar}";            elif list_has lfc_short_a "${lfc_optchar}";
1945            then            then
1946              if obj _rest is_empty;              if obj lfc_rest is_empty;
1947              then              then
1948                if test "$#" -ge 1;                if test "$#" -ge 1;
1949                then                then
1950                  list_append _result "-${_optchar}" "$1";                  list_append lfc_result "-${lfc_optchar}" "$1";
1951                  shift;                  shift;
1952                  continue;                  continue;
1953                else                else
1954                  error \                  error "list_from_cmdline(): \
1955                    "${_fn}"' no argument for option -'"${_optchar}."  ${lfc_fn}"' no argument for option -'"${lfc_optchar}."
1956                fi;                fi;
1957              else                # rest is the argument              else                # rest is the argument
1958                list_append _result "-${_optchar}" "${_rest}";                list_append lfc_result "-${lfc_optchar}" "${lfc_rest}";
1959                _rest='';                lfc_rest='';
1960                continue;                continue;
1961              fi;              fi;
1962            else            else
1963              error "${_fn} unknown option -${_optchar}."              error "list_from_cmdline(): \
1964    ${lfc_fn} unknown option -${lfc_optchar}."
1965            fi;            fi;
1966          done;          done;
1967          ;;          ;;
1968        *)        *)
1969          # Here, $_arg is not an option, so a file parameter.          # Here, $lfc_arg is not an option, so a file parameter.
1970          list_append _fparams "${_arg}";          list_append lfc_fparams "${lfc_arg}";
1971    
1972          # Ignore the strange option handling of $POSIXLY_CORRECT to          # Ignore the strange option handling of $POSIXLY_CORRECT to
1973          # end option parsing after the first file name argument.  To          # end option parsing after the first file name argument.  To
# Line 2015  list_from_cmdline() Line 1976  list_from_cmdline()
1976          ;;          ;;
1977      esac;      esac;
1978    done;    done;
1979    list_append _result '--';    list_append lfc_result '--';
1980    if obj _fparams is_not_empty;    if obj lfc_fparams is_not_empty;
1981    then    then
1982      _result="${_result} ${_fparams}";      lfc_result="${lfc_result} ${lfc_fparams}";
1983    fi;    fi;
1984    if test "$#" -gt 0;    if test "$#" -gt 0;
1985    then    then
1986      list_append _result "$@";      list_append lfc_result "$@";
1987    fi;    fi;
1988    echo -n "$_result";    echo -n "${lfc_result}";
1989      unset lfc_fparams;
1990      unset lfc_fn;
1991      unset lfc_short_a;
1992      unset lfc_short_n;
1993      unset lfc_long_a;
1994      unset lfc_long_n;
1995      unset lfc_result;
1996      unset lfc_arg;
1997      unset lfc_opt;
1998      unset lfc_opt_arg;
1999      unset lfc_opt_char;
2000      unset lfc_lopt;
2001      unset lfc_rest;
2002    eval "${return_ok}";    eval "${return_ok}";
2003  } # list_from_cmdline()  } # list_from_cmdline()
2004    
# Line 2039  list_from_cmdline() Line 2013  list_from_cmdline()
2013  #               <separator>  #               <separator>
2014  # Output:    the resulting list string  # Output:    the resulting list string
2015  #  #
2016    # Variable prefix: lfs
2017    #
2018  list_from_split()  list_from_split()
2019  {  {
2020    func_check list_from_split = 2 "$@";    func_check list_from_split = 2 "$@";
   local _s;  
2021    
2022    # precede each space or tab by a backslash `\' (doubled for `sed')    # precede each space or tab by a backslash `\' (doubled for `sed')
2023    _s="$(echo -n "$1" | sed -e 's/\(['"${_SPACE}${_TAB}"']\)/\\\1/g')";    lfs_s="$(echo -n "$1" | sed -e 's/\(['"${_SPACE}${_TAB}"']\)/\\\1/g')";
2024    
2025    # replace split character of string by the list separator ` ' (space).    # replace split character of string by the list separator ` ' (space).
2026    case "$2" in    case "$2" in
2027      /)                          # cannot use normal `sed' separator      /)                          # cannot use normal `sed' separator
2028        echo -n "${_s}" | sed -e '\|.*|s|'"$2"'| |g';        echo -n "${lfs_s}" | sed -e 's|'"$2"'| |g';
2029        ;;        ;;
2030      ?)                          # use normal `sed' separator      ?)                          # use normal `sed' separator
2031        echo -n "${_s}" | sed -e 's/'"$2"'/ /g';        echo -n "${lfs_s}" | sed -e 's/'"$2"'/ /g';
2032        ;;        ;;
2033      ??*)      ??*)
2034        error 'list_from_split(): separator must be a single character.';        error 'list_from_split(): separator must be a single character.';
2035        ;;        ;;
2036    esac;    esac;
2037      unset lfs_s;
2038    eval "${return_ok}";    eval "${return_ok}";
2039  }  }
2040    
# Line 2081  list_from_split() Line 2057  list_from_split()
2057  # Arguments: 1  # Arguments: 1
2058  # Output: the argument <list> unchanged, if the check succeeded.  # Output: the argument <list> unchanged, if the check succeeded.
2059  #  #
2060    # Variable prefix: lg
2061    #
2062  list_get()  list_get()
2063  {  {
2064    func_check list_get = 1 "$@";    func_check list_get = 1 "$@";
2065    local _list;    eval lg_list='"${'$1'}"';
   eval _list='"${'$1'}"';  
2066    # remove leading and final space characters    # remove leading and final space characters
2067    _list="$(echo -n "${_list}" | \    lg_list="$(echo -n "${lg_list}" | \
2068             sed -e 's/^['"${_SPACE}${_TAB}"']*//' | \             sed -e 's/^['"${_SPACE}${_TAB}"']*//' | \
2069             sed -e 's/['"${_SPACE}${_TAB}"']*$//')";             sed -e 's/['"${_SPACE}${_TAB}"']*$//')";
2070    case "${_list}" in    case "${lg_list}" in
2071    '')    '')
2072        unset lg_list;
2073      eval "${return_ok}";      eval "${return_ok}";
2074      ;;      ;;
2075    \'*\')    \'*\')
2076      echo -n "${_list}";      echo -n "${lg_list}";
2077        unset lg_list;
2078      eval "${return_ok}";      eval "${return_ok}";
2079      ;;      ;;
2080    *)    *)
2081      error "list_get(): bad list: $1"      error "list_get(): bad list: $1"
2082      ;;      ;;
2083    esac;    esac;
2084      unset lg_list;
2085    eval "${return_ok}";    eval "${return_ok}";
2086  }  }
2087    
# Line 2193  landmark '7: man_*()'; Line 2173  landmark '7: man_*()';
2173  # Only called from do_fileargs(), checks on $MANPATH and  # Only called from do_fileargs(), checks on $MANPATH and
2174  # $_MAN_ENABLE are assumed.  # $_MAN_ENABLE are assumed.
2175  #  #
2176    # Variable prefix: mdf
2177    #
2178  man_do_filespec()  man_do_filespec()
2179  {  {
2180    func_check man_do_filespec = 1 "$@";    func_check man_do_filespec = 1 "$@";
   local _got_one;  
   local _name;  
   local _prevsec;  
   local _res;  
   local _section;  
   local _spec;  
   local _string;  
   local s;  
2181    if obj _MAN_PATH is_empty;    if obj _MAN_PATH is_empty;
2182    then    then
2183      eval "${return_bad}";      eval "${return_bad}";
# Line 2212  man_do_filespec() Line 2186  man_do_filespec()
2186    then    then
2187      eval "${return_bad}";      eval "${return_bad}";
2188    fi;    fi;
2189    _spec="$1";    mdf_spec="$1";
2190    _name='';    mdf_name='';
2191    _section='';    mdf_section='';
2192    case "${_spec}" in    case "${mdf_spec}" in
2193      */*)                        # not a man spec when it contains '/'      */*)                        # not a man spec when it contains '/'
2194          unset mdf_got_one;
2195          unset mdf_name;
2196          unset mdf_section;
2197          unset mdf_spec;
2198        eval "${return_bad}";        eval "${return_bad}";
2199        ;;        ;;
2200      man:?*\(?*\))               # man:name(section)      man:?*\(?*\))               # man:name(section)
2201        _name="$(echo -n "${_spec}" \        mdf_name="$(echo -n "${mdf_spec}" \
2202                 | sed -e 's/^man:\(..*\)(\(..*\))$/\1/')";                 | sed -e 's/^man:\(..*\)(\(..*\))$/\1/')";
2203        _section="$(echo -n "${_spec}" \        mdf_section="$(echo -n "${mdf_spec}" \
2204                 | sed -e 's/^man:\(..*\)(\(..*\))$/\2/')";                 | sed -e 's/^man:\(..*\)(\(..*\))$/\2/')";
2205        ;;        ;;
2206      man:?*.[0-9on])                     # man:name.section      man:?*.[0-9on])                     # man:name.section
2207        _name="$(echo -n "${_spec}" \        mdf_name="$(echo -n "${mdf_spec}" \
2208                 | sed -e 's/^man:\(..*\)\..$/\1/')";                 | sed -e 's/^man:\(..*\)\..$/\1/')";
2209        _section="$(echo -n "${_spec}" \        mdf_section="$(echo -n "${mdf_spec}" \
2210                 | sed -e 's/^.*\(.\)$/\1/')";                 | sed -e 's/^.*\(.\)$/\1/')";
2211        ;;        ;;
2212      man:?*)                     # man:name      man:?*)                     # man:name
2213        _name="$(echo -n "${_spec}" | sed -e 's/^man://')";        mdf_name="$(echo -n "${mdf_spec}" | sed -e 's/^man://')";
2214        ;;        ;;
2215      ?*\(?*\))                   # name(section)      ?*\(?*\))                   # name(section)
2216        _name="$(echo -n "${_spec}" \        mdf_name="$(echo -n "${mdf_spec}" \
2217                 | sed -e 's/^\(..*\)(\(..*\))$/\1/')";                 | sed -e 's/^\(..*\)(\(..*\))$/\1/')";
2218        _section="$(echo -n "${_spec}" \        mdf_section="$(echo -n "${mdf_spec}" \
2219                 | sed -e 's/^\(..*\)(\(..*\))$/\2/')";                 | sed -e 's/^\(..*\)(\(..*\))$/\2/')";
2220        ;;        ;;
2221      ?*.[0-9on])                 # name.section      ?*.[0-9on])                 # name.section
2222        _name="$(echo -n "${_spec}" \        mdf_name="$(echo -n "${mdf_spec}" \
2223                 | sed -e 's/^\(..*\)\..$/\1/')";                 | sed -e 's/^\(..*\)\..$/\1/')";
2224        _section="$(echo -n "${_spec}" \        mdf_section="$(echo -n "${mdf_spec}" \
2225                 | sed -e 's/^.*\(.\)$/\1/')";                 | sed -e 's/^.*\(.\)$/\1/')";
2226        ;;        ;;
2227      ?*)      ?*)
2228        _name="${_filespec}";        mdf_name="${mdf_spec}";
2229        ;;        ;;
2230    esac;    esac;
2231    if obj _name is_empty;    if obj mdf_name is_empty;
2232    then    then
2233        unset mdf_got_one;
2234        unset mdf_name;
2235        unset mdf_section;
2236        unset mdf_spec;
2237      eval "${return_bad}";      eval "${return_bad}";
2238    fi;    fi;
2239    _got_one='no';    mdf_got_one='no';
2240    if obj _section is_empty;    if obj mdf_section is_empty;
2241    then    then
2242      eval set -- "${_MAN_AUTO_SEC}";      eval set x "${_MAN_AUTO_SEC}";
2243      for s in "$@";      shift;
2244        for s;
2245      do      do
2246        if man_search_section "${_name}" "$s";        mdf_s="$s";
2247          if man_search_section "${mdf_name}" "${mdf_s}";
2248        then                      # found        then                      # found
2249          if obj _MAN_ALL is_yes;          if obj _MAN_ALL is_yes;
2250          then          then
2251            _got_one='yes';            mdf_got_one='yes';
2252          else          else
2253              unset mdf_got_one;
2254              unset mdf_name;
2255              unset mdf_s;
2256              unset mdf_section;
2257              unset mdf_spec;
2258            eval "${return_good}";            eval "${return_good}";
2259          fi;          fi;
2260        fi;        fi;
2261      done;      done;
2262    else    else
2263      if man_search_section "${_name}" "${_section}";      if man_search_section "${mdf_name}" "${mdf_section}";
2264      then      then
2265          unset mdf_got_one;
2266          unset mdf_name;
2267          unset mdf_s;
2268          unset mdf_section;
2269          unset mdf_spec;
2270        eval "${return_good}";        eval "${return_good}";
2271      else      else
2272          unset mdf_got_one;
2273          unset mdf_name;
2274          unset mdf_section;
2275          unset mdf_spec;
2276        eval "${return_bad}";        eval "${return_bad}";
2277      fi;      fi;
2278    fi;    fi;
2279    if obj _MAN_ALL is_yes && is_yes "${_got_one}";    if obj _MAN_ALL is_yes && is_yes "${mdf_got_one}";
2280    then    then
2281        unset mdf_got_one;
2282        unset mdf_name;
2283        unset mdf_s;
2284        unset mdf_section;
2285        unset mdf_spec;
2286      eval "${return_good}";      eval "${return_good}";
2287    fi;    fi;
2288      unset mdf_got_one;
2289      unset mdf_name;
2290      unset mdf_s;
2291      unset mdf_section;
2292      unset mdf_spec;
2293    eval "${return_bad}";    eval "${return_bad}";
2294  } # man_do_filespec()  } # man_do_filespec()
2295    
# Line 2331  man_register_file() Line 2339  man_register_file()
2339  # Globals   : $_MAN_PATH, $_MAN_EXT  # Globals   : $_MAN_PATH, $_MAN_EXT
2340  # Return    : 0 if found, 1 otherwise  # Return    : 0 if found, 1 otherwise
2341  #  #
2342    # Variable prefix: mss
2343    #
2344  man_search_section()  man_search_section()
2345  {  {
2346    func_check man_search_section = 2 "$@";    func_check man_search_section = 2 "$@";
   local _dir;  
   local _ext;  
   local _got_one;  
   local _name;  
   local _prefix  
   local _section;  
   local d;  
   local f;  
2347    if obj _MAN_PATH is_empty;    if obj _MAN_PATH is_empty;
2348    then    then
2349      eval "${return_bad}";      eval "${return_bad}";
# Line 2354  man_search_section() Line 2356  man_search_section()
2356    then    then
2357      eval "${return_bad}";      eval "${return_bad}";
2358    fi;    fi;
2359    _name="$1";    mss_name="$1";
2360    _section="$2";    mss_section="$2";
2361    eval set -- "$(path_split "${_MAN_PATH}")";    eval set x "$(path_split "${_MAN_PATH}")";
2362    _got_one='no';    shift;
2363      mss_got_one='no';
2364    if obj _MAN_EXT is_empty;    if obj _MAN_EXT is_empty;
2365    then    then
2366      for d in "$@";      for d;
2367      do      do
2368        _dir="$(dirname_append "$d" "man${_section}")";        mss_dir="$(dirname_append "$d" "man${mss_section}")";
2369        if obj _dir is_dir;        if obj mss_dir is_dir;
2370        then        then
2371          _prefix="$(dirname_append "${_dir}" "${_name}.${_section}")";          mss_prefix="$(\
2372          for f in $(echo -n ${_prefix}*);            dirname_append "${mss_dir}" "${mss_name}.${mss_section}")";
2373            for f in $(echo -n ${mss_prefix}*);
2374          do          do
2375            if obj f is_file;            mss_f="$f";
2376              if obj mss_f is_file;
2377            then            then
2378              if is_yes "${_got_one}";              if is_yes "${mss_got_one}";
2379              then              then
2380                register_file "$f";                register_file "${mss_f}";
2381              elif obj _MAN_ALL is_yes;              elif obj _MAN_ALL is_yes;
2382              then              then
2383                man_register_file "$f" "${_name}";                man_register_file "${mss_f}" "${mss_name}";
2384              else              else
2385                man_register_file "$f" "${_name}" "${_section}";                man_register_file "${mss_f}" "${mss_name}" "${mss_section}";
2386                  unset mss_dir;
2387                  unset mss_ext;
2388                  unset mss_f;
2389                  unset mss_got_one;
2390                  unset mss_name;
2391                  unset mss_prefix;
2392                  unset mss_section;
2393                eval "${return_good}";                eval "${return_good}";
2394              fi;              fi;
2395              _got_one='yes';              mss_got_one='yes';
2396            fi;            fi;
2397          done;          done;
2398        fi;        fi;
2399      done;      done;
2400    else    else
2401      _ext="${_MAN_EXT}";      mss_ext="${_MAN_EXT}";
2402      # check for directory name having trailing extension      # check for directory name having trailing extension
2403      for d in "$@";      for d;
2404      do      do
2405        _dir="$(dirname_append $d man${_section}${_ext})";        mss_dir="$(dirname_append $d man${mss_section}${mss_ext})";
2406        if obj _dir is_dir;        if obj mss_dir is_dir;
2407        then        then
2408          _prefix="$(dirname_append "${_dir}" "${_name}.${_section}")";          mss_prefix=\
2409          for f in ${_prefix}*;            "$(dirname_append "${mss_dir}" "${mss_name}.${mss_section}")";
2410            for f in ${mss_prefix}*;
2411          do          do
2412            if obj f is_file;            mss_f="$f";
2413              if obj mss_f is_file;
2414            then            then
2415              if is_yes "${_got_one}";              if is_yes "${mss_got_one}";
2416              then              then
2417                register_file "$f";                register_file "${mss_f}";
2418              elif obj _MAN_ALL is_yes;              elif obj _MAN_ALL is_yes;
2419              then              then
2420                man_register_file "$f" "${_name}";                man_register_file "${mss_f}" "${mss_name}";
2421              else              else
2422                man_register_file "$f" "${_name}" "${_section}";                man_register_file "${mss_f}" "${mss_name}" "${mss_section}";
2423                  unset mss_dir;
2424                  unset mss_ext;
2425                  unset mss_f;
2426                  unset mss_got_one;
2427                  unset mss_name;
2428                  unset mss_prefix;
2429                  unset mss_section;
2430                eval "${return_good}";                eval "${return_good}";
2431              fi;              fi;
2432              _got_one='yes';              mss_got_one='yes';
2433            fi;            fi;
2434          done;          done;
2435        fi;        fi;
2436      done;      done;
2437      # check for files with extension in directories without extension      # check for files with extension in directories without extension
2438      for d in "$@";      for d;
2439      do      do
2440        _dir="$(dirname_append "$d" "man${_section}")";        mss_dir="$(dirname_append "$d" "man${mss_section}")";
2441        if obj _dir is_dir;        if obj mss_dir is_dir;
2442        then        then
2443          _prefix="$(dirname_append "${_dir}" \          mss_prefix="$(dirname_append "${mss_dir}" \
2444                                    "${_name}.${_section}${_ext}")";                          "${mss_name}.${mss_section}${mss_ext}")";
2445          for f in ${_prefix}*;          for f in ${mss_prefix}*;
2446          do          do
2447            if obj f is_file;            mss_f="$f";
2448              if obj mss_f is_file;
2449            then            then
2450              if is_yes "${_got_one}";              if is_yes "${mss_got_one}";
2451              then              then
2452                register_file "$f";                register_file "${mss_f}";
2453              elif obj _MAN_ALL is_yes;              elif obj _MAN_ALL is_yes;
2454              then              then
2455                man_register_file "$f" "${_name}";                man_register_file "${mss_f}" "${mss_name}";
2456              else              else
2457                man_register_file "$f" "${_name}" "${_section}";                man_register_file "${mss_f}" "${mss_name}" "${mss_section}";
2458                  unset mss_dir;
2459                  unset mss_ext;
2460                  unset mss_f;
2461                  unset mss_got_one;
2462                  unset mss_name;
2463                  unset mss_prefix;
2464                  unset mss_section;
2465                eval "${return_good}";                eval "${return_good}";
2466              fi;              fi;
2467              _got_one='yes';              mss_got_one='yes';
2468            fi;            fi;
2469          done;          done;
2470        fi;        fi;
2471      done;      done;
2472    fi;    fi;
2473    if obj _MAN_ALL is_yes && is_yes "${_got_one}";    if obj _MAN_ALL is_yes && is_yes "${mss_got_one}";
2474    then    then
2475        unset mss_dir;
2476        unset mss_ext;
2477        unset mss_f;
2478        unset mss_got_one;
2479        unset mss_name;
2480        unset mss_prefix;
2481        unset mss_section;
2482      eval "${return_good}";      eval "${return_good}";
2483    fi;    fi;
2484      unset mss_dir;
2485      unset mss_ext;
2486      unset mss_f;
2487      unset mss_got_one;
2488      unset mss_name;
2489      unset mss_prefix;
2490      unset mss_section;
2491    eval "${return_bad}";    eval "${return_bad}";
2492  } # man_search_section()  } # man_search_section()
2493    
# Line 2471  man_search_section() Line 2514  man_search_section()
2514  # $MANOPT; overridden by  # $MANOPT; overridden by
2515  # the groffer command line options.  # the groffer command line options.
2516  #  #
2517    # Variable prefix: ms
2518    #
2519  man_setup()  man_setup()
2520  {  {
2521    func_check main_man_setup = 0 "$@";    func_check main_man_setup = 0 "$@";
   local _lang;  
2522    
2523    if obj _MAN_IS_SETUP is_yes;    if obj _MAN_IS_SETUP is_yes;
2524    then    then
# Line 2517  man_setup() Line 2561  man_setup()
2561    
2562    _MAN_SYS="$(get_first_essential \    _MAN_SYS="$(get_first_essential \
2563                "${_OPT_SYSTEMS}" "${_MANOPT_SYS}" "${SYSTEM}")";                "${_OPT_SYSTEMS}" "${_MANOPT_SYS}" "${SYSTEM}")";
2564    _lang="$(get_first_essential \    ms_lang="$(get_first_essential \
2565             "${_OPT_LANG}" "${LC_ALL}" "${LC_MESSAGES}" "${LANG}")";             "${_OPT_LANG}" "${LC_ALL}" "${LC_MESSAGES}" "${LANG}")";
2566    case "${_lang}" in    case "${ms_lang}" in
2567      C|POSIX)      C|POSIX)
2568        _MAN_LANG="";        _MAN_LANG="";
2569        _MAN_LANG2="";        _MAN_LANG2="";
2570        ;;        ;;
2571      ?)      ?)
2572        _MAN_LANG="${_lang}";        _MAN_LANG="${ms_lang}";
2573        _MAN_LANG2="";        _MAN_LANG2="";
2574        ;;        ;;
2575      *)      *)
2576        _MAN_LANG="${_lang}";        _MAN_LANG="${ms_lang}";
2577        # get first two characters of $_lang        # get first two characters of $ms_lang
2578        _MAN_LANG2="$(echo -n "${_lang}" | sed -e 's/^\(..\).*$/\1/')";        _MAN_LANG2="$(echo -n "${ms_lang}" | sed -e 's/^\(..\).*$/\1/')";
2579        ;;        ;;
2580    esac;    esac;
2581    # from now on, use only $_LANG, forget about $_OPT_LANG, $LC_*.    # from now on, use only $_LANG, forget about $_OPT_LANG, $LC_*.
# Line 2543  man_setup() Line 2587  man_setup()
2587    if obj _MAN_PATH is_empty;    if obj _MAN_PATH is_empty;
2588    then    then
2589      _MAN_ENABLE="no";      _MAN_ENABLE="no";
2590        unset ms_lang;
2591      eval "${return_ok}";      eval "${return_ok}";
2592    fi;    fi;
2593    
2594    _MAN_EXT="$(get_first_essential \    _MAN_EXT="$(get_first_essential \
2595                "${_OPT_EXTENSION}" "${_MANOPT_EXTENSION}")";                "${_OPT_EXTENSION}" "${_MANOPT_EXTENSION}")";
2596      unset ms_lang;
2597    eval "${return_ok}";    eval "${return_ok}";
2598  } # man_setup()  } # man_setup()
2599    
# Line 2570  landmark '8: manpath_*()'; Line 2616  landmark '8: manpath_*()';
2616  #   in/out: $_MAN_PATH: has the form `dir1:dir2:...', a colon  #   in/out: $_MAN_PATH: has the form `dir1:dir2:...', a colon
2617  #             separated list of directories.  #             separated list of directories.
2618  #  #
2619    # Variable prefix: mals
2620    #
2621  manpath_add_lang_sys()  manpath_add_lang_sys()
2622  {  {
2623    func_check manpath_add_lang_sys = 0 "$@";    func_check manpath_add_lang_sys = 0 "$@";
   local p;  
   local _mp;  
2624    if obj _MAN_PATH is_empty;    if obj _MAN_PATH is_empty;
2625    then    then
2626      eval "${return_ok}";      eval "${return_ok}";
2627    fi;    fi;
2628    # twice test both sys and lang    # twice test both sys and lang
2629    eval set -- "$(path_split "${_MAN_PATH}")";    eval set x "$(path_split "${_MAN_PATH}")";
2630    _mp='';    shift;
2631    for p in "$@";    mals_mp='';
2632      for p;
2633    do                            # loop on man path directories    do                            # loop on man path directories
2634      _mp="$(_manpath_add_lang_sys_single "${_mp}" "$p")";      mals_mp="$(_manpath_add_lang_sys_single "${mals_mp}" "$p")";
2635    done;    done;
2636    eval set -- "$(path_split "${_mp}")";    eval set x "$(path_split "${mals_mp}")";
2637    for p in "$@";    shift;
2638      for p;
2639    do                            # loop on man path directories    do                            # loop on man path directories
2640      _mp="$(_manpath_add_lang_sys_single "${_mp}" "$p")";      mals_mp="$(_manpath_add_lang_sys_single "${mals_mp}" "$p")";
2641    done;    done;
2642    _MAN_PATH="$(path_chop "${_mp}")";    _MAN_PATH="$(path_chop "${mals_mp}")";
2643      unset mals_mp;
2644    eval "${return_ok}";    eval "${return_ok}";
2645  }  }
2646    
2647    
2648    # To the directory in $1 append existing sys/lang subdirectories
2649    # Function is necessary to split the OS list.
2650    #
2651    # globals: in: $_MAN_SYS, $_MAN_LANG, $_MAN_LANG2
2652    # argument: 2: `man_path' and `dir'
2653    # output: colon-separated path of the retrieved subdirectories
2654    #
2655    # Variable prefix: _mals
2656    #
2657  _manpath_add_lang_sys_single()  _manpath_add_lang_sys_single()
2658  {  {
   # To the directory in $1 append existing sys/lang subdirectories  
   # 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  
   #  
2659    func_check _manpath_add_lang_sys_single = 2 "$@";    func_check _manpath_add_lang_sys_single = 2 "$@";
2660    local d;    _mals_res="$1";
2661    _res="$1";    _mals_parent="$2";
2662    _parent="$2";    eval set x "$(list_from_split "${_MAN_SYS}" ',')";
2663    eval set -- "$(list_from_split "${_MAN_SYS}" ',')";    shift;
2664    for d in "$@" "${_MAN_LANG}" "${_MAN_LANG2}";    for d in "$@" "${_MAN_LANG}" "${_MAN_LANG2}";
2665    do    do
2666      _dir="$(dirname_append "${_parent}" "$d")";      _mals_dir="$(dirname_append "${_mals_parent}" "$d")";
2667      if obj _res path_not_contains "${_dir}" && obj _dir is_dir;      if obj _mals_res path_not_contains "${_mals_dir}" && \
2668           obj _mals_dir is_dir;
2669      then      then
2670        _res="${_res}:${_dir}";        _mals_res="${_mals_res}:${_mals_dir}";
2671      fi;      fi;
2672    done;    done;
2673    if path_not_contains "${_res}" "${_parent}";    if path_not_contains "${_mals_res}" "${_mals_parent}";
2674    then    then
2675      _res="${_res}:${_parent}";      _mals_res="${_mals_res}:${_mals_parent}";
2676    fi;    fi;
2677    path_chop "${_res}";    path_chop "${_mals_res}";
2678      unset _mals_dir;
2679      unset _mals_parent;
2680      unset _mals_res;
2681      eval "${return_ok}";
2682  }  }
2683    
2684  # end manpath_add_lang_sys ()  # end manpath_add_lang_sys ()
# Line 2639  _manpath_add_lang_sys_single() Line 2695  _manpath_add_lang_sys_single()
2695  #   in:  $PATH  #   in:  $PATH
2696  #   out: $_MAN_PATH  #   out: $_MAN_PATH
2697  #  #
2698    # Variable prefix: msfp
2699    #
2700  manpath_set_from_path()  manpath_set_from_path()
2701  {  {
2702    func_check manpath_set_from_path = 0 "$@";    func_check manpath_set_from_path = 0 "$@";
2703    local _base;  
2704    local _mandir;    msfp_manpath='';
   local _manpath;  
   local d;  
   local e;  
   _manpath='';  
2705    
2706    # get a basic man path from $PATH    # get a basic man path from $PATH
2707    if obj PATH is_not_empty;    if obj PATH is_not_empty;
2708    then    then
2709      eval set -- "$(path_split "${PATH}")";      eval set x "$(path_split "${PATH}")";
2710      for d in "$@";      shift;
2711        for d;
2712      do      do
2713        # delete the final `/bin' part        # delete the final `/bin' part
2714        _base="$(echo -n "$d" | sed -e '\|.*|s|//*bin/*$||')";        msfp_base="$(echo -n "$d" | sed -e 's|//*bin/*$||')";
2715        for e in /share/man /man;        for e in /share/man /man;
2716        do        do
2717          _mandir="${_base}$e";          msfp_mandir="${msfp_base}$e";
2718          if test -d "${_mandir}" && test -r "${_mandir}";          if test -d "${msfp_mandir}" && test -r "${msfp_mandir}";
2719          then          then
2720            _manpath="${_manpath}:${_mandir}";            msfp_manpath="${msfp_manpath}:${msfp_mandir}";
2721          fi;          fi;
2722        done;        done;
2723      done;      done;
# Line 2670  manpath_set_from_path() Line 2725  manpath_set_from_path()
2725    
2726    # append some default directories    # append some default directories
2727    for d in /usr/local/share/man /usr/local/man \    for d in /usr/local/share/man /usr/local/man \
2728              /usr/share/man /usr/man \             /usr/share/man /usr/man \
2729              /usr/X11R6/man /usr/openwin/man \             /usr/X11R6/man /usr/openwin/man \
2730              /opt/share/man /opt/man \             /opt/share/man /opt/man \
2731              /opt/gnome/man /opt/kde/man;             /opt/gnome/man /opt/kde/man;
2732    do    do
2733      if obj _manpath path_not_contains "$d" && obj d is_dir;      msfp_d="$d";
2734        if obj msfp_manpath path_not_contains "${msfp_d}" && obj mfsp_d is_dir;
2735      then      then
2736        _manpath="${_manpath}:$d";        msfp_manpath="${msfp_manpath}:${mfsp_d}";
2737      fi;      fi;
2738    done;    done;
2739    
2740    _MAN_PATH="${_manpath}";    _MAN_PATH="${msfp_manpath}";
2741      unset msfp_base;
2742      unset msfp_d;
2743      unset msfp_mandir;
2744      unset msfp_manpath;
2745    eval "${return_ok}";    eval "${return_ok}";
2746  } # manpath_set_from_path()  } # manpath_set_from_path()
2747    
# Line 2703  landmark '9: obj_*()'; Line 2763  landmark '9: obj_*()';
2763  #           <object>: variable name  #           <object>: variable name
2764  #           <call_name>: a program or function name  #           <call_name>: a program or function name
2765  #  #
2766    # Variable prefix: o
2767    #
2768  obj()  obj()
2769  {  {
2770    func_check obj '>=' 2 "$@";    func_check obj '>=' 2 "$@";
   local func;  
   local var;  
2771    if is_empty "$2";    if is_empty "$2";
2772    then    then
2773      error "obj(): function name is empty."      error "obj(): function name is empty."
2774    else    else
2775      func="$2";      o_func="$2";
2776    fi;    fi;
2777    eval arg1='"${'$1'}"';    eval o_arg1='"${'$1'}"';
2778    shift;    shift;
2779    shift;    shift;
2780    eval "${func}"' "${arg1}" "$@"';    eval "${o_func}"' "${o_arg1}" "$@"';
2781  }    n="$?";
2782      unset o_arg1;
2783      unset o_func;
2784      eval "${return_var} $n";
2785    } # obj()
2786    
2787    
2788  ########################################################################  ########################################################################
# Line 2739  obj_data() Line 2803  obj_data()
2803      error "obj_data(): object name is empty."      error "obj_data(): object name is empty."
2804    fi;    fi;
2805    eval echo -n '"${'$1'}"';    eval echo -n '"${'$1'}"';
2806      eval "${return_ok}";
2807  }  }
2808    
2809    
# Line 2754  obj_data() Line 2819  obj_data()
2819  #            <arg>: optional argument to <call_name>  #            <arg>: optional argument to <call_name>
2820  # Output:    none  # Output:    none
2821  #  #
2822    # Variable prefix: ofo
2823    #
2824  obj_from_output()  obj_from_output()
2825  {  {
2826    func_check obj_from_output '>=' 2 "$@";    func_check obj_from_output '>=' 2 "$@";
   local result_name;  
2827    if is_empty "$1";    if is_empty "$1";
2828    then    then
2829      error "res(): variable name is empty.";      error "res(): variable name is empty.";
# Line 2765  obj_from_output() Line 2831  obj_from_output()
2831    then    then
2832      error "res(): function name is empty."      error "res(): function name is empty."
2833    else    else
2834      result_name="$1";      ofo_result_name="$1";
2835    fi;    fi;
2836    shift;    shift;
2837    eval "${result_name}"'="$('"$@"')"';    eval "${ofo_result_name}"'="$('"$@"')"';
2838      eval "${return_ok}";
2839  }  }
2840    
2841    
# Line 2790  obj_set() Line 2857  obj_set()
2857      error "obj_set(): object name is empty."      error "obj_set(): object name is empty."
2858    fi;    fi;
2859    eval "$1"='"$2"';    eval "$1"='"$2"';
2860      eval "${return_ok}";
2861  }  }
2862    
2863    
# Line 2804  obj_set() Line 2872  obj_set()
2872  path_chop()  path_chop()
2873  {  {
2874    func_check path_chop = 1 "$@";    func_check path_chop = 1 "$@";
   local _res;  
2875    
2876    # replace multiple colons by a single colon `:'    # replace multiple colons by a single colon `:'
2877    # remove leading and trailing colons    # remove leading and trailing colons
# Line 2823  path_chop() Line 2890  path_chop()
2890  # Argument: 1, a colon separated path.  # Argument: 1, a colon separated path.
2891  # Output:   colon-separated list of existing directories.  # Output:   colon-separated list of existing directories.
2892  #  #
2893    # Variable prefix: pc
2894    #
2895  path_clean()  path_clean()
2896  {  {
2897    func_check path_clean = 1 "$@";    func_check path_clean = 1 "$@";
   local _arg;  
   local _dir;  
   local _res;  
   local i;  
2898    if is_not_equal "$#" 1;    if is_not_equal "$#" 1;
2899    then    then
2900      error 'path_clean() needs 1 argument.';      error 'path_clean() needs 1 argument.';
2901    fi;    fi;
2902    _arg="$1";    pc_arg="$1";
2903    eval set -- "$(path_split "${_arg}")";    eval set x "$(path_split "${pc_arg}")";
2904    _res="";    shift;
2905    for i in "$@";    pc_res="";
2906      for i;
2907    do    do
2908      if obj i is_not_empty \      pc_i="$i";
2909         && obj _res path_not_contains "$i" \      if obj pc_i is_not_empty \
2910         && obj i is_dir;         && obj pc_res path_not_contains "${pc_i}" \
2911           && obj pc_i is_dir;
2912      then      then
2913        case "$i" in        case "${pc_i}" in
2914          ?*/) _res="${_res}$(dirname_chop "$i")"; ;;          ?*/) pc_res="${pc_res}$(dirname_chop "${pc_i}")"; ;;
2915          *)  _res="${_res}:$i";          *)  pc_res="${pc_res}:${pc_i}";
2916        esac;        esac;
2917      fi;      fi;
2918    done;    done;
2919    if path_chop "${_res}";    unset pc_arg;
2920      unset pc_i;
2921      unset pc_res;
2922      if path_chop "${pc_res}";
2923    then    then
2924      eval "${return_ok}";      eval "${return_ok}";
2925    else    else
# Line 2907  path_not_contains() Line 2977  path_not_contains()
2977  # In `path' escape white space and replace each colon by a space.  # In `path' escape white space and replace each colon by a space.
2978  #  #
2979  # Arguments: 1: a colon-separated path  # Arguments: 1: a colon-separated path
2980  # Output:    the resulting list, process with `eval set --'  # Output:    the resulting list, process with `eval set'
2981  #  #
2982  path_split()  path_split()
2983  {  {
# Line 2955  register_file() Line 3025  register_file()
3025  #  #
3026  # Globals: $_REGISTERED_TITLE (rw)  # Globals: $_REGISTERED_TITLE (rw)
3027  #  #
3028    # Variable prefix: rt
3029    #
3030  register_title()  register_title()
3031  {  {
3032    func_check register_title = 1 "$@";    func_check register_title = 1 "$@";
   local _title;  
3033    if is_empty "$1";    if is_empty "$1";
3034    then    then
3035      eval "${return_ok}";      eval "${return_ok}";
3036    fi;    fi;
3037    _title="$(base_name "$1")";   # remove directory part    rt_title="$(base_name "$1")"; # remove directory part
3038        
3039    # remove extension `.gz'    # remove extension `.gz'
3040    _title="$(echo -n "${_title}" | sed -e 's/\.gz$//')";    rt_title="$(echo -n "${rt_title}" | sed -e 's/\.gz$//')";
3041    # remove extension `.Z'    # remove extension `.Z'
3042    _title="$(echo -n "${_title}" | sed -e 's/\.Z$//')";    rt_title="$(echo -n "${rt_title}" | sed -e 's/\.Z$//')";
3043    
3044    if obj _title is_empty;    if obj rt_title is_empty;
3045    then    then
3046      eval "${return_ok}";      eval "${return_ok}";
3047    fi;    fi;
3048    _REGISTERED_TITLE="${_REGISTERED_TITLE} ${_title}";    _REGISTERED_TITLE="${_REGISTERED_TITLE} ${rt_title}";
3049      unset rt_title;
3050    eval "${return_ok}";    eval "${return_ok}";
3051  }  }
3052    
# Line 2993  register_title() Line 3065  register_title()
3065  #  #
3066  # Store standard input to temporary file (with decompression).  # Store standard input to temporary file (with decompression).
3067  #  #
3068    # Variable prefix: ss
3069    #
3070  if obj _HAS_COMPRESSION is_yes;  if obj _HAS_COMPRESSION is_yes;
3071  then  then
3072    save_stdin()    save_stdin()
3073    {    {
     local _f;  
3074      func_check save_stdin = 0 "$@";      func_check save_stdin = 0 "$@";
3075       _f="${_TMP_DIR}"/INPUT;      ss_f="${_TMP_DIR}"/INPUT;
3076      cat >"${_f}";      cat >"${ss_f}";
3077      catz "${_f}" >"${_TMP_STDIN}";      catz "${ss_f}" >"${_TMP_STDIN}";
3078      rm -f "${_f}";      rm -f "${ss_f}";
3079        unset ss_f;
3080      eval "${return_ok}";      eval "${return_ok}";
3081    }    }
3082  else  else
# Line 3088  tmp_cat() Line 3162  tmp_cat()
3162  #  #
3163  # Output : name of created file  # Output : name of created file
3164  #  #
3165    # Variable prefix: tc
3166    #
3167  tmp_create()  tmp_create()
3168  {  {
3169    func_check tmp_create '<=' 1 "$@";    func_check tmp_create '<=' 1 "$@";
   local _tmp;  
3170    # the output file does not have `,' as first character    # the output file does not have `,' as first character
3171    _tmp="${_TMP_DIR}/,$1";    tc_tmp="${_TMP_DIR}/,$1";
3172    echo -n >"${_tmp}";    echo -n >"${tc_tmp}";
3173    echo -n "${_tmp}";            # output file name    echo -n "${tc_tmp}";          # output file name
3174      unset tc_tmp;
3175    eval "${return_ok}";    eval "${return_ok}";
3176  }  }
3177    
# Line 3138  to_tmp() Line 3214  to_tmp()
3214  trap_clean()  trap_clean()
3215  {  {
3216    func_check trap_clean = 0 "$@";    func_check trap_clean = 0 "$@";
   local i;  
3217    for i in ${_ALL_EXIT};    for i in ${_ALL_EXIT};
3218    do    do
3219      trap "" "$i" 2>${_NULL_DEV} || true;      trap "" "$i" 2>${_NULL_DEV} || true;
# Line 3158  trap_clean() Line 3233  trap_clean()
3233  trap_set()  trap_set()
3234  {  {
3235    func_check trap_set = 1 "$@";    func_check trap_set = 1 "$@";
   local i;  
3236    for i in ${_ALL_EXIT};    for i in ${_ALL_EXIT};
3237    do    do
3238      trap "$1" "$i" 2>${_NULL_DEV} || true;      trap "$1" "$i" 2>${_NULL_DEV} || true;
# Line 3286  warning() Line 3360  warning()
3360  # Interpret <filename> as a man page and display its `whatis'  # Interpret <filename> as a man page and display its `whatis'
3361  # information as a fragment written in the groff language.  # information as a fragment written in the groff language.
3362  #  #
3363    # Variable prefix: wi
3364    #
3365  what_is()  what_is()
3366  {  {
3367    func_check what_is = 1 "$@";    func_check what_is = 1 "$@";
   local _res;  
   local _dot;  
3368    if is_not_file "$1";    if is_not_file "$1";
3369    then    then
3370      error "what_is(): argument is not a readable file."      error "what_is(): argument is not a readable file."
3371    fi;    fi;
3372    _dot='^\.['"${_SPACE}${_TAB}"']*';    wi_dot='^\.['"${_SPACE}${_TAB}"']*';
3373    echo '.br';    echo '.br';
3374    echo "$1: ";    echo "$1: ";
3375      echo '.br';      echo '.br';
3376    echo -n '  ';    echo -n '  ';
3377    # grep the line containing `.TH' macro, if any    # grep the line containing `.TH' macro, if any
3378    _res="$(catz "$1" | sed -e '/'"${_dot}"'TH /p    wi_res="$(catz "$1" | sed -e '/'"${wi_dot}"'TH /p
3379  d')";  d')";
3380    if obj _res is_not_empty;    if obj wi_res is_not_empty;
3381    then                          # traditional man style    then                          # traditional man style
3382      # get the text between the first and the second `.SH' macro, by      # get the text between the first and the second `.SH' macro, by
3383      # - delete up to first .SH;      # - delete up to first .SH;
3384      # - of this, print everything up to next .SH, and delete the rest;      # - of this, print everything up to next .SH, and delete the rest;
3385      # - of this, delete the final .SH line;      # - of this, delete the final .SH line;
3386      catz "$1" | sed -e '1,/'"${_dot}"'SH/d' \      catz "$1" | sed -e '1,/'"${wi_dot}"'SH/d' \
3387                | sed -e '1,/'"${_dot}"'SH/p                | sed -e '1,/'"${wi_dot}"'SH/p
3388  d' \  d' \
3389                | sed -e '/'"${_dot}"'SH/d';                | sed -e '/'"${wi_dot}"'SH/d';
3390        unset wi_dot;
3391        unset wi_res;
3392      eval "${return_ok}";      eval "${return_ok}";
3393    fi;    fi;
3394    # grep the line containing `.Dd' macro, if any    # grep the line containing `.Dd' macro, if any
3395    _res="$(catz "$1" | sed -e '/'"${_dot}"'Dd /p    wi_res="$(catz "$1" | sed -e '/'"${wi_dot}"'Dd /p
3396  d')";  d')";
3397    if obj _res is_not_empty;    if obj wi_res is_not_empty;
3398    then                          # BSD doc style    then                          # BSD doc style
3399      # get the text between the first and the second `.Nd' macro, by      # get the text between the first and the second `.Nd' macro, by
3400      # - delete up to first .Nd;      # - delete up to first .Nd;
3401      # - of this, print everything up to next .Nd, and delete the rest;      # - of this, print everything up to next .Nd, and delete the rest;
3402      # - of this, delete the final .Nd line;      # - of this, delete the final .Nd line;
3403      catz "$1" | sed -e '1,/'"${_dot}"'Nd/d' \      catz "$1" | sed -e '1,/'"${wi_dot}"'Nd/d' \
3404                | sed -e '1,/'"${_dot}"'Nd/p                | sed -e '1,/'"${wi_dot}"'Nd/p
3405  d' \  d' \
3406                | sed -e '/'"${_dot}"'Nd/d';                | sed -e '/'"${wi_dot}"'Nd/d';
3407        unset wi_dot;
3408        unset wi_res;
3409      eval "${return_ok}";      eval "${return_ok}";
3410    fi;    fi;
3411    echo 'is not a man page.';    echo 'is not a man page.';
3412      unset wi_dot;
3413      unset wi_res;
3414    eval "${return_bad}";    eval "${return_bad}";
3415  }  }
3416    
# Line 3344  d' \ Line 3424  d' \
3424  #   more args are ignored, this allows to specify progs with arguments  #   more args are ignored, this allows to specify progs with arguments
3425  # Return    : `0' if arg1 is a program in $PATH, `1' otherwise.  # Return    : `0' if arg1 is a program in $PATH, `1' otherwise.
3426  #  #
3427    # Variable prefix: w
3428    #
3429  where()  where()
3430  {  {
3431    func_check where '>=' 1 "$@";    func_check where '>=' 1 "$@";
3432    local _file;    w_arg="$1";
3433    local _arg;    if obj w_arg is_empty;
   local p;  
   _arg="$1";  
   if obj _arg is_empty;  
3434    then    then
3435        unset w_arg;
3436      eval "${return_bad}";      eval "${return_bad}";
3437    fi;    fi;
3438    case "${_arg}" in    case "${w_arg}" in
3439      /*)      /*)
3440        if test -f "${_arg}" && test -x "${_arg}";        unset w_arg;
3441          unset w_file;
3442          if test -f "${w_arg}" && test -x "${w_arg}";
3443        then        then
3444          eval "${return_ok}";          eval "${return_ok}";
3445        else        else
# Line 3365  where() Line 3447  where()
3447        fi;        fi;
3448        ;;        ;;
3449    esac;    esac;
3450    eval set -- "$(path_split "${PATH}")";    eval set x "$(path_split "${PATH}")";
3451    for p in "$@";    shift;
3452      for p;
3453    do    do
3454      case "$p" in      case "$p" in
3455        */) _file=${p}${_arg}; ;;        */) w_file=${p}${w_arg}; ;;
3456        *)  _file=${p}/${_arg}; ;;        *)  w_file=${p}/${w_arg}; ;;
3457      esac;      esac;
3458      if test -f "${_file}" && test -x "${_file}";      if test -f "${w_file}" && test -x "${w_file}";
3459      then      then
3460        echo -n "${_file}";        echo -n "${w_file}";
3461          unset w_arg;
3462          unset w_file;
3463        eval "${return_ok}";        eval "${return_ok}";
3464      fi;      fi;
3465    done;    done;
3466      unset w_arg;
3467      unset w_file;
3468    eval "${return_bad}";    eval "${return_bad}";
3469  }  }
3470    
# Line 3400  where() Line 3487  where()
3487  # sequence they are called in the main() function.  # sequence they are called in the main() function.
3488    
3489    
3490    landmark '13: main_init()';
3491  #######################################################################  #######################################################################
3492  # main_init ()  # main_init ()
3493  #  #
# Line 3407  where() Line 3495  where()
3495  #  #
3496  # Globals: $_TMP_DIR, $_TMP_CAT, $_TMP_STDIN  # Globals: $_TMP_DIR, $_TMP_CAT, $_TMP_STDIN
3497  #  #
3498  landmark '13: main_init()';  # Variable prefix: mi
3499    #
3500  main_init()  main_init()
3501  {  {
3502    func_check main_init = 0 "$@";    func_check main_init = 0 "$@";
# Line 3420  main_init() Line 3509  main_init()
3509    for d in "${GROFF_TMPDIR}" "${TMPDIR}" "${TMP}" "${TEMP}" \    for d in "${GROFF_TMPDIR}" "${TMPDIR}" "${TMP}" "${TEMP}" \
3510             "${TEMPDIR}" "${HOME}"'/tmp' '/tmp' "${HOME}" '.';             "${TEMPDIR}" "${HOME}"'/tmp' '/tmp' "${HOME}" '.';
3511    do    do
3512      if obj d is_empty || obj d is_not_dir || obj d is_not_writable;     mi_dir="$d";
3513       if obj mi_dir is_empty || obj mi_dir is_not_dir || \
3514           obj mi_dir is_not_writable;
3515      then      then
3516        continue;        continue;
3517      fi;      fi;
3518      case "$d" in  
3519        case "${mi_dir}" in
3520      */)      */)
3521        _TMP_DIR="${d}";        _TMP_DIR="${mi_dir}";
3522        ;;        ;;
3523      *)      *)
3524        _TMP_DIR="${d}"'/';        _TMP_DIR="${mi_dir}"'/';
3525        ;;        ;;
3526      esac;      esac;
3527      _TMP_DIR="${_TMP_DIR}${_PROGRAM_NAME}${_PROCESS_ID}";      _TMP_DIR="${_TMP_DIR}${_PROGRAM_NAME}${_PROCESS_ID}";
# Line 3468  main_init() Line 3560  main_init()
3560      _TMP_DIR='';      _TMP_DIR='';
3561      continue;      continue;
3562    done;    done;
   unset d;  
3563    if obj _TMP_DIR is_empty;    if obj _TMP_DIR is_empty;
3564    then    then
3565      error "Couldn't create a directory for storing temporary files.";      error "main_init: \
3566    Couldn't create a directory for storing temporary files.";
3567    fi;    fi;
3568    
3569    _TMP_CAT="$(tmp_create groffer_cat)";    _TMP_CAT="$(tmp_create groffer_cat)";
# Line 3480  main_init() Line 3572  main_init()
3572    # groffer configuration files    # groffer configuration files
3573    for f in ${_CONFFILES};    for f in ${_CONFFILES};
3574    do    do
3575      if obj f is_file;      mi_file="$f";
3576        if obj mi_file is_file;
3577      then      then
3578        echo '_groffer_opt=""' >>${_TMP_CAT};        echo '_groffer_opt=""' >>${_TMP_CAT};
3579        # collect the lines starting with a minus        # collect the lines starting with a minus
3580        cat "$f" | sed -e \        cat "$mi_file" | sed -e \
3581          's/^[    ]*\(-.*\)$/_groffer_opt="${_groffer_opt} \1"'/ \          's/^[    ]*\(-.*\)$/_groffer_opt="${_groffer_opt} \1"'/ \
3582          >>${_TMP_CAT};          >>${_TMP_CAT};
3583        # prepend the collected information to $GROFFER_OPT        # prepend the collected information to $GROFFER_OPT
# Line 3494  main_init() Line 3587  main_init()
3587    . "${_TMP_CAT}";    . "${_TMP_CAT}";
3588    _TMP_CAT="$(tmp_create groffer_cat)";    _TMP_CAT="$(tmp_create groffer_cat)";
3589    
3590      unset mi_dir;
3591      unset mi_file;
3592    eval "${return_ok}";    eval "${return_ok}";
3593  } # main_init()  } # main_init()
3594    
3595    
3596    landmark '14: main_parse_MANOPT()';
3597  ########################################################################  ########################################################################
3598  # main_parse_MANOPT ()  # main_parse_MANOPT ()
3599  #  #
# Line 3509  main_init() Line 3605  main_init()
3605  #   out: $_MANOPT_*  #   out: $_MANOPT_*
3606  #   in/out: $GROFFER_OPT  #   in/out: $GROFFER_OPT
3607  #  #
3608  landmark '14: main_parse_MANOPT()';  # Variable prefix: mpm
3609    #
3610  main_parse_MANOPT()  main_parse_MANOPT()
3611  {  {
3612    func_check main_parse_MANOPT = 0 "$@";    func_check main_parse_MANOPT = 0 "$@";
3613    local _opt;    mpm_list='';
   local _list;  
   _list='';  
3614    if obj MANOPT is_not_empty;    if obj MANOPT is_not_empty;
3615    then    then
3616      MANOPT="$(echo -n "${MANOPT}" | \      MANOPT="$(echo -n "${MANOPT}" | \
# Line 3523  main_parse_MANOPT() Line 3618  main_parse_MANOPT()
3618    fi;    fi;
3619    if obj MANOPT is_empty;    if obj MANOPT is_empty;
3620    then    then
3621        unset mpm_list;
3622        unset mpm_opt;
3623      eval "${return_ok}";      eval "${return_ok}";
3624    fi;    fi;
3625    # add arguments in $MANOPT by mapping them to groffer options    # add arguments in $MANOPT by mapping them to groffer options
3626    eval set -- "$(list_from_cmdline _OPTS_MANOPT "${MANOPT}")";    eval set x "$(list_from_cmdline _OPTS_MANOPT "${MANOPT}")";
3627      shift;
3628    until test "$#" -le 0 || is_equal "$1" '--';    until test "$#" -le 0 || is_equal "$1" '--';
3629    do    do
3630      _opt="$1";      mpm_opt="$1";
3631      shift;      shift;
3632      case "${_opt}" in      case "${mpm_opt}" in
3633        -7|--ascii)        -7|--ascii)
3634          list_append _list '--ascii';          list_append mpm_list '--ascii';
3635          ;;          ;;
3636        -a|--all)        -a|--all)
3637          list_append _list '--all';          list_append mpm_list '--all';
3638          ;;          ;;
3639        -c|--catman)        -c|--catman)
3640          do_nothing;          do_nothing;
3641          shift;          shift;
3642          ;;          ;;
3643        -d|--debug)        -d|--debug)
3644          list_append _list '--debug';          list_append mpm_list '--debug';
3645          ;;          ;;
3646        -D|--default)        -D|--default)
3647          # undo all man options so far          # undo all man options so far
3648          _list='';          mpm_list='';
3649          ;;          ;;
3650        -e|--extension)        -e|--extension)
3651          list_append _list '--extension';          list_append mpm_list '--extension';
3652          shift;          shift;
3653          ;;          ;;
3654        -f|--whatis)        -f|--whatis)
3655          list_append _list '--whatis';          list_append mpm_list '--whatis';
3656          shift;          shift;
3657          ;;          ;;
3658        -h|--help)        -h|--help)
# Line 3567  main_parse_MANOPT() Line 3665  main_parse_MANOPT()
3665          shift;          shift;
3666          ;;          ;;
3667        -l|--local-file)        -l|--local-file)
3668          list_append _list '--local-file';          list_append mpm_list '--local-file';
3669          ;;          ;;
3670        -L|--locale)        -L|--locale)
3671          list_append _list '--locale' "$1";          list_append mpm_list '--locale' "$1";
3672          shift;          shift;
3673          ;;          ;;
3674        -m|--systems)        -m|--systems)
3675          list_append _list '--systems' "$1";          list_append mpm_list '--systems' "$1";
3676          shift;          shift;
3677          ;;          ;;
3678        -M|--manpath)        -M|--manpath)
3679          list_append _list '--manpath' "$1";          list_append mpm_list '--manpath' "$1";
3680          shift;          shift;
3681          ;;          ;;
3682        -p|--preprocessor)        -p|--preprocessor)
# Line 3586  main_parse_MANOPT() Line 3684  main_parse_MANOPT()
3684          shift;          shift;
3685          ;;          ;;
3686        -P|--pager|--tty-viewer)        -P|--pager|--tty-viewer)
3687          list_append _list '--pager' "$1";          list_append mpm_list '--pager' "$1";
3688          shift;          shift;
3689          ;;          ;;
3690        -r|--prompt)        -r|--prompt)
# Line 3594  main_parse_MANOPT() Line 3692  main_parse_MANOPT()
3692          shift;          shift;
3693          ;;          ;;
3694        -S|--sections)        -S|--sections)
3695          list_append _list '--sections' "$1";          list_append mpm_list '--sections' "$1";
3696          shift;          shift;
3697          ;;          ;;
3698        -t|--troff)        -t|--troff)
# Line 3602  main_parse_MANOPT() Line 3700  main_parse_MANOPT()
3700          shift;          shift;
3701          ;;          ;;
3702        -T|--device)        -T|--device)
3703          list_append _list '-T' "$1";          list_append mpm_list '-T' "$1";
3704          shift;          shift;
3705          ;;          ;;
3706        -u|--update)        -u|--update)
# Line 3613  main_parse_MANOPT() Line 3711  main_parse_MANOPT()
3711          do_nothing;          do_nothing;
3712          ;;          ;;
3713        -w|--where|--location)        -w|--where|--location)
3714          list_append _list '--location';          list_append mpm_list '--location';
3715          ;;          ;;
3716        -Z|--ditroff)        -Z|--ditroff)
3717          list_append _list '-Z' "$1";          list_append mpm_list '-Z' "$1";
3718          shift;          shift;
3719          ;;          ;;
3720        # ignore all other options        # ignore all other options
3721      esac;      esac;
3722    done;    done;
3723    # append the 2 lists in $_list and $GROFFER_OPT to $GROFFER_OPT    # append the 2 lists in $mpm_list and $GROFFER_OPT to $GROFFER_OPT
3724    if obj GROFFER_OPT is_empty;    if obj GROFFER_OPT is_empty;
3725    then    then
3726      GROFFER_OPT="${_list}";      GROFFER_OPT="${mpm_list}";
3727    elif obj _list is_not_empty;    elif obj mpm_list is_not_empty;
3728    then    then
3729      GROFFER_OPT="${_list} ${GROFFER_OPT}";      GROFFER_OPT="${mpm_list} ${GROFFER_OPT}";
3730    fi;    fi;
3731      unset mpm_list;
3732      unset mpm_opt;
3733    eval "${return_ok}";    eval "${return_ok}";
3734  } # main_parse_MANOPT()  } # main_parse_MANOPT()
3735    
3736    
3737    landmark '15: main_parse_args()';
3738  ########################################################################  ########################################################################
3739  # main_parse_args (<command_line_args>*)  # main_parse_args (<command_line_args>*)
3740  #  #
# Line 3644  main_parse_MANOPT() Line 3745  main_parse_MANOPT()
3745  #   in:  $_OPTS_*  #   in:  $_OPTS_*
3746  #   out: $_OPT_*, $_ADDOPTS, $_FILEARGS  #   out: $_OPT_*, $_ADDOPTS, $_FILEARGS
3747  #  #
3748  landmark '15: main_parse_args()';  #  Variable prefix: mpa
3749    #
3750  main_parse_args()  main_parse_args()
3751  {  {
3752    func_check main_parse_args '>=' 0 "$@";    func_check main_parse_args '>=' 0 "$@";
   local _arg;  
   local _code;  
   local _dpi;  
   local _longopt;  
   local _mode;  
   local _opt;  
   local _optchar;  
   local _optarg;  
   local _opts;  
   local _string;  
   
   eval set -- "${GROFFER_OPT}" '"$@"';  
   
   eval set -- "$(list_from_cmdline _OPTS_CMDLINE "$@")";  
   
 # By the call of `eval', unnecessary quoting was removed.  So the  
 # positional shell parameters ($1, $2, ...) are now guaranteed to  
 # represent an option or an argument to the previous option, if any;  
 # then a `--' argument for separating options and  
 # parameters; followed by the filespec parameters if any.  
3753    
3754  # Note, the existence of arguments to options has already been checked.    eval set x "${GROFFER_OPT}" '"$@"';
3755  # So a check for `$#' or `--' should not be done for arguments.    shift;
3756    
3757      eval set x "$(list_from_cmdline _OPTS_CMDLINE "$@")";
3758      shift;
3759    
3760      # By the call of `eval', unnecessary quoting was removed.  So the
3761      # positional shell parameters ($1, $2, ...) are now guaranteed to
3762      # represent an option or an argument to the previous option, if any;
3763      # then a `--' argument for separating options and
3764      # parameters; followed by the filespec parameters if any.
3765    
3766      # Note, the existence of arguments to options has already been checked.
3767      # So a check for `$#' or `--' should not be done for arguments.
3768    
3769    until test "$#" -le 0 || is_equal "$1" '--';    until test "$#" -le 0 || is_equal "$1" '--';
3770    do    do
3771      _opt="$1";                  # $_opt is fed into the option handler      mpa_opt="$1";               # $mpa_opt is fed into the option handler
3772      shift;      shift;
3773      case "${_opt}" in      case "${mpa_opt}" in
3774        -h|--help)        -h|--help)
3775          usage;          usage;
3776          leave;          leave;
# Line 3704  main_parse_args() Line 3798  main_parse_args()
3798          ;;          ;;
3799        -?)        -?)
3800          # delete leading `-'          # delete leading `-'
3801          _optchar="$(echo -n "${_opt}" | sed -e 's/^.//')";          mpa_optchar="$(echo -n "${mpa_opt}" | sed -e 's/^.//')";
3802          if list_has _OPTS_GROFF_SHORT_NA "${_optchar}";          if list_has _OPTS_GROFF_SHORT_NA "${mpa_optchar}";
3803          then          then
3804            list_append _ADDOPTS_GROFF "${_opt}";            list_append _ADDOPTS_GROFF "${mpa_opt}";
3805          elif list_has _OPTS_GROFF_SHORT_ARG "${_optchar}";          elif list_has _OPTS_GROFF_SHORT_ARG "${mpa_optchar}";
3806          then          then
3807            list_append _ADDOPTS_GROFF "${_opt}" "$1";            list_append _ADDOPTS_GROFF "${mpa_opt}" "$1";
3808            shift;            shift;
3809          else          else
3810            error "Unknown option : \`$1'";            error "main_parse_args(): Unknown option : \`$1'";
3811          fi;          fi;
3812          ;;          ;;
3813        --all)        --all)
# Line 3721  main_parse_args() Line 3815  main_parse_args()
3815            ;;            ;;
3816        --apropos)                # run `apropos'        --apropos)                # run `apropos'
3817          apropos_run "$1";          apropos_run "$1";
3818          _code="$?";          mpa_code="$?";
3819          clean_up;          clean_up;
3820          exit "${_code}";          exit "${mpa_code}";
3821          ;;          ;;
3822        --apropos-data)           # run `apropos' for data sections        --apropos-data)           # run `apropos' for data sections
3823          apropos_run "$1" | grep '^[^(]*([457][^)]*)';          apropos_run "$1" | grep '^[^(]*([457][^)]*)';
3824          _code="$?";          mpa_code="$?";
3825          clean_up;          clean_up;
3826          exit "${_code}";          exit "${mpa_code}";
3827          ;;          ;;
3828        --apropos-devel)          # run `apropos' for development sections        --apropos-devel)          # run `apropos' for development sections
3829          apropos_run "$1" | grep '^[^(]*([239][^)]*)';          apropos_run "$1" | grep '^[^(]*([239][^)]*)';
3830          _code="$?";          mpa_code="$?";
3831          clean_up;          clean_up;
3832          exit "${_code}";          exit "${mpa_code}";
3833          ;;          ;;
3834        --apropos-progs)          # run `apropos' for program sections        --apropos-progs)          # run `apropos' for program sections
3835          apropos_run "$1" | grep '^[^(]*([168][^)]*)';          apropos_run "$1" | grep '^[^(]*([168][^)]*)';
3836          _code="$?";          mpa_code="$?";
3837          clean_up;          clean_up;
3838          exit "${_code}";          exit "${mpa_code}";
3839          ;;          ;;
3840        --ascii)        --ascii)
3841          list_append _ADDOPTS_GROFF '-mtty-char';          list_append _ADDOPTS_GROFF '-mtty-char';
3842          if obj _mode is_empty;          if obj mpa_mode is_empty;
3843          then          then
3844            _mode='text';            mpa_mode='text';
3845          fi;          fi;
3846          ;;          ;;
3847        --auto)                   # the default automatic mode        --auto)                   # the default automatic mode
3848          _mode='';          mpa_mode='';
3849          ;;          ;;
3850        --bd)                     # border color for viewers, arg;        --bd)                     # border color for viewers, arg;
3851          _OPT_BD="$1";          _OPT_BD="$1";
# Line 3837  main_parse_args() Line 3931  main_parse_args()
3931          shift;          shift;
3932          ;;          ;;
3933        --mode)                   # display mode        --mode)                   # display mode
3934          _arg="$1";          mpa_arg="$1";
3935          shift;          shift;
3936          case "${_arg}" in          case "${mpa_arg}" in
3937            auto|'')              # search mode automatically among default            auto|'')              # search mode automatically among default
3938              _mode='';              mpa_mode='';
3939              ;;              ;;
3940            groff)                # pass input to plain groff            groff)                # pass input to plain groff
3941              _mode='groff';              mpa_mode='groff';
3942              ;;              ;;
3943            html|www)             # display with a web browser            html|www)             # display with a web browser
3944              _mode='html';              mpa_mode='html';
3945              ;;              ;;
3946            dvi)                  # display with xdvi viewer            dvi)                  # display with xdvi viewer
3947              _mode='dvi';              mpa_mode='dvi';
3948              ;;              ;;
3949            pdf)                  # display with PDF viewer            pdf)                  # display with PDF viewer
3950              _mode='pdf';              mpa_mode='pdf';
3951              ;;              ;;
3952            ps)                   # display with Postscript viewer            ps)                   # display with Postscript viewer
3953              _mode='ps';              mpa_mode='ps';
3954              ;;              ;;
3955            text)                 # output on terminal            text)                 # output on terminal
3956              _mode='text';              mpa_mode='text';
3957              ;;              ;;
3958            tty)                  # output on terminal            tty)                  # output on terminal
3959              _mode='tty';              mpa_mode='tty';
3960              ;;              ;;
3961            X|x)                  # output on X roff viewer            X|x)                  # output on X roff viewer
3962              _mode='x';              mpa_mode='x';
3963              ;;              ;;
3964            Q|source)             # display source code            Q|source)             # display source code
3965              _mode="source";              mpa_mode="source";
3966              ;;              ;;
3967            *)            *)
3968              error "unknown mode ${_arg}";              error "main_parse_args(): unknown mode ${mpa_arg}";
3969              ;;              ;;
3970          esac;          esac;
3971          _OPT_MODE="${_mode}";          _OPT_MODE="${mpa_mode}";
3972          ;;          ;;
3973        --no-location)            # disable former call to `--location'        --no-location)            # disable former call to `--location'
3974          _OPT_LOCATION='yes';          _OPT_LOCATION='yes';
# Line 3903  main_parse_args() Line 3997  main_parse_args()
3997          shift;          shift;
3998          ;;          ;;
3999        --resolution)             # set resolution for X devices, arg        --resolution)             # set resolution for X devices, arg
4000          _arg="$1";          mpa_arg="$1";
4001          shift;          shift;
4002          case "${_arg}" in          case "${mpa_arg}" in
4003            75|75dpi)            75|75dpi)
4004              _dpi=75;              mpa_dpi=75;
4005              ;;              ;;
4006            100|100dpi)            100|100dpi)
4007              _dpi=100;              mpa_dpi=100;
4008              ;;              ;;
4009            *)            *)
4010              error "only resoutions of 75 or 100 dpi are supported";              error "main_parse_args(): \
4011    only resoutions of 75 or 100 dpi are supported";
4012              ;;              ;;
4013          esac;          esac;
4014          _OPT_RESOLUTION="${_dpi}";          _OPT_RESOLUTION="${mpa_dpi}";
4015          ;;          ;;
4016        --rv)        --rv)
4017          _OPT_RV='yes';          _OPT_RV='yes';
# Line 3961  main_parse_args() Line 4056  main_parse_args()
4056          shift;          shift;
4057          ;;          ;;
4058        *)        *)
4059          error 'error on argument parsing : '"\`$*'";          error 'main_parse_args(): error on argument parsing : '"\`$*'";
4060          ;;          ;;
4061      esac;      esac;
4062    done;    done;
# Line 3979  main_parse_args() Line 4074  main_parse_args()
4074    # Save them to list $_FILEARGS    # Save them to list $_FILEARGS
4075    if is_equal "$#" 0;    if is_equal "$#" 0;
4076    then                          # use "-" for standard input    then                          # use "-" for standard input
4077      set -- '-';      set x '-';
4078        shift;
4079    fi;    fi;
4080    _FILEARGS='';    _FILEARGS='';
4081    list_append _FILEARGS "$@";    list_append _FILEARGS "$@";
# Line 3987  main_parse_args() Line 4083  main_parse_args()
4083    then    then
4084      save_stdin;      save_stdin;
4085    fi;    fi;
4086    # $_FILEARGS must be retrieved with `eval set -- "$_FILEARGS"'    # $_FILEARGS must be retrieved with `eval set x "$_FILEARGS"; shift;'
4087      unset mpa_arg;
4088      unset mpa_code;
4089      unset mpa_dpi;
4090      unset mpa_mode;
4091      unset mpa_opt;
4092      unset mpa_optchar;
4093    eval "${return_ok}";    eval "${return_ok}";
4094  } # main_parse_args()  } # main_parse_args()
4095    
4096    
4097  # Called from main_parse_args() because double `case' is not possible.  # Called from main_parse_args() because double `case' is not possible.
4098  # Globals: $_OPT_DEVICE, $_OPT_MODE  # Globals: $_OPT_DEVICE, $_OPT_MODE
4099  _check_device_with_mode()  _check_device_with_mode()
# Line 4033  _check_device_with_mode() Line 4136  _check_device_with_mode()
4136  }  }
4137    
4138    
4139    landmark '16: main_set_mode()';
4140  ########################################################################  ########################################################################
4141  # main_set_mode ()  # main_set_mode ()
4142  #  #
# Line 4042  _check_device_with_mode() Line 4146  _check_device_with_mode()
4146  #   in:  $DISPLAY, $_OPT_MODE, $_OPT_DEVICE  #   in:  $DISPLAY, $_OPT_MODE, $_OPT_DEVICE
4147  #   out: $_DISPLAY_MODE  #   out: $_DISPLAY_MODE
4148  #  #
4149    # Variable prefix: msm
 # _get_first_prog (<proglist>)  
4150  #  #
 # Retrieve first argument that represents an existing program in $PATH.  
 # Local function for main_set_mode().  
 #  
 # Arguments: 1; a comma-separated list of commands (with options),  
 #               like $_VIEWER_*.  
 #  
 # Return  : `1' if none found, `0' if found.  
 # Output  : the argument that succeded.  
 #  
 landmark '16: main_set_mode()';  
4151  main_set_mode()  main_set_mode()
4152  {  {
4153    func_check main_set_mode = 0 "$@";    func_check main_set_mode = 0 "$@";
   local m;  
   local _modes;  
   local _viewer;  
   local _viewers;  
4154    
4155    # handle apropos    # handle apropos
4156    if obj _OPT_APROPOS is_not_empty;    if obj _OPT_APROPOS is_not_empty;
4157    then    then
4158      apropos "${_OPT_APROPOS}";      apropos "${_OPT_APROPOS}";
4159      _code="$?";      msm_code="$?";
4160      clean_up;      clean_up;
4161      exit "${_code}";      exit "${msm_code}";
4162    fi;    fi;
4163    if obj _OPT_APROPOS_DATA is_not_empty;    if obj _OPT_APROPOS_DATA is_not_empty;
4164    then    then
4165      apropos "$@" | grep '^[^(]*([457])';      apropos "$@" | grep '^[^(]*([457])';
4166      _code="$?";      msm_code="$?";
4167      clean_up;      clean_up;
4168      exit "${_code}";      exit "${msm_code}";
4169    fi;    fi;
4170    if obj _OPT_APROPOS_DEVEL is_not_empty;    if obj _OPT_APROPOS_DEVEL is_not_empty;
4171    then    then
4172      apropos "$@" | grep '^[^(]*([239])';      apropos "$@" | grep '^[^(]*([239])';
4173      _code="$?";      msm_code="$?";
4174      clean_up;      clean_up;
4175      exit "${_code}";      exit "${msm_code}";
4176    fi;    fi;
4177    if obj _OPT_APROPOS_PROGS is_not_empty;    if obj _OPT_APROPOS_PROGS is_not_empty;
4178    then    then
4179      apropos "$@" | grep '^[^(]*([168])';      apropos "$@" | grep '^[^(]*([168])';
4180      _code="$?";      msm_code="$?";
4181      clean_up;      clean_up;
4182      exit "${_code}";      exit "${msm_code}";
4183    fi;    fi;
4184    
4185    # set display    # set display
# Line 4115  main_set_mode() Line 4204  main_set_mode()
4204    fi;    fi;
4205    if obj _DISPLAY_MODE is_equal 'groff';    if obj _DISPLAY_MODE is_equal 'groff';
4206    then    then
4207        unset msm_code;
4208        unset msm_modes;
4209        unset msm_viewer;
4210        unset msm_viewers;
4211      eval "${return_ok}";      eval "${return_ok}";
4212    fi;    fi;
4213    
4214    if obj _OPT_MODE is_equal 'source';    if obj _OPT_MODE is_equal 'source';
4215    then    then
4216      _DISPLAY_MODE='source';      _DISPLAY_MODE='source';
4217        unset msm_code;
4218        unset msm_modes;
4219        unset msm_viewer;
4220        unset msm_viewers;
4221      eval "${return_ok}";      eval "${return_ok}";
4222    fi;    fi;
4223    
# Line 4130  main_set_mode() Line 4227  main_set_mode()
4227          X*)          X*)
4228            if obj DISPLAY is_empty;            if obj DISPLAY is_empty;
4229            then            then
4230              error "no X display found for device ${_OPT_DEVICE}";              error "main_set_mode(): \
4231    no X display found for device ${_OPT_DEVICE}";
4232            fi;            fi;
4233            _DISPLAY_MODE='x';            _DISPLAY_MODE='x';
4234              unset msm_code;
4235              unset msm_modes;
4236              unset msm_viewer;
4237              unset msm_viewers;
4238            eval "${return_ok}";            eval "${return_ok}";
4239            ;;            ;;
4240          ascii|cp1047|latin1|utf8)          ascii|cp1047|latin1|utf8)
# Line 4140  main_set_mode() Line 4242  main_set_mode()
4242            then            then
4243              _DISPLAY_MODE='tty';              _DISPLAY_MODE='tty';
4244            fi;            fi;
4245              unset msm_code;
4246              unset msm_modes;
4247              unset msm_viewer;
4248              unset msm_viewers;
4249            eval "${return_ok}";            eval "${return_ok}";
4250            ;;            ;;
4251        esac;        esac;
4252        if obj DISPLAY is_empty;        if obj DISPLAY is_empty;
4253        then        then
4254          _DISPLAY_MODE='tty';          _DISPLAY_MODE='tty';
4255            unset msm_code;
4256            unset msm_modes;
4257            unset msm_viewer;
4258            unset msm_viewers;
4259          eval "${return_ok}";          eval "${return_ok}";
4260        fi;        fi;
4261    
4262        if obj _OPT_DEFAULT_MODES is_empty;        if obj _OPT_DEFAULT_MODES is_empty;
4263        then        then
4264          _modes="${_DEFAULT_MODES}";          msm_modes="${_DEFAULT_MODES}";
4265        else        else
4266          _modes="${_OPT_DEFAULT_MODES}";          msm_modes="${_OPT_DEFAULT_MODES}";
4267        fi;        fi;
4268        ;;        ;;
4269      text)      text)
4270        _DISPLAY_MODE='text';        _DISPLAY_MODE='text';
4271          unset msm_code;
4272          unset msm_modes;
4273          unset msm_viewer;
4274          unset msm_viewers;
4275        eval "${return_ok}";        eval "${return_ok}";
4276        ;;        ;;
4277      tty)      tty)
4278        _DISPLAY_MODE='tty';        _DISPLAY_MODE='tty';
4279          unset msm_code;
4280          unset msm_modes;
4281          unset msm_viewer;
4282          unset msm_viewers;
4283        eval "${return_ok}";        eval "${return_ok}";
4284        ;;        ;;
4285      *)                          # display mode was given      *)                          # display mode was given
4286        if obj DISPLAY is_empty;        if obj DISPLAY is_empty;
4287        then        then
4288          error "you must be in X Window for ${_OPT_MODE} mode.";          error "main_set_mode(): \
4289    you must be in X Window for ${_OPT_MODE} mode.";
4290        fi;        fi;
4291        _modes="${_OPT_MODE}";        msm_modes="${_OPT_MODE}";
4292        ;;        ;;
4293    esac;    esac;
4294    
4295    # only viewer modes are left    # only viewer modes are left
4296    eval set -- "$(list_from_split "${_modes}" ',')";    eval set x "$(list_from_split "${msm_modes}" ',')";
4297      shift;
4298    while test "$#" -gt 0;    while test "$#" -gt 0;
4299    do    do
4300      m="$1";      m="$1";
# Line 4182  main_set_mode() Line 4302  main_set_mode()
4302      case "$m" in      case "$m" in
4303        text)        text)
4304          _DISPLAY_MODE='text';          _DISPLAY_MODE='text';
4305            unset msm_code;
4306            unset msm_modes;
4307            unset msm_viewer;
4308            unset msm_viewers;
4309          eval "${return_ok}";          eval "${return_ok}";
4310          ;;          ;;
4311        tty)        tty)
4312          _DISPLAY_MODE='tty';          _DISPLAY_MODE='tty';
4313            unset msm_code;
4314            unset msm_modes;
4315            unset msm_viewer;
4316            unset msm_viewers;
4317          eval "${return_ok}";          eval "${return_ok}";
4318          ;;          ;;
4319        x)        x)
4320          if obj _OPT_VIEWER_X is_not_empty;          if obj _OPT_VIEWER_X is_not_empty;
4321          then          then
4322            _viewers="${_OPT_VIEWER_X}";            msm_viewers="${_OPT_VIEWER_X}";
4323          else          else
4324            _viewers="${_VIEWER_X}";            msm_viewers="${_VIEWER_X}";
4325          fi;          fi;
4326          _viewer="$(_get_first_prog "${_viewers}")";          msm_viewer="$(_get_first_prog "${msm_viewers}")";
4327          if is_not_equal "$?" 0;          if is_not_equal "$?" 0;
4328          then          then
4329            continue;            continue;
4330          fi;          fi;
4331          _DISPLAY_PROG="${_viewer}";          _DISPLAY_PROG="${msm_viewer}";
4332          _DISPLAY_MODE='x';          _DISPLAY_MODE='x';
4333            unset msm_code;
4334            unset msm_modes;
4335            unset msm_viewer;
4336            unset msm_viewers;
4337          eval "${return_ok}";          eval "${return_ok}";
4338          ;;          ;;
4339        dvi)        dvi)
4340          if obj _OPT_VIEWER_DVI is_not_empty;          if obj _OPT_VIEWER_DVI is_not_empty;
4341          then          then
4342            _viewers="${_OPT_VIEWER_DVI}";            msm_viewers="${_OPT_VIEWER_DVI}";
4343          else          else
4344            _viewers="${_VIEWER_DVI}";            msm_viewers="${_VIEWER_DVI}";
4345          fi;          fi;
4346          _viewer="$(_get_first_prog "${_viewers}")";          msm_viewer="$(_get_first_prog "${msm_viewers}")";
4347          if is_not_equal "$?" 0;          if is_not_equal "$?" 0;
4348          then          then
4349            continue;            continue;
4350          fi;          fi;
4351          _DISPLAY_PROG="${_viewer}";          _DISPLAY_PROG="${msm_viewer}";
4352          _DISPLAY_MODE="dvi";          _DISPLAY_MODE="dvi";
4353            unset msm_code;
4354            unset msm_modes;
4355            unset msm_viewer;
4356            unset msm_viewers;
4357          eval "${return_ok}";          eval "${return_ok}";
4358          ;;          ;;
4359        pdf)        pdf)
4360          if obj _OPT_VIEWER_PDF is_not_empty;          if obj _OPT_VIEWER_PDF is_not_empty;
4361          then          then
4362            _viewers="${_OPT_VIEWER_PDF}";            msm_viewers="${_OPT_VIEWER_PDF}";
4363          else          else
4364            _viewers="${_VIEWER_PDF}";            msm_viewers="${_VIEWER_PDF}";
4365          fi;          fi;
4366          _viewer="$(_get_first_prog "${_viewers}")";          msm_viewer="$(_get_first_prog "${msm_viewers}")";
4367          if is_not_equal "$?" 0;          if is_not_equal "$?" 0;
4368          then          then
4369            continue;            continue;
4370          fi;          fi;
4371          _DISPLAY_PROG="${_viewer}";          _DISPLAY_PROG="${msm_viewer}";
4372          _DISPLAY_MODE="pdf";          _DISPLAY_MODE="pdf";
4373            unset msm_code;
4374            unset msm_modes;
4375            unset msm_viewer;
4376            unset msm_viewers;
4377          eval "${return_ok}";          eval "${return_ok}";
4378          ;;          ;;
4379        ps)        ps)
4380          if obj _OPT_VIEWER_PS is_not_empty;          if obj _OPT_VIEWER_PS is_not_empty;
4381          then          then
4382            _viewers="${_OPT_VIEWER_PS}";            msm_viewers="${_OPT_VIEWER_PS}";
4383          else          else
4384            _viewers="${_VIEWER_PS}";            msm_viewers="${_VIEWER_PS}";
4385          fi;          fi;
4386          _viewer="$(_get_first_prog "${_viewers}")";          msm_viewer="$(_get_first_prog "${msm_viewers}")";
4387          if is_not_equal "$?" 0;          if is_not_equal "$?" 0;
4388          then          then
4389            continue;            continue;
4390          fi;          fi;
4391          _DISPLAY_PROG="${_viewer}";          _DISPLAY_PROG="${msm_viewer}";
4392          _DISPLAY_MODE="ps";          _DISPLAY_MODE="ps";
4393            unset msm_code;
4394            unset msm_modes;
4395            unset msm_viewer;
4396            unset msm_viewers;
4397          eval "${return_ok}";          eval "${return_ok}";
4398          ;;          ;;
4399        html)        html)
4400          if obj _OPT_VIEWER_HTML is_not_empty;          if obj _OPT_VIEWER_HTML is_not_empty;
4401          then          then
4402            _viewers="${_OPT_VIEWER_HTML}";            msm_viewers="${_OPT_VIEWER_HTML}";
4403          else          else
4404            _viewers="${_VIEWER_HTML}";            msm_viewers="${_VIEWER_HTML}";
4405          fi;          fi;
4406          _viewer="$(_get_first_prog "${_viewers}")";          msm_viewer="$(_get_first_prog "${msm_viewers}")";
4407          if is_not_equal "$?" 0;          if is_not_equal "$?" 0;
4408          then          then
4409            continue;            continue;
4410          fi;          fi;
4411          _DISPLAY_PROG="${_viewer}";          _DISPLAY_PROG="${msm_viewer}";
4412          _DISPLAY_MODE=html;          _DISPLAY_MODE=html;
4413            unset msm_code;
4414            unset msm_modes;
4415            unset msm_viewer;
4416            unset msm_viewers;
4417          eval "${return_ok}";          eval "${return_ok}";
4418          ;;          ;;
4419      esac;      esac;
4420    done;    done;
4421    error "no suitable display mode found.";    unset msm_code;
4422      unset msm_modes;
4423      unset msm_viewer;
4424      unset msm_viewers;
4425      error "main_set_mode(): no suitable display mode found.";
4426  }  }
4427    
4428    
4429    # _get_first_prog (<proglist>)
4430    #
4431    # Retrieve first argument that represents an existing program in $PATH.
4432    # Local function for main_set_mode().
4433    #
4434    # Arguments: 1; a comma-separated list of commands (with options),
4435    #               like $_VIEWER_*.
4436    #
4437    # Return  : `1' if none found, `0' if found.
4438    # Output  : the argument that succeded.
4439    #
4440    # Variable prefix: _gfp
4441    #
4442  _get_first_prog()  _get_first_prog()
4443  {  {
   local i;  
4444    if is_equal "$#" 0;    if is_equal "$#" 0;
4445    then    then
4446      error "_get_first_prog() needs 1 argument.";      error "_get_first_prog() needs 1 argument.";
# Line 4284  _get_first_prog() Line 4449  _get_first_prog()
4449    then    then
4450      return "${_BAD}";      return "${_BAD}";
4451    fi;    fi;
4452    eval set -- "$(list_from_split "$1" ',')";    eval set x "$(list_from_split "$1" ',')";
4453    for i in "$@";    shift;
4454      for i;
4455    do    do
4456      if obj i is_empty;      _gfp_i="$i";
4457        if obj _gfp_i is_empty;
4458      then      then
4459        continue;        continue;
4460      fi;      fi;
4461      if is_prog "$(get_first_essential $i)";      if is_prog "$(get_first_essential $i)";
4462      then      then
4463        echo -n "$i";        echo -n "${_gfp_i}";
4464          unset _gfp_i;
4465        return "${_GOOD}";        return "${_GOOD}";
4466      fi;      fi;
4467    done;    done;
4468      unset _gfp_i;
4469    return "${_BAD}";    return "${_BAD}";
4470  } # main_set_mode()  } # main_set_mode()
4471    
4472    
4473    landmark '17: main_do_fileargs()';
4474  #######################################################################  #######################################################################
4475  # main_do_fileargs ()  # main_do_fileargs ()
4476  #  #
4477  # Process filespec arguments in $_FILEARGS.  # Process filespec arguments in $_FILEARGS.
4478  #  #
4479  # Globals:  # Globals:
4480  #   in: $_FILEARGS (process with `eval set -- "$_FILEARGS"')  #   in: $_FILEARGS (process with `eval set x "$_FILEARGS"; shift;')
4481    #
4482    # Variable prefix: mdfa
4483  #  #
 landmark '17: main_do_fileargs()';  
4484  main_do_fileargs()  main_do_fileargs()
4485  {  {
4486    func_check main_do_fileargs = 0 "$@";    func_check main_do_fileargs = 0 "$@";
4487    local _exitcode;    mdfa_exitcode="${_BAD}";
4488    local _filespec;    eval set x "${_FILEARGS}";
4489    local _name;    shift;
   _exitcode="${_BAD}";  
   eval set -- "${_FILEARGS}";  
4490    unset _FILEARGS;    unset _FILEARGS;
4491    # temporary storage of all input to $_TMP_CAT    # temporary storage of all input to $_TMP_CAT
4492    while test "$#" -ge 2;    while test "$#" -ge 2;
4493    do    do
4494      # test for `s name' arguments, with `s' a 1-char standard section      # test for `s name' arguments, with `s' a 1-char standard section
4495      _filespec="$1";      mdfa_filespec="$1";
4496      shift;      shift;
4497      case "${_filespec}" in      case "${mdfa_filespec}" in
4498        '')        '')
4499          continue;          continue;
4500          ;;          ;;
4501        '-')        '-')
4502          if register_file '-';          if register_file '-';
4503          then          then
4504            _exitcode="${_GOOD}";            mdfa_exitcode="${_GOOD}";
4505          fi;          fi;
4506          continue;          continue;
4507          ;;          ;;
4508        ?)        ?)
4509          if list_has_not _MAN_AUTO_SEC "${_filespec}";          if list_has_not _MAN_AUTO_SEC "${mdfa_filespec}";
4510          then          then
4511            if do_filearg "${_filespec}";            if do_filearg "${mdfa_filespec}";
4512            then            then
4513              _exitcode="${_GOOD}";              mdfa_exitcode="${_GOOD}";
4514            fi;            fi;
4515            continue;            continue;
4516          fi;          fi;
4517          _name="$1";          mdfa_name="$1";
4518          case "${_name}" in          case "${mdfa_name}" in
4519            */*|man:*|*\(*\)|*."${_filespec}")            */*|man:*|*\(*\)|*."${mdfa_filespec}")
4520              if do_filearg "${_filespec}";              if do_filearg "${mdfa_filespec}";
4521              then              then
4522                _exitcode="${_GOOD}";                mdfa_exitcode="${_GOOD}";
4523              fi;              fi;
4524              continue;              continue;
4525              ;;              ;;
4526          esac;          esac;
4527          if do_filearg "man:${_name}(${_filespec})";          if do_filearg "man:${mdfa_name}(${mdfa_filespec})";
4528          then          then
4529            _exitcode="${_GOOD}";            mdfa_exitcode="${_GOOD}";
4530            shift;            shift;
4531            continue;            continue;
4532          else          else
4533            if do_filearg "${_filespec}";            if do_filearg "${mdfa_filespec}";
4534            then            then
4535              _exitcode="${_GOOD}";              mdfa_exitcode="${_GOOD}";
4536            fi;            fi;
4537            continue;            continue;
4538          fi;          fi;
4539          ;;          ;;
4540        *)        *)
4541          if do_filearg "${_filespec}";          if do_filearg "${mdfa_filespec}";
4542          then          then
4543            _exitcode="${_GOOD}";            mdfa_exitcode="${_GOOD}";
4544          fi;          fi;
4545          continue;          continue;
4546          ;;          ;;
# Line 4379  main_do_fileargs() Line 4548  main_do_fileargs()
4548    done;                         # end of `s name' test    done;                         # end of `s name' test
4549    while test "$#" -gt 0;    while test "$#" -gt 0;
4550    do    do
4551      _filespec="$1";      mdfa_filespec="$1";
4552      shift;      shift;
4553      if do_filearg "${_filespec}";      if do_filearg "${mdfa_filespec}";
4554      then      then
4555        _exitcode="${_GOOD}";        mdfa_exitcode="${_GOOD}";
4556      fi;      fi;
4557    done;    done;
4558    rm -f "${_TMP_STDIN}";    rm -f "${_TMP_STDIN}";
4559    if is_equal "${_exitcode}" "${_BAD}";    if is_equal "${mdfa_exitcode}" "${_BAD}";
4560    then    then
4561        unset mdfa_exitcode;
4562        unset mdfa_filespec;
4563        unset mdfa_name;
4564      eval "${return_bad}";      eval "${return_bad}";
4565    fi;    fi;
4566      unset mdfa_exitcode;
4567      unset mdfa_filespec;
4568      unset mdfa_name;
4569    eval "${return_ok}";    eval "${return_ok}";
4570  } # main_do_fileargs()  } # main_do_fileargs()
4571    
4572    
4573    landmark '18: main_set_resources()';
4574  ########################################################################  ########################################################################
4575  # main_set_resources ()  # main_set_resources ()
4576  #  #
# Line 4402  main_do_fileargs() Line 4578  main_do_fileargs()
4578  #  #
4579  # Globals: $_DISPLAY_PROG, $_OUTPUT_FILE_NAME  # Globals: $_DISPLAY_PROG, $_OUTPUT_FILE_NAME
4580  #  #
4581  landmark '18: main_set_resources()';  # Variable prefix: msr
4582    #
4583  main_set_resources()  main_set_resources()
4584  {  {
4585    func_check main_set_resources = 0 "$@";    func_check main_set_resources = 0 "$@";
4586    local _prog;                  # viewer program    # $msr_prog   viewer program
4587    local _rl;                    # resource list    # $msr_rl     resource list
4588    local n;    msr_title="$(get_first_essential \
4589    _title="$(get_first_essential \                   "${_OPT_TITLE}" "${_REGISTERED_TITLE}")";
                 "${_OPT_TITLE}" "${_REGISTERED_TITLE}")";  
4590    _OUTPUT_FILE_NAME='';    _OUTPUT_FILE_NAME='';
4591    set -- ${_title};    set x ${msr_title};
4592      shift;
4593    until is_equal "$#" 0;    until is_equal "$#" 0;
4594    do    do
4595      n="$1";      msr_n="$1";
4596      case "$n" in      case "${msr_n}" in
4597      '')      '')
4598        continue;        continue;
4599        ;;        ;;
4600      ,*)      ,*)
4601        n="$(echo -n "$1" | sed -e 's/^,,*//')";        msr_n="$(echo -n "$1" | sed -e 's/^,,*//')";
4602        ;;        ;;
4603      esac      esac
4604      if obj n is_empty;      if obj msr_n is_empty;
4605      then      then
4606        continue;        continue;
4607      fi;      fi;
# Line 4432  main_set_resources() Line 4609  main_set_resources()
4609      then      then
4610        _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME},";        _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME},";
4611      fi;      fi;
4612      _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}$n";      _OUTPUT_FILE_NAME="${_OUTPUT_FILE_NAME}${msr_n}";
4613      shift;      shift;
4614    done;    done;
4615    case "${_OUTPUT_FILE_NAME}" in    case "${_OUTPUT_FILE_NAME}" in
# Line 4440  main_set_resources() Line 4617  main_set_resources()
4617      _OUTPUT_FILE_NAME='-';      _OUTPUT_FILE_NAME='-';
4618      ;;      ;;
4619    ,*)    ,*)
4620      error "$_OUTPUT_FILE_NAME starts with a comma.";      error "main_set_resources(): ${_OUTPUT_FILE_NAME} starts with a comma.";
4621      ;;      ;;
4622    esac;    esac;
4623    _OUTPUT_FILE_NAME="${_TMP_DIR}/${_OUTPUT_FILE_NAME}";    _OUTPUT_FILE_NAME="${_TMP_DIR}/${_OUTPUT_FILE_NAME}";
# Line 4448  main_set_resources() Line 4625  main_set_resources()
4625    if obj _DISPLAY_PROG is_empty;    if obj _DISPLAY_PROG is_empty;
4626    then                          # for example, for groff mode    then                          # for example, for groff mode
4627      _DISPLAY_ARGS='';      _DISPLAY_ARGS='';
4628        unset msr_n;
4629        unset msr_prog;
4630        unset msr_rl;
4631        unset msr_title;
4632      eval "${return_ok}";      eval "${return_ok}";
4633    fi;    fi;
4634    
4635    set -- ${_DISPLAY_PROG};    set x ${_DISPLAY_PROG};
4636    _prog="$(base_name "$1")";    shift;
4637    _rl='';    msr_prog="$(base_name "$1")";
4638      msr_rl='';
4639    if obj _OPT_BD is_not_empty;    if obj _OPT_BD is_not_empty;
4640    then    then
4641      case "${_prog}" in      case "${msr_prog}" in
4642        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4643          list_append _rl '-bd' "${_OPT_BD}";          list_append msr_rl '-bd' "${_OPT_BD}";
4644          ;;          ;;
4645      esac;      esac;
4646    fi;    fi;
4647    if obj _OPT_BG is_not_empty;    if obj _OPT_BG is_not_empty;
4648    then    then
4649      case "${_prog}" in      case "${msr_prog}" in
4650        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4651          list_append _rl '-bg' "${_OPT_BG}";          list_append msr_rl '-bg' "${_OPT_BG}";
4652          ;;          ;;
4653        xpdf)        xpdf)
4654          list_append _rl '-papercolor' "${_OPT_BG}";          list_append msr_rl '-papercolor' "${_OPT_BG}";
4655          ;;          ;;
4656      esac;      esac;
4657    fi;    fi;
4658    if obj _OPT_BW is_not_empty;    if obj _OPT_BW is_not_empty;
4659    then    then
4660      case "${_prog}" in      case "${msr_prog}" in
4661        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4662          _list_append _rl '-bw' "${_OPT_BW}";          _list_append msr_rl '-bw' "${_OPT_BW}";
4663          ;;          ;;
4664      esac;      esac;
4665    fi;    fi;
4666    if obj _OPT_FG is_not_empty;    if obj _OPT_FG is_not_empty;
4667    then    then
4668      case "${_prog}" in      case "${msr_prog}" in
4669        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4670          list_append _rl '-fg' "${_OPT_FG}";          list_append msr_rl '-fg' "${_OPT_FG}";
4671          ;;          ;;
4672      esac;      esac;
4673    fi;    fi;
4674    if is_not_empty "${_OPT_FN}";    if is_not_empty "${_OPT_FN}";
4675    then    then
4676      case "${_prog}" in      case "${msr_prog}" in
4677        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4678          list_append _rl '-fn' "${_OPT_FN}";          list_append msr_rl '-fn' "${_OPT_FN}";
4679          ;;          ;;
4680      esac;      esac;
4681    fi;    fi;
4682    if is_not_empty "${_OPT_GEOMETRY}";    if is_not_empty "${_OPT_GEOMETRY}";
4683    then    then
4684      case "${_prog}" in      case "${msr_prog}" in
4685        ghostview|gv|gxditview|xditview|xdvi|xpdf)        ghostview|gv|gxditview|xditview|xdvi|xpdf)
4686          list_append _rl '-geometry' "${_OPT_GEOMETRY}";          list_append msr_rl '-geometry' "${_OPT_GEOMETRY}";
4687          ;;          ;;
4688      esac;      esac;
4689    fi;    fi;
4690    if is_empty "${_OPT_RESOLUTION}";    if is_empty "${_OPT_RESOLUTION}";
4691    then    then
4692      _OPT_RESOLUTION="${_DEFAULT_RESOLUTION}";      _OPT_RESOLUTION="${_DEFAULT_RESOLUTION}";
4693      case "${_prog}" in      case "${msr_prog}" in
4694        gxditview|xditview)        gxditview|xditview)
4695          list_append _rl '-resolution' "${_DEFAULT_RESOLUTION}";          list_append msr_rl '-resolution' "${_DEFAULT_RESOLUTION}";
4696          ;;          ;;
4697        xpdf)        xpdf)
4698          case "${_DEFAULT_RESOLUTION}" in          case "${_DEFAULT_RESOLUTION}" in
4699            75)            75)
4700              # 72dpi is '100'              # 72dpi is '100'
4701              list_append _rl '-z' '104';              list_append msr_rl '-z' '104';
4702              ;;              ;;
4703            100)            100)
4704              list_append _rl '-z' '139';              list_append msr_rl '-z' '139';
4705              ;;              ;;
4706          esac;          esac;
4707          ;;          ;;
4708      esac;      esac;
4709    else    else
4710      case "${_prog}" in      case "${msr_prog}" in
4711        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4712          list_append _rl '-resolution' "${_OPT_RESOLUTION}";          list_append msr_rl '-resolution' "${_OPT_RESOLUTION}";
4713          ;;          ;;
4714        xpdf)        xpdf)
4715          case "${_OPT_RESOLUTION}" in          case "${_OPT_RESOLUTION}" in
4716            75)            75)
4717              list_append _rl '-z' '104';              list_append msr_rl '-z' '104';
4718              # '100' corresponds to 72dpi              # '100' corresponds to 72dpi
4719              ;;              ;;
4720            100)            100)
4721              list_append _rl '-z' '139';              list_append msr_rl '-z' '139';
4722              ;;              ;;
4723          esac;          esac;
4724          ;;          ;;
# Line 4544  main_set_resources() Line 4726  main_set_resources()
4726    fi;    fi;
4727    if is_yes "${_OPT_ICONIC}";    if is_yes "${_OPT_ICONIC}";
4728    then    then
4729      case "${_prog}" in      case "${msr_prog}" in
4730        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4731          list_append _rl '-iconic';          list_append msr_rl '-iconic';
4732          ;;          ;;
4733      esac;      esac;
4734    fi;    fi;
4735    if is_yes "${_OPT_RV}";    if is_yes "${_OPT_RV}";
4736    then    then
4737      case "${_prog}" in      case "${msr_prog}" in
4738        ghostview|gv|gxditview|xditview|xdvi)        ghostview|gv|gxditview|xditview|xdvi)
4739          list_append _rl '-rv';          list_append msr_rl '-rv';
4740          ;;          ;;
4741      esac;      esac;
4742    fi;    fi;
4743    if is_not_empty "${_OPT_XRM}";    if is_not_empty "${_OPT_XRM}";
4744    then    then
4745      case "${_prog}" in      case "${msr_prog}" in
4746        ghostview|gv|gxditview|xditview|xdvi|xpdf)        ghostview|gv|gxditview|xditview|xdvi|xpdf)
4747          eval set -- "{$_OPT_XRM}";          eval set x "${_OPT_XRM}";
4748          for i in "$@";          shift;
4749            for i;
4750          do          do
4751            list_append _rl '-xrm' "$i";            list_append msr_rl '-xrm' "$i";
4752          done;          done;
4753          ;;          ;;
4754      esac;      esac;
4755    fi;    fi;
4756    if is_not_empty "${_title}";    if is_not_empty "${msr_title}";
4757    then    then
4758      case "${_prog}" in      case "${msr_prog}" in
4759        gxditview|xditview)        gxditview|xditview)
4760          list_append _rl '-title' "${_title}";          list_append msr_rl '-title' "${msr_title}";
4761          ;;          ;;
4762      esac;      esac;
4763    fi;    fi;
4764    _DISPLAY_ARGS="${_rl}";    _DISPLAY_ARGS="${msr_rl}";
4765      unset msr_n;
4766      unset msr_prog;
4767      unset msr_rl;
4768      unset msr_title;
4769    eval "${return_ok}";    eval "${return_ok}";
4770  } # main_set_resources  } # main_set_resources
4771    
4772    
4773    landmark '19: main_display()';
4774  ########################################################################  ########################################################################
4775  # main_display ()  # main_display ()
4776  #  #
# Line 4595  main_set_resources() Line 4782  main_set_resources()
4782  #       $_REGISTERED_TITLE, $_TMP_CAT,  #       $_REGISTERED_TITLE, $_TMP_CAT,
4783  #       $_OPT_PAGER $PAGER $_MANOPT_PAGER  #       $_OPT_PAGER $PAGER $_MANOPT_PAGER
4784  #  #
4785  landmark '19: main_display()';  # Variable prefix: md
4786    #
4787  main_display()  main_display()
4788  {  {
4789    func_check main_display = 0 "$@";    func_check main_display = 0 "$@";
4790    local p;  
4791    local _addopts;    export md_addopts;
4792    local _device;    export md_groggy;
4793    local _groggy;    export md_modefile;
   local _modefile;  
   local _options;  
   local _pager;  
   local _title;  
   export _addopts;  
   export _groggy;  
   export _modefile;  
4794    
4795    if obj _TMP_CAT is_non_empty_file;    if obj _TMP_CAT is_non_empty_file;
4796    then    then
4797      _modefile="${_OUTPUT_FILE_NAME}";      md_modefile="${_OUTPUT_FILE_NAME}";
4798    else    else
4799      clean_up;      clean_up;
4800        unset md_modefile;
4801      eval "${return_ok}";      eval "${return_ok}";
4802    fi;    fi;
4803    case "${_DISPLAY_MODE}" in    case "${_DISPLAY_MODE}" in
# Line 4625  main_display() Line 4807  main_display()
4807        then        then
4808          _ADDOPTS_GROFF="${_ADDOPTS_GROFF} -T${_OPT_DEVICE}";          _ADDOPTS_GROFF="${_ADDOPTS_GROFF} -T${_OPT_DEVICE}";
4809        fi;        fi;
4810        _groggy="$(tmp_cat | eval grog "${_options}")";        md_groggy="$(tmp_cat | eval grog "${md_options}")";
4811        trap_clean;        trap_clean;
4812        # start a new shell program to get another process ID.        # start a new shell program to get another process ID.
4813        sh -c '        sh -c '
4814          set -e;          set -e;
4815          test -f "${_modefile}" && rm -f "${_modefile}";          test -f "${md_modefile}" && rm -f "${md_modefile}";
4816          mv "${_TMP_CAT}" "${_modefile}";          mv "${_TMP_CAT}" "${md_modefile}";
4817          cat "${_modefile}" | \          cat "${md_modefile}" | \
4818          (          (
4819            clean_up()            clean_up()
4820            {            {
# Line 4643  main_display() Line 4825  main_display()
4825              fi;              fi;
4826            }            }
4827            trap clean_up 0 2>${_NULL_DEV} || true;            trap clean_up 0 2>${_NULL_DEV} || true;
4828            eval "${_groggy}" "${_ADDOPTS_GROFF}";            eval "${md_groggy}" "${_ADDOPTS_GROFF}";
4829          ) &'          ) &'
4830        ;;        ;;
4831      text|tty)      text|tty)
4832        case "${_OPT_DEVICE}" in        case "${_OPT_DEVICE}" in
4833          '')          '')
4834            _device="$(get_first_essential \            md_device="$(get_first_essential \
4835                       "${_OPT_TEXT_DEVICE}" "${_DEFAULT_TTY_DEVICE}")";                           "${_OPT_TEXT_DEVICE}" "${_DEFAULT_TTY_DEVICE}")";
4836            ;;            ;;
4837          ascii|cp1047|latin1|utf8)          ascii|cp1047|latin1|utf8)
4838            _device="${_OPT_DEVICE}";            md_device="${_OPT_DEVICE}";
4839            ;;            ;;
4840          *)          *)
4841            warning \            warning "main_display(): \
4842              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4843            ;;            ;;
4844        esac;        esac;
4845        _addopts="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}";        md_addopts="${_ADDOPTS_GROFF} ${_ADDOPTS_POST}";
4846        _groggy="$(tmp_cat | grog -T${_device})";        md_groggy="$(tmp_cat | grog -T${md_device})";
4847        if obj _DISPLAY_MODE is_equal 'text';        if obj _DISPLAY_MODE is_equal 'text';
4848        then        then
4849          tmp_cat | eval "${_groggy}" "${_addopts}";          tmp_cat | eval "${md_groggy}" "${md_addopts}";
4850        else        else
4851          _pager='';          md_pager='';
4852          for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \          for p in "${_OPT_PAGER}" "${PAGER}" "${_MANOPT_PAGER}" \
4853                   'less -r -R' 'more' 'pager' 'cat';                   'less -r -R' 'more' 'pager' 'cat';
4854          do          do
4855            if is_prog $p;            md_p="$p";
4856              if is_prog ${md_p};
4857            then                # no "" for is_prog() allows args for $p            then                # no "" for is_prog() allows args for $p
4858              _pager="$p";              md_pager="${md_p}";
4859              break;              break;
4860            fi;            fi;
4861          done;          done;
4862          if obj _pager is_empty;          if obj md_pager is_empty;
4863          then          then
4864            error 'no pager program found for tty mode';            error 'main_display(): no pager program found for tty mode';
4865          fi;          fi;
4866          tmp_cat | eval "${_groggy}" "${_addopts}" | \          tmp_cat | eval "${md_groggy}" "${md_addopts}" | \
4867                    eval "${_pager}";                    eval "${md_pager}";
4868        fi;        fi;
4869        clean_up;        clean_up;
4870        ;;        ;;
# Line 4692  main_display() Line 4875  main_display()
4875        case "${_OPT_DEVICE}" in        case "${_OPT_DEVICE}" in
4876          ''|dvi) do_nothing; ;;          ''|dvi) do_nothing; ;;
4877          *)          *)
4878            warning \            warning "main_display(): \
4879              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4880            ;;            ;;
4881        esac;        esac;
4882        _modefile="${_modefile}".dvi;        md_modefile="${md_modefile}".dvi;
4883        _groggy="$(tmp_cat | grog -Tdvi)";        md_groggy="$(tmp_cat | grog -Tdvi)";
4884        _do_display;        _do_display;
4885        ;;        ;;
4886      html)      html)
4887        case "${_OPT_DEVICE}" in        case "${_OPT_DEVICE}" in
4888          ''|html) do_nothing; ;;          ''|html) do_nothing; ;;
4889          *)          *)
4890            warning \            warning "main_display(): \
4891              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4892            ;;            ;;
4893        esac;        esac;
4894        _modefile="${_modefile}".html;        md_modefile="${md_modefile}".html;
4895        _groggy="$(tmp_cat | grog -Thtml)";        md_groggy="$(tmp_cat | grog -Thtml)";
4896        _do_display;        _do_display;
4897        ;;        ;;
4898      pdf)      pdf)
# Line 4718  main_display() Line 4901  main_display()
4901            do_nothing;            do_nothing;
4902            ;;            ;;
4903          *)          *)
4904            warning \            warning "main_display(): \
4905              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4906            ;;            ;;
4907        esac;        esac;
4908        _groggy="$(tmp_cat | grog -Tps)";        md_groggy="$(tmp_cat | grog -Tps)";
4909        trap_clean;        trap_clean;
4910        # start a new shell program to get another process ID.        # start a new shell program to get another process ID.
4911        sh -c '        sh -c '
4912          set -e;          set -e;
4913          _psfile="${_modefile}.ps";          _psfile="${md_modefile}.ps";
4914          _modefile="${_modefile}.pdf";          md_modefile="${md_modefile}.pdf";
4915          test -f "${_psfile}" && rm -f "${_psfile}";          test -f "${_psfile}" && rm -f "${_psfile}";
4916          test -f "${_modefile}" && rm -f "${_modefile}";          test -f "${md_modefile}" && rm -f "${md_modefile}";
4917          cat "${_TMP_CAT}" | \          cat "${_TMP_CAT}" | \
4918            eval "${_groggy}" "${_ADDOPTS_GROFF}" > "${_psfile}";            eval "${md_groggy}" "${_ADDOPTS_GROFF}" > "${_psfile}";
4919          gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \          gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
4920             -sOutputFile="${_modefile}" -c save pop -f "${_psfile}";             -sOutputFile="${md_modefile}" -c save pop -f "${_psfile}";
4921          test -f "${_psfile}" && rm -f "${_psfile}";          test -f "${_psfile}" && rm -f "${_psfile}";
4922          test -f "${_TMP_CAT}" && rm -f "${_TMP_CAT}";          test -f "${_TMP_CAT}" && rm -f "${_TMP_CAT}";
4923          (          (
4924            clean_up() {            clean_up() {
4925              rm -f "${_modefile}";              rm -f "${md_modefile}";
4926              if test -d "${_TMP_DIR}";              if test -d "${_TMP_DIR}";
4927              then              then
4928                rm -f "${_TMP_DIR}"/* || true;                rm -f "${_TMP_DIR}"/* || true;
# Line 4747  main_display() Line 4930  main_display()
4930              fi;              fi;
4931            }            }
4932            trap clean_up 0 2>${_NULL_DEV} || true;            trap clean_up 0 2>${_NULL_DEV} || true;
4933            eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${_modefile}";            eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${md_modefile}";
4934          ) &'          ) &'
4935        ;;        ;;
4936      ps)      ps)
# Line 4756  main_display() Line 4939  main_display()
4939            do_nothing;            do_nothing;
4940            ;;            ;;
4941          *)          *)
4942            warning \            warning "main_display(): \
4943              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4944            ;;            ;;
4945        esac;        esac;
4946        _modefile="${_modefile}".ps;        md_modefile="${md_modefile}".ps;
4947        _groggy="$(tmp_cat | grog -Tps)";        md_groggy="$(tmp_cat | grog -Tps)";
4948        _do_display;        _do_display;
4949        ;;        ;;
4950      source)      source)
# Line 4771  main_display() Line 4954  main_display()
4954      x)      x)
4955        case "${_OPT_DEVICE}" in        case "${_OPT_DEVICE}" in
4956          '')          '')
4957            _groggy="$(tmp_cat | grog -Z)";            md_groggy="$(tmp_cat | grog -Z)";
4958            ;;            ;;
4959          X*|ps)          X*|ps)
4960            _groggy="$(tmp_cat | grog -T"${_OPT_DEVICE}" -Z)";            md_groggy="$(tmp_cat | grog -T"${_OPT_DEVICE}" -Z)";
4961            ;;            ;;
4962          *)          *)
4963            warning \            warning "main_display(): \
4964              "wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";  wrong device for ${_DISPLAY_MODE} mode: ${_OPT_DEVICE}";
4965            _groggy="$(tmp_cat | grog -Z)";            md_groggy="$(tmp_cat | grog -Z)";
4966            ;;            ;;
4967        esac;        esac;
4968        _do_display;        _do_display;
4969        ;;        ;;
4970      *)      *)
4971        error "unknown mode \`${_DISPLAY_MODE}'";        error "main_display(): unknown mode \`${_DISPLAY_MODE}'";
4972        ;;        ;;
4973    esac;    esac;
4974      unset md_addopts;
4975      unset md_device;
4976      unset md_groggy;
4977      unset md_modefile;
4978      unset md_options;
4979      unset md_p;
4980      unset md_pager;
4981    eval "${return_ok}";    eval "${return_ok}";
4982  } # main_display()  } # main_display()
4983    
4984    
4985    # $md_modefile and $md_groggy come from main_display()
4986  _do_display()  _do_display()
4987  {  {
4988    func_check _do_display = 0 "$@";    func_check _do_display = 0 "$@";
# Line 4799  _do_display() Line 4991  _do_display()
4991    # cleaning-up of the temporary files.    # cleaning-up of the temporary files.
4992    sh -c '    sh -c '
4993      set -e;      set -e;
4994      test -f "${_modefile}" && rm -f "${_modefile}";      test -f "${md_modefile}" && rm -f "${md_modefile}";
4995      cat "${_TMP_CAT}" | \      cat "${_TMP_CAT}" | \
4996        eval "${_groggy}" "${_ADDOPTS_GROFF}" > "${_modefile}";        eval "${md_groggy}" "${_ADDOPTS_GROFF}" > "${md_modefile}";
4997      rm -f "${_TMP_CAT}";      rm -f "${_TMP_CAT}";
4998      (      (
4999        clean_up() {        clean_up() {
# Line 4812  _do_display() Line 5004  _do_display()
5004          fi;          fi;
5005        }        }
5006        trap clean_up 0 2>${_NULL_DEV} || true;        trap clean_up 0 2>${_NULL_DEV} || true;
5007        eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${_modefile}";        eval "${_DISPLAY_PROG}" ${_DISPLAY_ARGS} "${md_modefile}";
5008      ) &'      ) &'
5009  }  }
5010    

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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