home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / edit / stevie / regexp / readme.reg next >
Encoding:
Text File  |  1987-09-02  |  5.1 KB  |  115 lines

  1. This is a nearly-public-domain reimplementation of the V8 regexp(3) package.
  2. It gives C programs the ability to use egrep-style regular expressions, and
  3. does it in a much cleaner fashion than the analogous routines in SysV.
  4.  
  5.     Copyright (c) 1986 by University of Toronto.
  6.     Written by Henry Spencer.  Not derived from licensed software.
  7.  
  8.     Permission is granted to anyone to use this software for any
  9.     purpose on any computer system, and to redistribute it freely,
  10.     subject to the following restrictions:
  11.  
  12.     1. The author is not responsible for the consequences of use of
  13.         this software, no matter how awful, even if they arise
  14.         from defects in it.
  15.  
  16.     2. The origin of this software must not be misrepresented, either
  17.         by explicit claim or by omission.
  18.  
  19.     3. Altered versions must be plainly marked as such, and must not
  20.         be misrepresented as being the original software.
  21.  
  22. Barring a couple of small items in the BUGS list, this implementation is
  23. believed 100% compatible with V8.  It should even be binary-compatible,
  24. sort of, since the only fields in a "struct regexp" that other people have
  25. any business touching are declared in exactly the same way at the same
  26. location in the struct (the beginning).
  27.  
  28. This implementation is *NOT* AT&T/Bell code, and is not derived from licensed
  29. software.  Even though U of T is a V8 licensee.  This software is based on
  30. a V8 manual page sent to me by Dennis Ritchie (the manual page enclosed
  31. here is a complete rewrite and hence is not covered by AT&T copyright).
  32. The software was nearly complete at the time of arrival of our V8 tape.
  33. I haven't even looked at V8 yet, although a friend elsewhere at U of T has
  34. been kind enough to run a few test programs using the V8 regexp(3) to resolve
  35. a few fine points.  I admit to some familiarity with regular-expression
  36. implementations of the past, but the only one that this code traces any
  37. ancestry to is the one published in Kernighan & Plauger (from which this
  38. one draws ideas but not code).
  39.  
  40. Simplistically:  put this stuff into a source directory, copy regexp.h into
  41. /usr/include, inspect Makefile for compilation options that need changing
  42. to suit your local environment, and then do "make r".  This compiles the
  43. regexp(3) functions, compiles a test program, and runs a large set of
  44. regression tests.  If there are no complaints, then put regexp.o, regsub.o,
  45. and regerror.o into your C library, and regexp.3 into your manual-pages
  46. directory.
  47.  
  48. Note that if you don't put regexp.h into /usr/include *before* compiling,
  49. you'll have to add "-I." to CFLAGS before compiling.
  50.  
  51. The files are:
  52.  
  53. regexp.man    manual pages
  54. regexp.h    header file, for /usr/include
  55. regexp.c    source for regcomp() and regexec()
  56. regsub.c    source for regsub()
  57. regerror.c    source for default regerror()
  58. regmagic.h    internal header file
  59. try.c        source for test program
  60. tests        test list for try and timer
  61. readme.reg    this file
  62.  
  63. This implementation uses nondeterministic automata rather than the
  64. deterministic ones found in some other implementations, which makes it
  65. simpler, smaller, and faster at compiling regular expressions, but slower
  66. at executing them.  In theory, anyway.  This implementation does employ
  67. some special-case optimizations to make the simpler cases (which do make
  68. up the bulk of regular expressions actually used) run quickly.  In general,
  69. if you want blazing speed you're in the wrong place.  Replacing the insides
  70. of egrep with this stuff is probably a mistake; if you want your own egrep
  71. you're going to have to do a lot more work.  But if you want to use regular
  72. expressions a little bit in something else, you're in luck.  Note that many
  73. existing text editors use nondeterministic regular-expression implementations,
  74. so you're in good company.
  75.  
  76. This stuff should be pretty portable, given appropriate option settings.
  77. If your chars have less than 8 bits, you're going to have to change the
  78. internal representation of the automaton, although knowledge of the details
  79. of this is fairly localized.  There are no "reserved" char values except for
  80. NUL, and no special significance is attached to the top bit of chars.
  81. The string(3) functions are used a fair bit, on the grounds that they are
  82. probably faster than coding the operations in line.  Some attempts at code
  83. tuning have been made, but this is invariably a bit machine-specific.
  84.  
  85. ---
  86. Turbo C users:
  87.  
  88. The module regerror.c defines a single function, regerror(), which is referenced
  89. in regexp.c. Use of the included regerror() function is optional, as is
  90. demonstrated in try.c which defines its own version. When linking the modules
  91. that make up try.exe, do not include regerror.obj in the link. See the included
  92. note in regerror.c for more information on using the regerror() function.
  93.  
  94. To compile this package under Turbo C, use
  95.  
  96.     tcc -c regexp regsub regerror
  97.  
  98. Ignore the unreachable code warnings in regexp.c (I was too lazy to remove the 
  99. offending break statements).
  100.  
  101. Try.c is a program that uses regexp(3) and performs regression testing on the
  102. package. To compile it, enter
  103.  
  104.     tcc try regexp.obj regsub.obj
  105.  
  106. To run it, enter
  107.  
  108.     try < tests
  109.  
  110. If there is no response, then the tests were passed ("no news is good news"
  111. testing).
  112.  
  113. jrh
  114. ---
  115.