home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2962 < prev    next >
Encoding:
Internet Message Format  |  1991-03-05  |  54.3 KB

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Newsgroups: alt.sources
  3. Subject: STDWIN 0.9.5, Part 01/19
  4. Message-ID: <3065@charon.cwi.nl>
  5. Date: 4 Mar 91 11:51:19 GMT
  6.  
  7. Archive-name: stdwin/part01
  8.  
  9. This is STDWIN version 0.9.5.  (The last digit of the version number is
  10. also the patchlevel, in case you're collecting patches.)
  11.  
  12. I am posting this mainly because it is needed to support the Python
  13. distribution that I recently put on alt.sources, not because it is a
  14. new product.  After being flamed for posting 21 parts of Python I
  15. hesitated to post STDWIN, but fan mail has convinced me to go ahead
  16. (it's still peanuts compared to alt.sex.pictures :-) ).
  17.  
  18. STDWIN is a simple windowing interface which makes (the windowing part
  19. of) your program portable between multiple platforms without requiring
  20. changes to your code -- just link with a different library and you are
  21. done.  Major platforms supported are the Mac and X11.  STDWIN programs
  22. can also run on alphanumeric terminals, under UNIX using termcap, and
  23. on MS-DOS using the alphanumeric screen.  It used to work on the Atari
  24. ST but I can't do any maintenance on that version.
  25.  
  26. STDWIN applications are event-based.  STDWIN supports multiple
  27. windows, dynamic menus with shortcuts, mouse and keyboard input,
  28. time-outs, automatic scroll bars, and a number of drawing primitives
  29. such as text (multiple fonts, variable-width), lines, circles and
  30. ellipses, arcs, shading and boxes.  A number of standard dialogs are
  31. also available: message, yes/no question, ask for string, ask for file
  32. name.
  33.  
  34. STDWIN is copyrighted, but can be freely copied and used as long as
  35. the copyright notice remains in place.
  36.  
  37. STDWIN is not supported, I can only do my best.  Most of it was
  38. created over three years ago, although support for X11 R4 is more
  39. recent, and I have polished it a little bit recently (added clipping
  40. and X11 selection support for instance).
  41.  
  42. If you want to port STDWIN to a new platform (Suntools, MS Windows and
  43. Motif are most wanted), contact me, I can give you some hints on how
  44. to start.  Beware: although porting a STDWIN-based application to
  45. another platform supported by STDWIN is a piece of cake, porting
  46. STDWIN itself to a new window system is a major undertaking.  You need
  47. a thorough understanding both of the underlying window system and of
  48. the STDWIN model.
  49.  
  50. Documentation (in troff -ms format) is provided -- some of the new
  51. features are undocumented except through the source and example
  52. applications though.
  53.  
  54. To get to know more, extract the files and read the README file.
  55.  
  56. I regularly put the latest STDWIN distribution on two anonymous ftp
  57. sites.  As the filename shows, to unpack this you need the programs
  58. uncompress and tar.
  59.  
  60.     site        hp4nl.nluug.nl (IP address 192.16.202.2)
  61.     directory    pub/windows
  62.     file        stdwin*.tar.Z (the * is the version, e.g. 0.9.5)
  63.  
  64.     site        wuarchive.wustl.edu (IP address 128.252.135.4)
  65.     directory    pub
  66.     file        stdwin*.tar.Z (the * is the version, e.g. 0.9.5)
  67.  
  68. Don't forget to specify binary file transfer mode!  ("type binary")
  69.  
  70. --Guido van Rossum <guido@cwi.nl>
  71.  
  72.     CWI, dept. CST
  73.     Kruislaan 413
  74.     1098 SJ  Amsterdam
  75.     The Netherlands
  76.  
  77. #! /bin/sh
  78. # This is a shell archive.  Remove anything before this line, then unpack
  79. # it by saving it into a file and typing "sh file".  To overwrite existing
  80. # files, type "sh file -c".  You can also feed this as standard input via
  81. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  82. # will see the following message at the end:
  83. #        "End of archive 1 (of 19)."
  84. # Contents:  README MANIFEST Appls Appls/bed Appls/dpv Appls/klok
  85. #   Appls/miniedit Appls/miniedit/regexp.c Appls/repeat Appls/test
  86. #   Appls/test/test3.c Appls/tetris Conf Doc Doc/man Gen H Packs
  87. #   Packs/textedit Packs/vt Ports Ports/alfa Ports/mac Ports/mac_mpw
  88. #   Ports/msdos Ports/vtrm Ports/vtrm/DIST Ports/x11 Tools
  89. # Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:22 1991
  90. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  91. if test -f 'README' -a "${1}" != "-c" ; then 
  92.   echo shar: Will not clobber existing file \"'README'\"
  93. else
  94. echo shar: Extracting \"'README'\" \(5626 characters\)
  95. sed "s/^X//" >'README' <<'END_OF_FILE'
  96. XSTDWIN INSTALLATION GUIDE
  97. X-------------------------
  98. X
  99. X[last edit: 4 March 1991]
  100. X
  101. X
  102. XWhat Is STDWIN
  103. X==============
  104. X
  105. XSTDWIN (STanDard Window INterface) is a simple windowing interface for
  106. Xwhich multiple implementations exist; currently, programs using STDWIN
  107. Xcan be made to run on Unix (using either alphanumeric terminals or the
  108. XX11 Window System), on the Apple Macintosh (using THINK C or MPW), or
  109. Xon MS-DOS with a dumb display (using Microsoft C).  If you insist, I
  110. Xalso have two versions for the Atari ST that need some dusting off.
  111. X
  112. XFor a longer introduction, read the (slightly outdated) file Doc/ABOUT.
  113. XFor more information on the Macintosh version, read Ports/mac/README,
  114. Xfor MS-DOS, read Ports/msdos/README.
  115. X
  116. XThis is version 0.9.5.  It is still a beta test version.
  117. X
  118. X
  119. XWhere To Get STDWIN
  120. X===================
  121. X
  122. XI regularly put the latest STDWIN distribution on two anonymous ftp
  123. Xsites.  As the filename shows, to unpack this you need the programs
  124. Xuncompress and tar.
  125. X
  126. X    site        hp4nl.nluug.nl (IP address 192.16.202.2)
  127. X    directory    pub/windows
  128. X    file        stdwin*.tar.Z (the * is the version, e.g. 0.9.5)
  129. X
  130. X    site        wuarchive.wustl.edu (IP address 128.252.135.4)
  131. X    directory    pub
  132. X    file        stdwin*.tar.Z (the * is the version, e.g. 0.9.5)
  133. X
  134. XDon't forget to specify binary file transfer mode!  ("type binary")
  135. X
  136. XI can also e-mail you a voluminous bunch of shar files but please try
  137. Xfinding a friend with ftp access first -- it's much more convenient
  138. Xfor all concerned.
  139. X
  140. X
  141. XGetting Started Right Now
  142. X=========================
  143. X
  144. XFor some common systems, the system knows how to configure itself
  145. Xautomatically.  This works for:
  146. X
  147. X    Hardware            Operating System
  148. X
  149. X    DEC VAX, DECstation        Ultrix 2.2 or 3.0
  150. X    Sun3, Sun4            SunOS 4.0 or 4.1
  151. X    Silicon Graphics Personal IRIS    IRIX 3.2 or 3.3
  152. X    Harris HCX-7 (tahoe)        BSD 4.3
  153. X
  154. X(For other OS versions on these or similar machines, give it a try
  155. Xanyway, it may work as well, especially if there is a program called
  156. X"arch" or "machine" that prints the machine type.)  To build STDWIN
  157. Xfor X11 on such systems:
  158. X
  159. X    cd Conf
  160. X    ./mkmf                # answer all questions with yes
  161. X    cd ..
  162. X    cd Build/<arch>/x11/lib        # <arch> is `machine` or `arch`
  163. X    make
  164. X
  165. XThis creates the STDWIN library for X11 on a file named "lib.a".
  166. XTo build the standard test/demo application, "miniedit" (first chdir
  167. Xback to the top of the STDWIN source tree):
  168. X
  169. X    cd Conf
  170. X    ./mkmf miniedit
  171. X    cd ..
  172. X    cd Build/<arch>/x11/miniedit
  173. X    make
  174. X
  175. XTo try it out, use it to have a look at the Makefile:
  176. X
  177. X    miniedit Makefile
  178. X
  179. X
  180. XIf It Doesn't Work Right Away
  181. X=============================
  182. X
  183. XYou may have to create new Makefile prototypes in subdirectory Conf, or
  184. Xfix the mkmf script there.
  185. X
  186. XThe configuration system works as follows.  Sources and objects live in
  187. Xseparate directories.  There are no tools like "imake" nor nonstandard
  188. Xmake features like "VPATH" used.  Instead, all Makefiles are generated
  189. Xby simple, easy-to-understand shell scripts living in Conf.  It is
  190. Xpossible to say "make" in any leaf subdirectory of Build.
  191. X
  192. XRead Conf/README for more information.
  193. X
  194. X
  195. XThe STDWIN source tree
  196. X======================
  197. X
  198. XThe STDWIN tree is organized as follows.  Starting from the top of the
  199. Xtree (where this README file lives), we have:
  200. X
  201. X    .        Top-level directory.
  202. X
  203. X    README        The file you are now reading.
  204. X
  205. X    H/        Public header files of STDWIN ports and
  206. X            packages.  Stdwin applications should pass this
  207. X            directory to the compiler in a "-I" option.
  208. X
  209. X    Tools/        Subroutines used by various ports and
  210. X            applications; not STDWIN-specific.
  211. X            (This has now been truncated to the bare
  212. X            minimum.)
  213. X
  214. X    Gen/        (Almost) generic versions of some STDWIN
  215. X            functions, used by more than one port.  (Some
  216. X            are dummies that ignore the request or always
  217. X            fail.)
  218. X
  219. X    Ports/        Source for various ports.
  220. X            Note: not all subdirectories are distributed!
  221. X
  222. X    Ports/x11/    Port to X11 R4; uses Xlib only.
  223. X    Ports/alfa/    Port for alphanumeric displays using termcap/terminfo.
  224. X    Ports/vtrm/    VTRM (virtual terminal) package used by Ports/alfa.
  225. X    Ports/atrm/    Amoeba support or verion for VTRM (old).
  226. X    Ports/proto/    Dummy routines to start a new port (ancient).
  227. X    Ports/stubs/    RPC-style stubs (ancient).
  228. X    Ports/mg1/    Obsolete Whitechapel MG-1 port.
  229. X    Ports/atari/    Atari ST port, for Mark Williams C compiler.
  230. X    Ports/atari_turbo/    (Newer) Atari ST port, for TurboC.
  231. X    Ports/mac/    Apple Macintosh port (both MPW and THINK C).
  232. X    Ports/msdos/    MS-DOS port (uses the alfa port mostly).
  233. X    (etc)
  234. X
  235. X    Packs/        Source for packages (libraries) on top of STDWIN.
  236. X
  237. X    Packs/textedit/    Standard text-editing package.
  238. X    Packs/vt/    Virtual terminal package (needs some work).
  239. X    packs/buttons/    Probably not useful, and broken.
  240. X
  241. X    Appls/        Source for test programs and real applications.
  242. X
  243. X    Appls/README    Read this for more information.
  244. X
  245. X    Doc/        Documentation for STDWIN and packages.
  246. X            Unfortunately this is terribly out of date.
  247. X
  248. X    Doc/ABOUT    Blurb to be sent to prospective users.
  249. X    Doc/paper.ms    The original paper (CWI report CS-R8817) (*troff -ms).
  250. X    (etc)
  251. X
  252. X    Conf/        Configuration scripts and prototype Makefiles.
  253. X
  254. X    Conf/README    Read this before twiddling the configuration.
  255. X    Conf/mkmf    Script to build Makefiles.
  256. X    Conf/mkall    Script to build Makefiles for allo applications.
  257. X    Conf/proto.*    Makefile fragments used by mkmf.
  258. X    Conf/*        Scripts used by mkmf.
  259. X
  260. X    Build/        Contains subdirectories where the various
  261. X            ports are built for various architectures.
  262. X
  263. X    Build/sun3/    Sun3 (680x0) under SunOS 4.1
  264. X    Build/sun4/    Sun4 (SPARC) under SunOS 4.1
  265. X    Build/sgi/    Silicon Graphics under IRIX 3.2
  266. X    Build/mips/    DEC RISC architecture under Ultrix 3.0
  267. X    Build/vax/    DEC VAX under Ultrix 2.2
  268. X    (etc)
  269. X
  270. X
  271. X--
  272. XGuido van Rossum, CWI, Amsterdam <guido@cwi.nl>
  273. X"The life of a Repo Man is always intense"
  274. END_OF_FILE
  275. if test 5626 -ne `wc -c <'README'`; then
  276.     echo shar: \"'README'\" unpacked with wrong size!
  277. fi
  278. # end of 'README'
  279. fi
  280. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  281.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  282. else
  283. echo shar: Extracting \"'MANIFEST'\" \(7822 characters\)
  284. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  285. X   File Name        Archive #    Description
  286. X-----------------------------------------------------------
  287. X README                     1    
  288. X MANIFEST                   1    
  289. X Appls                      1    
  290. X Appls/bed                  1    
  291. X Appls/bed/2x2              3    
  292. X Appls/bed/Dada            14    
  293. X Appls/bed/Make.proto      19    
  294. X Appls/bed/Woman           14    
  295. X Appls/bed/bed.c           13    
  296. X Appls/bed/bed.h           19    
  297. X Appls/bed/file.c          16    
  298. X Appls/bed/fmenu.c         16    
  299. X Appls/bed/menu.h          19    
  300. X Appls/bed/mmenu.c         17    
  301. X Appls/bed/mouse.c         11    
  302. X Appls/bed/opmenu.c        12    
  303. X Appls/dpv                  1    
  304. X Appls/dpv/Make.proto      19    
  305. X Appls/dpv/README          17    
  306. X Appls/dpv/To.do           19    
  307. X Appls/dpv/choose.c        10    
  308. X Appls/dpv/dpv.c           17    
  309. X Appls/dpv/dpv.h           19    
  310. X Appls/dpv/dpvcontrol.c    13    
  311. X Appls/dpv/dpvdoc.h        16    
  312. X Appls/dpv/dpvfonts.c       8    
  313. X Appls/dpv/dpvfunny.c      14    
  314. X Appls/dpv/dpvmachine.c    16    
  315. X Appls/dpv/dpvmachine.h    16    
  316. X Appls/dpv/dpvoutput.c      6    
  317. X Appls/dpv/dpvoutput.h     18    
  318. X Appls/dpv/dpvparse.c      14    
  319. X Appls/dpv/dpvrestart.c    14    
  320. X Appls/dpv/figtest         15    
  321. X Appls/dpv/funnyproto      19    
  322. X Appls/dpv/funnytab        17    
  323. X Appls/dpv/makefunny       19    
  324. X Appls/dpv/r3symbol        18    
  325. X Appls/dpv/symbol          19    
  326. X Appls/dpv/symbola         19    
  327. X Appls/dpv/trans           17    
  328. X Appls/klok                 1    
  329. X Appls/klok/Make.proto     19    
  330. X Appls/klok/amsetdate.c    19    
  331. X Appls/klok/bsdsetdate.c   17    
  332. X Appls/klok/klok.c          5    
  333. X Appls/miniedit             1    
  334. X Appls/miniedit/Make.proto 19    
  335. X Appls/miniedit/miniedit.c 12    
  336. X Appls/miniedit/regexp.c    1    
  337. X Appls/miniedit/regexp.h   19    
  338. X Appls/miniedit/regmagic.h 19    
  339. X Appls/miniedit/regsub.c   17    
  340. X Appls/repeat               1    
  341. X Appls/repeat/Make.proto   19    
  342. X Appls/repeat/repeat.c     12    
  343. X Appls/test                 1    
  344. X Appls/test/README         19    
  345. X Appls/test/bike.c         16    
  346. X Appls/test/bits.c         16    
  347. X Appls/test/charset.c      16    
  348. X Appls/test/dklok.c        16    
  349. X Appls/test/faced.c        12    
  350. X Appls/test/hello.c        18    
  351. X Appls/test/kuifje         18    
  352. X Appls/test/magic.c        14    
  353. X Appls/test/multiwin.c     17    
  354. X Appls/test/sevenseg.h     14    
  355. X Appls/test/test0.c        19    
  356. X Appls/test/test1.c         4    
  357. X Appls/test/test2.c        19    
  358. X Appls/test/test3.c         1    
  359. X Appls/test/test4.c        18    
  360. X Appls/test/test5.c        18    
  361. X Appls/test/testlocalmenus.c 18    
  362. X Appls/test/testpollevent.c 18    
  363. X Appls/test/thand.c        18    
  364. X Appls/test/vtdemo.c       18    
  365. X Appls/tetris               1    
  366. X Appls/tetris/Make.proto   19    
  367. X Appls/tetris/tetris.c      3    
  368. X Conf                       1    
  369. X Conf/README               10    
  370. X Conf/fastmkdep            19    
  371. X Conf/makemakefile         17    
  372. X Conf/mkall                19    
  373. X Conf/mkmf                 17    
  374. X Conf/proto.arch.68000     18    
  375. X Conf/proto.arch.mips      19    
  376. X Conf/proto.arch.sgi       19    
  377. X Conf/proto.arch.sun3      19    
  378. X Conf/proto.arch.sun4      19    
  379. X Conf/proto.arch.tahoe     19    
  380. X Conf/proto.arch.vax       19    
  381. X Conf/proto.arch.xxx       18    
  382. X Conf/proto.conf           17    
  383. X Conf/proto.os.amoeba      13    
  384. X Conf/proto.os.bsd          5    
  385. X Conf/proto.os.sony        18    
  386. X Conf/proto.os.sunos       19    
  387. X Conf/proto.os.sysv        18    
  388. X Conf/proto.os.ultrix      19    
  389. X Conf/proto.os.xxx         18    
  390. X Conf/proto.port.alfa      19    
  391. X Conf/proto.port.x11       19    
  392. X Conf/proto.port.xxx       18    
  393. X Conf/putlibmf             19    
  394. X Conf/putobjs              19    
  395. X Conf/putprogmf            19    
  396. X Conf/puttargets           19    
  397. X Conf/slowmkdep            19    
  398. X Doc                        1    
  399. X Doc/ABOUT                  6    
  400. X Doc/README                19    
  401. X Doc/macros.ms             18    
  402. X Doc/man                    1    
  403. X Doc/man/dpv.man           15    
  404. X Doc/man/editwin.man       10    
  405. X Doc/man/textedit.man      12    
  406. X Doc/man/vt.man            12    
  407. X Doc/man/x11stdwin.man     11    
  408. X Doc/paper.ms               2    
  409. X Doc/seldoc.ms              8    
  410. X Doc/vtrmdoc.ms             7    
  411. X Gen                        1    
  412. X Gen/waskfile.c            18    
  413. X Gen/waskync.c             19    
  414. X Gen/wdrawpar.c            17    
  415. X Gen/wperror.c             19    
  416. X Gen/wsetclip.c            19    
  417. X Gen/wsetcutbuffer.c       19    
  418. X Gen/wsetselection.c       19    
  419. X Gen/wstyle.c              19    
  420. X Gen/wtextbreak.c          17    
  421. X H                          1    
  422. X H/_ARGS.h                 18    
  423. X H/editwin.h               18    
  424. X H/endian.h                19    
  425. X H/filedefs.h              19    
  426. X H/lists.h                 16    
  427. X H/patchlevel.h            16    
  428. X H/sigtype.h               19    
  429. X H/stdwconf.h              19    
  430. X H/stdwin.h                11    
  431. X H/stdwtext.h              17    
  432. X H/style.h                 19    
  433. X H/tilist.h                19    
  434. X H/tools.h                 15    
  435. X H/vt.h                    14    
  436. X H/vtrm.h                  18    
  437. X H/vtserial.h              19    
  438. X H/winreq.h                16    
  439. X Packs                      1    
  440. X Packs/textedit             1    
  441. X Packs/textedit/editwin.c  11    
  442. X Packs/textedit/text.h     15    
  443. X Packs/textedit/textdbg.c  17    
  444. X Packs/textedit/textedit.c  6    
  445. X Packs/textedit/textlow.c   8    
  446. X Packs/textedit/wprintf.c  18    
  447. X Packs/vt                   1    
  448. X Packs/vt/To.do            19    
  449. X Packs/vt/vt.c              4    
  450. X Packs/vt/vtansi.c          9    
  451. X Packs/vt/vtfunc.c         14    
  452. X Packs/vt/vtimpl.h         18    
  453. X Packs/vt/vtpanic.c        19    
  454. X Packs/vt/vtputs.c         18    
  455. X Packs/vt/vtresize.c       16    
  456. X Packs/vt/vtselect.c       10    
  457. X Packs/vt/vtsend.c         19    
  458. X Packs/vt/vtusesend.c      19    
  459. X Packs/vt/vtvtrm.c         16    
  460. X Ports                      1    
  461. X Ports/alfa                 1    
  462. X Ports/alfa/BUGS           19    
  463. X Ports/alfa/Make.proto     19    
  464. X Ports/alfa/To.do          17    
  465. X Ports/alfa/alfa.h         15    
  466. X Ports/alfa/bind.c         12    
  467. X Ports/alfa/draw.c         10    
  468. X Ports/alfa/event.c        13    
  469. X Ports/alfa/keymap.c       15    
  470. X Ports/alfa/measure.c      18    
  471. X Ports/alfa/menu.c          5    
  472. X Ports/alfa/menu.h         19    
  473. X Ports/alfa/scroll.c       18    
  474. X Ports/alfa/stdwin.c        9    
  475. X Ports/alfa/syswin.c       13    
  476. X Ports/alfa/timer.c        14    
  477. X Ports/mac                  1    
  478. X Ports/mac/about.c         11    
  479. X Ports/mac/argcargv.c      18    
  480. X Ports/mac/caret.c         16    
  481. X Ports/mac/cursor.c        15    
  482. X Ports/mac/dialog.c        11    
  483. X Ports/mac/dprintf.c       17    
  484. X Ports/mac/draw.c           9    
  485. X Ports/mac/event.c          8    
  486. X Ports/mac/fullpath.c      18    
  487. X Ports/mac/macwin.h        13    
  488. X Ports/mac/menu.c          15    
  489. X Ports/mac/menu.h           8    
  490. X Ports/mac/pstring.c        2    
  491. X Ports/mac/scrap.c         17    
  492. X Ports/mac/scroll.c         7    
  493. X Ports/mac/stdwin.c        13    
  494. X Ports/mac/timer.c         17    
  495. X Ports/mac_mpw              1    
  496. X Ports/mac_mpw/Makefile    18    
  497. X Ports/mac_mpw/README      19    
  498. X Ports/mac_mpw/intercept.h 18    
  499. X Ports/mac_mpw/set_open_hook.c 15    
  500. X Ports/msdos                1    
  501. X Ports/msdos/README        19    
  502. X Ports/msdos/dir.c         15    
  503. X Ports/msdos/dir.h         19    
  504. X Ports/msdos/lib.          19    
  505. X Ports/msdos/ptrm.c         5    
  506. X Ports/vtrm                 1    
  507. X Ports/vtrm/DIST            1    
  508. X Ports/vtrm/DIST/README    17    
  509. X Ports/vtrm/DIST/pag.c     16    
  510. X Ports/vtrm/uxtty.c        14    
  511. X Ports/vtrm/vtrm.c          3    
  512. X Ports/vtrm/vtrm.h         18    
  513. X Ports/x11                  1    
  514. X Ports/x11/Make.proto      19    
  515. X Ports/x11/amtimer.c       15    
  516. X Ports/x11/caret.c         18    
  517. X Ports/x11/cursor.c        13    
  518. X Ports/x11/cutbuffer.c     18    
  519. X Ports/x11/dialog.c         6    
  520. X Ports/x11/draw.c          11    
  521. X Ports/x11/error.c         17    
  522. X Ports/x11/event.c         13    
  523. X Ports/x11/font.c          15    
  524. X Ports/x11/general.c        7    
  525. X Ports/x11/llevent.c        7    
  526. X Ports/x11/llevent.h       18    
  527. X Ports/x11/menu.c           9    
  528. X Ports/x11/scroll.c        16    
  529. X Ports/x11/selection.c     10    
  530. X Ports/x11/timer.c          9    
  531. X Ports/x11/window.c         4    
  532. X Ports/x11/x11.h           15    
  533. X Tools                      1    
  534. X Tools/getopt.c            17    
  535. X Tools/strdup.c            18    
  536. END_OF_FILE
  537. if test 7822 -ne `wc -c <'MANIFEST'`; then
  538.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  539. fi
  540. # end of 'MANIFEST'
  541. fi
  542. if test ! -d 'Appls' ; then
  543.     echo shar: Creating directory \"'Appls'\"
  544.     mkdir 'Appls'
  545. fi
  546. if test ! -d 'Appls/bed' ; then
  547.     echo shar: Creating directory \"'Appls/bed'\"
  548.     mkdir 'Appls/bed'
  549. fi
  550. if test ! -d 'Appls/dpv' ; then
  551.     echo shar: Creating directory \"'Appls/dpv'\"
  552.     mkdir 'Appls/dpv'
  553. fi
  554. if test ! -d 'Appls/klok' ; then
  555.     echo shar: Creating directory \"'Appls/klok'\"
  556.     mkdir 'Appls/klok'
  557. fi
  558. if test ! -d 'Appls/miniedit' ; then
  559.     echo shar: Creating directory \"'Appls/miniedit'\"
  560.     mkdir 'Appls/miniedit'
  561. fi
  562. if test -f 'Appls/miniedit/regexp.c' -a "${1}" != "-c" ; then 
  563.   echo shar: Will not clobber existing file \"'Appls/miniedit/regexp.c'\"
  564. else
  565. echo shar: Extracting \"'Appls/miniedit/regexp.c'\" \(31000 characters\)
  566. sed "s/^X//" >'Appls/miniedit/regexp.c' <<'END_OF_FILE'
  567. X/*
  568. X * regcomp and regexec -- regsub and regerror are elsewhere
  569. X *
  570. X *    Copyright (c) 1986 by University of Toronto.
  571. X *    Written by Henry Spencer.  Not derived from licensed software.
  572. X#ifdef MULTILINE
  573. X *    Changed by Guido van Rossum, CWI, Amsterdam
  574. X *    for multi-line support.
  575. X#endif
  576. X *
  577. X *    Permission is granted to anyone to use this software for any
  578. X *    purpose on any computer system, and to redistribute it freely,
  579. X *    subject to the following restrictions:
  580. X *
  581. X *    1. The author is not responsible for the consequences of use of
  582. X *        this software, no matter how awful, even if they arise
  583. X *        from defects in it.
  584. X *
  585. X *    2. The origin of this software must not be misrepresented, either
  586. X *        by explicit claim or by omission.
  587. X *
  588. X *    3. Altered versions must be plainly marked as such, and must not
  589. X *        be misrepresented as being the original software.
  590. X *
  591. X * Beware that some of this code is subtly aware of the way operator
  592. X * precedence is structured in regular expressions.  Serious changes in
  593. X * regular-expression syntax might require a total rethink.
  594. X */
  595. X#include <stdio.h>
  596. X#include "regexp.h"
  597. X#include "regmagic.h"
  598. X
  599. X#ifdef MULTILINE
  600. X/*
  601. X * Defining MULTILINE turns on the following changes in the semantics:
  602. X * 1.    The '.' operator matches all characters except a newline.
  603. X * 2.    The '^' operator matches at the beginning of the string or after
  604. X *    a newline.  (Anchored matches are retried after each newline.)
  605. X * 3.    The '$' operator matches at the end of the string or before
  606. X *    a newline.
  607. X * 4.    A '\' followed by an 'n' matches a newline.  (This is an
  608. X *    unfortunate exception to the rule that '\' followed by a
  609. X *    character matches that character...)
  610. X *
  611. X * Also, there is a new function reglexec(prog, string, offset)
  612. X * which searches for a match starting at 'string+offset';
  613. X * it differs from regexec(prog, string+offset) in assuming
  614. X * that the line begins at 'string'.
  615. X */
  616. X#endif
  617. X
  618. X/*
  619. X * The "internal use only" fields in regexp.h are present to pass info from
  620. X * compile to execute that permits the execute phase to run lots faster on
  621. X * simple cases.  They are:
  622. X *
  623. X * regstart    char that must begin a match; '\0' if none obvious
  624. X * reganch    is the match anchored (at beginning-of-line only)?
  625. X * regmust    string (pointer into program) that match must include, or NULL
  626. X * regmlen    length of regmust string
  627. X *
  628. X * Regstart and reganch permit very fast decisions on suitable starting points
  629. X * for a match, cutting down the work a lot.  Regmust permits fast rejection
  630. X * of lines that cannot possibly match.  The regmust tests are costly enough
  631. X * that regcomp() supplies a regmust only if the r.e. contains something
  632. X * potentially expensive (at present, the only such thing detected is * or +
  633. X * at the start of the r.e., which can involve a lot of backup).  Regmlen is
  634. X * supplied because the test in regexec() needs it and regcomp() is computing
  635. X * it anyway.
  636. X */
  637. X
  638. X/*
  639. X * Structure for regexp "program".  This is essentially a linear encoding
  640. X * of a nondeterministic finite-state machine (aka syntax charts or
  641. X * "railroad normal form" in parsing technology).  Each node is an opcode
  642. X * plus a "next" pointer, possibly plus an operand.  "Next" pointers of
  643. X * all nodes except BRANCH implement concatenation; a "next" pointer with
  644. X * a BRANCH on both ends of it is connecting two alternatives.  (Here we
  645. X * have one of the subtle syntax dependencies:  an individual BRANCH (as
  646. X * opposed to a collection of them) is never concatenated with anything
  647. X * because of operator precedence.)  The operand of some types of node is
  648. X * a literal string; for others, it is a node leading into a sub-FSM.  In
  649. X * particular, the operand of a BRANCH node is the first node of the branch.
  650. X * (NB this is *not* a tree structure:  the tail of the branch connects
  651. X * to the thing following the set of BRANCHes.)  The opcodes are:
  652. X */
  653. X
  654. X/* definition    number    opnd?    meaning */
  655. X#define    END    0    /* no    End of program. */
  656. X#define    BOL    1    /* no    Match "" at beginning of line. */
  657. X#define    EOL    2    /* no    Match "" at end of line. */
  658. X#define    ANY    3    /* no    Match any one character. */
  659. X#define    ANYOF    4    /* str    Match any character in this string. */
  660. X#define    ANYBUT    5    /* str    Match any character not in this string. */
  661. X#define    BRANCH    6    /* node    Match this alternative, or the next... */
  662. X#define    BACK    7    /* no    Match "", "next" ptr points backward. */
  663. X#define    EXACTLY    8    /* str    Match this string. */
  664. X#define    NOTHING    9    /* no    Match empty string. */
  665. X#define    STAR    10    /* node    Match this (simple) thing 0 or more times. */
  666. X#define    PLUS    11    /* node    Match this (simple) thing 1 or more times. */
  667. X#define    OPEN    20    /* no    Mark this point in input as start of #n. */
  668. X            /*    OPEN+1 is number 1, etc. */
  669. X#define    CLOSE    30    /* no    Analogous to OPEN. */
  670. X
  671. X/*
  672. X * Opcode notes:
  673. X *
  674. X * BRANCH    The set of branches constituting a single choice are hooked
  675. X *        together with their "next" pointers, since precedence prevents
  676. X *        anything being concatenated to any individual branch.  The
  677. X *        "next" pointer of the last BRANCH in a choice points to the
  678. X *        thing following the whole choice.  This is also where the
  679. X *        final "next" pointer of each individual branch points; each
  680. X *        branch starts with the operand node of a BRANCH node.
  681. X *
  682. X * BACK        Normal "next" pointers all implicitly point forward; BACK
  683. X *        exists to make loop structures possible.
  684. X *
  685. X * STAR,PLUS    '?', and complex '*' and '+', are implemented as circular
  686. X *        BRANCH structures using BACK.  Simple cases (one character
  687. X *        per match) are implemented with STAR and PLUS for speed
  688. X *        and to minimize recursive plunges.
  689. X *
  690. X * OPEN,CLOSE    ...are numbered at compile time.
  691. X */
  692. X
  693. X/*
  694. X * A node is one char of opcode followed by two chars of "next" pointer.
  695. X * "Next" pointers are stored as two 8-bit pieces, high order first.  The
  696. X * value is a positive offset from the opcode of the node containing it.
  697. X * An operand, if any, simply follows the node.  (Note that much of the
  698. X * code generation knows about this implicit relationship.)
  699. X *
  700. X * Using two bytes for the "next" pointer is vast overkill for most things,
  701. X * but allows patterns to get big without disasters.
  702. X */
  703. X#define    OP(p)    (*(p))
  704. X#define    NEXT(p)    (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
  705. X#define    OPERAND(p)    ((p) + 3)
  706. X
  707. X/*
  708. X * See regmagic.h for one further detail of program structure.
  709. X */
  710. X
  711. X
  712. X/*
  713. X * Utility definitions.
  714. X */
  715. X#ifndef CHARBITS
  716. X#define    UCHARAT(p)    ((int)*(unsigned char *)(p))
  717. X#else
  718. X#define    UCHARAT(p)    ((int)*(p)&CHARBITS)
  719. X#endif
  720. X
  721. X#define    FAIL(m)    { regerror(m); return(NULL); }
  722. X#define    ISMULT(c)    ((c) == '*' || (c) == '+' || (c) == '?')
  723. X#define    META    "^$.[()|?+*\\"
  724. X
  725. X/*
  726. X * Flags to be passed up and down.
  727. X */
  728. X#define    HASWIDTH    01    /* Known never to match null string. */
  729. X#define    SIMPLE        02    /* Simple enough to be STAR/PLUS operand. */
  730. X#define    SPSTART        04    /* Starts with * or +. */
  731. X#define    WORST        0    /* Worst case. */
  732. X
  733. X/*
  734. X * Global work variables for regcomp().
  735. X */
  736. Xstatic char *regparse;        /* Input-scan pointer. */
  737. Xstatic int regnpar;        /* () count. */
  738. Xstatic char regdummy;
  739. Xstatic char *regcode;        /* Code-emit pointer; ®dummy = don't. */
  740. Xstatic long regsize;        /* Code size. */
  741. X#ifdef MULTILINE
  742. Xstatic int regnl;        /* '\n' detected. */
  743. X#endif
  744. X
  745. X/*
  746. X * Forward declarations for regcomp()'s friends.
  747. X */
  748. X#ifndef STATIC
  749. X#define    STATIC    static
  750. X#endif
  751. XSTATIC char *reg();
  752. XSTATIC char *regbranch();
  753. XSTATIC char *regpiece();
  754. XSTATIC char *regatom();
  755. XSTATIC char *regnode();
  756. XSTATIC char *regnext();
  757. XSTATIC void regc();
  758. XSTATIC void reginsert();
  759. XSTATIC void regtail();
  760. XSTATIC void regoptail();
  761. X#ifdef STRCSPN
  762. XSTATIC int strcspn();
  763. X#endif
  764. X
  765. X/*
  766. X - regcomp - compile a regular expression into internal code
  767. X *
  768. X * We can't allocate space until we know how big the compiled form will be,
  769. X * but we can't compile it (and thus know how big it is) until we've got a
  770. X * place to put the code.  So we cheat:  we compile it twice, once with code
  771. X * generation turned off and size counting turned on, and once "for real".
  772. X * This also means that we don't allocate space until we are sure that the
  773. X * thing really will compile successfully, and we never have to move the
  774. X * code and thus invalidate pointers into it.  (Note that it has to be in
  775. X * one piece because free() must be able to free it all.)
  776. X *
  777. X * Beware that the optimization-preparation code in here knows about some
  778. X * of the structure of the compiled regexp.
  779. X */
  780. Xregexp *
  781. Xregcomp(exp)
  782. Xchar *exp;
  783. X{
  784. X    register regexp *r;
  785. X    register char *scan;
  786. X    register char *longest;
  787. X    register int len;
  788. X    int flags;
  789. X    extern char *malloc();
  790. X
  791. X    if (exp == NULL)
  792. X        FAIL("NULL argument");
  793. X
  794. X    /* First pass: determine size, legality. */
  795. X    regparse = exp;
  796. X    regnpar = 1;
  797. X    regsize = 0L;
  798. X    regcode = ®dummy;
  799. X#ifdef MULTILINE
  800. X    regnl = 0;
  801. X#endif
  802. X    regc(MAGIC);
  803. X    if (reg(0, &flags) == NULL)
  804. X        return(NULL);
  805. X
  806. X    /* Small enough for pointer-storage convention? */
  807. X    if (regsize >= 32767L)        /* Probably could be 65535L. */
  808. X        FAIL("regexp too big");
  809. X
  810. X    /* Allocate space. */
  811. X    r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize);
  812. X    if (r == NULL)
  813. X        FAIL("out of space");
  814. X
  815. X    /* Second pass: emit code. */
  816. X    regparse = exp;
  817. X    regnpar = 1;
  818. X    regcode = r->program;
  819. X    regc(MAGIC);
  820. X    if (reg(0, &flags) == NULL)
  821. X        return(NULL);
  822. X
  823. X    /* Dig out information for optimizations. */
  824. X    r->regstart = '\0';    /* Worst-case defaults. */
  825. X    r->reganch = 0;
  826. X    r->regmust = NULL;
  827. X    r->regmlen = 0;
  828. X    scan = r->program+1;            /* First BRANCH. */
  829. X    if (OP(regnext(scan)) == END) {        /* Only one top-level choice. */
  830. X        scan = OPERAND(scan);
  831. X
  832. X        /* Starting-point info. */
  833. X        if (OP(scan) == EXACTLY)
  834. X            r->regstart = *OPERAND(scan);
  835. X        else if (OP(scan) == BOL)
  836. X            r->reganch++;
  837. X
  838. X        /*
  839. X         * If there's something expensive in the r.e., find the
  840. X         * longest literal string that must appear and make it the
  841. X         * regmust.  Resolve ties in favor of later strings, since
  842. X         * the regstart check works with the beginning of the r.e.
  843. X         * and avoiding duplication strengthens checking.  Not a
  844. X         * strong reason, but sufficient in the absence of others.
  845. X         */
  846. X#ifdef MULTILINE
  847. X        if ((flags&SPSTART) && !regnl) {
  848. X#else
  849. X        if (flags&SPSTART) {
  850. X#endif
  851. X            longest = NULL;
  852. X            len = 0;
  853. X            for (; scan != NULL; scan = regnext(scan))
  854. X                if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
  855. X                    longest = OPERAND(scan);
  856. X                    len = strlen(OPERAND(scan));
  857. X                }
  858. X            r->regmust = longest;
  859. X            r->regmlen = len;
  860. X        }
  861. X    }
  862. X
  863. X    return(r);
  864. X}
  865. X
  866. X/*
  867. X - reg - regular expression, i.e. main body or parenthesized thing
  868. X *
  869. X * Caller must absorb opening parenthesis.
  870. X *
  871. X * Combining parenthesis handling with the base level of regular expression
  872. X * is a trifle forced, but the need to tie the tails of the branches to what
  873. X * follows makes it hard to avoid.
  874. X */
  875. Xstatic char *
  876. Xreg(paren, flagp)
  877. Xint paren;            /* Parenthesized? */
  878. Xint *flagp;
  879. X{
  880. X    register char *ret;
  881. X    register char *br;
  882. X    register char *ender;
  883. X    register int parno;
  884. X    int flags;
  885. X
  886. X    *flagp = HASWIDTH;    /* Tentatively. */
  887. X
  888. X    /* Make an OPEN node, if parenthesized. */
  889. X    if (paren) {
  890. X        if (regnpar >= NSUBEXP)
  891. X            FAIL("too many ()");
  892. X        parno = regnpar;
  893. X        regnpar++;
  894. X        ret = regnode(OPEN+parno);
  895. X    } else
  896. X        ret = NULL;
  897. X
  898. X    /* Pick up the branches, linking them together. */
  899. X    br = regbranch(&flags);
  900. X    if (br == NULL)
  901. X        return(NULL);
  902. X    if (ret != NULL)
  903. X        regtail(ret, br);    /* OPEN -> first. */
  904. X    else
  905. X        ret = br;
  906. X    if (!(flags&HASWIDTH))
  907. X        *flagp &= ~HASWIDTH;
  908. X    *flagp |= flags&SPSTART;
  909. X    while (*regparse == '|') {
  910. X        regparse++;
  911. X        br = regbranch(&flags);
  912. X        if (br == NULL)
  913. X            return(NULL);
  914. X        regtail(ret, br);    /* BRANCH -> BRANCH. */
  915. X        if (!(flags&HASWIDTH))
  916. X            *flagp &= ~HASWIDTH;
  917. X        *flagp |= flags&SPSTART;
  918. X    }
  919. X
  920. X    /* Make a closing node, and hook it on the end. */
  921. X    ender = regnode((paren) ? CLOSE+parno : END);    
  922. X    regtail(ret, ender);
  923. X
  924. X    /* Hook the tails of the branches to the closing node. */
  925. X    for (br = ret; br != NULL; br = regnext(br))
  926. X        regoptail(br, ender);
  927. X
  928. X    /* Check for proper termination. */
  929. X    if (paren && *regparse++ != ')') {
  930. X        FAIL("unmatched ()");
  931. X    } else if (!paren && *regparse != '\0') {
  932. X        if (*regparse == ')') {
  933. X            FAIL("unmatched ()");
  934. X        } else
  935. X            FAIL("junk on end");    /* "Can't happen". */
  936. X        /* NOTREACHED */
  937. X    }
  938. X
  939. X    return(ret);
  940. X}
  941. X
  942. X/*
  943. X - regbranch - one alternative of an | operator
  944. X *
  945. X * Implements the concatenation operator.
  946. X */
  947. Xstatic char *
  948. Xregbranch(flagp)
  949. Xint *flagp;
  950. X{
  951. X    register char *ret;
  952. X    register char *chain;
  953. X    register char *latest;
  954. X    int flags;
  955. X
  956. X    *flagp = WORST;        /* Tentatively. */
  957. X
  958. X    ret = regnode(BRANCH);
  959. X    chain = NULL;
  960. X    while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
  961. X        latest = regpiece(&flags);
  962. X        if (latest == NULL)
  963. X            return(NULL);
  964. X        *flagp |= flags&HASWIDTH;
  965. X        if (chain == NULL)    /* First piece. */
  966. X            *flagp |= flags&SPSTART;
  967. X        else
  968. X            regtail(chain, latest);
  969. X        chain = latest;
  970. X    }
  971. X    if (chain == NULL)    /* Loop ran zero times. */
  972. X        (void) regnode(NOTHING);
  973. X
  974. X    return(ret);
  975. X}
  976. X
  977. X/*
  978. X - regpiece - something followed by possible [*+?]
  979. X *
  980. X * Note that the branching code sequences used for ? and the general cases
  981. X * of * and + are somewhat optimized:  they use the same NOTHING node as
  982. X * both the endmarker for their branch list and the body of the last branch.
  983. X * It might seem that this node could be dispensed with entirely, but the
  984. X * endmarker role is not redundant.
  985. X */
  986. Xstatic char *
  987. Xregpiece(flagp)
  988. Xint *flagp;
  989. X{
  990. X    register char *ret;
  991. X    register char op;
  992. X    register char *next;
  993. X    int flags;
  994. X
  995. X    ret = regatom(&flags);
  996. X    if (ret == NULL)
  997. X        return(NULL);
  998. X
  999. X    op = *regparse;
  1000. X    if (!ISMULT(op)) {
  1001. X        *flagp = flags;
  1002. X        return(ret);
  1003. X    }
  1004. X
  1005. X    if (!(flags&HASWIDTH) && op != '?')
  1006. X        FAIL("*+ operand could be empty");
  1007. X    *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
  1008. X
  1009. X    if (op == '*' && (flags&SIMPLE))
  1010. X        reginsert(STAR, ret);
  1011. X    else if (op == '*') {
  1012. X        /* Emit x* as (x&|), where & means "self". */
  1013. X        reginsert(BRANCH, ret);            /* Either x */
  1014. X        regoptail(ret, regnode(BACK));        /* and loop */
  1015. X        regoptail(ret, ret);            /* back */
  1016. X        regtail(ret, regnode(BRANCH));        /* or */
  1017. X        regtail(ret, regnode(NOTHING));        /* null. */
  1018. X    } else if (op == '+' && (flags&SIMPLE))
  1019. X        reginsert(PLUS, ret);
  1020. X    else if (op == '+') {
  1021. X        /* Emit x+ as x(&|), where & means "self". */
  1022. X        next = regnode(BRANCH);            /* Either */
  1023. X        regtail(ret, next);
  1024. X        regtail(regnode(BACK), ret);        /* loop back */
  1025. X        regtail(next, regnode(BRANCH));        /* or */
  1026. X        regtail(ret, regnode(NOTHING));        /* null. */
  1027. X    } else if (op == '?') {
  1028. X        /* Emit x? as (x|) */
  1029. X        reginsert(BRANCH, ret);            /* Either x */
  1030. X        regtail(ret, regnode(BRANCH));        /* or */
  1031. X        next = regnode(NOTHING);        /* null. */
  1032. X        regtail(ret, next);
  1033. X        regoptail(ret, next);
  1034. X    }
  1035. X    regparse++;
  1036. X    if (ISMULT(*regparse))
  1037. X        FAIL("nested *?+");
  1038. X
  1039. X    return(ret);
  1040. X}
  1041. X
  1042. X/*
  1043. X - regatom - the lowest level
  1044. X *
  1045. X * Optimization:  gobbles an entire sequence of ordinary characters so that
  1046. X * it can turn them into a single node, which is smaller to store and
  1047. X * faster to run.  Backslashed characters are exceptions, each becoming a
  1048. X * separate node; the code is simpler that way and it's not worth fixing.
  1049. X */
  1050. Xstatic char *
  1051. Xregatom(flagp)
  1052. Xint *flagp;
  1053. X{
  1054. X    register char *ret;
  1055. X    int flags;
  1056. X
  1057. X    *flagp = WORST;        /* Tentatively. */
  1058. X
  1059. X    switch (*regparse++) {
  1060. X    case '^':
  1061. X        ret = regnode(BOL);
  1062. X        break;
  1063. X    case '$':
  1064. X        ret = regnode(EOL);
  1065. X        break;
  1066. X    case '.':
  1067. X        ret = regnode(ANY);
  1068. X        *flagp |= HASWIDTH|SIMPLE;
  1069. X        break;
  1070. X    case '[': {
  1071. X            register int class;
  1072. X            register int classend;
  1073. X
  1074. X            if (*regparse == '^') {    /* Complement of range. */
  1075. X                ret = regnode(ANYBUT);
  1076. X                regparse++;
  1077. X            } else
  1078. X                ret = regnode(ANYOF);
  1079. X            if (*regparse == ']' || *regparse == '-')
  1080. X                regc(*regparse++);
  1081. X            while (*regparse != '\0' && *regparse != ']') {
  1082. X                if (*regparse == '-') {
  1083. X                    regparse++;
  1084. X                    if (*regparse == ']' || *regparse == '\0')
  1085. X                        regc('-');
  1086. X                    else {
  1087. X                        class = UCHARAT(regparse-2)+1;
  1088. X                        classend = UCHARAT(regparse);
  1089. X                        if (class > classend+1)
  1090. X                            FAIL("invalid [] range");
  1091. X                        for (; class <= classend; class++)
  1092. X                            regc(class);
  1093. X                        regparse++;
  1094. X                    }
  1095. X                } else
  1096. X                    regc(*regparse++);
  1097. X            }
  1098. X            regc('\0');
  1099. X            if (*regparse != ']')
  1100. X                FAIL("unmatched []");
  1101. X            regparse++;
  1102. X            *flagp |= HASWIDTH|SIMPLE;
  1103. X        }
  1104. X        break;
  1105. X    case '(':
  1106. X        ret = reg(1, &flags);
  1107. X        if (ret == NULL)
  1108. X            return(NULL);
  1109. X        *flagp |= flags&(HASWIDTH|SPSTART);
  1110. X        break;
  1111. X    case '\0':
  1112. X    case '|':
  1113. X    case ')':
  1114. X        FAIL("internal urp");    /* Supposed to be caught earlier. */
  1115. X        break;
  1116. X    case '?':
  1117. X    case '+':
  1118. X    case '*':
  1119. X        FAIL("?+* follows nothing");
  1120. X        break;
  1121. X    case '\\':
  1122. X        if (*regparse == '\0')
  1123. X            FAIL("trailing \\");
  1124. X        ret = regnode(EXACTLY);
  1125. X#ifdef MULTILINE
  1126. X        if (*regparse == 'n') {
  1127. X            regc('\n');
  1128. X            regparse++;
  1129. X            regnl++;
  1130. X        }
  1131. X        else
  1132. X#endif
  1133. X        regc(*regparse++);
  1134. X        regc('\0');
  1135. X        *flagp |= HASWIDTH|SIMPLE;
  1136. X        break;
  1137. X    default: {
  1138. X            register int len;
  1139. X            register char ender;
  1140. X
  1141. X            regparse--;
  1142. X            len = strcspn(regparse, META);
  1143. X            if (len <= 0)
  1144. X                FAIL("internal disaster");
  1145. X            ender = *(regparse+len);
  1146. X            if (len > 1 && ISMULT(ender))
  1147. X                len--;        /* Back off clear of ?+* operand. */
  1148. X            *flagp |= HASWIDTH;
  1149. X            if (len == 1)
  1150. X                *flagp |= SIMPLE;
  1151. X            ret = regnode(EXACTLY);
  1152. X            while (len > 0) {
  1153. X#ifdef MULTILINE
  1154. X                if (*regparse == '\n')
  1155. X                    regnl++;
  1156. X#endif
  1157. X                regc(*regparse++);
  1158. X                len--;
  1159. X            }
  1160. X            regc('\0');
  1161. X        }
  1162. X        break;
  1163. X    }
  1164. X
  1165. X    return(ret);
  1166. X}
  1167. X
  1168. X/*
  1169. X - regnode - emit a node
  1170. X */
  1171. Xstatic char *            /* Location. */
  1172. Xregnode(op)
  1173. Xchar op;
  1174. X{
  1175. X    register char *ret;
  1176. X    register char *ptr;
  1177. X
  1178. X    ret = regcode;
  1179. X    if (ret == ®dummy) {
  1180. X        regsize += 3;
  1181. X        return(ret);
  1182. X    }
  1183. X
  1184. X    ptr = ret;
  1185. X    *ptr++ = op;
  1186. X    *ptr++ = '\0';        /* Null "next" pointer. */
  1187. X    *ptr++ = '\0';
  1188. X    regcode = ptr;
  1189. X
  1190. X    return(ret);
  1191. X}
  1192. X
  1193. X/*
  1194. X - regc - emit (if appropriate) a byte of code
  1195. X */
  1196. Xstatic void
  1197. Xregc(b)
  1198. Xchar b;
  1199. X{
  1200. X    if (regcode != ®dummy)
  1201. X        *regcode++ = b;
  1202. X    else
  1203. X        regsize++;
  1204. X}
  1205. X
  1206. X/*
  1207. X - reginsert - insert an operator in front of already-emitted operand
  1208. X *
  1209. X * Means relocating the operand.
  1210. X */
  1211. Xstatic void
  1212. Xreginsert(op, opnd)
  1213. Xchar op;
  1214. Xchar *opnd;
  1215. X{
  1216. X    register char *src;
  1217. X    register char *dst;
  1218. X    register char *place;
  1219. X
  1220. X    if (regcode == ®dummy) {
  1221. X        regsize += 3;
  1222. X        return;
  1223. X    }
  1224. X
  1225. X    src = regcode;
  1226. X    regcode += 3;
  1227. X    dst = regcode;
  1228. X    while (src > opnd)
  1229. X        *--dst = *--src;
  1230. X
  1231. X    place = opnd;        /* Op node, where operand used to be. */
  1232. X    *place++ = op;
  1233. X    *place++ = '\0';
  1234. X    *place++ = '\0';
  1235. X}
  1236. X
  1237. X/*
  1238. X - regtail - set the next-pointer at the end of a node chain
  1239. X */
  1240. Xstatic void
  1241. Xregtail(p, val)
  1242. Xchar *p;
  1243. Xchar *val;
  1244. X{
  1245. X    register char *scan;
  1246. X    register char *temp;
  1247. X    register int offset;
  1248. X
  1249. X    if (p == ®dummy)
  1250. X        return;
  1251. X
  1252. X    /* Find last node. */
  1253. X    scan = p;
  1254. X    for (;;) {
  1255. X        temp = regnext(scan);
  1256. X        if (temp == NULL)
  1257. X            break;
  1258. X        scan = temp;
  1259. X    }
  1260. X
  1261. X    if (OP(scan) == BACK)
  1262. X        offset = scan - val;
  1263. X    else
  1264. X        offset = val - scan;
  1265. X    *(scan+1) = (offset>>8)&0377;
  1266. X    *(scan+2) = offset&0377;
  1267. X}
  1268. X
  1269. X/*
  1270. X - regoptail - regtail on operand of first argument; nop if operandless
  1271. X */
  1272. Xstatic void
  1273. Xregoptail(p, val)
  1274. Xchar *p;
  1275. Xchar *val;
  1276. X{
  1277. X    /* "Operandless" and "op != BRANCH" are synonymous in practice. */
  1278. X    if (p == NULL || p == ®dummy || OP(p) != BRANCH)
  1279. X        return;
  1280. X    regtail(OPERAND(p), val);
  1281. X}
  1282. X
  1283. X/*
  1284. X * regexec and friends
  1285. X */
  1286. X
  1287. X/*
  1288. X * Global work variables for regexec().
  1289. X */
  1290. Xstatic char *reginput;        /* String-input pointer. */
  1291. Xstatic char *regbol;        /* Beginning of input, for ^ check. */
  1292. Xstatic char **regstartp;    /* Pointer to startp array. */
  1293. Xstatic char **regendp;        /* Ditto for endp. */
  1294. X
  1295. X/*
  1296. X * Forwards.
  1297. X */
  1298. XSTATIC int regtry();
  1299. XSTATIC int regmatch();
  1300. XSTATIC int regrepeat();
  1301. X
  1302. X#ifdef DEBUG
  1303. Xint regnarrate = 0;
  1304. Xvoid regdump();
  1305. XSTATIC char *regprop();
  1306. X#endif
  1307. X
  1308. X/*
  1309. X - regexec - match a regexp against a string
  1310. X */
  1311. Xint
  1312. Xregexec(prog, string)
  1313. Xregister regexp *prog;
  1314. Xregister char *string;
  1315. X{
  1316. X    register char *s;
  1317. X    extern char *strchr();
  1318. X
  1319. X    /* Be paranoid... */
  1320. X    if (prog == NULL || string == NULL) {
  1321. X        regerror("NULL parameter");
  1322. X        return(0);
  1323. X    }
  1324. X
  1325. X#ifdef MULTILINE
  1326. X    /* Check for \n in string, and if so, call the more general routine. */
  1327. X    if (strchr(string, '\n') != NULL)
  1328. X        return reglexec(prog, string, 0);
  1329. X#endif
  1330. X
  1331. X    /* Check validity of program. */
  1332. X    if (UCHARAT(prog->program) != MAGIC) {
  1333. X        regerror("corrupted program");
  1334. X        return(0);
  1335. X    }
  1336. X
  1337. X    /* If there is a "must appear" string, look for it. */
  1338. X    if (prog->regmust != NULL) {
  1339. X        s = string;
  1340. X        while ((s = strchr(s, prog->regmust[0])) != NULL) {
  1341. X            if (strncmp(s, prog->regmust, prog->regmlen) == 0)
  1342. X                break;    /* Found it. */
  1343. X            s++;
  1344. X        }
  1345. X        if (s == NULL)    /* Not present. */
  1346. X            return(0);
  1347. X    }
  1348. X
  1349. X    /* Mark beginning of line for ^ . */
  1350. X    regbol = string;
  1351. X
  1352. X    /* Simplest case:  anchored match need be tried only once. */
  1353. X    if (prog->reganch)
  1354. X        return(regtry(prog, string));
  1355. X
  1356. X    /* Messy cases:  unanchored match. */
  1357. X    s = string;
  1358. X    if (prog->regstart != '\0')
  1359. X        /* We know what char it must start with. */
  1360. X        while ((s = strchr(s, prog->regstart)) != NULL) {
  1361. X            if (regtry(prog, s))
  1362. X                return(1);
  1363. X            s++;
  1364. X        }
  1365. X    else
  1366. X        /* We don't -- general case. */
  1367. X        do {
  1368. X            if (regtry(prog, s))
  1369. X                return(1);
  1370. X        } while (*s++ != '\0');
  1371. X
  1372. X    /* Failure. */
  1373. X    return(0);
  1374. X}
  1375. X
  1376. X#ifdef MULTILINE
  1377. X/*
  1378. X - reglexec - match a regexp against a long string buffer, starting at offset
  1379. X */
  1380. Xint
  1381. Xreglexec(prog, string, offset)
  1382. Xregister regexp *prog;
  1383. Xregister char *string;
  1384. X{
  1385. X    register char *s;
  1386. X    extern char *strchr();
  1387. X
  1388. X    /* Be paranoid... */
  1389. X    if (prog == NULL || string == NULL) {
  1390. X        regerror("NULL parameter");
  1391. X        return(0);
  1392. X    }
  1393. X
  1394. X    /* Check validity of program. */
  1395. X    if (UCHARAT(prog->program) != MAGIC) {
  1396. X        regerror("corrupted program");
  1397. X        return(0);
  1398. X    }
  1399. X
  1400. X    /* (Don't look for "must appear" string -- string can be long.) */
  1401. X
  1402. X    /* Mark beginning of line for ^ . */
  1403. X    regbol = string;
  1404. X    
  1405. X    /* Apply offset.
  1406. X       Assume 0 <= offset <= strlen(string), but don't check,
  1407. X       as string can be long. */
  1408. X    s= string + offset;
  1409. X
  1410. X    /* Anchored match need be tried only at line starts. */
  1411. X    if (prog->reganch) {
  1412. X        while (!regtry(prog, s)) {
  1413. X            s = strchr(s, '\n');
  1414. X            if (s == NULL)
  1415. X                return(0);
  1416. X            s++;
  1417. X        }
  1418. X        return(1);
  1419. X    }
  1420. X
  1421. X    /* Messy cases:  unanchored match. */
  1422. X    if (prog->regstart != '\0')
  1423. X        /* We know what char it must start with. */
  1424. X        while ((s = strchr(s, prog->regstart)) != NULL) {
  1425. X            if (regtry(prog, s))
  1426. X                return(1);
  1427. X            s++;
  1428. X        }
  1429. X    else
  1430. X        /* We don't -- general case. */
  1431. X        do {
  1432. X            if (regtry(prog, s))
  1433. X                return(1);
  1434. X        } while (*s++ != '\0');
  1435. X
  1436. X    /* Failure. */
  1437. X    return(0);
  1438. X}
  1439. X#endif
  1440. X
  1441. X/*
  1442. X - regtry - try match at specific point
  1443. X */
  1444. Xstatic int            /* 0 failure, 1 success */
  1445. Xregtry(prog, string)
  1446. Xregexp *prog;
  1447. Xchar *string;
  1448. X{
  1449. X    register int i;
  1450. X    register char **sp;
  1451. X    register char **ep;
  1452. X
  1453. X    reginput = string;
  1454. X    regstartp = prog->startp;
  1455. X    regendp = prog->endp;
  1456. X
  1457. X    sp = prog->startp;
  1458. X    ep = prog->endp;
  1459. X    for (i = NSUBEXP; i > 0; i--) {
  1460. X        *sp++ = NULL;
  1461. X        *ep++ = NULL;
  1462. X    }
  1463. X    if (regmatch(prog->program + 1)) {
  1464. X        prog->startp[0] = string;
  1465. X        prog->endp[0] = reginput;
  1466. X        return(1);
  1467. X    } else
  1468. X        return(0);
  1469. X}
  1470. X
  1471. X/*
  1472. X - regmatch - main matching routine
  1473. X *
  1474. X * Conceptually the strategy is simple:  check to see whether the current
  1475. X * node matches, call self recursively to see whether the rest matches,
  1476. X * and then act accordingly.  In practice we make some effort to avoid
  1477. X * recursion, in particular by going through "ordinary" nodes (that don't
  1478. X * need to know whether the rest of the match failed) by a loop instead of
  1479. X * by recursion.
  1480. X */
  1481. Xstatic int            /* 0 failure, 1 success */
  1482. Xregmatch(prog)
  1483. Xchar *prog;
  1484. X{
  1485. X    register char *scan;    /* Current node. */
  1486. X    char *next;        /* Next node. */
  1487. X    extern char *strchr();
  1488. X
  1489. X    scan = prog;
  1490. X#ifdef DEBUG
  1491. X    if (scan != NULL && regnarrate)
  1492. X        fprintf(stderr, "%s(\n", regprop(scan));
  1493. X#endif
  1494. X    while (scan != NULL) {
  1495. X#ifdef DEBUG
  1496. X        if (regnarrate)
  1497. X            fprintf(stderr, "%s...\n", regprop(scan));
  1498. X#endif
  1499. X        next = regnext(scan);
  1500. X
  1501. X        switch (OP(scan)) {
  1502. X        case BOL:
  1503. X#ifdef MULTILINE
  1504. X            if (!(reginput == regbol ||
  1505. X                reginput > regbol && *(reginput-1) == '\n'))
  1506. X#else
  1507. X            if (reginput != regbol)
  1508. X#endif
  1509. X                return(0);
  1510. X            break;
  1511. X        case EOL:
  1512. X#ifdef MULTILINE
  1513. X            if (*reginput != '\0' && *reginput != '\n')
  1514. X#else
  1515. X            if (*reginput != '\0')
  1516. X#endif
  1517. X                return(0);
  1518. X            break;
  1519. X        case ANY:
  1520. X#ifdef MULTILINE
  1521. X            if (*reginput == '\0' || *reginput == '\n')
  1522. X#else
  1523. X            if (*reginput == '\0')
  1524. X#endif
  1525. X                return(0);
  1526. X            reginput++;
  1527. X            break;
  1528. X        case EXACTLY: {
  1529. X                register int len;
  1530. X                register char *opnd;
  1531. X
  1532. X                opnd = OPERAND(scan);
  1533. X                /* Inline the first character, for speed. */
  1534. X                if (*opnd != *reginput)
  1535. X                    return(0);
  1536. X                len = strlen(opnd);
  1537. X                if (len > 1 && strncmp(opnd, reginput, len) != 0)
  1538. X                    return(0);
  1539. X                reginput += len;
  1540. X            }
  1541. X            break;
  1542. X        case ANYOF:
  1543. X            if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
  1544. X                return(0);
  1545. X            reginput++;
  1546. X            break;
  1547. X        case ANYBUT:
  1548. X#ifdef MULTILINE
  1549. X            if (*reginput == '\0' || *reginput == '\n' ||
  1550. X                strchr(OPERAND(scan), *reginput) != NULL)
  1551. X#else
  1552. X            if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
  1553. X#endif
  1554. X                return(0);
  1555. X            reginput++;
  1556. X            break;
  1557. X        case NOTHING:
  1558. X            break;
  1559. X        case BACK:
  1560. X            break;
  1561. X        case OPEN+1:
  1562. X        case OPEN+2:
  1563. X        case OPEN+3:
  1564. X        case OPEN+4:
  1565. X        case OPEN+5:
  1566. X        case OPEN+6:
  1567. X        case OPEN+7:
  1568. X        case OPEN+8:
  1569. X        case OPEN+9: {
  1570. X                register int no;
  1571. X                register char *save;
  1572. X
  1573. X                no = OP(scan) - OPEN;
  1574. X                save = reginput;
  1575. X
  1576. X                if (regmatch(next)) {
  1577. X                    /*
  1578. X                     * Don't set startp if some later
  1579. X                     * invocation of the same parentheses
  1580. X                     * already has.
  1581. X                     */
  1582. X                    if (regstartp[no] == NULL)
  1583. X                        regstartp[no] = save;
  1584. X                    return(1);
  1585. X                } else
  1586. X                    return(0);
  1587. X            }
  1588. X            break;
  1589. X        case CLOSE+1:
  1590. X        case CLOSE+2:
  1591. X        case CLOSE+3:
  1592. X        case CLOSE+4:
  1593. X        case CLOSE+5:
  1594. X        case CLOSE+6:
  1595. X        case CLOSE+7:
  1596. X        case CLOSE+8:
  1597. X        case CLOSE+9: {
  1598. X                register int no;
  1599. X                register char *save;
  1600. X
  1601. X                no = OP(scan) - CLOSE;
  1602. X                save = reginput;
  1603. X
  1604. X                if (regmatch(next)) {
  1605. X                    /*
  1606. X                     * Don't set endp if some later
  1607. X                     * invocation of the same parentheses
  1608. X                     * already has.
  1609. X                     */
  1610. X                    if (regendp[no] == NULL)
  1611. X                        regendp[no] = save;
  1612. X                    return(1);
  1613. X                } else
  1614. X                    return(0);
  1615. X            }
  1616. X            break;
  1617. X        case BRANCH: {
  1618. X                register char *save;
  1619. X
  1620. X                if (OP(next) != BRANCH)        /* No choice. */
  1621. X                    next = OPERAND(scan);    /* Avoid recursion. */
  1622. X                else {
  1623. X                    do {
  1624. X                        save = reginput;
  1625. X                        if (regmatch(OPERAND(scan)))
  1626. X                            return(1);
  1627. X                        reginput = save;
  1628. X                        scan = regnext(scan);
  1629. X                    } while (scan != NULL && OP(scan) == BRANCH);
  1630. X                    return(0);
  1631. X                    /* NOTREACHED */
  1632. X                }
  1633. X            }
  1634. X            break;
  1635. X        case STAR:
  1636. X        case PLUS: {
  1637. X                register char nextch;
  1638. X                register int no;
  1639. X                register char *save;
  1640. X                register int min;
  1641. X
  1642. X                /*
  1643. X                 * Lookahead to avoid useless match attempts
  1644. X                 * when we know what character comes next.
  1645. X                 */
  1646. X                nextch = '\0';
  1647. X                if (OP(next) == EXACTLY)
  1648. X                    nextch = *OPERAND(next);
  1649. X                min = (OP(scan) == STAR) ? 0 : 1;
  1650. X                save = reginput;
  1651. X                no = regrepeat(OPERAND(scan));
  1652. X                while (no >= min) {
  1653. X                    /* If it could work, try it. */
  1654. X                    if (nextch == '\0' || *reginput == nextch)
  1655. X                        if (regmatch(next))
  1656. X                            return(1);
  1657. X                    /* Couldn't or didn't -- back up. */
  1658. X                    no--;
  1659. X                    reginput = save + no;
  1660. X                }
  1661. X                return(0);
  1662. X            }
  1663. X            break;
  1664. X        case END:
  1665. X            return(1);    /* Success! */
  1666. X            break;
  1667. X        default:
  1668. X            regerror("memory corruption");
  1669. X            return(0);
  1670. X            break;
  1671. X        }
  1672. X
  1673. X        scan = next;
  1674. X    }
  1675. X
  1676. X    /*
  1677. X     * We get here only if there's trouble -- normally "case END" is
  1678. X     * the terminating point.
  1679. X     */
  1680. X    regerror("corrupted pointers");
  1681. X    return(0);
  1682. X}
  1683. X
  1684. X/*
  1685. X - regrepeat - repeatedly match something simple, report how many
  1686. X */
  1687. Xstatic int
  1688. Xregrepeat(p)
  1689. Xchar *p;
  1690. X{
  1691. X    register int count = 0;
  1692. X    register char *scan;
  1693. X    register char *opnd;
  1694. X#ifdef MULTILINE
  1695. X    register char *eol;
  1696. X#endif
  1697. X
  1698. X    scan = reginput;
  1699. X    opnd = OPERAND(p);
  1700. X    switch (OP(p)) {
  1701. X    case ANY:
  1702. X#ifdef MULTILINE
  1703. X        if ((eol = strchr(scan, '\n')) != NULL) {
  1704. X            count += eol - scan;
  1705. X            scan = eol;
  1706. X            break;
  1707. X        }
  1708. X#endif
  1709. X        count = strlen(scan);
  1710. X        scan += count;
  1711. X        break;
  1712. X    case EXACTLY:
  1713. X        while (*opnd == *scan) {
  1714. X            count++;
  1715. X            scan++;
  1716. X        }
  1717. X        break;
  1718. X    case ANYOF:
  1719. X        while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
  1720. X            count++;
  1721. X            scan++;
  1722. X        }
  1723. X        break;
  1724. X    case ANYBUT:
  1725. X#ifdef MULTILINE
  1726. X        while (*scan != '\0' && *scan != '\n' &&
  1727. X            strchr(opnd, *scan) == NULL) {
  1728. X#else
  1729. X        while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
  1730. X#endif
  1731. X            count++;
  1732. X            scan++;
  1733. X        }
  1734. X        break;
  1735. X    default:        /* Oh dear.  Called inappropriately. */
  1736. X        regerror("internal foulup");
  1737. X        count = 0;    /* Best compromise. */
  1738. X        break;
  1739. X    }
  1740. X    reginput = scan;
  1741. X
  1742. X    return(count);
  1743. X}
  1744. X
  1745. X/*
  1746. X - regnext - dig the "next" pointer out of a node
  1747. X */
  1748. Xstatic char *
  1749. Xregnext(p)
  1750. Xregister char *p;
  1751. X{
  1752. X    register int offset;
  1753. X
  1754. X    if (p == ®dummy)
  1755. X        return(NULL);
  1756. X
  1757. X    offset = NEXT(p);
  1758. X    if (offset == 0)
  1759. X        return(NULL);
  1760. X
  1761. X    if (OP(p) == BACK)
  1762. X        return(p-offset);
  1763. X    else
  1764. X        return(p+offset);
  1765. X}
  1766. X
  1767. X#ifdef DEBUG
  1768. X
  1769. XSTATIC char *regprop();
  1770. X
  1771. X/*
  1772. X - regdump - dump a regexp onto stdout in vaguely comprehensible form
  1773. X */
  1774. Xvoid
  1775. Xregdump(r)
  1776. Xregexp *r;
  1777. X{
  1778. X    register char *s;
  1779. X    register char op = EXACTLY;    /* Arbitrary non-END op. */
  1780. X    register char *next;
  1781. X    extern char *strchr();
  1782. X
  1783. X
  1784. X    s = r->program + 1;
  1785. X    while (op != END) {    /* While that wasn't END last time... */
  1786. X        op = OP(s);
  1787. X        printf("%2d%s", s-r->program, regprop(s));    /* Where, what. */
  1788. X        next = regnext(s);
  1789. X        if (next == NULL)        /* Next ptr. */
  1790. X            printf("(0)");
  1791. X        else 
  1792. X            printf("(%d)", (s-r->program)+(next-s));
  1793. X        s += 3;
  1794. X        if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
  1795. X            /* Literal string, where present. */
  1796. X            while (*s != '\0') {
  1797. X#ifdef MULTILINE
  1798. X                if (*s == '\n')
  1799. X                    printf("\\n");
  1800. X                else
  1801. X#endif
  1802. X                putchar(*s);
  1803. X                s++;
  1804. X            }
  1805. X            s++;
  1806. X        }
  1807. X        putchar('\n');
  1808. X    }
  1809. X
  1810. X    /* Header fields of interest. */
  1811. X    if (r->regstart != '\0')
  1812. X        printf("start `%c' ", r->regstart);
  1813. X    if (r->reganch)
  1814. X        printf("anchored ");
  1815. X    if (r->regmust != NULL)
  1816. X        printf("must have \"%s\"", r->regmust);
  1817. X    printf("\n");
  1818. X}
  1819. X
  1820. X/*
  1821. X - regprop - printable representation of opcode
  1822. X */
  1823. Xstatic char *
  1824. Xregprop(op)
  1825. Xchar *op;
  1826. X{
  1827. X    register char *p;
  1828. X    static char buf[50];
  1829. X
  1830. X    (void) strcpy(buf, ":");
  1831. X
  1832. X    switch (OP(op)) {
  1833. X    case BOL:
  1834. X        p = "BOL";
  1835. X        break;
  1836. X    case EOL:
  1837. X        p = "EOL";
  1838. X        break;
  1839. X    case ANY:
  1840. X        p = "ANY";
  1841. X        break;
  1842. X    case ANYOF:
  1843. X        p = "ANYOF";
  1844. X        break;
  1845. X    case ANYBUT:
  1846. X        p = "ANYBUT";
  1847. X        break;
  1848. X    case BRANCH:
  1849. X        p = "BRANCH";
  1850. X        break;
  1851. X    case EXACTLY:
  1852. X        p = "EXACTLY";
  1853. X        break;
  1854. X    case NOTHING:
  1855. X        p = "NOTHING";
  1856. X        break;
  1857. X    case BACK:
  1858. X        p = "BACK";
  1859. X        break;
  1860. X    case END:
  1861. X        p = "END";
  1862. X        break;
  1863. X    case OPEN+1:
  1864. X    case OPEN+2:
  1865. X    case OPEN+3:
  1866. X    case OPEN+4:
  1867. X    case OPEN+5:
  1868. X    case OPEN+6:
  1869. X    case OPEN+7:
  1870. X    case OPEN+8:
  1871. X    case OPEN+9:
  1872. X        sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
  1873. X        p = NULL;
  1874. X        break;
  1875. X    case CLOSE+1:
  1876. X    case CLOSE+2:
  1877. X    case CLOSE+3:
  1878. X    case CLOSE+4:
  1879. X    case CLOSE+5:
  1880. X    case CLOSE+6:
  1881. X    case CLOSE+7:
  1882. X    case CLOSE+8:
  1883. X    case CLOSE+9:
  1884. X        sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
  1885. X        p = NULL;
  1886. X        break;
  1887. X    case STAR:
  1888. X        p = "STAR";
  1889. X        break;
  1890. X    case PLUS:
  1891. X        p = "PLUS";
  1892. X        break;
  1893. X    default:
  1894. X        regerror("corrupted opcode");
  1895. X        break;
  1896. X    }
  1897. X    if (p != NULL)
  1898. X        (void) strcat(buf, p);
  1899. X    return(buf);
  1900. X}
  1901. X#endif
  1902. X
  1903. X/*
  1904. X * The following is provided for those people who do not have strcspn() in
  1905. X * their C libraries.  They should get off their butts and do something
  1906. X * about it; at least one public-domain implementation of those (highly
  1907. X * useful) string routines has been published on Usenet.
  1908. X */
  1909. X#ifdef STRCSPN
  1910. X/*
  1911. X * strcspn - find length of initial segment of s1 consisting entirely
  1912. X * of characters not from s2
  1913. X */
  1914. X
  1915. Xstatic int
  1916. Xstrcspn(s1, s2)
  1917. Xchar *s1;
  1918. Xchar *s2;
  1919. X{
  1920. X    register char *scan1;
  1921. X    register char *scan2;
  1922. X    register int count;
  1923. X
  1924. X    count = 0;
  1925. X    for (scan1 = s1; *scan1 != '\0'; scan1++) {
  1926. X        for (scan2 = s2; *scan2 != '\0';)    /* ++ moved down. */
  1927. X            if (*scan1 == *scan2++)
  1928. X                return(count);
  1929. X        count++;
  1930. X    }
  1931. X    return(count);
  1932. X}
  1933. X#endif
  1934. END_OF_FILE
  1935. if test 31000 -ne `wc -c <'Appls/miniedit/regexp.c'`; then
  1936.     echo shar: \"'Appls/miniedit/regexp.c'\" unpacked with wrong size!
  1937. fi
  1938. # end of 'Appls/miniedit/regexp.c'
  1939. fi
  1940. if test ! -d 'Appls/repeat' ; then
  1941.     echo shar: Creating directory \"'Appls/repeat'\"
  1942.     mkdir 'Appls/repeat'
  1943. fi
  1944. if test ! -d 'Appls/test' ; then
  1945.     echo shar: Creating directory \"'Appls/test'\"
  1946.     mkdir 'Appls/test'
  1947. fi
  1948. if test -f 'Appls/test/test3.c' -a "${1}" != "-c" ; then 
  1949.   echo shar: Will not clobber existing file \"'Appls/test/test3.c'\"
  1950. else
  1951. echo shar: Extracting \"'Appls/test/test3.c'\" \(769 characters\)
  1952. sed "s/^X//" >'Appls/test/test3.c' <<'END_OF_FILE'
  1953. X/* Text-edit test -- a text-edit window. */
  1954. X
  1955. X#include "stdwin.h"
  1956. X
  1957. XTEXTEDIT *tb;
  1958. X
  1959. Xvoid
  1960. Xdrawproc(win, l, t, r, b)
  1961. X    WINDOW *win;
  1962. X{
  1963. X    tedraw(tb);
  1964. X}
  1965. X
  1966. Xmain(argc, argv)
  1967. X    int argc;
  1968. X    char **argv;
  1969. X{
  1970. X    WINDOW *win;
  1971. X    int width, height;
  1972. X    
  1973. X    winitargs(&argc, &argv);
  1974. X    if (argc >= 3) {
  1975. X        int h= atoi(argv[1]), v= atoi(argv[2]);
  1976. X        wsetdefwinpos(h, v);
  1977. X    }
  1978. X    
  1979. X    win= wopen("Textedit", drawproc);
  1980. X    wgetwinsize(win, &width, &height);
  1981. X    wsetdocsize(win, width, height);
  1982. X    
  1983. X    tb= tealloc(win, 0, 0, width);
  1984. X    tereplace(tb, "Hello, world\n--Guido van Rossum");
  1985. X    
  1986. X    for (;;) {
  1987. X        EVENT e;
  1988. X        wgetevent(&e);
  1989. X        if (e.type == WE_CLOSE || e.type == WE_COMMAND &&
  1990. X            (e.u.command == WC_CLOSE || e.u.command == WC_CANCEL))
  1991. X            break;
  1992. X        (void) teevent(tb, &e);
  1993. X    }
  1994. X    tefree(tb);
  1995. X    wclose(win);
  1996. X    wdone();
  1997. X    exit(0);
  1998. X}
  1999. END_OF_FILE
  2000. if test 769 -ne `wc -c <'Appls/test/test3.c'`; then
  2001.     echo shar: \"'Appls/test/test3.c'\" unpacked with wrong size!
  2002. fi
  2003. # end of 'Appls/test/test3.c'
  2004. fi
  2005. if test ! -d 'Appls/tetris' ; then
  2006.     echo shar: Creating directory \"'Appls/tetris'\"
  2007.     mkdir 'Appls/tetris'
  2008. fi
  2009. if test ! -d 'Conf' ; then
  2010.     echo shar: Creating directory \"'Conf'\"
  2011.     mkdir 'Conf'
  2012. fi
  2013. if test ! -d 'Doc' ; then
  2014.     echo shar: Creating directory \"'Doc'\"
  2015.     mkdir 'Doc'
  2016. fi
  2017. if test ! -d 'Doc/man' ; then
  2018.     echo shar: Creating directory \"'Doc/man'\"
  2019.     mkdir 'Doc/man'
  2020. fi
  2021. if test ! -d 'Gen' ; then
  2022.     echo shar: Creating directory \"'Gen'\"
  2023.     mkdir 'Gen'
  2024. fi
  2025. if test ! -d 'H' ; then
  2026.     echo shar: Creating directory \"'H'\"
  2027.     mkdir 'H'
  2028. fi
  2029. if test ! -d 'Packs' ; then
  2030.     echo shar: Creating directory \"'Packs'\"
  2031.     mkdir 'Packs'
  2032. fi
  2033. if test ! -d 'Packs/textedit' ; then
  2034.     echo shar: Creating directory \"'Packs/textedit'\"
  2035.     mkdir 'Packs/textedit'
  2036. fi
  2037. if test ! -d 'Packs/vt' ; then
  2038.     echo shar: Creating directory \"'Packs/vt'\"
  2039.     mkdir 'Packs/vt'
  2040. fi
  2041. if test ! -d 'Ports' ; then
  2042.     echo shar: Creating directory \"'Ports'\"
  2043.     mkdir 'Ports'
  2044. fi
  2045. if test ! -d 'Ports/alfa' ; then
  2046.     echo shar: Creating directory \"'Ports/alfa'\"
  2047.     mkdir 'Ports/alfa'
  2048. fi
  2049. if test ! -d 'Ports/mac' ; then
  2050.     echo shar: Creating directory \"'Ports/mac'\"
  2051.     mkdir 'Ports/mac'
  2052. fi
  2053. if test ! -d 'Ports/mac_mpw' ; then
  2054.     echo shar: Creating directory \"'Ports/mac_mpw'\"
  2055.     mkdir 'Ports/mac_mpw'
  2056. fi
  2057. if test ! -d 'Ports/msdos' ; then
  2058.     echo shar: Creating directory \"'Ports/msdos'\"
  2059.     mkdir 'Ports/msdos'
  2060. fi
  2061. if test ! -d 'Ports/vtrm' ; then
  2062.     echo shar: Creating directory \"'Ports/vtrm'\"
  2063.     mkdir 'Ports/vtrm'
  2064. fi
  2065. if test ! -d 'Ports/vtrm/DIST' ; then
  2066.     echo shar: Creating directory \"'Ports/vtrm/DIST'\"
  2067.     mkdir 'Ports/vtrm/DIST'
  2068. fi
  2069. if test ! -d 'Ports/x11' ; then
  2070.     echo shar: Creating directory \"'Ports/x11'\"
  2071.     mkdir 'Ports/x11'
  2072. fi
  2073. if test ! -d 'Tools' ; then
  2074.     echo shar: Creating directory \"'Tools'\"
  2075.     mkdir 'Tools'
  2076. fi
  2077. echo shar: End of archive 1 \(of 19\).
  2078. cp /dev/null ark1isdone
  2079. MISSING=""
  2080. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2081.     if test ! -f ark${I}isdone ; then
  2082.     MISSING="${MISSING} ${I}"
  2083.     fi
  2084. done
  2085. if test "${MISSING}" = "" ; then
  2086.     echo You have unpacked all 19 archives.
  2087.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2088. else
  2089.     echo You still need to unpack the following archives:
  2090.     echo "        " ${MISSING}
  2091. fi
  2092. ##  End of shell archive.
  2093. exit 0
  2094.