home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / less3 / part01 next >
Encoding:
Internet Message Format  |  1986-12-04  |  58.4 KB

  1. Subject:  v07i082:  New release of LESS, Part01/03
  2. Newsgroups: mod.sources
  3. Approved: mirror!rs
  4.  
  5. Submitted by: rgb@nscpdc.uucp (Robert Bond)
  6. Mod.sources: Volume 7, Issue 82
  7. Archive-name: less3/Part01
  8.  
  9. [  A new version, from the original author.  To paraphrase Mark Twain,
  10.    rumors of his demise are greatly exxagerated.  --r$ ]
  11.  
  12. This is the latest version of my paginator, "less".  It is now
  13. distributed in three parts.  The changes are summarized below.  Thanks
  14. to Casey Leedom for the very nice additions recently posted to the
  15. net.
  16.  
  17. P.S. Apologies to anyone who has tried to reach me during the past nine
  18. months.  I have been off the net.  I still am not receiving netnews, so
  19. if you have any comments, suggestions, etc. which you wish me to see,
  20. please MAIL to me at:
  21.     tektronix!nscpdc!convgt!mark
  22.   or    ihnp4!nsc!nscpdc!convgt!mark
  23.  
  24.     Mark Nudelman
  25.     Convergent Technologies
  26.  
  27.  Summary of changes to this version of less:
  28.  
  29. 1. Incorporated Casey Leedom's changes for boldface handling and addition
  30.     of -z option.
  31. 2. New -l option to log input to a file.
  32. 3. E command now expands shell metacharacters in the filename.
  33. 4. Single quote command may now be followed by another single quote, as in vi.
  34. 5. New + command, similar to + command line option.
  35. 6. g command when beginning of file is lost will now go back as far as
  36.     possible, rather than just printing an error message.
  37. 7. New -P option for finer control over the prompt messages.
  38. 8. New mechanism for help.
  39. 9. The usual minor bug fixes and prettying up.
  40.  
  41.  ---- cut here ---- cut here ---- cut here ---- cut here ---- cut here ----
  42. : This is a shell archive.
  43. : Unpack by running /bin/sh.
  44. echo README
  45. cat >README <<'_SHAR_EOF_'
  46. This is the distribution of "less", a paginator similar to "more" or "pg".
  47. The manual page is in less.man (nroff source in less.nro).
  48.  
  49. INSTALLATION:
  50.  
  51. 1. Move the distributed source to its own directory and 
  52.    unpack it by running "sh" on the distribution file,
  53.    if you have not already done so.
  54.  
  55. 2. Type "install" and answer the questions it asks.
  56.    This will generate a makefile.
  57.  
  58.    If you choose not to include some features in your version,
  59.    you may wish to edit the manual page less.nro and/or less.man
  60.    to remove the references to the appropriate commands or options.
  61.  
  62.    (NOTE: there are some pre-generated makefiles for
  63.     various systems, named makefile.sys5, makefile.bsd41,
  64.     etc. which may be used if you wish.)
  65.  
  66. 3. It is a good idea to look over the generated makefile 
  67.    and make sure it looks ok.
  68.  
  69. 4. Type "make" and watch the fun.
  70.  
  71. 5. If the make succeeds, it will generate a program "less"
  72.    in your current directory.  Test the generated program.
  73.  
  74. 6. When satisfied that it works, if you wish to install it
  75.    in a public place, type "make install".
  76.  
  77. If you have any problems building or running "less", 
  78. suggestions, complaints, etc., you may mail to the 
  79. author via USENET at:
  80.     tektronix!nscpdc!convgt!mark
  81.   or    ihnp4!nsc!nscpdc!convgt!mark
  82.  
  83. Note to hackers: comments noting possible improvements are enclosed
  84. in double curly brackets {{ like this }}.
  85. _SHAR_EOF_
  86.  
  87. echo install
  88. cat >install <<'_SHAR_EOF_'
  89. :
  90. # Installation script for less.
  91. # This script prompts the operator for various information
  92. # and constructs a makefile.
  93.  
  94. echo "This script will build a makefile for less."
  95. echo "If you already have a file called \"makefile\" it will be overwritten."
  96. echo "Press RETURN to continue."
  97. read ans
  98.  
  99. echo "I will ask you some questions about your system."
  100. echo "If you do not know the answer to any question,"
  101. echo "just press RETURN and I will choose a default for you."
  102. echo "Press RETURN now."
  103. read ans
  104.  
  105. echo "Most Unix systems are derived from either System V"
  106. echo "or Berkeley BSD 4.1, 4.2, 4.3, etc."
  107. echo ""
  108. echo "Is your system closest to:"
  109. echo "  1. System V"
  110. echo "  2. BSD 4.1"
  111. echo "  3. BSD 4.2 or later"
  112. echo "  4. Xenix"
  113. echo "Enter a number, or just RETURN if you don't know: \c"
  114. read ans
  115. xenix=0
  116. case "X$ans" in
  117. X1) sys=sys5; sysname="System V" ;;
  118. X2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
  119. X3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
  120. X4) sys=sys5; xenix=1; sysname="Xenix" ;;
  121. *) sys=unknown ;;
  122. esac
  123. echo ""
  124.  
  125. cat >makefile <<"EOF"
  126. # Makefile for "less"
  127. #
  128. # Invoked as:
  129. #    make all
  130. #   or    make install
  131. # Plain "make" is equivalent to "make all".
  132. #
  133. # If you add or delete functions, remake funcs.h by doing:
  134. #    make newfuncs
  135. # This depends on the coding convention of function headers looking like:
  136. #    " \t public <function-type> \n <function-name> ( ... ) "
  137. #
  138. # Also provided:
  139. #    make lint    # Runs "lint" on all the sources.
  140. #    make clean    # Removes "less" and the .o files.
  141. #    make clobber    # Pretty much the same as make "clean".
  142.  
  143.  
  144. ##########################################################################
  145. # System-specific parameters
  146. ##########################################################################
  147.  
  148. EOF
  149.  
  150. cat >>makefile <<EOF
  151. # Define XENIX if running under XENIX 3.0
  152. XENIX = $xenix
  153.  
  154. EOF
  155. echo ""
  156.  
  157.  
  158.  
  159. if [ "X$sys" = "Xunknown" ]
  160. then
  161.     alldefault=0
  162. else
  163.     def=yes
  164.     alldefault=1
  165.     echo "Do you want to use ALL the defaults for $sysname?"
  166.     echo "  Enter \"yes\" if you have a STANDARD $sysname."
  167.     echo "  Enter \"no\" if you want to change any of the defaults. [$def] \c"
  168.     read ans
  169.     case "X$ans" in
  170.     X[yY]*) alldefault=1 ;;
  171.     X[nN]*) alldefault=0 ;;
  172.     esac
  173.     echo ""
  174. fi
  175.  
  176.  
  177.  
  178. def=yes
  179. x=1
  180. if [ $alldefault = 0 ]
  181. then
  182.     echo "Does your C compiler support the \"void\" type? [$def] \c"
  183.     read ans
  184.     case "X$ans" in
  185.     X[yY]*) x=1 ;;
  186.     X[nN]*) x=0 ;;
  187.     esac
  188.     echo ""
  189. fi
  190. cat >>makefile <<EOF
  191. # VOID is 1 if your C compiler supports the "void" type,
  192. # 0 if it does not.
  193. VOID = $x
  194.  
  195. EOF
  196.  
  197.  
  198.  
  199. def=long
  200. if [ $alldefault = 0 ]
  201. then
  202.     echo "What type is the \"offset\" argument to lseek? [$def] \c"
  203.     read ans
  204.     if [ "X$ans" != "X" ]
  205.     then
  206.         def=$ans
  207.     fi
  208.     echo ""
  209. fi
  210. cat >>makefile <<EOF
  211. # off_t is the type which lseek() returns.
  212. # It is also the type of lseek()'s second argument.
  213. off_t = $def
  214.  
  215. EOF
  216.  
  217.  
  218.  
  219.  
  220. if [ "$sys" = "bsd" ]
  221. then
  222.     def=no; x=0
  223. else
  224.     def=yes; x=1
  225. fi
  226. if [ $alldefault = 0 ]
  227. then
  228.     echo "Most System V systems have termio.h, while most"
  229.     echo "Berkeley-derived systems have sgtty.h."
  230.     echo "Does your system have termio.h? [$def] \c"
  231.     read ans
  232.     case "X$ans" in
  233.     X[yY]*) x=1 ;;
  234.     X[nN]*) x=0 ;;
  235.     esac
  236.     echo ""
  237. fi
  238. cat >>makefile <<EOF
  239. # TERMIO is 1 if your system has /usr/include/termio.h.
  240. # This is normally the case for System 5.
  241. # If TERMIO is 0 your system must have /usr/include/sgtty.h.
  242. # This is normally the case for BSD.
  243. TERMIO = $x
  244.  
  245. EOF
  246.  
  247.  
  248.  
  249.  
  250. if [ "$sys" = "bsd" -a "$bsd41" = "0" ]
  251. then
  252.     def=yes; x=1
  253. else
  254.     def=no; x=0
  255. fi
  256. if [ $alldefault = 0 ]
  257. then
  258.     echo "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
  259.     echo "Most System V and BSD 4.1 systems do not."
  260.     echo "Does your system have sigsetmask()? [$def] \c"
  261.     read ans
  262.     case "X$ans" in
  263.     X[yY]*) x=1 ;;
  264.     X[nN]*) x=0 ;;
  265.     esac
  266.     echo ""
  267. fi
  268. cat >>makefile <<EOF
  269. # SIGSETMASK is 1 if your system has the sigsetmask() call.
  270. # This is normally the case only for BSD 4.2,
  271. # not for BSD 4.1 or System 5.
  272. SIGSETMASK = $x
  273.  
  274. EOF
  275.  
  276. cat >>makefile <<EOF
  277. ##########################################################################
  278. # Optional and semi-optional features
  279. ##########################################################################
  280.  
  281. EOF
  282.  
  283.  
  284.  
  285.  
  286. if [ "$sys" = "bsd" ]
  287. then
  288.     def=2; REGCMP=0;RECOMP=1
  289. else
  290.     def=1; REGCMP=1;RECOMP=0
  291. fi
  292. if [ $alldefault = 0 ]
  293. then
  294.     echo "Most System V systems have the regcmp() function."
  295.     echo "Most Berkeley-derived systems have the re_comp() function."
  296.     echo "Does your system have:"
  297.     echo "  1. regcmp"
  298.     echo "  2. re_comp"
  299.     echo "  3. neither   [$def] \c"
  300.     read ans
  301.     case "X$ans" in
  302.     X1) REGCMP=1;RECOMP=0 ;;
  303.     X2) REGCMP=0;RECOMP=1 ;;
  304.     X3) REGCMP=0;RECOMP=0 ;;
  305.     esac
  306.     echo ""
  307. fi
  308. cat >>makefile <<EOF
  309. # REGCMP is 1 if your system has the regcmp() function.
  310. # This is normally the case for System 5.
  311. # RECOMP is 1 if your system has the re_comp() function.
  312. # This is normally the case for BSD.
  313. # If neither is 1, pattern matching is supported, but without metacharacters.
  314. REGCMP = $REGCMP
  315. RECOMP = $RECOMP
  316.  
  317. EOF
  318.  
  319.  
  320.  
  321.  
  322. def=yes
  323. x=1
  324. if [ $alldefault = 0 ]
  325. then
  326.     echo "Do you wish to allow shell escapes? [$def] \c"
  327.     read ans
  328.     case "X$ans" in
  329.     X[yY]*) x=1 ;;
  330.     X[nN]*) x=0 ;;
  331.     esac
  332.     echo ""
  333. fi
  334. cat >>makefile <<EOF
  335. # SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  336. # (This is possible only if your system supplies the system() function.)
  337. SHELL_ESCAPE = $x
  338.  
  339. EOF
  340.  
  341.  
  342.  
  343. def=yes
  344. x=1
  345. edname="vi"
  346. if [ $alldefault = 0 ]
  347. then
  348.     echo "Do you wish to allow editor escapes? [$def] \c"
  349.     read ans
  350.     case "X$ans" in
  351.     X[nN]*) x=0; edname="" ;;
  352.     X[yY]*) x=1
  353.         echo "What is the pathname of the default editor? [$edname] \c"
  354.         read ans 
  355.         if [ "x$ans" != "x" ]
  356.         then
  357.             edname=$ans
  358.         fi
  359.         ;;
  360.     esac
  361.     echo ""
  362. fi
  363. cat >>makefile <<EOF
  364. # EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  365. # (This is possible only if your system supplies the system() function.)
  366. # EDIT_PGM is the name of the (default) editor to be invoked.
  367. EDITOR = $x
  368. EDIT_PGM = $edname
  369.  
  370. EOF
  371.  
  372.  
  373.  
  374. def=yes
  375. x=1
  376. if [ $alldefault = 0 ]
  377. then
  378.     echo "If your system provides the popen() function and"
  379.     echo "the \"echo\" shell command, you may allow shell metacharacters" 
  380.     echo "to be expanded in filenames."
  381.     echo "Do you wish to allow shell metacharacters in filenames? [$def] \c"
  382.     read ans
  383.     case "X$ans" in
  384.     X[yY]*) x=1 ;;
  385.     X[nN]*) x=0 ;;
  386.     esac
  387.     echo ""
  388. fi
  389. cat >>makefile <<EOF
  390. # GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  391. # This will generally work if your system provides the "popen" function
  392. # and the "echo" shell command.
  393. GLOB = $x
  394.  
  395. EOF
  396.  
  397.  
  398.  
  399. def=yes
  400. x=1
  401. if [ $alldefault = 0 ]
  402. then
  403.     echo "Do you wish to allow log files (-l option)? [$def] \c"
  404.     read ans
  405.     case "X$ans" in
  406.     X[yY]*) x=1 ;;
  407.     X[nN]*) x=0 ;;
  408.     esac
  409.     echo ""
  410. fi
  411. cat >>makefile <<EOF
  412. # LOGFILE is 1 if you wish to allow the -l option (to create log files).
  413. LOGFILE = $x
  414.  
  415. EOF
  416.  
  417. cat >>makefile <<EOF
  418. # ONLY_RETURN is 1 if you want RETURN to be the only input which
  419. # will continue past an error message.
  420. # Otherwise, any key will continue past an error message.
  421. ONLY_RETURN = 0
  422.  
  423.  
  424. ##########################################################################
  425. # Compilation environment.
  426. ##########################################################################
  427.  
  428. EOF
  429.  
  430.  
  431.  
  432. if [ "$xenix" = "1" ]
  433. then
  434.     LIBS="-ltermlib"
  435. elif [ "$sys" = "bsd" ]
  436. then
  437.     LIBS="-ltermcap"
  438. else
  439.     LIBS="-lcurses -ltermcap -lPW"
  440. fi
  441. if [ $alldefault = 0 ]
  442. then
  443.     echo "To build \"less\", you must link with libraries supplied by your system."
  444.     echo "(If this needs to be changed later, edit the makefile"
  445.     echo "and change the definition of LIBS.)"
  446.     echo "What libraries should be used [$LIBS] \c"
  447.     read ans
  448.     if [ "X$ans" != "X" ]
  449.     then
  450.         LIBS="$ans"
  451.     fi
  452.     echo ""
  453. fi
  454. cat >>makefile <<EOF
  455. # LIBS is the list of libraries needed.
  456. LIBS = $LIBS
  457.  
  458. EOF
  459.  
  460.  
  461.  
  462. INSTALL_LESS="/usr/local/bin/less"
  463. INSTALL_HELP="/usr/local/bin/less.help"
  464. INSTALL_MAN="/usr/man/man1/less.1"
  465. MANUAL="less.nro"
  466. if [ $alldefault = 0 ]
  467. then
  468.     echo "What is the name of the \"public\" (installed) version of less?"
  469.     echo " [$INSTALL_LESS] \c"
  470.     read ans
  471.     if [ "X$ans" != "X" ]
  472.     then
  473.         INSTALL_LESS="$ans"
  474.     fi
  475.     echo "What is the name of the \"public\" (installed) version of the help file?"
  476.     echo " [$INSTALL_HELP] \c"
  477.     read ans
  478.     if [ "X$ans" != "X" ]
  479.     then
  480.         INSTALL_HELP="$ans"
  481.     fi
  482.     echo "What is the name of the \"public\" (installed) version of the manual page?"
  483.     echo " [$INSTALL_MAN] \c"
  484.     read ans
  485.     if [ "X$ans" != "X" ]
  486.     then
  487.         INSTALL_MAN="$ans"
  488.     fi
  489.     echo ""
  490. fi
  491. cat >>makefile <<EOF
  492. # INSTALL_LESS is a list of the public versions of less.
  493. # INSTALL_HELP is a list of the public version of the help file.
  494. # INSTALL_MAN is a list of the public versions of the manual page.
  495. INSTALL_LESS =    $INSTALL_LESS
  496. INSTALL_HELP =    $INSTALL_HELP
  497. INSTALL_MAN =    $INSTALL_MAN
  498. MANUAL =    $MANUAL
  499. HELPFILE =    $INSTALL_HELP
  500.  
  501.  
  502. EOF
  503.  
  504.  
  505.  
  506. cat >>makefile <<"EOF"
  507. # OPTIM is passed to the compiler and the loader.
  508. # It is normally "-O" but may be, for example, "-g".
  509. OPTIM = -O
  510.  
  511.  
  512. ##########################################################################
  513. # Files
  514. ##########################################################################
  515.  
  516. SRC1 =    main.c option.c prim.c ch.c position.c input.c output.c 
  517. SRC2 =    screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
  518. SRC =    $(SRC1) $(SRC2)
  519. OBJ =    main.o option.o prim.o ch.o position.o input.o output.o screen.o \
  520.     prompt.o line.o signal.o help.o ttyin.o command.o version.o
  521.  
  522.  
  523. ##########################################################################
  524. # Rules
  525. ##########################################################################
  526.  
  527. DEFS =    "-DTERMIO=$(TERMIO)" \
  528.     "-DSIGSETMASK=$(SIGSETMASK)" \
  529.     "-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
  530.     "-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
  531.     "-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
  532.     "-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
  533.     "-DHELPFILE=\"$(HELPFILE)\"" \
  534.     "-DLOGFILE=$(LOGFILE)" \
  535.     "-DONLY_RETURN=$(ONLY_RETURN)" \
  536.     "-DGLOB=$(GLOB)" \
  537.     "-DXENIX=$(XENIX)"
  538.  
  539. CFLAGS = $(OPTIM) $(DEFS)
  540.  
  541.  
  542. all: less
  543.  
  544. less: $(OBJ)
  545.     cc $(OPTIM) -o less $(OBJ) $(LIBS)
  546.  
  547. install: install_man install_less install_help
  548.  
  549. install_less: less
  550.     for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  551.     touch install_less
  552.  
  553. install_help: less.help
  554.     for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  555.     touch install_help
  556.  
  557. install_man: $(MANUAL)
  558.     for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
  559.     touch install_man
  560.  
  561. $(OBJ): less.h funcs.h
  562.  
  563. # help.o depends on makefile for the definition of HELPFILE.
  564. help.o: makefile
  565.  
  566. lint:
  567.     lint -hp $(DEFS) $(SRC)
  568.  
  569. newfuncs:
  570.     mv funcs.h funcs.h.OLD
  571.     awk -f mkfuncs.awk $(SRC) >funcs.h
  572.  
  573. clean:
  574.     rm -f $(OBJ) less
  575.  
  576. clobber:
  577.     rm -f *.o less install_less install_man
  578.  
  579. shar:
  580.     shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
  581.     shar -v less.nro $(SRC1) > less.shar.b
  582.     shar -v $(SRC2) > less.shar.c
  583. EOF
  584. echo ""
  585.  
  586. echo "The makefile has been built."
  587. echo "You should check it to make sure everything is as you want it to be."
  588. echo "When you are satisfied with the makefile, just type \"make\""
  589. echo "and \"less\" will be built."
  590. _SHAR_EOF_
  591.  
  592. echo less.man
  593. cat >less.man <<'_SHAR_EOF_'
  594.  
  595.  
  596.  
  597.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  598.  
  599.  
  600.  
  601.      NNNNAAAAMMMMEEEE
  602.           less - opposite of more
  603.  
  604.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  605.           lllleeeessssssss [[[[----ccccddddeeeeppppssssttttwwwwmmmmMMMMqqqqQQQQuuuuUUUU]]]] [[[[----hhhh_N]]]] [[[[----bbbb[[[[ffffpppp]]]]_N]]]] [[[[--
  606.  
  607.  
  608.  
  609.  
  610.  
  611. --xxxx_N]]]] [[[[----[[[[zzzz]]]]_N]]]]
  612.                [[[[----PPPP[[[[mmmmMMMM]]]]_s_t_r_i_n_g]]]] [[[[----llll_l_o_g_f_i_l_e]]]] [[[[++++_c_m_d]]]]  [[[[_f_i_l_e_n_a_m_e]]]]............
  613.  
  614.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  615.           _L_e_s_s is a program similar to _m_o_r_e (1), but which allows
  616.           backwards movement in the file as well as forward movement.
  617.           Also, _l_e_s_s does not have to read the entire input file
  618.           before starting, so with large input files it starts up
  619.           faster than text editors like _v_i (1).  _L_e_s_s uses termcap, so
  620.           it can run on a variety of terminals.  There is even limited
  621.           support for hardcopy terminals.  (On a hardcopy terminal,
  622.           lines which should be printed at the top of the screen are
  623.           prefixed with an up-arrow.)
  624.  
  625.           Commands are based on both _m_o_r_e and _v_i. Commands may be
  626.           preceeded by a decimal number, called N in the descriptions
  627.           below.  The number is used by some commands, as indicated.
  628.  
  629.  
  630.      CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
  631.           In the following descriptions, ^X means control-X.
  632.  
  633.           h    Help: display a summary of these commands.  If you
  634.                forget all the other commands, remember this one.
  635.  
  636.           SPACE
  637.                Scroll forward N lines, default one window (see option
  638.                -z below).  If N is more than the screen size, only the
  639.                final screenful is displayed.
  640.  
  641.           f or ^F
  642.                Same as SPACE.
  643.  
  644.           b or ^B
  645.                Scroll backward N lines, default one window (see option
  646.                -z below).  If N is more than the screen size, only the
  647.                final screenful is displayed.
  648.  
  649.           RETURN
  650.                Scroll forward N lines, default 1.  The entire N lines
  651.                are displayed, even if N is more than the screen size.
  652.  
  653.           e or ^E
  654.                Same as RETURN.
  655.  
  656.           j or ^J
  657.                Also the same as RETURN.
  658.  
  659.  
  660.  
  661.  
  662.      Page 1                                          (printed 9/30/86)
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  670.  
  671.  
  672.  
  673.           y or ^Y
  674.                Scroll backward N lines, default 1.  The entire N lines
  675.                are displayed, even if N is more than the screen size.
  676.  
  677.           k or ^K
  678.                Same as y.
  679.  
  680.           d or ^D
  681.                Scroll forward N lines, default 10.  If N is specified,
  682.                it becomes the new default for subsequent d and u
  683.                commands.
  684.  
  685.           u or ^U
  686.                Scroll backward N lines, default 10.  If N is
  687.                specified, it becomes the new default for subsequent d
  688.                and u commands.
  689.  
  690.           r or ^R or ^L
  691.                Repaint the screen.
  692.  
  693.           R    Repaint the screen, discarding any buffered input.
  694.                Useful if the file is changing while it is being
  695.                viewed.
  696.  
  697.           g    Go to line N in the file, default 1 (beginning of
  698.                file).  (Warning: this may be slow if N is large.)
  699.  
  700.           G    Go to line N in the file, default the end of the file.
  701.                (Warning: this may be slow if standard input, rather
  702.                than a file, is being read.)
  703.  
  704.           p    Go to a position N percent into the file.  N should be
  705.                between 0 and 100.  (This is possible if standard input
  706.                is being read, but only if _l_e_s_s has already read to the
  707.                end of the file.  It is always fast, but not always
  708.                useful.)
  709.  
  710.           %    Same as p.
  711.  
  712.           m    Followed by any lowercase letter, marks the current
  713.                position with that letter.
  714.  
  715.           '    (Single quote.) Followed by any lowercase letter,
  716.                returns to the position which was previously marked
  717.                with that letter.  Followed by another single quote,
  718.                returns to the postion at which the last "large"
  719.                movement command was executed.  All marks are lost when
  720.                a new file is examined.
  721.  
  722.           /pattern
  723.                Search forward in the file for the N-th line containing
  724.                the pattern.  N defaults to 1.  The pattern is a
  725.  
  726.  
  727.  
  728.      Page 2                                          (printed 9/30/86)
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  736.  
  737.  
  738.  
  739.                regular expression, as recognized by _e_d. The search
  740.                starts at the second line displayed (but see the -t
  741.                option, which changes this).
  742.  
  743.           ?pattern
  744.                Search backward in the file for the N-th line
  745.                containing the pattern.  The search starts at the line
  746.                immediately before the top line displayed.
  747.  
  748.           n    Repeat previous search, for N-th line containing the
  749.                last pattern.
  750.  
  751.           E    Examine a new file.  If the filename is missing, the
  752.                "current" file (see the N and P commands below) from
  753.                the list of files in the command line is re-examined.
  754.  
  755.           N    Examine the next file (from the list of files given in
  756.                the command line).  If a number N is specified (not to
  757.                be confused with the command N), the N-th next file is
  758.                examined.
  759.  
  760.           P    Examine the previous file.  If a number N is specified,
  761.                the N-th previous file is examined.
  762.  
  763.           = or ^G
  764.                Prints some information about the file being viewed,
  765.                including its name and the byte offset of the bottom
  766.                line being displayed.  If possible, it also prints the
  767.                length of the file and the percent of the file above
  768.                the last displayed line.
  769.  
  770.           -    Followed by one of the command line option letters (see
  771.                below), this will toggle the setting of that option and
  772.                print a message describing the new setting.
  773.  
  774.           +cmd Causes the specified cmd to be executed each time a new
  775.                file is examined.  For example, +G causes _l_e_s_s to
  776.                initially display each file starting at the end rather
  777.                than the beginning.
  778.  
  779.           V    Prints the version number of _l_e_s_s being run.
  780.  
  781.           q    Exits _l_e_s_s.
  782.  
  783.           The following two commands may or may not be valid,
  784.           depending on your particular installation.
  785.  
  786.           v    Invokes an editor to edit the current file being
  787.                viewed.  The editor is taken from the environment
  788.                variable EDITOR, or defaults to "vi".
  789.  
  790.           ! shell-command
  791.  
  792.  
  793.  
  794.      Page 3                                          (printed 9/30/86)
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  802.  
  803.  
  804.  
  805.                Invokes a shell to run the shell-command given.
  806.  
  807.      OOOOPPPPTTTTIIIIOOOONNNNSSSS
  808.           Command line options are described below.  Most options may
  809.           be changed while _l_e_s_s is running, via the "-" command.
  810.  
  811.           Options are also taken from the environment variable "LESS".
  812.           For example, if you like more-style prompting, to avoid
  813.           typing "less -m ..." each time _l_e_s_s is invoked, you might
  814.           tell _c_s_h:
  815.  
  816.           setenv LESS m
  817.  
  818.           or if you use _s_h:
  819.  
  820.           LESS=m; export LESS
  821.  
  822.           The environment variable is parsed before the command line,
  823.           so command line options override the LESS environment
  824.           variable.  A dollar sign ($) may be used to signal the end
  825.           of an option string.  This is important only for options
  826.           like -P which take a following string.
  827.  
  828.           -s   The -s option causes consecutive blank lines to be
  829.                squeezed into a single blank line.  This is useful when
  830.                viewing _n_r_o_f_f output.
  831.  
  832.           -t   Normally, forward searches start just after the top
  833.                displayed line (that is, at the second displayed line).
  834.                Thus forward searches include the currently displayed
  835.                screen.  The -t option causes forward searches to start
  836.                just after the bottom line displayed, thus skipping the
  837.                currently displayed screen.
  838.  
  839.           -m   Normally, _l_e_s_s prompts with a colon.  The -m option
  840.                causes _l_e_s_s to prompt verbosely (like _m_o_r_e), with the
  841.                percent into the file.
  842.  
  843.           -M   The -M option causes _l_e_s_s to prompt even more verbosely
  844.                than _m_o_r_e.
  845.  
  846.           -P   The -P option provides a way to tailor the three prompt
  847.                styles to your own preference.  You would normally put
  848.                this option in your LESS environment variable, rather
  849.                than type it in with each less command.  Such an option
  850.                must either be the last option in the LESS variable, or
  851.                be terminated by a dollar sign.  -P followed by a
  852.                string changes the default (short) prompt to that
  853.                string.  -Pm changes the medium (-m) prompt to the
  854.                string, and -PM changes the long (-M) prompt.  The
  855.                string consists of a sequence of letters which are
  856.                replaced with certain predefined strings, as follows:
  857.  
  858.  
  859.  
  860.      Page 4                                          (printed 9/30/86)
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  868.  
  869.  
  870.  
  871.                     F    file name
  872.                     f    file name, only once
  873.                     O    file n of n
  874.                     o    file n of n, only once
  875.                     b    byte offset
  876.                     p    percent into file
  877.                     P    percent if known, else byte offset
  878.                Angle brackets, < and >, may be used to surround a
  879.                literal string to be included in the prompt.  The
  880.                defaults are "fo" for the short prompt, "foP" for the
  881.                medium prompt, and "Fobp" for the long prompt.
  882.                Example: Setting your LESS variable to "PmFOP$PMFObp"
  883.                would change the medium and long prompts to always
  884.                include the file name and "file n of n" message.
  885.                Another example: Setting your LESS variable to
  886.                "mPm<--Less-->FoPe" would change the medium prompt to
  887.                the string "--Less--" followed by the file name and
  888.                percent into the file.  It also selects the medium
  889.                prompt as the default prompt (because of the first
  890.                "m").
  891.  
  892.           -q   Normally, if an attempt is made to scroll past the end
  893.                of the file or before the beginning of the file, the
  894.                terminal bell is rung to indicate this fact.  The -q
  895.                option tells _l_e_s_s not to ring the bell at such times.
  896.                If the terminal has a "visual bell", it is used
  897.                instead.
  898.  
  899.           -Q   Even if -q is given, _l_e_s_s will ring the bell on certain
  900.                other errors, such as typing an invalid character.  The
  901.                -Q option tells _l_e_s_s to be quiet all the time; that is,
  902.                never ring the terminal bell.  If the terminal has a
  903.                "visual bell", it is used instead.
  904.  
  905.           -e   Normally the only way to exit less is via the "q"
  906.                command.  The -e option tells less to automatically
  907.                exit the second time it reaches end-of-file.
  908.  
  909.           -u   If the -u option is given, backspaces are treated as
  910.                printable characters; that is, they are sent to the
  911.                terminal when they appear in the input.
  912.  
  913.           -U   If the -U option is given, backspaces are printed as
  914.                the two character sequence "^H".
  915.  
  916.                If neither -u nor -U is given, backspaces which appear
  917.                adjacent to an underscore character are treated
  918.                specially: the underlined text is displayed using the
  919.                terminal's hardware underlining capability.  Also,
  920.                backspaces which appear between two identical
  921.                characters are treated specially: the overstruck text
  922.                is printed using the terminal's hardware boldface
  923.  
  924.  
  925.  
  926.      Page 5                                          (printed 9/30/86)
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  934.  
  935.  
  936.  
  937.                capability.  Other backspaces are deleted, along with
  938.                the preceeding character.
  939.  
  940.           -w   Normally, _l_e_s_s uses a tilde character to represent
  941.                lines past the end of the file.  The -w option causes
  942.                blank lines to be used instead.
  943.  
  944.           -d   Normally, _l_e_s_s will complain if the terminal is dumb;
  945.                that is, lacks some important capability, such as the
  946.                ability to clear the screen or scroll backwards.  The
  947.                -d option suppresses this complaint (but does not
  948.                otherwise change the behavior of the program on a dumb
  949.                terminal).
  950.  
  951.           -p   Normally, _l_e_s_s will repaint the screen by scrolling
  952.                from the bottom of the screen.  If the -p option is
  953.                set, when _l_e_s_s needs to change the entire display, it
  954.                will clear the screen and paint from the top line down.
  955.  
  956.           -h   Normally, _l_e_s_s will scroll backwards when backwards
  957.                movement is necessary.  The -h option specifies a
  958.                maximum number of lines to scroll backwards.  If it is
  959.                necessary to move backwards more than this many lines,
  960.                the screen is repainted in a forward direction.  (If
  961.                the terminal does not have the ability to scroll
  962.                backwards, -h0 is implied.)
  963.  
  964.           -[z] When given a backwards or forwards window command, _l_e_s_s
  965.                will by default scroll backwards or forwards one
  966.                screenful of lines. The -z_n option changes the default
  967.                scrolling window size to _n lines.  If _n is greater than
  968.                the screen size, the scrolling window size will be set
  969.                to one screenful. Note that the "z" is optional for
  970.                compatibility with _m_o_r_e.
  971.  
  972.           -x   The -x_n option sets tab stops every _n positions.  The
  973.                default for _n is 8.
  974.  
  975.           -l   The -l option, followed immediately by a filename, will
  976.                cause _l_e_s_s to copy its input to the named file as it is
  977.                being viewed.  This applies only when the input file is
  978.                a pipe, not an ordinary file.
  979.  
  980.           -b   The -b_n option tells _l_e_s_s to use a non-standard buffer
  981.                size.  There are two standard (default) buffer sizes,
  982.                one is used when a file is being read and the other
  983.                when a pipe (standard input) is being read.  The
  984.                current defaults are 5 buffers for files and 12 for
  985.                pipes.  (Buffers are 1024 bytes.) The number _n
  986.                specifies a different number of buffers to use.  The -b
  987.                may be followed by "f", in which case only the file
  988.                default is changed, or by "p" in which case only the
  989.  
  990.  
  991.  
  992.      Page 6                                          (printed 9/30/86)
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.      LLLLEEEESSSSSSSS((((llll))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((llll))))
  1000.  
  1001.  
  1002.  
  1003.                pipe default is changed.  Otherwise, both are changed.
  1004.  
  1005.           -c   Normally, when data is read by _l_e_s_s, it is scanned to
  1006.                ensure that bit 7 (the high order bit) is turned off in
  1007.                each byte read, and to ensure that there are no null
  1008.                (zero) bytes in the data (null bytes are turned into
  1009.                "@" characters).  If the data is known to be "clean",
  1010.                the -c option will tell _l_e_s_s to skip this checking,
  1011.                causing an imperceptible speed improvement.  (However,
  1012.                if the data is not "clean", unpredicatable results may
  1013.                occur.)
  1014.  
  1015.           +    If a command line option begins with ++++, the remainder
  1016.                of that option is taken to be an initial command to
  1017.                _l_e_s_s. For example, +G tells _l_e_s_s to start at the end of
  1018.                the file rather than the beginning, and +/xyz tells it
  1019.                to start at the first occurence of "xyz" in the file.
  1020.                As a special case, +<number> acts like +<number>g; that
  1021.                is, it starts the display at the specified line number
  1022.                (however, see the caveat under the "g" command above).
  1023.                If the option starts with ++++++++, the initial command
  1024.                applies to every file being viewed, not just the first
  1025.                one.  The + command described previously may also be
  1026.                used to set (or change) an initial command for every
  1027.                file.
  1028.  
  1029.  
  1030.      BBBBUUUUGGGGSSSS
  1031.           When used on standard input (rather than a file), you can
  1032.           move backwards only a finite amount, corresponding to that
  1033.           portion of the file which is still buffered.  The -b option
  1034.           may be used to expand the buffer space.
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.      Page 7                                          (printed 9/30/86)
  1059.  
  1060.  
  1061.  
  1062. _SHAR_EOF_
  1063.  
  1064. echo less.help
  1065. cat >less.help <<'_SHAR_EOF_'
  1066.  
  1067.       Commands marked with * may be preceeded by a number, N.
  1068.  
  1069.   h              Display this help.
  1070.   q              Exit.
  1071.  
  1072.   f, SPACE    *  Forward  N lines, default one screen.
  1073.   b           *  Backward N lines, default one screen.
  1074.   e, j, CR    *  Forward  N lines, default 1 line.
  1075.   y, k        *  Backward N lines, default 1 line.
  1076.   d           *  Forward  N lines, default 10 or last N to d or u command.
  1077.   u           *  Backward N lines, default 10 or last N to d or u command.
  1078.   r              Repaint screen.
  1079.   R              Repaint screen, discarding buffered input.
  1080.  
  1081.   /pattern    *  Search forward for N-th line containing the pattern.
  1082.   ?pattern    *  Search backward for N-th line containing the pattern.
  1083.   n           *  Repeat previous search (for N-th occurence).
  1084.  
  1085.   g           *  Go to line N, default 1.
  1086.   G           *  Like g, but default is last line in file.
  1087.   p, %        *  Position to N percent into the file.
  1088.   m<letter>      Mark the current position with <letter>.
  1089.   '<letter>      Return to a previously marked position.
  1090.   ''             Return to previous position.
  1091.  
  1092.   E [file]       Examine a new file.
  1093.   N           *  Examine the next file (from the command line).
  1094.   P           *  Examine the previous file (from the command line).
  1095.   =              Print current file name.
  1096.   V              Print version number of "less".
  1097.  
  1098.   -<flag>        Toggle a command line flag.
  1099.   +cmd           Execute the less cmd each time a new file is examined.
  1100.  
  1101.   !command       Passes the command to a shell to be executed.
  1102.   v              Edit the current file with $EDITOR.
  1103. _SHAR_EOF_
  1104.  
  1105. echo makefile.bsd41
  1106. cat >makefile.bsd41 <<'_SHAR_EOF_'
  1107. # Makefile for "less"
  1108. #
  1109. # Invoked as:
  1110. #    make all
  1111. #   or    make install
  1112. # Plain "make" is equivalent to "make all".
  1113. #
  1114. # If you add or delete functions, remake funcs.h by doing:
  1115. #    make newfuncs
  1116. # This depends on the coding convention of function headers looking like:
  1117. #    " \t public <function-type> \n <function-name> ( ... ) "
  1118. #
  1119. # Also provided:
  1120. #    make lint    # Runs "lint" on all the sources.
  1121. #    make clean    # Removes "less" and the .o files.
  1122. #    make clobber    # Pretty much the same as make "clean".
  1123.  
  1124.  
  1125. ##########################################################################
  1126. # System-specific parameters
  1127. ##########################################################################
  1128.  
  1129. # Define XENIX if running under XENIX 3.0
  1130. XENIX = 0
  1131.  
  1132. # VOID is 1 if your C compiler supports the "void" type,
  1133. # 0 if it does not.
  1134. VOID = 1
  1135.  
  1136. # off_t is the type which lseek() returns.
  1137. # It is also the type of lseek()'s second argument.
  1138. off_t = long
  1139.  
  1140. # TERMIO is 1 if your system has /usr/include/termio.h.
  1141. # This is normally the case for System 5.
  1142. # If TERMIO is 0 your system must have /usr/include/sgtty.h.
  1143. # This is normally the case for BSD.
  1144. TERMIO = 0
  1145.  
  1146. # SIGSETMASK is 1 if your system has the sigsetmask() call.
  1147. # This is normally the case only for BSD 4.2,
  1148. # not for BSD 4.1 or System 5.
  1149. SIGSETMASK = 0
  1150.  
  1151. ##########################################################################
  1152. # Optional and semi-optional features
  1153. ##########################################################################
  1154.  
  1155. # REGCMP is 1 if your system has the regcmp() function.
  1156. # This is normally the case for System 5.
  1157. # RECOMP is 1 if your system has the re_comp() function.
  1158. # This is normally the case for BSD.
  1159. # If neither is 1, pattern matching is supported, but without metacharacters.
  1160. REGCMP = 0
  1161. RECOMP = 1
  1162.  
  1163. # SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  1164. # (This is possible only if your system supplies the system() function.)
  1165. SHELL_ESCAPE = 1
  1166.  
  1167. # EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  1168. # (This is possible only if your system supplies the system() function.)
  1169. # EDIT_PGM is the name of the (default) editor to be invoked.
  1170. EDITOR = 1
  1171. EDIT_PGM = vi
  1172.  
  1173. # GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  1174. # This will generally work if your system provides the "popen" function
  1175. # and the "echo" shell command.
  1176. GLOB = 1
  1177.  
  1178. # LOGFILE is 1 if you wish to allow the -l option (to create log files).
  1179. LOGFILE = 1
  1180.  
  1181. # ONLY_RETURN is 1 if you want RETURN to be the only input which
  1182. # will continue past an error message.
  1183. # Otherwise, any key will continue past an error message.
  1184. ONLY_RETURN = 0
  1185.  
  1186.  
  1187. ##########################################################################
  1188. # Compilation environment.
  1189. ##########################################################################
  1190.  
  1191. # LIBS is the list of libraries needed.
  1192. LIBS = -ltermcap
  1193.  
  1194. # INSTALL_LESS is a list of the public versions of less.
  1195. # INSTALL_HELP is a list of the public version of the help file.
  1196. # INSTALL_MAN is a list of the public versions of the manual page.
  1197. INSTALL_LESS =    /usr/local/bin/less
  1198. INSTALL_HELP =    /usr/local/bin/less.help
  1199. INSTALL_MAN =    /usr/man/man1/less.1
  1200. MANUAL =    less.nro
  1201. HELPFILE =    /usr/local/bin/less.help
  1202.  
  1203.  
  1204. # OPTIM is passed to the compiler and the loader.
  1205. # It is normally "-O" but may be, for example, "-g".
  1206. OPTIM = -O
  1207.  
  1208.  
  1209. ##########################################################################
  1210. # Files
  1211. ##########################################################################
  1212.  
  1213. SRC1 =    main.c option.c prim.c ch.c position.c input.c output.c 
  1214. SRC2 =    screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
  1215. SRC =    $(SRC1) $(SRC2)
  1216. OBJ =    main.o option.o prim.o ch.o position.o input.o output.o screen.o \
  1217.     prompt.o line.o signal.o help.o ttyin.o command.o version.o
  1218.  
  1219.  
  1220. ##########################################################################
  1221. # Rules
  1222. ##########################################################################
  1223.  
  1224. DEFS =    "-DTERMIO=$(TERMIO)" \
  1225.     "-DSIGSETMASK=$(SIGSETMASK)" \
  1226.     "-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
  1227.     "-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
  1228.     "-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
  1229.     "-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
  1230.     "-DHELPFILE=\"$(HELPFILE)\"" \
  1231.     "-DLOGFILE=$(LOGFILE)" \
  1232.     "-DONLY_RETURN=$(ONLY_RETURN)" \
  1233.     "-DGLOB=$(GLOB)" \
  1234.     "-DXENIX=$(XENIX)"
  1235.  
  1236. CFLAGS = $(OPTIM) $(DEFS)
  1237.  
  1238.  
  1239. all: less
  1240.  
  1241. less: $(OBJ)
  1242.     cc $(OPTIM) -o less $(OBJ) $(LIBS)
  1243.  
  1244. install: install_man install_less install_help
  1245.  
  1246. install_less: less
  1247.     for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  1248.     touch install_less
  1249.  
  1250. install_help: less.help
  1251.     for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  1252.     touch install_help
  1253.  
  1254. install_man: $(MANUAL)
  1255.     for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
  1256.     touch install_man
  1257.  
  1258. $(OBJ): less.h funcs.h
  1259.  
  1260. # help.o depends on makefile for the definition of HELPFILE.
  1261. help.o: makefile
  1262.  
  1263. lint:
  1264.     lint -hp $(DEFS) $(SRC)
  1265.  
  1266. newfuncs:
  1267.     mv funcs.h funcs.h.OLD
  1268.     awk -f mkfuncs.awk $(SRC) >funcs.h
  1269.  
  1270. clean:
  1271.     rm -f $(OBJ) less
  1272.  
  1273. clobber:
  1274.     rm -f *.o less install_less install_man
  1275.  
  1276. shar:
  1277.     shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
  1278.     shar -v less.nro $(SRC1) > less.shar.b
  1279.     shar -v $(SRC2) > less.shar.c
  1280. _SHAR_EOF_
  1281.  
  1282. echo makefile.bsd42
  1283. cat >makefile.bsd42 <<'_SHAR_EOF_'
  1284. # Makefile for "less"
  1285. #
  1286. # Invoked as:
  1287. #    make all
  1288. #   or    make install
  1289. # Plain "make" is equivalent to "make all".
  1290. #
  1291. # If you add or delete functions, remake funcs.h by doing:
  1292. #    make newfuncs
  1293. # This depends on the coding convention of function headers looking like:
  1294. #    " \t public <function-type> \n <function-name> ( ... ) "
  1295. #
  1296. # Also provided:
  1297. #    make lint    # Runs "lint" on all the sources.
  1298. #    make clean    # Removes "less" and the .o files.
  1299. #    make clobber    # Pretty much the same as make "clean".
  1300.  
  1301.  
  1302. ##########################################################################
  1303. # System-specific parameters
  1304. ##########################################################################
  1305.  
  1306. # Define XENIX if running under XENIX 3.0
  1307. XENIX = 0
  1308.  
  1309. # VOID is 1 if your C compiler supports the "void" type,
  1310. # 0 if it does not.
  1311. VOID = 1
  1312.  
  1313. # off_t is the type which lseek() returns.
  1314. # It is also the type of lseek()'s second argument.
  1315. off_t = long
  1316.  
  1317. # TERMIO is 1 if your system has /usr/include/termio.h.
  1318. # This is normally the case for System 5.
  1319. # If TERMIO is 0 your system must have /usr/include/sgtty.h.
  1320. # This is normally the case for BSD.
  1321. TERMIO = 0
  1322.  
  1323. # SIGSETMASK is 1 if your system has the sigsetmask() call.
  1324. # This is normally the case only for BSD 4.2,
  1325. # not for BSD 4.1 or System 5.
  1326. SIGSETMASK = 1
  1327.  
  1328. ##########################################################################
  1329. # Optional and semi-optional features
  1330. ##########################################################################
  1331.  
  1332. # REGCMP is 1 if your system has the regcmp() function.
  1333. # This is normally the case for System 5.
  1334. # RECOMP is 1 if your system has the re_comp() function.
  1335. # This is normally the case for BSD.
  1336. # If neither is 1, pattern matching is supported, but without metacharacters.
  1337. REGCMP = 0
  1338. RECOMP = 1
  1339.  
  1340. # SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  1341. # (This is possible only if your system supplies the system() function.)
  1342. SHELL_ESCAPE = 1
  1343.  
  1344. # EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  1345. # (This is possible only if your system supplies the system() function.)
  1346. # EDIT_PGM is the name of the (default) editor to be invoked.
  1347. EDITOR = 1
  1348. EDIT_PGM = vi
  1349.  
  1350. # GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  1351. # This will generally work if your system provides the "popen" function
  1352. # and the "echo" shell command.
  1353. GLOB = 1
  1354.  
  1355. # LOGFILE is 1 if you wish to allow the -l option (to create log files).
  1356. LOGFILE = 1
  1357.  
  1358. # ONLY_RETURN is 1 if you want RETURN to be the only input which
  1359. # will continue past an error message.
  1360. # Otherwise, any key will continue past an error message.
  1361. ONLY_RETURN = 0
  1362.  
  1363.  
  1364. ##########################################################################
  1365. # Compilation environment.
  1366. ##########################################################################
  1367.  
  1368. # LIBS is the list of libraries needed.
  1369. LIBS = -ltermcap
  1370.  
  1371. # INSTALL_LESS is a list of the public versions of less.
  1372. # INSTALL_HELP is a list of the public version of the help file.
  1373. # INSTALL_MAN is a list of the public versions of the manual page.
  1374. INSTALL_LESS =    /usr/local/bin/less
  1375. INSTALL_HELP =    /usr/local/bin/less.help
  1376. INSTALL_MAN =    /usr/man/man1/less.1
  1377. MANUAL =    less.nro
  1378. HELPFILE =    /usr/local/bin/less.help
  1379.  
  1380.  
  1381. # OPTIM is passed to the compiler and the loader.
  1382. # It is normally "-O" but may be, for example, "-g".
  1383. OPTIM = -O
  1384.  
  1385.  
  1386. ##########################################################################
  1387. # Files
  1388. ##########################################################################
  1389.  
  1390. SRC1 =    main.c option.c prim.c ch.c position.c input.c output.c 
  1391. SRC2 =    screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
  1392. SRC =    $(SRC1) $(SRC2)
  1393. OBJ =    main.o option.o prim.o ch.o position.o input.o output.o screen.o \
  1394.     prompt.o line.o signal.o help.o ttyin.o command.o version.o
  1395.  
  1396.  
  1397. ##########################################################################
  1398. # Rules
  1399. ##########################################################################
  1400.  
  1401. DEFS =    "-DTERMIO=$(TERMIO)" \
  1402.     "-DSIGSETMASK=$(SIGSETMASK)" \
  1403.     "-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
  1404.     "-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
  1405.     "-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
  1406.     "-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
  1407.     "-DHELPFILE=\"$(HELPFILE)\"" \
  1408.     "-DLOGFILE=$(LOGFILE)" \
  1409.     "-DONLY_RETURN=$(ONLY_RETURN)" \
  1410.     "-DGLOB=$(GLOB)" \
  1411.     "-DXENIX=$(XENIX)"
  1412.  
  1413. CFLAGS = $(OPTIM) $(DEFS)
  1414.  
  1415.  
  1416. all: less
  1417.  
  1418. less: $(OBJ)
  1419.     cc $(OPTIM) -o less $(OBJ) $(LIBS)
  1420.  
  1421. install: install_man install_less install_help
  1422.  
  1423. install_less: less
  1424.     for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  1425.     touch install_less
  1426.  
  1427. install_help: less.help
  1428.     for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  1429.     touch install_help
  1430.  
  1431. install_man: $(MANUAL)
  1432.     for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
  1433.     touch install_man
  1434.  
  1435. $(OBJ): less.h funcs.h
  1436.  
  1437. # help.o depends on makefile for the definition of HELPFILE.
  1438. help.o: makefile
  1439.  
  1440. lint:
  1441.     lint -hp $(DEFS) $(SRC)
  1442.  
  1443. newfuncs:
  1444.     mv funcs.h funcs.h.OLD
  1445.     awk -f mkfuncs.awk $(SRC) >funcs.h
  1446.  
  1447. clean:
  1448.     rm -f $(OBJ) less
  1449.  
  1450. clobber:
  1451.     rm -f *.o less install_less install_man
  1452.  
  1453. shar:
  1454.     shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
  1455.     shar -v less.nro $(SRC1) > less.shar.b
  1456.     shar -v $(SRC2) > less.shar.c
  1457. _SHAR_EOF_
  1458.  
  1459. echo makefile.sys5
  1460. cat >makefile.sys5 <<'_SHAR_EOF_'
  1461. # Makefile for "less"
  1462. #
  1463. # Invoked as:
  1464. #    make all
  1465. #   or    make install
  1466. # Plain "make" is equivalent to "make all".
  1467. #
  1468. # If you add or delete functions, remake funcs.h by doing:
  1469. #    make newfuncs
  1470. # This depends on the coding convention of function headers looking like:
  1471. #    " \t public <function-type> \n <function-name> ( ... ) "
  1472. #
  1473. # Also provided:
  1474. #    make lint    # Runs "lint" on all the sources.
  1475. #    make clean    # Removes "less" and the .o files.
  1476. #    make clobber    # Pretty much the same as make "clean".
  1477.  
  1478.  
  1479. ##########################################################################
  1480. # System-specific parameters
  1481. ##########################################################################
  1482.  
  1483. # Define XENIX if running under XENIX 3.0
  1484. XENIX = 0
  1485.  
  1486. # VOID is 1 if your C compiler supports the "void" type,
  1487. # 0 if it does not.
  1488. VOID = 1
  1489.  
  1490. # off_t is the type which lseek() returns.
  1491. # It is also the type of lseek()'s second argument.
  1492. off_t = long
  1493.  
  1494. # TERMIO is 1 if your system has /usr/include/termio.h.
  1495. # This is normally the case for System 5.
  1496. # If TERMIO is 0 your system must have /usr/include/sgtty.h.
  1497. # This is normally the case for BSD.
  1498. TERMIO = 1
  1499.  
  1500. # SIGSETMASK is 1 if your system has the sigsetmask() call.
  1501. # This is normally the case only for BSD 4.2,
  1502. # not for BSD 4.1 or System 5.
  1503. SIGSETMASK = 0
  1504.  
  1505. ##########################################################################
  1506. # Optional and semi-optional features
  1507. ##########################################################################
  1508.  
  1509. # REGCMP is 1 if your system has the regcmp() function.
  1510. # This is normally the case for System 5.
  1511. # RECOMP is 1 if your system has the re_comp() function.
  1512. # This is normally the case for BSD.
  1513. # If neither is 1, pattern matching is supported, but without metacharacters.
  1514. REGCMP = 1
  1515. RECOMP = 0
  1516.  
  1517. # SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  1518. # (This is possible only if your system supplies the system() function.)
  1519. SHELL_ESCAPE = 1
  1520.  
  1521. # EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  1522. # (This is possible only if your system supplies the system() function.)
  1523. # EDIT_PGM is the name of the (default) editor to be invoked.
  1524. EDITOR = 1
  1525. EDIT_PGM = vi
  1526.  
  1527. # GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  1528. # This will generally work if your system provides the "popen" function
  1529. # and the "echo" shell command.
  1530. GLOB = 1
  1531.  
  1532. # LOGFILE is 1 if you wish to allow the -l option (to create log files).
  1533. LOGFILE = 1
  1534.  
  1535. # ONLY_RETURN is 1 if you want RETURN to be the only input which
  1536. # will continue past an error message.
  1537. # Otherwise, any key will continue past an error message.
  1538. ONLY_RETURN = 0
  1539.  
  1540.  
  1541. ##########################################################################
  1542. # Compilation environment.
  1543. ##########################################################################
  1544.  
  1545. # LIBS is the list of libraries needed.
  1546. LIBS = -lcurses -ltermcap -lPW
  1547.  
  1548. # INSTALL_LESS is a list of the public versions of less.
  1549. # INSTALL_HELP is a list of the public version of the help file.
  1550. # INSTALL_MAN is a list of the public versions of the manual page.
  1551. INSTALL_LESS =    /usr/local/bin/less
  1552. INSTALL_HELP =    /usr/local/bin/less.help
  1553. INSTALL_MAN =    /usr/man/man1/less.1
  1554. MANUAL =    less.nro
  1555. HELPFILE =    /usr/local/bin/less.help
  1556.  
  1557.  
  1558. # OPTIM is passed to the compiler and the loader.
  1559. # It is normally "-O" but may be, for example, "-g".
  1560. OPTIM = -O
  1561.  
  1562.  
  1563. ##########################################################################
  1564. # Files
  1565. ##########################################################################
  1566.  
  1567. SRC1 =    main.c option.c prim.c ch.c position.c input.c output.c 
  1568. SRC2 =    screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
  1569. SRC =    $(SRC1) $(SRC2)
  1570. OBJ =    main.o option.o prim.o ch.o position.o input.o output.o screen.o \
  1571.     prompt.o line.o signal.o help.o ttyin.o command.o version.o
  1572.  
  1573.  
  1574. ##########################################################################
  1575. # Rules
  1576. ##########################################################################
  1577.  
  1578. DEFS =    "-DTERMIO=$(TERMIO)" \
  1579.     "-DSIGSETMASK=$(SIGSETMASK)" \
  1580.     "-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
  1581.     "-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
  1582.     "-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
  1583.     "-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
  1584.     "-DHELPFILE=\"$(HELPFILE)\"" \
  1585.     "-DLOGFILE=$(LOGFILE)" \
  1586.     "-DONLY_RETURN=$(ONLY_RETURN)" \
  1587.     "-DGLOB=$(GLOB)" \
  1588.     "-DXENIX=$(XENIX)"
  1589.  
  1590. CFLAGS = $(OPTIM) $(DEFS)
  1591.  
  1592.  
  1593. all: less
  1594.  
  1595. less: $(OBJ)
  1596.     cc $(OPTIM) -o less $(OBJ) $(LIBS)
  1597.  
  1598. install: install_man install_less install_help
  1599.  
  1600. install_less: less
  1601.     for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  1602.     touch install_less
  1603.  
  1604. install_help: less.help
  1605.     for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  1606.     touch install_help
  1607.  
  1608. install_man: $(MANUAL)
  1609.     for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
  1610.     touch install_man
  1611.  
  1612. $(OBJ): less.h funcs.h
  1613.  
  1614. # help.o depends on makefile for the definition of HELPFILE.
  1615. help.o: makefile
  1616.  
  1617. lint:
  1618.     lint -hp $(DEFS) $(SRC)
  1619.  
  1620. newfuncs:
  1621.     mv funcs.h funcs.h.OLD
  1622.     awk -f mkfuncs.awk $(SRC) >funcs.h
  1623.  
  1624. clean:
  1625.     rm -f $(OBJ) less
  1626.  
  1627. clobber:
  1628.     rm -f *.o less install_less install_man
  1629.  
  1630. shar:
  1631.     shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
  1632.     shar -v less.nro $(SRC1) > less.shar.b
  1633.     shar -v $(SRC2) > less.shar.c
  1634. _SHAR_EOF_
  1635.  
  1636. echo makefile.xen
  1637. cat >makefile.xen <<'_SHAR_EOF_'
  1638. # Makefile for "less"
  1639. #
  1640. # Invoked as:
  1641. #    make all
  1642. #   or    make install
  1643. # Plain "make" is equivalent to "make all".
  1644. #
  1645. # If you add or delete functions, remake funcs.h by doing:
  1646. #    make newfuncs
  1647. # This depends on the coding convention of function headers looking like:
  1648. #    " \t public <function-type> \n <function-name> ( ... ) "
  1649. #
  1650. # Also provided:
  1651. #    make lint    # Runs "lint" on all the sources.
  1652. #    make clean    # Removes "less" and the .o files.
  1653. #    make clobber    # Pretty much the same as make "clean".
  1654.  
  1655.  
  1656. ##########################################################################
  1657. # System-specific parameters
  1658. ##########################################################################
  1659.  
  1660. # Define XENIX if running under XENIX 3.0
  1661. XENIX = 1
  1662.  
  1663. # VOID is 1 if your C compiler supports the "void" type,
  1664. # 0 if it does not.
  1665. VOID = 1
  1666.  
  1667. # off_t is the type which lseek() returns.
  1668. # It is also the type of lseek()'s second argument.
  1669. off_t = long
  1670.  
  1671. # TERMIO is 1 if your system has /usr/include/termio.h.
  1672. # This is normally the case for System 5.
  1673. # If TERMIO is 0 your system must have /usr/include/sgtty.h.
  1674. # This is normally the case for BSD.
  1675. TERMIO = 1
  1676.  
  1677. # SIGSETMASK is 1 if your system has the sigsetmask() call.
  1678. # This is normally the case only for BSD 4.2,
  1679. # not for BSD 4.1 or System 5.
  1680. SIGSETMASK = 0
  1681.  
  1682. ##########################################################################
  1683. # Optional and semi-optional features
  1684. ##########################################################################
  1685.  
  1686. # REGCMP is 1 if your system has the regcmp() function.
  1687. # This is normally the case for System 5.
  1688. # RECOMP is 1 if your system has the re_comp() function.
  1689. # This is normally the case for BSD.
  1690. # If neither is 1, pattern matching is supported, but without metacharacters.
  1691. REGCMP = 1
  1692. RECOMP = 0
  1693.  
  1694. # SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  1695. # (This is possible only if your system supplies the system() function.)
  1696. SHELL_ESCAPE = 1
  1697.  
  1698. # EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  1699. # (This is possible only if your system supplies the system() function.)
  1700. # EDIT_PGM is the name of the (default) editor to be invoked.
  1701. EDITOR = 1
  1702. EDIT_PGM = vi
  1703.  
  1704. # GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  1705. # This will generally work if your system provides the "popen" function
  1706. # and the "echo" shell command.
  1707. GLOB = 1
  1708.  
  1709. # LOGFILE is 1 if you wish to allow the -l option (to create log files).
  1710. LOGFILE = 1
  1711.  
  1712. # ONLY_RETURN is 1 if you want RETURN to be the only input which
  1713. # will continue past an error message.
  1714. # Otherwise, any key will continue past an error message.
  1715. ONLY_RETURN = 0
  1716.  
  1717.  
  1718. ##########################################################################
  1719. # Compilation environment.
  1720. ##########################################################################
  1721.  
  1722. # LIBS is the list of libraries needed.
  1723. LIBS = -ltermlib
  1724.  
  1725. # INSTALL_LESS is a list of the public versions of less.
  1726. # INSTALL_HELP is a list of the public version of the help file.
  1727. # INSTALL_MAN is a list of the public versions of the manual page.
  1728. INSTALL_LESS =    /usr/local/bin/less
  1729. INSTALL_HELP =    /usr/local/bin/less.help
  1730. INSTALL_MAN =    /usr/man/man1/less.1
  1731. MANUAL =    less.nro
  1732. HELPFILE =    /usr/local/bin/less.help
  1733.  
  1734.  
  1735. # OPTIM is passed to the compiler and the loader.
  1736. # It is normally "-O" but may be, for example, "-g".
  1737. OPTIM = -O
  1738.  
  1739.  
  1740. ##########################################################################
  1741. # Files
  1742. ##########################################################################
  1743.  
  1744. SRC1 =    main.c option.c prim.c ch.c position.c input.c output.c 
  1745. SRC2 =    screen.c prompt.c line.c signal.c help.c ttyin.c command.c version.c
  1746. SRC =    $(SRC1) $(SRC2)
  1747. OBJ =    main.o option.o prim.o ch.o position.o input.o output.o screen.o \
  1748.     prompt.o line.o signal.o help.o ttyin.o command.o version.o
  1749.  
  1750.  
  1751. ##########################################################################
  1752. # Rules
  1753. ##########################################################################
  1754.  
  1755. DEFS =    "-DTERMIO=$(TERMIO)" \
  1756.     "-DSIGSETMASK=$(SIGSETMASK)" \
  1757.     "-Doff_t=$(off_t)" "-DVOID=$(VOID)" \
  1758.     "-DREGCMP=$(REGCMP)" "-DRECOMP=$(RECOMP)" \
  1759.     "-DSHELL_ESCAPE=$(SHELL_ESCAPE)" \
  1760.     "-DEDITOR=$(EDITOR)" "-DEDIT_PGM=\"$(EDIT_PGM)\"" \
  1761.     "-DHELPFILE=\"$(HELPFILE)\"" \
  1762.     "-DLOGFILE=$(LOGFILE)" \
  1763.     "-DONLY_RETURN=$(ONLY_RETURN)" \
  1764.     "-DGLOB=$(GLOB)" \
  1765.     "-DXENIX=$(XENIX)"
  1766.  
  1767. CFLAGS = $(OPTIM) $(DEFS)
  1768.  
  1769.  
  1770. all: less
  1771.  
  1772. less: $(OBJ)
  1773.     cc $(OPTIM) -o less $(OBJ) $(LIBS)
  1774.  
  1775. install: install_man install_less install_help
  1776.  
  1777. install_less: less
  1778.     for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  1779.     touch install_less
  1780.  
  1781. install_help: less.help
  1782.     for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  1783.     touch install_help
  1784.  
  1785. install_man: $(MANUAL)
  1786.     for f in $(INSTALL_MAN); do  rm -f $$f; cp $(MANUAL) $$f;  done
  1787.     touch install_man
  1788.  
  1789. $(OBJ): less.h funcs.h
  1790.  
  1791. # help.o depends on makefile for the definition of HELPFILE.
  1792. help.o: makefile
  1793.  
  1794. lint:
  1795.     lint -hp $(DEFS) $(SRC)
  1796.  
  1797. newfuncs:
  1798.     mv funcs.h funcs.h.OLD
  1799.     awk -f mkfuncs.awk $(SRC) >funcs.h
  1800.  
  1801. clean:
  1802.     rm -f $(OBJ) less
  1803.  
  1804. clobber:
  1805.     rm -f *.o less install_less install_man
  1806.  
  1807. shar:
  1808.     shar -v README install less.man less.help makefile.* *.h *.awk > less.shar.a
  1809.     shar -v less.nro $(SRC1) > less.shar.b
  1810.     shar -v $(SRC2) > less.shar.c
  1811. _SHAR_EOF_
  1812.  
  1813. echo funcs.h
  1814. cat >funcs.h <<'_SHAR_EOF_'
  1815.     public void edit ();
  1816.     public void next_file ();
  1817.     public void prev_file ();
  1818.     public void quit ();
  1819.     public void init_option ();
  1820.     public void toggle_option ();
  1821.     public void scan_option ();
  1822.     public void forward ();
  1823.     public void backward ();
  1824.     public void repaint ();
  1825.     public void jump_forw ();
  1826.     public void jump_back ();
  1827.     public void jump_percent ();
  1828.     public void jump_loc ();
  1829.     public void init_mark ();
  1830.     public void setmark ();
  1831.     public void lastmark ();
  1832.     public void gomark ();
  1833.     public int get_back_scroll ();
  1834.     public void search ();
  1835.     public void end_logfile ();
  1836.     public int ch_seek ();
  1837.     public int ch_end_seek ();
  1838.     public int ch_beg_seek ();
  1839.     public POSITION ch_length ();
  1840.     public POSITION ch_tell ();
  1841.     public int ch_forw_get ();
  1842.     public int ch_back_get ();
  1843.     public void ch_init ();
  1844.     public POSITION position ();
  1845.     public void add_forw_pos ();
  1846.     public void add_back_pos ();
  1847.     public void pos_clear ();
  1848.     public int onscreen ();
  1849.     public POSITION forw_line ();
  1850.     public POSITION back_line ();
  1851.     public void put_line ();
  1852.     public int control_char ();
  1853.     public int carat_char ();
  1854.     public void flush ();
  1855.     public void dropout ();
  1856.     public void putc ();
  1857.     public void puts ();
  1858.     public void error ();
  1859.     public int error_width ();
  1860.     public void raw_mode ();
  1861.     public void get_term ();
  1862.     public void init ();
  1863.     public void deinit ();
  1864.     public void home ();
  1865.     public void add_line ();
  1866.     public void lower_left ();
  1867.     public void bell ();
  1868.     public void vbell ();
  1869.     public void clear ();
  1870.     public void clear_eol ();
  1871.     public void so_enter ();
  1872.     public void so_exit ();
  1873.     public void ul_enter ();
  1874.     public void ul_exit ();
  1875.     public void bo_enter ();
  1876.     public void bo_exit ();
  1877.     public void backspace ();
  1878.     public void putbs ();
  1879.     public char * eq_message ();
  1880.     public char * pr_string ();
  1881.     public void prewind ();
  1882.     public int pappend ();
  1883.     public POSITION forw_raw_line ();
  1884.     public POSITION back_raw_line ();
  1885.     public void init_signals ();
  1886.     public void  psignals ();
  1887.     public void lsystem ();
  1888.     public void help ();
  1889.     public void open_getc ();
  1890.     public int getc ();
  1891.     public void commands ();
  1892. _SHAR_EOF_
  1893.  
  1894. echo less.h
  1895. cat >less.h <<'_SHAR_EOF_'
  1896. /*
  1897.  * Standard include file for "less".
  1898.  */
  1899.  
  1900. /*
  1901.  * Language details.
  1902.  */
  1903. #if !VOID
  1904. #define    void  int
  1905. #endif
  1906. #define    public        /* PUBLIC FUNCTION */
  1907.  
  1908. /*
  1909.  * Special types and constants.
  1910.  */
  1911. typedef long        POSITION;
  1912. /*
  1913.  * {{ Warning: if POSITION is changed to other than "long",
  1914.  *    you may have to change some of the printfs which use "%ld"
  1915.  *    to print a variable of type POSITION. }}
  1916.  */
  1917.  
  1918. #define    NULL_POSITION    ((POSITION)(-1))
  1919.  
  1920. #define    EOF        (0)
  1921. #define    NULL        (0)
  1922.  
  1923. /* How quiet should we be? */
  1924. #define    NOT_QUIET    0    /* Ring bell at eof and for errors */
  1925. #define    LITTLE_QUIET    1    /* Ring bell only for errors */
  1926. #define    VERY_QUIET    2    /* Never ring bell */
  1927.  
  1928. /* How should we prompt? */
  1929. #define    PR_SHORT    0    /* Prompt with colon */
  1930. #define    PR_MEDIUM    1    /* Prompt with message */
  1931. #define    PR_LONG        2    /* Prompt with longer message */
  1932.  
  1933. /* How should we handle backspaces? */
  1934. #define    BS_SPECIAL    0    /* Do special things for underlining and bold */
  1935. #define    BS_NORMAL    1    /* \b treated as normal char; actually output */
  1936. #define    BS_CONTROL    2    /* \b treated as control char; prints as ^H */
  1937.  
  1938. /* Special chars used to tell put_line() to do something special */
  1939. #define    UL_CHAR        '\201'    /* Enter underline mode */
  1940. #define    UE_CHAR        '\202'    /* Exit underline mode */
  1941. #define    BO_CHAR        '\203'    /* Enter boldface mode */
  1942. #define    BE_CHAR        '\204'    /* Exit boldface mode */
  1943.  
  1944. #define    CONTROL(c)        ((c)&037)
  1945. #define    SIGNAL(sig,func)    signal(sig,func)
  1946.  
  1947. /* Library function declarations */
  1948. off_t lseek();
  1949.  
  1950. #include "funcs.h"
  1951. _SHAR_EOF_
  1952.  
  1953. echo position.h
  1954. cat >position.h <<'_SHAR_EOF_'
  1955. /*
  1956.  * Include file for interfacing to position.c modules.
  1957.  */
  1958. #define    TOP        0
  1959. #define    TOP_PLUS_ONE    1
  1960. #define    BOTTOM        -1
  1961. #define    BOTTOM_PLUS_ONE    -2
  1962. _SHAR_EOF_
  1963.  
  1964. echo mkfuncs.awk
  1965. cat >mkfuncs.awk <<'_SHAR_EOF_'
  1966. BEGIN { FS="("; state = 0 }
  1967.  
  1968. /^    public/ { ftype = $0; state = 1 }
  1969.  
  1970. { if (state == 1)
  1971.     state = 2
  1972.   else if (state == 2)
  1973.     { print ftype,$1,"();"; state = 0 }
  1974. }
  1975. _SHAR_EOF_
  1976.  
  1977.