Remove elle(1) editor, due to an incompatible license

This commit is contained in:
David van Moolenbroek 2012-02-14 15:47:02 +01:00
parent 0491126758
commit 342171fa9e
51 changed files with 4 additions and 19726 deletions

View file

@ -10,7 +10,7 @@ SUBDIR= add_route arp ash at autil awk \
comm compress cp crc cron crontab cut \
dd decomp16 DESCRIBE dev2name devsize df dhcpd \
dhrystone diff dirname diskctl du dumpcore \
ed eject elle elvis env expand factor fbdctl file \
ed eject elvis env expand factor fbdctl file \
find finger fingerd fix fold format fortune fsck.mfs \
ftp101 gcore gcov-pull getty grep head hexdump host \
hostaddr id ifconfig ifdef install \

View file

@ -1,30 +0,0 @@
# Makefile for elle
PROGS= ellec elle
SRCS.elle= eemain.c eecmds.c eesite.c eevini.c eedisp.c eeterm.c eeerr.c \
eeques.c eebuff.c eefile.c eefed.c eeedit.c eebit.c eef1.c \
eef2.c eefd.c eehelp.c eekmac.c eef3.c eesrch.c eequer.c \
eefill.c eediag.c sbstr.c sbm.c sberr.c
SRCS.ellec= ellec.c
CPPFLAGS+= -DIGN_JOB_CONTROl
MAN.elle=
MAN.ellec=
.if !empty(CC:Mclang)
# tons of int functions don't return values
CFLAGS+= -Wreturn-type
.endif
defprf.c: deffun.e
cat deffun.e defprf.e | ellec -Pconf > defprf.c
eefdef.h: deffun.e
cat deffun.e defprf.e | ellec -Fconf > eefdef.h
eefidx.h: deffun.e
cat deffun.e defprf.e | ellec -FXconf > eefidx.h
# Don't flush these files if interrupted, dammit!
.PRECIOUS: ellec deffun.e defprf.e
.include <bsd.prog.mk>

View file

@ -1,201 +0,0 @@
;;;
;;; ELLE Master Function Definition file - "deffun.e"
;;;
;;; This file serves as input to the ellec program. It defines
;;; all ELLE functions which may serve as keyboard-bound user commands.
;;;
;;; Format: (efun <Index> <Name> <Routine> <Module>)
;;; Index - an unique index # (used only within ELLE)
;;; Name - an unique string identifying this function to the user.
;;; Routine - the C routine implementing the function within ELLE.
;;; Module - the name of the C source file that the routine is in.
;;;
;;; The following definitions are roughly organized by object.
;;; All functions that emulate EMACS functions are given names identical
;;; to the EMACS function names. For historical reasons these names
;;; are not as consistent as they could be (sigh).
;;; Those which have no exact counterpart in EMACS are identified by comments.
(undefall) ; Ensure all predefined stuff is cleared out.
; Simple Insertion
(efun 1 "Insert Self" f_insself eef1)
(efun 2 "Quoted Insert" f_quotins eef1)
(efun 3 "CRLF" f_crlf eef1)
; Characters
(efun 4 "Forward Character" f_fchar eef1)
(efun 5 "Backward Character" f_bchar eef1)
(efun 6 "Delete Character" f_dchar eef1)
(efun 7 "Backward Delete Character" f_bdchar eef1)
(efun 8 "Delete Horizontal Space" f_delspc eef1)
(efun 9 "Transpose Characters" f_tchars eef1)
; Words
(efun 10 "Forward Word" f_fword eef1)
(efun 11 "Backward Word" f_bword eef1)
(efun 12 "Kill Word" f_kword eef1)
(efun 13 "Backward Kill Word" f_bkword eef1)
(efun 14 "Transpose Words" f_twords eef1)
(efun 15 "Uppercase Word" f_ucword eef1)
(efun 16 "Lowercase Word" f_lcword eef1)
(efun 17 "Uppercase Initial" f_uciword eef1)
; 18-19 reserved
; Lines
(efun 20 "Beginning of Line" f_begline eef2)
(efun 21 "End of Line" f_endline eef2)
(efun 22 "Next Line" f_nxtline eef2)
(efun 23 "Previous Line" f_prvline eef2)
(efun 24 "Down Real Line" f_dnrline eef2)
(efun 25 "Up Real Line" f_uprline eef2)
(efun 26 "Open Line" f_oline eef2)
(efun 27 "Delete Blank Lines" f_delblines eef2)
(efun 28 "Kill Line" f_kline eef2)
(efun 29 "Backward Kill Line" f_bkline eef2) ; not EMACS
(efun 30 "Goto Line" f_goline eef2) ; not EMACS
; 31-34 reserved
; Regions
(efun 35 "Set/Pop Mark" f_setmark eef2)
(efun 36 "Exchange Point and Mark" f_exchmark eef2)
(efun 37 "Kill Region" f_kregion eef2)
(efun 38 "Copy Region" f_copreg eef2)
(efun 39 "Uppercase Region" f_ucreg eef2)
(efun 40 "Lowercase Region" f_lcreg eef2)
(efun 41 "Fill Region" f_fillreg eef2)
; 42-44 reserved
; Paragraphs
(efun 45 "Forward Paragraph" f_fpara eef2)
(efun 46 "Backward Paragraph" f_bpara eef2)
(efun 47 "Mark Paragraph" f_mrkpara eef2)
(efun 48 "Fill Paragraph" f_fillpara eef2)
; 49 reserved
; Buffers
(efun 50 "Select Buffer" f_selbuffer eebuff)
(efun 51 "Select Existing Buffer" f_selxbuffer eebuff) ; not EMACS
(efun 52 "Kill Buffer" f_kbuffer eebuff)
(efun 53 "List Buffers" f_listbufs eebuff)
(efun 54 "Buffer Not Modified" f_bufnotmod eebuff)
(efun 55 "EOL CRLF Mode" f_eolmode eebuff) ; ELLE
(efun 56 "Goto Beginning" f_gobeg eebuff)
(efun 57 "Goto End" f_goend eebuff)
(efun 58 "What Page" f_whatpage eebuff)
; 59 reserved
; Files
(efun 60 "Find File" f_ffile eefile)
(efun 61 "Read File" f_rfile eefile)
(efun 62 "Visit File" f_vfile eefile)
(efun 63 "Insert File" f_ifile eefile)
(efun 64 "Save File" f_sfile eefile)
(efun 65 "Save All Files" f_savefiles eebuff)
(efun 66 "Write File" f_wfile eefile)
(efun 67 "Write Region" f_wreg eefile)
(efun 68 "Write Last Kill" f_wlastkill eefile) ; not EMACS
; 69 reserved
; Windows
(efun 70 "Two Windows" f_2winds eebuff)
(efun 71 "One Window" f_1wind eebuff)
(efun 72 "Other Window" f_othwind eebuff)
(efun 73 "Grow Window" f_growind eebuff)
(efun 74 "Shrink Window" f_shrinkwind eebuff) ; not EMACS
(efun 75 "Delete Window" f_delwind eebuff) ; not EMACS
(efun 76 "Standout Window" f_sowind eebuff) ; ELLE
(efun 77 "Two Mode Windows" f_2modewinds eebuff) ; ELLE
; Window Positioning
(efun 78 "New Window" f_newwin eefd)
(efun 79 "Next Screen" f_nscreen eefd)
(efun 80 "Previous Screen" f_pscreen eefd)
(efun 81 "Other New Screen" f_othnscreen eefd) ; not EMACS
(efun 82 "Line to Window Border" f_lwindbord eefd) ; not EMACS
(efun 83 "Scroll Window Up" f_scupwind eefd) ; not EMACS
(efun 84 "Scroll Window Down" f_scdnwind eefd) ; not EMACS
(efun 85 "Move to Window Top" f_mvwtop eefd) ; not EMACS
(efun 86 "Move to Window Bottom" f_mvwbot eefd) ; not EMACS
; 87-89 reserved
; Command Input
(efun 90 "Set Profile" f_setprof eecmds) ; ELLE
(efun 91 "Prefix Meta" f_pfxmeta eecmds)
(efun 92 "Prefix Extend" f_pfxext eecmds)
(efun 93 "Universal Arg" f_uarg eecmds)
(efun 94 "Negative Argument" f_negarg eecmds)
(efun 95 "Argument Digit" f_argdig eecmds)
(efun 96 "VT100 Button Hack" f_vtbuttons eecmds) ; not EMACS
; Help
(efun 97 "Describe" f_describe eehelp)
; 98-99 reserved
; Keyboard Macros
(efun 100 "Start Kbd Macro" f_skmac eekmac)
(efun 101 "End Kbd Macro" f_ekmac eekmac)
(efun 102 "Execute Kbd Macro" f_xkmac eekmac)
(efun 103 "View Kbd Macro" f_vkmac eekmac)
; 104 reserved
; Killing
(efun 105 "Un-kill" f_unkill eef3)
(efun 106 "Un-kill Pop" f_unkpop eef3)
(efun 107 "Append Next Kill" f_appnkill eef3)
; 108-109 reserved
; Searching
(efun 110 "String Search" f_srch eesrch)
(efun 111 "Reverse String Search" f_rsrch eesrch)
(efun 112 "Incremental Search" f_isrch eesrch)
(efun 113 "Reverse Search" f_risrch eesrch)
; Query Replace & friends
(efun 114 "Replace String" f_repstr eequer)
(efun 115 "Query Replace" f_querep eequer)
(efun 116 "Replace in Line" f_repline eequer) ; not EMACS
; Fill Mode
(efun 117 "Set Fill Column" f_sfcol eefill)
(efun 118 "Set Fill Prefix" f_sfpref eefill)
(efun 119 "Auto Fill Mode" f_fillmode eefill)
(efun 120 "Text Mode" f_textmode eefill) ; IMAGEN
; Indentation
(efun 121 "Indent According to Mode" f_indatm eef3)
(efun 122 "Indent New Line" f_indnl eef3)
(efun 123 "Back to Indentation" f_backind eef3)
(efun 124 "Indent for Comment" f_indcomm eef3)
(efun 125 "Indent Relative" f_indrel eef3)
; 126-128 reserved
; Miscellaneous
(efun 129 "Match Bracket" f_matchbrack eef3) ; not EMACS
; Process Control
(efun 130 "Push to Inferior" f_pshinf eemain)
(efun 131 "Return to Superior" f_retsup eemain)
(efun 132 "Write File Exit" f_wfexit eemain) ; not EMACS
; 133-139 reserved
; ELLE Debugging
(efun 140 "Hit Breakpoint" f_bkpt eeerr) ; ELLE
(efun 141 "Debug Mode" f_debug eediag) ; ELLE
; 142-149 reserved
;---------------------------------------------------------------
; IMAGEN configuration only
(efun 150 "Execute Unix Command" f_xucmd eemake) ; IMAGEN
(efun 151 "Execute Make" f_make eemake) ; IMAGEN
(efun 152 "Find Next Error" f_nxterr eemake) ; IMAGEN
; ICONOGRAPHICS-specific
(efun 153 "ICO Extend Command" f_icoxcmd eefico) ; ICONOGRAPHICS
(efun 154 "ICO Typeset Funs" f_icotypfns eefico) ; ICONOGRAPHICS
(efun 155 "ICO Spec Input Funs" f_icospifns eefico) ; ICONOGRAPHICS
; SUN Mouse functions
(efun 156 "Stuff Selection" f_stuffsel eesun) ; SUN
(efun 157 "Select Region" f_selregion eesun) ; SUN

View file

@ -1,231 +0,0 @@
/* This file defines the initial data for ELLE's default user profile.
** It is automatically generated by ELLEC, and should not be edited.
*/
char charmap[] = {
35, /* ( 0) ^@ Set/Pop Mark */
20, /* ( 1) ^A Beginning of Line */
5, /* ( 2) ^B Backward Character */
0, /* ( 3) ^C unknown function */
6, /* ( 4) ^D Delete Character */
21, /* ( 5) ^E End of Line */
4, /* ( 6) ^F Forward Character */
0, /* ( 7) ^G unknown function */
5, /* ( 10) ^H Backward Character */
121, /* ( 11) ^I Indent According to Mode */
122, /* ( 12) ^J Indent New Line */
28, /* ( 13) ^K Kill Line */
78, /* ( 14) ^L New Window */
3, /* ( 15) ^M CRLF */
24, /* ( 16) ^N Down Real Line */
26, /* ( 17) ^O Open Line */
25, /* ( 20) ^P Up Real Line */
2, /* ( 21) ^Q Quoted Insert */
113, /* ( 22) ^R Reverse Search */
112, /* ( 23) ^S Incremental Search */
9, /* ( 24) ^T Transpose Characters */
93, /* ( 25) ^U Universal Arg */
79, /* ( 26) ^V Next Screen */
37, /* ( 27) ^W Kill Region */
92, /* ( 30) ^X Prefix Extend */
105, /* ( 31) ^Y Un-kill */
0, /* ( 32) ^Z unknown function */
91, /* ( 33) ^[ Prefix Meta */
141, /* ( 34) ^\ Debug Mode */
0, /* ( 35) ^] unknown function */
140, /* ( 36) ^^ Hit Breakpoint */
97, /* ( 37) ^_ Describe */
1, /* ( 40) Insert Self */
1, /* ( 41) ! Insert Self */
1, /* ( 42) " Insert Self */
1, /* ( 43) # Insert Self */
1, /* ( 44) $ Insert Self */
1, /* ( 45) % Insert Self */
1, /* ( 46) & Insert Self */
1, /* ( 47) ' Insert Self */
1, /* ( 50) ( Insert Self */
1, /* ( 51) ) Insert Self */
1, /* ( 52) * Insert Self */
1, /* ( 53) + Insert Self */
1, /* ( 54) , Insert Self */
1, /* ( 55) - Insert Self */
1, /* ( 56) . Insert Self */
1, /* ( 57) / Insert Self */
1, /* ( 60) 0 Insert Self */
1, /* ( 61) 1 Insert Self */
1, /* ( 62) 2 Insert Self */
1, /* ( 63) 3 Insert Self */
1, /* ( 64) 4 Insert Self */
1, /* ( 65) 5 Insert Self */
1, /* ( 66) 6 Insert Self */
1, /* ( 67) 7 Insert Self */
1, /* ( 70) 8 Insert Self */
1, /* ( 71) 9 Insert Self */
1, /* ( 72) : Insert Self */
1, /* ( 73) ; Insert Self */
1, /* ( 74) < Insert Self */
1, /* ( 75) = Insert Self */
1, /* ( 76) > Insert Self */
1, /* ( 77) ? Insert Self */
1, /* (100) @ Insert Self */
1, /* (101) A Insert Self */
1, /* (102) B Insert Self */
1, /* (103) C Insert Self */
1, /* (104) D Insert Self */
1, /* (105) E Insert Self */
1, /* (106) F Insert Self */
1, /* (107) G Insert Self */
1, /* (110) H Insert Self */
1, /* (111) I Insert Self */
1, /* (112) J Insert Self */
1, /* (113) K Insert Self */
1, /* (114) L Insert Self */
1, /* (115) M Insert Self */
1, /* (116) N Insert Self */
1, /* (117) O Insert Self */
1, /* (120) P Insert Self */
1, /* (121) Q Insert Self */
1, /* (122) R Insert Self */
1, /* (123) S Insert Self */
1, /* (124) T Insert Self */
1, /* (125) U Insert Self */
1, /* (126) V Insert Self */
1, /* (127) W Insert Self */
1, /* (130) X Insert Self */
1, /* (131) Y Insert Self */
1, /* (132) Z Insert Self */
1, /* (133) [ Insert Self */
1, /* (134) \ Insert Self */
1, /* (135) ] Insert Self */
1, /* (136) ^ Insert Self */
1, /* (137) _ Insert Self */
1, /* (140) ` Insert Self */
1, /* (141) a Insert Self */
1, /* (142) b Insert Self */
1, /* (143) c Insert Self */
1, /* (144) d Insert Self */
1, /* (145) e Insert Self */
1, /* (146) f Insert Self */
1, /* (147) g Insert Self */
1, /* (150) h Insert Self */
1, /* (151) i Insert Self */
1, /* (152) j Insert Self */
1, /* (153) k Insert Self */
1, /* (154) l Insert Self */
1, /* (155) m Insert Self */
1, /* (156) n Insert Self */
1, /* (157) o Insert Self */
1, /* (160) p Insert Self */
1, /* (161) q Insert Self */
1, /* (162) r Insert Self */
1, /* (163) s Insert Self */
1, /* (164) t Insert Self */
1, /* (165) u Insert Self */
1, /* (166) v Insert Self */
1, /* (167) w Insert Self */
1, /* (170) x Insert Self */
1, /* (171) y Insert Self */
1, /* (172) z Insert Self */
1, /* (173) { Insert Self */
1, /* (174) | Insert Self */
1, /* (175) } Insert Self */
1, /* (176) ~ Insert Self */
7, /* (177) DEL Backward Delete Character */
};
char metamap[] = {
02 , 86, /* M-^B Move to Window Bottom */
014 , 30, /* M-^L Goto Line */
016 , 84, /* M-^N Scroll Window Down */
020 , 83, /* M-^P Scroll Window Up */
022 ,111, /* M-^R Reverse String Search */
023 ,110, /* M-^S String Search */
024 , 85, /* M-^T Move to Window Top */
027 ,107, /* M-^W Append Next Kill */
030 , 51, /* M-^X Select Existing Buffer */
036 , 74, /* M-^^ Shrink Window */
045 ,115, /* M-% Query Replace */
055 , 94, /* M-- Negative Argument */
060 , 95, /* M-0 Argument Digit */
061 , 95, /* M-1 Argument Digit */
062 , 95, /* M-2 Argument Digit */
063 , 95, /* M-3 Argument Digit */
064 , 95, /* M-4 Argument Digit */
065 , 95, /* M-5 Argument Digit */
066 , 95, /* M-6 Argument Digit */
067 , 95, /* M-7 Argument Digit */
070 , 95, /* M-8 Argument Digit */
071 , 95, /* M-9 Argument Digit */
073 ,124, /* M-; Indent for Comment */
074 , 56, /* M-< Goto Beginning */
076 , 57, /* M-> Goto End */
0133, 46, /* M-[ Backward Paragraph */
0134, 8, /* M-\ Delete Horizontal Space */
0135, 45, /* M-] Forward Paragraph */
0102, 11, /* M-B Backward Word */
0103, 17, /* M-C Uppercase Initial */
0104, 12, /* M-D Kill Word */
0106, 10, /* M-F Forward Word */
0107, 41, /* M-G Fill Region */
0110, 47, /* M-H Mark Paragraph */
0111,125, /* M-I Indent Relative */
0114, 16, /* M-L Lowercase Word */
0115,123, /* M-M Back to Indentation */
0116, 22, /* M-N Next Line */
0117, 96, /* M-O VT100 Button Hack */
0120, 23, /* M-P Previous Line */
0121, 48, /* M-Q Fill Paragraph */
0124, 14, /* M-T Transpose Words */
0125, 15, /* M-U Uppercase Word */
0126, 80, /* M-V Previous Screen */
0127, 38, /* M-W Copy Region */
0131,106, /* M-Y Un-kill Pop */
0176, 54, /* M-~ Buffer Not Modified */
0177, 13, /* M-DEL Backward Kill Word */
};
char extmap[] = {
02 , 53, /* X-^B List Buffers */
03 ,132, /* X-^C Write File Exit */
05 , 67, /* X-^E Write Region */
06 , 60, /* X-^F Find File */
013 , 68, /* X-^K Write Last Kill */
014 , 40, /* X-^L Lowercase Region */
015 , 55, /* X-^M EOL CRLF Mode */
017 , 27, /* X-^O Delete Blank Lines */
020 , 90, /* X-^P Set Profile */
022 , 61, /* X-^R Read File */
023 , 64, /* X-^S Save File */
025 , 39, /* X-^U Uppercase Region */
026 , 62, /* X-^V Visit File */
027 , 66, /* X-^W Write File */
030 , 36, /* X-^X Exchange Point and Mark */
032 ,131, /* X-^Z Return to Superior */
041 ,130, /* X-! Push to Inferior */
044 ,116, /* X-$ Replace in Line */
045 ,114, /* X-% Replace String */
050 ,100, /* X-( Start Kbd Macro */
051 ,101, /* X-) End Kbd Macro */
052 ,103, /* X-* View Kbd Macro */
056 ,118, /* X-. Set Fill Prefix */
060 , 75, /* X-0 Delete Window */
061 , 71, /* X-1 One Window */
062 , 70, /* X-2 Two Windows */
070 , 76, /* X-8 Standout Window */
071 , 77, /* X-9 Two Mode Windows */
075 , 58, /* X-= What Page */
0136, 73, /* X-^ Grow Window */
0102, 50, /* X-B Select Buffer */
0105,102, /* X-E Execute Kbd Macro */
0106,117, /* X-F Set Fill Column */
0111, 63, /* X-I Insert File */
0113, 52, /* X-K Kill Buffer */
0117, 72, /* X-O Other Window */
0123, 65, /* X-S Save All Files */
0124,119, /* X-T Auto Fill Mode */
0177, 29, /* X-DEL Backward Kill Line */
};
struct profile def_prof = {
1, /* Ver */
sizeof(charmap), charmap,
sizeof(metamap)/2, metamap,
sizeof(extmap)/2, extmap,
0, 0
};

View file

@ -1,258 +0,0 @@
;;;
;;; ELLE Default Command Profile - "defprf.e"
;;;
;;; This file is input to the ellec program. It defines the default
;;; command key bindings that ELLE uses, in the absence of an individual
;;; user profile.
;;; These defaults attempt to emulate the default EMACS command key
;;; bindings. Differences, where known, are commented.
;;;
;;; "ELLE" means the function is unique to ELLE.
;;; E/G: (cmd altnam) "thisname";
;;; "E:" refers to TOPS-20 EMACS, "G:" refers to Gnu Emacs.
;;; (cmd) This function exists but is bound to "cmd" instead.
;;; (*) function exists but is not bound to any specific key.
;;; () function does not exist.
;;; (=) function exists, with same binding (normally omitted)
;;; altnam Name by which this function is known.
;;; "thisname" - name of function bound to this command.
;;; - means the command is unbound (undefined).
(keyallunbind) ; Flush any predefined bindings
(keybind ^@ "Set/Pop Mark")
(keybind ^A "Beginning of Line")
(keybind ^B "Backward Character")
; ^C not bound. ; E: ()- G: mode-specific-command-prefix
(keybind ^D "Delete Character")
(keybind ^E "End of Line")
(keybind ^F "Forward Character")
(keybind ^H "Backward Character") ; G: (^B) help-command
(keybind ^I "Indent According to Mode")
(keybind ^J "Indent New Line")
(keybind ^K "Kill Line")
(keybind ^L "New Window")
(keybind ^M "CRLF")
(keybind ^N "Down Real Line")
(keybind ^O "Open Line")
(keybind ^P "Up Real Line")
(keybind ^Q "Quoted Insert")
(keybind ^R "Reverse Search")
(keybind ^S "Incremental Search")
(keybind ^T "Transpose Characters")
(keybind ^U "Universal Arg")
(keybind ^V "Next Screen")
(keybind ^W "Kill Region")
(keybind ^X "Prefix Extend")
(keybind ^Y "Un-kill")
; ^Z not bound ; E: Prefix Control-Meta; G: suspend-emacs
(keybind ^[ "Prefix Meta")
(keybind "^\" "Debug Mode") ; ELLE. E: () Prefix Meta; G: () -
; ^] not bound. ; E+G: Abort Recursive Edit
(keybind ^^ "Hit Breakpoint") ; ELLE. E: () Prefix Control; G: () -
(keybind ^_ "Describe") ; E: (M-?) Help; G: (^H-k) undo
(keybind " " "Insert Self")
(keybind ! "Insert Self")
(keybind """" "Insert Self")
(keybind # "Insert Self")
(keybind $ "Insert Self")
(keybind % "Insert Self")
(keybind & "Insert Self")
(keybind ' "Insert Self")
(keybind "(" "Insert Self")
(keybind ")" "Insert Self")
(keybind * "Insert Self")
(keybind + "Insert Self")
(keybind , "Insert Self")
(keybind - "Insert Self")
(keybind . "Insert Self")
(keybind / "Insert Self")
(keybind 0 "Insert Self")
(keybind 1 "Insert Self")
(keybind 2 "Insert Self")
(keybind 3 "Insert Self")
(keybind 4 "Insert Self")
(keybind 5 "Insert Self")
(keybind 6 "Insert Self")
(keybind 7 "Insert Self")
(keybind 8 "Insert Self")
(keybind 9 "Insert Self")
(keybind : "Insert Self")
(keybind ";" "Insert Self")
(keybind < "Insert Self")
(keybind = "Insert Self")
(keybind > "Insert Self")
(keybind ? "Insert Self")
(keybind @ "Insert Self")
(keybind A "Insert Self")
(keybind B "Insert Self")
(keybind C "Insert Self")
(keybind D "Insert Self")
(keybind E "Insert Self")
(keybind F "Insert Self")
(keybind G "Insert Self")
(keybind H "Insert Self")
(keybind I "Insert Self")
(keybind J "Insert Self")
(keybind K "Insert Self")
(keybind L "Insert Self")
(keybind M "Insert Self")
(keybind N "Insert Self")
(keybind O "Insert Self")
(keybind P "Insert Self")
(keybind Q "Insert Self")
(keybind R "Insert Self")
(keybind S "Insert Self")
(keybind T "Insert Self")
(keybind U "Insert Self")
(keybind V "Insert Self")
(keybind W "Insert Self")
(keybind X "Insert Self")
(keybind Y "Insert Self")
(keybind Z "Insert Self")
(keybind [ "Insert Self")
(keybind "\" "Insert Self")
(keybind ] "Insert Self")
(keybind ^ "Insert Self")
(keybind _ "Insert Self")
(keybind ` "Insert Self")
(keybind a "Insert Self")
(keybind b "Insert Self")
(keybind c "Insert Self")
(keybind d "Insert Self")
(keybind e "Insert Self")
(keybind f "Insert Self")
(keybind g "Insert Self")
(keybind h "Insert Self")
(keybind i "Insert Self")
(keybind j "Insert Self")
(keybind k "Insert Self")
(keybind l "Insert Self")
(keybind m "Insert Self")
(keybind n "Insert Self")
(keybind o "Insert Self")
(keybind p "Insert Self")
(keybind q "Insert Self")
(keybind r "Insert Self")
(keybind s "Insert Self")
(keybind t "Insert Self")
(keybind u "Insert Self")
(keybind v "Insert Self")
(keybind w "Insert Self")
(keybind x "Insert Self")
(keybind y "Insert Self")
(keybind z "Insert Self")
(keybind { "Insert Self")
(keybind | "Insert Self")
(keybind } "Insert Self")
(keybind ~ "Insert Self")
(keybind DEL "Backward Delete Character")
; Meta chars
(keybind M-^B "Move to Window Bottom") ; ELLE (ima). E+G:()-
(keybind M-^L "Goto Line") ; E:(); G:(* goto-line) -
(keybind M-^N "Scroll Window Down") ; ELLE (ima). E+G:()- forward-list
(keybind M-^P "Scroll Window Up") ; ELLE (ima). E+G:()- backward-list
(keybind M-^R "Reverse String Search") ; E:(*); G:(* search-backward) -
(keybind M-^S "String Search") ; E:(*); G:(* search-forward) isearch-forward-regexp
(keybind M-^T "Move to Window Top") ; ELLE (ima). E+G:()-
(keybind M-^W "Append Next Kill")
(keybind M-^X "Select Existing Buffer") ; ELLE (ima). E+G:()-
(keybind M-^^ "Shrink Window") ; ELLE (ima). E+G:()-
(keybind M-% "Query Replace")
(keybind M-- "Negative Argument")
(keybind M-0 "Argument Digit")
(keybind M-1 "Argument Digit")
(keybind M-2 "Argument Digit")
(keybind M-3 "Argument Digit")
(keybind M-4 "Argument Digit")
(keybind M-5 "Argument Digit")
(keybind M-6 "Argument Digit")
(keybind M-7 "Argument Digit")
(keybind M-8 "Argument Digit")
(keybind M-9 "Argument Digit")
(keybind "M-;" "Indent for Comment")
(keybind M-< "Goto Beginning")
(keybind M-> "Goto End")
(keybind M-[ "Backward Paragraph")
(keybind "M-\" "Delete Horizontal Space")
(keybind M-] "Forward Paragraph")
(keybind M-B "Backward Word")
(keybind M-C "Uppercase Initial")
(keybind M-D "Kill Word")
(keybind M-F "Forward Word")
(keybind M-G "Fill Region")
(keybind M-H "Mark Paragraph")
(keybind M-I "Indent Relative") ; E+G: (*) Tab to Tab Stop
(keybind M-L "Lowercase Word")
(keybind M-M "Back to Indentation")
(keybind M-N "Next Line") ; E:(*); G:(* forward-line) -
(keybind M-O "VT100 button hack") ; ELLE. E+G: () -
(keybind M-P "Previous Line") ; E:(*); G:() -
(keybind M-Q "Fill Paragraph")
(keybind M-T "Transpose Words")
(keybind M-U "Uppercase Word")
(keybind M-V "Previous Screen")
(keybind M-W "Copy Region")
(keybind M-Y "Un-kill Pop")
(keybind M-~ "Buffer Not Modified")
(keybind M-DEL "Backward Kill Word")
; Extended commands
(keybind X-^B "List Buffers")
(keybind X-^C "Write File Exit") ; ELLE (ima). E:()-; G: (= save-buffers-kill-emacs)
(keybind X-^E "Write Region") ; E:(*)-; G:(*) eval-last-sexp
(keybind X-^F "Find File")
(keybind X-^K "Write Last Kill") ; ELLE (mnx). E+G:()-
(keybind X-^L "Lowercase Region")
(keybind X-^M "EOL CRLF Mode") ; ELLE. E+G: ()-
(keybind X-^O "Delete Blank Lines")
(keybind X-^P "Set Profile") ; ELLE. E+G: () Mark Page
(keybind X-^R "Read File")
(keybind X-^S "Save File")
(keybind X-^U "Uppercase Region")
(keybind X-^V "Visit File")
(keybind X-^W "Write File")
(keybind X-^X "Exchange Point and Mark")
(keybind X-^Z "Return to Superior") ; G:() suspend-emacs
(keybind X-! "Push to Inferior") ; ELLE. E:(*)-; G:()-
(keybind X-$ "Replace in Line") ; ELLE (mnx). E+G:()-
(keybind X-% "Replace String") ; E+G: (*) -
(keybind "X-(" "Start Kbd Macro")
(keybind "X-)" "End Kbd Macro")
(keybind X-* "View Kbd Macro") ; E: (*)-; G: ()-
(keybind X-. "Set Fill Prefix")
(keybind X-0 "Delete Window") ; E: ()-
(keybind X-1 "One Window")
(keybind X-2 "Two Windows")
(keybind X-8 "Standout Window") ; ELLE. E+G:()-
(keybind X-9 "Two Mode Windows") ; ELLE. E+G:()-
(keybind X-= "What Page") ; E+G: (*) What Cursor Position
(keybind X-^ "Grow Window")
(keybind X-B "Select Buffer")
(keybind X-E "Execute Kbd Macro")
(keybind X-F "Set Fill Column")
(keybind X-I "Insert File") ; E: (*) Info
(keybind X-K "Kill Buffer")
(keybind X-O "Other Window")
(keybind X-S "Save All Files") ; E:(*)-; G:(= save-some-buffers)
(keybind X-T "Auto Fill Mode") ; E:(*) Transpose Regions; G:(*)-
(keybind X-DEL "Backward Kill Line") ; ELLE(ico) E+G:() Backward Kill Sentence
; IMAGEN-specific functions, not bound.
;(keybind "" "Text Mode") ; IMAGEN E:(*); G:(*)
;(keybind "" "Execute Unix Command") ; IMAGEN E:(); G:(M-! shell-command)
;(keybind "" "Execute Make") ; IMAGEN E:(* Compile); G:(* compile)
;(keybind "" "Find Next Error") ; IMAGEN E:(); G:(X-` next-error)
; SUN Mouse functions, for menuitem selection.
;(menuitem "Stuff Selection") ; SUN
;(menuitem "Select Region") ; SUN
; Forget completely about these.
;(keybind "" "ICO Extend Command") ; ICONOGRAPHICS
;(keybind "" "ICO Typeset Funs") ; ICONOGRAPHICS
;(keybind "" "ICO Spec Input Funs") ; ICONOGRAPHICS

View file

@ -1,47 +0,0 @@
/* ELLE - Copyright 1985, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEBIT Bit Array functions
*/
#include "sb.h"
/* Char-bit array functions. All assume that there are at least 8 bits
* in a byte, and that the number of bytes per word is a power of 2.
*/
/* CHBBITS represents log 2 of the # of bits stored per chbit-array word.
* WDBITS already has log2 of the # of bytes per word, and we are
* assuming each byte has at least 8 bits, so log2(8) = 3.
*/
#define CHBSIZE (WDSIZE*8) /* # bits per word */
#define CHBBITS (WDBITS+3) /* log2(CHBSIZE) */
#define CHBMASK (CHBSIZE-1)
#define CHBARYSIZ (128/CHBSIZE) /* # words per ASCII array */
/* CHBALLOC(size) - Allocates a char-bit array */
int *
chballoc(size)
int size;
{ return((int *)calloc((size + CHBSIZE-1)/CHBSIZE, (sizeof(int))));
}
/* CHBIT(array, char) - Tests bit in char-bit array
*/
chbit(array,c)
register int *array, c;
{ return(array[c >> CHBBITS] & (1 << (c & CHBMASK)));
}
/* CHBIS (array, char) - Sets bit in char-bit array
*/
chbis(array,c)
register int *array, c;
{ array[c >> CHBBITS] |= (1 << (c & CHBMASK));
}
/* CHBIC (array, char) - Clears bit in char-bit array
*/
chbic(array,c)
register int *array, c;
{ array[c >> CHBBITS] &= ~(1 << (c & CHBMASK));
}

File diff suppressed because it is too large Load diff

View file

@ -1,321 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EECMDS Command table lookup and profile code
*/
#include "elle.h"
#include "eeproto.h"
/* Function table, see the included file for explanation. */
/* First must pre-declare function addrs */
#if 0
#define EFUN(rtn,rtnstr,name) int rtn();
#define EFUNHOLE
#include "eefdef.h"
#endif
/* Now re-insert to define function table */
typedef int (*eefunc)();
eefunc funtab[] =
{
#undef EFUN /* Avoid redefinition error message */
#undef EFUNHOLE
#define EFUN(rtn,rtnstr,name) (eefunc) rtn,
#define EFUNHOLE 0,
#include "eefdef.h"
};
int funmax = sizeof(funtab)/sizeof(funtab[0]); /* 1st illegal function # */
/* Insert default command char map tables and profile structure */
#include "defprf.c"
/* EFUN: "Prefix Meta" */
/* Meta-prefix command.
* For now, very simple. Perhaps later try to hair up with
* time-out "M-" prompt?
*/
f_pfxmeta()
{ return(cmd_xct(cmd_read()|CB_META));
}
/* EFUN: "Prefix Extend" */
/* Extended-prefix command.
* Likewise trivial; perhaps later hair up with timeout "^X-" prompt?
*/
f_pfxext()
{ return(cmd_xct(cmd_read()|CB_EXT));
}
/* EFUN: "Universal Arg" */
/* This routine is also called by "Argument Digit" with a special arg
* of -1 in order to share code. Since that invocation always sets unrchf,
* it should always complete at least one digit read loop.
* Note that exp and exp_p are set to 1 and 0 at the top-level command
* loop.
*/
f_uarg(ch)
int ch;
{ register int c, oc, i;
/* Set distinguishing exp_p value depending on whether invoked
* by CTRL-U or another function (Argument Digit, Negative Argument)
*/
exp_p = (ch < 0) ? 1 : 4;
i = 0; /* Read numerical arg if any follows */
for(;;)
{ oc = cmd_read(); /* Get next input char */
c = oc & 0177;
if(c == '-' && !i)
{ exp_p = -1;
exp = 1; /* Set in case no digits follow */
}
else if('0' <= c && c <= '9') /* If it's a digit too, */
{ i = (i * 10) + c - '0'; /* add digit in. */
if(exp_p >= 0) exp_p = 1;
exp = i;
}
else break;
}
exp *= exp_p; /* Multiply arg appropriately */
unrchf = oc; /* Not a digit, re-read it next. */
this_cmd = ARGCMD;
}
/* EFUN: "Negative Argument" */
f_negarg(ch)
int ch;
{ f_uarg(-1); /* Invoke code from Universal Arg */
exp = -exp;
}
/* EFUN: "Argument Digit" */
f_argdig(ch)
int ch;
{ unrchf = ch; /* Re-read the digit */
f_uarg(-1); /* Invoke code from Universal Arg */
}
/* EFUN: "Set Profile" */
/* Asks for a profile file and sets profile from it.
*/
f_setprof()
{ hack_file("Set Profile: ", set_profile);
}
#if FX_VTBUTTONS
/* EFUN: "VT100 Button Hack" */
/* This must be bound to Meta-O if anything, because the VT100 sends
* an ESC O prefix when the function buttons are used.
*/
f_vtbuttons () /* vt100 function buttons */
{
switch(cmd_read())
{ case ('A'):
return (f_uprline ());
case ('B'):
return (f_dnrline ());
case ('C'):
return (f_fword ());
case ('D'):
return (f_bword ());
case ('Q'): /* PF1 */
return (f_kregion());
default:
ring_bell ();
break;
}
}
#endif /*FX_VTBUTTONS*/
/* CMD_WAIT() - Return TRUE if any command input waiting.
*/
cmd_wait()
{ return(unrchf >= 0
#if FX_SKMAC
|| km_inwait() /* Check for kbdmac input waiting */
#endif /*FX_SKMAC*/
|| tinwait());
}
/* CMD_READ() - Read a command (single char) from user, and return it.
*/
cmd_read()
{ register int c;
if((c = unrchf) >= 0) /* Re-reading last char? */
{ unrchf = -1;
return(c);
}
#if FX_SKMAC /* Hacking keyboard macros? */
return(km_getc()); /* Yes. This calls tgetc if no kbd macro */
#else
return(tgetc());
#endif /*-FX_SKMAC*/
}
/* CMD_XCT(ch) - Command Execution dispatch routine.
** Takes char and executes the function (efun) bound to that command key.
*/
cmd_xct(ch)
int ch;
{ register int (*funct) ();
register int c;
int (*(cmd_fun())) ();
if(funct = cmd_fun(c = ch)) /* Get function to run */
return((*funct) (c&0177)); /* Invoke with char arg */
ring_bell(); /* Undefined command char, error. */
}
/* CMD_FUN(ch) - Return function for char, 0 if none
*/
int (*cmd_fun(c))()
int c;
{
return(funtab[cmd_idx(c)]);
}
/* CMD_IDX(ch) - Given command char, return function index for it
*/
cmd_idx(c)
register int c;
{ register char *cp;
register int i;
if(c&CB_EXT)
{ cp = def_prof.extvec;
i = def_prof.extvcnt;
goto inlup;
}
if(c&CB_META)
{ cp = def_prof.metavec;
i = def_prof.metavcnt;
inlup: c = upcase(c);
do { if(*cp++ != c) cp++;
else
{ i = *cp&0377;
break;
}
} while(--i); /* If counts out, will return 0! */
}
else i = def_prof.chrvec[c&0177]&0377;
if(i >= funmax)
return(0);
return(i);
}
/* Profile hacking */
#if TOPS20
#include <sys/file.h> /* for O_BINARY */
#endif
void set_profile(filename)
char *filename;
{ char pfile[200];
register int pfd, len;
chroff sbx_fdlen();
register char *profptr;
struct stored_profile st_prof;
if(filename) strcpy(pfile,filename);
else /* Check for user's profile */
{
strcat(strcat(strcpy(pfile,homedir),"/"),ev_profile);
}
if((pfd = open(pfile,
#if TOPS20
O_BINARY
#else
0
#endif
)) < 0)
{ if(filename)
{ ding("Cannot open file");
}
return;
}
if((len = (int)sbx_fdlen(pfd)) < sizeof(struct stored_profile))
goto badfil;
profptr = memalloc((SBMO)len);
if(read(pfd,profptr,len) != len)
goto badfmt;
/* Have read profile into memory, now set up ptrs etc */
bcopy((SBMA)profptr,(SBMA)&st_prof,sizeof(struct stored_profile));
def_prof.version = prof_upack(st_prof.version);
if(def_prof.version != 1)
goto badfmt;
def_prof.chrvcnt = prof_upack(st_prof.chrvcnt);
def_prof.chrvec = profptr + prof_upack(st_prof.chrvec);
def_prof.metavcnt = prof_upack(st_prof.metavcnt);
def_prof.metavec = profptr + prof_upack(st_prof.metavec);
def_prof.extvcnt = prof_upack(st_prof.extvcnt);
def_prof.extvec = profptr + prof_upack(st_prof.extvec);
#if SUN
def_prof.menuvcnt = prof_upack(st_prof.menuvcnt);
def_prof.menuvec = profptr + prof_upack(st_prof.menuvec);
#endif /*SUN*/
goto done;
badfmt: chkfree(profptr);
badfil: ding("Bad profile format");
done: close(pfd);
}
#if SUN
/* SUN Menu profile hacking.
* This is here, instead of e_sun.c, because
* the profile format is still evolving and for the time being I want to
* keep all profile-hacking code in one place. --KLH
*/
#include "suntool/tool_hs.h"
#include "suntool/menu.h"
#define MENUMAX 16
/* Defined in eesun.c */
extern struct menu *menuptr;
extern struct menu menu;
char *funamtab[] = {
#undef EFUN
#undef EFUNHOLE
#define EFUN(rtn,rtnstr,name) name,
#define EFUNHOLE 0,
#include "eefdef.h"
};
init_menu() /* initialize the menu for elle from user profile */
{
register struct menuitem *mi;
register int n, i, fni;
if((n = def_prof.menuvcnt) <= 0)
return;
if(n > MENUMAX) n = MENUMAX;
mi = menu.m_items = (struct menuitem *) calloc(n, sizeof *mi);
menu.m_itemcount = 0;
for(i = 0; i < n; i++)
{ fni = def_prof.menuvec[i]&0377;
if(fni >= funmax) continue;
if(funtab[fni] && funamtab[fni])
{ mi->mi_data = (caddr_t) funtab[fni];
mi->mi_imagedata = (caddr_t) strdup(funamtab[fni]);
mi->mi_imagetype = MENU_IMAGESTRING;
mi++;
menu.m_itemcount++;
}
}
if(menu.m_itemcount)
menuptr = &menu;
}
#endif /*SUN*/

View file

@ -1,351 +0,0 @@
/* ELLE - Copyright 1982, 1985, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEDIAG - Error diagnostics and testing routines
*/
#include "elle.h"
#if FX_DEBUG
/* EFUN: "Debug Mode" */
/* With no arg, toggles self-checking on and off.
* With arg of 4 (^U), enters special debug/diagnostics mode.
*/
f_debug(ch)
int ch;
{ extern int (*vfy_vec)(); /* In E_MAIN.C */
char *vfy_data();
if(ch < 0) /* Internal call? */
{ dbg_diag();
return;
}
if(exp == 4)
{ askerr();
return;
}
if(vfy_vec) vfy_vec = 0; /* Toggle current value */
else vfy_vec = (int (*)())vfy_data;
say(vfy_vec ? "Self-checking on" : "Self-checking off");
}
char *
vfy_data(flag) /* Flag = 0 for quiet check */
int flag;
{
register char *res, *mess;
if(res = sbe_mvfy()) mess = "Mem mgt";
else if(res = sbe_sbvfy(cur_buf)) mess = "SBBUF";
else if(res = sbe_svfy()) mess = "SD list";
else return(0); /* Success */
if(flag)
{ int ostate = clean_exit();
printf("\n%s error: %s !!!\n",mess,res);
askerr();
if(ostate > 0) set_tty();
}
return(res); /* Error seen */
}
extern char *asklin();
extern int sbx_nfl,sbm_nfl;
char diaghelp[] = "\
Q - Quit diag mode\n\
! - Goto subshell\n\
V - Verify Mem & SD lists\n\
MF - Mem Freelist\n\
M - Mem list\n\
B - Current buffer SB\n\
DF - SD Freelist\n\
D - SDs in use\n\
DL - SD Logical lists\n\
DP - SD Physical lists\n\
C n - Compact; 0-7=sbx_comp(n), 8=SM freelist, 9=SD freelist.\n\
W - Window printout\n\
X n - Xercise randomly (GC every n)\n\
Z n - like X but with notes\n";
dbg_diag()
{ register char *cp;
register int c;
char linbuf[100];
char *sbe_mfl();
char *sbe_sfl();
char *sbe_sbs();
char *sbe_sdlist();
for(;;)
{ printf("D>");
asklin(cp = linbuf); /* Read a line of input */
switch(upcase(*cp++))
{
case '?':
writez(1,diaghelp); /* Too long for printf */
continue;
case '!':
f_pshinf(); /* Invoke inferior subshell */
clean_exit(); /* Restore normal modes */
continue;
case 'Q': /* Quit */
return;
case 'B': /* Print current SBBUF */
sbe_sbs(cur_buf,1);
continue;
case 'C': /* C n - Compact */
c = atoi(&linbuf[1]);
if(c == 8)
sbm_ngc(); /* GC the SM nodes */
#if 0 /* This doesn't work, dangerous to invoke. */
else if(c == 9)
sbm_xngc(&sbx_nfl,sizeof(struct sdblk),
SM_DNODS);
#endif
else
sbx_comp(512,c);
continue;
case 'D': /* Print all SD blocks in mem order */
switch(upcase(*cp))
{
case 0: /* D - all SDs in mem order */
sbe_sds();
continue;
case 'F': /* DF - SD freelist */
sbe_sfl(1);
continue;
case 'L': /* DL - SD logical list */
sbe_sdlist(1,0);
continue;
case 'P': /* DP - SD physical list */
sbe_sdlist(1,1);
continue;
}
break; /* failure */
case 'M':
switch(upcase(*cp))
{
case 0: /* M - all mem alloc info */
sbe_mem();
continue;
case 'F': /* MF - mem freelist */
sbe_mfl(1);
continue;
}
break; /* failure */
case 'V': /* Verify */
if(cp = vfy_data(0))
printf(" Failed: %s\n",cp);
else printf(" OK\n");
continue;
case 'W': /* Print out current window */
db_prwind(cur_win);
continue;
case 'X': /* Xercise */
c = atoi(&linbuf[1]);
vfy_exer(0, c ? c : 100);
continue;
case 'Z': /* Zercise */
c = atoi(&linbuf[1]);
vfy_exer(1, c ? c : 100);
continue;
} /* End of switch */
printf("?? Type ? for help\n");
} /* Loop forever */
}
/* VFY_EXER - a "random" editor exerciser. It creates a buffer,
* fills it with some patterned stuff, and then edits it
* pseudo-randomly in ways which retain the basic pattern.
* Frequent GC's and self-checks are done, and execution
* halted either when an error is seen or when typein is detected.
*/
char *xer_strs [] = {
"throne", "too", "sky", "fore", "fingers", "sex", "stone",
"010", "nazgul", "base"
};
vfy_exer(pf, gcfrq)
int pf; /* Nonzero to print notes as we go */
int gcfrq; /* Frequency of GC invocation (# passes per GC) */
{ register int i, k, c;
long npass;
char *res, linbuf[100];
chroff lbeg, lend;
struct buffer *bfp, *make_buf();
/* Clean out kill buffer first */
for(i = 0; i < KILL_LEN; ++i)
kill_push((SBSTR *)0);
bfp = make_buf("**EXORCISE**");
chg_buf(bfp);
i = 2000;
e_gobol();
do {
ed_sins("Line ");
ed_sins(xer_strs[i%10]);
e_putc(LF);
} while(--i);
if(pf) printf("Bufflen: %ld\n", e_blen());
/* Buffer now has stuff in it, start hacking. */
npass = 0;
srand(1); /* Start random seed */
for(;;)
{ if(tinwait() && (*asklin(linbuf)))
{ printf("Typein stop.\n");
break;
}
++npass;
printf(" Pass %ld",npass);
if(npass%gcfrq == 0) /* Time to do a GC? */
{
i = rand(); /* Level between 0-4 */
i = (i < 0 ? -i : i) % 5;
printf(" - GC lev %d\n", i);
sbx_comp(512,i);
goto xerchk;
}
k = (i = rand())%1024;
if (i&020000) k = -k;
e_igoff(k); /* Move randomly */
e_gobol(); /* Get stuff to flush */
lbeg = e_dot();
k = (i = rand())%64;
if(i&010000) k = -k;
e_igoff(k);
lend = e_nldot();
if(pf) printf(" Kill %ld/ %d;", lbeg, k);
ed_kill(lbeg, lend);
if(res = vfy_data(0))
{ printf("XERR after kill: %s\n",res);
break;
}
k = (i = rand())%2048;
if(i&04000) k = -k;
e_igoff(k);
e_gobol();
e_setcur();
if(pf) printf(" Yank %ld;", e_dot());
f_unkill(); /* Yank back */
if(res = vfy_data(0))
{ printf("XERR after yank: %s\n",res);
break;
}
last_cmd = YANKCMD;
for(i = rand()%4; i >= 0; --i)
{ if(pf) printf(" Pop;");
f_unkpop(); /* Do meta-Y */
if(res = vfy_data(0))
{ printf("XERR after pop: %s\n",res);
goto out;
}
}
if(rand()&07) /* Slowly add stuff */
{ if(pf) printf(" Add");
ed_sins("Line ");
ed_sins(xer_strs[rand()%10]);
e_putc(LF);
if(res = vfy_data(0))
{ printf("XERR after ins: %s\n",res);
break;
}
}
printf("\n");
/* Okay, done with this pass edits, run through the
* file to ensure pattern is still there
*/
xerchk: e_gobob();
while((c = e_getc()) != EOF)
if(c == LF && (c = e_getc()) != EOF)
{ if( c != 'L'
|| e_getc() != 'i'
|| e_getc() != 'n'
|| e_getc() != 'e'
|| e_getc() != ' ')
{ printf("XERR in pattern!\n");
goto out;
}
}
}
/* User typein or error, stop. */
out: e_setcur();
redp(RD_SCREEN);
printf("Loop count = %ld\n",npass);
}
/* DB_PRWIND(win) - Print out stuff about given window
*/
db_prwind(w)
register struct window *w;
{ register struct scr_line *s;
register int i;
char tstr[MAXLINE+MAXCHAR];
char *db_scflgs();
printf("cur_dot/ %ld cur_buf/ %o cur_win/ %o\n",
cur_dot, cur_buf, cur_win);
printf("Window %o:\n", w);
printf(" next/ %o\n", w->w_next);
printf(" buf / %o\n", w->w_buf);
printf(" redp/ %o\n", w->w_redp);
printf(" topldot/ %ld\n", w->w_topldot);
printf(" dot / %ld\n", w->w_dot);
printf(" bmod/ %ld\n", w->w_bmod);
printf(" emod/ %ld\n", w->w_emod);
printf(" oldz/ %ld\n", w->w_oldz);
printf(" pos / %d\n", w->w_pos);
printf(" ht / %d\n", w->w_ht);
printf("\
# Flags Boff Len ! Cols Line\n");
for(i = w->w_pos; i < w->w_pos + w->w_ht; ++i)
{ s = scr[i];
printf("%2d %-5.5s %6ld %3d %1d %4d ",
i, db_scflgs(s->sl_flg), s->sl_boff, s->sl_len,
s->sl_cont, s->sl_col);
strncpy(tstr, s->sl_line, MAXLINE);
tstr[s->sl_col] = 0;
printf("%-40.40s\n", tstr);
if(s->sl_flg&SL_MOD)
{ printf("%26d ", s->sl_ncol);
strncpy(tstr, s->sl_nlin, MAXLINE);
tstr[s->sl_ncol] = 0;
printf("%-40.40s\n", tstr);
}
}
}
char *
db_scflgs(flags)
int flags;
{ static char retstr[10];
register char *cp;
cp = retstr;
if(flags&SL_MOD) *cp++ = 'M';
if(flags&SL_EOL) *cp++ = 'E';
*cp = 0;
return(retstr);
}
#endif /*FX_DEBUG*/

File diff suppressed because it is too large Load diff

View file

@ -1,717 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEEDIT - E-type routines */
#include "elle.h"
/* E_ - Operate on cur_buf. Do not change value of cur_dot unless
* unavoidable side effect (also e_setcur).
* EX_ - Like E_ but take SB ptr value. Never touch cur_dot.
* ED_ - Like E_, operate on cur_buf, update cur_dot and display stuff.
* D_ - Perform necessary display update for given operations.
*
* Note that "dot" refers to the current read/write pointer for a sbbuffer.
* The name comes from EMACS/TECO where "." represents this value.
*/
#define CURSBB (SBBUF *)cur_buf /* Shorthand for current SB buffer */
e_reset() /* Reset current buffer */
{ ex_reset(CURSBB);
cur_dot = 0;
}
/* Basic functions - apply SB routines to current buffer.
* There is some optimization here which knows that certain SB functions
* are macros.
*/
e_rgetc() /* Read/move 1 char backward */
{ return(sb_rgetc((CURSBB)));
}
e_rdelc() /* Delete 1 char backward */
{ return(sb_rdelc((CURSBB)));
}
e_delc() /* Delete 1 char forward */
{ return(sb_deln(CURSBB,(chroff)1));
}
e_getc() /* Read/move 1 char forward */
{ register SBBUF *sb;
sb = CURSBB; /* Macro: use reg */
return(sb_getc(sb));
}
e_backc() /* Move 1 char backward */
{ register SBBUF *sb;
sb = CURSBB; /* Macro: use reg */
sb_backc(sb); /* No value returned */
}
e_putc(c) /* Insert/write 1 char forward */
char c;
{ register SBBUF *sb;
sb = CURSBB; /* Macro: use reg */
return(sb_putc(sb, c));
}
e_peekc() /* Read 1 char forward (no move) */
{ register SBBUF *sb;
sb = CURSBB; /* Macro: use reg */
return(sb_peekc(sb));
}
e_ovwc(ch) /* Overwrite 1 char forward */
char ch;
{
sb_setovw(CURSBB); /* Turn on overwrite mode */
e_putc(ch);
sb_clrovw(CURSBB); /* Turn off overwrite mode */
}
SBSTR *
e_copyn(off) /* Copy N chars forward/backward, return SD to sbstring */
chroff off;
{ return(sb_cpyn(CURSBB,off));
}
e_deln(off) /* Delete N chars forward/backward */
chroff off;
{ return(sb_deln(CURSBB, off));
}
/* E_SETCUR() - set cur_dot to current position (dot). This is the only
* E_ routine that mungs cur_dot except for e_reset.
*/
e_setcur()
{ cur_dot = e_dot();
}
e_gosetcur(dot) /* Go to specified dot and set cur_dot as well */
chroff dot;
{ sb_seek(CURSBB,dot,0);
e_setcur(); /* Not cur_dot = dot since want canonicalization */
}
/* E_GO(dot) - Move to specified location. */
/* These "GO" routines all move to the location specified, returning
* 0 if successful and -1 on error. "cur_dot" is never changed,
* with the exception of e_gosetcur.
* Note that other "GO" routines (eg E_GONL) will return 1 if successful
* and 0 if stopped by EOF.
*/
e_gocur() { return(e_go(cur_dot)); } /* Move to cur_dot */
e_gobob() { return(e_go((chroff) 0)); } /* Move to Beg Of Buffer */
e_goeob() { return(sb_seek(CURSBB,(chroff)0,2)); } /* Move to End Of Buffer */
e_go(dot) /* Move to specified location. */
chroff dot;
{ return(sb_seek(CURSBB,dot,0));
}
e_igoff(ioff) /* Move (int) N chars forward/backward */
int ioff;
{ return(sb_seek(CURSBB,(chroff)ioff,1));
}
e_goff(off) /* Move (full) N chars forward/backward */
chroff off;
{ return(sb_seek(CURSBB,off,1));
}
int ex_gonl(), ex_gopl(), ex_gobol(), ex_goeol();
e_gobol() { return(ex_gobol(CURSBB)); } /* Move to beg of this line */
e_goeol() { return(ex_goeol(CURSBB)); } /* Move to end of this line */
e_gonl() { return(ex_gonl(CURSBB)); } /* Move to beg of next line */
e_gopl() { return(ex_gopl(CURSBB)); } /* Move to beg of prev line */
/* E_DOT() - Return current value of dot. */
chroff e_dot() { return(sb_tell(CURSBB)); } /* Current pos */
chroff e_nldot() { return(e_alldot(CURSBB,ex_gonl)); } /* Beg of next line */
chroff e_pldot() { return(e_alldot(CURSBB,ex_gopl)); } /* Beg of prev line */
chroff e_boldot(){ return(e_alldot(CURSBB,ex_gobol));} /* Beg of this line */
chroff e_eoldot(){ return(e_alldot(CURSBB,ex_goeol));} /* End of this line */
chroff
e_alldot(sbp,rtn) /* Auxiliary for above stuff */
SBBUF *sbp;
int (*rtn)();
{ return(ex_alldot(sbp,rtn,e_dot()));
}
/* E_BLEN - Return length of current buffer */
chroff
e_blen() { return(ex_blen(CURSBB)); }
/* EX_ routines - similar to E_ but take a buffer/sbbuf argument
* instead of assuming current buffer.
*/
/* EX_RESET - Reset a given buffer */
ex_reset(b)
struct buffer *b;
{ sbs_del(sb_close((SBBUF *)b));
sb_open((SBBUF *)b,(SBSTR *)0);
}
ex_go(sbp,loc) /* Move to given dot in specified sbbuf */
chroff loc;
SBBUF *sbp;
{ return(sb_seek(sbp,loc,0));
}
chroff
ex_dot(sbp) /* Return current position in specified sbbuf */
SBBUF *sbp;
{
return(sb_tell(sbp));
}
chroff
ex_boldot(sbp,dot) /* Return dot for BOL of specified sbbuf */
SBBUF *sbp;
chroff dot;
{ return(ex_alldot(sbp,ex_gobol,dot));
}
chroff
ex_alldot(sbp,rtn,dot) /* Auxiliary for some e_ stuff */
SBBUF *sbp;
int (*rtn)();
chroff dot;
{ register SBBUF *sb;
chroff savloc, retloc;
savloc = sb_tell(sb = sbp);
sb_seek(sb,dot,0);
(*rtn)(sb);
retloc = sb_tell(sb);
sb_seek(sb,savloc,0);
return(retloc);
}
/* GO (forward) to Next Line of specified sbbuf - returns 0 if stopped at EOF
* before an EOL is seen. */
ex_gonl(sbp)
SBBUF *sbp;
{ register SBBUF *sb;
register int c;
sb = sbp;
#if FX_EOLMODE
if(eolcrlf(sb))
while((c = sb_getc(sb)) != EOF)
{ if(c == LF) /* Possible EOL? */
{ sb_backc(sb); /* See if prev char was CR */
if((c = sb_rgetc(sb)) != EOF)
sb_getc(sb);
sb_getc(sb); /* Must restore position */
if(c == CR) /* Now test for CR */
return(1); /* Won, CR-LF! */
}
}
else
#endif
while((c = sb_getc(sb)) != EOF)
if(c == LF)
return(1);
return(0);
}
/* GO (forward) to End Of Line of specified sbbuf - returns 0 if stopped at
* EOF before an EOL is seen. */
ex_goeol(sbp)
SBBUF *sbp;
{ register SBBUF *sb;
register int c;
sb = sbp;
#if FX_EOLMODE
if(eolcrlf(sb))
while((c = sb_getc(sb)) != EOF)
{ if(c == LF) /* Possible EOL? */
{ sb_backc(sb); /* See if prev char was CR */
if((c = sb_rgetc(sb)) == CR)
return(1); /* Won, CR-LF! */
if(c != EOF) /* No, must restore position */
sb_getc(sb); /* Skip over */
sb_getc(sb); /* Skip over LF */
}
}
else
#endif
while((c = sb_getc(sb)) != EOF)
if(c == LF)
{ sb_backc(sb);
return(1);
}
return(0);
}
/* GO (backward) to Beg Of Line of specified sbbuf - returns 0 if stopped
* at EOF
*/
ex_gobol(sbp)
SBBUF *sbp;
{ register SBBUF *sb;
register int c;
sb = sbp;
#if FX_EOLMODE
if(eolcrlf(sb))
while((c = sb_rgetc(sb)) != EOF)
{ if(c == LF) /* Possible EOL? */
{ if((c = sb_rgetc(sb)) == CR)
{ sb_getc(sb); /* Won, CR-LF! */
sb_getc(sb); /* Move back */
return(1);
}
if(c != EOF) /* No, must restore position */
sb_getc(sb); /* Undo the rgetc */
}
}
else
#endif
while((c = sb_rgetc(sb)) != EOF)
if(c == LF)
{ sb_getc(sb);
return(1);
}
return(0);
}
/* GO (backward) to Previous Line of specified sbbuf - returns 0 if stopped
* at EOF before an EOL is seen (i.e. if already on 1st line of buffer)
*/
ex_gopl(sbp)
SBBUF *sbp;
{ register SBBUF *sb;
register int c;
sb = sbp;
#if FX_EOLMODE
if(eolcrlf(sb))
while((c = sb_rgetc(sb)) != EOF)
{ if(c == LF) /* Possible EOL? */
{ if((c = sb_rgetc(sb)) == CR)
{ ex_gobol(sb);
return(1); /* Won! */
}
if(c != EOF) /* No, must restore position */
sb_getc(sb); /* Undo the rgetc */
}
}
else
#endif
while((c = sb_rgetc(sb)) != EOF)
if(c == LF)
{ ex_gobol(sb);
return(1); /* Won! */
}
return(0);
}
chroff
ex_blen(sbp) /* Return length of specified sbbuf */
SBBUF *sbp;
{
return(sb_tell(sbp)+sb_ztell(sbp));
}
/* Miscellaneous stuff */
/* E_GOFWSP() - Forward over whitespace */
e_gofwsp()
{ register int c;
while((c = e_getc()) == SP || c == TAB);
if(c != EOF) e_backc();
}
/* E_GOBWSP() - Backward over whitespace */
e_gobwsp()
{ register int c;
while((c = e_rgetc()) == SP || c == TAB);
if(c != EOF) e_getc();
}
/* E_GOLINE(n) - Goes N lines forward (or backward).
** If N == 0, goes to beginning of current line.
** Returns 0 if hit EOF.
*/
e_goline(i)
register int i;
{
if(i > 0)
{ do { if(!e_gonl()) return(0); }
while(--i);
}
else if(i < 0)
{ i = -i;
do { if(!e_gopl()) return(0); }
while(--i);
}
else e_gobol(); /* arg of 0 */
return 1;
}
/* E_LBLANKP() - Returns true if all characters in rest of line are blank.
* Moves to beginning of next line as side effect, unless fails.
*/
e_lblankp()
{ register int c;
for(;;) switch(e_getc())
{
case SP:
case TAB:
continue;
case LF: /* Normally drop thru to return 1 as for EOF */
#if FX_EOLMODE
if(eolcrlf(cur_buf))
{ e_rgetc();
if((c = e_rgetc()) != EOF) /* Get prev char */
e_getc();
e_getc();
if(c != CR) /* Now examine */
continue; /* Not CR-LF, go on */
} /* Else drop thru to return win */
#endif
case EOF:
return(1);
default:
return(0);
}
/* Never drops out */
}
e_insn(ch, cnt)
int ch;
int cnt;
{ register int i;
if((i = cnt) > 0)
do { e_putc(ch);
} while(--i);
}
e_sputz(acp)
char *acp;
{ register SBBUF *sb;
register char *cp;
register int c;
if(cp = acp)
{ sb = CURSBB;
while(c = *cp++)
sb_putc(sb,c);
}
}
/* BOLEQ - Returns TRUE if 2 dots are on the same line
* (i.e. have the same Beg-Of-Line)
*/
boleq(dot1,dot2)
chroff dot1,dot2;
{ return( (ex_boldot(CURSBB,dot1) == ex_boldot(CURSBB,dot2)));
}
char *
dottoa(str,val)
char *str;
chroff val;
{ register char *s;
s = str;
if(val < 0)
{ *s++ = '-';
val = -val;
}
if(val >= 10)
s = dottoa(s, val/10);
*s++ = '0' + (int)(val%10);
*s = 0;
return(s);
}
/* Paragraph utilities */
#if FX_FPARA || FX_BPARA || FX_MRKPARA || FX_FILLPARA
#if FX_SFPREF
extern char *fill_prefix; /* Defined in eefill.c for now */
extern int fill_plen; /* Ditto */
#endif /*FX_SFPREF*/
#if ICONOGRAPHICS
int para_mode = PARABLOCK; /* eexcmd.c only other file that refs this */
#endif /*ICONOGRAPHICS*/
/* Go to beginning of paragraph */
e_gobpa()
{ register int c;
chroff savdot;
savdot = e_dot();
e_bwsp();
while((c = e_rgetc()) != EOF)
if(c == LF) /* Went past line? */
{ e_getc(); /* Back up and check */
#if FX_SFPREF
if(fill_plen)
if(tstfillp(fill_plen))
{ e_igoff(-(fill_plen+1));
continue;
}
else break;
#endif /*FX_SFPREF*/
#if ICONOGRAPHICS
c = e_peekc ();
if (para_mode == PARABLOCK)
if (c == LF)
break;
if (para_mode == PARALINE)
if (c_wsp (c))
break;
#else
if(c_pwsp(e_peekc())) /* Check 1st chr for wsp */
break; /* If wsp, done */
#endif /*ICONOGRAPHICS*/
e_rgetc(); /* Nope, continue */
}
if((c = e_peekc()) == '.' || c == '-')
{ e_gonl();
if(e_dot() >= savdot)
e_gopl();
}
}
/* Go to end of paragraph */
e_goepa()
{ register int c;
e_gobol(); /* First go to beg of cur line */
e_fwsp();
while((c = e_getc()) != EOF)
if (c == LF)
{
#if FX_SFPREF
if(fill_plen) /* If Fill Prefix is defined */
if(tstfillp(fill_plen)) /* then must start with it */
continue;
else break; /* or else we're done */
#endif /*FX_SFPREF*/
#if ICONOGRAPHICS
if (para_mode == PARABLOCK)
if (e_peekc () == LF)
break;
if (para_mode == PARALINE)
if (c_wsp (e_peekc ()))
break;
#else
if(c_pwsp(e_peekc()))
break;
#endif /*-ICONOGRAPHICS*/
}
}
exp_do(rpos, rneg)
int (*rpos)(), (*rneg)();
{ register int e;
register int (*rtn)();
if((e = exp) == 0)
return;
rtn = rpos;
if(e < 0)
{ rtn = rneg;
e = -e;
}
do { (*rtn)();
} while(--e);
}
e_fwsp()
{ register int c;
while(c_wsp(c = e_getc()));
if(c != EOF) e_backc();
}
e_bwsp()
{ register int c;
while(c_wsp(c = e_rgetc()));
if(c != EOF) e_getc();
}
c_wsp(ch)
int ch;
{ register int c;
c = ch;
if(c == SP || c == TAB || c == LF || c == FF)
return(1);
return(0);
}
c_pwsp(ch)
int ch;
{ register int c;
c = ch;
if(c == '.' || c == '-')
return(1);
return(c_wsp(c));
}
#endif /* FX_FPARA || FX_BPARA || FX_MRKPARA || FX_FILLPARA */
/* Word function auxiliaries */
/* Returns true if this character is a delimiter. */
delimp(c)
int c;
{ static int delim_tab[] =
{
0177777, 0177777, /* All controls */
0177777, 0176000, /* All punct but 0-9 */
0000001, 0074000, /* All punct but A-Z and _ */
0000001, 0174000 /* All punct but a-z */
};
return (delim_tab[c >> 4] & (1 << (c & 017)));
}
e_wding(adot,n)
register chroff *adot;
int n;
{ chroff savdot;
savdot = e_dot();
e_gowd(n);
*adot = e_dot();
e_go(savdot);
if(*adot == savdot)
{ ring_bell();
return(0);
}
return(1);
}
chroff
e_wdot(dot,n)
chroff dot;
int n;
{ chroff savdot, retdot;
savdot = e_dot();
e_go(dot);
e_gowd(n);
retdot = e_dot();
e_go(savdot);
return(retdot);
}
e_gowd(n)
int n;
{ register int (*gch)(), c, cnt;
int e_getc(), e_rgetc();
chroff ret_dot;
if((cnt = n) == 0)
return;
if(cnt > 0)
gch = e_getc; /* Forward routine */
else
{ gch = e_rgetc; /* Backward routine */
cnt = -cnt;
}
do
{ ret_dot = e_dot(); /* Remember dot for last word found */
while((c = (*gch)()) != EOF && delimp(c));
if(c == EOF)
{ e_go(ret_dot); /* Use last word found */
break;
}
while((c = (*gch)()) != EOF && !delimp(c));
if(c == EOF)
break;
if(n < 0) e_getc(); else e_backc();
} while(--cnt);
}
/* Searching */
e_search(mstr,mlen,backwards)
char *mstr;
int mlen;
int backwards;
{ register SBBUF *sb;
register char *cp;
register int c;
char *savcp;
int cnt, scnt;
#if IMAGEN
register int c1;
register int caseless = (cur_buf->b_flags & B_TEXTMODE);
#endif /*IMAGEN*/
sb = (SBBUF *) cur_buf;
if (!backwards)
{ /* Search forwards */
sfwd: cp = mstr;
while((c = sb_getc(sb)) != EOF)
{
#if IMAGEN
if((!caseless && c != *cp) ||
(caseless && upcase(c) != upcase(*cp))) continue;
#else
if(c != *cp) continue;
#endif /*-IMAGEN*/
cp++;
cnt = mlen;
while(--cnt > 0)
{
#if IMAGEN
c1 = *cp++;
c = e_getc();
if ((!caseless && c1 != c) ||
(caseless && upcase(c1) != upcase(c)))
#else
if(*cp++ != (c = e_getc()))
#endif /*-IMAGEN*/
{ if(c == EOF) return(0);
sb_seek(sb,(chroff)(cnt-mlen),1);
goto sfwd;
}
}
return(1);
}
}
else
{ /* Search backwards */
scnt = mlen - 1;
savcp = mstr + scnt; /* Point to end of string */
sbck: cp = savcp;
while((c = sb_rgetc(sb)) != EOF)
{
#if IMAGEN
if((!caseless && c != *cp) ||
(caseless && upcase(c) != upcase(*cp))) continue;
#else
if(c != *cp) continue;
#endif /*-IMAGEN*/
cp--;
if((cnt = scnt) == 0) return(1);
do
{
#if IMAGEN
c1 = *cp--;
c = e_rgetc();
if ((!caseless && c1 != c) ||
(caseless && upcase(c1) != upcase(c)))
#else
if(*cp-- != (c = e_rgetc()))
#endif /*-IMAGEN*/
{ if(c == EOF) return(0);
sb_seek(sb,(chroff)(mlen-cnt),1);
goto sbck;
}
}
while(--cnt);
return(1);
}
}
return(0); /* Failed */
}

View file

@ -1,183 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEERR - Error handling & testing routines
*/
#include "elle.h"
#if V6
#include "eesigs.h"
#else
#include <signal.h>
#endif
/* EFUN: "Hit Breakpoint" */
f_bkpt()
{ clean_exit();
bpt();
set_tty();
}
bpt() {} /* Put a DDT/ADB breakpoint here */
#if !(STRERROR) /* If strerror() not supported, we provide it. */
extern int sys_nerr; /* Max index into sys_errlist */
extern char *sys_errlist[];
char *
strerror(num)
int num;
{
static char badbuf[30];
if (num > 0 && num <= sys_nerr)
return (sys_errlist[num]);
sprintf(badbuf, "unknown error %d", num);
return badbuf;
}
#endif /* -STRERROR */
errsbm(type,adr,str,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
register int type; /* Type, flags */
int (*adr)(); /* Addr called from */
char *str; /* Printf string */
{ register struct buffer *b;
int oldttystate;
oldttystate = clean_exit(); /* Ensure not in editing mode */
if(type == SBFERR) /* File overwrite error? A0 is FD */
{ printf("WARNING - FILE CORRUPTED!\nBuffers affected:\n");
for(b = buf_head; b; b = b->b_next)
{ if(sb_fdinp((SBBUF *)b, a0))
printf((b->b_fn ? " %s: %s\n" : " %s\n"),
b->b_name, b->b_fn);
}
if (oldttystate > 0) set_tty();
return(1); /* Try to continue normally */
}
printf("%sERR: %o ", (type ? "SBX" : "SBM"), adr);
printf(str,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
askerr();
}
/*
* Bite_bag -- Try to save our rear ends after a catastrophe.
* This routine is mainly called from "interrupt"
* level when a memory fault or bus error occurs.
* We try to save the buffer to the file "ELLE.crash"
* in the current working directory. If it loses, well
* then you have really lost. Note: this routine does
* not reset the appropriate signal handler, so it is
* never re-entered. If a fault repeats once in this
* code, then the world dies.
*/
bite_bag(fault) /* We come here on any memory error */
int fault;
{
int ostate;
/* Some systems, such as BSD4.x and SUN, do not reset caught signals
* to SIG_DFL.
* This is a win, but isn't what vanilla UNIX code expects.
* Since it doesn't hurt to do it explicitly, we always turn it off
* explicitly...
*/
signal(fault, SIG_DFL); /* Reinstate default handling */
ostate = clean_exit(); /* Fix up the terminal modes first! */
printf("ELLE stopped by fatal interrupt (%d)!\n\
Type S or W to try saving your work.\n",fault);
askerr();
if(ostate > 0) set_tty();
signal(fault, bite_bag); /* If continued, re-enable signal */
}
/* HUP_EXIT - Called by a SIGHUP hangup signal.
* Tries to save all modified buffers before exiting.
* Note that the TTY is not touched at all, although the terminal mode
* flag is set just in case further error handling routines are invoked.
*/
hup_exit()
{ extern int trm_mode; /* See e_disp.c */
trm_mode = -1; /* Say TTY is now detached */
saveworld((struct buffer *)0, 0); /* Save world, w/o feedback */
exit(1);
}
errint() /* Routine provided for ADB jumps */
{ askerr();
}
char askh1[] = "\
A - Abort process\n\
B - Breakpoint (must have \"bpt:b\" set in ADB)\n\
C - Continue\n\
D - Diagnostic command mode\n";
char askh2[] = "\
S - Try to save current buffer\n\
W - Try to save world (all modified buffers)\n";
int bsaving = 0; /* Set while in middle of saving buffer(s) */
askerr()
{ register struct buffer *b;
char linbuf[100];
char *asklin();
extern int (*funtab[])(); /* In E_CMDS.C */
int ostate;
ostate = clean_exit(); /* Clean up TTY if not already done */
reask:
printf("(A,B,C,D,S,W,?)");
switch(upcase(*asklin(linbuf)))
{
case '?':
writez(1,askh1); /* Too long for &$@! printf */
writez(1,askh2); /* Too long for &$@! V6 C */
break; /* optimizer (/lib/c2) */
case 'A':
abort();
break;
case 'B':
bpt();
break;
case 'Q':
case 'C':
goto done;
case 'D':
if(funtab[FN_DEBUG])
(*funtab[FN_DEBUG])(-1);
else printf("Sorry, no diagnostics\n");
break;
case 'S': /* Try to save current buffer only */
b = cur_buf;
goto savb;
case 'W': /* Try to save all modified buffers */
b = 0;
savb: if(bsaving++)
{ printf("Already saving -- continued");
goto done;
}
saveworld(b, 1); /* Save, with feedback */
bsaving = 0;
break;
}
goto reask;
done:
if(ostate > 0)
set_tty();
}
char *
asklin(acp)
char *acp;
{ register char *cp;
register int c;
cp = acp;
while((c = tgetc()) != LF)
*cp++ = c;
*cp++ = 0;
return(acp);
}

View file

@ -1,278 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEF1 Various functions
* Char move/ins/del
* Case change
* Char/word transpose
*/
#include "elle.h"
/* EFUN: "Insert Self" */
f_insself (c)
int c;
{
#if IMAGEN
fim_insself(c);
#else
#if FX_FILLMODE
extern int fill_mode;
if(fill_mode) fx_insfill(c);
else
#endif /*FX_FILLMODE*/
ed_insn(c, exp); /* Normal stuff */
#endif /*-IMAGEN*/
}
/* EFUN: "Quoted Insert"
** Inserts next char directly, <exp> number of times.
** Does not check anything about the char and does not do anything
** depending on the mode. In particular, CR is not turned into EOL.
*/
f_quotins()
{
ed_insn(cmd_read(), exp); /* Insert next char directly */
}
#if FX_CRLF
/* EFUN: "CRLF" */
f_crlf()
{
#if IMAGEN
fim_crlf();
#else
register int i;
if(e_goeol() == cur_dot /* If at end of current line */
&& exp == 1 /* and inserting only 1 new line */
&& e_lblankp() && e_lblankp()) /* and next 2 lines blank */
{ e_gocur(); /* Then just re-use next line. */
e_gonl(); /* Go to its start */
e_setcur(); /* and establish cur_dot there. */
ed_delete(e_dot(), e_eoldot()); /* Ensure any blanks flushed */
}
else
{ e_gocur(); /* Otherwise back to original place */
if((i = exp) > 0) /* and simply insert newlines */
do ed_crins();
while(--i);
}
#endif /*-IMAGEN*/
}
#endif /*FX_CRLF*/
/* EFUN: "Forward Character" */
f_fchar()
{ ed_igoff(exp);
}
/* EFUN: "Backward Character" */
f_bchar()
{ ed_igoff(-exp);
}
/* EFUN: "Delete Character" */
f_dchar ()
{
#if IMAGEN
fim_dchar();
#else
ef_deln(exp);
#endif /*-IMAGEN*/
}
/* EFUN: "Backward Delete Character" */
f_bdchar ()
{
#if IMAGEN
fim_bdchar();
#else
ef_deln(-exp);
#endif /*-IMAGEN*/
}
/* Delete forward or backward N characters.
* If arg, kills instead of deleting.
*/
ef_deln(x)
int x;
{
e_igoff(x);
if(exp_p) ed_kill(cur_dot, e_dot());
else ed_delete(cur_dot, e_dot());
}
#if FX_DELSPC
/* EFUN: "Delete Horizontal Space" */
/* Delete spaces/tabs around point.
*/
f_delspc()
{ chroff dot1;
e_gobwsp(); /* Move backward over whitespace */
dot1 = e_dot(); /* Save point */
e_gofwsp(); /* Move forward over whitespace */
ed_delete(dot1,e_dot()); /* Delete twixt start and here */
}
#endif /*FX_DELSPC*/
#if FX_TCHARS
/* EFUN: "Transpose Characters"
* Transpose chars before and after cursor. Doesn't hack args yet.
* EMACS: With positive arg, exchs chars before & after cursor, moves right,
* and repeats the specified # of times, dragging the char to the
* left of the cursor right.
* With negative arg, transposes 2 chars to left of cursor, moves
* between them, and repeats the specified # of times, exactly undoing
* the positive arg form. With zero arg, transposes chars at point
* and mark.
* HOWEVER: at the end of a line, with no arg, the preceding 2 chars
* are transposed.
*/
f_tchars()
{ register int c, c2;
#if IMAGEN
c = e_rgetc(); /* Gosmacs style: twiddle prev 2 */
if (c == EOF)
return(e_gocur()); /* Do nothing at beginning of bfr */
#else
if((c = e_getc()) == EOF /* If at EOF */
|| e_rgetc() == LF) /* or at end of line, */
c = e_rgetc(); /* use preceding 2 chars */
#endif /*-IMAGEN*/
if((c2 = e_rgetc()) == EOF) /* At beginning of buffer? */
return(e_gocur()); /* Yes, do nothing */
e_ovwc(c);
e_ovwc(c2);
e_setcur();
buf_tmod((chroff)-2); /* Munged these 2 chars */
}
#endif /*FX_TCHARS*/
#if FX_FWORD
/* EFUN: "Forward Word" */
f_fword()
{ chroff retdot;
if(e_wding(&retdot, exp))
ed_go(retdot);
}
#endif
#if FX_BWORD
/* EFUN: "Backward Word" */
f_bword()
{ exp = -exp;
f_fword();
}
#endif
#if FX_KWORD
/* EFUN: "Kill Word" */
f_kword()
{ chroff retdot;
if(e_wding(&retdot,exp))
{ ed_kill(cur_dot,retdot);
this_cmd = KILLCMD;
}
}
#endif
#if FX_BKWORD
/* EFUN: "Backward Kill Word" */
f_bkword()
{ exp = -exp;
f_kword();
}
#endif
#if FX_TWORDS
/* EFUN: "Transpose Words" */
/* Transpose word. Urk!
*/
f_twords()
{ register SBSTR *sd1, *sd2;
register SBBUF *sb;
chroff begwd1, endwd1, begwd2, endwd2;
endwd2 = e_wdot(cur_dot, 1); /* Go to end of 2nd word */
begwd2 = e_wdot(endwd2, -1); /* Go to beg of 2nd word */
if(begwd2 >= endwd2) /* If no 2nd word, punt. */
return;
begwd1 = e_wdot(begwd2, -1); /* Go to beg of 1st word */
endwd1 = e_wdot(begwd1, 1); /* Go to end of 1st word */
if(begwd1 >= endwd1) /* If no 1st word, punt. */
return;
if(endwd1 > begwd2) /* Avoid possible overlap */
return;
e_go(begwd2);
sb = (SBBUF *)cur_buf;
sd2 = sb_killn(sb, endwd2 - begwd2); /* Excise wd 2 first */
e_go(begwd1);
sd1 = sb_killn(sb, endwd1 - begwd1); /* Excise wd 1 */
sb_sins(sb, sd2); /* Replace with wd 2 */
e_goff(begwd2 - endwd1); /* Move past between stuff */
sb_sins(sb, sd1); /* Insert wd 1 */
e_setcur();
buf_tmat(begwd1); /* Modified this range */
}
#endif /*FX_TWORDS*/
/* Case hacking functions and support */
#if FX_UCWORD
/* EFUN: "Uppercase Word" */
f_ucword()
{ case_word(0);
}
#endif /*FX_UCWORD*/
#if FX_LCWORD
/* EFUN: "Lowercase Word" */
f_lcword()
{ case_word(1);
}
#endif /*FX_LCWORD*/
#if FX_UCIWORD
/* EFUN: "Uppercase Initial" */
f_uciword()
{ case_word(2);
}
#endif /*FX_UCIWORD*/
#if FX_UCWORD||FX_LCWORD||FX_UCIWORD
case_word (downp)
{ chroff retdot;
#if IMAGEN
chroff startdot;
/* Normalize our position to beginning of "current" word,
* where "current" is defined to be the current word we are in,
* or else the previous word if we are not in any word.
* All this silly nonsense just to perpetuate Gosmacs's
* wrong behaviour!
*/
startdot = cur_dot; /* Save current position */
e_getc(); /* If at beg of word, ensure we get inside it */
e_gowd(-1); /* Go to start of this or prev word */
e_setcur(); /* Set cur_dot */
#endif /*IMAGEN*/
if(e_wding(&retdot, exp))
{ ed_case(cur_dot,retdot,downp);
e_gosetcur(retdot);
}
#if IMAGEN
e_gosetcur(startdot);
#endif /*IMAGEN*/
}
#endif /* any case_word caller */

View file

@ -1,311 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEF2 Various functions
*/
#include "elle.h"
/* Line Handling functions */
/* EFUN: "Beginning of Line" */
f_begline()
{ e_gobol();
ed_setcur();
}
/* EFUN: "End of Line" */
f_endline()
{ e_goeol();
ed_setcur();
}
/* EFUN: "Next Line" */
/* Goes to beginning of next line */
f_nxtline()
{ return(down_bline(exp));
}
/* EFUN: "Previous Line" */
/* Goes to beginning of previous line */
f_prvline()
{ return(down_bline(-exp));
}
/* EFUN: "Down Real Line" */
f_dnrline ()
{ down_line(exp);
}
/* EFUN: "Up Real Line" */
f_uprline ()
{ down_line(-exp);
}
#if FX_OLINE
/* EFUN: "Open Line" */
f_oline()
{ register int i;
chroff savdot;
savdot = cur_dot;
if((i = exp) > 0)
do { ed_crins(); }
while(--i);
e_gosetcur(savdot);
}
#endif /*FX_OLINE*/
#if FX_DELBLINES
/* EFUN: "Delete Blank Lines" */
/* Delete blank lines around point.
*/
f_delblines()
{ register int c;
chroff dot1, dot2, oldcur;
oldcur = cur_dot;
do { e_gobwsp(); }
while ((c = e_rgetc()) == LF);
if (c != EOF)
e_gonl();
dot1 = e_dot();
if(dot1 > oldcur) return;
do { e_gofwsp(); }
while ((c = e_getc()) == LF);
if(c != EOF)
e_gobol();
dot2 = e_dot();
if(dot2 < oldcur) return;
ed_delete(dot1,dot2);
}
#endif /*FX_DELBLINES*/
#if FX_KLINE
/* EFUN: "Kill Line" */
f_kline()
{
if(exp_p)
e_goline(exp); /* Move that many lines */
/* (if 0, goes to BOL) */
else /* No arg, handle specially */
{ if(e_lblankp()) /* Is rest of line blank? */
; /* Yes, now at next line! */
else e_goeol(); /* No, go to EOL rather than NL */
}
ed_kill(cur_dot,e_dot());
e_setcur();
this_cmd = KILLCMD;
}
#endif /*FX_KLINE*/
#if FX_BKLINE
/* EFUN: "Backward Kill Line" (not EMACS) */
/* Originally an Iconographics function.
*/
f_bkline()
{
if(exp_p) exp = -exp; /* If arg, invert it */
else
{ exp = 0; /* No arg, furnish 0 */
exp_p = 1;
}
f_kline(); /* Invoke "Kill Line" */
}
#endif /*FX_BKLINE*/
#if FX_GOLINE
/* EFUN: "Goto Line" (not EMACS) (GNU goto-line) */
f_goline()
{
e_gobob();
down_bline(exp-1); /* already at line 1 */
}
#endif /*FX_GOLINE*/
down_bline(arg)
int arg;
{
if(arg)
e_goline(arg);
ed_setcur();
}
#if FX_DNRLINE || FX_UPRLINE
down_line (x)
int x;
{ register int i, res;
res = x ? e_goline(x) : 1; /* Move that many lines */
goal = 0;
if(res == 0) /* Hit buffer limits (EOF)? */
{ if(x > 0) /* Moving downwards? */
{
#if !(IMAGEN) /* If IMAGEN, do not extend!! */
if(x == 1) ed_crins(); /* Yeah, maybe extend */
else
#endif
goal = indtion(cur_dot);
goto done;
}
}
if(last_cmd == LINECMD /* If previous cmd also a line move */
&& pgoal != -1) /* and we have a previous goal col */
goal = pgoal; /* then make it the current goal */
else goal = indtion(cur_dot); /* Else invent goal from current pos */
i = inindex(e_dot(), goal); /* See # chars needed to reach goal */
if(i == -1) /* If off edge of line, */
e_goeol(); /* just move to end of this line */
else e_igoff(i); /* else move to goal. */
done: pgoal = goal;
this_cmd = LINECMD;
ed_setcur();
}
#endif /*FX_DNRLINE || FX_UPRLINE*/
/* Region Handling functions */
/* EFUN: "Set/Pop Mark" */
f_setmark()
{
mark_dot = e_dot();
mark_p = 1;
if(ev_markshow) /* If have one, show indicator */
saytoo(ev_markshow); /* that mark was set. */
}
/* EFUN: "Exchange Point and Mark" */
f_exchmark()
{ chroff tmpdot;
if(chkmark())
{ tmpdot = mark_dot;
mark_dot = cur_dot;
ed_go(tmpdot); /* Set cur_dot and go there */
}
}
/* EFUN: "Kill Region" */
f_kregion()
{
if(chkmark())
{ ed_kill(cur_dot,mark_dot); /* Will adj cur_dot, mark_dot */
e_gocur();
this_cmd = KILLCMD;
}
}
/* EFUN: "Copy Region" */
f_copreg()
{
if(chkmark())
{ e_gocur();
kill_push(e_copyn(mark_dot - cur_dot));
e_gocur();
}
}
/* EFUN: "Uppercase Region" */
f_ucreg()
{ ef_creg(0);
}
/* EFUN: "Lowercase Region" */
f_lcreg()
{ ef_creg(1);
}
ef_creg(downp)
int downp;
{
if(chkmark())
ed_case(cur_dot,mark_dot,downp);
}
#if FX_FILLREG
/* EFUN: "Fill Region" */
f_fillreg()
{ if(chkmark())
ed_fill(mark_dot,cur_dot,0);
}
#endif /*FX_FILLREG*/
/* CHKMARK() - minor utility for region-hacking functions.
* Returns TRUE if mark exists.
* Otherwise complains to user and returns 0.
*/
chkmark()
{ if(mark_p == 0)
ding("No mark!");
return(mark_p);
}
/* Paragraph functions */
#if FX_FPARA
/* EFUN: "Forward Paragraph" */
f_fpara()
{ int e_gobpa(), e_goepa();
exp_do(e_goepa, e_gobpa);
ed_setcur();
}
#endif /*FX_FPARA*/
#if FX_BPARA
/* EFUN: "Backward Paragraph" */
/* Go to beginning of paragraph.
* Skip all whitespace until text seen, then stop at beginning of
* 1st line starting with whitespace.
*/
f_bpara()
{ int e_gobpa(), e_goepa();
exp_do(e_gobpa, e_goepa);
ed_setcur();
}
#endif /*FX_BPARA*/
#if FX_MRKPARA
/* EFUN: "Mark Paragraph" */
f_mrkpara()
{
f_fpara(); /* Go to end of paragraph */
f_setmark(); /* Put mark there */
f_bpara(); /* Then back to start of paragraph */
}
#endif /*FX_MRKPARA*/
#if FX_FILLPARA
/* EFUN: "Fill Paragraph" */
f_fillpara()
{
chroff savloc, endloc;
savloc = cur_dot;
#if ICONOGRAPHICS
e_getc(); /* DON'T go to next para if at end */
e_gobpa(); /* of this one!! */
#endif /*ICONOGRAPHICS*/
e_goepa(); /* Go to end of parag */
if(e_rgetc() != LF) /* If last char EOL, back over it. */
e_getc();
endloc = e_dot(); /* Remember where end is */
e_gobpa(); /* Go to beg of parag */
#if ICONOGRAPHICS
kill_push(e_copyn(endloc - e_dot ()));
/* put old version on kill ring */
#endif /*ICONOGRAPHICS*/
e_fwsp(); /* Move over initial whitespace */
ed_fill(e_dot(), endloc, 0); /* Fill this region, return to dot */
}
#endif /*FX_FILLPARA*/

View file

@ -1,282 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEF3 Various Functions (Yanking, Indentation, miscellaneous)
*/
#include "elle.h"
#if FX_APPNKILL
/* EFUN: "Append Next Kill" */
f_appnkill()
{ this_cmd = KILLCMD; /* Fake out next call to ed_kill */
}
#endif /*FX_APPNKILL*/
#if FX_UNKILL
/* EFUN: "Un-kill" */
f_unkill()
{ register SBSTR *sd;
if((sd = kill_ring[kill_ptr]) == 0)
{ ring_bell();
return;
}
mark_dot = cur_dot; /* Set mark at old location */
mark_p = 1; /* Mark's been set */
sb_sins((SBBUF *)cur_buf,sbs_cpy(sd)); /* Insert copy of stuff */
cur_dot = e_dot(); /* We're now after the new stuff */
buf_tmat(mark_dot); /* Say modified from here to cur_dot*/
this_cmd = YANKCMD;
}
#endif /*FX_UNKILL*/
#if FX_UNKPOP
/* EFUN: "Un-kill Pop" */
f_unkpop()
{ register SBSTR *sd;
register int i;
if (last_cmd != YANKCMD)
{ ring_bell ();
return;
}
ed_delete(cur_dot,mark_dot);
if(cur_dot > mark_dot)
cur_dot = mark_dot;
i = KILL_LEN;
do {
if(--kill_ptr < 0)
kill_ptr = KILL_LEN-1;
if(sd = kill_ring[kill_ptr])
break;
} while(--i);
/* kill_ptr now pointing to right place; effect the yank. */
e_gocur(); /* Make sure point at right place too! */
return(f_unkill());
}
#endif /*FX_UNKPOP*/
/* Indentation routines - still not polished */
#if FX_INDATM
/* EFUN: "Indent According to Mode" */
/* In Fundamental mode, just inserts a tab.
*/
f_indatm()
{ f_insself(TAB); /* This takes care of mode checking */
}
#endif /*FX_INDATM*/
#if FX_INDNL
/* EFUN: "Indent New Line" */
f_indnl() /* execute CR followed by tab */
{
#if IMAGEN
/* Not dispatch-based, but rather hard-wired to do Gosmacs thing */
ed_crins();
f_indund();
#else
cmd_xct(CR);
cmd_xct(TAB);
#endif /*-IMAGEN*/
}
#endif /*FX_INDNL*/
#if FX_BACKIND
/* EFUN: "Back to Indentation"
** Moves to end of current line's indentation.
*/
f_backind()
{ e_gobol(); /* First move to beg of line */
e_gofwsp(); /* Then forward over whitespace */
ed_setcur();
}
#endif /*FX_BACKIND*/
#if FX_INDCOMM
static char *comm_beg = "/* ";
static char *comm_end = " */";
/* EFUN: "Indent for Comment" */
f_indcomm()
{
f_endline();
if(indtion(cur_dot) < ev_ccolumn)
ed_indto(ev_ccolumn);
else ed_sins(" ");
ed_sins (comm_beg);
ed_sins (comm_end);
e_igoff(-strlen (comm_end)); /* back over end string */
e_setcur();
}
#endif /*FX_INDCOMM*/
#if FX_INDREL
/* EFUN: "Indent Relative" */
/* This used to mistakenly be called Indent Under.
** Still not fully implemented.
** If at beginning of line, looks back at previous indented line,
** and indents this line that much. If there is no preceding indented
** line or not at beginning of line, insert a tab.
*/
f_indrel()
{ register int c;
register n;
#if IMAGEN
chroff savdot;
#endif /*IMAGEN*/
#if ICONOGRAPHICS
chroff savdot;
int curind, newind, morebuf;
#endif /*ICONOGRAPHICS*/
if((c = e_rgetc()) == EOF)
#if IMAGEN
return(f_insself(TAB)); /* Do mode-based tabbing */
#else
return(ed_insert(TAB));
#endif /*-IMAGEN*/
if(c == LF)
{ e_gobol();
e_gofwsp();
n = d_curind();
e_gonl(); /* Return to orig pos */
if(n)
{ ed_indto(n);
#if IMAGEN
savdot = e_dot();
e_gofwsp();
ed_delete(savdot, e_dot());
#endif /*IMAGEN*/
return;
}
}
#if ICONOGRAPHICS
else
{ e_igoff (1);
curind = indtion (savdot = e_dot ());
/* get current dot and indentation */
while (1) /* find a prev line that extends rightward */
{ morebuf = e_gopl ();
e_goeol ();
if ((newind = d_curind()) > curind) break;
if (morebuf == 0) /* hit beginning of buffer */
{ e_go (savdot);
f_delspc();
return (1);
}
}
e_gobol ();
e_igoff (inindex (e_dot (), curind));
if (d_curind() > curind)
e_rgetc (); /* pushed ahead by tab */
while (c_wsp (e_getc ()) == 0) ;
e_backc ();
e_fwsp ();
newind = d_curind();
e_go (savdot);
f_delspc();
ed_indto (newind);
}
#else
else e_getc();
#if IMAGEN
f_insself(TAB); /* Do mode-based tabbing */
#else
ed_insert(TAB);
#endif /*-IMAGEN*/
#endif /*-ICONOGRAPHICS*/
}
#endif /*FX_INDREL*/
/* Paren matching stuff. Note that this stuff will be very painful unless
** tinwait() works properly.
*/
#if 0
/* EFUN: "Self-Insert and Match" (intended to be bound to brackets) */
/* (KLH: Evidently this was never finished)
*/
insertmatch(c)
register int c;
{
}
#endif
/* Should change this to Matching Paren */
#if FX_MATCHBRACK
/* EFUN: "Match Bracket" (not EMACS) - from IMAGEN config
* Show the matching bracket for the character right before dot
*/
f_matchbrack()
{
chroff savdot;
register int i, mc, secs;
if (exp_p)
secs = exp;
else
secs = 1;
savdot = cur_dot; /* Save our location */
mc = e_rgetc(); /* Pick up character before dot */
if (mc != ')' && mc != ']' && mc != '}')
{ e_getc(); /* Nothing, try at dot instead */
e_getc();
mc = e_rgetc();
if (mc != ')' && mc != ']' && mc != '}')
{ ding("What bracket?");
e_go(savdot);
return;
}
}
if (! matchonelevel(mc))
ring_bell();
else
{ ed_setcur();
if (d_line(cur_dot) < 0)
secs = 10; /* Wait longer if off-screen */
redisplay(); /* Wish it were simple upd_wind() */
for (i = 1; i <= secs; ++i)
{ if (tinwait())
break;
sleep(1);
}
}
e_gosetcur(savdot); /* Back to origin */
redp(RD_MOVE); /* Cursor has moved */
}
/* Try to match 'mc', return true iff found it */
matchonelevel(mc)
register int mc;
{
register int c;
while ((c = e_rgetc()) != EOF)
{ if (c == /*[*/ ']' || c == /*(*/ ')' || c == /*{*/ '}')
{ if (! matchonelevel(c))
break;
}
else if (c == '(' /*)*/)
return(mc == /*(*/ ')');
else if (c == '[' /*]*/)
return(mc == /*[*/ ']');
else if (c == '{' /*}*/)
return(mc == /*{*/ '}');
}
return(0);
}
#endif /*FX_MATCHBRACK*/

View file

@ -1,434 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEFD Display control functions
*/
#include "elle.h"
static void moveborder(int);
#if FX_NEWWIN
/* EFUN: "New Window" */
/* Clear current window and set as requested.
* ^L - clear current window and redisplay it (default top)
* <arg>^L - select new window so that current line is
* the <arg>'th from top of window (0 = top line)
* ^U^L - clear current line and redisplay.
*/
f_newwin()
{ register int i, n;
register struct window *w;
d_fixcur(); /* Ensure screen vars correct */
w = cur_win;
if (exp_p)
{ if((n = exp) == 4 && exp_p == 4 /* CTRL-U? */
&& (i = d_line(cur_dot)) >= 0) /* On valid line? */
{ d_lupd(w, i); /* Update it */
return;
}
}
else /* No argument given */
{ redp(RD_SCREEN); /* Clear whole screen (later just window? */
#if IMAGEN
return;
#else
n = (ev_nwpct*w->w_ht)/100; /* Set new window using % */
#endif /*-IMAGEN*/
}
if (n < 0) n = 0; /* Ensure # is reasonable */
else if (n >= w->w_ht)
n = w->w_ht - 1;
d_fgoloff(-n); /* Go up given # of lines */
w->w_topldot = e_dot(); /* Set new top-line dot */
e_gocur(); /* Move back to cur_dot */
redp(RD_FIXWIN); /* Say to re-hack window */
}
#endif /*FX_NEWWIN*/
#if FX_NSCREEN
/* EFUN: "Next Screen" */
f_nscreen()
{ d_screen( exp);
}
#endif /*FX_NSCREEN*/
#if FX_PSCREEN
/* EFUN: "Previous Screen" */
f_pscreen()
{ d_screen(-exp);
}
#endif /*FX_PSCREEN*/
#if FX_OTHNSCREEN
/* EFUN: "Other New Screen" (not EMACS) - from IMAGEN config */
f_othnscreen()
{
if (! oth_win)
return;
f_othwind();
if (exp_p) /* With arg, back up */
d_screen(-1);
else
d_screen(1);
f_othwind();
redp(RD_WINDS); /* Look at all windows */
}
#endif /*FX_OTHNSCREEN*/
#if FX_LWINDBORD
/* EFUN: "Line to Window Border" (not EMACS) - from IMAGEN config */
f_lwindbord()
{
if (exp_p)
/* With arg, means "to bottom" */
exp = cur_win->w_ht - 1;
else
/* Else, to top */
exp = 0;
/* Just a "front end" for ^L */
exp_p = 1;
f_newwin();
}
#endif /*FX_LWINDBORD*/
#if FX_SCUPWIND
/* EFUN: "Scroll Window Up" (not EMACS) - from IMAGEN config */
f_scupwind()
{
scroll_win(exp);
}
#endif /*FX_SCUPWIND*/
#if FX_SCDNWIND
/* EFUN: "Scroll Window Down" (not EMACS) - from IMAGEN config */
f_scdnwind()
{
scroll_win(-exp);
}
#endif /*FX_SCDNWIND*/
#if FX_MVWTOP
/* EFUN: "Move to Window Top" (not EMACS) - from IMAGEN config */
f_mvwtop()
{
moveborder(1);
}
#endif /*FX_MVWTOP*/
#if FX_MVWBOT
/* EFUN: "Move to Window Bottom" (not EMACS) - from IMAGEN config */
f_mvwbot()
{
moveborder(0);
}
#endif /*FX_MVWBOT*/
#if FX_NSCREEN || FX_PSCREEN || FX_OTHNSCREEN
/* Move to new loc by N screenfuls.
* If moving downward, keep bottom 2 lines of current screen on top of next.
* If moving up, keep top 2 lines of current screen on bottom of next.
*/
d_screen(rep)
int rep;
{
register int i;
register struct window *w;
chroff newdot;
w = cur_win;
if((i = w->w_ht - 2) <= 0) /* Just-in-case check */
i = 1;
if((i *= rep) == 0)
return;
d_fixcur(); /* Ensure window fixed up */
e_go(w->w_topldot); /* Start at top of screen */
d_fgoloff(i);
/* Find where we are now, and make that the new top of window. */
if((newdot = e_dot()) != e_blen()) /* If not at EOF, */
w->w_topldot = newdot; /* set new top of window! */
else w->w_topldot = 0; /* Else let fix_wind select top. */
e_setcur(); /* Ensure cur_dot set to real loc */
#if IMAGEN
redp(RD_WINRES|RD_REDO); /* HINT: just repaint screen */
#else
redp(RD_FIXWIN|RD_MOVE);
#endif /*-IMAGEN*/
}
#endif /*FX_NSCREEN || FX_PSCREEN || FX_OTHNSCREEN*/
#if FX_SCUPWIND || FX_SCDNWIND /* If want scroll-window function */
scroll_win(n)
register int n;
{ register struct window *w = cur_win;
chroff savdot;
if (n == 0) return;
d_fixcur(); /* Ensure screen vars for win all set up */
e_go(w->w_topldot); /* Go to top of current window */
d_fgoloff(n); /* Move given # of display lines */
w->w_topldot = e_dot(); /* Set new top of window */
redp(RD_FIXWIN); /* Say new window needs fixing up */
/* Now adjust position of current dot so it is still within window */
if (n > 0)
{ /* Moving screen text "up" (win down) */
if (cur_dot < w->w_topldot) /* See if scrolled off top */
e_setcur(); /* yes, make dot be win top */
}
else { /* Moving screen text "down" (win up) */
savdot = cur_dot; /* Save since must temporarily */
e_setcur(); /* set current dot within window, */
d_fixcur(); /* so screen can be fixed up. */
if (inwinp(w, savdot)) /* Now see if old dot in new win */
cur_dot = savdot; /* Yes, just restore it! */
else /* No, make it beg of bottom line. */
cur_dot = scr[w->w_pos + w->w_ht - 1]->sl_boff;
}
e_gocur(); /* Make current pos be cur_dot */
}
#endif /* FX_SC%%WIND */
#if FX_MVWTOP || FX_MVWBOT /* Guts for above two functions */
static void
moveborder(top)
int top;
{
d_fixcur(); /* Ensure current win screen image fixed up */
e_gosetcur(top ? cur_win->w_topldot
: scr[cur_win->w_pos + cur_win->w_ht - 1]->sl_boff);
redp(RD_MOVE); /* Should only be cursor adjustment */
}
#endif /*FX_MVW%%%*/
/* Given a line and a position in that line, return the xpos.
* NOTE CAREFULLY that when line extends over several screen lines,
* the value returned is the screen X position even though it
* may be some lines down from the start of the logical line!
* Also note this won't work very well if tabs exist on the extra
* lines. This rtn should not be used for cursor positioning.
* Also note: d_ncols() will never return -1 meaning EOL because the
* setup guarantees there is no EOL within the range checked.
*/
d_curind() /* Find current indentation */
{ indtion(e_dot());
}
indtion(lin)
chroff lin;
{ register int i, col;
chroff savdot;
chroff nchars;
savdot = e_dot(); /* Save current position */
e_go(lin); /* Go to line caller wants */
e_gobol(); /* Go to its beginning */
col = 0; /* Start at left margin */
if((nchars = lin - e_dot()) > 0)
do {
if(nchars < (i = scr_wd0))
i = nchars;
if((col = d_ncols(i, col)) < 0) /* Hit edge of screen? */
col = 0; /* Reset to left margin */
} while((nchars -= i) > 0);
e_go(savdot); /* Restore current position */
return(col);
}
/* ININDEX - How many positions in lin must we go to get to xpos?
* Returns -1 if can't be done. Assumes "lin" is at beginning of a line!
*/
inindex (lin, xpos)
chroff lin;
int xpos;
{ register int col, x;
chroff savdot;
char tmp[MAXLINE+MAXCHAR];
extern int sctreol; /* From EEDISP */
if((x = xpos) <= 0) return(0);
if(x >= MAXLINE) return(-1); /* ?!? */
col = 0;
savdot = e_dot();
e_go(lin); /* Assumes this is start of line */
col = sctrin(tmp, x, 0); /* Translate from sb_getc input */
if((col - x) >= 0) /* Exact count-out or past it? */
{ x = e_dot() - lin; /* Yup, win. */
if (sctreol > 0) /* Did we hit (and include) EOL? */
#if FX_EOLMODE /* If so, back up over the EOL. */
x -= eolcrlf(cur_buf) ? 2 : 1;
#else
--x;
#endif
}
else x = -1; /* Nope, EOL or EOF hit too soon. */
e_go(savdot);
return(x);
}
/*
* D_ ROUTINES - display-relative functions. Similar to E_, but
* a "line" is defined as one line of the screen rather than
* as a logical text line. Also, for efficiency reasons
* arguments are given saying how many lines to hack.
*/
d_gopl() { return(d_goloff(-1)); }
d_gonl() { return(d_goloff( 1)); }
/* D_GOLOFF(i) - Go to beginning of a display line
* D_FGOLOFF(i) - ditto, but assumes screen image of window already fixed up.
* i - # of lines offset. Negative moves up, positive down.
* Zero arg goes to beginning of current display line.
* Side effects: screen image of window is fixed up at
* start of routine, but is NOT updated by the move to new location.
*/
d_goloff(cnt)
int cnt;
{ d_fixcur();
d_fgoloff(cnt); /* Now can invoke fixed-up fast version */
}
d_fgoloff(cnt)
register int cnt;
{ register int y;
struct scr_line l;
char line[MAXLINE+MAXCHAR];
int top, bot;
/* Find current position in window, since can save time
* by using stuff already in fixed-up screen image.
*/
if((y = d_line(e_dot())) < 0) /* Get current Y position */
{
errbarf("Dot out of window");
y = 0;
}
top = cur_win->w_pos; /* 1st line of window */
bot = top + cur_win->w_ht; /* 1st line not in window */
l.sl_boff = scr[y]->sl_boff;
l.sl_nlin = &line[0];
l.sl_cont = 0;
if(cnt > 0) goto down;
/* Go upwards. This is hairy because we want to be clever about
* huge logical lines -- avoid going all the way back to BOL.
*/
if((y+cnt) >= top) /* Fits? */
goto onscr; /* Hurray, hack it! */
cnt += y - top; /* Sigh, find # lines to skip */
y = top;
l.sl_boff = scr[y]->sl_boff;
e_go(l.sl_boff);
/* Okay, here's the hairy part. Must go backwards from top
* line; if no EOL within scr_wid*cnt chars, then simply assume one is
* seen.
*/
cnt = -cnt;
d_backup(cnt);
return; /* Really should re-adjust stuff, but... */
/* Go downwards. Not too bad... */
down:
if((y+cnt) <= bot) /* Fits? */
goto onscr; /* Hurray, hack it! */
cnt -= bot - y; /* Sigh, find # lines can skip */
y = bot - 1;
l.sl_boff = scr[y]->sl_boff + scr[y]->sl_len;
if(y > top
&& (l.sl_cont = scr[y-1]->sl_cont))
l.sl_line = scr[y-1]->sl_line;
e_go(l.sl_boff);
do {
fix_line(&l,&l);
} while(--cnt > 0 && l.sl_len);
return;
onscr: if((y += cnt) >= bot)
{ --y;
e_go(scr[y]->sl_boff + scr[y]->sl_len);
}
else e_go(scr[y]->sl_boff);
}
/* D_FIXCUR() - Ensure current window is fixed up, with
* current location (not necessarily cur_dot)!
* Ensure cur_dot reflects real loc so that fix_wind will work,
* and always call fix_wind to ensure that screen image vars
* are set properly. Note any active redisplay flags must be carried
* on into window redisplay flags, so fix_wind will notice them.
*/
d_fixcur()
{ register struct window *w;
chroff savedot;
w = cur_win;
savedot = cur_dot;
e_setcur();
w->w_redp |= rd_type&RDS_WINFLGS;
fix_wind(w); /* Always ensure window is set up! */
redp(w->w_redp); /* Add back new flags */
rd_type &= ~RDS_DOFIX; /* and flush fix-invoking ones */
cur_dot = savedot; /* Restore cur_dot, no longer hacked. */
}
d_backup(nlin) /* Try to back up by nlin screen lines */
int nlin;
{ register int cnt, n, c;
int eolstop;
if((cnt = nlin+1) <= 0) return;
c = 0;
do
{ n = scr_wid;
eolstop = 0; /* Not yet stopped at EOL */
do { if((c = e_rgetc()) == EOF)
return;
if(c == LF)
{
#if FX_EOLMODE
if(eolcrlf(cur_buf))
{ if((c = e_rgetc()) == CR)
{ eolstop++;
break;
}
if(c != EOF)
e_getc();
}
else
#endif
{ eolstop++;
break;
}
}
} while(--n);
} while(--cnt);
if(eolstop)
{
#if FX_EOLMODE
if(eolcrlf(cur_buf)) e_getc(); /* Skip back over CR */
#endif
e_getc(); /* Skip back over LF */
}
/* At this point, dot is guaranteed to be less than goal,
* which is the important thing for fix_wind, which can handle
* things okay if dot is off bottom of window.
*/
return(1); /* Say always test result */
}

View file

@ -1,159 +0,0 @@
/* .H Function Definition file, generated by ELLEC */
/* 0 */ EFUNHOLE /* Always undefined */
/* 1 */ EFUN( f_insself , "f_insself" , "Insert Self")
/* 2 */ EFUN( f_quotins , "f_quotins" , "Quoted Insert")
/* 3 */ EFUN( f_crlf , "f_crlf" , "CRLF")
/* 4 */ EFUN( f_fchar , "f_fchar" , "Forward Character")
/* 5 */ EFUN( f_bchar , "f_bchar" , "Backward Character")
/* 6 */ EFUN( f_dchar , "f_dchar" , "Delete Character")
/* 7 */ EFUN( f_bdchar , "f_bdchar" , "Backward Delete Character")
/* 8 */ EFUN( f_delspc , "f_delspc" , "Delete Horizontal Space")
/* 9 */ EFUN( f_tchars , "f_tchars" , "Transpose Characters")
/* 10 */ EFUN( f_fword , "f_fword" , "Forward Word")
/* 11 */ EFUN( f_bword , "f_bword" , "Backward Word")
/* 12 */ EFUN( f_kword , "f_kword" , "Kill Word")
/* 13 */ EFUN( f_bkword , "f_bkword" , "Backward Kill Word")
/* 14 */ EFUN( f_twords , "f_twords" , "Transpose Words")
/* 15 */ EFUN( f_ucword , "f_ucword" , "Uppercase Word")
/* 16 */ EFUN( f_lcword , "f_lcword" , "Lowercase Word")
/* 17 */ EFUN( f_uciword , "f_uciword" , "Uppercase Initial")
/* 18 */ EFUNHOLE
/* 19 */ EFUNHOLE
/* 20 */ EFUN( f_begline , "f_begline" , "Beginning of Line")
/* 21 */ EFUN( f_endline , "f_endline" , "End of Line")
/* 22 */ EFUN( f_nxtline , "f_nxtline" , "Next Line")
/* 23 */ EFUN( f_prvline , "f_prvline" , "Previous Line")
/* 24 */ EFUN( f_dnrline , "f_dnrline" , "Down Real Line")
/* 25 */ EFUN( f_uprline , "f_uprline" , "Up Real Line")
/* 26 */ EFUN( f_oline , "f_oline" , "Open Line")
/* 27 */ EFUN( f_delblines , "f_delblines" , "Delete Blank Lines")
/* 28 */ EFUN( f_kline , "f_kline" , "Kill Line")
/* 29 */ EFUN( f_bkline , "f_bkline" , "Backward Kill Line")
/* 30 */ EFUN( f_goline , "f_goline" , "Goto Line")
/* 31 */ EFUNHOLE
/* 32 */ EFUNHOLE
/* 33 */ EFUNHOLE
/* 34 */ EFUNHOLE
/* 35 */ EFUN( f_setmark , "f_setmark" , "Set/Pop Mark")
/* 36 */ EFUN( f_exchmark , "f_exchmark" , "Exchange Point and Mark")
/* 37 */ EFUN( f_kregion , "f_kregion" , "Kill Region")
/* 38 */ EFUN( f_copreg , "f_copreg" , "Copy Region")
/* 39 */ EFUN( f_ucreg , "f_ucreg" , "Uppercase Region")
/* 40 */ EFUN( f_lcreg , "f_lcreg" , "Lowercase Region")
/* 41 */ EFUN( f_fillreg , "f_fillreg" , "Fill Region")
/* 42 */ EFUNHOLE
/* 43 */ EFUNHOLE
/* 44 */ EFUNHOLE
/* 45 */ EFUN( f_fpara , "f_fpara" , "Forward Paragraph")
/* 46 */ EFUN( f_bpara , "f_bpara" , "Backward Paragraph")
/* 47 */ EFUN( f_mrkpara , "f_mrkpara" , "Mark Paragraph")
/* 48 */ EFUN( f_fillpara , "f_fillpara" , "Fill Paragraph")
/* 49 */ EFUNHOLE
/* 50 */ EFUN( f_selbuffer , "f_selbuffer" , "Select Buffer")
/* 51 */ EFUN( f_selxbuffer, "f_selxbuffer", "Select Existing Buffer")
/* 52 */ EFUN( f_kbuffer , "f_kbuffer" , "Kill Buffer")
/* 53 */ EFUN( f_listbufs , "f_listbufs" , "List Buffers")
/* 54 */ EFUN( f_bufnotmod , "f_bufnotmod" , "Buffer Not Modified")
/* 55 */ EFUN( f_eolmode , "f_eolmode" , "EOL CRLF Mode")
/* 56 */ EFUN( f_gobeg , "f_gobeg" , "Goto Beginning")
/* 57 */ EFUN( f_goend , "f_goend" , "Goto End")
/* 58 */ EFUN( f_whatpage , "f_whatpage" , "What Page")
/* 59 */ EFUNHOLE
/* 60 */ EFUN( f_ffile , "f_ffile" , "Find File")
/* 61 */ EFUN( f_rfile , "f_rfile" , "Read File")
/* 62 */ EFUN( f_vfile , "f_vfile" , "Visit File")
/* 63 */ EFUN( f_ifile , "f_ifile" , "Insert File")
/* 64 */ EFUN( f_sfile , "f_sfile" , "Save File")
/* 65 */ EFUN( f_savefiles , "f_savefiles" , "Save All Files")
/* 66 */ EFUN( f_wfile , "f_wfile" , "Write File")
/* 67 */ EFUN( f_wreg , "f_wreg" , "Write Region")
/* 68 */ EFUN( f_wlastkill , "f_wlastkill" , "Write Last Kill")
/* 69 */ EFUNHOLE
/* 70 */ EFUN( f_2winds , "f_2winds" , "Two Windows")
/* 71 */ EFUN( f_1wind , "f_1wind" , "One Window")
/* 72 */ EFUN( f_othwind , "f_othwind" , "Other Window")
/* 73 */ EFUN( f_growind , "f_growind" , "Grow Window")
/* 74 */ EFUN( f_shrinkwind, "f_shrinkwind", "Shrink Window")
/* 75 */ EFUN( f_delwind , "f_delwind" , "Delete Window")
/* 76 */ EFUN( f_sowind , "f_sowind" , "Standout Window")
/* 77 */ EFUN( f_2modewinds, "f_2modewinds", "Two Mode Windows")
/* 78 */ EFUN( f_newwin , "f_newwin" , "New Window")
/* 79 */ EFUN( f_nscreen , "f_nscreen" , "Next Screen")
/* 80 */ EFUN( f_pscreen , "f_pscreen" , "Previous Screen")
/* 81 */ EFUNHOLE
/* 82 */ EFUNHOLE
/* 83 */ EFUN( f_scupwind , "f_scupwind" , "Scroll Window Up")
/* 84 */ EFUN( f_scdnwind , "f_scdnwind" , "Scroll Window Down")
/* 85 */ EFUN( f_mvwtop , "f_mvwtop" , "Move to Window Top")
/* 86 */ EFUN( f_mvwbot , "f_mvwbot" , "Move to Window Bottom")
/* 87 */ EFUNHOLE
/* 88 */ EFUNHOLE
/* 89 */ EFUNHOLE
/* 90 */ EFUN( f_setprof , "f_setprof" , "Set Profile")
/* 91 */ EFUN( f_pfxmeta , "f_pfxmeta" , "Prefix Meta")
/* 92 */ EFUN( f_pfxext , "f_pfxext" , "Prefix Extend")
/* 93 */ EFUN( f_uarg , "f_uarg" , "Universal Arg")
/* 94 */ EFUN( f_negarg , "f_negarg" , "Negative Argument")
/* 95 */ EFUN( f_argdig , "f_argdig" , "Argument Digit")
/* 96 */ EFUN( f_vtbuttons , "f_vtbuttons" , "VT100 Button Hack")
/* 97 */ EFUN( f_describe , "f_describe" , "Describe")
/* 98 */ EFUNHOLE
/* 99 */ EFUNHOLE
/* 100 */ EFUN( f_skmac , "f_skmac" , "Start Kbd Macro")
/* 101 */ EFUN( f_ekmac , "f_ekmac" , "End Kbd Macro")
/* 102 */ EFUN( f_xkmac , "f_xkmac" , "Execute Kbd Macro")
/* 103 */ EFUN( f_vkmac , "f_vkmac" , "View Kbd Macro")
/* 104 */ EFUNHOLE
/* 105 */ EFUN( f_unkill , "f_unkill" , "Un-kill")
/* 106 */ EFUN( f_unkpop , "f_unkpop" , "Un-kill Pop")
/* 107 */ EFUN( f_appnkill , "f_appnkill" , "Append Next Kill")
/* 108 */ EFUNHOLE
/* 109 */ EFUNHOLE
/* 110 */ EFUN( f_srch , "f_srch" , "String Search")
/* 111 */ EFUN( f_rsrch , "f_rsrch" , "Reverse String Search")
/* 112 */ EFUN( f_isrch , "f_isrch" , "Incremental Search")
/* 113 */ EFUN( f_risrch , "f_risrch" , "Reverse Search")
/* 114 */ EFUN( f_repstr , "f_repstr" , "Replace String")
/* 115 */ EFUN( f_querep , "f_querep" , "Query Replace")
/* 116 */ EFUN( f_repline , "f_repline" , "Replace in Line")
/* 117 */ EFUN( f_sfcol , "f_sfcol" , "Set Fill Column")
/* 118 */ EFUN( f_sfpref , "f_sfpref" , "Set Fill Prefix")
/* 119 */ EFUN( f_fillmode , "f_fillmode" , "Auto Fill Mode")
/* 120 */ EFUNHOLE
/* 121 */ EFUN( f_indatm , "f_indatm" , "Indent According to Mode")
/* 122 */ EFUN( f_indnl , "f_indnl" , "Indent New Line")
/* 123 */ EFUN( f_backind , "f_backind" , "Back to Indentation")
/* 124 */ EFUN( f_indcomm , "f_indcomm" , "Indent for Comment")
/* 125 */ EFUN( f_indrel , "f_indrel" , "Indent Relative")
/* 126 */ EFUNHOLE
/* 127 */ EFUNHOLE
/* 128 */ EFUNHOLE
/* 129 */ EFUNHOLE
/* 130 */ EFUN( f_pshinf , "f_pshinf" , "Push to Inferior")
/* 131 */ EFUN( f_retsup , "f_retsup" , "Return to Superior")
/* 132 */ EFUN( f_wfexit , "f_wfexit" , "Write File Exit")
/* 133 */ EFUNHOLE
/* 134 */ EFUNHOLE
/* 135 */ EFUNHOLE
/* 136 */ EFUNHOLE
/* 137 */ EFUNHOLE
/* 138 */ EFUNHOLE
/* 139 */ EFUNHOLE
/* 140 */ EFUN( f_bkpt , "f_bkpt" , "Hit Breakpoint")
/* 141 */ EFUN( f_debug , "f_debug" , "Debug Mode")
/* 142 */ EFUNHOLE
/* 143 */ EFUNHOLE
/* 144 */ EFUNHOLE
/* 145 */ EFUNHOLE
/* 146 */ EFUNHOLE
/* 147 */ EFUNHOLE
/* 148 */ EFUNHOLE
/* 149 */ EFUNHOLE
/* 150 */ EFUNHOLE
/* 151 */ EFUNHOLE
/* 152 */ EFUNHOLE
/* 153 */ EFUNHOLE
/* 154 */ EFUNHOLE
/* 155 */ EFUNHOLE
/* 156 */ EFUNHOLE
/* 157 */ EFUNHOLE

View file

@ -1,283 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEFED - ED-type functions
*/
#include "elle.h"
/*
* ED_INSERT -- Insert character given as argument.
*/
ed_insert(c)
int c;
{ register SBBUF *sb;
sb = (SBBUF *) cur_buf; /* For a little speed */
sb_putc(sb,c); /* Insert the char */
cur_dot++; /* Advance dot */
buf_tmod((chroff)-1); /* Mark buffer modified, for redisplay etc. */
/* Perhaps later use specialized routine? */
}
ed_insn(ch, cnt)
int ch, cnt;
{ register int i;
if((i = cnt) > 0)
do { ed_insert(ch);
} while(--i);
}
ed_crins()
{
#if FX_EOLMODE
if (eolcrlf(cur_buf)) /* If EOL is made of CR-LF */
ed_insert(CR); /* then first insert CR, then drop down to */
#endif
ed_insert(LF); /* Insert LF */
}
ed_sins (s) /* insert this string */
register char *s;
{ register c;
while (c = *s++)
ed_insert (c);
}
ed_nsins (s, i) /* Insert string of N chars */
register char *s;
register int i;
{ if(i > 0)
do { ed_insert(*s++); } while(--i);
}
/* ED_INDTO(col) - Indent to specified column.
** Finds current cursor position, and inserts tabs and spaces
** so cursor ends up at column goal. Does nothing if already at or past
** specified column.
*/
ed_indto(goal)
register int goal;
{ register int ng;
ng = goal & ~07; /* Get distance to tab stop */
ed_insn(TAB, ((ng - (d_curind() & ~07)) >> 3));
ed_insn(SP, goal-ng);
}
/* Oddball routine - Set cur_dot to actual I/O location and
* tell display that cursor probably moved. This is not really a
* function of itself; it provides support for real functions.
*/
ed_setcur()
{ e_setcur(); /* Set cur_dot */
redp(RD_MOVE); /* Alert redisplay to check cursor loc */
}
/* Go to given dot */
ed_go (dot)
chroff dot;
{ e_go(dot);
ed_setcur();
}
/* Go to given offset from current location */
ed_goff(off)
chroff off;
{ e_goff(off);
ed_setcur();
}
/* Go to given INTEGER offset from current location */
ed_igoff(ioff)
int ioff;
{ e_igoff(ioff);
ed_setcur();
}
/* Reset (delete all of) Buffer
* Should buffer be marked modified or not? Currently isn't.
*/
ed_reset()
{ if(e_blen() == 0)
return; /* Already empty */
e_reset();
cur_dot = 0;
cur_win->w_topldot = 0; /* Is this necessary? */
#if IMAGEN
redp(RD_WINRES|RD_REDO);
#else
redp(RD_WINRES); /* This window needs complete update */
#endif /*-IMAGEN*/
/* buf_mod(); */ /* Mark modified ?? */
/* mark_p = 0; */ /* Say no mark set ?? */
}
ed_deln(off)
chroff off;
{ chroff dot;
dot = e_dot();
e_goff(off);
ed_delete(e_dot(), dot);
}
/* ED_DELETE(dot1,dot2) - Delete all characters between the two
* positions indicated by dot1 and dot2. Their order does not
* matter; cur_dot and mark_dot are updated as necessary.
*/
ed_delete(dot1,dot2)
chroff dot1,dot2;
{ chroff tmpdot, savdot;
if(dot1 > dot2)
{ tmpdot = dot1;
dot1 = dot2;
dot2 = tmpdot;
}
e_go(dot1);
tmpdot = dot2-dot1;
sb_deln((SBBUF *)cur_buf,tmpdot);
savdot = cur_dot; /* Save cur_dot value */
cur_dot = dot1; /* so can set up for */
buf_tmod((chroff)0); /* call to update disp-change vars */
cur_dot = savdot;
if(cur_dot >= dot2)
cur_dot -= tmpdot;
else if(cur_dot > dot1)
cur_dot = dot1;
if(mark_dot >= dot2)
mark_dot -= tmpdot;
else if(mark_dot > dot1)
mark_dot = dot1;
e_gocur();
}
/* ED_KILL(dot1,dot2) - Kill (save and delete) text between two places in
* the buffer.
* We assume we are deleting from dot1 to dot2, thus if dot1 > dot2
* then backwards deletion is implied, and the saved text is prefixed
* (instead of appended) to any previously killed text.
*/
ed_kill(dot1,dot2)
chroff dot1,dot2;
{ register SBSTR *sd, *sdo;
SBSTR *e_copyn();
e_go(dot1);
sd = e_copyn(dot2-dot1);
if(sd == 0) return;
if(last_cmd == KILLCMD && (sdo = kill_ring[kill_ptr]))
{ if(dot1 > dot2) /* Prefix new killed stuff onto old stuff */
{ sbs_app(sd,sdo);
kill_ring[kill_ptr] = sd;
}
else /* Append new stuff to old stuff */
sbs_app(sdo,sd);
}
else kill_push(sd);
ed_delete(dot1,dot2);
}
kill_push(sdp)
SBSTR *sdp;
{ register SBSTR *sd;
if(++kill_ptr >= KILL_LEN) kill_ptr = 0;
if(sd = kill_ring[kill_ptr])
sbs_del(sd);
kill_ring[kill_ptr] = sdp;
}
#define isupper(c) (('A' <= c) && (c <= 'Z'))
#define islower(c) (('a' <= c) && (c <= 'z'))
#define toupper(c) (c + ('A' - 'a'))
#define tolower(c) (c + ('a' - 'A'))
#if FX_UCWORD||FX_LCWORD||FX_UCIWORD||FX_UCREG||FX_LCREG
/* ED_CASE(dot1,dot2,downp) - Change the case within a region.
* downp = 0 for uppercase, 1 for lowercase, 2 for capitalize.
*/
ed_case(dot1, dot2, downp)
chroff dot1, dot2;
int downp;
{ chroff dcnt;
register int c, a, z;
int modflg;
modflg = 0;
if((dcnt = dot2 - dot1) < 0)
{ dcnt = dot1;
dot1 = dot2;
dot2 = dcnt;
dcnt -= dot1;
}
e_go(dot1);
if(downp==2)
{ a = 0; /* 0 looking for wd, 1 in word */
while(--dcnt >= 0)
{ if(delimp(c = e_getc())) /* Char in wd? */
{ a = 0; /* No */
continue;
}
if(a) /* If already inside word */
{ if(isupper(c))
c = tolower(c);
else continue;
}
else /* If encountered start of word */
{ a = 1;
if(islower(c))
c = toupper(c);
else continue;
}
e_backc();
e_ovwc(c);
modflg++;
}
goto casdon;
}
if(downp==0)
{ a = 'a'; /* Convert to lower case */
z = 'z';
downp = -040;
}
else
{ a = 'A'; /* Convert to upper case */
z = 'Z';
downp = 040;
}
while(--dcnt >= 0)
{ if(a <= (c = e_getc()) && c <= z)
{ e_backc();
e_ovwc(c+downp);
modflg++;
}
}
casdon: dot2 = cur_dot; /* Save dot */
e_setcur(); /* Set up for modification range chk*/
if(modflg)
buf_tmat(dot1); /* Stuff munged from there to here */
ed_go(dot2);
}
#endif /* any ed_case caller */
/* UPCASE(c) - Return upper-case version of character */
upcase(ch)
int ch;
{ register int c;
c = ch&0177;
return(islower(c) ? toupper(c) : c);
}

View file

@ -1,241 +0,0 @@
/* .H Function Index Definition file, generated by ELLEC */
/* FN_ defines Function Numbers (indices) for all known functions */
/* FX_ defines Function eXistence in this ELLE configuration */
#define FN_INSSELF 1 /* Insert Self */
#define FX_INSSELF 1
#define FN_QUOTINS 2 /* Quoted Insert */
#define FX_QUOTINS 2
#define FN_CRLF 3 /* CRLF */
#define FX_CRLF 3
#define FN_FCHAR 4 /* Forward Character */
#define FX_FCHAR 4
#define FN_BCHAR 5 /* Backward Character */
#define FX_BCHAR 5
#define FN_DCHAR 6 /* Delete Character */
#define FX_DCHAR 6
#define FN_BDCHAR 7 /* Backward Delete Character */
#define FX_BDCHAR 7
#define FN_DELSPC 8 /* Delete Horizontal Space */
#define FX_DELSPC 8
#define FN_TCHARS 9 /* Transpose Characters */
#define FX_TCHARS 9
#define FN_FWORD 10 /* Forward Word */
#define FX_FWORD 10
#define FN_BWORD 11 /* Backward Word */
#define FX_BWORD 11
#define FN_KWORD 12 /* Kill Word */
#define FX_KWORD 12
#define FN_BKWORD 13 /* Backward Kill Word */
#define FX_BKWORD 13
#define FN_TWORDS 14 /* Transpose Words */
#define FX_TWORDS 14
#define FN_UCWORD 15 /* Uppercase Word */
#define FX_UCWORD 15
#define FN_LCWORD 16 /* Lowercase Word */
#define FX_LCWORD 16
#define FN_UCIWORD 17 /* Uppercase Initial */
#define FX_UCIWORD 17
#define FN_BEGLINE 20 /* Beginning of Line */
#define FX_BEGLINE 20
#define FN_ENDLINE 21 /* End of Line */
#define FX_ENDLINE 21
#define FN_NXTLINE 22 /* Next Line */
#define FX_NXTLINE 22
#define FN_PRVLINE 23 /* Previous Line */
#define FX_PRVLINE 23
#define FN_DNRLINE 24 /* Down Real Line */
#define FX_DNRLINE 24
#define FN_UPRLINE 25 /* Up Real Line */
#define FX_UPRLINE 25
#define FN_OLINE 26 /* Open Line */
#define FX_OLINE 26
#define FN_DELBLINES 27 /* Delete Blank Lines */
#define FX_DELBLINES 27
#define FN_KLINE 28 /* Kill Line */
#define FX_KLINE 28
#define FN_BKLINE 29 /* Backward Kill Line */
#define FX_BKLINE 29
#define FN_GOLINE 30 /* Goto Line */
#define FX_GOLINE 30
#define FN_SETMARK 35 /* Set/Pop Mark */
#define FX_SETMARK 35
#define FN_EXCHMARK 36 /* Exchange Point and Mark */
#define FX_EXCHMARK 36
#define FN_KREGION 37 /* Kill Region */
#define FX_KREGION 37
#define FN_COPREG 38 /* Copy Region */
#define FX_COPREG 38
#define FN_UCREG 39 /* Uppercase Region */
#define FX_UCREG 39
#define FN_LCREG 40 /* Lowercase Region */
#define FX_LCREG 40
#define FN_FILLREG 41 /* Fill Region */
#define FX_FILLREG 41
#define FN_FPARA 45 /* Forward Paragraph */
#define FX_FPARA 45
#define FN_BPARA 46 /* Backward Paragraph */
#define FX_BPARA 46
#define FN_MRKPARA 47 /* Mark Paragraph */
#define FX_MRKPARA 47
#define FN_FILLPARA 48 /* Fill Paragraph */
#define FX_FILLPARA 48
#define FN_SELBUFFER 50 /* Select Buffer */
#define FX_SELBUFFER 50
#define FN_SELXBUFFER 51 /* Select Existing Buffer */
#define FX_SELXBUFFER 51
#define FN_KBUFFER 52 /* Kill Buffer */
#define FX_KBUFFER 52
#define FN_LISTBUFS 53 /* List Buffers */
#define FX_LISTBUFS 53
#define FN_BUFNOTMOD 54 /* Buffer Not Modified */
#define FX_BUFNOTMOD 54
#define FN_EOLMODE 55 /* EOL CRLF Mode */
#define FX_EOLMODE 55
#define FN_GOBEG 56 /* Goto Beginning */
#define FX_GOBEG 56
#define FN_GOEND 57 /* Goto End */
#define FX_GOEND 57
#define FN_WHATPAGE 58 /* What Page */
#define FX_WHATPAGE 58
#define FN_FFILE 60 /* Find File */
#define FX_FFILE 60
#define FN_RFILE 61 /* Read File */
#define FX_RFILE 61
#define FN_VFILE 62 /* Visit File */
#define FX_VFILE 62
#define FN_IFILE 63 /* Insert File */
#define FX_IFILE 63
#define FN_SFILE 64 /* Save File */
#define FX_SFILE 64
#define FN_SAVEFILES 65 /* Save All Files */
#define FX_SAVEFILES 65
#define FN_WFILE 66 /* Write File */
#define FX_WFILE 66
#define FN_WREG 67 /* Write Region */
#define FX_WREG 67
#define FN_WLASTKILL 68 /* Write Last Kill */
#define FX_WLASTKILL 68
#define FN_2WINDS 70 /* Two Windows */
#define FX_2WINDS 70
#define FN_1WIND 71 /* One Window */
#define FX_1WIND 71
#define FN_OTHWIND 72 /* Other Window */
#define FX_OTHWIND 72
#define FN_GROWIND 73 /* Grow Window */
#define FX_GROWIND 73
#define FN_SHRINKWIND 74 /* Shrink Window */
#define FX_SHRINKWIND 74
#define FN_DELWIND 75 /* Delete Window */
#define FX_DELWIND 75
#define FN_SOWIND 76 /* Standout Window */
#define FX_SOWIND 76
#define FN_2MODEWINDS 77 /* Two Mode Windows */
#define FX_2MODEWINDS 77
#define FN_NEWWIN 78 /* New Window */
#define FX_NEWWIN 78
#define FN_NSCREEN 79 /* Next Screen */
#define FX_NSCREEN 79
#define FN_PSCREEN 80 /* Previous Screen */
#define FX_PSCREEN 80
#define FN_OTHNSCREEN 81 /* Other New Screen */
#define FX_OTHNSCREEN 0
#define FN_LWINDBORD 82 /* Line to Window Border */
#define FX_LWINDBORD 0
#define FN_SCUPWIND 83 /* Scroll Window Up */
#define FX_SCUPWIND 83
#define FN_SCDNWIND 84 /* Scroll Window Down */
#define FX_SCDNWIND 84
#define FN_MVWTOP 85 /* Move to Window Top */
#define FX_MVWTOP 85
#define FN_MVWBOT 86 /* Move to Window Bottom */
#define FX_MVWBOT 86
#define FN_SETPROF 90 /* Set Profile */
#define FX_SETPROF 90
#define FN_PFXMETA 91 /* Prefix Meta */
#define FX_PFXMETA 91
#define FN_PFXEXT 92 /* Prefix Extend */
#define FX_PFXEXT 92
#define FN_UARG 93 /* Universal Arg */
#define FX_UARG 93
#define FN_NEGARG 94 /* Negative Argument */
#define FX_NEGARG 94
#define FN_ARGDIG 95 /* Argument Digit */
#define FX_ARGDIG 95
#define FN_VTBUTTONS 96 /* VT100 Button Hack */
#define FX_VTBUTTONS 96
#define FN_DESCRIBE 97 /* Describe */
#define FX_DESCRIBE 97
#define FN_SKMAC 100 /* Start Kbd Macro */
#define FX_SKMAC 100
#define FN_EKMAC 101 /* End Kbd Macro */
#define FX_EKMAC 101
#define FN_XKMAC 102 /* Execute Kbd Macro */
#define FX_XKMAC 102
#define FN_VKMAC 103 /* View Kbd Macro */
#define FX_VKMAC 103
#define FN_UNKILL 105 /* Un-kill */
#define FX_UNKILL 105
#define FN_UNKPOP 106 /* Un-kill Pop */
#define FX_UNKPOP 106
#define FN_APPNKILL 107 /* Append Next Kill */
#define FX_APPNKILL 107
#define FN_SRCH 110 /* String Search */
#define FX_SRCH 110
#define FN_RSRCH 111 /* Reverse String Search */
#define FX_RSRCH 111
#define FN_ISRCH 112 /* Incremental Search */
#define FX_ISRCH 112
#define FN_RISRCH 113 /* Reverse Search */
#define FX_RISRCH 113
#define FN_REPSTR 114 /* Replace String */
#define FX_REPSTR 114
#define FN_QUEREP 115 /* Query Replace */
#define FX_QUEREP 115
#define FN_REPLINE 116 /* Replace in Line */
#define FX_REPLINE 116
#define FN_SFCOL 117 /* Set Fill Column */
#define FX_SFCOL 117
#define FN_SFPREF 118 /* Set Fill Prefix */
#define FX_SFPREF 118
#define FN_FILLMODE 119 /* Auto Fill Mode */
#define FX_FILLMODE 119
#define FN_TEXTMODE 120 /* Text Mode */
#define FX_TEXTMODE 0
#define FN_INDATM 121 /* Indent According to Mode */
#define FX_INDATM 121
#define FN_INDNL 122 /* Indent New Line */
#define FX_INDNL 122
#define FN_BACKIND 123 /* Back to Indentation */
#define FX_BACKIND 123
#define FN_INDCOMM 124 /* Indent for Comment */
#define FX_INDCOMM 124
#define FN_INDREL 125 /* Indent Relative */
#define FX_INDREL 125
#define FN_MATCHBRACK 129 /* Match Bracket */
#define FX_MATCHBRACK 0
#define FN_PSHINF 130 /* Push to Inferior */
#define FX_PSHINF 130
#define FN_RETSUP 131 /* Return to Superior */
#define FX_RETSUP 131
#define FN_WFEXIT 132 /* Write File Exit */
#define FX_WFEXIT 132
#define FN_BKPT 140 /* Hit Breakpoint */
#define FX_BKPT 140
#define FN_DEBUG 141 /* Debug Mode */
#define FX_DEBUG 141
#define FN_XUCMD 150 /* Execute Unix Command */
#define FX_XUCMD 0
#define FN_MAKE 151 /* Execute Make */
#define FX_MAKE 0
#define FN_NXTERR 152 /* Find Next Error */
#define FX_NXTERR 0
#define FN_ICOXCMD 153 /* ICO Extend Command */
#define FX_ICOXCMD 0
#define FN_ICOTYPFNS 154 /* ICO Typeset Funs */
#define FX_ICOTYPFNS 0
#define FN_ICOSPIFNS 155 /* ICO Spec Input Funs */
#define FX_ICOSPIFNS 0
#define FN_STUFFSEL 156 /* Stuff Selection */
#define FX_STUFFSEL 0
#define FN_SELREGION 157 /* Select Region */
#define FX_SELREGION 0

View file

@ -1,826 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEFILE File reading/writing functions
*/
#include "elle.h"
#include <stdio.h> /* Use "standard" I/O package for writing */
#ifndef BUFSIZ
#define BUFSIZ BUFSIZE /* Some places use wrong name in stdio.h */
#endif /*-BUFSIZ*/
#if V6
struct stat {
int st_dev;
int st_ino;
char *st_mode;
char st_nlink;
char st_uid;
char st_gid;
char st_size0;
char st_size;
int st_addr[8];
long st_atime;
long st_mtime;
};
#define ENOENT (2) /* Syscall error - no such file or dir */
#else
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif /*-V6*/
#if TOPS20
#include <sys/file.h> /* Get open mode bits */
#endif
extern char *strerror(); /* Return error string for errno */
extern struct buffer *make_buf(), *find_buf();
char *fncons(), *last_fname();
int hoardfd = -1; /* Retain a FD here to ensure we can always write */
/* Flags for iwritfile() */
#define WF_SMASK 07 /* Source Mask */
#define WF_SBUFF 0 /* source: Buffer */
#define WF_SREG 1 /* source: Region */
#define WF_SKILL 2 /* source: Last Kill */
#define WF_ASK 010 /* Ask for filename to write to */
static int iwritfile();
/* EFUN: "Find File" */
/* Ask user for a filename and do a find_file for it.
* If buffer exists for that filename, select that buffer.
* Else create a buffer for it, and read in the file if it exists.
*/
f_ffile()
{ int find_file();
#if IMAGEN
hack_file("Visit file: ", find_file);
#else
hack_file("Find file: ", find_file);
#endif /*-IMAGEN*/
}
/* EFUN: "Read File" */
/* User read_file function, asks user for a filename and reads it
*/
f_rfile() { u_r_file("Read file: "); }
/* EFUN: "Visit File" */
/* Same as Read File, with different prompt.
*/
f_vfile() { u_r_file("Visit file: "); }
u_r_file(prompt)
char *prompt;
{ register char *f_name;
register struct buffer *b;
if((f_name = ask (prompt))==0) /* prompt user for filename */
return; /* user punted... */
b = cur_buf;
if(*f_name == '\0')
{ if (b -> b_fn == 0)
ding("No default file name.");
else read_file(b -> b_fn);
}
else read_file(f_name);
chkfree(f_name);
}
/* EFUN: "Insert File" */
/* Asks for a filename and inserts the file at current location.
* Point is left at beginning, and the mark at the end.
*/
f_ifile()
{ int ins_file();
hack_file("Insert file: ", ins_file);
}
/* EFUN: "Save File" */
/* Save current buffer to its default file name
*/
f_sfile()
{ if(cur_buf->b_flags&B_MODIFIED)
return(iwritfile(WF_SBUFF)); /* Write buffer, don't ask */
else
{ saynow("(No changes need to be written)");
return(1);
}
}
#if FX_SAVEFILES || FX_WFEXIT
/* EFUN: "Save All Files" */
/* F_SAVEFILES - Offer to save all modified files.
* With argument, doesn't ask.
* Returns 0 if user aborts or if an error happened.
*/
f_savefiles()
{ register struct buffer *b, *savb;
register int res = 1;
char *ans;
savb = cur_buf;
for (b = buf_head; res && b; b = b->b_next)
if ((b->b_flags & B_MODIFIED) && b->b_fn)
{ if(exp_p) /* If arg, */
{ chg_buf(b); /* just save, don't ask */
res = f_sfile();
continue; /* Check next buffer */
}
/* Ask user whether to save */
ans = ask("Buffer %s contains changes - write out? ",
b->b_name);
if(ans == 0)
{ res = 0; /* User aborted */
break;
}
if (upcase(*ans) == 'Y')
{ chg_buf(b);
res = f_sfile(); /* Save File */
}
chkfree(ans);
}
chg_buf(savb);
return(res);
}
#endif /*FX_SAVEFILES||FX_WFEXIT*/
/* EFUN: "Write File" */
/* Write out the buffer to an output file.
*/
f_wfile()
{ return iwritfile(WF_ASK|WF_SBUFF);
}
/* EFUN: "Write Region" */
/* Write region out to a file
*/
f_wreg()
{ return iwritfile(WF_ASK|WF_SREG); /* Ask, write region */
}
#if FX_WLASTKILL
/* EFUN: "Write Last Kill" (not EMACS) */
/* Write current kill buffer out to a file.
** This is mainly for MINIX.
*/
extern int kill_ptr; /* From EEF3 */
extern SBSTR *kill_ring[];
f_wlastkill()
{ return iwritfile(WF_ASK|WF_SKILL);
}
#endif
/* HACK_FILE - intermediate subroutine
*/
hack_file(prompt, rtn)
char *prompt;
int (*rtn)();
{ register char *f_name;
if((f_name = ask(prompt)) == 0)
return;
if (*f_name != '\0') /* Check for null answer */
(*rtn)(f_name);
chkfree(f_name);
}
/* FIND_FILE(f_name)
* If there is a buffer whose fn == f_name, select that buffer.
* Else create one with name of the last section of f_name and
* read the file into that buffer.
*/
find_file(f_name)
register char *f_name;
{ register struct buffer *b;
register char *ans;
char *lastn;
int fd;
#if IMAGEN
char real_name[128]; /* File name w/ expanded ~ and $ */
expand_file(real_name, f_name);
f_name = real_name;
#endif /*IMAGEN*/
for (b = buf_head; b; b = b -> b_next)
if(b->b_fn && (strcmp (b -> b_fn, f_name) == 0))
break;
if (b) /* if we found one */
{ sel_buf(b); /* go there */
return; /* and we are done */
}
if((fd = open(f_name,0)) < 0) /* See if file exists */
{ if(errno != ENOENT) /* No, check reason */
{ ferr_ropn(); /* Strange error, complain */
return; /* and do nothing else. */
}
}
else close(fd); /* Found! Close FD, since the */
/* read_file rtn will re-open. */
lastn = last_fname(f_name); /* Find buffer name */
b = find_buf(lastn); /* Is there a buffer of that name? */
if (b && (ex_blen(b) || b->b_fn))
{ ans = ask("Buffer %s contains %s, which buffer shall I use? ",
b -> b_name, b->b_fn ? b->b_fn : "something");
if(ans == 0) return; /* Aborted */
if (*ans != '\0') /* if null answer, use b */
b = make_buf(ans); /* else use ans */
chkfree(ans);
}
else
b = make_buf(lastn);
sel_buf(b);
if(fd < 0) /* If file doesn't exist, */
{ set_fn(f_name); /* just say "new" and set filename */
return; /* and return right away. */
}
if (read_file(f_name)==0) /* File exists, read it in! */
{ if(b->b_fn) /* Failed... if filename, */
{ chkfree(b->b_fn); /* flush the filename. */
b->b_fn = 0;
}
}
}
/* READ_FILE(f_name)
* Reads file into current buffer, flushing any
* previous contents (if buffer modified, will ask about saving)
* Returns 0 if failed.
*/
read_file(f_name)
char *f_name;
{
#if IMAGEN
struct stat s;
char real_name[128]; /* File name w/ expanded ~ and $ */
#endif /*IMAGEN*/
if(!zap_buffer()) /* Flush the whole buffer */
return; /* Unless user aborts */
#if IMAGEN
expand_file(real_name, f_name);
f_name = real_name; /* Hack, hack! */
#endif /*IMAGEN*/
set_fn(f_name);
if (ins_file(f_name)==0)
return 0;
f_bufnotmod(); /* Say not modified now */
#if IMAGEN
stat(f_name, &s); /* Get file stat */
cur_buf->b_mtime = s.st_mtime; /* and pick out last-modified time */
#endif /*IMAGEN*/
return 1;
}
/* INS_FILE(f_name)
* Inserts file named f_name into current buffer at current point
* Point is not moved; mark is set to end of inserted stuff.
* Returns 0 if failed, 1 if won.
*/
ins_file (f_name)
char *f_name;
{ register int ifd;
register SBSTR *sd;
chroff insdot; /* To check for range of mods */
#if IMAGEN
char real_name[128]; /* File name w/ expanded ~ and $ */
expand_file(real_name, f_name);
f_name = real_name;
#endif /*IMAGEN*/
#if !(TOPS20)
if((ifd = open(f_name,0)) < 0)
#else
if((ifd = open(f_name,O_RDONLY|O_UNCONVERTED)) < 0)
#endif /*TOPS20*/
{ ferr_ropn(); /* Can't open, complain */
return 0; /* no redisplay */
}
errno = 0;
if((sd = sb_fduse(ifd)) == 0)
{ if (ifd >= SB_NFILES)
dingtoo(" Cannot read - too many internal files");
else if (errno)
ferr_ropn();
else errbarf("SB rtn cannot read file?");
close(ifd);
return 0;
}
sb_sins(cur_buf,sd);
insdot = e_dot();
f_setmark(); /* Set mark at current ptr */
if(cur_dot != insdot) /* If pointer was advanced, */
buf_tmat(insdot); /* then stuff was inserted */
e_gocur();
return 1;
}
ferr_ropn() { ferr(" Cannot read"); }
ferr_wopn() { ferr(" Cannot write"); }
ferr(str)
char *str;
{ saytoo(str);
saytoo(" - ");
dingtoo(strerror(errno));
}
/* IWRITFILE - auxiliary for writing files.
** Returns 1 if write successful, 0 if not.
*/
static int
iwritfile(flags)
int flags;
{ register struct buffer *b;
register char *o_name; /* output file name */
int styp = flags & WF_SMASK; /* Source type, one of WF_Sxxx */
char *prompt;
#ifdef STDWRITE
register FILE *o_file; /* output file pointer */
char obuf[BUFSIZ];
chroff dotcnt;
#endif /*STDWRITE*/
int ofd; /* output file FD */
SBSTR *sd;
char fname[FNAMSIZ]; /* To avoid chkfree hassle */
char newname[FNAMSIZ]; /* for robustness */
char oldname[FNAMSIZ]; /* ditto */
int res;
struct stat statb;
int statres;
#if IMAGEN
struct stat s;
char real_name[128]; /* File name w/ expanded ~ and $ */
#endif /*IMAGEN*/
res = 1; /* Let's keep track of success */
/* Check for existence of source, and set prompt string */
switch(styp)
{
case WF_SBUFF:
prompt = "Write File: ";
break;
case WF_SREG:
if(!mark_p)
{ dingtoo(" No Mark!");
return(0);
}
prompt = "Write Region: ";
break;
#if FX_WLASTKILL
case WF_SKILL:
if(!kill_ring[kill_ptr])
{ dingtoo("No killed stuff");
return(0);
}
prompt = "Write Last Kill: ";
break;
#endif
default: /* Internal error */
errbarf("bad iwritfile arg");
return 0;
}
if (flags&WF_ASK)
{ if((o_name = ask(prompt))==0)
return(0); /* User punted. */
strcpy(&fname[0], o_name); /* Copy filename onto stack */
chkfree(o_name);
}
o_name = &fname[0];
b = cur_buf;
if (!(flags&WF_ASK) || (*o_name == '\0'))
{ if (b->b_fn == 0)
{ ding("No default file name.");
return(0);
}
strcpy(o_name, b->b_fn);
}
#if IMAGEN
expand_file(real_name, o_name);
o_name = real_name; /* Hack, hack */
#endif /*IMAGEN*/
statres = stat(o_name,&statb); /* Get old file's info (if any) */
#if IMAGEN
/* Now, make sure someone hasn't written the file behind our backs */
if ((styp==WF_SBUFF) && !(flags&WF_ASK)
&& b->b_fn && stat(b->b_fn, &s) >= 0)
if (s.st_mtime != b->b_mtime)
{ char *ans;
ans = ask("Since you last read \"%s\", someone has changed it.\nDo you want to write it anyway (NOT RECOMMENDED!)? ",
b->b_fn);
if (ans == 0 || upcase(*ans) != 'Y')
{
ding("I suggest you either read it again, or\nwrite it to a temporary file, and merge the two versions manually.");
if (ans) chkfree(ans);
return(0);
}
if (ans) chkfree(ans);
}
#endif /*IMAGEN*/
/* Try to get around major UNIX screw of smashing files.
* This still isn't perfect (screws up with long filenames) but...
* 1. Write out to <newname>
* 2. Rename <name> to <oldname> (may have to delete existing <oldname>)
* 3. Rename <newname> to <name>.
*/
fncons(oldname,ev_fno1,o_name,ev_fno2); /* Set up "old" filename */
fncons(newname,ev_fnn1,o_name,ev_fnn2); /* Set up "new" filename */
unlink(newname); /* Ensure we don't clobber */
unhoard(); /* Now give up saved FD */
#if !(V6) /* Standard V6 doesn't have access call */
if(statres >= 0) /* If file exists, */
{ if(access(o_name, 2) != 0) /* check for write access */
{ ferr_wopn();
res = 0; /* Failure */
goto wdone;
}
}
#endif /*-V6*/
#ifdef STDWRITE
if(flags&WF_ASK)
{ if((o_file = fopen(newname, "w")) ==0) /* Create new output file */
{ ferr_wopn();
res = 0; /* Failure */
goto wdone;
}
setbuf(o_file,obuf); /* Ensure always have buffer */
}
else /* New stuff */
#endif /*STDWRITE*/
{
#if !(TOPS20)
if((ofd = creat(newname,ev_filmod)) < 0)
#else
if((ofd = open(newname,O_WRONLY|O_UNCONVERTED)) < 0)
#endif /*TOPS20*/
{ ferr_wopn();
res = 0; /* Failure */
goto wdone;
}
}
if (styp==WF_SBUFF)
set_fn(o_name); /* Won, so set default fn for buff */
#if IMAGEN
saynow("Writing ");
switch(styp)
{ case WF_SBUFF: saytoo(b->b_fn); break;
case WF_SREG: saytoo("region"); break;
#if FX_WLASTKILL
case WF_SKILL: saytoo("last kill"); break;
#endif
}
sayntoo("...");
#else
saynow("Writing...");
#endif /*-IMAGEN*/
#if !(TOPS20) /* T20 does all this already */
if(statres >= 0) /* Get old file's modes */
{ /* Try to duplicate them */
/* Do chmod first since after changing owner we may not
** have permission to change mode, at least on V6.
*/
chmod(newname,statb.st_mode & 07777);
#if V6
chown(newname, (statb.st_gid<<8)|(statb.st_uid&0377));
#else
chown(newname,statb.st_uid,statb.st_gid);
#endif /*-V6*/
}
#if V6
/* If no old file existed, and we are a V6 system, try to set
* the modes explicitly. On V7 we're OK because the user can
* diddle "umask" to get whatever is desired.
* On TOPS-20 of course everything is all peachy.
*/
else chmod(newname, ev_filmod);
#endif /*V6*/
#endif /*TOPS20*/
#ifdef STDWRITE
if(flags&WF_ASK)
{ switch(styp)
{
case WF_SBUFF:
dotcnt = e_blen();
e_gobob();
break;
case WF_SREG:
if((dotcnt = mark_dot - cur_dot) < 0)
{ e_goff(dotcnt);
dotcnt = -dotcnt;
}
else e_gocur();
break;
/* WF_SKILL not implemented here */
}
while(--dotcnt >= 0)
putc(sb_getc(((SBBUF *)b)), o_file);
e_gocur();
fflush(o_file); /* Force everything out */
res = ferror(o_file); /* Save result of stuff */
fclose(o_file); /* Now flush FD */
}
else /* New stuff */
#endif /*STDWRITE*/
{
switch(styp)
{
case WF_SBUFF:
res = sb_fsave((SBBUF *)b, ofd);
break;
case WF_SREG:
e_gocur();
sd = e_copyn((chroff)(mark_dot - cur_dot));
res = sbx_aout(sd, 2, ofd);
sbs_del(sd);
break;
#if FX_WLASTKILL
case WF_SKILL:
res = sbx_aout(kill_ring[kill_ptr], 2, ofd);
break;
#endif
}
close(ofd);
}
if(errno = res)
{ ferr(" Output error");
res = 0; /* Failure */
goto wdone;
}
else
res = 1; /* Success so far */
if(styp == WF_SBUFF)
f_bufnotmod(); /* Reset "buffer modified" flag */
/* Here we effect the screw-prevention steps explained earlier. */
/* TOPS-20, with generation numbers, need not worry about this. */
#if TOPS20
saynow("Written");
#else /*-TOPS20*/
#if IMAGEN /* KLH -- This conditional bracketting is prone to lossage */
/* Only create the .BAK file once per editing session!! */
if ((styp==WF_SBUFF) || !(b->b_flags & B_BACKEDUP))
{ if (styp==WF_SBUFF)
b->b_flags |= B_BACKEDUP;
#endif /*IMAGEN*/
unlink(oldname); /* remove any existing "old" file */
if(link(o_name,oldname) == 0) /* Rename current to "old" */
unlink(o_name);
/* Here is the critical point... if we stop here, there is no
* longer any file with the appropriate filename!!!
*/
#if IMAGEN
}
else
unlink(o_name);
#endif /*IMAGEN*/
if(link(newname,o_name) == 0) /* Rename "new" to current */
{ unlink(newname);
#if IMAGEN
sayntoo("OK");
#else
saynow("Written");
#endif /*-IMAGEN*/
}
else
{ dingtoo("rename error!");
res = 0;
}
#endif /*-TOPS20*/
#if IMAGEN
/* Update the last-modified time for the file in this buffer */
if ((styp == WF_SBUFF) && b->b_fn)
{ stat(b->b_fn, &s);
b->b_mtime = s.st_mtime;
}
#endif /*IMAGEN*/
wdone:
hoard(); /* Get back a retained FD */
return(res);
}
/* FNCONS(dest,pre,f_name,post)
* Specialized routine to cons up a filename string into "dest",
* given prefix and postfix strings to be added onto last component of
* filename.
*/
char *
fncons(dest, pre, f_name, post)
char *dest,*pre,*f_name,*post;
{ register char *cp, *cp2;
char *last_fname();
cp = dest;
*cp = 0; /* Make dest string null initially */
cp2 = last_fname(f_name); /* Get pointer to beg of last name */
strncat(cp,f_name,cp2-f_name); /* Copy first part of filename */
if(pre) strcat(cp, pre); /* If prefix exists, add it on */
cp = last_fname(cp); /* Recheck in case levels added */
strcat(cp, cp2); /* Now add last name */
if(cp2 = post) /* If there's a postfix, must check */
{ cp[FNAMELEN-strlen(cp2)] = 0; /* and cut dest so postfix */
strcat(cp, cp2); /* will fit on end. */
}
return(dest);
}
/* LAST_FNAME(string)
* Get the last component of a file name. Returns pointer to
* start of component; does NOT copy string!
*/
char *
last_fname(f_name)
char *f_name;
{ register char *cp, *p;
register int c;
p = f_name; /* pointer to last slash */
cp = p;
while(c = *cp++)
if(c == '/')
p = cp; /* point to after the slash */
return(p);
}
/* SET_FN(string)
* Set the default filename for current buffer to "string".
*/
set_fn (string)
char *string;
{ register struct buffer *b;
register char *str;
#if IMAGEN
register char *cp;
register int len;
#endif /*IMAGEN*/
char *strdup();
b = cur_buf;
str = strdup(string); /* Copy now in case copying self */
if(b->b_fn)
chkfree(b->b_fn);
b -> b_fn = str;
#if IMAGEN
/* Do mode determination based on file name (HACK HACK) */
len = strlen(str);
b->b_flags &= ~(B_CMODE|B_TEXTMODE);
if (len > 4)
{ if (strcmp(&str[len - 5], "draft") == 0)
b->b_flags |= B_TEXTMODE;
else
{ cp = &str[len - 4];
if (strcmp(cp, ".txt") == 0 ||
strcmp(cp, ".mss") == 0)
b->b_flags |= B_TEXTMODE;
}
}
if (len > 2)
{ cp = &str[len - 2];
if (strcmp(cp, ".h") == 0 || strcmp(cp, ".c") == 0)
b->b_flags |= B_CMODE;
}
#endif /*IMAGEN*/
redp(RD_MODE);
}
/* SAVEWORLD - Attempt to save all changes user has made.
* Currently this amounts to writing out all modified buffers
* to the files $HOME/+buffername. If a buffer is given as argument,
* only that buffer is saved.
* This is only called from the error handling routines with
* the TTY either gone or in normal (non-edit) mode. The "grunt"
* flag says whether to output feedback during the saving process.
*/
saveworld(bp, grunt)
struct buffer *bp;
int grunt;
{ register struct buffer *b;
register int wfd;
char sfname[FNAMSIZ];
struct buffer *sel_mbuf();
unhoard(); /* Ensure a FD is free for writing */
if(b = bp) goto once;
while(!bp && (b = sel_mbuf(b)))
{
once: strcat(strcat(strcpy(sfname,homedir),"/+"),b->b_name);
if(grunt) printf("Saving %s...",sfname);
#if !(TOPS20)
if((wfd = creat(sfname, ev_filmod)) < 0)
#else
if((wfd = open(sfname,O_WRONLY|O_UNCONVERTED)) < 0)
#endif /*TOPS20*/
{ if(grunt)
printf(" error - %s\n", strerror(errno));
}
else
{ sb_fsave((SBBUF *)b, wfd);
close(wfd);
if(grunt) printf("\n");
}
b->b_flags &= ~B_MODIFIED;
}
hoard();
}
/* HOARD, UNHOARD - Routines to save a FD for writing, to make sure
* that we can always write out a buffer no matter how many
* file descriptors we are currently using.
*/
hoard() /* Stash away a FD */
{ if(hoardfd <= 0)
#if !(TOPS20)
hoardfd = open("nul:", 1);
#else
hoardfd = open("/dev/null", 1);
#endif
}
unhoard() /* Give up our stashed FD so it can be re-used */
{ close(hoardfd);
hoardfd = -1;
}
#if IMAGEN
#include <pwd.h>
#include <ctype.h>
/*
* expand_file: expand any ~user-name/ or $env-var/ prefixes in sfn,
* producing the full name in dfn
*/
expand_file(dfn, sfn)
register char *dfn, *sfn;
{
register char *sp, *tp;
register int c;
register struct passwd *pw;
char ts[128];
/* HORRIBLE, GROSS, DISGUSTING HACK: if the destination and
* source strings are identical (same pointer), then do not
* do any expansion--this happens to work with the current
* structure very well, since multiple expansions may happen.
*/
if (dfn == sfn)
return;
ts[0] = 0;
/* If have a leading $, then expand environment variable */
if (*sfn == '$')
{ ++sfn;
tp = ts;
while (*tp++ = *sfn)
if (!isalnum(*sfn))
break;
else
++sfn;
*--tp = 0; /* Just in case */
strcpy(ts, getenv(ts)); /* MARGINAL!! */
}
/* If have leading ~, then expand login name (null means $HOME) */
else if (*sfn == '~')
{ ++sfn;
if (*sfn == '/' || *sfn == 0)
strcpy(ts, getenv("HOME"));
else
{ tp = ts;
while (*sfn && *sfn != '/')
*tp++ = *sfn++;
*tp = 0;
pw = (struct passwd *)getpwnam(ts);
if (! pw)
strcpy(ts, "???");
else
strcpy(ts, pw->pw_dir);
}
}
/* Now, ts is either empty or contains the expansion;
* sfn has been updated correctly.
*/
strcpy(dfn, ts);
strcat(dfn, sfn);
}
#endif /*IMAGEN*/

View file

@ -1,642 +0,0 @@
/* ELLE - Copyright 1982, 1985, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEFILL Fill Mode functions
*/
#include "elle.h"
extern int ev_fcolumn; /* Fill Column variable (defined in EEVINI) */
#if FX_SFPREF
char *fill_prefix; /* Fill Prefix variable */
int fill_plen; /* Length of Fill Prefix (0 = no prefix) */
#endif /*FX_SFPREF*/
#if FX_FILLMODE
int fill_mode = 0; /* TRUE when Auto Fill Mode is on */
int *fill_trig; /* Pointer to fill-trigger chbit array */
static char *fill_initrig = " \t.,;:)!";
#endif /*FX_FILLMODE*/
/* Following stuff for testing routines on */
/*
1 2 3 4 5 6 7
0123456789012345678901234567890123456789012345678901234567890123456789012345
Okay... more stuff to hack. Okay. a b c d e f g h i j k l m
n o p q r s t u v w x y z dfsd stuff to hack 01234 Okay testing
more stuff to hack. Okay... more stuff to hack more stuff to
hack. Okay... more stuff to line long stuff to hack. Okay...
even more gap and. period. okay, end of stuff.
This is another fence.
*/
#if FX_SFCOL
/* EFUN: "Set Fill Column" */
f_sfcol()
{ register int linel;
char temp[20];
linel = exp_p ? exp : d_curind();
if(linel < 0) linel = 0;
say("Fill column = ");
dottoa(temp,(chroff)linel);
saytoo(temp);
ev_fcolumn = linel;
}
#endif /*FX_SFCOL*/
#if FX_SFPREF
/* EFUN: "Set Fill Prefix" */
f_sfpref()
{ register int i;
register char *cp;
if((i = cur_dot - e_boldot()) > MAXLINE)
{ ding("Absurd Fill Prefix");
return;
}
if(fill_prefix)
{ chkfree(fill_prefix);
fill_plen = 0;
}
if(i <= 0)
{ fill_prefix = 0;
cp = "";
}
else
{ fill_prefix = cp = memalloc((SBMO)(i+1));
fill_plen = i;
e_gobol();
do { *cp++ = e_getc(); }
while(--i);
*cp = 0;
cp = fill_prefix;
}
say("Fill Prefix = \"");
saytoo(cp);
saytoo("\"");
}
/* TSTFILLP(lim) - Check for existence of Fill Prefix at current dot. If
* not there, returns 0 without changing dot. If there, returns
* 1 and leaves dot immediately after the Fill Prefix.
* Lim = # of chars allowed to scan from buffer.
*/
tstfillp(lim)
int lim;
{ register int i;
register char *cp;
chroff savdot;
if(!(i = fill_plen) || (i > lim))
return(0);
savdot = e_dot();
cp = fill_prefix;
do { if(*cp++ != e_getc())
{ e_go(savdot);
return(0);
}
} while(--i);
return(1);
}
#endif /*FX_SFPREF*/
#if FX_FILLREG || FX_FILLPARA
/* ED_FILL(start, end, flag) - Fill a region.
* Flag 0 for full filling; extra whitespace is flushed. First
* word is always retained.
* 1 for skimpy filling such as Auto-Fill likes.
* Extra whitespace is NOT flushed, except at
* beginning of a newly created line.
* This is not yet implemented however.
* Note: updates cur_dot to compensate for changes in buffer, and returns
* there when done!
* Note: Checks for Fill Prefix when it exists.
*/
ed_fill(begloc, endloc, flag)
chroff begloc, endloc;
int flag;
{ register int c;
register int len, lastc;
chroff savloc;
int lastbrk;
int parlen;
parlen = endloc - begloc;
if(parlen < 0)
{ begloc = endloc;
parlen = -parlen;
}
e_go(begloc);
len = d_curind(); /* Set up current col */
#if FX_SFPREF
/* If at beg of line, check for fill prefix and skip over it */
if((len == 0) && tstfillp(parlen))
{ parlen -= fill_plen;
len = d_curind();
}
#endif /*FX_SFPREF*/
lastbrk = 0; /* Put next word on no matter what. */
c = 0;
for(;;)
{
#if ICONOGRAPHICS
if (c != ')' && c != '"') /* allow for two sp after .) or ." */
#endif /*ICONOGRAPHICS*/
lastc = c;
if(--parlen < 0) break;
c = e_getc();
if(c == EOF)
break;
#if FX_SFPREF
/* If at beg of line, check for fill prefix and flush it */
if((c == LF) && tstfillp(parlen))
{ e_igoff(-(fill_plen+1));
e_ovwc(c = SP);
e_deln((chroff)fill_plen);
parlen -= fill_plen;
if(cur_dot >= e_dot())
cur_dot -= fill_plen;
}
#endif /*FX_SFPREF*/
if(c == TAB || c == LF) /* Replace tabs+eols by sps */
{ e_backc(); /* Back up 1 */
e_ovwc(c = SP);
}
if(c == SP)
{ if(lastc == SP)
{ e_rdelc();
if(cur_dot > e_dot()) --cur_dot;
continue;
}
lastbrk = len;
if(lastc == '.' || lastc == '!' || lastc == '?'
#if ICONOGRAPHICS
|| lastc == ':'
#endif /*ICONOGRAPHICS*/
)
{ if(--parlen < 0) goto done;
if((c = e_getc()) == EOF)
goto done;
len++;
if(c != SP)
{ e_backc();
e_putc(c = SP);
if(cur_dot >= e_dot()) ++cur_dot;
}
}
}
#if ICONOGRAPHICS
if (c == BS) /* adjust for backspaces */
if ((len -= 2) < 0) len = 0;
#endif /*ICONOGRAPHICS*/
/* Normal char */
if(++len > ev_fcolumn && lastbrk) /* If went too far */
{ c = lastbrk - len; /* Must put EOL at last SP */
e_igoff(c);
parlen -= c; /* C is negative, actually adding */
parlen--;
e_ovwc(LF);
lastbrk = 0;
len = 0;
c = SP; /* Pretend this char was space */
#if FX_SFPREF
if(fill_plen)
{ if(cur_dot >= e_dot())
cur_dot += fill_plen;
/* Better hope no nulls in prefix! */
e_sputz(fill_prefix);
len = d_curind();
}
#endif /*FX_SFPREF*/
}
}
done: savloc = cur_dot;
e_setcur(); /* Reached paragraph end, set cur_dot temporarily */
buf_tmod(begloc-cur_dot); /* So that proper range is marked */
e_gosetcur(savloc); /* Then restore original cur_dot */
}
#endif /*FX_FILLREG || FX_FILLPARA*/
#if FX_FILLMODE
/* EFUN: "Auto Fill Mode" */
/* Toggles Auto Fill Mode (a minor mode). */
f_fillmode()
{ register char *cp;
int *chballoc();
fill_mode = fill_mode ? 0 : 1;
if(!fill_trig)
{ fill_trig = chballoc(128);
for(cp = fill_initrig; *cp; ++cp)
chbis(fill_trig, *cp);
}
redp(RD_MODE);
}
/* Called by F_INSSELF to handle char insertion in Auto Fill mode */
fx_insfill(c)
int c;
{
ed_insn(c,exp);
if(chbit(fill_trig, c))
{ fill_cur_line();
}
}
fill_cur_line()
{
register int foundit, i;
chroff lastbrkdot, boldot;
boldot = e_boldot();
/* First back up to find place to make first break. */
e_bwsp();
lastbrkdot = e_dot();
foundit = 0;
for(foundit = 0; foundit >= 0;)
{ if((i = d_curind()) <= ev_fcolumn)
{ if(foundit)
foundit = -1;
else break;
}
else ++foundit;
while (!c_wsp (e_rgetc ())) ;
e_bwsp();
lastbrkdot = e_dot();
if(lastbrkdot <= boldot)
{ lastbrkdot = boldot;
break;
}
}
if(foundit)
ed_fill(lastbrkdot, e_eoldot(), 1);
}
#endif /*FX_FILLMODE*/
#if IMAGEN
#if FX_TEXTMODE
/* EFUN: "Text Mode Toggle" (not EMACS) */
f_textmode()
{
cur_buf->b_flags ^= B_TEXTMODE;
redp(RD_MODE);
}
#endif /*FX_TEXTMODE*/
int curr_indent = -1; /* Current indent (for text mode autowrap) */
/* (misnomered: actually current column) */
chroff best_break; /* Best break point so far */
/* Fill-mode version of "Insert Self" */
fim_insself(c)
int c;
{
register int ind, flags = cur_buf->b_flags;
/* In Text mode, auto-wrap happens at spaces after fill column */
if (c == SP && flags & B_TEXTMODE && exp == 1 && magic_wrap(c))
return;
/* In C-mode, tab stops are every 4 columns */
else if (c == TAB && flags & B_CMODE &&
(ind = magic_backto_bol()) >= 0)
ed_indto((ind + 4) & ~3);
else
{ ed_insn(c, exp);
/* Keep track of indent, once we have a grip on it */
if (last_cmd == INSCMD && curr_indent != -1)
{ this_cmd = INSCMD; /* Keep the ball rolling */
if (c == TAB)
curr_indent = ((curr_indent + 8) & ~7)
+ 8 * (exp - 1);
else if (c == '\n')
curr_indent = 0;
else if (c < SP || c > 0176)
curr_indent += (2 * exp);
else
curr_indent += exp;
}
}
}
/* Fill-mode version of "Delete Character" */
fim_dchar()
{ /* In C mode, deleting at BOL should do fake TAB preservation */
if (cur_buf->b_flags & B_CMODE)
{ chroff savdot;
register int c, indent;
if (e_rgetc() != LF)
{ /* Only hack this at BOL */
e_getc();
goto normal;
}
e_getc();
savdot = e_dot();
indent = 0;
while ((c = e_getc()) == SP || c == TAB)
if (c == SP)
++indent;
else
indent = (indent + 8) & ~7;
e_rgetc();
if (indent >= 4)
{ ed_delete(savdot, e_dot());
ed_indto((indent - 4) & ~3);
f_begline(); /* HACK!!!! */
}
else
{ e_go(savdot);
ef_deln(exp);
}
}
else
normal: return (ef_deln(exp));
}
/* Fill-mode version of "Backward Delete Character" */
fim_bdchar()
{ register int ind;
/* If in C mode, and deleting into white space at BOL, hack tabs */
if (exp == 1 && cur_buf->b_flags & B_CMODE &&
(ind = magic_backto_bol()) > 0)
ed_indto(ind < 4 ? ind - 1 : ((ind - 4) & ~3));
else
return (ef_deln (-exp));
}
/* Fill-mode version of "CRLF" */
fim_crlf()
{ register int i;
if(e_getc() == LF
&& exp == 1
&& e_lblankp() && e_lblankp())
{ e_gocur();
e_gonl();
e_setcur();
ed_delete(e_dot(), e_eoldot());
}
else
{ e_gocur();
#if IMAGEN
if (cur_buf->b_flags & B_TEXTMODE && exp == 1 &&
magic_wrap('\n'))
return;
else
#endif /*IMAGEN*/
if((i = exp) > 0)
do ed_crins();
while(--i);
}
}
/* Do all magic for auto-wrap in Text mode:
* return as did wrap (i.e., everything is taken care of)
*/
magic_wrap(tc)
int tc; /* "trigger char" */
{
register int c, indent, i, nc;
chroff savdot, modstart, breakdot;
savdot = e_dot();
nc = 0;
if (last_cmd == INSCMD && curr_indent != -1)
{ indent = curr_indent; /* Already know our indent */
breakdot = best_break;
}
else
{
#ifdef INDENTDEBUG
barf2("Full indent calculation");
#endif
for (nc = 0; (c = e_rgetc()) != EOF && c != '\n'; ++nc)
; /* nc: # chars to look at */
if (c == '\n') /* Go back over NL */
e_getc();
indent = 0;
/* Search for last line break point, leaving it in breakdot */
breakdot = (chroff)0;
while (--nc >= 0)
{ c = e_getc();
if (c == TAB)
indent = (indent + 8) & ~7;
else if (c < SP || c > 0176)
indent += 2;
else
++indent;
if ((c == SP || c == TAB) &&
(breakdot == (chroff)0 || (indent <= ev_fcolumn)))
breakdot = e_dot();
}
}
/* If there is nothing to do, get out */
if (indent <= ev_fcolumn)
{ e_go(savdot);
if (tc == SP)
{ curr_indent = indent;
best_break = (chroff)(savdot + 1); /* Remember here, also */
this_cmd = INSCMD; /* We do know current indent */
}
else if (tc == '\n')
{ curr_indent = 0;
best_break = (chroff)0;
this_cmd = INSCMD;
}
else
errbarf("bad trigger");
return(0);
}
if (breakdot == (chroff)0)
{
/* No breakpoint found or none needed, just break line at end
*/
e_go(savdot);
modstart = savdot;
e_putc('\n');
}
else
{
/* Get to breakpoint and replace with newline
*/
e_go(breakdot);
e_rdelc();
modstart = e_dot(); /* Remember where changes start */
e_putc('\n'); /* Insert line break */
e_go(savdot); /* Get back to trigger point */
}
if (e_rgetc() != '\n')
{ /* If not at line start, */
e_getc();
e_putc(tc); /* insert trigger character */
/* Once again, compute new indent by backing up to BOL */
for (nc = 0; (c = e_rgetc()) != EOF && c != '\n'; ++nc)
;
if (c == '\n') /* Go back over NL */
e_getc();
indent = 0;
breakdot = (chroff)0;
while (--nc >= 0)
{ /* Get back to current dot */
c = e_getc();
if (c == TAB)
indent = (indent + 8) & ~7;
else if (c < SP || c > 0176)
indent += 2;
else
++indent;
if ((c == SP || c == TAB) &&
(breakdot == (chroff)0 || (indent <= ev_fcolumn)))
breakdot = e_dot();
}
if (breakdot == (chroff)0) /* If no good break found, use dot */
breakdot = e_dot();
curr_indent = indent; /* Now we know where we are */
if (tc == '\n') /* If trigger was NL */
best_break = (chroff)0; /* indent is 0, and no best break */
else
best_break = breakdot; /* This is best break so far */
}
else
{ e_getc();
curr_indent = 0; /* At line start, no indent */
best_break = (chroff)0; /* Do not have a best break so far */
}
ed_setcur();
buf_tmat(modstart); /* Alert to potential changes */
this_cmd = INSCMD; /* Say we know where we are */
return(1);
}
/* Do lots of magic things for C-mode indent:
* erase back to BOL iff we are looking back at white space only,
* returning the indent level of the original dot
* (< 0 means no erasure done)
*/
/*#define MYDEBUG /* */
#ifdef MYDEBUG
reveal(msg, v1, v2, v3)
char *msg;
{
char ahint[128];
sprintf(ahint, msg, v1, v2, v3);
barf2(ahint);
}
#endif
magic_backto_bol()
{
chroff savdot;
register int c, indent, nc, i;
savdot = e_dot();
nc = 0;
while ((c = e_rgetc()) != EOF && c != LF)
{ ++nc; /* Count # chars */
if (c != SP && c != TAB)
{ e_go(savdot);
#ifdef MYDEBUG
reveal("fail: nc: %d", nc);
#endif
return -1;
}
}
if (c == LF) /* Go back over the LF */
e_getc();
indent = 0; /* (zero-based indent) */
savdot = e_dot(); /* BOL is now origin for delete */
for (i = 1; i <= nc; ++i)
if ((c = e_getc()) == SP)
++indent;
else /* (tab) */
indent = (indent + 8) & ~7;
if (nc > 0) /* Don't bother deleting nothing */
ed_delete(savdot, e_dot());
#ifdef MYDEBUG
reveal("indent: %d, nc: %d, foo: %d", indent, nc, 234);
#endif
return(indent);
}
#endif /*IMAGEN*/
#if ICONOGRAPHICS
/* Iconographics hack for Auto-Fill mode. Too big and clumsy, but
* retained for posterity in case it has some obscure feature.
*/
fill_current_line ()
{
chroff startpos, endpos, savepos, limitpos;
int i, foundit;
SBSTR *savep;
foundit = 0;
while (d_curind() > ev_fcolumn)
{
foundit = 1;
startpos = e_dot ();
e_bwsp ();
while (d_curind() > ev_fcolumn) /* back up to ends of wds*/
{ /* until <= fill column */
while (!c_wsp (e_rgetc ())) ;
e_bwsp ();
}
if (e_dot () == e_boldot ())
{ /* ding ("Word does not fit in fill column"); */
return(0);
}
savep = e_copyn (startpos - e_dot ());
e_setcur (); /* ed_delete does gocur */
ed_delete (savepos = e_dot (), startpos);
f_crlf(); /* Now insert newline */
e_sputz(fill_prefix); /* With fill prefix */
startpos += e_dot () - savepos;
if (d_curind() > ev_fcolumn)
{ ed_delete (savepos, e_dot ());
sb_sins (cur_buf, savep);
e_setcur ();
ding ("Fill prefix > fill column???");
return(0);
}
savepos = e_dot (); /* gun inherited initial whitespace */
sb_sins (cur_buf, savep);
e_go (savepos);
e_fwsp ();
if ((limitpos = e_dot ()) > startpos) limitpos = startpos;
/* in case rest of line was white */
ed_delete (savepos, limitpos);
e_gosetcur (startpos + savepos - limitpos);
}
return foundit;
}
#endif /*ICONOGRAPHICS*/

View file

@ -1,81 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEHELP - Help function
*/
#include "elle.h" /* include structure definitions */
#if FX_DESCRIBE
/* EFUN: "Describe" */
/* DESCRIBE - Help-command hack.
** Crude approximation of EMACS function.
*/
static struct buffer *help_buf;
f_describe()
{ register char *cp;
register int i, c;
char str[10];
struct buffer *savbuf, *b, *make_buf();
chroff bdot;
saynow("Help for command: ");
i = cmd_idx(c = cmd_read()); /* Get function idx for cmd */
if(c&CB_META) sayntoo("M-");
if(i == FN_PFXMETA)
{ sayntoo("M-");
i = cmd_idx(c = (cmd_read() | CB_META));
}
else if(i == FN_PFXEXT)
{ sayntoo("^X-");
i = cmd_idx(c = (cmd_read() | CB_EXT));
}
str[0] = c&0177;
str[1] = 0;
sayntoo(str);
/* Now read in the help file, if necessary */
savbuf = cur_buf;
if(help_buf)
chg_buf(help_buf);
else
{
saynow("Loading ");
sayntoo(ev_helpfile);
sayntoo("...");
chg_buf(help_buf = make_buf(" **HELP**"));
if(read_file(ev_helpfile) == 0)
{ chg_buf(savbuf);
kill_buf(help_buf);
help_buf = 0;
return;
}
}
/* Find function index in current buffer */
cp = str;
*cp++ = '<';
*cp++ = 'F';
cp = dottoa(cp, (chroff)i);
*cp++ = '>';
e_gobob();
if(e_search(str, cp-str, 0) == 0)
sayntoo(" No help found");
else
{
bdot = e_dot();
while(!e_lblankp()) e_gonl(); /* Move past 1st blank line */
b = make_buf(" *SHOW*");
sb_sins((SBBUF *)b, e_copyn(bdot - e_dot()));
mk_showin(b); /* Show the stuff */
kill_buf(b);
sayclr();
}
chg_buf(savbuf);
}
#endif /*FX_DESCRIBE*/

View file

@ -1,179 +0,0 @@
/* ELLE - Copyright 1982, 1985, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEKMAC - Keyboard Macro routines
* Modelled after the "e_macro.c" for ICONOGRAPHICS
* by C. D. Tavares, 9/11/82
*/
#include "elle.h"
#if FX_SKMAC /* Entire file is under this conditional! */
int kdef_mode; /* Set when collecting (a "minor mode") */
static int km_flag = 0; /* 1 = executing, -1 collecting, 0 neither */
static int km_exp; /* Arg to "Execute Kbd Macro" - # times more to xct */
static struct buffer *km_buf;
/* EFUN: "Start Kbd Macro" */
f_skmac()
{ register struct buffer *b;
struct buffer *make_buf();
if(km_flag)
{ ding("Kbd macro active, ignoring \"Start Kbd Macro\"");
return;
}
if((b = km_buf) == 0)
b = km_buf = make_buf(" *KBDMAC*");
ex_reset(b);
km_flag = -1; /* Say starting macro collection */
kdef_mode = 1;
redp(RD_MODE);
}
/* EFUN: "End Kbd Macro" */
f_ekmac()
{
if(km_flag > 0 && (--km_exp >= 0))
{ ex_go((SBBUF *)km_buf, (chroff)0);
}
else if(km_flag)
{ km_flag = 0;
kdef_mode = 0; /* Flush minor mode */
redp(RD_MODE);
}
}
/* EFUN: "Execute Kbd Macro" */
f_xkmac()
{
if(km_flag)
ding("Already in kbd macro!");
else if(km_buf == 0)
ding("No kbd macro defined");
else if((km_exp = exp-1) >= 0)
{
ex_go((SBBUF *)km_buf, (chroff) 0);
km_flag = 1; /* Start macro execution */
}
}
/* EFUN: "View Kbd Macro" */
f_vkmac()
{ register struct buffer *b, *savbuf;
chroff prmplen;
if(!(b = km_buf))
{ ding("No kbd macro defined");
return;
}
savbuf = cur_buf;
chg_buf(b);
e_gobob();
e_sputz("Current Kbd macro:\n\n");
prmplen = e_dot();
mk_showin(b); /* Show the macro buffer temporarily */
e_gobob();
chg_buf(savbuf);
sb_deln((SBBUF *)b, prmplen); /* Flush the prompt */
}
/* KM_GETC - return next command char from kbd macro being executed.
** This is < 0 if not executing kbd macro. Also responsible for
** gathering input for kbd macro.
*/
km_getc()
{ register int c;
while (km_flag > 0) /* Executing macro? */
{ c = sb_getc(((SBBUF *)km_buf)); /* Yes, get char */
if(c != EOF)
return(c); /* and return as cmd */
if(--km_exp >= 0) /* Macro done. Repeat? */
ex_go((SBBUF *)km_buf, (chroff)0); /* Yes */
else km_flag = 0; /* No, stop execution */
}
c = tgetc(); /* Get char from user (TTY) */
if(km_flag < 0) /* Save it if collecting macro */
{ sb_putc(((SBBUF *)km_buf), c);
}
return(c);
}
/* KM_INWAIT() - Return TRUE if any keyboard-macro input waiting.
*/
km_inwait()
{ register int c;
if(km_flag > 0)
if((c = sb_getc(((SBBUF *)km_buf))) != EOF || (km_exp > 0))
{ sb_backc(((SBBUF *)km_buf));
return(1);
}
return(0);
}
km_abort ()
{
if(km_flag > 0) /* Executing? */
km_flag = 0; /* Stop */
else if(km_flag < 0) /* Collecting? */
f_ekmac(); /* Close it out */
}
#endif /*FX_SKMAC*/
#if 0 /* Old unused stuff */
static char mode_buf [60];
add_mode (mode)
char *mode;
{
register char *cur, *c, *m;
if (cur_mode != mode_buf)
{
strcpy (mode_buf, cur_mode);
cur_mode = mode_buf;
}
if (cur_mode [0]) strcat (cur_mode, ", ");
strcat (cur_mode, mode);
make_mode ();
}
remove_mode (mode)
char *mode;
{
register char *cur, *c, *m;
if (*cur_mode == 0) return;
if (cur_mode != mode_buf)
{
strcpy (mode_buf, cur_mode);
cur_mode = mode_buf;
}
for (cur = cur_mode ; *cur ; cur++)
if (*cur == *mode) /* 1st char matches */
{
for (c = cur, m = mode ; *m && (*m == *c) ; m++, c++) ;
if (!(*m)) /* ok, mode matched */
{ /* kill leading ", " */
if (*(cur - 1) == ' ') --cur;
if (*(cur - 1) == ',') --cur;
for ( ; *cur = *c ; cur++, c++) ; /* recopy to end */
make_mode ();
return;
}
}
}
#endif /*COMMENT*/

View file

@ -1,513 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEMAIN ELLE Main Command Loop
*/
#include "elle.h"
#include <stdio.h>
#if !(V6)
#include <signal.h>
#else
#include "eesigs.h" /* Use this on V6 system */
#endif /*V6*/
char *argfile[MAXARGFILES]; /* Filename args at startup */
extern int (*sbm_debug)();
extern int (*sbv_debug)();
int (*vfy_vec)(); /* If non-zero, routine to verify data
* after each main-loop command */
main (argc, argv)
int argc;
char **argv;
{
register int c; /* Current command character */
register int i;
static int waitct;
extern int errsbm();
#if SUN
extern int sun_rdevf; /* from EESUN */
#endif
#ifdef STKMEM
char stackm[STKMEM]; /* Allocate some unused stack space */
#endif /*STKMEM*/
sbv_debug = errsbm; /* Load with addrs of routine to */
sbm_debug = errsbm; /* process SB and SBM errors. */
#ifdef STKMEM
sbm_init(&stackm[0],(SBMO)STKMEM); /* Initialize mem alloc rtns */
#endif /*STKMEM*/
#if SUN
sun_main(&argc, argv); /* On SUN, invoke window startup */
#endif /*SUN*/
setbuf(stdout, (char *)NULL); /* Remove all stdio buffering */
setbuf(stderr, (char *)NULL); /* in case of error reports. */
waitct = 0; /* debugging */
doargs(argc,argv); /* Set up args */
initialize (); /* Initialize the editor */
if (argfile[0]) /* shell line arg */
find_file(argfile[0]);
#if MAXARGFILES > 1
if(argfile[1])
{ f_2winds(); /* Make 2 windows, go to 2nd */
i = 1;
#if MAXARGFILES > 2
for (; i < MAXARGFILES; ++i)
#endif /* > 2 files */
find_file(argfile[i]); /* Get further file(s) */
f_othwind(); /* Move back to 1st window */
}
#endif /* > 1 file */
redp(RD_SCREEN|RD_MODE); /* Clear and show mode line */
setexit(0); /* catch for ints, ^G throws */
/* -----------------------------------------------------------
** ELLE MAIN LOOP
**
*/
for (;;)
{
/* First set up default arg unless last cmd specified it */
if(this_cmd != ARGCMD)
{ exp = 1; /* Default arg is 1 */
exp_p = 0; /* Say no explicit arg */
last_cmd = this_cmd;
}
this_cmd = 0;
askclr(); /* If stuff asked, say to clear it */
if(cmd_wait())
waitct++;
else if(rd_type != 0)
redisplay(); /* Redisplay if needed and no input */
#if SUN
sun_rdevf = 1; /* Allow mouse events on this input */
#endif
c = cmd_read(); /* Read an editor command */
sayclr(); /* Ask to clear echo area cleverly */
#if SUN
if(c != -1) /* SUN may not have real input */
#endif /* if mouse event happened. */
cmd_xct(c); /* Execute the command char! */
if(vfy_vec) /* If debugging, */
(*vfy_vec)(1); /* verify data structs right away */
}
}
char *prof_file; /* Can specify user profile filename */
doargs(argc,argv)
int argc;
char **argv;
{ register int cnt, c;
register char **av;
extern int tibfmsk;
int argfiles = 0;
int argsignored = 0;
av = argv;
cnt = argc;
#if V6 /* V6 doesn't have environment thus no TERM var */
/* Hack to force terminal type; analyze pgm name to get
* possible ".type" suffix.
*/
if(cnt && (c = strlen(*av)))
while(--c >= 0)
{ switch(av[0][c])
{ case '.':
tv_stype = &av[0][c+1];
case '/':
break;
default: continue;
}
break;
}
#endif /*V6*/
while(--cnt > 0)
{ ++av;
if(*av[0] != '-') /* If not switch, */
{ /* assume it's an input filename */
if (argfiles < MAXARGFILES)
argfile[argfiles++] = *av;
else
++argsignored;
continue;
}
c = upcase(av[0][1]);
switch(c) /* Switches without args */
{ case 'I': /* Allow debug ints */
dbg_isw = 1;
continue;
case '8': /* Ask for 8-bit input */
tibfmsk = 0377;
continue;
case '7': /* Ask for 7-bit input */
tibfmsk = 0177;
continue;
#if IMAGEN
case 'R': /* Debug redisplay stuff */
dbg_redp = 1;
continue;
#endif /*IMAGEN*/
}
if(--cnt <= 0)
goto stop;
++av;
switch(c) /* Switches with args */
{ case 'T': /* Terminal type */
tv_stype = *av;
break;
case 'P':
prof_file = *av;
default:
goto stop;
}
continue;
stop: printf("ELLE: bad switch: %s\n",*av);
exit(1);
}
if (argsignored > 0)
{ printf("ELLE: more than %d file args, %d ignored.\n",
MAXARGFILES, argsignored);
sleep(2); /* Complain but continue after pause */
}
}
int f_throw(); /* throw function */
int bite_bag(); /* Error handling routine */
int hup_exit(); /* Hangup handling routine */
struct majmode ifunmode = { "Fundamental" };
initialize () /* Initialization */
{
#if SUN
extern int sun_winfd;
#endif
cur_mode = fun_mode = &ifunmode; /* Set current major mode */
unrchf = pgoal = -1;
if(!homedir)
{
#if V6
extern char *logdir();
homedir = logdir();
#else /* V7 */
homedir = getenv("HOME");
#endif /*-V6*/
}
sbx_tset((chroff)0,0); /* Create swapout file */
/* (Temporary hack, fix up later) */
hoard(); /* Hoard a FD for write purposes */
redp_init(); /* Set up the display routines */
init_buf(); /* Set up initial buffers */
set_profile(prof_file); /* Set up user profile */
#if SUN
if(sun_winfd) sun_init();
#endif /*SUN*/
/* Set up signal handlers */
#if 0 /* not really used */
signal (SIGQUIT, f_throw); /* Quit - on ^G */
#endif
#if !(MINIX)
signal (SIGSYS, bite_bag); /* Bad arg to Sys call */
#endif
signal (SIGSEGV, bite_bag); /* Segmentation Violation */
#if !(COHERENT)
signal (SIGILL, bite_bag); /* Illegal Instruction interrupt */
signal (SIGBUS, bite_bag); /* Bus Error interrupt */
#endif /*-COHERENT*/
#if !(TOPS20) /* T20 just detaches job */
signal (SIGHUP, hup_exit); /* Terminal Hangup interrupt */
#endif /*-TOPS20*/
}
/* NOTE: This routine is not actually used, because ELLE does not
* allow interrupts to do anything.
*/
/* EFUN: "Error Throw" */
f_throw () /* abort whatever is going on */
{
ring_bell ();
curs_lin = -1000; /* make t_curpos do something */
redp(RD_MOVE); /* crock: cursor seems to move, so fix it */
signal(SIGQUIT, f_throw); /* rearm signal */
/* unwind_stack(main); */
reset(1); /* throw to main loop */
}
/* RING_BELL - General-purpose feeper when something goes wrong with
* a function.
*/
ring_bell()
{ t_bell(); /* Tell user something's wrong */
#if FX_SKMAC
f_ekmac(); /* Stop collecting keyboard macro if any */
#endif /*FX_SKMAC*/
}
/* EFUN: "Return to Superior"
* Behavior here is somewhat system-dependent. If it is possible to
* suspend the process and continue later, we do not ask about modified
* buffers. Otherwise, we do. Questioning can always be forced by using
* the prefix ^U.
* Note that here we try to be very careful about not letting the user
* exit while buffers are still modified, since UNIX flushes the process
* if we exit. Also, the code here conspires with sel_mbuf to rotate
* through all modified buffers, complaining about a different one each time,
* so that the user need not even know how to select a buffer!
*/
void f_retsup()
{ register char *reply;
register int c;
register struct buffer *b, *b2;
extern struct buffer *sel_mbuf();
extern int tsf_pause;
/* If we have capability of pausing and later continuing, do that,
* except if CTRL-U forces us into question/save/quit behavior.
*/
if(tsf_pause && (exp_p != 4))
{ clean_exit(); /* Return TTY to normal mode */
ts_pause(); /* Pause this inferior */
set_tty(); /* Continued, return to edit mode */
redp(RD_SCREEN);
return;
}
/* Sigh, do more typical "Are you sure" questioning prior to
* killing the editor permanently.
*/
b = cur_buf;
if((b = sel_mbuf(b)) || (b = sel_mbuf((struct buffer *)0)) )
{ if(b2 = sel_mbuf(b))
reply = ask(
"Quit: buffers %s, %s,... still have changes - forget them? ",
b->b_name, b2->b_name);
else
reply = ask(
"Quit: buffer %s still has changes - forget them? ",
b->b_name);
}
else
{
#if IMAGEN /* Do not ask further if nothing modified */
barf("Bye");
clean_exit();
exit(0);
#else
reply = ask("Quit? ");
#endif /*-IMAGEN*/
}
if (reply == 0)
return; /* Aborted, just return */
c = upcase(*reply); /* Get 1st char of reply */
chkfree(reply);
switch(c)
{ case 'Y':
#if IMAGEN
barf("Bye");
#endif /*IMAGEN*/
clean_exit();
exit(0);
#if 0
case 'S': /* Suspend command for debugging */
bkpt();
return;
#endif /*COMMENT*/
default: /* Complain */
ring_bell();
case 'N':
if(b) /* B set if we have any modified buffers */
{ sel_buf(b);
if(b->b_fn)
saynow("Use ^X ^S to save buffer");
else saynow("Use ^X ^W to write out buffer");
}
}
}
#if FX_WFEXIT
/* EFUN: "Write File Exit" (not EMACS) - from IMAGEN config */
void f_wfexit()
{
exp_p = 1; /* Ensure f_savefiles asks no questions */
if (! f_savefiles()) /* Save all modified buffers, but */
return; /* stay here if any save fails */
saynow("Bye");
clean_exit();
exit(0);
}
#endif /*FX_WFEXIT*/
/* Subprocess-handling stuff; put here for time being. */
/* EFUN: "Push to Inferior" */
#if TOPS20
#include <frkxec.h> /* Support for KCC forkexec() call */
#endif
f_pshinf()
{
register int res;
register int (*sav2)(), (*sav3)();
int pid, status;
char *shellname;
#if IMAGEN
char fullshell[64];
#endif /*IMAGEN*/
sav2 = signal(SIGINT, SIG_IGN); /* Ignore TTY interrupts */
sav3 = signal(SIGQUIT, SIG_IGN); /* Ditto TTY "quit"s */
clean_exit(); /* Restore normal TTY modes */
#if TOPS20
{
struct frkxec fx;
fx.fx_flags = FX_WAIT | FX_T20_PGMNAME;
fx.fx_name = "SYS:EXEC.EXE";
fx.fx_argv = fx.fx_envp = NULL;
if (forkexec(&fx) < 0)
writerr("Cannot run EXEC");
}
#else /*-TOPS20*/
switch(pid = fork())
{ case -1:
writerr("Cannot fork");
break;
case 0: /* We're the child */
for(res = 3; res < 20;) /* Don't let inf hack fd's */
close(res++);
#if V6
execl("/bin/sh","-sh",0);
#else
signal(SIGINT, SIG_DFL); /* V7 shell wants this?? */
signal(SIGQUIT, SIG_DFL); /* */
#if IMAGEN
if((shellname = getenv("SHELL")) == 0)
shellname = "sh";
strcpy(fullshell, "/bin/");
strcat(fullshell, shellname);
shellname = fullshell;
#else
if((shellname = getenv("SHELL")) == 0)
shellname = "/bin/sh";
#endif /*-IMAGEN*/
if((shellname = getenv("SHELL")) == 0)
shellname = "/bin/sh";
execl(shellname, shellname, 0);
#endif /*-V6*/
writerr("No shell!");
exit(1);
break;
default:
while((res = wait(&status)) != pid && res != -1);
break;
}
#endif /*-TOPS20*/
signal(SIGINT, sav2); /* Restore signal settings */
signal(SIGQUIT, sav3);
set_tty(); /* Restore editor TTY modes */
redp(RD_SCREEN|RD_MODE); /* Done, redisplay */
}
#if 0
/* Miscellaneous utility routines - memory alloc/free and string hacking.
* If this page becomes overly large, it can be split off into a separate
* file called E_MISC.
*/
char *
strdup(s)
char *s; /* Note that STRCPY's return val must be its 1st arg */
{ char *strcpy();
return(strcpy(memalloc((SBMO)(strlen(s)+1)), s));
}
#endif
char *
memalloc(size)
SBMO size;
{ register SBMA ptr;
extern SBMA sbx_malloc();
if ((ptr = (SBMA)sbx_malloc(size)) != 0)
return((char *)ptr);
barf("ELLE: No memory left");
askerr();
return(0); /* If we dare to continue... */
}
chkfree (ptr)
SBMA ptr;
{
if(!free(ptr))
{ errbarf("Something overwrote an allocated block!");
askerr();
}
}
/* USTRCMP - Uppercase String Compare.
* Returns 0 if mismatch,
* 1 if full match,
* -1 if str1 runs out first (partial match)
*/
ustrcmp(str1,str2)
char *str1, *str2;
{ register char *s1, *s2;
register int c;
s1 = str1; s2 = str2;
while(c = *s1++)
{ if(c != *s2 && upcase(c) != upcase(*s2))
return(0);
s2++;
}
return(c == *s2 ? 1 : -1);
}
/* WRITERR(str) - Output string to standard error output.
** This is a separate routine to save a little space on calls.
*/
writerr(str)
char *str;
{ return(writez(2, str));
}
/* WRITEZ(fd, str) - Miscellaneous general-purpose string output.
*/
writez(fd,acp)
int fd;
char *acp;
{ register char *cp;
cp = acp;
while(*cp++);
write(fd,acp,cp-acp-1);
}

View file

@ -1,308 +0,0 @@
/* ELLE - Copyright 1982, 1985, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEMAKE - IMAGEN configuration functions for interfacing to "make".
* Written by (I think) Chris Ryland at IMAGEN, who also
* wrote other functions scattered through ELLE. These are either
* conditionalized or are commented as being derived from the IMAGEN
* configuration.
*
* KLH: An attempt has been made to keep these routines updated as ELLE
* changed, but their workings cannot be guaranteed.
*/
/*
* eemake: "make" (and other program) support
*
* Next-error depends on programs writing error messages of the form:
* "file", line n: message
* which is a de facto standard, at least in some worlds.
*/
#include "elle.h"
#if !(IMAGEN) /* Only with IMAGEN config for now */
f_xucmd() {}
f_make() {}
f_nxterr() {}
#else
#include <stdio.h>
struct buffer *exec_buf; /* Ptr to "Execution" buffer */
/* Only external ref is from e_buff.c */
#define MSGLENGTH (scr_wid - 11) /* Max length of message */
int fresh_make = 1; /* Fresh Execution buffer contents */
chroff last_error_BOL; /* Dot for last-error's BOL */
/* EFUN: "Execute Unix Command" */
f_xucmd()
{
make_or_unix_cmd(0);
}
/* EFUN: "Execute Make" */
f_make()
{
make_or_unix_cmd(1);
}
/* EFUN: "Find Next Error" */
f_nxterr()
{
register struct sbstr *sb;
register char *cp;
register int c;
char file[64], line[32];
#ifdef ONEWINDOW
char msg[512];
#endif
chroff linedot;
int lineno;
register int len;
sel_execbuf();
if (! fresh_make)
{ e_go(last_error_BOL);
e_gonl();
}
else
{ fresh_make = 0;
e_gobob();
last_error_BOL = e_dot();
}
/* Looking for `"file", line n: msg' */
if (! e_search("\", line ", 8, 0))
goto failed;
linedot = e_dot();
e_gobol(); /* Found something, get to BOL */
if (e_getc() != '"')
goto failed; /* Insist on beginning "file" */
cp = file; /* Pick up filename */
while ((c = e_getc()) != '"')
*cp++ = c;
*cp = 0;
e_go(linedot); /* Back to after "line " */
cp = line;
while ((c = e_getc()) >= '0' && c <= '9')
*cp++ = c;
*cp = 0;
lineno = atoi(line); /* Pick up line number */
#ifdef ONEWINDOW
cp = msg; /* Now get rest of line to msg */
len = 0; /* But keep length <= MSGLENGTH */
e_getc(); /* Go past purported space */
while ((c = e_getc()) != LF && c != EOF && len <= MSGLENGTH)
{ if (c == '\t')
len = (len + 8) & ~07;
else if (c < ' ' || c > 0176)
len += 2;
else
++len;
*cp++ = c;
}
*cp = 0;
if (len > MSGLENGTH)
strcat(msg, "...");
#ifdef DEBUG
say("file ");
saytoo(file);
saytoo(", line ");
saytoo(line);
saytoo(", msg: ");
sayntoo(msg);
#else
say(line);
saytoo(": ");
sayntoo(msg);
#endif /*DEBUG*/
#else /* -ONEWINDOW */
f_begline(); /* Get to start of line */
last_error_BOL = e_dot(); /* Remember this position */
exp_p = 1; /* Make this the new top line */
exp = 0;
f_newwin();
upd_wind(0);
#endif /*ONEWINDOW*/
/* Now, visit the given file and line */
#ifdef ONEWINDOW
#else
f_othwind(); /* To other window */
#endif
find_file(file);
f_gobeg();
down_line(lineno - 1);
#ifdef READJUST /* NAW */
exp_p = 1;
exp = cur_win->w_ht / 4; /* Adjust how we look at "error" */
f_newwin();
#endif /*READJUST*/
return;
failed: ding("No more errors!");
fresh_make = 1; /* Fake-out: pretend starting over */
return;
}
/* Do the "cmd" and put its output in the Execution buffer */
do_exec(cmd, nicely)
char *cmd;
int nicely;
{
register int n;
int status, res, pid, fd[2];
char nicecmd[256];
char pipebuff[512];
struct buffer *b;
b = cur_buf;
sel_execbuf(); /* Get our execution buffer up */
ed_reset(); /* Clear it out */
fresh_make = 1;
upd_wind(0);
if (nicely)
sayntoo(" ...starting up...");
else
sayntoo(" ...starting up (nasty person)...");
pipe(fd);
switch (pid = fork())
{
case -1:
/* Fork failed, in parent */
ding("Cannot fork!?!");
break;
case 0: /* In child */
for (n = 0; n < 20; ++n)
if (n != fd[0] && n != fd[1])
close(n);
open("/dev/null", 0); /* Give ourselves empty stdin */
dup(fd[1]);
dup(fd[1]); /* stdout, stderr out to pipe */
close(fd[1]); /* Close the pipe itself */
close(fd[0]);
if (nicely)
{ strcpy(nicecmd, "nice -4 ");
strcat(nicecmd, cmd);
execl("/bin/sh", "sh", "-c", nicecmd, 0);
}
else
execl("/bin/sh", "sh", "-c", cmd, 0);
write(1, "Cannot execute!", 15);
_exit(-1);
break;
default:
/* Parent */
close(fd[1]); /* Close the output direction */
while ((n = read(fd[0], pipebuff, sizeof(pipebuff))) > 0)
{ ed_nsins(pipebuff, n);
upd_wind(0);
saynow("Chugging along...");
}
close(fd[0]);
while ((res = wait(&status)) != pid && res != -1)
; /* Wait for this fork to die */
f_bufnotmod(); /* Buffer is fresh */
saynow("Done!");
break;
}
f_othwind(); /* Back to other window */
chg_buf(b); /* Back to original buffer */
}
char last_make_cmd[256]; /* Last Unix/make command */
int have_last_make_cmd = 0;
make_or_unix_cmd(domake)
int domake;
{
#if APOLLO
register int nicely = exp == 16; /* modification for apollo */
#else
register int nicely = exp != 16;
#endif /*-APOLLO*/
register char *reply, *cmd = 0;
if (domake) /* If "make"-style, */
{ int savp = exp_p;
exp_p = 1;
f_savefiles(); /* write modified files quietly */
exp_p = savp;
}
if (exp_p || ! domake)
{ /* Arg given make, or Unix command */
reply = ask((! domake) ? "Unix command: " : "Command: ");
if (! reply)
return;
if (*reply == 0)
{ if (have_last_make_cmd)
cmd = &last_make_cmd[0];
else
{ chkfree(reply);
ding("No previous command!");
return;
}
}
else
cmd = reply;
if (cmd != &last_make_cmd[0]) /* Update last command */
strcpy(last_make_cmd, cmd);
have_last_make_cmd = 1;
say("Command: ");
sayntoo(cmd);
do_exec(cmd, nicely);
chkfree(reply);
}
else if (have_last_make_cmd)
{ say("Command: ");
sayntoo(last_make_cmd);
do_exec(last_make_cmd, nicely);
}
else
{ saynow("Command: make");
do_exec("make", nicely);
}
}
sel_execbuf()
{ if(!exec_buf)
{ /* Make execution buffer; don't let anyone kill it */
exec_buf = make_buf("Execution");
exec_buf->b_flags |= B_PERMANENT;
}
popto_buf(exec_buf);
}
/* Utility: pop the given buffer to a window, getting into 2-window mode */
popto_buf(b)
register struct buffer *b;
{
/* See if we already have this buffer in a visible window */
if (b == cur_win->w_buf)
{ if (oth_win == 0)
{ f_2winds();
f_othwind(); /* Get back to our window */
}
}
else if (oth_win != 0 && b == oth_win->w_buf)
f_othwind();
else if (oth_win == 0)
{ /* One window mode */
f_2winds(); /* Get two, get into second */
sel_buf(b); /* Select our new buffer */
}
else
{ f_othwind(); /* Get to other window */
sel_buf(b); /* and select our buffer */
}
}
#endif /*IMAGEN*/

View file

@ -1,20 +0,0 @@
#define PROF_VER (1)
struct profile {
int version;
int chrvcnt; char *chrvec;
int metavcnt; char *metavec;
int extvcnt; char *extvec;
int menuvcnt; char *menuvec;
};
struct stored_profile {
unsigned char version[2];
unsigned char chrvcnt[2], chrvec[2];
unsigned char metavcnt[2], metavec[2];
unsigned char extvcnt[2], extvec[2];
unsigned char menuvcnt[2], menuvec[2];
};
#define prof_pack(p, n) ((p)[0] = (n) & 0xFF, (p)[1] = (n) >> 8)
#define prof_upack(p) ((p)[0] | ((p)[1] << 8))

View file

@ -1,435 +0,0 @@
#ifndef _ANSI
#include <minix/ansi.h>
#endif
/* eebit.c */
_PROTOTYPE( int *chballoc, (int size) );
_PROTOTYPE( int chbit, (int *array, int c) );
_PROTOTYPE( int chbis, (int *array, int c) );
_PROTOTYPE( int chbic, (int *array, int c) );
/* eebuff.c */
_PROTOTYPE( int f_selbuffer, (void) );
_PROTOTYPE( int f_selxbuffer, (void) );
_PROTOTYPE( int f_kbuffer, (void) );
_PROTOTYPE( int f_listbufs, (void) );
_PROTOTYPE( int f_bufnotmod, (void) );
_PROTOTYPE( int f_eolmode, (void) );
_PROTOTYPE( int f_gobeg, (void) );
_PROTOTYPE( int f_goend, (void) );
_PROTOTYPE( int f_whatpage, (void) );
_PROTOTYPE( int init_buf, (void) );
_PROTOTYPE( struct buffer *make_buf, (char *bname) );
_PROTOTYPE( struct buffer *find_buf, (char *name) );
_PROTOTYPE( int sel_buf, (struct buffer *b) );
_PROTOTYPE( int chg_buf, (struct buffer *newbuf) );
_PROTOTYPE( int unlk_buf, (struct buffer *bufp) );
_PROTOTYPE( struct buffer *sel_mbuf, (struct buffer *buf) );
_PROTOTYPE( struct buffer *sel_mbuf, (struct buffer *buf) );
_PROTOTYPE( struct buffer *sel_nbuf, (struct buffer *buf) );
_PROTOTYPE( int kill_buf, (struct buffer *buf) );
_PROTOTYPE( int zap_buffer, (void) );
_PROTOTYPE( int ask_kbuf, (struct buffer *buf) );
_PROTOTYPE( int f_2winds, (void) );
_PROTOTYPE( int f_1wind, (void) );
_PROTOTYPE( int f_othwind, (void) );
_PROTOTYPE( int f_growind, (void) );
_PROTOTYPE( int f_shrinkwind, (void) );
_PROTOTYPE( int f_delwind, (void) );
_PROTOTYPE( int f_sowind, (void) );
_PROTOTYPE( int f_2modewinds, (void) );
_PROTOTYPE( int chk2modws, (void) );
_PROTOTYPE( int init_win, (void) );
_PROTOTYPE( int chg_win, (struct window *newwin) );
_PROTOTYPE( struct window *make_win, (int pos, int ht, struct buffer *buf) );
_PROTOTYPE( int kill_win, (struct window *win) );
_PROTOTYPE( int mk_showin, (struct buffer *b) );
_PROTOTYPE( struct window *make_mode, (struct window *bw) );
_PROTOTYPE( int buf_mod, (void) );
_PROTOTYPE( int buf_tmat, (chroff dot) );
_PROTOTYPE( int buf_tmod, (chroff offset) );
/* eecmds.c */
_PROTOTYPE( int f_pfxmeta, (void) );
_PROTOTYPE( int f_pfxext, (void) );
_PROTOTYPE( int f_uarg, (int ch) );
_PROTOTYPE( int f_negarg, (int ch) );
_PROTOTYPE( int f_argdig, (int ch) );
_PROTOTYPE( int f_setprof, (void) );
_PROTOTYPE( int f_vtbuttons, (void) );
_PROTOTYPE( int cmd_wait, (void) );
_PROTOTYPE( int cmd_read, (void) );
_PROTOTYPE( int cmd_xct, (int ch) );
_PROTOTYPE( int cmd_idx, (int c) );
_PROTOTYPE( void set_profile, (char *filename) );
_PROTOTYPE( int init_menu, (void) );
/* eediag.c */
_PROTOTYPE( int f_debug, (int ch) );
_PROTOTYPE( char *vfy_data, (int flag) );
_PROTOTYPE( int dbg_diag, (void) );
_PROTOTYPE( int vfy_exer, (int pf, int gcfrq) );
_PROTOTYPE( int db_prwind, (struct window *w) );
_PROTOTYPE( char *db_scflgs, (int flags) );
/* eedisp.c */
_PROTOTYPE( void set_tty, (void) );
_PROTOTYPE( int clean_exit, (void) );
_PROTOTYPE( int set_scr, (void) );
_PROTOTYPE( void redisplay, (void) );
_PROTOTYPE( int fupd_wind, (struct window *w) );
_PROTOTYPE( int upd_curs, (chroff adot) );
_PROTOTYPE( int d_line, (chroff cdot) );
_PROTOTYPE( int d_ncols, (int lcnt, int ccol) );
_PROTOTYPE( int d_lupd, (struct window *w, int idx) );
_PROTOTYPE( int clear_wind, (struct window *w) );
_PROTOTYPE( int fix_wind, (struct window *win) );
_PROTOTYPE( int inwinp, (struct window *win, chroff cdot) );
_PROTOTYPE( int upd_wind, (struct window *win) );
_PROTOTYPE( int slineq, (struct scr_line *olds, struct scr_line *news) );
_PROTOTYPE( int upd_line, (int y) );
_PROTOTYPE( void fillset, (char *str, int cnt, int c) );
_PROTOTYPE( void fillsp, (char *str, int cnt) );
_PROTOTYPE( void inspc, (char *cp0, char *cpl, int cnt) );
_PROTOTYPE( void fix_line, (struct scr_line *slp, struct scr_line *olds) );
_PROTOTYPE( int sctrin, (char *to, int lim, int ccol) );
_PROTOTYPE( int inslin, (int line, int n, struct window *win) );
_PROTOTYPE( int dellin, (int line, int n, struct window *win) );
_PROTOTYPE( int t_dostandout, (int on) );
_PROTOTYPE( void t_move, (int y, int x) );
_PROTOTYPE( int t_docleol, (void) );
/* eeedit.c */
_PROTOTYPE( int e_reset, (void) );
_PROTOTYPE( int e_rgetc, (void) );
_PROTOTYPE( int e_rdelc, (void) );
_PROTOTYPE( int e_delc, (void) );
_PROTOTYPE( int e_getc, (void) );
_PROTOTYPE( int e_backc, (void) );
_PROTOTYPE( int e_putc, (int c) );
_PROTOTYPE( int e_peekc, (void) );
_PROTOTYPE( int e_ovwc, (int ch) );
_PROTOTYPE( SBSTR *e_copyn, (chroff off) );
_PROTOTYPE( int e_deln, (chroff off) );
_PROTOTYPE( int e_setcur, (void) );
_PROTOTYPE( int e_gosetcur, (chroff dot) );
_PROTOTYPE( int e_gocur, (void) );
_PROTOTYPE( int e_gobob, (void) );
_PROTOTYPE( int e_goeob, (void) );
_PROTOTYPE( int e_go, (chroff dot) );
_PROTOTYPE( int e_igoff, (int ioff) );
_PROTOTYPE( int e_goff, (chroff off) );
_PROTOTYPE( int e_gobol, (void) );
_PROTOTYPE( int e_goeol, (void) );
_PROTOTYPE( int e_gonl, (void) );
_PROTOTYPE( int e_gopl, (void) );
_PROTOTYPE( chroff e_dot, (void) );
_PROTOTYPE( chroff e_nldot, (void) );
_PROTOTYPE( chroff e_pldot, (void) );
_PROTOTYPE( chroff e_boldot, (void) );
_PROTOTYPE( chroff e_eoldot, (void) );
_PROTOTYPE( chroff e_alldot, (SBBUF *sbp, int (*rtn )()) );
_PROTOTYPE( chroff e_blen, (void) );
_PROTOTYPE( int ex_reset, (struct buffer *b) );
_PROTOTYPE( int ex_go, (SBBUF *sbp, chroff loc) );
_PROTOTYPE( chroff ex_dot, (SBBUF *sbp) );
_PROTOTYPE( chroff ex_boldot, (SBBUF *sbp, chroff dot) );
_PROTOTYPE( chroff ex_alldot, (SBBUF *sbp, int (*rtn )(), chroff dot) );
_PROTOTYPE( int ex_gonl, (SBBUF *sbp) );
_PROTOTYPE( int ex_goeol, (SBBUF *sbp) );
_PROTOTYPE( int ex_gobol, (SBBUF *sbp) );
_PROTOTYPE( int ex_gopl, (SBBUF *sbp) );
_PROTOTYPE( chroff ex_blen, (SBBUF *sbp) );
_PROTOTYPE( int e_gofwsp, (void) );
_PROTOTYPE( int e_gobwsp, (void) );
_PROTOTYPE( int e_goline, (int i) );
_PROTOTYPE( int e_lblankp, (void) );
_PROTOTYPE( int e_insn, (int ch, int cnt) );
_PROTOTYPE( int e_sputz, (char *acp) );
_PROTOTYPE( int boleq, (chroff dot1, chroff dot2) );
_PROTOTYPE( char *dottoa, (char *str, chroff val) );
_PROTOTYPE( int e_gobpa, (void) );
_PROTOTYPE( int e_goepa, (void) );
_PROTOTYPE( int exp_do, (int (*rpos )(), int (*rneg )()) );
_PROTOTYPE( int e_fwsp, (void) );
_PROTOTYPE( int e_bwsp, (void) );
_PROTOTYPE( int c_wsp, (int ch) );
_PROTOTYPE( int c_pwsp, (int ch) );
_PROTOTYPE( int delimp, (int c) );
_PROTOTYPE( int e_wding, (chroff *adot, int n) );
_PROTOTYPE( chroff e_wdot, (chroff dot, int n) );
_PROTOTYPE( int e_gowd, (int n) );
_PROTOTYPE( int e_search, (char *mstr, int mlen, int backwards) );
/* eeerr.c */
_PROTOTYPE( int f_bkpt, (void) );
_PROTOTYPE( int bpt, (void) );
_PROTOTYPE( char *strerror, (int num) );
_PROTOTYPE( int errsbm, (int type, int (*adr )(), char *str, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12) );
_PROTOTYPE( int bite_bag, (int fault) );
_PROTOTYPE( int hup_exit, (void) );
_PROTOTYPE( int errint, (void) );
_PROTOTYPE( int askerr, (void) );
_PROTOTYPE( char *asklin, (char *acp) );
/* eef1.c */
_PROTOTYPE( int f_insself, (int c) );
_PROTOTYPE( int f_quotins, (void) );
_PROTOTYPE( int f_crlf, (void) );
_PROTOTYPE( int f_fchar, (void) );
_PROTOTYPE( int f_bchar, (void) );
_PROTOTYPE( int f_dchar, (void) );
_PROTOTYPE( int f_bdchar, (void) );
_PROTOTYPE( int ef_deln, (int x) );
_PROTOTYPE( int f_delspc, (void) );
_PROTOTYPE( int f_tchars, (void) );
_PROTOTYPE( int f_fword, (void) );
_PROTOTYPE( int f_bword, (void) );
_PROTOTYPE( int f_kword, (void) );
_PROTOTYPE( int f_bkword, (void) );
_PROTOTYPE( int f_twords, (void) );
_PROTOTYPE( int f_ucword, (void) );
_PROTOTYPE( int f_lcword, (void) );
_PROTOTYPE( int f_uciword, (void) );
_PROTOTYPE( int case_word, (int downp) );
/* eef2.c */
_PROTOTYPE( int f_begline, (void) );
_PROTOTYPE( int f_endline, (void) );
_PROTOTYPE( int f_nxtline, (void) );
_PROTOTYPE( int f_prvline, (void) );
_PROTOTYPE( int f_dnrline, (void) );
_PROTOTYPE( int f_uprline, (void) );
_PROTOTYPE( int f_oline, (void) );
_PROTOTYPE( int f_delblines, (void) );
_PROTOTYPE( int f_kline, (void) );
_PROTOTYPE( int f_bkline, (void) );
_PROTOTYPE( int f_goline, (void) );
_PROTOTYPE( int down_bline, (int arg) );
_PROTOTYPE( int down_line, (int x) );
_PROTOTYPE( int f_setmark, (void) );
_PROTOTYPE( int f_exchmark, (void) );
_PROTOTYPE( int f_kregion, (void) );
_PROTOTYPE( int f_copreg, (void) );
_PROTOTYPE( int f_ucreg, (void) );
_PROTOTYPE( int f_lcreg, (void) );
_PROTOTYPE( int ef_creg, (int downp) );
_PROTOTYPE( int f_fillreg, (void) );
_PROTOTYPE( int chkmark, (void) );
_PROTOTYPE( int f_fpara, (void) );
_PROTOTYPE( int f_bpara, (void) );
_PROTOTYPE( int f_mrkpara, (void) );
_PROTOTYPE( int f_fillpara, (void) );
/* eef3.c */
_PROTOTYPE( int f_appnkill, (void) );
_PROTOTYPE( int f_unkill, (void) );
_PROTOTYPE( int f_unkpop, (void) );
_PROTOTYPE( int f_indatm, (void) );
_PROTOTYPE( int f_indnl, (void) );
_PROTOTYPE( int f_backind, (void) );
_PROTOTYPE( int f_indcomm, (void) );
_PROTOTYPE( int f_indrel, (void) );
_PROTOTYPE( int insertmatch, (int c) );
_PROTOTYPE( int f_matchbrack, (void) );
_PROTOTYPE( int matchonelevel, (int mc) );
/* eefd.c */
_PROTOTYPE( int f_newwin, (void) );
_PROTOTYPE( int f_nscreen, (void) );
_PROTOTYPE( int f_pscreen, (void) );
_PROTOTYPE( int f_othnscreen, (void) );
_PROTOTYPE( int f_lwindbord, (void) );
_PROTOTYPE( int f_scupwind, (void) );
_PROTOTYPE( int f_scdnwind, (void) );
_PROTOTYPE( int f_mvwtop, (void) );
_PROTOTYPE( int f_mvwbot, (void) );
_PROTOTYPE( int d_screen, (int rep) );
_PROTOTYPE( int scroll_win, (int n) );
_PROTOTYPE( int d_curind, (void) );
_PROTOTYPE( int indtion, (chroff lin) );
_PROTOTYPE( int inindex, (chroff lin, int xpos) );
_PROTOTYPE( int d_gopl, (void) );
_PROTOTYPE( int d_gonl, (void) );
_PROTOTYPE( int d_goloff, (int cnt) );
_PROTOTYPE( int d_fgoloff, (int cnt) );
_PROTOTYPE( int d_fixcur, (void) );
_PROTOTYPE( int d_backup, (int nlin) );
/* eefed.c */
_PROTOTYPE( int ed_insert, (int c) );
_PROTOTYPE( int ed_insn, (int ch, int cnt) );
_PROTOTYPE( int ed_crins, (void) );
_PROTOTYPE( int ed_sins, (char *s) );
_PROTOTYPE( int ed_nsins, (char *s, int i) );
_PROTOTYPE( int ed_indto, (int goal) );
_PROTOTYPE( int ed_setcur, (void) );
_PROTOTYPE( int ed_go, (chroff dot) );
_PROTOTYPE( int ed_goff, (chroff off) );
_PROTOTYPE( int ed_igoff, (int ioff) );
_PROTOTYPE( int ed_reset, (void) );
_PROTOTYPE( int ed_deln, (chroff off) );
_PROTOTYPE( int ed_delete, (chroff dot1, chroff dot2) );
_PROTOTYPE( int ed_kill, (chroff dot1, chroff dot2) );
_PROTOTYPE( int kill_push, (SBSTR *sdp) );
_PROTOTYPE( int ed_case, (chroff dot1, chroff dot2, int downp) );
_PROTOTYPE( int upcase, (int ch) );
/* eefile.c */
_PROTOTYPE( int f_ffile, (void) );
_PROTOTYPE( int f_rfile, (void) );
_PROTOTYPE( int f_vfile, (void) );
_PROTOTYPE( int u_r_file, (char *prompt) );
_PROTOTYPE( int f_ifile, (void) );
_PROTOTYPE( int f_sfile, (void) );
_PROTOTYPE( int f_savefiles, (void) );
_PROTOTYPE( int f_wfile, (void) );
_PROTOTYPE( int f_wreg, (void) );
_PROTOTYPE( int f_wlastkill, (void) );
_PROTOTYPE( int hack_file, (char *prompt, int (*rtn )()) );
_PROTOTYPE( int find_file, (char *f_name) );
_PROTOTYPE( int read_file, (char *f_name) );
_PROTOTYPE( int ins_file, (char *f_name) );
_PROTOTYPE( int ferr_ropn, (void) );
_PROTOTYPE( int ferr_wopn, (void) );
_PROTOTYPE( int ferr, (char *str) );
_PROTOTYPE( char *fncons, (char *dest, char *pre, char *f_name, char *post) );
_PROTOTYPE( char *last_fname, (char *f_name) );
_PROTOTYPE( int set_fn, (char *string) );
_PROTOTYPE( int saveworld, (struct buffer *bp, int grunt) );
_PROTOTYPE( int hoard, (void) );
_PROTOTYPE( int unhoard, (void) );
_PROTOTYPE( int expand_file, (char *dfn, char *sfn) );
/* eefill.c */
_PROTOTYPE( int f_sfcol, (void) );
_PROTOTYPE( int f_sfpref, (void) );
_PROTOTYPE( int tstfillp, (int lim) );
_PROTOTYPE( int ed_fill, (chroff begloc, chroff endloc, int flag) );
_PROTOTYPE( int f_fillmode, (void) );
_PROTOTYPE( int fx_insfill, (int c) );
_PROTOTYPE( int fill_cur_line, (void) );
_PROTOTYPE( int f_textmode, (void) );
_PROTOTYPE( int fim_insself, (int c) );
_PROTOTYPE( int fim_dchar, (void) );
_PROTOTYPE( int fim_bdchar, (void) );
_PROTOTYPE( int fim_crlf, (void) );
_PROTOTYPE( int magic_wrap, (int tc) );
_PROTOTYPE( int reveal, (char *msg, int v1, int v2, int v3) );
_PROTOTYPE( int magic_backto_bol, (void) );
_PROTOTYPE( int fill_current_line, (void) );
/* eehelp.c */
_PROTOTYPE( int f_describe, (void) );
/* eekmac.c */
_PROTOTYPE( int f_skmac, (void) );
_PROTOTYPE( int f_ekmac, (void) );
_PROTOTYPE( int f_xkmac, (void) );
_PROTOTYPE( int f_vkmac, (void) );
_PROTOTYPE( int km_getc, (void) );
_PROTOTYPE( int km_inwait, (void) );
_PROTOTYPE( int km_abort, (void) );
_PROTOTYPE( int add_mode, (char *mode) );
_PROTOTYPE( int remove_mode, (char *mode) );
/* eemain.c */
_PROTOTYPE( int doargs, (int argc, char **argv) );
_PROTOTYPE( int initialize, (void) );
_PROTOTYPE( int f_throw, (void) );
_PROTOTYPE( int ring_bell, (void) );
_PROTOTYPE( void f_retsup, (void) );
_PROTOTYPE( void f_wfexit, (void) );
_PROTOTYPE( int f_pshinf, (void) );
_PROTOTYPE( char *memalloc, (SBMO size) );
_PROTOTYPE( int chkfree, (SBMA ptr) );
_PROTOTYPE( int ustrcmp, (char *str1, char *str2) );
_PROTOTYPE( int writerr, (char *str) );
_PROTOTYPE( int writez, (int fd, char *acp) );
/* eemake.c */
_PROTOTYPE( int f_xucmd, (void) );
_PROTOTYPE( int f_make, (void) );
_PROTOTYPE( int f_nxterr, (void) );
_PROTOTYPE( int f_xucmd, (void) );
_PROTOTYPE( int f_make, (void) );
_PROTOTYPE( int f_nxterr, (void) );
_PROTOTYPE( int do_exec, (char *cmd, int nicely) );
_PROTOTYPE( int make_or_unix_cmd, (int domake) );
_PROTOTYPE( int sel_execbuf, (void) );
_PROTOTYPE( int popto_buf, (struct buffer *b) );
/* eequer.c */
_PROTOTYPE( int f_querep, (void) );
_PROTOTYPE( int f_repstr, (void) );
_PROTOTYPE( int f_repline, (void) );
_PROTOTYPE( int ed_dorep, (int type, struct majmode *mode) );
/* eeques.c */
#if 0
_PROTOTYPE( char *ask, (char *string, char *arg1, char *arg2, char *arg3) );
#else
char *ask();
#endif
_PROTOTYPE( int askclr, (void) );
_PROTOTYPE( int say, (char *str) );
_PROTOTYPE( int saynow, (char *str) );
_PROTOTYPE( int saytoo, (char *str) );
_PROTOTYPE( int sayntoo, (char *str) );
_PROTOTYPE( int ding, (char *str) );
_PROTOTYPE( int dingtoo, (char *str) );
_PROTOTYPE( int saylntoo, (char *str, int n) );
_PROTOTYPE( int sayclr, (void) );
#if 0
_PROTOTYPE( int sayall, (char *str, int flags, int len) );
#else
int sayall();
#endif
_PROTOTYPE( int yellat, (char *str, int line) );
_PROTOTYPE( int yelltoo, (char *str) );
_PROTOTYPE( int errbarf, (char *str) );
_PROTOTYPE( int barf, (char *str) );
_PROTOTYPE( int barf2, (char *str) );
/* eesite.c */
_PROTOTYPE( int ts_inp, (void) );
_PROTOTYPE( int ts_init, (void) );
_PROTOTYPE( int ts_enter, (void) );
_PROTOTYPE( int ts_exit, (void) );
_PROTOTYPE( int tpoke, (int cmd, int bn, int val) );
_PROTOTYPE( int ts_pause, (void) );
/* eesrch.c */
_PROTOTYPE( int f_srch, (void) );
_PROTOTYPE( int f_rsrch, (void) );
_PROTOTYPE( int lin_search, (int backwards) );
_PROTOTYPE( int srchint, (void) );
_PROTOTYPE( char *srch_ask, (char *prompt) );
_PROTOTYPE( int f_risrch, (void) );
_PROTOTYPE( int f_isrch, (void) );
_PROTOTYPE( int i_search, (int back) );
/* eeterm.c */
_PROTOTYPE( int t_init, (void) );
_PROTOTYPE( int t_fatal, (char *str) );
_PROTOTYPE( int t_enter, (void) );
_PROTOTYPE( int t_exit, (void) );
_PROTOTYPE( int t_clear, (void) );
_PROTOTYPE( int t_curpos, (int lin, int col) );
_PROTOTYPE( int t_backspace, (void) );
_PROTOTYPE( int t_bell, (void) );
_PROTOTYPE( int t_cleol, (void) );
_PROTOTYPE( int t_inslin, (int n, int bot) );
_PROTOTYPE( int t_dellin, (int n, int bot) );
_PROTOTYPE( int t_inschr, (int n, char *str) );
_PROTOTYPE( int t_delchr, (int n) );
_PROTOTYPE( int t_standout, (int on) );
_PROTOTYPE( int t_direct, (int lin, int col, char *str, int len) );
_PROTOTYPE( int tput, (int ch) );
_PROTOTYPE( int tputz, (char *str) );
_PROTOTYPE( int tputn, (char *str, int cnt) );
_PROTOTYPE( int tbufls, (void) );
_PROTOTYPE( int tgetc, (void) );
_PROTOTYPE( int tinwait, (void) );
/* eevini.c */

View file

@ -1,189 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EEQUER Query-Replace and Replace-String functions
*/
#include "elle.h" /* include structure definitions */
/* EFUN: "Query Replace" */
/* Crude approximation of EMACS function.
*/
f_querep()
{ static struct majmode iqrpmode = { "Query Replace" };
ed_dorep(0, &iqrpmode);
}
/* EFUN: "Replace String" */
/* Similar to Query Replace and uses same code.
*/
f_repstr()
{ static struct majmode irepmode = { "Replace String" };
ed_dorep(1, &irepmode);
}
#if FX_REPLINE
/* EFUN: "Replace in Line" (not EMACS) */
/* Acts like Replace String but only operates on current line.
** Currently a big crock.
** Feature of crockishness is that Unkill Pop (M-Y) will restore old
** line.
*/
f_repline()
{
extern struct buffer *make_buf();
struct buffer *b, *oldb = cur_buf;
static struct majmode rlmode = { "Replace in Line" };
if(!(b = make_buf(" **LINE**")))
{ ring_bell();
return;
}
f_kline(); /* Kill line(s) from original buffer */
chg_buf(b); /* Switch to temp buffer */
f_unkill(); /* Get killed stuff into temp buffer */
e_gosetcur((chroff)0); /* Starting at beginning, */
ed_dorep(1, &rlmode); /* Execute Replace String on it. */
ed_kill((chroff)0, e_blen()); /* Now kill everything in it, */
chg_buf(oldb); /* switch back to original buffer, */
f_unkill(); /* and restore new stuff! */
kill_buf(b); /* Now flush temporary buffer. */
}
#endif
/* Note that the major mode is set without changing the buffer's major
* mode. When the function is done, the current major mode is reset
* from the buffer mode.
*/
ed_dorep(type, mode) /* 0 = Query Replace, 1 = Replace String */
int type;
struct majmode *mode;
{ register int c;
register int olen, allflg;
char *srch_ask();
char *opromp, *npromp;
char *nstr, *ostr; /* Note ostr is == to srch_str */
int nlen;
chroff last_loc;
#if IMAGEN
int nrepled = 0;
char replmsg[64];
#endif /*IMAGEN*/
/* Set mode, then get search string and replace string */
#if IMAGEN
cur_win->w_buf->b_flags |= B_QUERYREP;
#else
cur_mode = mode; /* Set major mode pointer */
#endif /*-IMAGEN*/
redp(RD_MODE);
nstr = 0;
#if IMAGEN
opromp = "Old string: ";
npromp = "New string: ";
#else
opromp = "Replace string: ";
npromp = "with string: ";
#endif /*-IMAGEN*/
if((ostr = srch_ask(opromp)) == 0)
goto done;
olen = srch_len; /* srch_ask sets this! */
if((nstr = ask("%s%s %s", opromp, ostr, npromp)) == 0)
goto done;
nlen = ask_len;
/* Now enter search and subcommand loop */
allflg = type; /* Unless 0 for Query Rep, replace all */
for(;;)
{ last_loc = cur_dot;
if(e_search(ostr,olen,0) == 0)
break;
ed_setcur(); /* Cursor moved */
redisp:
if(!allflg) redisplay(); /* Update screen */
getcmd:
if(!allflg) c = cmd_read();
else c = SP;
switch(c)
{
#if IMAGEN
case 'n':
#endif /*IMAGEN*/
case DEL: /* Don't replace, go on */
continue;
#if IMAGEN
case ',':
#endif /*IMAGEN*/
case '.': /* Replace and exit */
case SP: /* Replace, go on */
ed_delete(cur_dot,(chroff)(cur_dot-olen));
ed_nsins(nstr,nlen);
#if IMAGEN
++nrepled;
#endif /*IMAGEN*/
if(c == '.') goto done;
continue;
#if IMAGEN
default:
#endif /*IMAGEN*/
case '?': /* Show options */
#if IMAGEN
saynow("\
' '=>change, 'n'=>don't, '.'=>change, quit, '!'=>change rest, '^'=>back up");
#else
saynow("\
SP=Replace, DEL=Don't, ESC=Stop, !=Replace all, ^=Back up, .=Replace & Stop");
#endif /*-IMAGEN*/
goto getcmd;
case '^': /* Return to last place found */
ed_go(last_loc);
goto redisp;
case CTRL('G'):
case ESC: /* Exit where we are */
goto done;
case CTRL('L'): /* Redisplay */
redp(RD_SCREEN);
goto redisp;
case '!': /* Replace all the rest */
allflg++;
goto getcmd;
#if !(IMAGEN)
case ',': /* Replace and show */
case CTRL('R'): /* Enter edit mode recursively */
case CTRL('W'): /* Delete once and ^R */
saynow("not implemented");
goto getcmd;
default: /* Exit and re-read char */
unrchf = c;
goto done;
#endif /*-IMAGEN*/
}
}
done:
#if IMAGEN
cur_win->w_buf->b_flags &= ~B_QUERYREP;
#else
cur_mode = cur_buf->b_mode;
#endif /*-IMAGEN*/
redp(RD_MODE);
if(nstr) /* Free nstr (but not ostr, it's == srch_str!) */
chkfree(nstr);
#if IMAGEN
if (nrepled <= 0)
saynow("No replacements done");
else
{ sprintf(replmsg, "Replaced %d occurences", nrepled);
saynow(replmsg);
}
#endif /*IMAGEN*/
}

View file

@ -1,325 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEQUES - Handle queries and status displays
*/
#include "elle.h"
/*
* Ask -- ask the user for some input on the lowest line of the screen
*
* The arg is a string in printf form, followed by up to three args
* for the printf string
*
* The string is read into a sort of mini buffer, only the
* last line of which is visible on the screen. All editing
* features are available to the user to edit the input string.
* When the delim character is typed, input is terminated and
* The input string is passed back to the caller.
* The delim is either an escape or a cr.
* IT IS UP TO THE CALLER TO FREE THIS MEMORY.
*
* Note that the actual length of the returned string can be found
* in the global variable ask_len. This is a crock but allows
* callers to hack nulls in arg strings if they want to.
*/
int chg_win();
struct window *make_mode();
static int ask_lin; /* Saved cursor location when ask is done */
static int ask_blen; /* Non-zero if buffer contains something */
static int ask_cnt; /* Incremented by ask(), cleared by askclr() */
/* Table of allowed functions during ASK */
static char askftab[] = {
FN_PFXMETA, FN_INSSELF, FN_BEGLINE, FN_ENDLINE, FN_BCHAR, FN_FCHAR,
FN_DCHAR, FN_BDCHAR, FN_TCHARS, FN_QUOTINS, FN_UARG, FN_BKPT,
FN_DEBUG,
FN_GOBEG, FN_GOEND, FN_FWORD, FN_BWORD, FN_KWORD, FN_BKWORD,
FN_UCWORD, FN_LCWORD, FN_UCIWORD, FN_ARGDIG, FN_NEWWIN, FN_KLINE,
FN_UNKILL, FN_BKLINE,
0
};
char *
ask (string, arg1, arg2, arg3)
char *string, *arg1, *arg2, *arg3;
{ register int i, c;
register char *s;
struct window *oldwin;
char *newline; /* where output line goes */
char cbuf[200]; /* For prompt string creation */
int p_length; /* length of prompt */
chroff anslen; /* Length of answer */
int funnum; /* Crock stuff */
#if FX_FILLMODE
extern int fill_mode;
int ofillmode = fill_mode; /* Gotta turn this one off */
fill_mode = 0;
#endif /*FX_FILLMODE*/
oldwin = cur_win;
chg_win (ask_win);
ed_reset(); /* Flush contents & request redisp */
ask_lin = cur_win->w_pos; /* Set here in case never redisp */
ask_cnt++; /* Bump # of times called */
/* copy 'string' into line */
cbuf[0] = 0;
asklp: sprintf (&cbuf[strlen(cbuf)], string, arg1, arg2, arg3);
p_length = strlen(cbuf); /* Find how long it is */
/* now let the user type in */
for(;;)
{
if ((rd_type & (RDS_WINFLGS|RD_MODE)) && tinwait () == 0)
{
e_gobob(); /* Gross crock: insert prompt */
e_sputz(cbuf); /* Ugh, bletch */
cur_dot += p_length; /* Temporarily update loc */
redp(RD_WINRES); /* Do complete re-crunch */
upd_wind((struct window *)0); /* Don't interrupt */
/* Ensure mode line is spiffy too. This should
** only have to be invoked the first time ask_win
** redisplay is done, and never thereafter.
*/
if(rd_type&RD_MODE) /* If mode also needs it, */
fupd_wind(make_mode(user_win)); /* do it */
upd_curs(cur_dot);
rd_type &= ~(RDS_WINFLGS|RD_MODE);
ask_lin = curs_lin; /* Remember line cursor on */
tbufls();
e_gobob(); /* More crock: Remove prompt */
sb_deln((SBBUF *)cur_buf,(chroff)p_length); /* Ugh etc. */
cur_dot -= p_length; /* Restore loc */
e_gocur();
}
exp = 1;
exp_p = 0;
cont: this_cmd = 0;
c = cmd_read();
if (
#if !(ICONOGRAPHICS)
c == ESC ||
#endif /*-ICONOGRAPHICS*/
c == LF || c == CR)
break;
if (c == BELL) /* ^G means punt.. */
{ chg_win(oldwin);
ask_blen = 1; /* Assume buffer has something */
ding((char *)0); /* Clear echo window */
ask_cnt = 0; /* Nothing for askclr to do */
#if FX_SKMAC
km_abort();
#endif /*FX_SKMAC*/
#if FX_FILLMODE
fill_mode = ofillmode;
#endif /*FX_FILLMODE*/
return(0); /* Return 0 to indicate we quit */
}
/* This censoring section is a real crock! */
funnum = cmd_idx(c); /* Map key to command */
while(funnum == FN_PFXMETA) /* Allow META prefix */
funnum = cmd_idx(c = CB_META|cmd_read());
for(s = askftab; (i = *s&0377); ++s)
if(funnum == i) break;
switch(i)
{ default: /* Permissible function */
cmd_xct(c);
break;
case FN_NEWWIN: /* Wants redisplay, do specially */
clear_wind(ask_win);
break;
case 0: /* Illegal function */
ring_bell();
#if FX_SKMAC
km_abort();
#endif /*FX_SKMAC*/
continue;
}
if(this_cmd == ARGCMD)
goto cont;
}
if((anslen = e_blen()) > 255) /* Ridiculously long? */
{ strcpy(cbuf,"Huh? Try again - ");
#if FX_SKMAC
km_abort();
#endif /*FX_SKMAC*/
goto asklp;
}
i = anslen;
e_gobob(); /* Go to start of buffer */
e_sputz(cbuf); /* Re-insert prompt so buffer == screen */
ask_blen = i + 1; /* Say buffer has something in it */
s = memalloc((SBMO)(i + 1)); /* Allocate fixed loc for answer */
newline = s; /* Return ptr to allocated string */
ask_len = i; /* And return (via global) length of string */
if(i) do { *s++ = e_getc(); }
while(--i);
*s = '\0'; /* make sure string terminated */
chg_win(oldwin);
#if FX_FILLMODE
fill_mode = ofillmode;
#endif /*FX_FILLMODE*/
return (newline); /* return pointer to data */
}
/* ASKCLR - Clears the echo area (but not immediately) if the last thing
** done to it was an ask() call. Note that invoking a SAY routine
** specifically causes this to be a no-op; SAYCLR must be done instead.
*/
askclr()
{
if(ask_cnt) sayclr(); /* Zap if need be */
}
/* SAY - put up some text on bottom line.
* Does this intelligently; text stays up until next SAY or
* screen refresh.
* SAYNOW - like SAY but forces display right away
* SAYTOO - adds to existing stuff
* SAYNTOO - ditto but forces output right away.
* DING - Ring_bell then SAYNOW
* DINGTOO - is to DING as SAYNTOO is to SAYNOW.
* SAYCLR - Clears echo area (but not immediately)
*/
#define SAY_NOW 01 /* Force display immediately */
#define SAY_TOO 02 /* Add to existing stuff */
#define SAY_BEL 04 /* Ding bell prior to text */
#define SAY_LEN 010 /* String length specified by 3rd arg */
say(str) char *str; { sayall(str, 0); }
saynow(str) char *str; { sayall(str, SAY_NOW); }
saytoo(str) char *str; { sayall(str, SAY_TOO); }
sayntoo(str) char *str; { sayall(str, SAY_NOW|SAY_TOO); }
ding(str) char *str; { sayall(str, SAY_NOW|SAY_BEL); }
dingtoo(str) char *str; { sayall(str, SAY_NOW|SAY_TOO|SAY_BEL); }
saylntoo(str,n) char *str; { sayall(str, SAY_NOW|SAY_TOO|SAY_LEN, n); }
sayclr() { sayall((char *)0, 0); }
sayall(str,flags,len)
char *str;
int flags, len;
{ register struct window *w;
register f;
f = flags;
w = cur_win;
ask_cnt = 0; /* Always reset this */
if(str == 0 && ask_blen == 0) /* If clearing, and buff empty */
return; /* nothing to do. */
chg_win(ask_win);
if(f&SAY_TOO)
e_goeob(); /* Add to end of existing stuff */
else e_reset(); /* Flush previous stuff if any */
if(str)
{ if(f&SAY_LEN) /* Insert string to post up */
ed_nsins(str,len);
else e_sputz(str);
}
ask_blen = e_dot(); /* Remember whether buffer has something */
e_setcur(); /* and remember to set dot */
if(f&SAY_NOW)
{ if(f&SAY_BEL)
ring_bell();
redp(RD_WINRES);
upd_wind((struct window *)0);
tbufls();
}
else redp(RD_WINRES); /* Set for this window */
chg_win(w); /* Back to previous window */
/* redisplay() does a special check for ask_win->w_redp, so we
** don't need to set a global flag like RD_CHKALL.
*/
}
/* YELLAT -- post string on specified line of screen, immediately.
* Differs from SAYNOW and SAYNTOO in that NO buffer
* manipulation is done; screen image is hacked directly.
*/
yellat(str, line)
char *str;
register int line;
{ register struct scr_line *s;
s = scr[line];
strncpy(s->sl_nlin, str, scr_wd0);
s->sl_ncol = strlen(str);
#if IMAGEN
s->sl_flg |= SL_REDO;
#endif
upd_line(line);
tbufls();
}
/* YELLTOO -- Append string to previous echo line of screen, immediately.
** Uses the ask_lin variable which is set by ask().
** Currently this function is only needed for srchint() in EESRCH.
*/
yelltoo(str)
char *str;
{ register int i;
register struct scr_line *s;
char nstr[MAXLINE];
s = scr[ask_lin];
i = s->sl_col;
nstr[0] = 0;
strncat(strncat(nstr, s->sl_line, i), /* Make new string */
str, MAXLINE - i);
yellat(nstr, ask_lin); /* Post it */
}
/* BARF - output a message on the bottom line of the screen,
** bypassing everything (window, buffer, screen image).
** Does NOT know about SAY's stuff and does not update it!
** Use only in dire straits...
** ERRBARF - same but uses a standard error-message prefix.
*/
errbarf(str)
char *str;
{
barf("\007ELLE Internal Error: ");
tputz(str);
tbufls();
}
barf(str)
char *str;
{
ask_cnt = 0; /* Ensure askclr() disabled */
t_curpos(scr_ht - ECHOLINES, 0); /* goto echo area */
t_cleol();
tputz(str);
tbufls();
curs_col = -1000; /* Say we dunno where cursor is now */
}
#if IMAGEN
/* Same, but do it far from harm's way */
barf2(str)
char *str;
{
t_curpos (scr_ht - 1, scr_wid - strlen(str) - 8);
t_cleol ();
tputz(str);
tputz(" --M--");
tbufls();
tgetc(); /* Read any char & discard */
curs_col = -1000; /* Say we dunno where cursor is now */
}
#endif /*IMAGEN*/

View file

@ -1,32 +0,0 @@
/* ELLE - Copyright 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EESIGS.H
* This file is only provided for inclusion only by V6 systems, where
* the standard /usr/include/signal.h file may not exist and thus we
* need to do our own definitions.
*/
/* Signals marked with "*" cause a core image dump
* if not caught or ignored. */
#define SIGHUP 1 /* Hangup (eg dialup carrier lost) */
#define SIGINT 2 /* Interrupt (user TTY interrupt) */
#define SIGQUIT 3 /* * Quit (user TTY interrupt) */
#define SIGILL 4 /* * Illegal Instruction (not reset when caught) */
#define SIGTRAP 5 /* * Trace Trap (not reset when caught) */
#define SIGIOT 6 /* * IOT instruction */
#define SIGEMT 7 /* * EMT instruction */
#define SIGFPE 8 /* * Floating Point Exception */
#define SIGKILL 9 /* Kill (cannot be caught or ignored) */
#define SIGBUS 10 /* * Bus Error */
#define SIGSEGV 11 /* * Segmentation Violation */
#define SIGSYS 12 /* * Bad argument to system call */
#define SIGPIPE 13 /* Write on a pipe with no one to read it */
#define SIGALRM 14 /* Alarm Clock */
#define SIGTERM 15 /* Software termination signal (from "kill" pgm) */
#define SIG_DFL (int (*)())0 /* Arg to "signal" to resume default action */
#define SIG_IGN (int (*)())1 /* Arg to "signal" to ignore this sig */

View file

@ -1,367 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EESITE Site dependent frobs
* Primarily TS_ routines for TTY control. Most site-dependent
* routine is TS_INP for detection of TTY input.
*/
#define _MINIX 1
#include "elle.h"
#if !(V6)
#include <signal.h> /* For SIGTSTP in ts_pause */
#else
#include "eesigs.h"
#endif
int tsf_pause = 0; /* Set if ts_pause works. Ref'd by equit in e_main */
#if !(SYSV || BBN) /* SYSV and BBN have weird tty calls */
#if MINIX
#include <sys/ioctl.h>
#include <termios.h>
struct termios origterm, newterm;
#else
#if V6
/* Normal V6 declarations, must provide explicitly */
struct sgttyb {
char sg_ispeed;
char sg_ospeed;
char sg_erase;
char sg_kill;
int sg_flags;
};
#define ECHO (010)
#define CRMOD (020)
#define RAW (040)
#else
/* Normal V7 UNIX declarations, can use include file */
#include <sgtty.h>
#endif
struct sgttyb nstate; /* Both V6 and V7 */
struct sgttyb ostate; /* Both V6 and V7 */
#endif /*!(SYSV || BBN)*/
#endif /*!MINIX*/
#if BBN /* BBN system frobs */
#include "/sys/sys/h/modtty.h"
struct modes nstate;
struct modes ostate;
#endif /*BBN*/
#if DNTTY /* DN TTY frobs */
#include <tty.h>
char partab[2]; /* to satisfy obscene ref in tty.h */
#endif /*DNTTY*/
#if (UCB || TOPS20) /* UCB, TOPS20 additional frobs */
#include <sys/ioctl.h> /* For ts_inp() and tldisc */
#if IMAGEN
struct tchars otchars, ntchars; /* Original and new tchars */
#endif /*IMAGEN*/
#endif /*(UCB || TOPS20)*/
#if SYSV /* System V (and PC/IX) crocks */
#include <termio.h>
#include <sys/ioctl.h>
struct termio /* terminal i/o status flags */
origterm, /* status of terminal at start of ELLE */
newterm; /* status of terminal when using ELLE */
#endif /*SYSV*/
/* TS_INP
* Ask system if terminal input is available (on file descriptor 0).
* Returns non-zero if so, else returns zero.
* Very important that this call NOT hang or block in any way,
* because it is used to detect type-ahead by the user;
* return should be immediate whether or not input is waiting.
*/
ts_inp()
{
#if BBN /* Idiosyncratic */
int cap_buf[2];
capac (0, &cap_buf[0], 4);
return (cap_buf[0]);
#endif /*BBN*/
#if (DNTTY || ONYX) /* Have "empty()" syscall */
return(empty(0) ? 0 : 1);
#endif /*DNTTY || ONYX*/
#if (UCB || TOPS20) /* Have FIONREAD ioctl */
long retval;
if(ioctl(0,FIONREAD,&retval)) /* If this call fails, */
return(0); /* assume no input waiting */
return((retval ? 1 : 0));
#endif /*UCB || TOPS20*/
#if COHERENT
int retval;
ioctl(0, TIOCQUERY, &retval);
return((retval ? 1 : 0));
#endif /*COHERENT*/
#if VENIX86
struct sgttyb iocbuf;
ioctl(0, TIOCQCNT, &iocbuf);
return(iocbuf.sg_ispeed != 0 );
#endif /*VENIX86*/
#if !(BBN||COHERENT||DNTTY||ONYX||TOPS20||UCB||VENIX86)
return(0); /* Default - never any type-ahead, sigh */
#endif
}
/* TS_INIT()
* Get terminal information from system, initialize things for
* ts_enter and ts_exit. This is called before t_init.
* Must set "trm_ospeed".
*/
ts_init()
{
#if DNTTY
signal(16,1); /* DN peculiar - turn off ctl-A */
#endif /*DNTTY*/
#if !(MINIX || SYSV || BBN) /* Normal UNIX stuff */
ioctl(1, TIOCGETP, &ostate); /* Remember old state */
nstate = ostate; /* Set up edit-mode state vars */
nstate.sg_flags |= RAW; /* We'll want raw mode */
nstate.sg_flags &= ~(ECHO|CRMOD); /* with no echoing */
trm_ospeed = ostate.sg_ospeed;
#if (IMAGEN && UCB)
/* Get around 4.1+ remote/local flow control bug (from Gosmacs) */
ioctl(0, TIOCGETC, &otchars); /* Save original tchars */
ntchars = otchars;
ntchars.t_startc = -1; /* Kill start/stop */
ntchars.t_stopc = -1;
ioctl(0, TIOCSETC, &ntchars);
#endif /*IMAGEN && UCB*/
#endif /*!(SYSV || BBN)*/
#if BBN
modtty(1, M_GET | M_MODES, &ostate, sizeof(ostate)); /* Save old */
modtty(1, M_GET | M_MODES, &nstate, sizeof(nstate)); /* Setup new */
nstate.t_erase = nstate.t_kill = nstate.t_intr = nstate.t_esc =
nstate.t_eof = nstate.t_replay = 0377;
nstate.t_quit = BELL; /* ^G */
nstate.t_breaks = TB_ALL; /* break on all */
nstate.t_iflags &= ~TI_ECHO & ~TI_NOSPCL & ~TI_CRMOD;
/* no echos, specials on, no CR -> LF*/
nstate.t_iflags |= TI_CLR_MSB; /* ignore parity */
nstate.t_oflags &= ~TO_CRMOD & ~TO_AUTONL; /* no CR -> NL */
if (trm_flags & NOXONOFF)
nstate.t_oflags &= ~TO_XONXOFF;
else
nstate.t_oflags |= TO_XONXOFF;
nstate.t_oflags |= TO_CLR_MSB; /* no special high bits */
nstate.t_pagelen = 0; /* no paging of output */
trm_ospeed = ostate.t_ospeed;
#endif /*BBN*/
#if MINIX
tcgetattr(0, &origterm); /* How things are now */
newterm = origterm; /* Save them for restore on exit */
/* input flags */
newterm.c_iflag |= IGNBRK; /* Ignore break conditions.*/
newterm.c_iflag &= ~INLCR; /* Don't map NL to CR on input */
newterm.c_iflag &= ~ICRNL; /* Don't map CR to NL on input */
newterm.c_iflag &= ~BRKINT; /* Do not signal on break.*/
newterm.c_iflag &= ~IXON; /* Disable start/stop output control.*/
newterm.c_iflag &= ~IXOFF; /* Disable start/stop input control.*/
/* output flags */
newterm.c_oflag &= ~OPOST; /* Disable output processing */
/* line discipline */
newterm.c_lflag &= ~ISIG; /* Disable signals.*/
newterm.c_lflag &= ~ICANON; /* Want to disable canonical I/O */
newterm.c_lflag &= ~ECHO; /* Disable echo.*/
newterm.c_lflag &= ~ECHONL; /* Disable separate NL echo.*/
newterm.c_lflag &= ~IEXTEN; /* Disable input extensions.*/
newterm.c_cc[VMIN] = 1; /* Min. chars. on input (immed) */
newterm.c_cc[VTIME] = 0; /* Min. time delay on input (immed) */
/* Make it stick */
tcsetattr(0, TCSANOW, &newterm);
#endif /*MINIX*/
#if SYSV
ioctl(0, TCGETA, &origterm); /* How things are now */
newterm = origterm; /* Save them for restore on exit */
/* input flags */
newterm.c_iflag |= IGNBRK; /* Ignore break conditions.*/
newterm.c_iflag &= ~INLCR; /* Don't map NL to CR on input */
newterm.c_iflag &= ~ICRNL; /* Don't map CR to NL on input */
newterm.c_iflag &= ~BRKINT; /* Do not signal on break.*/
newterm.c_iflag &= ~IXON; /* Disable start/stop output control.*/
newterm.c_iflag &= ~IXOFF; /* Disable start/stop input control.*/
/* line discipline */
newterm.c_lflag &= ~ISIG; /* Disable signals.*/
newterm.c_lflag &= ~ICANON; /* Want to disable canonical I/O */
newterm.c_lflag &= ~ECHO; /* Disable echo.*/
newterm.c_cc[4] = 1; /* Min. chars. on input (immed) */
newterm.c_cc[5] = 1; /* Min. time delay on input (immed) */
/* Make it stick */
ioctl(0, TCSETA, &newterm);
#endif /*SYSV*/
#if (UCB || TOPS20)
{ int tldisc;
ioctl(0, TIOCGETD, &tldisc); /* Find line discipline */
/* The flag IGN_JOB_CONTROL has been introduced to allow job control haters
* to simply ignore the whole thing. When ELLE is compiled with
* -DIGN_JOB_CONTROL, it will exit properly when the Return to Superior
* command is executed.
*/
#if SIGTSTP
#ifndef IGN_JOB_CONTROL
if(tldisc == NTTYDISC) tsf_pause = 1;
#endif
#endif /*SIGTSTP*/
}
#endif /*UCB || TOPS20*/
}
/* TS_ENTER()
* Tell system to enter right terminal mode for editing.
* This is called before t_enter.
*/
ts_enter()
{
#if !(MINIX || SYSV || BBN)
ioctl(1, TIOCSETP, &nstate);
#if IMAGEN && UCB
ioctl(0, TIOCSETC, &ntchars); /* Restore new tchars */
#endif /*IMAGEN && UCB*/
#endif /*!(SYSV||BBN)*/
#if BBN
modtty (1, M_SET | M_MODES, &nstate, sizeof (nstate));
#endif /*BBN*/
#if MINIX
/* Make it behave as previously defined in ts_init */
tcsetattr(0, TCSANOW, &newterm);
#endif /*SYSV*/
#if SYSV
/* Make it behave as previously defined in ts_init */
ioctl(0, TCSETA, &newterm);
#endif /*SYSV*/
#if DNTTY /* DN hackery! Enable 8-bit input so as to read meta bit. */
if(dbg_isw)
{ tpoke(TH_CSET,T_2FLGS2,EEI); /* Enable ints */
tpoke(TH_CSETB,T_QUIT, 0377); /* Turn off QUIT intrpt */
}
else if(trm_flags & TF_METAKEY)
tpoke(TH_CSET,T_2FLGS2,T2_LITIN); /* Turn on 8-bit input! */
#endif /*DNTTY*/
}
/* TS_EXIT
* Tell system to restore old terminal mode (we are leaving edit mode).
* This is called after t_exit.
*/
ts_exit()
{
#if DNTTY
if(dbg_isw)
tpoke(TH_CCLR,T_2FLGS2,EEI); /* Turn off EEI bit */
else if(trm_flags & TF_METAKEY)
tpoke(TH_CCLR,T_2FLGS2,T2_LITIN); /* Turn off 8-bit input */
#endif /*DNTTY*/
#if !(MINIX || SYSV || BBN)
ioctl(1, TIOCSETP, &ostate); /* SYSV and BBN don't use stty */
#if IMAGEN && UCB
ioctl(0, TIOCSETC, &otchars); /* Restore original tchars */
#endif /*IMAGEN && UCB*/
#endif /*!(SYSV || BBN)*/
#if BBN
modtty (1, M_SET | M_MODES, &ostate, sizeof (ostate));
#endif /*BBN*/
#if MINIX
tcsetattr(0, TCSANOW, &origterm);
#endif /*MINIX*/
#if SYSV
ioctl(0, TCSETA, &origterm);
#endif /*SYSV*/
}
#if DNTTY
int thkcmd[] { 0, 0, -1 };
tpoke(cmd,bn,val)
int cmd, bn, val;
{
thkcmd[0] = cmd|bn;
thkcmd[1] = val;
if(ttyhak(0,&thkcmd) < 0)
return(-1);
else return(thkcmd[1]);
}
#endif /*DNTTY*/
/* TS_PAUSE - Stop process and return control of TTY to superior.
* There is also a flag variable, TSF_PAUSE, which indicates
* whether or not this routine will actually do anything.
*/
#if TOPS20
#include <jsys.h>
#endif
ts_pause()
{
#if TOPS20
int acs[5];
jsys(HALTF, acs);
#endif
#if UCB
#if SIGTSTP
signal(SIGTSTP, SIG_DFL);
#if BSD4_2
#define mask(s) (1 << ((s)-1))
sigsetmask(sigblock(0) &~ mask(SIGTSTP));
#endif /*BSD4_2*/
kill(0, SIGTSTP);
#if BSD4_2
sigblock(mask(SIGTSTP));
#endif /*BSD4_2*/
#endif /*SIGTSTP*/
#endif /*UCB*/
}
ts_winsize()
{
#ifdef TIOCGWINSZ
struct winsize winsize;
if (ioctl(1, TIOCGWINSZ, &winsize) == 0) {
if (winsize.ws_row != 0) scr_ht = winsize.ws_row;
if (winsize.ws_col != 0) scr_wid = winsize.ws_col;
}
#endif
}

View file

@ -1,184 +0,0 @@
/* ELLE - Copyright 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EESITE.H Site-dependent switches & definitions
*/
/* CONDITIONAL COMPILATION SWITCHES */
#define V6 0 /* Running on V6 system (else V7 assumed) */
#define APOLLO 0 /* Running on an Apollo system */
#define BBN 0 /* Running on BBN system (tty stuff) */
#define BSD4_2 0 /* Running on 4.2BSD system */
#define COHERENT 0 /* Running on Coherent IBM-PC system */
#define DNTTY 0 /* Running on SRI V6 Deafnet system (tty stuff) */
#define HPUX 0 /* Running on Hewlett-Packard System V + */
#define MINIX 1 /* Running on MINIX (IBM-PC) system */
#define ONYX 0 /* Running on ONYX Z8000 system */
#define PCIX 0 /* Running on PC/IX (IBM-PC) system */
#define SUN 0 /* Running on SUN workstation system */
#define SYSV 0 /* Running on Unix System V (or perhaps Sys III) */
#define TOPS20 0 /* Running on TOPS-20 KCC C implementation */
#define UCB 0 /* Running on 2.8, 2.9, or 4.x BSD sys (tty stuff) */
#define VENIX86 0 /* Running on Venix86 (IBM-PC) system */
#define ICONOGRAPHICS 0 /* Using Iconographics configuration version */
#define IMAGEN 0 /* Using Imagen configuration version */
/* Resolve system dependencies */
#if SUN
#undef BSD4_2
#define BSD4_2 1 /* SUN uses 4.2BSD */
#endif
#if BSD4_2
#undef UCB
#define UCB 1 /* 4.2 is special case of general UCB stuff */
#endif /*BSD4_2*/
#if (PCIX || HPUX)
#undef SYSV
#define SYSV 1 /* PC/IX & HP-UX are based on System III & V (resp) */
#endif
/* Set system or site dependent stuff here */
#if V6
#define void int /* May need this for other systems too */
#endif
/* Changes to parameters (elle.h) or variable defaults (e_vinit.c) */
#if COHERENT
#define EVFNO2 0 /* "Old" filename postfix - use no old file! */
#define EVFNN2 "+" /* "New" filename postfix */
#define TX_COHIBM 1 /* Ensure Coherent IBM-PC console support included */
#endif /*COHERENT*/
#if DNTTY
#define EVLLEN 60 /* Short line length for TDDs */
#endif /*DNTTY*/
#if HPUX
#define EVFNO2 "~" /* Same as CCA Emacs. Sorts last in listing. */
#endif /*HPUX*/
#if MINIX
#define EVFNO2 ".bak" /* "Old" filename postfix */
#define EVMARKSHOW "Mark set"
#define EVCCOL (33) /* Use this as Comment Column */
#define EVMVPCT 1 /* 1% - Try to use minimal window repositioning */
#define EVMODWSO 1 /* Use mode window standout if can */
#define STRERROR 1 /* Say that implementation provides strerror() */
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#endif /*MINIX*/
#if ONYX
#define STKMEM (4*512) /* ONYX Z8000 seems to have less room avail */
#endif /*ONYX*/
#if BSD4_2
#define FNAMELEN 255 /* Max size of last filename component */
#define FNAMSIZ 400 /* Max size of complete filename */
#endif /*BSD4_2*/
#if TOPS20
#define EVHELPFILE "elle:help.dat" /* T20 ELLE help file */
#define EVPROFBINFILE "ellep.b1" /* T20 binary profile file */
#define EVPROFTEXTFILE "ellep.e" /* T20 ASCII profile file */
#define EVFNO2 0 /* No old filename postfix (T20 has generations) */
#define EVFNN2 0 /* No new filename postfix (T20 has generations) */
#define FNAMELEN (40*3) /* Max size of non-directory filename component */
#define FNAMSIZ (40*5) /* Max size of complete filename */
#define STRERROR 1 /* Say that implementation provides strerror() */
#endif /*TOPS20*/
#if VENIX86
#define TIBFSIZ 1 /* Venix86 block reads in raw mode */
#endif /*VENIX86*/
/* Configuration settings */
#if ICONOGRAPHICS
#define EVFNO2 "@" /* "Old" filename postfix */
#define EVMARKSHOW "Set."
#define PARABLOCK 1 /* Values meaningful only for ICONOGRAPHICS */
#define PARALINE 2
#define TXC_VISBEL 1 /* Use visible bell if possible */
#endif /*ICONOGRAPHICS*/
#if IMAGEN
#define EVFNO2 ".BAK" /* "Old" filename postfix */
#define EVMARKSHOW "Mark set"
#define TOBFSIZ (10*80) /* Size of TTY output buffer */
#define ECHOLINES 2 /* Use 2 echo-area lines, not 1 */
#define MAXARGFILES 10 /* Several startup filename args */
#endif /*IMAGEN*/
/* Now set any defaults for things not already defined */
/* TERMINAL SUPPORT SWITCHES */
/* Only those terminals which have a switch defined here */
/* will be included in ELLE's "hardwired" support. */
/* Switch name: Compiles support for: */
#ifndef TX_TERMCAP
#define TX_TERMCAP 1 /* * - most TERMCAP-defined terminals */
#endif
#ifndef TX_H19
#define TX_H19 1 /* "H19" - Heath/Zenith-19 */
#endif
#ifndef TX_DM2500
#define TX_DM2500 1 /* "DM2500","DM3025" - Datamedia 2500 */
#endif
#ifndef TX_COHIBM
#define TX_COHIBM 0 /* "COHIBM" - Coherent IBM-PC console */
#endif
#ifndef TX_TVI925
#define TX_TVI925 0 /* "TVI925" - TeleVideo 925 */
#endif
#ifndef TX_OM8025
#define TX_OM8025 0 /* "OM8025" - Omron 8025AG */
#endif
#ifndef TXC_VISBEL /* Non-zero if want to use visible bell */
#define TXC_VISBEL 0
#endif
/* Default terminal type string, used if ELLE cannot get type either
** from $TERM or from startup args.
*/
#ifndef TXS_DEFAULT
#define TXS_DEFAULT "H19" /* Default terminal type string */
#endif
/* Combination parameter/switch definitions */
/* STKMEM - System-dependent stack allocation crock, defines amount of
* stack memory to grab for general-purpose use. This is mainly
* useful for PDP-11s or machines with similarly brain-damaged
* address space hardware. A PDP-11 memory segment is 8K bytes,
* or 16 512-byte blocks, and the stack segment quarantines all of
* this space even though the actual stack may only use a miniscule
* portion of it.
*/
/* Use this if compiling for a PDP11 system, otherwise leave undefined.. */
#if (V6 || 0)
#define STKMEM (8*512) /* Use half a PDP11 segment */
#endif
/* These defaults are in eesite.h so ELLEC can get at them too. */
#ifndef EVPROFBINFILE /* Location of binary user profile, relative to HOME */
#define EVPROFBINFILE ".ellepro.b1"
#endif
#ifndef EVPROFTEXTFILE /* Location of ASCII user profile (used by ELLEC) */
#define EVPROFTEXTFILE ".ellepro.e"
#endif

View file

@ -1,276 +0,0 @@
/* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* EESRCH Searching functions
*/
#include "elle.h"
#if !(V6)
#include <signal.h>
#else
#include "eesigs.h" /* Use this on V6 system */
#endif /*V6*/
/*
* Buffer String Search routines
*
* If no search string is provided, a string that was previously
* used in the last search is once again used.
*/
/* EFUN: "String Search" */
f_srch()
{ return (lin_search (0));
}
/* EFUN: "Reverse String Search" */
f_rsrch()
{ return (lin_search (1));
}
/* LIN_SEARCH - Main routine for non-incremental String Search. Asks for
* a search string and looks for it.
*/
lin_search (backwards)
int backwards;
{ register char *mem; /* item to be searched for */
register int res;
int srchint(), (*sav_srchalarm)();
char *srch_ask();
chroff savdot;
savdot = cur_dot; /* Save original loc */
#if ICONOGRAPHICS
if((mem = srch_ask(backwards ? "Reverse Search%s%s%s"
: "Search%s%s%s"))==0)
return;
#else
if((mem = srch_ask(backwards ? "Reverse Search: " : "Search: "))==0)
return;
#endif /*-ICONOGRAPHICS*/
sav_srchalarm = signal(SIGALRM,/*&*/srchint); /* Handle timeout */
alarm(1); /* One sec from now */
res = e_search(mem,srch_len,backwards); /* Search for str! */
alarm(0); /* Turn off alarm */
signal(SIGALRM,sav_srchalarm); /* Restore old handler */
if(res) /* Search won? */
{ ed_setcur();
return;
}
/* Search failed */
e_gosetcur(savdot);
ding("Search Failed");
}
srchint()
{ yelltoo(" ...");
}
char *
srch_ask(prompt)
char *prompt;
{ register char *ans, *old;
#if ICONOGRAPHICS
if (srch_str)
ans = ask(prompt, " (", srch_str, "): ");
else ans = ask (prompt, ": ", "", "");
if (ans == 0) return (0);
#else
if((ans = ask(prompt)) == 0)
return(0); /* user punted ... */
#endif /*-ICONOGRAPHICS*/
old = srch_str;
if (*ans == '\0')
{ chkfree(ans);
if ((ans = old) == 0) /* no string specified */
{ dingtoo("Nothing to search for");
return(0);
}
#if !(ICONOGRAPHICS)
saylntoo(old, srch_len); /* Show what old string is */
#endif /*-ICONOGRAPHICS*/
}
else
{ if (old)
chkfree(old); /* free up old srch string */
srch_str = ans;
srch_len = ask_len;
}
return(ans);
}
#if 0
Incremental Search stuff.
Description of EMACS behavior:
^Q quotes next char.
DEL cancels last char. If this cancelled a match, point is moved
to previous match.
If not all of input can be found, it is not discarded. Can rub out,
discard unmatched stuff with ^G, exit, etc.
^S repeats search forward; ^R repeats backward.
If empty string, either
changes direction (if not same)
or brings back previous string
ESC exits. If empty string, changes to non-incremental string search.
^G of a winning search aborts, exits, and moves point back to origin.
^G of a failing search discards the input that wasn''t found.
Other C- or M- chars exit and are executed.
ELLE also interprets ^H (BS) as DEL, because some keyboards make it hard to
type DEL and there is no way the user can
re-bind the incremental-search commands.
#endif /*COMMENT*/
#if FX_ISRCH
/* EFUN: "Incremental Search" */
f_isrch() { i_search(0); }
#endif /*FX_ISRCH*/
#if FX_RISRCH
/* EFUN: "Reverse Search" */
f_risrch() { i_search(1); }
#endif /*FX_RISRCH*/
#if FX_ISRCH || FX_RISRCH
i_search(back)
int back; /* Current mode: 0 if forward, 1 if backward */
{ register int c;
register int inpcnt; /* # chars in current input srch str */
int inpgood; /* Length of last winning string */
char inpstr[ISRCHLIM]; /* Holds current input search string */
chroff inpdot[ISRCHLIM]; /* Holds winning addrs for each */
struct window *savwin;
int winning; /* 1 = currently winning, 0 = currently failing */
int pref, shown;
int f_insself(), (*(cmd_fun()))();
winning = 1;
inpcnt = 0;
inpgood = 0;
inpdot[0] = cur_dot;
savwin = cur_win;
/* Set up prompt and read all TTY input thus far */
shown = 0;
sloop: c = cmd_wait(); /* See if any command input waiting */
if(shown || !c)
{ e_setcur(); /* Assume we moved around, so set cur_dot */
chg_win(ask_win);
ed_reset(); /* Flush contents & invoke redisplay */
ed_sins(back ? "R-search: " : "I-search: ");
ed_nsins(inpstr, inpcnt);
if(!winning) ed_sins("\t(FAILING)");
upd_wind((struct window *)0); /* Force ask_win update */
if(c)
{ upd_curs(cur_dot);
tbufls();
}
chg_win(savwin);
shown = 1; /* Say search prompt has been shown */
}
if(!c) /* If no user input waiting, show buffer */
{ redp(RD_MOVE); /* Cursor moved in window */
redisplay();
}
c = cmd_read(); /* Get input char */
switch(c)
{ case DEL: /* Cancel last char */
case BS: /* Hard to type DEL on some kbds */
if(inpcnt <= 0) goto sloop;
if(--inpcnt > inpgood) goto sloop;
winning = 1;
if(inpcnt == inpgood) goto sloop;
inpgood--;
ed_go(inpdot[inpcnt]);
goto sloop;
case CTRL('Q'):
c = cmd_read(); /* Quote next char */
break;
case CTRL('S'):
pref = 0;
goto ctlsr;
case CTRL('R'):
pref = 1;
goto ctlsr;
case CTRL('G'):
if(winning)
{ ed_go(inpdot[0]);
goto sdone;
}
inpcnt = inpgood;
winning = 1;
goto sloop;
case ESC:
case CR:
if(inpcnt)
goto sdone;
lin_search(back);
return;
default:
if(f_insself != cmd_fun(c))
{ unrchf = c;
goto sdone;
}
case TAB: /* Strange self-inserting char */
break;
}
if(inpcnt >= ISRCHLIM-1)
{ ding("I-search str too long");
sleep(1);
goto sdone;
}
inpstr[inpcnt++] = c;
if(!winning) goto sloop;
/* Now search for string. (Arm alarm interrupt?) */
/* cur_dot has current location cursor is at; we want to back off
* from this so a repeated search will find the same location if
* appropriate. */
e_igoff(back ? inpcnt : -(inpcnt-1));
dosrch:
winning = e_search(inpstr,inpcnt,back);
if (winning)
{ inpgood = inpcnt; /* Remember last win length */
inpdot[inpcnt] = e_dot(); /* and location */
}
else e_gocur(); /* Back to start position */
goto sloop;
ctlsr: if (pref != back)
{ back = pref;
if(inpcnt <= 0) goto sloop;
}
if(inpcnt <= 0)
{ if(!srch_str || (inpcnt = srch_len) <= 0)
goto sloop;
bcopy((SBMA)srch_str, (SBMA)inpstr, srch_len);
inpcnt = srch_len;
unrchf = c; /* Repeat cmd after display */
shown = 1; /* Force search-string display */
goto sloop;
}
goto dosrch;
sdone:
if(srch_str) chkfree(srch_str);
srch_str = memalloc((SBMO)(inpcnt+1));
bcopy((SBMA)inpstr,(SBMA)srch_str,inpcnt); /* Copy into srch_str */
srch_len = inpcnt;
e_setcur();
chg_win(ask_win);
ed_reset();
chg_win(savwin);
redp(RD_CHKALL);
}
#endif /*FX_ISRCH || FX_RISRCH*/

File diff suppressed because it is too large Load diff

View file

@ -1,100 +0,0 @@
/* ELLE - Copyright 1982, 1987 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/* EEVINI - ELLE initialized variables and array storage.
* Initial values are defined here, but the vars must be
* declared in ELLE.H as well so that references from all modules will
* compile correctly.
* Arrays are also allocated here, so size re-definitions only require
* re-compiling this single small module.
*/
#define EXT /* Allocate storage for non-initialized vars */
#include "elle.h"
#ifndef EVFILMOD
#if V6
#define EVFILMOD (0600) /* (int) Default file creation mode on V6 */
#else
#define EVFILMOD (0666) /* (int) Default file creation mode on V7, note */
#endif /*-V6*/ /* paranoids can use V7 "umask" in shell. */
#endif
#ifndef EVFNO1
#define EVFNO1 0 /* (char *) "Old" filename prefix */
#endif
#ifndef EVFNN1
#define EVFNN1 0 /* (char *) "New" filename prefix */
#endif
#ifndef EVFNO2
#define EVFNO2 "O" /* (char *) "Old" filename postfix */
#endif
#ifndef EVFNN2
#define EVFNN2 "N" /* (char *) "New" filename postfix */
#endif
#ifndef EVFCOL
#define EVFCOL (71) /* (int) Initial value for Fill Column */
#endif
#ifndef EVCCOL
#define EVCCOL (40) /* (int) Initial value for Comment Column */
#endif
#ifndef EVNWPCT
#define EVNWPCT 50 /* (int) 50% For random New Window, center cursor. */
#endif
#ifndef EVMVPCT
#define EVMVPCT 67 /* (int) 67% When move off edge, show 67% new stuff */
#endif
#ifndef EVMODWSO
#define EVMODWSO 0 /* (bool) Initial mode window standout mode */
#endif
#ifndef EV2MODEWS
#define EV2MODEWS 1 /* 2-mode-window flag. 0=Never, 1=if SO, 2=always */
#endif
#ifndef EVMARKSHOW
#define EVMARKSHOW 0 /* (char *) String shown for Set Mark */
#endif
#ifndef EVHELPFILE /* (char *) Location of ELLE help file. */
#define EVHELPFILE "/usr/src/elle/help.dat"
#endif
char *ev_verstr = "ELLE 4.1b"; /* String: Editor name and version # */
int ev_filmod = EVFILMOD; /* Default file creation mode */
char *ev_fno1 = EVFNO1; /* "Old" filename prefix */
char *ev_fnn1 = EVFNN1; /* "New" filename prefix */
char *ev_fno2 = EVFNO2; /* "Old" filename postfix */
char *ev_fnn2 = EVFNN2; /* "New" filename postfix */
int ev_fcolumn = EVFCOL; /* Initial value for Fill Column */
#if FX_INDCOMM
int ev_ccolumn = EVCCOL; /* Initial value for Comment Column */
#endif
/* New window selection parameters.
** Both are expressed as an integer % of window lines (where the whole
** window is 100), and apply when a new window is selected.
** ev_nwpct - when "New Window" is called, % of lines between top and cursor.
** Also applies when screen has changed randomly.
** ev_mvpct - when cursor moves out of window, this is the % of lines
** between top and cursor (if moved off top) or between bottom and
** cursor (if moved off bottom).
*/
int ev_nwpct = EVNWPCT; /* New Window cursor loc preference (%) */
int ev_mvpct = EVMVPCT; /* Moved cursor loc preference (%) */
#if FX_SOWIND
int ev_modwso = EVMODWSO; /* Initial mode window standout flag */
#endif
#if FX_2MODEWINDS
int ev_2modws = EV2MODEWS; /* Initial 2-mode-wind flag */
#endif
char *ev_markshow = EVMARKSHOW; /* String to display when Set Mark done */
char *ev_helpfile = EVHELPFILE; /* Location of ELLE help file */
char *ev_profile = EVPROFBINFILE; /* Location of ELLE binary user profile */
/* Note ELLE doesn't use EVPROFTEXTFILE. */
/* Array allocations */
struct scr_line *scr[MAXHT]; /* Array of screen line structures */
SBSTR *kill_ring[KILL_LEN]; /* Kill ring table */

View file

@ -1,364 +0,0 @@
/* ELLE - Copyright 1982, 1984 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author.
*/
/*
* ELLE.H Global ELLE definitions
*/
#ifndef EXT
#define EXT extern /* Default assumes these are referencing decls */
#endif
/* Make identifiers unique in 1st 6 chars as per ANSI rule for externals */
#define tvc_cin tvccin
#define tvc_cdn tvccdn
#define tvc_lin tvclin
#define tvc_ldn tvcldn
#define ev_fno1 evfno1
#define ev_fno2 evfno2
#define ev_fnn1 evfnn1
#define ev_fnn2 evfnn2
#define ask_sall asksal /* eebuff.c */
#define ask_save asksav
#define buf_tmod buftmo
#define buf_tmat buftma
#define e_gobob egobob /* eeedit.c */
#define e_gobol egobol
#define e_goeob egoeob
#define e_goeol egoeol
#define fill_prefix filpfx /* eefill.c */
#define fill_plen filpln
#define fill_cur_line filcln
#define kill_ptr kilptr /* eef3.c */
#define kill_push kilpsh
#define ed_insert edinst /* eefed.c */
#define ed_insn edinsn
#define ed_deln eddeln
#define ed_delete eddele
#define f_fillreg ffilrg /* eejust.c */
#define f_fillpara ffilpa
#include "eesite.h" /* Insert site-dependent flags and parameters */
#include "sb.h" /* Insert SB package definitions */
#include "eeprof.h" /* Insert user profile definition. This is a
* separate file so ELLEC can use it too. */
#include "eefidx.h" /* Insert desired function defs */
/* ELLE Compile-time parameter defaults */
#ifndef KILL_LEN
#define KILL_LEN 8 /* Size of kill ring */
#endif
#ifndef MAXHT
#define MAXHT 72 /* Height (# lines) of largest screen we'll suport */
#endif
#ifndef MAXLINE
#define MAXLINE 132 /* Width (# chars) of largest screen we'll support */
#endif
#ifndef FNAMELEN
#define FNAMELEN 14 /* Sys-dep: Max size of last filename component */
#endif /* Check FNAMSIZ if you change this. */
#ifndef FNAMSIZ
#define FNAMSIZ 100 /* Sys-dep: Max size of complete filename */
#endif /* This must be at least as large as FNAMELEN! */
#ifndef ISRCHLIM
#define ISRCHLIM 50 /* Max # of chars to allow I-search on */
#endif
#ifndef TOBFSIZ
#define TOBFSIZ 80 /* Size of TTY output buffer */
#endif
#ifndef TIBFSIZ
#define TIBFSIZ 50 /* Size of TTY input buffer */
#endif
#ifndef ECHOLINES
#define ECHOLINES 1 /* # of lines for echo area (below mode line) */
#endif
#ifndef MAXARGFILES
#define MAXARGFILES 2 /* # of filename args OK at startup */
#endif
/* ELLE initialized variables.
* Initial values are defined in EEVINI.C, but the vars must be
* declared here as well so that references from all modules will
* compile correctly.
*/
extern char *ev_verstr; /* String: Editor name and version # */
extern int ev_filmod; /* Default file creation mode */
extern char *ev_fno1,*ev_fno2; /* Pre, postfix for "old" filenames */
extern char *ev_fnn1,*ev_fnn2; /* Pre, postfix for "new" filenames */
extern int ev_fcolumn; /* Fill Column variable */
#if FX_INDCOMM
extern int ev_ccolumn; /* Comment Column variable */
#endif
extern int ev_nwpct, ev_mvpct; /* New window selection percentages */
#if FX_SOWIND
extern int ev_modwso; /* Initial mode window standout flag */
#endif
#if FX_2MODEWINDS
extern int ev_2modws; /* Initial setting of 2-mode-window flag */
#endif
extern char *ev_markshow; /* String to show when Set Mark done */
extern char *ev_helpfile; /* Location of ELLE help file */
extern char *ev_profile; /* Filename of ELLE binary user profile */
extern struct profile def_prof; /* ELLE default user profile */
/* Global variables */
EXT chroff cur_dot; /* Current dot */
EXT chroff mark_dot; /* Dot for mark */
EXT int mark_p; /* flag indicating whether mark exists */
EXT int this_cmd, last_cmd; /* Command type */
EXT int unrchf; /* Stuffed character back for readcommand */
EXT int exp; /* Numeric argument for commands */
EXT int exp_p; /* Flag meaning an arg was given */
EXT int pgoal; /* Permanent goal column */
EXT int goal;
EXT char *srch_str; /* Last search string specified (0 = none) */
EXT int srch_len; /* Length of srch_str string */
EXT int ask_len; /* Length of last string returned by "ask" */
EXT char *homedir; /* User's home directory */
EXT int kill_ptr; /* Index into kill ring */
extern SBSTR *kill_ring[]; /* Kill ring table (allocated in eevini) */
/* Editor Command types */
#define KILLCMD 1 /* Kill command, for kill merging */
#define ARGCMD 2 /* Argument-setter, for main loop */
#define YANKCMD 3 /* Yank command, for yankpop */
#define LINECMD 4 /* Next or previous line goal hacking */
#if IMAGEN
#define INSCMD 5 /* Simple char-insert command, for autowrap */
#endif /*IMAGEN*/
/* Misc char definitions */
#define CTRL(ch) (037&ch)
#define BELL ('\007') /* Will become \a in ANSI */
#define BS ('\b')
#define TAB ('\t')
#define LF ('\n')
#define FF ('\f')
#define CR ('\r')
#define ESC ('\033')
#define SP (' ')
#define DEL ('\177')
#define CB_META (0200) /* Meta bit in command char */
#define CB_EXT (0400) /* Extend bit in command char */
#define METIZER ESC
#define EXTIZER CTRL('X')
/* Terminal parameters - set at runtime startup */
EXT char *tv_stype; /* Terminal type string specified by user/system */
EXT int scr_ht; /* # lines of main screen area */
EXT int scr_wid; /* # columns of screen */
EXT int scr_wd0; /* scr_wid - 1 (for 0-origin stuff) */
EXT int trm_ospeed; /* Output speed index */
EXT int tvc_pos; /* Cost for absolute move (# of output chars) */
EXT int tvc_bs; /* Cost for backspace */
EXT int tvc_ci, tvc_cin; /* Char ins cost per call, cost per column */
EXT int tvc_cd, tvc_cdn; /* Char del " " " " " " */
EXT int tvc_li, tvc_lin; /* Line ins cost per call, cost per line */
EXT int tvc_ld, tvc_ldn; /* Line del " " " " " " */
EXT int trm_flags; /* Terminal capabilities - bit flags */
/* Maybe change to word vars someday (faster) */
#define TF_IDLIN 01 /* Has I/D line */
#define TF_IDCHR 02 /* Has I/D char */
#define TF_SO 04 /* Has usable standout mode */
#define TF_CLEOL 010 /* Has clear-to-eol */
#define TF_METAKEY 020 /* Has meta key */
#define TF_DIRVID 040 /* Has direct-video type interface */
/* Redisplay definitions */
EXT int curs_lin; /* Line # of current cursor (0 origin) */
EXT int curs_col; /* Column # of current cursor (0 origin) */
EXT int rd_type; /* Global var: holds redisplay "hints" */
#define redp(n) rd_type |= (n)
#define RD_SCREEN 01 /* Clear everything and redisplay */
#define RD_WINDS 02 /* Check all windows for changes (b/emod) */
#define RD_MODE 04 /* Mode line has changed, update it. */
#define RD_WINRES 0400 /* Assume all of window was changed (clear b/emod) */
#define RD_MOVE 010 /* Cursor has moved */
#define RD_UPDWIN 020 /* Window fixed, must update modified screen lines */
/*#define RD_ICHR 0 *//* Hint: Char insert done */
/*#define RD_DCHR 0 *//* Hint: Char del done */
#define RD_ILIN 0100 /* Hint: Line insert done */
#define RD_DLIN 0200 /* Hint: Line del done */
/* #define RD_MOVWIN 02000 *//* Window should be re-positioned */
#define RD_FIXWIN 02000 /* Window needs fixing (call fix_wind) */
#define RD_TMOD 04000 /* Text changed in this window, check it. */
#define RD_WINCLR 010000 /* Clear window with CLEOLs (not yet) */
#define RD_CHKALL 020000 /* Check all windows for redisplay flags */
#if IMAGEN
#define RD_REDO 040000 /* Just re-do the entire window, don't think */
#endif /*IMAGEN*/
/* Flags with global effects, only seen in rd_type */
#define RDS_GLOBALS (RD_SCREEN|RD_MODE|RD_WINDS|RD_CHKALL)
/* Flags which are allowed per-window (in w_redp) */
#define RDS_WINFLGS (~RDS_GLOBALS)
/* Flags which force FIX_WIND() to do something */
#define RDS_DOFIX (RD_WINRES|RD_TMOD|RD_FIXWIN|RD_MOVE)
#define CI_CLINE '!' /* Char indicator for continued line */
#define CI_CNTRL '^' /* Char indicator for control chars */
#define CI_META '~' /* Char indicator for meta-bit (8th) set */
#define CI_TOP '|' /* Char indicator for top-bit (9th) set */
#define MAXCHAR (8+3) /* Longest char representation (TAB) + slop */
/* Definitions for screen structures */
struct scr_line {
chroff sl_boff; /* Ptr to start of line's text in buffer */
int sl_len; /* # buffer chars in line (incl NL) */
char *sl_line; /* Ptr to screen image of line */
int sl_col; /* # chars in image == # columns used */
char sl_flg; /* Flags - set if this line modified */
char sl_cont; /* If line being continued on next, this */
/* contains 1 plus # extra chars (if any) */
/* stored at end of this line which shd be */
/* put at beg of next line. */
char *sl_nlin; /* New screen image line if modified flag set */
int sl_ncol;
};
/* sl_flg definitions */
#define SL_MOD 01 /* New line exists, must update to it */
#define SL_EOL 02 /* Buffer line ends with EOL */
#define SL_CSO 04 /* Current screen line is in standout mode */
#define SL_NSO 010 /* New screen line is in standout mode */
#if IMAGEN
#define SL_REDO 0100 /* Line should be redone completely */
#endif /*IMAGEN*/
extern struct scr_line *scr[]; /* Screen line ptrs (allocated in e_vinit) */
/* Buffer stuff */
struct buffer
{ SBBUF b_sb; /* MUST be 1st thing! */
struct buffer *b_next; /* ptr to next in chain */
char *b_name; /* text name */
char *b_fn; /* filename */
chroff b_dot; /* point (dot) */
int b_flags; /* misc. bits */
struct majmode *b_mode; /* Mode of buffer */
#if IMAGEN
long b_mtime; /* Last file modification time */
#endif /*IMAGEN*/
};
/* b_flags definitions */
#define B_MODIFIED 01 /* Buffer is modified */
#define B_EOLCRLF 0200 /* On = CRLF mode, off = LF mode */
#if IMAGEN
#define B_PERMANENT 002 /* buffer cannot be killed */
#define B_CMODE 004 /* "C" mode (HACK HACK) */
#define B_BACKEDUP 010 /* Buffer has been backed up once */
#define B_TEXTMODE 020 /* Text mode (auto-wrap, basically) */
#define B_QUERYREP 040 /* Query-replace mode (qualifier) */
#endif /*IMAGEN*/
/* Handy macro to check EOL mode */
#define eolcrlf(buf) (((struct buffer *)buf)->b_flags&B_EOLCRLF)
/* Buffer pointers */
EXT struct buffer
*buf_head, /* head of list of all buffers */
*cur_buf, /* buffer we are editing now */
*last_buf, /* buffer we were editing before */
*lines_buf; /* buffer for sep_win */
/* Window stuff */
struct window
{ struct window *w_next; /* ptr to next in chain */
int w_flags; /* Window flags */
int w_pos; /* index of top line */
int w_ht; /* number of lines */
struct buffer *w_buf; /* buffer in this window */
int w_pct; /* % of buffer window is at */
int w_redp; /* Redisplay hints */
chroff w_topldot; /* line currently at top of window */
chroff w_dot; /* Saved dot while not cur_win */
chroff w_bmod; /* Lower bound of modified text */
chroff w_emod; /* Upper bound of modified text */
/* (offset from end of buffer!) */
chroff w_oldz; /* Buffer len as of last update */
};
/* Window flags */
#define W_STANDOUT 01 /* Use terminal's standout mode for window */
#define W_MODE 02 /* This is a mode window */
/* Window pointers */
EXT struct window
*win_head, /* head of list of all windows */
*cur_win, /* window we are now in */
*user_win, /* current user window */
*oth_win, /* "other" user window */
*mode_win, /* window for mode line */
*ask_win, /* window for ask (echo) area */
*sep_win; /* window for separation dashes */
/* Major Mode stuff. Each buffer has its own major mode.
* Only one major mode may be in effect at any time.
*/
struct majmode {
char *mjm_name; /* Simple for now */
};
EXT struct majmode *fun_mode; /* Fundamental mode - the default */
EXT struct majmode *cur_mode; /* Current major mode */
/* Minor modes are currently implemented by means of flag variables
* which have global effects (regardless of buffer or major mode).
* Each variable has the name "x_mode" where x is the name of the minor
* mode. These are declared in the modules containing their support code.
* In the future this may be generalized along the lines of major modes.
*/
/* Miscellaneous debug stuff */
EXT int dbgval; /* Set nonzero to do verify stuff */
EXT int dbg_isw; /* Set to enable interrupts if possible */
#if IMAGEN
EXT int dbg_redp; /* Set to debug redisplay algorithms */
#endif /*IMAGEN*/
extern int errno;
/* V7 routines for setexit/reset emulation */
#if !(V6)
#include <setjmp.h>
EXT jmp_buf env_main;
#define setexit(a) setjmp(env_main)
#define reset(a) longjmp(env_main,a)
#endif /*-V6*/
/* Declare functions returning CHROFF values (offsets into a buffer) */
extern chroff e_dot(),e_nldot(),e_pldot(),e_boldot(),e_eoldot(),
e_alldot(),ex_boldot(),ex_alldot(),
ex_blen(),e_blen(),ex_dot(),e_wdot();
extern SBSTR *e_copyn();
/* Some other commonly needed declarations */
extern char *memalloc(), *ask(), *dottoa(), *strdup();
#if !(V6)
extern char *getenv();
#endif /*-V6*/
#include "eeproto.h" /* function prototypes */

File diff suppressed because it is too large Load diff

View file

@ -1,281 +0,0 @@
/* SB - Copyright 1982 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author. In all cases
* the source code and any modifications thereto must remain
* available to any user.
*
* This is part of the SB library package.
* Any software using the SB library must likewise be made
* quasi-public, with freely available sources.
*/
#ifdef COMMENT
The initials "SB" stand for "String Block" or "String Buffer".
SBBUFFER - A SB buffer containing a sbstring opened for editing.
SBFILE - A structure holding file-specific information for all
SDBLKs pointing to that file.
SBSTRING - A SB string; conceptually a single string, but actually
a linked list of SDBLKs. Unless opened by a SBBUFFER,
only a few operations are allowed on SBSTRINGs (creating,
copying, deleting).
SDBLK - One of the linked nodes constituting a sbstring. Each SDBLK
node points to a continuous string either in memory or
on disk, or both.
SBLK - Another name for SDBLK.
SMBLK - An allocated chunk of memory. Also refers to the node structure
maintained by the SBM memory management routines, which
points to the actual chunk of memory.
SBM - Name of the memory management package. SBM routines are used
to allocate memory in general, and are not just for
use by SB routines.
************ MACHINE DEPENDENT DEFINITIONS **********
The following compile time definitions represent machine
dependent parameters which are intended mainly for use only by SBM and
SBSTR routines. Other programs should use them with caution. Note
that a great deal of code assumes that type "int" corresponds to a basic
machine word (as per C Reference Manual).
The current definitions will only work for machines which have
1, 2, 4, or 8 "char" bytes in a machine word. Any other size will
require some changes to the definitions and possibly to some places
using them.
WORD - integer-type definition corresponding to machine word.
WDSIZE - # addressable char bytes in a machine word. (1, 2, 4, 8)
WDBITS - # low order bits in an address, ie log2(WDSIZE). (0, 1, 2, 3)
WDMASK - Mask for low order bits of address (0, 1, 3, 7)
CHAR_MASK - If defined, machine does sign-extension on chars, and
they must be masked with this value.
Note that the macro for WDBITS has no mathematical significance
other than being an expression which happens to evaluate into the right
constant for the 4 allowed values of WDSIZE, and in fact it is this
crock which restricts WDSIZE! If C had a base 2 logarithm expression
then any power of 2 could be used.
Values for machines
WORD WDSIZE WDBITS WDMASK
PDP11, Z8000, I8086 int 2 1 01
VAX11, M68000, PDP10 int 4 2 03
#endif /* COMMENT */
/* First try to define a few things in a semi-portable way
*/
#include "eesite.h"
#ifdef __STDC__ /* Implementation supports ANSI stuff? */
#include <limits.h> /* Get sizes for char stuff */
#define _SBMUCHAR 1 /* Can use "unsigned char" */
#define _SBMCHARSIGN (CHAR_MIN < 0) /* True if "char" is sign-extended */
#define CHAR_MASK (UCHAR_MAX)
#else /* not ANSI */
#ifndef _SBMUCHAR /* Default assumes no "unsigned char" */
#define _SBMUCHAR 0
#endif
#ifndef _SBMCHARSIGN /* Default assumes "char" is sign-extended */
#define _SBMCHARSIGN 1
#endif
#ifndef CHAR_MASK /* Default assumes "char" is 8 bits */
#define CHAR_MASK 0377
#endif
#endif /* not ANSI */
/* Define "sb_uchartoint" as a macro which ensures that an unsigned
** character value is converted properly to an int value.
*/
#if (_SBMUCHAR || (_SBMCHARSIGN==0))
#define sb_uchartoint(a) (a) /* No fear of sign extension */
#else
#define sb_uchartoint(a) ((a)&CHAR_MASK) /* Bah, sign extension */
#endif
/* Defs for machines with a base-2 WDSIZE. Yes, the (int) is indeed necessary
* (to allow implicit conversion to long where needed - the PDP11 compiler
* is known to lose without it, because sizeof is cast as "unsigned int"
* which loses big in long masks!)
*/
#define WORD int
#define WDSIZE ((int)(sizeof(WORD)))
#define WDMASK (WDSIZE-1)
#define WDBITS ((WDSIZE>>2)+(1&WDMASK))
#define rnddiv(a) ((a)>>WDBITS) /* # words, rounded down */
#define rndrem(a) ((a)&WDMASK) /* # bytes remaining past wd bndary */
#define rnddwn(a) ((a)&~WDMASK) /* Round down to word boundary */
#define rndup(a) rnddwn((a)+WDSIZE-1) /* Round up to word boundary */
#ifdef COMMENT /* The following are for machines without a base-2 WDSIZE */
#define rnddiv(a) ((a)/WDSIZE)
#define rndrem(a) ((a)%WDSIZE)
#define rnddwn(a) ((a)-rndrem(a))
#define rndup(a) rnddwn((a)+WDSIZE-1)
#undef WDMASK /* These become meaningless and anything */
#undef WDBITS /* which uses them should be changed! */
#endif /* COMMENT */
/* The following 3 definitions are somewhat machine-dependent,
* but are specifically intended for general use and work for all
* currently known C implementations.
* SBMO must be an integer-type object large enough to hold
* the largest difference in SBMA pointers, and must not be
* used in signed comparisons.
*/
typedef long chroff; /* CHROFF - Char offset in disk/sbstr */
typedef unsigned int SBMO; /* SBMO - Char offset in memory */
typedef
#if _SBMUCHAR
unsigned
#endif
char *SBMA; /* SBMA - Pointer to char loc in memory */
/* The following definitions tend to be system-dependent. Only the
* SBM and SBSTR routines use them.
*/
#define SB_NFILES 32 /* # of open files we can hack. Actually
* this is max FD value plus 1. */
#define SB_BUFSIZ 512 /* Optimal buffer size (system block size) */
#define SB_SLOP (16*WDSIZE) /* # slop chars to tolerate for allocations */
#define SMNODES (20) /* # SM or SD nodes to create when needed */
#define SMCHUNKSIZ (16*512) /* # bytes of mem to create (via sbrk) " " */
#define MAXSBMO ((SBMO)-1) /* Used in SBM only */
/* MAXSBMO should be the largest possible SBMO value. */
#define EOF (-1)
#define SBFILE struct sbfile
#define SBBUF struct sbbuffer
#define SBSTR struct sdblk /* Start of a sbstring */
struct sbfile {
int sfflags; /* Various flags */
int sffd; /* FD for file (-1 if none) */
struct sdblk *sfptr1; /* Ptr to 1st node in phys list */
chroff sflen; /* Original length of file FD is for */
};
/* Definition of SBBUF string/buffer */
struct sbbuffer {
SBMA sbiop; /* I/O pointer into in-core text */
int sbrleft; /* # chars left for reading */
int sbwleft; /* # chars left for writing */
int sbflags; /* Various flags */
chroff sbdot; /* Logical pos for start of current sdblk */
chroff sboff; /* Offset into current sdblk (if no smblk)*/
struct sdblk *sbcur; /* Pointer to current SD block of string */
};
/* Flags for "sbflags" */
#define SB_OVW 01 /* Over-write mode */
#define SB_WRIT 02 /* Written; smuse needs to be updated from sbiop */
/* NOTE: An unused sbbuf structure should be completely zeroed.
* This will cause routines to handle it properly
* if they are accidentally pointed at it.
*/
/* Definition of SDBLK */
struct sdblk {
struct sdblk *slforw; /* Logical sequence forward link */
struct sdblk *slback; /* Logical sequence backward link */
int sdflags;
struct sdblk *sdforw; /* Physical sequence (disk) */
struct sdblk *sdback; /* ditto - backptr for easy flushing */
struct smblk *sdmem; /* Mem pointer, 0 if no in-core version */
SBFILE *sdfile; /* File pointer, 0 if no disk version */
chroff sdlen; /* # chars in disk text */
chroff sdaddr; /* Disk address of text */
};
/* Flags for "sdflags" */
#define SD_LOCK 0100000 /* Locked because opened by a SBBUF */
#define SD_LCK2 0040000 /* Locked for other reasons */
#define SD_MOD 0020000 /* Modified, mem blk is real stuff */
#define SD_NID 0323 /* Node ID marks active (not on freelist) */
#define SD_LOCKS (SD_LOCK|SD_LCK2)
/* Note sdback is ONLY needed for fixing up phys list when a sdblk is
* deleted (so as to find previous blk in phys list). Perhaps it shd
* be flushed (ie only use SDFORW)? How to do deletions - use circular
* list? Sigh.
*/
/* Definition of SMBLK (used by SBM routines) */
struct smblk {
struct smblk *smforw; /* Links to other mem blks, in phys order */
struct smblk *smback;
int smflags; /* Type, in-use flags */
SBMA smaddr; /* Mem address of text */
SBMO smlen; /* # bytes in mem block */
SBMO smuse; /* # bytes "used" in block */
};
/* Flags for "smflags" */
#define SM_USE 0100000 /* Block is in use (mem free if off) */
#define SM_NXM 040000 /* Block mem is non-existent */
#define SM_EXT 020000 /* Block mem owned by external (non-SBM) rtn*/
#define SM_MNODS 010000 /* Block holds SMBLK nodes */
#define SM_DNODS 04000 /* Block holds SDBLK nodes */
#define SM_NID 0315 /* Node in-use identifier (low byte) */
/* Error handler type values */
#define SBMERR 0 /* Error in SBM package */
#define SBXERR 1 /* Error in SBSTR package */
#define SBFERR 2 /* "Error" - SBSTR package found a file overwritten.
* Non-zero return will continue normally. */
/* Redefine certain external symbols to be unique in the first 6 chars
** to conform with ANSI requirements.
*/
#define sbm_nfre sbmnfre /* SBM stuff */
#define sbm_nfor sbmnfor
#define sbm_nmov sbmnmov
#define sbm_ngc sbmngc
#define sbx_ndget sbxndg /* SBSTR stuff */
#define sbx_ndel sbxnde
#define sbx_ndfre sbxndf
#define sbx_sdcpy sbxsdc
#define sbx_sdgc sbxsdg
#define sbe_sdlist sbesls /* SBERR stuff */
#define sbe_sdtab sbestb
#define sbe_sds sbesds
#define sbe_sbvfy sbesbv
#define sbe_sbs sbesbs
/* Forward declarations */
extern SBMA sbm_lowaddr; /* For roundoff purposes */
extern SBFILE sbv_tf; /* SBFILE for temp swapout file */
extern int (*sbv_debug)(); /* Error handler address */
extern off_t lseek(); /* For sbstr code mostly */
extern char *mktemp();
extern char *malloc();
extern char *calloc();
extern SBBUF *sb_open();
extern SBSTR *sb_close(), *sb_fduse(), *sbs_cpy(), *sbs_app(), *sb_cpyn(),
*sb_killn();
extern struct sdblk *sbx_ready();
extern chroff sb_tell(), sb_ztell(), sbs_len();
/* Definition of SB_GETC, SB_PUTC, SB_BACKC macros */
#define sb_putc(s,c) (--((s)->sbwleft) >= 0 ? \
(*(s)->sbiop++ = c) : sb_sputc(s,c))
#define sb_getc(s) (--((s)->sbrleft) >= 0 ? \
sb_uchartoint(*(s)->sbiop++) : sb_sgetc(s))
#define sb_peekc(s) ((s)->sbrleft > 0 ? \
sb_uchartoint(*(s)->sbiop) : sb_speekc(s))
/* WARNING - sb_backc must ONLY be used if last operation was a
* successful sb_getc!! For slow but sure invocation use sb_rgetc.
*/
#define sb_backc(s) (++(s->sbrleft), --(s->sbiop))
#include "sbproto.h" /* function prototypes */

View file

@ -1,54 +0,0 @@
#include "sb.h"
/* BCOPY(from,to,cnt) - Copy string of bytes.
* Normally this routine is an assembly-language library routine,
* but not all systems have it. Hence this C-language version
* which tries to be fairly machine-independent.
* Attempts to be clever about using word moves instead of byte moves.
* Does not hack overlapping backward moves.
*/
bcopy(from, to, cnt) /* Copy count bytes from -> to */
register SBMA from;
register SBMA to;
register unsigned cnt;
{
if(!cnt)
return;
while(rndrem((int)from)) /* Get source aligned */
{ *to++ = *from++;
if(--cnt == 0) return;
}
if(rndrem((int)to) == 0) /* Do word move if dest now aligned */
{ register unsigned tmp;
tmp = cnt;
if((cnt = rnddiv(cnt)) > 4)
{ sbm_wcpy((int *)from, (int *)to, cnt);
if((cnt = rndrem(tmp)) == 0)
return; /* No leftover bytes, all done */
tmp -= cnt; /* Ugh, must update pointers */
from += tmp;
to += tmp;
}
else cnt = tmp; /* Not worth call overhead */
}
do { *to++ = *from++; } /* Finish up with byte loop */
while(--cnt);
}
/* SBM_WCPY - word-move auxiliary routine.
* This is a separate routine so that machines with only a few
* registers have a chance to use them for the word copy loop.
* This cannot be made part of BCOPY without doing some
* unnecessary pointer conversions and using extra variables
* (since most compilers will not accept type casts on lvalues,
* which are needed to treat (char *) as (int *)).
*/
sbm_wcpy(from, to, cnt)
register int *from, *to;
register unsigned cnt;
{
if(cnt)
do { *to++ = *from++; }
while(--cnt);
}

View file

@ -1,678 +0,0 @@
/* SB - Copyright 1982 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author. In all cases
* the source code and any modifications thereto must remain
* available to any user.
*
* This is part of the SB library package.
* Any software using the SB library must likewise be made
* quasi-public, with freely available sources.
*/
#define PRINT /* Include printout stuff */
#include "sb.h"
#include <stdio.h>
extern struct smblk *sbm_nfl;
extern struct smblk *sbm_list;
extern struct sdblk *sbx_nfl;
#ifdef PRINT
#define PRF(stmt) {if(p) stmt;}
#define PRFBUG(str,stmt) {if(p) stmt;else return(str);}
#define PRFBAD(str,stmt) {if(p) stmt; return(str);}
#else
#define PRF(stmt) ;
#define PRFBUG(str,stmt) return(str);
#define PRFBAD(str,stmt) return(str);
#endif
#ifndef NPTRS
#define NPTRS (1000) /* Catch loops of period less than this. */
#endif
int sbe_dec = 0; /* Set nonzero to use decimal printout */
struct ptab {
int pt_pflag; /* Printflag value */
char *pt_err; /* Error string return */
int pt_xerr; /* Error index return */
int pt_hidx; /* Highest freelist entry */
int pt_nsto; /* # entries stored in table */
int pt_cnt; /* # of entry store attempts */
struct smblk *pt_tab[NPTRS];
};
_PROTOTYPE( char *sbe_sdtab, (struct ptab *pt, int p, int phys) );
_PROTOTYPE( char *sbe_schk, (struct sdblk *sd, struct ptab *pt) );
_PROTOTYPE( int sbe_tbent, (struct ptab *pt, struct smblk *sm) );
#define PTF_PRF 01 /* Do printout stuff */
#define PTF_OVFERR 02 /* Complain if table overflows */
#define PTF_SDPHYS 04 /* Follow SD phys links (else logical links) */
struct flgt {
int flg_bit;
int flg_chr;
};
_PROTOTYPE( char *sbe_fstr, (int flags, struct flgt *fp) );
char *sbe_mvfy(), *sbe_mfl(), *sbe_mlst(); /* SBM */
char *sbe_sbvfy(), *sbe_sbs(); /* SBBUF */
char *sbe_svfy(), *sbe_sdlist(), *sbe_sdtab(), *sbe_schk(); /* SD */
char *sbe_fstr(); /* Misc utility */
/* SBE_MEM() - Print out memory usage list
*/
sbe_mem()
{
printf("\nMemory Usage:\n");
printf("\tsbm_nfl : %6o\n",sbm_nfl);
printf("\tsbm_list: %6o\n",sbm_list);
printf("\tsmblk nodes are %o bytes long.\n",sizeof (struct smblk));
sbe_mlst(1); /* Scan mem list, printing stuff. */
}
/* SBE_MVFY() - Verify memory allocation structures
* Returns error message (0 if no errors found).
*/
char *
sbe_mvfy()
{ register char *res;
if((res = sbe_mfl(0))
|| (res = sbe_mlst(0)))
return(res);
return(0);
}
/* SBM Debugging Routines */
struct flgt smflgtab[] = {
SM_USE, 'U',
SM_NXM, 'N',
SM_EXT, 'E',
SM_MNODS,'M',
SM_DNODS,'D',
0,0
};
static char smfhelp[] = "U-Used, N-NXM, E-External, M-SMnodes, D-SDnodes";
static char smhdline[] = "\
SM: back smaddr smlen smuse smflags";
/* SBE_MFL(printflag) - Verify/Print memory freelist
* Returns error message (0 if no errors found).
*/
char *
sbe_mfl(p)
int p;
{ register struct smblk *sm;
register int i;
struct ptab smtab; /* For loop detection */
PRF(printf("Tracing SM node freelist --\n"))
PRF(printf(" Maximum loop detection size is %d.", NPTRS))
if((sm = sbm_nfl) == 0)
{ PRF(printf("\n\tNo list.\n"))
return(0); /* Null freelist is ok */
}
smtab.pt_pflag = p ? PTF_PRF : 0;
smtab.pt_nsto = smtab.pt_cnt = 0;
i = 0; /* Print 8 addrs/line */
for(; sm; sm = sm->smforw)
{
PRF(printf("%s%7o->", (i==0 ? "\n " : ""), sm))
if(++i >= 8) i = 0;
if(sbe_tbent(&smtab, sm) < 0) /* If hit loop, stop */
PRFBAD("SM freelist loop",
printf("\nLOOP - %o seen as node %d!!\n",
sm, smtab.pt_xerr))
if(sm->smflags)
{ PRF((i = 0, printf("\nFreelist node has flags:\n")))
PRFBUG("Free SM flagged", sbe_smp(sm, 0))
}
}
PRF(printf("\nEnd - %d nodes on SM freelist.\n", smtab.pt_cnt))
return(0);
}
/* SBE_MLST(printflag) - Verify/Print allocated memory list.
* Returns error message (0 if no errors found).
*/
char *
sbe_mlst(p)
int p;
{ register struct smblk *sm, *smf, *smb;
char *nextaddr = NULL;
int i;
struct ptab smtab; /* For loop detection */
PRF(printf("Tracing mem list -- \n"))
if((sm = sbm_list) == 0)
{ PRF(printf("\tNo list?!\n"))
if(sbm_nfl) /* Ensure rest are 0 too */
return("No mem list?!!");
return(0);
}
smtab.pt_pflag = p;
smtab.pt_cnt = smtab.pt_nsto = 0;
smb = 0;
PRF(printf(" Flags: %s\n%s\n", smfhelp, smhdline))
for(; sm; sm = smf)
{ PRF(printf(" %6o: ",sm))
if(sbe_tbent(&smtab, sm) < 0)
PRFBAD("Loop in mem list!!",
printf("LOOP - seen as node %d!!\n", smtab.pt_xerr))
if(sm->smback == smb)
PRF(printf("^ ")) /* Back ptr OK */
else PRFBUG("Bad back ptr!",
printf("%6o BAD Backptr!!\n\t ",sm->smback))
if((sm->smflags&0377)!= SM_NID)
PRFBUG("SM: bad node ID",
printf("BAD - no node ID!\n\t "))
PRF(printf((sm->smflags&SM_USE) ? " " : "FREE "))
if(sm->smlen == 0)
PRFBUG("SM: len 0",
printf("Zero-length area!"))
if((sm->smflags&SM_USE)==0
&& rndrem(sm->smaddr - sbm_lowaddr))
PRFBUG("Bad free-mem block",
printf("Bad free-mem block"))
PRF(sbe_smp(sm, 1)) /* Print out rest of info */
if(nextaddr != sm->smaddr
&& smtab.pt_cnt != 1) /* 1st time needs init */
{ PRFBUG("Alignment error!",
printf("\t BAD!! %6o expected; ",nextaddr))
#if !(MINIX)
PRF((i = sm->smaddr - nextaddr) > 0
? printf("%d skipped.\n",i)
: printf("%d overlapped.\n",-i))
#endif
}
nextaddr = sm->smaddr + sm->smlen;
smf = sm->smforw;
smb = sm; /* Save ptr to back */
}
PRF(printf("End = %6o\n",nextaddr))
return(0);
}
#ifdef PRINT
sbe_smp(sm,type)
register struct smblk *sm;
int type;
{
if(type==0)
printf(" %6o: %s ", sm,
((sm->smflags&SM_USE) ? " " : "FREE"));
printf("%6o: ", sm->smaddr);
printf((sbe_dec ? "%5d. %5d." : "%6o %6o"), sm->smlen, sm->smuse);
printf(" %7o = %s\n", sm->smflags, sbe_fstr(sm->smflags, smflgtab));
}
#endif /*PRINT*/
/* SD (SBSTR) debugging routines */
struct flgt sdflgtab[] = {
SD_LOCK, 'L',
SD_LCK2, 'T',
SD_MOD, '*',
0,0
};
static char sdfhelp[] = "\
<f> flags: *-MOD (disk outofdate), L-LOCK, T-LCK2 (temp)";
static char sdhdline[] = "\
<f> SD: slforw slback sdflgs sdforw sdback sdmem sdfile sdaddr sdlen";
/* SBE_SFL(printflag) - Verify/Print SD freelist
* Returns error message (0 if no errors found).
*/
char *
sbe_sfl(p)
int p;
{ register struct sdblk *sd;
register int i;
struct ptab sdtab; /* For loop detection */
PRF(printf("Tracing SDBLK node freelist --\n"))
PRF(printf(" Maximum loop detection size is %d.", NPTRS))
if((sd = sbx_nfl) == 0)
{ PRF(printf("\n\tNo list.\n"))
return(0); /* Null freelist is ok */
}
sdtab.pt_pflag = p ? PTF_PRF : 0;
sdtab.pt_nsto = sdtab.pt_cnt = 0;
i = 0; /* Print 8 addrs/line */
for(; sd; sd = sd->slforw)
{
PRF(printf("%s%7o->", (i==0 ? "\n " : ""), sd))
if(++i >= 8) i = 0;
if(sbe_tbent(&sdtab, sd) < 0) /* If hit loop, stop */
PRFBAD("SD freelist loop",
printf("\nLOOP - %o seen as node %d!!",
sd, sdtab.pt_xerr))
if(sd->sdflags)
{ PRF((i = 0, printf("\nFreelist node has flags:\n")))
PRFBUG("Free SD flagged", sbe_psd(sd))
}
}
PRF(printf("\nEnd - %d nodes on SD freelist.\n", sdtab.pt_cnt))
return(0);
}
/* SBE_SDS() - Print out all sdblk data stuff
*/
sbe_sds()
{ int sbe_psd();
printf("Printout of all in-use SDBLKs:\n");
printf(" %s\n", sdfhelp);
printf("%s\n", sdhdline);
sbm_nfor(SM_DNODS,sizeof(struct sdblk),sbe_psd,0);
printf("\n");
}
/* SBE_PSD - Auxiliary for invocation by SBE_SDS above. */
sbe_psd(sd)
register struct sdblk *sd;
{ register int flags;
flags = sd->sdflags;
printf("%c%c%c",
((flags&SD_MOD) ? '*' : ' '),
((flags&SD_LOCK) ? 'L' : ' '),
((flags&SD_LCK2) ? 'T' : ' '));
printf(" %7o: %6o %6o %6o %6o %6o %6o %6o %7lo %5ld.\n", sd,
sd->slforw, sd->slback, sd->sdflags,
sd->sdforw, sd->sdback, sd->sdmem,
sd->sdfile, sd->sdaddr, sd->sdlen);
return(0);
}
/* SBE_SVFY() - Verify all SD blocks
* Returns error message (0 if no errors found).
*/
char *
sbe_svfy()
{ register char *res;
return((res = sbe_sdlist(0,0)) ? res : sbe_sdlist(0,1));
}
/* SBE_SDLIST(printflag, physflag) - Verify/Print all SD blocks.
* Show logical lists if physflag 0
* Show physical lists otherwise
* Returns error message (0 if no errors found).
*/
char *
sbe_sdlist(p,phys)
int p, phys;
{ register char *res;
struct ptab sdtab; /* The SDLIST table to use */
/* First put freelist in table, then scan for all
* SD nodes. Each active node (not in table) gets
* its entire list traced forward/backward and added to table.
*/
if(res = sbe_sdtab(&sdtab, p, phys)) /* Set up freelist table */
return(res);
/* Freelist entered in table, now scan all SD's */
res = (char *)sbm_nfor(SM_DNODS,sizeof(struct sdblk),
sbe_schk, &sdtab);
PRF(printf("\n"))
return(res);
}
/* SBE_SDTAB(tableptr, printflag, physflag) - Auxiliary for SBE_SDLIST.
* Stuffs all freelist SDBLK addresses in table for dup detection.
* Returns error message (0 if no errors found).
*/
char *
sbe_sdtab(pt, p, phys)
register struct ptab *pt;
int p, phys;
{ register struct sdblk *sd;
pt->pt_pflag = (p ? PTF_PRF : 0) | (phys ? PTF_SDPHYS : 0)
| PTF_OVFERR;
pt->pt_cnt = pt->pt_nsto = 0; /* Initialize */
/* Stick freelist in table */
for(sd = sbx_nfl; sd; sd = sd->slforw)
{ if(sbe_tbent(pt, sd) < 0)
{ if(pt->pt_xerr < 0)
PRFBAD("SD freelist too long",
printf("SD freelist too long (%d)\n",
NPTRS))
PRFBAD("SD freelist loop",
printf("SD freelist loop at %o\n", pt->pt_xerr))
}
if(sd->sdflags)
{
PRF(printf("Bad free SD, non-zero flag:\n"))
PRFBUG("Free SD flagged", sbe_psd(sd))
}
}
pt->pt_hidx = pt->pt_nsto; /* Set idx of 1st non-FL entry */
return(0);
}
/* SBE_SCHK(SDptr, tableptr) - Auxiliary for SBE_SDLIST.
* If SD not already in table, verifies or prints
* the complete physical or logical list it's on, and enters all
* of its SDs into table (to prevent doing it again).
* Returns 0 if no errors, else error string.
** There is a problem when the table overflows. The tbent routine
** wants to add it (wrapping around at bottom) in that case, because
** that still helps detect loops. But this routine wants to reset
** the table back (after scanning to head of list) and once it starts
** scanning forward again it will fail, because some of the SDs are
** still in the table due to the wraparound! Thus PTF_OVFERR is always
** set, in order to at least give the right error message.
*/
char *
sbe_schk(sd, pt)
register struct sdblk *sd;
struct ptab *pt;
{ register struct sdblk *sdx;
register struct smblk *sm;
struct sbfile *savfile;
chroff lastaddr;
int p, savidx, phys;
phys = pt->pt_pflag&PTF_SDPHYS; /* Set up physflag */
if(phys && (sd->sdfile == 0)) /* Ignore non-phys stuff if phys */
return(0);
p = pt->pt_pflag&PTF_PRF; /* Set up printflag */
savidx = pt->pt_nsto; /* Remember initial extent of table */
if(sbe_tbent(pt, sd) < 0)
{ if(pt->pt_xerr >= 0) /* OK if already in table */
return(0);
PRFBAD("Too many SDs",
printf("Too many SDs for table (%d)\n", NPTRS))
}
/* Now search backward for start of list */
while(sdx = (phys ? sd->sdback : sd->slback))
if(sbe_tbent(pt,sdx) >= 0)
sd = sdx;
else break;
if(sdx)
{ if(pt->pt_xerr < 0) /* Table error? */
PRFBAD("Too many SDs",
printf("Too many SDs for table (%d)\n",NPTRS))
PRF(printf("Backlist loop!! Dup'd node:%s\n",
(pt->pt_xerr < pt->pt_hidx) ?
"(on freelist!)" : "" ))
PRFBUG((phys ? "Phys SD loop" : "SD loop"), sbe_psd(sdx))
}
/* Reset table to flush nodes backed over */
pt->pt_cnt = pt->pt_nsto = savidx;
/* SD now points to start of list. Begin stepping thru list... */
PRF(printf("---- %sList started: ", (phys ? "Phys " : "")))
if(phys)
{ savfile = sd->sdfile;
PRF(printf(" SF: %o, fd= %d, ln= %ld\n",
savfile,savfile->sffd,savfile->sflen))
if(savfile->sfptr1 != sd)
PRFBUG("SFPTR1 bad",
printf(" BAD!! Sfptr1 %o doesn't match SD %o!!\n",
savfile->sfptr1, sd))
lastaddr = 0;
}
else PRF(printf("\n"))
PRF(printf("%s\n", sdhdline))
for(sdx = 0; sd; (sdx = sd, sd = (phys ? sd->sdforw : sd->slforw)))
{
PRF(sbe_psd(sd)) /* Print it out */
if(sdx != (phys ? sd->sdback : sd->slback))
{ if(phys)
PRFBUG("PSD bad sdback",printf("\tBad phys backptr\n"))
else
PRFBUG("SD bad slback",printf("\tBad backptr\n"))
}
if((sd->sdflags&0377) != SD_NID)
PRFBUG("Bad SD node ID", printf("\tBad node ID!\n"))
if(sd->sdfile && (sd->sdlen < 0 || sd->sdaddr < 0))
PRFBUG("SD: neg len/addr",
printf("\tNeg disk len/addr\n"))
if(phys) goto dophys;
/* Do special stuff for logical list */
if(sm = sd->sdmem)
{ if((sm->smflags&0377) != SM_NID)
PRFBUG("SD: bad SM",
printf("\nBad SMBLK ptr\n"))
if((sd->sdflags&SD_MOD)==0
&& sd->sdlen != sm->smuse)
PRFBUG("SD != SM",
printf("\tBad SMBLK? Len conflict\n"))
if(sm->smlen < sm->smuse)
PRFBUG("SD: SM len < use",
printf("\tBad SMBLK, len < use\n"))
}
goto doboth; /* Skip phys stuff */
/* Do special stuff for phys list */
dophys: if(sd->sdfile != savfile)
PRFBUG("SD: bad sdfile",
printf("\tBad sdfile ptr! Shd be %o\n",
savfile))
if(sd->sdaddr < lastaddr)
PRFBUG("SD addr out of order",
printf("\tBad disk addr, not in order!\n"))
lastaddr = sd->sdaddr;
/* Done with special phys stuff */
doboth: if(sbe_tbent(pt, sd) < 0)
{ if(pt->pt_xerr < 0)
PRFBAD("Too many SDs",
printf("Too many SDs for table (%d)\n",NPTRS))
PRFBUG("SD loop",
printf("\tLOOP!! This SD already seen%s.\n",
(pt->pt_xerr < pt->pt_hidx) ?
" (on freelist!)" : "" ))
break;
}
}
PRF(printf("-----------\n"))
return(0);
}
/* SBE_DSK(SFptr) - Print out disk usage list for specific file
*/
sbe_dsk(sfp)
SBFILE *sfp;
{
printf("SBFILE printout not coded: %o\n",sfp);
}
/* SBBUF structure debugging routines */
struct flgt sbflgtab[] = {
SB_OVW, 'O',
SB_WRIT,'W',
0,0
};
static char sbfhelp[] = "O-Overwrite, W-Write";
/* SBE_SBVFY(SBptr) - Verify a SB-string.
* Returns error message (0 if no errors found).
*/
char *
sbe_sbvfy(sbp)
SBBUF *sbp;
{ return(sbe_sbs(sbp,0));
}
/* SBE_SBS(SBptr, printflag) - Verify/Print SBSTR data stuff
* Returns error message (0 if no errors found).
*/
char *
sbe_sbs(sbp,p)
SBBUF *sbp;
int p;
{ register SBBUF *sb;
register struct smblk *sm;
register struct sdblk *sd;
sb = sbp;
PRF(printf("SBSTR %o: ",sb))
if(sb == 0)
PRFBUG(0,printf("Zero pointer???\n"))
/* First print out cryptic summary in case pointers bomb
* out farther on. */
PRF(printf(" (io,cur,r,w,f,.,+ = %o,%o,%d,%d,%o,%lo,%lo)\n",
sb->sbiop, sb->sbcur, sb->sbrleft, sb->sbwleft,
sb->sbflags, sb->sbdot, sb->sboff))
PRF(printf(" sbflags %5o = %s (%s)\n",
sb->sbflags, sbe_fstr(sb->sbflags,sbflgtab),
sbfhelp))
if(sd = sb->sbcur) /* Okay, now try getting pointers */
sm = sd->sdmem;
else sm = 0;
PRF(printf(" sbcur %6o",sd))
if(sd)
{
PRF(printf("\n %s\n ", sdhdline))
PRF(sbe_psd(sd))
if((sd->sdflags&0377) != SD_NID)
PRFBUG("SBCUR not SD?",printf(" BAD SDBLK ID!! \n"))
if(sm)
{
PRF(printf(" %s\n ", smhdline))
PRF(sbe_smp(sm,0))
if((sm->smflags&0377) != SM_NID)
PRFBUG("SBCUR has bad SM",
printf(" BAD SMBLK ID!!\n"))
}
}
PRF(printf(" sbiop %6o",sb->sbiop))
if(sb->sbiop)
{ if(!sm || sb->sbiop < sm->smaddr
|| sb->sbiop > (sm->smaddr + sm->smlen))
PRFBUG("Bad SBIOP", printf(" BAD"))
}
else if(sb->sbrleft > 0 || sb->sbwleft > 0)
PRFBUG("Bad SBIOP/cnts", printf(" BAD"))
PRF(printf("\n"))
PRF(printf(" sbrleft %5o = %5d.",sb->sbrleft, sb->sbrleft))
if(sb->sbrleft
&& ( !sm
|| sb->sbwleft
|| (sb->sbflags&SB_WRIT)
|| (sb->sbrleft != (sm->smuse - (sb->sbiop - sm->smaddr)))
))
PRFBUG("Bad sbrleft", printf(" BAD"))
PRF(printf("\n"))
PRF(printf(" sbwleft %5o = %5d.", sb->sbwleft, sb->sbwleft))
if(sb->sbwleft
&& ( !sm
|| (sb->sbflags&SB_WRIT) == 0
|| (sb->sbwleft > (sm->smlen - (sb->sbiop - sm->smaddr)))
))
PRFBUG("Bad sbwleft", printf(" BAD"))
PRF(printf("\n"))
PRF(printf(" sbdot %7lo = %7ld.", sb->sbdot, sb->sbdot))
if(sb->sbdot < 0)
PRFBUG("Bad sbdot", printf(" BAD"))
PRF(printf("\n sboff %7lo = %7ld.\n", sb->sboff, sb->sboff))
PRF(printf(" I/O ptr loc: %ld.\n\n", sb_tell(sb)))
return(0);
}
/* SBE_TBENT() - Auxiliary to add and check entries to a pointer table.
* Note we assume here that smblk ptrs are used, although sdblks
* can also be hacked. This wins as long as the two kinds of ptrs
* are basically identical (saves horrible casting problems).
* Returns index # if successful (between 0 and NPTRS-1 inclusive).
* Otherwise an error (-1), with relevant info in pt_xerr:
* -1 if out of room and flag set making it an error
* 0-n if entry already existed.
*/
sbe_tbent(pt, sm)
register struct ptab *pt;
struct smblk *sm;
{ register struct smblk **smt;
register int i;
int p;
p = pt->pt_pflag&PTF_PRF; /* Set up print flag */
smt = &(pt->pt_tab[0]);
if(i = pt->pt_nsto)
{ do {
if(sm == *smt++)
{ pt->pt_xerr = pt->pt_nsto - i;
return(-1);
}
} while(--i);
--smt;
}
i = pt->pt_cnt++;
if(++(pt->pt_nsto) > NPTRS)
{ if(pt->pt_pflag&PTF_OVFERR)
{ pt->pt_err = "Ptrtab overflow";
pt->pt_xerr = -1;
return(-1);
}
pt->pt_nsto = NPTRS;
i %= NPTRS;
}
pt->pt_tab[i] = sm;
return(i);
}
/* SBE_FSTR(flags, flagtab) - Auxiliary to convert flag word to a string
* and return pointer to it. Handy for printfs.
*/
char *
sbe_fstr(flags, fp)
register int flags;
register struct flgt *fp;
{ static char retstr[17]; /* Max of 16 flags */
register char *cp;
cp = retstr;
for(; fp->flg_bit; ++fp)
*cp++ = (fp->flg_bit&flags) ? fp->flg_chr : ' ';
*cp = 0;
return(retstr);
}

View file

@ -1,925 +0,0 @@
/* SB - Copyright 1982 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author. In all cases
* the source code and any modifications thereto must remain
* available to any user.
*
* This is part of the SB library package.
* Any software using the SB library must likewise be made
* quasi-public, with freely available sources.
*/
#if 0
This file contains the low-level memory allocation
subroutines which are used by the SBLK routines. The code here
is quite machine-dependent, and the definitions in "sb.h" should be
carefully checked to verify that they are correct for the target
machine.
The ultimate low-level routine is "sbrk()" which must be
provided by the system''s C library. SBM expects that successive calls
to sbrk() will return contiguous areas of memory with progressively
higher addresses. Also, the very first call to sbrk() is assumed to
return a word-aligned address.
#endif /*COMMENT*/
#include "sb.h"
#define FUDGE (sizeof(struct smblk)) /* Allow this much fudge in
allocation, to prevent undue fragmentation */
char *(*sbm_debug)(); /* Debug switch - user-furnished routine */
struct smblk *sbm_nfl; /* Pointer to node freelist */
struct smblk *sbm_nxtra; /* Reserved extra free node */
struct smblk *sbm_list; /* Pointer to smblk memory alloc list.
* ALL smblks are strung onto this list
* except for the freelist!
*/
SBMA sbm_lowaddr; /* Lowest word-aligned address we know about.*/
/* If compiling with debug switch set, use special routine in place of
* sbrk so we can pretend we have a very limited area of free memory.
*/
#ifdef DBG_SIZE
#define SBM_SBRK sbm_brk
char *sbm_brk();
#else
#define SBM_SBRK sbrk
#endif /*DBG_SIZE*/
/* Forward routine declarations */
#ifdef __NBSD_LIBC
void *sbrk();
#else
char *sbrk();
#endif
struct smblk *sbm_nmak(), *sbm_nget(), *sbm_mget(), *sbm_split();
struct smblk *sbm_lmak(), *sbm_err();
/* SBM_INIT - Initialize storage management.
* If args are zero, normal initialization is done. Otherwise,
* args are understood to be pointers to an area of memory allocated
* on the stack (eg by an "int mem[2000]" declaration in MAIN) and
* initialization will include this area in addition to the
* unused space between "_end" and the start of the stack segment.
* This is mostly of use for PDP11s which would otherwise waste a lot
* of address space.
* Maybe should have a SBM_RESET() function?
*/
struct smblk *
sbm_init(xaddr,xlen)
SBMA xaddr; /* Address of allocated stack area if any */
SBMO xlen; /* Size of this area */
{ register struct smblk *sm, *sml;
register char *cp;
/* Get initial chunk of memory from standard system rtn */
if((cp = SBM_SBRK(SMNODES*sizeof(struct smblk))) == 0
|| (int) cp == -1)
return(sbm_err(0,"Can't sbrk"));
sm = (struct smblk *)cp; /* Better be word-aligned! */
sbm_lmak(sm,(SBMO)sizeof(struct smblk),SMNODES); /* Make list */
sbm_nfl = sm; /* Point freelist at it */
sbm_lowaddr = (SBMA)sm; /* Remember lowest addr seen */
/* Set up 1st node pointing to all memory from here on up.
* We don't know exactly how much will be available at this point,
* so we just pretend we have the maximum possible.
*/
sbm_list = sml = sbm_nget();
sml->smforw = sml->smback = 0;
sml->smflags = SM_USE|SM_NID; /* Initial flags */
sml->smaddr = (SBMA) sml;
sml->smlen = MAXSBMO; /* Pretend we have lots */
sml->smuse = (SMNODES * sizeof(struct smblk));
/* Now split off everything above initial allocation as NXM. */
sm = sbm_split(sml, sm->smuse);
sml->smflags |= SM_MNODS; /* Mark 1st node as having SM nodes */
sm->smflags |= SM_NXM; /* Mark 2nd node as NXM */
/* Now possibly set up extra nodes, if stack mem is being allocated
* (From our viewpoint it looks as if a chunk in the middle of
* the initial NXM section has been declared usable)
*/
if(xlen)
{ /* Allow for "extra" static stack memory */
/* Will lose if xaddr <= 1st NXM! */
sml = sbm_split(sm, (SBMO)(xaddr - sm->smaddr));
sbm_split(sml, xlen); /* Split off following NXM */
sml->smflags &= ~(SM_USE|SM_NXM); /* This node is free mem! */
}
/* Now set up a small additional node which points to the NXM
* that we cannot get from SBRK. At this stage, this is just
* a place-holder, to reserve the node so we don't have to
* worry about running out of nodes at the same time sbrk stops
* returning memory.
* SM points to the NXM that we expect SBRK to dig into.
*/
sbm_split(sm, sm->smlen - WDSIZE); /* Chop off teensy bit */
sm->smflags &= ~SM_USE; /* Now mark NXM "free"!! */
/* Finally, reserve an "extra" SM node for use by sbm_nget
* when it is allocating more freelist node chunks.
*/
sbm_nxtra = sbm_nget();
return(sbm_list);
}
/* SBM_NGET() - Get a free SM node.
* Note the hair to provide a spare SM node when
* we are allocating memory for more SM nodes. This is necessary
* because sbm_mget and sbm_nget call each other recursively and
* sbm_mget cannot create any new memory without a SM node to point
* at the allocated chunk.
*/
struct smblk *
sbm_nget()
{ register struct smblk *sm, *sml;
if(!(sm = sbm_nfl)) /* Get a node from freelist */
{ /* Freelist is empty, try to allocate more nodes. */
/* Put our "spare" smblk on freelist temporarily so that
* sbm_mget has a chance of winning.
* Infinite recursion is avoided by a test
* in sbm_mget which checks sbm_nfl and sbm_nxtra.
*/
if(!(sm = sbm_nxtra))
return(sbm_err(0,"Zero sbm_nxtra!"));
sm->smforw = 0;
sbm_nfl = sm;
sbm_nxtra = 0;
/* Try to allocate another chunk of SM nodes. */
sml = sbm_nmak(sizeof(struct smblk),SM_MNODS);
/* Put the new free nodes (if any) on freelist.
* Done this way because freelist may have had one or two
* nodes added to it by sbm_mget, so can't just stick
* a new pointer in sbm_nfl.
*/
while(sm = sml)
{ sml = sm->smforw;
sbm_nfre(sm);
}
/* Now reserve an extra node again.
* It is an error if there is nothing on freelist here,
* because even if sbm_mget failed the "extra node" should
* still be on freelist. The check for a zero sbm_nxtra
* above will catch such an error.
*/
sbm_nxtra = sbm_nget();
/* Now see if anything to return */
if(!(sm = sbm_nfl)) /* If freelist empty again, */
return(0); /* give up. */
}
sbm_nfl = sm->smforw; /* If win, take it off freelist */
return(sm); /* Return ptr or 0 if none */
}
/* SBM_NFRE(sm) - Return a SM node to the SM freelist.
*/
sbm_nfre(smp)
struct smblk *smp;
{ register struct smblk *sm;
(sm = smp)->smflags = 0;
sm->smforw = sbm_nfl;
sbm_nfl = sm;
}
/* SBM_NMAK(elsize, flag) - Make (allocate & build) a typeless node freelist.
*/
struct smblk *
sbm_nmak(elsize, flag)
SBMO elsize;
unsigned flag;
{ register struct smblk *sm, *smp;
register int cnt;
if((sm = sbm_mget(SMNODES*elsize,SMNODES*elsize)) == 0)
return(0);
sm->smflags |= flag; /* Indicate type of nodes */
cnt = sm->smlen/elsize; /* Find # nodes that will fit */
sm->smuse = cnt * elsize; /* Actual size used */
smp = (struct smblk *)(sm->smaddr); /* Ptr to 1st loc of mem */
sbm_lmak(smp, (SBMO)elsize, cnt); /* Build freelist */
return(smp); /* Return 1st free node. Caller is */
/* responsible for setting freelist ptr. */
}
/* SBM_LMAK - Build freelist of typeless nodes.
* Note this does not allocate memory, it just converts an already
* allocated memory area.
*/
struct smblk *
sbm_lmak(addr, elsize, num)
SBMA addr;
SBMO elsize;
int num;
{ register struct smblk *sm, *smp;
register int cnt;
smp = (struct smblk *) addr;
if((cnt = num) <= 0)
return(0);
do { sm = smp; /* Save ptr */
sm->smforw = (smp = (struct smblk *) ((SBMA)smp + elsize));
sm->smflags = 0;
} while(--cnt);
sm->smforw = 0; /* Last node points to nothing */
return(sm); /* Return ptr to last node */
}
/* SBM_NMOV(sm1, sm2, begp, elsize) - Move a typeless node.
* Copy sm1 to sm2, adjust ptrs, leave sm1 free.
*/
sbm_nmov(smp1,smp2,begp,elsize)
struct smblk *smp1, *smp2, **begp;
int elsize;
{ register struct smblk *sm;
bcopy((SBMA)smp1,(SBMA)(sm = smp2), elsize); /* Copy the stuff */
if(sm->smforw) sm->smforw->smback = sm; /* Fix up links */
if(sm->smback) sm->smback->smforw = sm;
else *begp = sm;
}
/* SBM_MGET(min,max) - Get a SMBLK with specified amount of memory.
* Returns 0 if none available.
* Memory is guaranteed to start on word boundary, but may not
* end on one. Note that sbm_mfree is responsible for
* ensuring that free mem starts word-aligned.
* A subtle but major concern of this code is the number of freelist
* nodes gobbled by a single call. If the freelist happens to not have
* enough nodes, then a recursive call to sbm_mget is made (via sbm_nget)
* in order to allocate a new batch of freelist nodes! sbm_nget will
* always provide a single "spare" node during such an allocation, but
* there is only one and it is essential that sbm_mget gobble only ONE
* (if any) during such a call, which is indicated by sbm_nxtra==0.
* The maximum # of freelist nodes that sbm_mget can gobble is
* 2, when (1) NXM memory is obtained, and a SM is needed to point at
* the new free mem, plus (2) the resulting SM is too big, and has to
* be split up, which requires another SM for the remainder.
* The "used-NXM" smblk is set up at init time precisely in order to
* avoid the necessity of creating it here when sbrk stops winning, since
* that would require yet another freelist node and make it possible for
* sbm_mget to gobble 3 during one call -- too many.
* Further note: the sbm_nfl checks are necessary in order
* to ensure that a SM node is available for use by sbm_split. Otherwise
* the calls to sbm_split might create a new SM freelist by gobbling the
* very memory which we are hoping to return!
*/
SBMO sbm_chksiz = SMCHUNKSIZ; /* Current chunk size to feed sbrk */
struct smblk *
sbm_mget(cmin,cmax)
SBMO cmin,cmax;
{ register struct smblk *sm, *sml;
register SBMO csiz;
register SBMA addr, xaddr;
if((sm = sbm_list) == 0 /* If never done, */
&& (sm = sbm_init((SBMA)0,(SBMO)0)) == 0) /* initialize mem alloc stuff. */
return(0); /* Can't init??? */
/* Round up sizes to word boundary */
if(rndrem(cmin)) cmin = rndup(cmin);
if(rndrem(cmax)) cmax = rndup(cmax);
/* Search for a free block having enough memory.
* If run into a free-NXM block, always "win", since there may be
* a combination of preceding free-mem and new mem which will satisfy
* the request. If it turns out this didn't work, we'll just fail
* a little farther on.
*/
retry: csiz = cmin; /* Set size that will satisfy us */
do {
if( ((sm->smflags&SM_USE) == 0)
&& ((sm->smlen >= csiz) || (sm->smflags&SM_NXM)) )
break;
} while(sm = sm->smforw);
if(sm == 0)
return(0); /* Found none that minimum would fit */
if(sm->smflags&SM_NXM)
{ /* Found free area, but it's marked NXM and the system
* must be persuaded (via sbrk) to let us use that portion
* of our address space. Grab a good-sized chunk.
*/
if(sbm_nfl == 0) /* Verify a spare SM node is avail */
goto getnod; /* Nope, must get one. */
/* Decide amount of mem to ask system for, via sbrk.
* The fine point here is the check of sbm_nxtra to make sure
* that, when building more freelist nodes, we don't have
* to use more than one SM node in the process. If we
* asked for too much mem, we'd have to use a SM node
* to hold the excess after splitting.
*/
csiz = cmax;
if(sbm_nxtra /* If normal then try for big chunk */
&& csiz < sbm_chksiz) csiz = sbm_chksiz; /* Max */
if (csiz > sm->smlen) csiz = sm->smlen; /* Min */
/* Get the NXM mem */
if((addr = (SBMA)SBM_SBRK(csiz)) != sm->smaddr)
{ /* Unexpected value returned from SBRK! */
if((int)addr != 0 && (int)addr != -1)
{ return(sbm_err(0,"SBRK %o != %o", addr,
sm->smaddr));
#if 0
/* If value indicates couldn't get the stuff, then
* we have probably hit our limit and the rest of
* NXM should be declared "used" to prevent further
* hopeless sbrk calls. We split off the portion
* of NXM that is known for sure to be unavailable,
* and mark it "used". If a "used NXM" area already
* exists following this one, the two are merged.
* The chunk size is then reduced by half, so
* only log2(SMCHUNKSIZ) attempts will be made, and
* we try again.
*/
/* If returned some mem which starts outside
* the NXM then something is screwed up. */
if(addr < sm->smaddr
|| (addr >= sm->smaddr+sm->smlen))
return(sbm_err(0,"SBRK %o != %o",
addr, sm->smaddr));
/* Got some mem, falls within NXM.
* Presumably someone else has called sbrk
* since last time, so we need to fence off
* the intervening area. */
sm = sbm_split((sml=sm),(addr - sm->smaddr));
sml->smflags |= SM_USE|SM_EXT;
return(sbm_mget(cmin,cmax));
#endif /*COMMENT*/
}
/* Handle case of SBRK claiming no more memory.
* Gobble as much as we can, and then turn this NXM
* block into a free-mem block, and leave the
* remainder in the used-NXM block (which should
* immediately follow this free-NXM block!)
*/
if(!(sml = sm->smforw) /* Ensure have used-NXM blk */
|| (sml->smflags&(SM_USE|SM_NXM))
!= (SM_USE|SM_NXM))
return(sbm_err(0,"No uNXM node!"));
xaddr = sm->smaddr; /* Use this for checking */
sm->smuse = 0; /* Use this for sum */
for(csiz = sm->smlen; csiz > 0;)
{ addr = SBM_SBRK(csiz);
if((int)addr == 0 || (int)addr == -1)
{ csiz >>= 1;
continue;
}
if(addr != xaddr)
return(sbm_err(0,"SBRK %o != %o", addr,
xaddr));
sm->smuse += csiz;
xaddr += csiz;
}
/* Have gobbled as much from SBRK as we could.
* Turn the free-NXM block into a free-mem block,
* unless we got nothing, in which case just merge
* it into the used-NXM block and continue
* searching from this point.
*/
if(!(csiz = sm->smuse)) /* Get total added */
{ sm->smflags = sml->smflags; /* Ugh. */
sbm_mmrg(sm);
goto retry; /* Keep looking */
}
else
{ sml->smaddr = sm->smaddr + csiz;
sml->smlen += sm->smlen - csiz;
sm->smlen = csiz;
sm->smflags &= ~SM_NXM; /* No longer NXM */
}
}
/* Here when we've acquired CSIZ more memory from sbrk.
* If preceding mem area is not in use, merge new mem
* into it.
*/
if((sml = sm->smback) &&
(sml->smflags&(SM_USE|SM_NXM))==0) /* Previous free? */
{ sml->smlen += csiz; /* Yes, simple! */
sm->smaddr += csiz; /* Fix up */
if((sm->smlen -= csiz) == 0) /* If no NXM left,*/
sbm_mmrg(sml); /* Merge NXM node w/prev */
sm = sml; /* Prev is now winning node */
}
else
{ /* Prev node isn't a free area. Split up the NXM
* node to account for acquired mem, unless we
* gobbled all the mem available.
*/
if(sm->smlen > csiz /* Split unless all used */
&& !sbm_split(sm,csiz)) /* Call shd always win */
return(sbm_err(0,"getsplit err: %o",sm));
sm->smflags &= ~SM_NXM; /* Node is now real mem */
}
/* Now make a final check that we have enough memory.
* This can fail because SBRK may not have been able
* to gobble enough memory, either because (1) not
* as much NXM was available as we thought,
* or (2) we noticed the free-NXM area and immediately
* gambled on trying it without checking any lengths.
* In any case, we try again starting from the current SM
* because there may be more free mem higher up (eg on
* stack).
*/
if(sm->smlen < cmin)
goto retry;
}
/* Check to see if node has too much mem. This is especially true
* for memory just acquired via sbrk, which gobbles a huge chunk each
* time. If there's too much, we split up the area.
*/
if(sm->smlen > cmax+FUDGE) /* Got too much? (Allow some fudge)*/
/* Yes, split up so don't gobble too much. */
if(sbm_nfl) /* If success guaranteed, */
sbm_split(sm,cmax); /* split it, all's well. */
else goto getnod;
sm->smuse = 0;
sm->smflags |= SM_USE; /* Finally seize it by marking "in-use". */
return(sm);
/* Come here when we will need to get another SM node but the
* SM freelist is empty. We have to forget about using the area
* we just found, because sbm_nget may gobble it for the
* freelist. So, we first force a refill of the freelist, and then
* invoke ourselves again on what's left.
*/
getnod:
if(sml = sbm_nget()) /* Try to build freelist */
{ sbm_nfre(sml); /* Won, give node back, */
sm = sbm_list; /* and retry, starting over! */
goto retry;
}
/* Failed. Not enough memory for both this request
* and one more block of SM nodes. Since such a SM_MNODS
* block isn't very big, we are so close to the limits that it
* isn't worth trying to do something fancy here to satisfy the
* original request. So we just fail.
*/
return(0);
}
#ifdef DBG_SIZE
/* Code for debugging stuff by imposing an artificial limitation on size
* of available memory.
*/
SBMO sbm_dlim = MAXSBMO; /* Amount of mem to allow (default is max) */
char *
sbm_brk(size)
unsigned size;
{ register char *addr;
if(size > sbm_dlim) return(0);
addr = sbrk(size);
if((int)addr == 0 || (int)addr == -1)
return(0);
sbm_dlim -= size;
return(addr);
}
#endif /*DBG_SIZE*/
/* SBM_MFREE(sm) - Free up an allocated memory area.
*/
void
sbm_mfree(sm)
register struct smblk *sm;
{ register struct smblk *smx;
register SBMO crem;
sm->smflags &= ~SM_USE; /* Say mem is free */
if((smx = sm->smback) /* Check preceding mem */
&& (smx->smflags&(SM_USE|SM_NXM))==0) /* If it's free, */
sbm_mmrg(sm = smx); /* then merge 'em. */
if((smx = sm->smforw) /* Check following mem */
&& (smx->smflags&(SM_USE|SM_NXM))==0) /* Again, if free, */
sbm_mmrg(sm); /* merge them. */
if(sm->smlen == 0) /* Just in case, chk for null blk */
{ if(smx = sm->smback) /* If pred exists, */
sbm_mmrg(smx); /* merge quietly. */
else {
sbm_list = sm->smforw; /* 1st node on list, so */
sbm_nfre(sm); /* simply flush it. */
}
return;
}
/* This code is slightly over-general for some machines.
* The pointer subtraction is done in order to get a valid integer
* offset value regardless of the internal representation of a pointer.
* We cannot reliably force alignment via casts; some C implementations
* treat that as a no-op.
*/
if(crem = rndrem(sm->smaddr - sbm_lowaddr)) /* On word bndry? */
{ /* No -- must adjust. All free mem blks MUST, by fiat,
* start on word boundary. Here we fix things by
* making the leftover bytes belong to the previous blk,
* no matter what it is used for. Prev blk is guaranteed to
* (1) Exist (this cannot be 1st blk since 1st is known to
* start on wd boundary) and to be (2) Non-free (else it would
* have been merged).
*/
if((smx = sm->smback) == 0) /* Get ptr to prev blk */
{ sbm_err(0,"Align err"); /* Catch screws */
return;
}
crem = WDSIZE - crem; /* Find # bytes to flush */
if(crem >= sm->smlen) /* Make sure node has that many */
{ sbm_mmrg(smx); /* Flush node to avoid zero length */
return;
}
smx->smlen += crem; /* Make stray bytes part of prev */
sm->smaddr += crem; /* And flush from current. */
sm->smlen -= crem;
}
}
/* SBM_EXP - Expand (or shrink) size of an allocated memory chunk.
* "nsize" is desired new size; may be larger or smaller than current
* size.
*/
struct smblk *
sbm_exp(sm,size)
register struct smblk *sm;
register SBMO size;
{ register struct smblk *smf;
register SBMO mexp, pred, succ;
if(sm->smlen >= size) /* Do we want truncation? */
goto realo2; /* Yup, go split block */
/* Block is expanding. */
mexp = size - sm->smlen; /* Get # bytes to expand by */
pred = succ = 0;
if((smf = sm->smforw) /* See if free mem follows */
&& (smf->smflags&(SM_USE|SM_NXM)) == 0)
if((succ = smf->smlen) >= mexp)
goto realo1; /* Quick stuff if succ OK */
if((smf = sm->smback) /* See if free mem precedes */
&& (smf->smflags&(SM_USE|SM_NXM)) == 0)
pred = smf->smlen;
/* If not enough free space combined on both sides of this chunk,
* we have to look for a completely new block.
*/
if(pred+succ < mexp)
{ if((smf = sbm_mget(size,size)) == 0)
return(0); /* Couldn't find one */
else pred = 0; /* Won, indicate new block */
}
/* OK, must copy either into new block or down into predecessor
* (overlap is OK as long as bcopy moves 1st byte first)
*/
bcopy(sm->smaddr, smf->smaddr, sm->smlen);
smf->smflags = sm->smflags; /* Copy extra attribs */
smf->smuse = sm->smuse;
if(!pred) /* If invoked sbm_mget */
{ sbm_mfree(sm); /* then must free up old area */
return(smf); /* and can return immediately. */
}
sbm_mmrg(smf); /* Merge current into pred blk */
sm = smf; /* Now pred is current blk. */
if(succ)
realo1: sbm_mmrg(sm); /* Merge succ into current blk */
realo2: if(sm->smlen > size /* If now have too much, */
&& sbm_split(sm, size)) /* split up and possibly */
sbm_mfree(sm->smforw); /* free up unused space. */
return(sm);
/* Note that sbm_split can fail if it can't get a free node,
* which is only possible if we are reducing the size of an area.
* If it fails, we just return anyway without truncating the area.
*/
}
/* SBM_MMRG(sm) - Merge a memory area with the area following it.
* The node (and memory area) following the SM pointed to are
* merged in and the successor node freed up. The flags
* and smuse of the current SM (which is not moved or anything)
* remain the same.
*/
sbm_mmrg(smp)
struct smblk *smp;
{ register struct smblk *sm, *sm2;
sm = smp;
sm->smlen += (sm2 = sm->smforw)->smlen; /* Add succ's len */
if(sm->smforw = sm2->smforw) /* and fix linkages */
sm->smforw->smback = sm;
sbm_nfre(sm2); /* now can flush succ node */
}
/* SBM_SPLIT - Split up an area (gets a new smblk to point to split-off
* portion.)
* Note returned value is ptr to 2nd smblk, since this is a new one.
* Ptr to 1st remains valid since original smblk stays where it is.
* NOTE: Beware of splitting up free mem (SM_USE == 0) since sbm_nget may
* steal it out from under unless precautions are taken! See comments
* at sbm_mget related to this.
*/
struct smblk *
sbm_split(smp,coff)
struct smblk *smp;
SBMO coff;
{ register struct smblk *sm, *smx;
register SBMO csiz;
if((sm = smp)->smlen <= (csiz = coff))
return(0);
if((smx = sbm_nget()) == 0)
return(0);
smx->smlen = sm->smlen - csiz; /* Set 2nd size */
smx->smaddr = sm->smaddr + csiz; /* Set 2nd addr */
sm->smlen = csiz; /* Take from 1st size */
smx->smflags = sm->smflags; /* Copy flags */
if(smx->smforw = sm->smforw) /* Splice 2nd after 1 */
smx->smforw->smback = smx;
smx->smback = sm;
sm->smforw = smx; /* Put 2nd into chain */
return(smx); /* Return ptr to 2nd smblk */
}
#if 0 /* Replaced by "bcopy" for system-dep efficiency */
/* SBM_SCPY - Copy string of bytes. Somewhat machine-dependent;
* Tries to be clever about using word moves instead of byte moves.
*/
sbm_scpy(from, to, count) /* Copy count bytes from -> to */
char *from, *to;
unsigned count;
{ register char *s1, *s2;
register unsigned cnt;
int tmp;
if((cnt = count) == 0)
return;
s1 = from;
s2 = to;
while(rndrem((int)s1)) /* Get 1st ptr aligned */
{ *s2++ = *s1++;
if(--cnt == 0) return;
}
if(rndrem((int)s2) == 0) /* Do wd move if ptr 2 now aligned */
{
#ifdef DUMBPCC /* Code for dumber (Portable C type) compiler */
register WORD *ap, *bp;
tmp = cnt;
ap = (WORD *) s1;
bp = (WORD *) s2;
if(cnt = rnddiv(cnt))
do { *bp++ = *ap++; }
while(--cnt);
if ((cnt = rndrem(tmp)) ==0)
return;
s1 = (char *) ap;
s2 = (char *) bp;
#else
/* Tight loop for efficient copying on 11s */
tmp = cnt;
if(cnt = rnddiv(cnt))
do { *((WORD *)s2)++ = *((WORD *)s1)++; }
while(--cnt);
if((cnt = rndrem(tmp)) == 0)
return;
#endif /*-DUMBPCC*/
}
do { *s2++ = *s1++; } /* Finish up with byte loop */
while(--cnt);
}
#endif /*COMMENT*/
struct smblk * /* If it returns at all, this is most common type */
sbm_err(val,str,a0,a1,a2,a3)
char *str;
struct smblk *val;
{ int *sptr;
sptr = (int *) &sptr; /* Point to self on stack */
sptr += 5; /* Point to return addr */
if((int)sbm_debug==1)
abort();
if(sbm_debug)
(*sbm_debug)(0,*sptr,str,a0,a1,a2,a3);
return(val);
}
/* These routines correspond to the V7 LIBC routines as described
* in the V7 UPM (3). They should provide satisfactory emulation
* if the documentation is correct. Replacement is necessary since
* the SBM routines are jealous and cannot tolerate competition for
* calls of SBRK; i.e. the memory being managed must be contiguous.
*/
/* Guaranteed to return word-aligned pointer to area of AT LEAST
* requested size. Area size is rounded up to word boundary.
*/
char *
malloc(size)
unsigned size;
{ register struct smblk *sm, **sma;
register SBMO siz;
siz = rndup(size + sizeof (struct smblk *)); /* Make room for ptr */
if((sm = sbm_mget(siz,siz)) == 0)
return(0);
*(sma = (struct smblk **)sm->smaddr) = sm; /* Store ptr in addr-1 */
return((char *)++sma);
}
char *
alloc(size) /* For V6 programs - note different failure value! */
unsigned size;
{ register char *addr;
return((addr = malloc(size)) ? addr : (char *) -1);
}
free(ptr)
char *ptr;
{ register struct smblk *sm, **smp;
#ifdef __NBSD_LIBC
/* In NetBSD, free is a nop if ptr == NULL; */
if(ptr == NULL)
return(1);
#endif
smp = &((struct smblk **)ptr)[-1]; /* Point to addr-1 */
sm = *smp; /* Pluck SM ptr therefrom */
if(((sm->smflags&0377) != SM_NID) || sm->smaddr != (SBMA)smp)
return((int)sbm_err(0,"free: bad arg %o", ptr));
sbm_mfree(sm);
return(1);
}
char *
realloc(ptr,size)
char *ptr;
unsigned size;
{ register struct smblk *sm, **smp;
smp = &((struct smblk **)ptr)[-1]; /* Point to addr-1 */
sm = *smp; /* Pluck SM ptr therefrom */
if(((sm->smflags&0377) != SM_NID) || (sm->smaddr != (SBMA)smp))
return((char *)sbm_err(0,"realloc: bad arg %o",ptr));
if((sm = sbm_exp(sm, rndup(size+(sizeof(struct smblk *))))) == 0)
return(0);
*(smp = (struct smblk **)sm->smaddr) = sm; /* Save smblk ptr */
return((char *)++smp);
}
char *
calloc(nelem,elsize)
unsigned nelem, elsize;
{ register SBMO cmin;
register WORD *ip; /* Clear in units of words */
register char *addr;
if((cmin = nelem*elsize) == 0 /* Find # bytes to get */
|| (addr = malloc(cmin)) == 0) /* Get it */
return(0);
ip = (WORD *) addr; /* Set up ptr to area */
cmin = rnddiv(cmin+WDSIZE-1); /* Find # words to clear */
do { *ip++ = 0; } while (--cmin); /* Zap the area */
return(addr);
}
/* SBM_NGC() - Specific routine for GC'ing SMBLK nodes.
*
* SBM_XNGC(begp, elsize, type) - Compact nodes of specified type.
* Scans allocated mem from low to high to find chunks with nodes of
* the specified type.
* Flushes current freelist and rebuilds it as scan progresses,
* such that 1st thing on list is lowest-addr node. When a node is
* seen that can be moved, new node is acquired from freelist if
* it exists, otherwise no move is made. If a chunk has been scanned
* and no active nodes remain, it is flushed and freelist updated.
* NOTE: This has not yet been verified to work with nodes of any
* type other than SMBLK.
*/
sbm_ngc()
{ register struct smblk *sm;
if(!(sm = sbm_nxtra))
return((int)sbm_err(0,"Zero sbm_nxtra"));
sm->smflags |= SM_USE; /* Ensure this one isn't GC'd */
sbm_xngc(&sbm_nfl, sizeof(struct smblk), SM_MNODS);
sm->smflags = 0; /* Flush temporary crock */
}
sbm_xngc(begp, elsize, flag)
struct smblk **begp;
unsigned elsize, flag;
{ register struct smblk *sm, *chk, *smf;
struct smblk *ftail, *savtail;
int cnt, inuse;
*begp = ftail = 0; /* Flush node freelist */
for(chk = sbm_list; chk; chk = chk->smforw)
if(chk->smflags&flag)
{ sm = (struct smblk *) chk->smaddr;
cnt = (chk->smuse)/elsize;
savtail = ftail;
inuse = 0;
smf = *begp;
/* Set up ptr to 1st freelist node */
while(--cnt >= 0)
{ /* Here decide if movable */
if(sm->smflags && smf /* Live and have copy place */
&& (
(sm->smflags&SM_USE) == 0 /* Free mem? */
|| (sm->smflags&(SM_MNODS|SM_DNODS))
)
&& sm->smback) /* has backptr (see ncpy) */
{ /* Move the node */
*begp = smf->smforw; /* Get free node */
if(smf == ftail)
ftail = 0;
if(smf == savtail)
savtail = 0;
/* Move node. Already checked for back ptr
* of 0 since no obvious way to tell where
* the ptr to list is kept. Sigh.
*/
sbm_nmov(sm,smf,(struct smblk **)0,elsize);
/* Get ptr to new freelist node. Note
* check to ensure that it is not in this
* same chunk (if it is, no point in moving
* any nodes!)
*/
if((smf = *begp) >= chk)
smf = 0; /* Zero if same chk */
sm->smflags = 0; /* Make node free */
}
/* At this point, not movable */
if(sm->smflags == 0) /* Free node? */
{ if(ftail) /* Add to freelist */
ftail->smforw = sm;
ftail = sm;
if(*begp == 0)
*begp = sm;
sm->smforw = 0;
}
else inuse++;
sm = (struct smblk *)((SBMA)sm + elsize);
}
if(inuse == 0 /* All free? */
&& (sm = chk->smback)) /* & not 1st? */
{ if(savtail) /* Edit freelist */
(ftail = savtail)->smforw = 0;
else *begp = ftail = 0;
sbm_mfree(chk);
chk = sm;
}
}
}
/*
* Note that proc must return a zero value, or loop aborts and
* returns that selfsame value.
*/
sbm_nfor(flag,nodsiz,proc,arg)
int flag;
int (*proc)();
int nodsiz;
struct sbfile *arg;
{ register struct smblk *sm, *np;
register int cnt;
int res;
for(sm = sbm_list; sm; sm = sm->smforw)
if(sm->smflags&flag)
{ np = (struct smblk *) sm->smaddr;
cnt = sm->smuse/nodsiz;
do {
if(np->smflags)
if(res = (*proc)(np,arg))
return(res);
np = (struct smblk *)((SBMA)np + nodsiz);
} while(--cnt);
}
return(0);
}

View file

@ -1,122 +0,0 @@
#ifndef _ANSI
#include <minix/ansi.h>
#endif
/* sbbcpy.c */
#ifndef _MINIX
_PROTOTYPE( int bcopy, (SBMA from, SBMA to, unsigned cnt) );
#endif
_PROTOTYPE( int sbm_wcpy, (int *from, int *to, unsigned cnt) );
/* sberr.c */
_PROTOTYPE( int sbe_mem, (void) );
_PROTOTYPE( char *sbe_mvfy, (void) );
_PROTOTYPE( char *sbe_mfl, (int p) );
_PROTOTYPE( char *sbe_mlst, (int p) );
_PROTOTYPE( int sbe_smp, (struct smblk *sm, int type) );
_PROTOTYPE( char *sbe_sfl, (int p) );
_PROTOTYPE( int sbe_sds, (void) );
_PROTOTYPE( int sbe_psd, (struct sdblk *sd) );
_PROTOTYPE( char *sbe_svfy, (void) );
_PROTOTYPE( char *sbe_sdlist, (int p, int phys) );
_PROTOTYPE( int sbe_dsk, (SBFILE *sfp) );
_PROTOTYPE( char *sbe_sbvfy, (SBBUF *sbp) );
_PROTOTYPE( char *sbe_sbs, (SBBUF *sbp, int p) );
/* sbm.c */
_PROTOTYPE( struct smblk *sbm_init, (SBMA xaddr, SBMO xlen) );
_PROTOTYPE( struct smblk *sbm_nget, (void) );
_PROTOTYPE( int sbm_nfre, (struct smblk *smp) );
_PROTOTYPE( struct smblk *sbm_nmak, (SBMO elsize, unsigned flag) );
_PROTOTYPE( struct smblk *sbm_lmak, (SBMA addr, SBMO elsize, int num) );
_PROTOTYPE( int sbm_nmov, (struct smblk *smp1, struct smblk *smp2, struct smblk **begp, int elsize) );
_PROTOTYPE( struct smblk *sbm_mget, (SBMO cmin, SBMO cmax) );
_PROTOTYPE( char *sbm_brk, (unsigned size) );
_PROTOTYPE( void sbm_mfree, (struct smblk *sm) );
_PROTOTYPE( struct smblk *sbm_exp, (struct smblk *sm, SBMO size) );
_PROTOTYPE( int sbm_mmrg, (struct smblk *smp) );
_PROTOTYPE( struct smblk *sbm_split, (struct smblk *smp, SBMO coff) );
_PROTOTYPE( int sbm_scpy, (char *from, char *to, unsigned count) );
#if 0
_PROTOTYPE( struct smblk *sbm_err, (struct smblk *val, char *str, int a0, int a1, int a2, int a3) );
#else
struct smblk *sbm_err();
#endif
_PROTOTYPE( char *malloc, (unsigned size) );
_PROTOTYPE( char *alloc, (unsigned size) );
_PROTOTYPE( int free, (char *ptr) );
_PROTOTYPE( char *realloc, (char *ptr, unsigned size) );
_PROTOTYPE( char *calloc, (unsigned nelem, unsigned elsize) );
_PROTOTYPE( int sbm_ngc, (void) );
_PROTOTYPE( int sbm_xngc, (struct smblk **begp, unsigned elsize, unsigned flag) );
_PROTOTYPE( int sbm_nfor, (int flag, int nodsiz, int (*proc )(), struct sbfile *arg) );
/* sbstr.c */
_PROTOTYPE( SBSTR *sb_close, (SBBUF *sbp) );
_PROTOTYPE( int sb_setovw, (SBBUF *sbp) );
_PROTOTYPE( int sb_clrovw, (SBBUF *sbp) );
_PROTOTYPE( chroff sbx_fdlen, (int fd) );
_PROTOTYPE( SBSTR *sb_fduse, (int ifd) );
_PROTOTYPE( int sb_fdcls, (int ifd) );
_PROTOTYPE( int sbx_fcls, (struct sbfile *sfp) );
_PROTOTYPE( int sb_fdinp, (SBBUF *sb, int fd) );
_PROTOTYPE( int sb_fsave, (SBBUF *sb, int fd) );
_PROTOTYPE( int sb_sgetc, (SBBUF *sb) );
_PROTOTYPE( int sb_sputc, (SBBUF *sb, int ch) );
_PROTOTYPE( int sb_speekc, (SBBUF *sb) );
_PROTOTYPE( int sb_rgetc, (SBBUF *sb) );
_PROTOTYPE( int sb_rdelc, (SBBUF *sbp) );
_PROTOTYPE( int sb_deln, (SBBUF *sbp, chroff num) );
_PROTOTYPE( struct sdblk *sb_killn, (SBBUF *sbp, chroff num) );
_PROTOTYPE( SBSTR *sb_cpyn, (SBBUF *sbp, chroff num) );
_PROTOTYPE( int sb_sins, (SBBUF *sbp, struct sdblk *sdp) );
_PROTOTYPE( SBSTR *sbs_cpy, (SBSTR *sdp) );
_PROTOTYPE( int sbs_del, (SBSTR *sdp) );
_PROTOTYPE( SBSTR *sbs_app, (struct sdblk *sdp, struct sdblk *sdp2) );
_PROTOTYPE( chroff sbs_len, (SBSTR *sdp) );
_PROTOTYPE( int sb_seek, (SBBUF *sbp, chroff coff, int flg) );
_PROTOTYPE( int sb_rewind, (SBBUF *sbp) );
_PROTOTYPE( chroff sb_tell, (SBBUF *sbp) );
_PROTOTYPE( chroff sb_ztell, (SBBUF *sbp) );
#if 0
_PROTOTYPE( struct sdblk *sbx_ready, (SBBUF *sbp, int type, SBMO cmin, SBMO cmax) );
#else
struct sdblk *sbx_ready();
#endif
_PROTOTYPE( struct sdblk *sbx_next, (SBBUF *sbp) );
_PROTOTYPE( struct sdblk *sbx_norm, (SBBUF *sbp, int mode) );
_PROTOTYPE( struct sdblk *sbx_beg, (struct sdblk *sdp) );
_PROTOTYPE( int sbx_smdisc, (SBBUF *sbp) );
_PROTOTYPE( int sbx_sbrdy, (SBBUF *sbp) );
_PROTOTYPE( struct sdblk *sbx_scpy, (struct sdblk *sdp, struct sdblk *sdlast) );
_PROTOTYPE( struct sdblk *sbx_sdcpy, (struct sdblk *sdp) );
_PROTOTYPE( struct sdblk *sbx_xcis, (SBBUF *sbp, chroff num, struct sdblk **asd2, chroff *adot) );
_PROTOTYPE( struct sdblk *sbx_split, (struct sdblk *sdp, chroff coff) );
_PROTOTYPE( struct smblk *sbx_msplit, (struct smblk *smp, SBMO size) );
_PROTOTYPE( struct sdblk *sbx_ndel, (struct sdblk *sdp) );
_PROTOTYPE( int sbx_npdel, (struct sdblk *sdp) );
_PROTOTYPE( struct sdblk *sbx_ndget, (void) );
_PROTOTYPE( int sbx_ndfre, (struct sdblk *sdp) );
_PROTOTYPE( SBMA sbx_malloc, (unsigned size) );
_PROTOTYPE( struct smblk *sbx_mget, (SBMO cmin, SBMO cmax) );
_PROTOTYPE( int sbx_comp, (int cmin, int lev) );
_PROTOTYPE( int sbx_sdgc, (struct sdblk *sdp, int lev) );
#if 0
_PROTOTYPE( int sbx_aout, (struct sdblk *sdp, int flag, int fd) );
#else
int sbx_aout();
#endif
_PROTOTYPE( chroff sbx_qlen, (struct sdblk *sdp) );
_PROTOTYPE( int sbx_tset, (chroff loff, int align) );
_PROTOTYPE( struct sdblk *sbx_ffnd, (SBFILE *sfp, chroff size, chroff *aloc) );
_PROTOTYPE( int sbx_rdf, (int fd, char *addr, int cnt, int skflg, chroff loc) );
_PROTOTYPE( int sbx_rugpull, (int fd) );
_PROTOTYPE( int sbx_unpur, (struct sdblk *sd, struct sbfile *sf) );
#if 0
_PROTOTYPE( int sbx_err, (int val, char *str, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12) );
#else
int sbx_err();
#endif
/* sbvall.c */
_PROTOTYPE( char *valloc, (unsigned size) );

File diff suppressed because it is too large Load diff

View file

@ -1,42 +0,0 @@
/* VALLOC - Aligned memory allocator
* Emulation of the 4.2BSD library routine of the same name.
* Copyright 1985 by Ken Harrenstien, SRI International
* This software is quasi-public; it may be used freely with
* like software, but may NOT be sold or made part of licensed
* products without permission of the author. In all cases
* the source code and any modifications thereto must remain
* available to any user.
*
* This is part of the SB library package.
* Any software using the SB library must likewise be made
* quasi-public, with freely available sources.
*/
#include "sb.h"
char *
valloc(size)
unsigned size;
{ register int pagmsk;
register SBMO i;
register struct smblk *sm, *smr;
struct smblk *sbm_mget(), *sbm_split();
pagmsk = getpagesize() - 1; /* Get page size in bytes, less 1 */
if(!(sm = sbm_mget(size+pagmsk, size+pagmsk))) /* Get area big enuf */
return(0);
/* Now find # bytes prior to 1st page boundary.
* This expression gives 0 if already at boundary, else #-1.
*/
i = pagmsk - ((int)(sm->smaddr) & pagmsk);
if(i) /* If need to split off preceding stuff, */
{ smr = sbm_split(sm, i+1); /* do so (note i adjusted) */
sbm_mfree(sm); /* Release preceding mem */
if(!(sm = smr)) return(0); /* If couldn't split, fail */
}
if(i = (sm->smlen - size)) /* See if any trailing stuff */
{ smr = sbm_split(sm, size); /* Yeah, split it off too */
if(smr) sbm_mfree(smr); /* If couldn't split, excess OK. */
}
return((char *)(sm->smaddr));
}

Binary file not shown.

View file

@ -1,219 +0,0 @@
; This is the default user profile to emulate "mined" (MINIX editor),
; as per Andy Tanenbaum.
(keyallunbind)
; Insert self
(keybind A "Insert Self")
(keybind B "Insert Self")
(keybind C "Insert Self")
(keybind D "Insert Self")
(keybind E "Insert Self")
(keybind F "Insert Self")
(keybind G "Insert Self")
(keybind H "Insert Self")
(keybind I "Insert Self")
(keybind J "Insert Self")
(keybind K "Insert Self")
(keybind L "Insert Self")
(keybind M "Insert Self")
(keybind N "Insert Self")
(keybind O "Insert Self")
(keybind P "Insert Self")
(keybind Q "Insert Self")
(keybind R "Insert Self")
(keybind S "Insert Self")
(keybind T "Insert Self")
(keybind U "Insert Self")
(keybind V "Insert Self")
(keybind W "Insert Self")
(keybind X "Insert Self")
(keybind Y "Insert Self")
(keybind Z "Insert Self")
(keybind a "Insert Self")
(keybind b "Insert Self")
(keybind c "Insert Self")
(keybind d "Insert Self")
(keybind e "Insert Self")
(keybind f "Insert Self")
(keybind g "Insert Self")
(keybind h "Insert Self")
(keybind i "Insert Self")
(keybind j "Insert Self")
(keybind k "Insert Self")
(keybind l "Insert Self")
(keybind m "Insert Self")
(keybind n "Insert Self")
(keybind o "Insert Self")
(keybind p "Insert Self")
(keybind q "Insert Self")
(keybind r "Insert Self")
(keybind s "Insert Self")
(keybind t "Insert Self")
(keybind u "Insert Self")
(keybind v "Insert Self")
(keybind w "Insert Self")
(keybind x "Insert Self")
(keybind y "Insert Self")
(keybind z "Insert Self")
(keybind 0 "Insert Self")
(keybind 1 "Insert Self")
(keybind 2 "Insert Self")
(keybind 3 "Insert Self")
(keybind 4 "Insert Self")
(keybind 5 "Insert Self")
(keybind 6 "Insert Self")
(keybind 7 "Insert Self")
(keybind 8 "Insert Self")
(keybind 9 "Insert Self")
(keybind / "Insert Self")
(keybind : "Insert Self")
(keybind < "Insert Self")
(keybind = "Insert Self")
(keybind > "Insert Self")
(keybind ? "Insert Self")
(keybind @ "Insert Self")
(keybind [ "Insert Self")
(keybind ] "Insert Self")
(keybind ^ "Insert Self")
(keybind # "Insert Self")
(keybind $ "Insert Self")
(keybind % "Insert Self")
(keybind & "Insert Self")
(keybind ' "Insert Self")
(keybind * "Insert Self")
(keybind + "Insert Self")
(keybind , "Insert Self")
(keybind - "Insert Self")
(keybind . "Insert Self")
(keybind ! "Insert Self")
(keybind " " "Insert Self")
(keybind """" "Insert Self")
(keybind "(" "Insert Self")
(keybind ")" "Insert Self")
(keybind ";" "Insert Self")
(keybind "\" "Insert Self")
(keybind _ "Insert Self")
(keybind ` "Insert Self")
(keybind { "Insert Self")
(keybind | "Insert Self")
(keybind } "Insert Self")
(keybind ~ "Insert Self")
; CTRL char
(keybind ^A "Beginning of Line")
(keybind ^B "Backward Word")
(keybind ^C "Copy Region")
(keybind ^D "Scroll Window Up")
(keybind ^E "New Window")
(keybind ^F "Forward Word")
(keybind ^H "Backward Delete Character")
(keybind ^I "Insert Self")
; open
(keybind ^K "Kill Region")
(keybind ^L "Replace in Line")
(keybind ^M "CRLF")
(keybind ^N "Kill Word")
(keybind ^O "Open Line")
(keybind ^P "Backward Kill Word")
(keybind ^Q "Write Last Kill")
(keybind ^R "Replace String")
(keybind ^S "Push to Inferior")
(keybind ^T "Kill Line")
(keybind ^U "Scroll Window Down")
(keybind ^V "Find File")
(keybind ^W "Save File")
(keybind ^X "Prefix Extend")
(keybind ^Y "Un-kill")
(keybind ^Z "End of Line")
(keybind "^\" "Quoted Insert")
(keybind ^_ "Move to Window Bottom")
(keybind ^^ "Set/Pop Mark")
(keybind ^] "Goto Line")
; ESC char
(keybind ^[ "Prefix Meta")
(keybind M-0 "Argument Digit")
(keybind M-1 "Argument Digit")
(keybind M-2 "Argument Digit")
(keybind M-3 "Argument Digit")
(keybind M-4 "Argument Digit")
(keybind M-5 "Argument Digit")
(keybind M-6 "Argument Digit")
(keybind M-7 "Argument Digit")
(keybind M-8 "Argument Digit")
(keybind M-9 "Argument Digit")
(keybind M-A "Append Next Kill")
(keybind M-B "Select Buffer")
(keybind M-C "Uppercase Word")
(keybind M-E "Execute Kbd Macro")
(keybind M-F "Find File")
(keybind M-G "Insert File")
(keybind M-H "Describe")
(keybind M-I "Uppercase Initial")
(keybind M-K "Kill Buffer")
(keybind M-L "Lowercase Region")
(keybind M-M "Mark Paragraph")
(keybind M-N "Buffer Not Modified")
(keybind M-O "Lowercase Word")
(keybind M-P "Forward Paragraph")
(keybind M-Q "Query Replace")
(keybind M-R "Set Profile")
(keybind M-S "Select Existing Buffer")
(keybind M-T "Transpose Characters")
(keybind M-U "Uppercase Region")
(keybind M-W "Transpose Words")
(keybind M-X "Return to Superior")
(keybind M-Y "Un-kill Pop")
(keybind M-Z "Incremental Search")
(keybind M-^ "Exchange Point and Mark")
(keybind M-* "View Kbd Macro")
(keybind M-[ "Prefix Extend")
(keybind M-] "Backward Paragraph")
(keybind M-= "Delete Horizontal Space")
(keybind M-| "Delete Blank Lines")
(keybind "M-," "Move to Window Top")
(keybind "M-;" "Indent for Comment")
(keybind "M-." "Indent Relative")
(keybind "M-/" "Start Kbd Macro")
(keybind "M-\" "End Kbd Macro")
; CTRL-X char
(keybind X-1 "One Window")
(keybind X-2 "Two Windows")
(keybind X-A "Up Real Line")
(keybind X-B "Down Real Line")
(keybind X-C "Forward Character")
(keybind X-D "Backward Character")
(keybind X-G "List Buffers")
(keybind X-H "Goto Beginning")
(keybind X-L "Grow Window")
(keybind X-N "Other Window")
(keybind X-P "Shrink Window")
(keybind X-S "Reverse String Search")
(keybind X-T "String Search")
(keybind X-U "Next Screen")
(keybind X-V "Previous Screen")
(keybind X-X "Return to Superior")
(keybind X-Y "Goto End")
(keybind X-^A "Up Real Line")
(keybind X-^B "Down Real Line")
(keybind X-^C "Forward Character")
(keybind X-^D "Backward Character")
(keybind X-^G "List Buffers")
(keybind X-^H "Goto Beginning")
(keybind X-^L "Grow Window")
(keybind X-^N "Other Window")
(keybind X-^P "Shrink Window")
(keybind X-^S "Reverse String Search")
(keybind X-^T "String Search")
(keybind X-^U "Next Screen")
(keybind X-^V "Previous Screen")
(keybind X-^W "New Window")
(keybind X-^X "Return to Superior")
(keybind X-^Y "Goto End")
(keybind DEL "Delete Character")

View file

@ -62,8 +62,7 @@ Below is a sample editing session with comments given following the # symbol.
.fi
\fIEd\fR is provided for its sentimental value.
If you want a line-oriented editor, try \fIex\fR.
If you want a good editor, use \fIelle\fR, \fIelvis\fR, or \fImined\fR.
If you want a good editor, use \fIelvis\fR or \fImined\fR.
.SH "SEE ALSO"
.BR elvis (1),
.BR elle (1x),
.BR mined (1x).

View file

@ -1,4 +1,4 @@
MAN= awk.1x dis88.1x elle.1x elvis.1x kermit.1x \
MAN= awk.1x dis88.1x elvis.1x kermit.1x \
macros.1x mined.1x
.include <bsd.man.mk>

View file

@ -1,557 +0,0 @@
.so mnx.mac
.TH ELLE 1x
.CD "elle \(en ELLE Looks Like Emacs"
.SX "elle \fIfile\fR [\fIfile2\fR]"
.FL "\fR(none)"
.EY "elle file.c" "Start the editor"
.PP
\fIELLE\fR (ELLE Looks Like Emacs) is an Emacs clone for
.MX .
ELLE is not full Emacs but it has about 80 commands and is quite fast.
.SP 0.5
.SS "Key bindings"
.SP 0.5
.PP
\fIMined\fR only has a small number of commands. All of them are either of
the form CTRL-x or are on the numeric keypad. Emacs, in contrast, has so
many commands, that not only are all the CTRL-x commands used up, but so
are all the ESC x (escape followed by x; escape is not a shift character,
like CTRL). Even this is not enough, so CTRL-X is used as a prefix for
additional commands. Thus CTRL-X CTRL-L is a command, and so is CTRL-X K.
Note that what is conventionally written as CTRL-X K really means CTRL-X k.
In some contexts it is traditional to write CTRL-X as ^X.
Please note that they mean the same thing.
.PP
As a result, many Emacs commands need three or four key strokes to
execute. Some people think 3-4 key strokes is too many.
For this reason, Emacs and ELLE allow users to assign their own key bindings.
In ELLE this is done with \*(OQuser profiles.\*(CQ A user profile is a file listing
which function is invoked by which key stroke. The user profile is then
compiled by a program called ellec into binary form. When ELLE starts up
it checks to see if a file .ellepro.b1 exists in $HOME. If it does, this
file is read in and overrides the default bindings.
.PP
A user profile that simulates the \fImined\fR commands fairly
well is provided.
Its installation is described later. If you have never used Emacs,
it is suggested that you use the \fImined\fR profile.
If you normally use Emacs, then
do not install the \fImined\fR profile. You can also make your own using
\fIellec\fR.
There is no Mock Lisp.
.PP
ELLE has a character-oriented view of the world, not a line oriented
view, like \fIed\fR.
It does not have magic characters for searching.
However, you can use line feed in search patterns.
For example, to find a line consisting of the three characters
\*(OQfoo\*(CQ all by themselves on a line, using the mined
bindings (see below), use the pattern: CTRL-\\ CTRL-J f o o CTRL-\\ CTRL-J.
The CTRL-\ means to interpret the next character literally, in this case it
is CTRL-J, which is line feed. You can also search for patterns involving
multiple lines. For example, to find a line ending in an \*(OQx\*(CQ followed by a
line beginning with a \*(OQy\*(CQ, use as pattern: x CTRL-\ CTRL-J y.
.SS "Mined Key Bindings"
.PP
These are the key bindings if the binary user profile, \fI.ellepro.b1\fR,
is installed in $HOME. The ESCAPE key followed by a number followed by a
command causes that command to be executed \*(OQnumber\*(CQ times. This applies
both to control characters and insertable characters. CTRL-X refers to a
\*(OQcontrol character.\*(CQ ESC x refers to an escape character
followed by x.
In other words, ^X is a synonym for CTRL-X.
^X Y refers to CTRL-X followed by y. To abort the current command and go
back to the main loop of the editor, type CTRL-G, rather than CTRL-\\.
.PP
Only a few commands are of the form CTRL-X Y. All of these are also
bound to CTRL-X CTRL-Y, so you can hold down CTRL and then hit X Y, or
release control after the X, as you prefer.
.PP
The key bindings that are not listed should not be used.
Some of them actually do things.
For example, the ANSI escape codes ESC [ x are bound
to ^X Y for a variety of y.
.PP
Some commands work on regions.
A region is defined as the text between the most recently set mark
and the cursor.
.SP 0.5
.SS "Mined Commands"
.SP 0.5
.PP
If the \fImined\fR profile,
.I .ellepro.b1
is installed in your home directory, the following commands will work.
.sp
.in +1.75i
.ta +1.25i
.ti -1.5i
\fBCURSOR MOTION\fR
.ti -1.25i
arrows Move the cursor in the indicated direction
.ti -1.25i
CTRL-A Move cursor to start of current line
.ti -1.25i
CTRL-Z Move cursor to end of current line
.ti -1.25i
CTRL-F Move cursor forward word
.ti -1.25i
CTRL-B Move cursor backward to start of previous word
.sp
.ti -1.5i
\fBSCREEN MOTION\fR
.ti -1.25i
Home key Move to first character of the file
.ti -1.25i
End key Move to last character of the file
.ti -1.25i
PgUp key Scroll window up 22 lines (closer to start of the file)
.ti -1.25i
PgDn key Scroll window down 22 lines (closer to end of the file)
.ti -1.25i
CTRL-U Scroll window up 1 line
.ti -1.25i
CTRL-D Scroll window down 1 line
.ti -1.25i
ESC , Move to top of screen
.ti -1.25i
CTRL-_ Move to bottom of screen
.sp
.ti -1.5i
\fBMODIFYING TEXT\fR
.ti -1.25i
DEL key Delete the character under the cursor
.ti -1.25i
Backsp Delete the character to left of the cursor
.ti -1.25i
CTRL-N Delete the next word
.ti -1.25i
CTRL-P Delete the previous word
.ti -1.25i
CTRL-T Delete tail of line (all characters from cursor to end of line)
.ti -1.25i
CTRL-O Open up the line (insert line feed and back up)
.ti -1.25i
ESC G Get and insert a file at the cursor position (CTRL-G in mined)
.sp
.ti -1.5i
\fBREGIONS\fR
.ti -1.25i
CTRL-^ Set mark at current position for use with CTRL-C and CTRL-K
.ti -1.25i
CTRL-C Copy the text between the mark and the cursor into the buffer
.ti -1.25i
CTRL-K Delete text between mark and cursor; also copy it to the buffer
.ti -1.25i
CTRL-Y Yank contents of the buffer out and insert it at the cursor
.sp
.ti -1.5i
\fBMISCELLANEOUS\fR
.ti -1.25i
numeric + Search forward (prompts for expression)
.ti -1.25i
numeric \(mi Search backward (prompts for expression)
.ti -1.25i
CTRL-] ESC n CTRL-[ goes to line n (slightly different syntax than mined)
.ti -1.25i
CTRL-R Global replace pattern with string (from cursor to end)
.ti -1.25i
CTRL-L Replace pattern with string within the current line only
.ti -1.25i
CTRL-W Write the edited file back to the disk
.ti -1.25i
CTRL-S Fork off a shell (use CTRL-D to get back to the editor)
.ti -1.25i
CTRL-G Abort whatever the editor was doing and wait for command (CTRL-\)
.ti -1.25i
CTRL-E Redraw screen with cursor line positioned in the middle
.ti -1.25i
CTRL-V Visit (edit) a new file
.ti -1.25i
CTRL-Q Write buffer to a file
.ti -1.25i
ESC X Exit the editor
.SP 0.5
.in -1.75i
.SS "Non-Mined Commands"
.LP
.SP 0.5
.in +1.75i
.ta +1.25i
.ti -1.5i
\fBCURSOR MOTION\fR
.ti -1.25i
ESC P Forward paragraph (a paragraph is a line beginning with a dot)
.ti -1.25i
ESC ] Backward paragraph
.ti -1.25i
ESC . Indent this line as much as the previous one
.sp
.ti -1.5i
\fBMODIFYING TEXT\fR
.ti -1.25i
CTRL-\\ Insert the next character (used for inserting control characters)
.ti -1.25i
ESC T Transpose characters
.ti -1.25i
ESC W Transpose words
.ti -1.25i
ESC = Delete white space (horizontal space)
.ti -1.25i
ESC | Delete blank lines (vertical space)
.sp
.ti -1.5i
\fBREGIONS\fR
.ti -1.25i
ESC M Mark current paragraph
.ti -1.25i
ESC ^ Exchange cursor and mark
.ti -1.25i
ESC Y Yank back the next-to-the-last kill (CTRL-Y yanks the last one)
.ti -1.25i
ESC A Append next kill to kill buffer
.sp
.ti -1.5i
\fBKEYBOARD MACROS\fR
.ti -1.25i
ESC / Start Keyboard Macro
.ti -1.25i
ESC \\ End Keyboard Macro
.ti -1.25i
ESC * View Keyboard Macro (the PrtSc key on the numeric pad is also a *)
.ti -1.25i
ESC E Execute Keyboard Macro
.sp
.ti -1.5i
\fBWINDOW MANAGEMENT\fR
.ti -1.25i
^X 1 Enter one window mode
.ti -1.25i
^X 2 Enter two window mode
.ti -1.25i
^X L Make the current window larger
.ti -1.25i
^X P Make the window more petit/petite (Yes, Virginia, they are English)
.ti -1.25i
^X N Next window
.ti -1.25i
^X W New window
.sp
.ti -1.5i
\fBBUFFER MANAGEMENT\fR
.ti -1.25i
numeric 5 Display the list of current files and buffers
.ti -1.25i
ESC B Select a buffer
.ti -1.25i
ESC S Select an existing buffer
.ti -1.25i
ESC N Mark a buffer as NOT modified (even if it really is)
.sp
.ti -1.5i
\fBUPPER AND LOW CASE MANIPULATION\fR
.ti -1.25i
ESC I Set first character of word to upper case
.ti -1.25i
ESC C Capitalize current word
.ti -1.25i
ESC O Make current word ordinary (i.e., lower case)
.ti -1.25i
ESC U Set entire region between mark and cursor to upper case
.ti -1.25i
ESC L Set entire region between mark and cursor to lower case
.sp
.ti -1.5i
\fBMISCELLANEOUS\fR
.ti -1.25i
ESC F Find file and read it into its own buffer
.ti -1.25i
ESC Z Incremental search
.ti -1.25i
ESC Q Like CTRL-R, but queries at each occurrence (type ? for options)
.ti -1.25i
ESC R Reset the user profile from a file
.ti -1.25i
ESC H Help (ELLE prompts for the 1 or 2 character command to describe)
.ti -1.25i
ESC ; Insert a comment in a C program (generates /* */ for you)
.ti -1.25i
^X X Exit the editor (same as ESC X and CTRL-X CTRL-X)
.in -1.75i
.fi
.sp
The major differences between ELLE
with the \fImined\fR profile and \fImined\fR itself are:
.sp
.nf
.in +0.25i
1. The definition of a \*(OQword\*(CQ is different for forward and backward word
2. The mark is set with CTRL-^ instead of CTRL-@
3. Use CTRL-G to abort a command instead of CTRL-\\
4. Use CTRL-\ to literally insert the next character, instead of ALT
5. CTRL-E adjusts the window to put the cursor in the middle of it
6. To get and insert a file, use ESC G instead of CTRL-G
7. To go to line n, type ESC n CTRL-[ instead of CTRL-[ n
8. You exit with CTRL-X CTRL-X and then answer the question with \*(OQy\*(CQ.
9. There are many new commands, windows, larger files, etc.
.fi
.in -0.25i
.sp
.SS "Emacs Key Bindings"
.PP
If you do not have the \fImined\fR profile installed, you get the standard
Emacs key bindings.
These are listed below.
Commands not listed are not implemented.
.sp
.in +1.75i
.ta +1.25i
.ti -1.5i
\fBCURSOR MOVEMENT\fR
.ti -1.25i
CTRL-F Forward one character.
.ti -1.25i
CTRL-B Backward one character.
.ti -1.25i
CTRL-H Same as CTRL-B: move backward one character.
.ti -1.25i
ESC F Forward one word.
.ti -1.25i
ESC B Backward one word.
.ti -1.25i
CTRL-A Beginning of current line.
.ti -1.25i
CTRL-E End of current line.
.ti -1.25i
CTRL-N Next line (goes to the next line).
.ti -1.25i
CTRL-P Previous line (goes to the previous line).
.ti -1.25i
CTRL-V Beginning of next screenful.
.ti -1.25i
ESC V Beginning of previous screenful.
.ti -1.25i
ESC ]~ Forward Paragraph.
.ti -1.25i
ESC [~ Backward Paragraph.
.ti -1.25i
ESC < Beginning of whole buffer.
.ti -1.25i
ESC > End of whole buffer.
.sp
.ti -1.5i
\fBDELETING\fR
.ti -1.25i
CTRL-D Deletes forward one character (the one the cursor is under).
.ti -1.25i
DELETE Deletes backward one character (the one to left of cursor).
.ti -1.25i
ESC D Kills forward one word.
.ti -1.25i
ESC DEL Kills backward one word.
.ti -1.25i
CTRL-K Kills the rest of the line (to the right of the cursor).
.ti -1.25i
ESC \\ Deletes spaces around the cursor.
.ti -1.25i
^X CTRL-O Deletes blank lines around the cursor.
.sp
.ti -1.5i
\fBCASE CHANGE\fR
.ti -1.25i
ESC C Capitalizes word : first letter becomes uppercase; rest lower
.ti -1.25i
ESC L Makes the whole next word lowercase.
.ti -1.25i
ESC U Makes the whole next word uppercase.
.ti -1.25i
^X CTRL-L Makes whole region lowercase.
.ti -1.25i
^X CTRL-U Makes whole region uppercase.
.sp
.ti -1.5i
\fBSEARCHING\fR (If no string is given, previous string is used)
.ti -1.25i
CTRL-S Incremental Search forward; prompts \*(OQI-search:\*(CQ
.ti -1.25i
CTRL-R Reverse Incremental Search; prompts \*(OQR-search:\*(CQ
.HS
During an incremental search, the following characters have special effects:
.HS
.in +1.2i
.ta +1.0i +0.2i
.ti -1.2i
\*(OQnormal\*(CQ - Begin searching immediately.
.ti -1.2i
^G - Cancel I-search, return to start.
.ti -1.2i
DEL - Erase last char, return to last match.
.ti -1.2i
^S, ^R - Repeat search (or change direction).
.ti -1.2i
ESC or CR - Exit I-search at current point.
.sp
.in -1.2i
.ta +1.25i
.ti -1.25i
ESC % Query Replace. Interactive replace. Type \*(OQ?\*(CQ to see options.
.ti -1.25i
^X % Replace String. Like Query Replace, but not interactive
.sp
.ti -1.5i
\fBMARKING AREAS\fR
.ti -1.25i
CTRL-^ Set mark
.ti -1.25i
^X CTRL-X Exchange cursor and mark.
.ti -1.25i
ESC H Mark Paragraph. Sets mark and cursor to surround a para.
.ti -1.25i
CTRL-W Wipe-out -- kills a \*(OQregion\*(CQ:
.ti -1.25i
ESC W Copy region. Like CTRL-W then CTRL-Y but modifies buffer
.ti -1.25i
CTRL-Y Yanks-back (un-kills) whatever you have most recently killed.
.ti -1.25i
ESC Y Yanks-back (un-kills) the next most recently killed text.
.ti -1.25i
ESC CTRL-W Append Next Kill. Accumulates stuff from several kills
.sp
.ti -1.5i
\fBFILLING TEXT\fR
.ti -1.25i
ESC Q Fill the paragraph to the size of the Fill Column.
.ti -1.25i
ESC G Fill the region.
.ti -1.25i
^X F Set Fill Column. ESC Q will use this line size.
.ti -1.25i
^X . Set Fill Prefix. Asks for prefix string
.ti -1.25i
^X T Toggles Auto Fill Mode.
.sp
.ti -1.5i
\fBWINDOWS\fR
.ti -1.25i
^X 2 Make two windows (split screen).
.ti -1.25i
^X 1 Make one window (delete window) (make one screen).
.ti -1.25i
^X O Go to Other window.
.ti -1.25i
^X ^ Grow window: makes current window bigger.
.sp
.ti -1.5i
\fBBUFFERS\fR
.ti -1.25i
^X CTRL-F Find a file and make a buffer for it.
.ti -1.25i
^X B Select Buffer: goes to specified buffer or makes new one
.ti -1.25i
^X CTRL-B Show the names of the buffers used in this editing session.
.ti -1.25i
^X K Kill Buffer.
.ti -1.25i
ESC tilde Say buffer is not modified.
.ti -1.25i
^X CTRL-M Toggle EOL mode (per-buffer flag).
.sp
.ti -1.5i
\fBKEYBOARD MACRO\fR
.ti -1.25i
^X ( Start collecting a keyboard macro.
.ti -1.25i
^X ) Stop collecting.
.ti -1.25i
^X E Execute the collected macro.
.ti -1.25i
^X * Display the collected macro.
.sp
.ti -1.5i
\fBFILES\fR
.ti -1.25i
^X CTRL-I Insert a file where cursor is.
.ti -1.25i
^X CTRL-R Read a new file into current buffer.
.ti -1.25i
^X CTRL-V Same as ^X ^R above (reads a file).
.ti -1.25i
^X CTRL-W Write buffer out to new file name.
.ti -1.25i
^X CTRL-S Save file: write out buffer to its file name.
.ti -1.25i
^X CTRL-E Write region out to new file name.
.sp
.ti -1.5i
\fBMISCELLANEOUS\fR
.ti -1.25i
^X CTRL-Z Exit from ELLE.
.ti -1.25i
^X ! Escape to shell (CTRL-D to return)
.ti -1.25i
CTRL-O Open up line
.ti -1.25i
LINEFEED Same as typing RETURN and TAB.
.ti -1.25i
CTRL-T Transposes characters.
.ti -1.25i
ESC T Transposes words.
.ti -1.25i
CTRL-U Makes the next command happen four times.
.ti -1.25i
CTRL-U number Makes the next command happen \*(OQnumber\*(CQ times.
.ti -1.25i
ESC number Same as CTRL-U number.
.ti -1.25i
CTRL-L Refreshes screen.
.ti -1.25i
CTRL-U CTRL-L Refresh only the line cursor is on.
.ti -1.25i
CTRL-U n CTRL-L Change window so the cursor is on line n
.ti -1.25i
CTRL-Q Quote: insert the next character no matter what it is.
.ti -1.25i
CTRL-G Quit: use to avoid answering a question.
.ti -1.25i
ESC ; Inserts comment (for writing C programs).
.ti -1.25i
ESC I Inserts indentation equal to previous line.
.ti -1.25i
ESC M Move to end of this line's indentation.
.ti -1.25i
CTRL-_ Describe a command (if the command database is online)
.sp
.ti -1.5i
\fBUNUSED CONTROLS\fR
.ti -1.25i
CTRL-C Not used.
.ti -1.25i
CTRL-Z Not used.
.ti -1.25i
CTRL-] Not used.
.fi
.in -1.75i
.sp
.SP 0.5
.SS "ELLE profile"
.PP
It is possible to create your own user profile.
The mechanism is different from Emacs, since ELLE does not have Mock Lisp.
Proceed as follows.
.LI
.IT
Modify \fI.ellepro.e\fR to suit your taste.
.IT
Install \fI.ellepro.e\fR in your home directory.
.IT
Type:
.HS
.Cx "ellec \(enProfile"
.HS
.IT
Check to see if \fI.ellepro.b1\fR has been created.
If it has, you are ready to go.
.LX
.SS "Author"
.PP
ELLE was written by Ken Harrenstien of SRI (klh@sri.com).

View file

@ -90,10 +90,6 @@ This directory is the home directory for the root user.
.PP
.nf
\fB.ashrc\fP ash (shell) startup configuration, \fBash\fP(1)
\fB.ellepro.b1\fP
elle (editor) startup configuration (compiled), \fBelle\fP(1)
\fB.ellepro.e\fP
elle (editor) startup configuration (text), \fBelle\fP(1)
\fB.exrc\fP ex/vi (editor) startup configuration, \fBvim\fP(1)
\fB.profile\fP
login shell profile configuration

View file

@ -574,11 +574,7 @@ The editors available are
.B elvis
(a
.B vi
clone),
.B elle
(a simple
.B emacs
clone),
clone)
and the old MINIX
.B mined
editor. Of these editors only elvis can recover your file after a system