home *** CD-ROM | disk | FTP | other *** search
/ Mega CD-ROM 1 / megacd_rom_1.zip / megacd_rom_1 / GNUISH / GREP15.ZIP / PATCHES < prev    next >
Text File  |  1990-09-23  |  40KB  |  1,018 lines

  1. *** e:\tmp/RCSt1006359    Sat Sep 22 22:33:42 1990
  2. --- dfa.c    Sat Sep 22 22:28:26 1990
  3. ***************
  4. *** 4,109 ****
  5.                 Modified July, 1988 by Arthur David Olson
  6.                to assist BMG speedups
  7.   
  8. !                NO WARRANTY
  9.   
  10. !   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  11. ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  12. ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  13. ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  14. ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  15. ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  16. ! FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  17. ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  18. ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  19. ! CORRECTION.
  20. !  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  21. ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  22. ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  23. ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  24. ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  25. ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  26. ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  27. ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  28. ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  29. ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  30. !         GENERAL PUBLIC LICENSE TO COPY
  31. !   1. You may copy and distribute verbatim copies of this source file
  32. ! as you receive it, in any medium, provided that you conspicuously and
  33. ! appropriately publish on each copy a valid copyright notice "Copyright
  34. !  (C) 1988 Free Software Foundation, Inc."; and include following the
  35. ! copyright notice a verbatim copy of the above disclaimer of warranty
  36. ! and of this License.  You may charge a distribution fee for the
  37. ! physical act of transferring a copy.
  38. !   2. You may modify your copy or copies of this source file or
  39. ! any portion of it, and copy and distribute such modifications under
  40. ! the terms of Paragraph 1 above, provided that you also do the following:
  41. !     a) cause the modified files to carry prominent notices stating
  42. !     that you changed the files and the date of any change; and
  43. !     b) cause the whole of any work that you distribute or publish,
  44. !     that in whole or in part contains or is a derivative of this
  45. !     program or any part thereof, to be licensed at no charge to all
  46. !     third parties on terms identical to those contained in this
  47. !     License Agreement (except that you may choose to grant more extensive
  48. !     warranty protection to some or all third parties, at your option).
  49. !     c) You may charge a distribution fee for the physical act of
  50. !     transferring a copy, and you may at your option offer warranty
  51. !     protection in exchange for a fee.
  52. ! Mere aggregation of another unrelated program with this program (or its
  53. ! derivative) on a volume of a storage or distribution medium does not bring
  54. ! the other program under the scope of these terms.
  55. !   3. You may copy and distribute this program or any portion of it in
  56. ! compiled, executable or object code form under the terms of Paragraphs
  57. ! 1 and 2 above provided that you do the following:
  58. !     a) accompany it with the complete corresponding machine-readable
  59. !     source code, which must be distributed under the terms of
  60. !     Paragraphs 1 and 2 above; or,
  61. !     b) accompany it with a written offer, valid for at least three
  62. !     years, to give any third party free (except for a nominal
  63. !     shipping charge) a complete machine-readable copy of the
  64. !     corresponding source code, to be distributed under the terms of
  65. !     Paragraphs 1 and 2 above; or,
  66. !     c) accompany it with the information you received as to where the
  67. !     corresponding source code may be obtained.  (This alternative is
  68. !     allowed only for noncommercial distribution and only if you
  69. !     received the program in object code or executable form alone.)
  70. ! For an executable file, complete source code means all the source code for
  71. ! all modules it contains; but, as a special exception, it need not include
  72. ! source code for modules which are standard libraries that accompany the
  73. ! operating system on which the executable file runs.
  74. !   4. You may not copy, sublicense, distribute or transfer this program
  75. ! except as expressly provided under this License Agreement.  Any attempt
  76. ! otherwise to copy, sublicense, distribute or transfer this program is void and
  77. ! your rights to use the program under this License agreement shall be
  78. ! automatically terminated.  However, parties who have received computer
  79. ! software programs from you with this License Agreement will not have
  80. ! their licenses terminated so long as such parties remain in full compliance.
  81. !   5. If you wish to incorporate parts of this program into other free
  82. ! programs whose distribution conditions are different, write to the Free
  83. ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  84. ! worked out a simple rule that can be stated here, but we will often permit
  85. ! this.  We will be guided by the two goals of preserving the free status of
  86. ! all derivatives our free software and of promoting the sharing and reuse of
  87. ! software.
  88.   
  89. ! In other words, you are welcome to use, share and improve this program.
  90. ! You are forbidden to forbid anyone else to use, share and improve
  91. ! what you give them.   Help stamp out software-hoarding!  */
  92.   
  93.   #include <stdio.h>
  94.   #include <assert.h>
  95. --- 4,34 ----
  96.                 Modified July, 1988 by Arthur David Olson
  97.                to assist BMG speedups
  98.   
  99. !    This program is free software; you can redistribute it and/or modify
  100. !    it under the terms of the GNU General Public License as published by
  101. !    the Free Software Foundation; either version 1, or (at your option)
  102. !    any later version.
  103.   
  104. !    This program is distributed in the hope that it will be useful,
  105. !    but WITHOUT ANY WARRANTY; without even the implied warranty of
  106. !    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  107. !    GNU General Public License for more details.
  108. !    You should have received a copy of the GNU General Public License
  109. !    along with this program; if not, write to the Free Software
  110. !    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  111. ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
  112. !    This port is also distributed under the terms of the
  113. !    GNU General Public License as published by the
  114. !    Free Software Foundation.
  115. !    Please note that this file is not identical to the
  116. !    original GNU release, you should have received this
  117. !    code as patch to the official release.
  118.   
  119. !    $Header: e:/gnu/grep/RCS/dfa.c 1.5.0.4 90/09/21 11:48:02 tho Exp $   */
  120.   
  121.   #include <stdio.h>
  122.   #include <assert.h>
  123. ***************
  124. *** 112,120 ****
  125.   
  126.   #ifdef __STDC__
  127.   typedef void *ptr_t;
  128. ! #else
  129.   typedef char *ptr_t;
  130. ! #endif
  131.   
  132.   static void    regmust();
  133.   
  134. --- 37,85 ----
  135.   
  136.   #ifdef __STDC__
  137.   typedef void *ptr_t;
  138. ! #ifdef MSDOS
  139. ! #include <stdlib.h>
  140. ! static void *xcalloc (int n, unsigned int s);
  141. ! static void *xmalloc (unsigned int n);
  142. ! static void *xrealloc (void *p, unsigned int n);
  143. ! static int tstbit (int b, int *c);
  144. ! static void setbit (int b, int *c);
  145. ! static void clrbit (int b, int *c);
  146. ! static void copyset (const _charset src, _charset dst);
  147. ! static void zeroset (int *s);
  148. ! static void notset (int *s);
  149. ! static int equal (const _charset s1, const _charset s2);
  150. ! static int charset_index (const _charset s);
  151. ! static void atom (void);
  152. ! static void closure (void);
  153. ! static void branch (void);
  154. ! static void regexp (void);
  155. ! static void build_state (int s, struct regexp * r);
  156. ! static void build_state_zero (struct regexp * r);
  157. ! static char *icatalloc (char *old, char *new);
  158. ! static char *icpyalloc (char *string);
  159. ! static char *istrstr (char *lookin, char *lookfor);
  160. ! static void ifree (char *cp);
  161. ! static void freelist (char **cpp);
  162. ! static char **enlist (char **cpp, char *new, int len);
  163. ! static char **comsubs (char *left, char *right);
  164. ! static char **addlists (char **old, char **new);
  165. ! static char **inboth (char **left, char **right);
  166. ! static void regmust (struct regexp * r);
  167. ! static void copy (_position_set const * src, _position_set * dst);
  168. ! static void insert (_position p, _position_set * s);
  169. ! static void merge (_position_set * s1, _position_set * s2, _position_set * m);
  170. ! static void delete (_position p, _position_set * s);
  171. ! static int state_index (struct regexp * r, _position_set * s,
  172. !             int newline, int letter);
  173. ! static void epsclosure (_position_set * s, struct regexp * r);
  174. ! static void addtok (_token t);
  175. ! static _token lex (void);
  176. ! #endif /* MSDOS */
  177. ! #else /* not __STDC__ */
  178.   typedef char *ptr_t;
  179. ! #endif /* not __STDC__ */
  180.   
  181.   static void    regmust();
  182.   
  183. ***************
  184. *** 261,267 ****
  185.   }
  186.   
  187.   /* Syntax bits controlling the behavior of the lexical analyzer. */
  188. ! static syntax_bits, syntax_bits_set;
  189.   
  190.   /* Flag for case-folding letters into sets. */
  191.   static case_fold;
  192. --- 226,233 ----
  193.   }
  194.   
  195.   /* Syntax bits controlling the behavior of the lexical analyzer. */
  196. ! static LONG syntax_bits;
  197. ! static int syntax_bits_set;
  198.   
  199.   /* Flag for case-folding letters into sets. */
  200.   static case_fold;
  201. ***************
  202. *** 269,275 ****
  203.   /* Entry point to set syntax options. */
  204.   void
  205.   regsyntax(bits, fold)
  206. !      int bits;
  207.        int fold;
  208.   {
  209.     syntax_bits_set = 1;
  210. --- 235,241 ----
  211.   /* Entry point to set syntax options. */
  212.   void
  213.   regsyntax(bits, fold)
  214. !      LONG bits;
  215.        int fold;
  216.   {
  217.     syntax_bits_set = 1;
  218. ***************
  219. *** 861,866 ****
  220. --- 827,835 ----
  221.      that position with the elements of its follow labeled with an appropriate
  222.      constraint.  Repeat exhaustively until no funny positions are left.
  223.      S->elems must be large enough to hold the result. */
  224. + #ifdef MSDOS
  225. + void
  226. + #endif
  227.   epsclosure(s, r)
  228.        _position_set *s;
  229.        struct regexp *r;
  230. ***************
  231. *** 1834,1840 ****
  232. --- 1803,1813 ----
  233.   
  234.   static char *
  235.   icpyalloc(string)
  236. + #ifdef MSDOS
  237. +       char *    string;
  238. + #else
  239.   const char *    string;
  240. + #endif
  241.   {
  242.       return icatalloc((char *) NULL, string);
  243.   }
  244. ***************
  245. *** 2021,2026 ****
  246. --- 1994,2003 ----
  247.       char *    right;
  248.       char *    is;
  249.   } must;
  250. + #ifdef __STDC__
  251. + static void resetmust (must *mp);
  252. + #endif
  253.   
  254.   static void
  255.   resetmust(mp)
  256. *** e:\tmp/RCSt1006359    Sat Sep 22 22:33:46 1990
  257. --- dfa.h    Sat Sep 22 22:26:56 1990
  258. ***************
  259. *** 2,112 ****
  260.      Copyright (C) 1988 Free Software Foundation, Inc.
  261.                         Written June, 1988 by Mike Haertel
  262.   
  263. !                NO WARRANTY
  264.   
  265. !   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  266. ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  267. ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  268. ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  269. ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  270. ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  271. ! FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  272. ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  273. ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  274. ! CORRECTION.
  275. !  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  276. ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  277. ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  278. ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  279. ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  280. ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  281. ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  282. ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  283. ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  284. ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  285. !         GENERAL PUBLIC LICENSE TO COPY
  286. !   1. You may copy and distribute verbatim copies of this source file
  287. ! as you receive it, in any medium, provided that you conspicuously and
  288. ! appropriately publish on each copy a valid copyright notice "Copyright
  289. !  (C) 1988 Free Software Foundation, Inc."; and include following the
  290. ! copyright notice a verbatim copy of the above disclaimer of warranty
  291. ! and of this License.  You may charge a distribution fee for the
  292. ! physical act of transferring a copy.
  293. !   2. You may modify your copy or copies of this source file or
  294. ! any portion of it, and copy and distribute such modifications under
  295. ! the terms of Paragraph 1 above, provided that you also do the following:
  296. !     a) cause the modified files to carry prominent notices stating
  297. !     that you changed the files and the date of any change; and
  298. !     b) cause the whole of any work that you distribute or publish,
  299. !     that in whole or in part contains or is a derivative of this
  300. !     program or any part thereof, to be licensed at no charge to all
  301. !     third parties on terms identical to those contained in this
  302. !     License Agreement (except that you may choose to grant more extensive
  303. !     warranty protection to some or all third parties, at your option).
  304. !     c) You may charge a distribution fee for the physical act of
  305. !     transferring a copy, and you may at your option offer warranty
  306. !     protection in exchange for a fee.
  307. ! Mere aggregation of another unrelated program with this program (or its
  308. ! derivative) on a volume of a storage or distribution medium does not bring
  309. ! the other program under the scope of these terms.
  310. !   3. You may copy and distribute this program or any portion of it in
  311. ! compiled, executable or object code form under the terms of Paragraphs
  312. ! 1 and 2 above provided that you do the following:
  313. !     a) accompany it with the complete corresponding machine-readable
  314. !     source code, which must be distributed under the terms of
  315. !     Paragraphs 1 and 2 above; or,
  316. !     b) accompany it with a written offer, valid for at least three
  317. !     years, to give any third party free (except for a nominal
  318. !     shipping charge) a complete machine-readable copy of the
  319. !     corresponding source code, to be distributed under the terms of
  320. !     Paragraphs 1 and 2 above; or,
  321. !     c) accompany it with the information you received as to where the
  322. !     corresponding source code may be obtained.  (This alternative is
  323. !     allowed only for noncommercial distribution and only if you
  324. !     received the program in object code or executable form alone.)
  325. ! For an executable file, complete source code means all the source code for
  326. ! all modules it contains; but, as a special exception, it need not include
  327. ! source code for modules which are standard libraries that accompany the
  328. ! operating system on which the executable file runs.
  329. !   4. You may not copy, sublicense, distribute or transfer this program
  330. ! except as expressly provided under this License Agreement.  Any attempt
  331. ! otherwise to copy, sublicense, distribute or transfer this program is void and
  332. ! your rights to use the program under this License agreement shall be
  333. ! automatically terminated.  However, parties who have received computer
  334. ! software programs from you with this License Agreement will not have
  335. ! their licenses terminated so long as such parties remain in full compliance.
  336. !   5. If you wish to incorporate parts of this program into other free
  337. ! programs whose distribution conditions are different, write to the Free
  338. ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  339. ! worked out a simple rule that can be stated here, but we will often permit
  340. ! this.  We will be guided by the two goals of preserving the free status of
  341. ! all derivatives our free software and of promoting the sharing and reuse of
  342. ! software.
  343.   
  344. ! In other words, you are welcome to use, share and improve this program.
  345. ! You are forbidden to forbid anyone else to use, share and improve
  346. ! what you give them.   Help stamp out software-hoarding!  */
  347.   
  348.   
  349.   #ifdef USG
  350.   #include <string.h>
  351. ! extern char *index();
  352.   #else
  353.   #include <strings.h>
  354.   extern char *strchr(), *strrchr(), *memcpy();
  355. --- 2,50 ----
  356.      Copyright (C) 1988 Free Software Foundation, Inc.
  357.                         Written June, 1988 by Mike Haertel
  358.   
  359. !    This program is free software; you can redistribute it and/or modify
  360. !    it under the terms of the GNU General Public License as published by
  361. !    the Free Software Foundation; either version 1, or (at your option)
  362. !    any later version.
  363.   
  364. !    This program is distributed in the hope that it will be useful,
  365. !    but WITHOUT ANY WARRANTY; without even the implied warranty of
  366. !    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  367. !    GNU General Public License for more details.
  368. !    You should have received a copy of the GNU General Public License
  369. !    along with this program; if not, write to the Free Software
  370. !    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  371. ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
  372. !    This port is also distributed under the terms of the
  373. !    GNU General Public License as published by the
  374. !    Free Software Foundation.
  375. !    Please note that this file is not identical to the
  376. !    original GNU release, you should have received this
  377. !    code as patch to the official release.
  378.   
  379. !    $Header: e:/gnu/grep/RCS/dfa.h 1.5.0.5 90/09/21 11:48:25 tho Exp $  */
  380.   
  381. + #ifdef MSDOS
  382. + #define LONG long
  383. + #define ONE 1L
  384. + #else /* not MSDOS */
  385. + #define LONG int
  386. + #define ONE 1
  387. + #endif /* not MSDOS */
  388.   
  389.   #ifdef USG
  390.   #include <string.h>
  391. ! #define bcopy(s,d,n)    memcpy((d),(s),(n))
  392. ! #define bcmp(s1,s2,n)    memcmp((s1),(s2),(n))
  393. ! #define bzero(s,n)    memset((s),0,(n))
  394. ! #define index strchr
  395. ! #define rindex strrchr
  396.   #else
  397.   #include <strings.h>
  398.   extern char *strchr(), *strrchr(), *memcpy();
  399. ***************
  400. *** 116,128 ****
  401.   
  402.   /* Missing include files for GNU C. */
  403.   /* #include <stdlib.h> */
  404. ! typedef int size_t;
  405.   extern void *calloc(int, size_t);
  406.   extern void *malloc(size_t);
  407.   extern void *realloc(void *, size_t);
  408.   extern void free(void *);
  409.   
  410.   extern char *bcopy(), *bzero();
  411.   
  412.   #ifdef SOMEDAY
  413.   #define ISALNUM(c) isalnum(c)
  414. --- 54,70 ----
  415.   
  416.   /* Missing include files for GNU C. */
  417.   /* #include <stdlib.h> */
  418. ! #ifndef MSDOS
  419. ! typedef int size_t;            /* long !!!! */
  420.   extern void *calloc(int, size_t);
  421.   extern void *malloc(size_t);
  422.   extern void *realloc(void *, size_t);
  423.   extern void free(void *);
  424. + #endif /* MSDOS */
  425.   
  426. + #ifndef USG
  427.   extern char *bcopy(), *bzero();
  428. + #endif /* not USG */
  429.   
  430.   #ifdef SOMEDAY
  431.   #define ISALNUM(c) isalnum(c)
  432. ***************
  433. *** 134,140 ****
  434.   #define ISUPPER(c) (isascii(c) && isupper(c))
  435.   #endif
  436.   
  437. ! #else /* ! __STDC__ */
  438.   
  439.   #define const
  440.   typedef int size_t;
  441. --- 76,82 ----
  442.   #define ISUPPER(c) (isascii(c) && isupper(c))
  443.   #endif
  444.   
  445. ! #else /* not __STDC__ */
  446.   
  447.   #define const
  448.   typedef int size_t;
  449. ***************
  450. *** 147,193 ****
  451.   #define ISALPHA(c) (isascii(c) && isalpha(c))
  452.   #define ISUPPER(c) (isascii(c) && isupper(c))
  453.   
  454. ! #endif /* ! __STDC__ */
  455.   
  456. ! /* 1 means plain parentheses serve as grouping, and backslash
  457.        parentheses are needed for literal searching.
  458. !    0 means backslash-parentheses are grouping, and plain parentheses
  459.        are for literal searching.  */
  460. ! #define RE_NO_BK_PARENS 1
  461. ! /* 1 means plain | serves as the "or"-operator, and \| is a literal.
  462. !    0 means \| serves as the "or"-operator, and | is a literal.  */
  463. ! #define RE_NO_BK_VBAR 2
  464. ! /* 0 means plain + or ? serves as an operator, and \+, \? are literals.
  465. !    1 means \+, \? are operators and plain +, ? are literals.  */
  466. ! #define RE_BK_PLUS_QM 4
  467. ! /* 1 means | binds tighter than ^ or $.
  468. !    0 means the contrary.  */
  469. ! #define RE_TIGHT_VBAR 8
  470. ! /* 1 means treat \n as an _OR operator
  471. !    0 means treat it as a normal character */
  472. ! #define RE_NEWLINE_OR 16
  473. ! /* 0 means that a special characters (such as *, ^, and $) always have
  474. !      their special meaning regardless of the surrounding context.
  475. !    1 means that special characters may act as normal characters in some
  476. !      contexts.  Specifically, this applies to:
  477. !     ^ - only special at the beginning, or after ( or |
  478. !     $ - only special at the end, or before ) or |
  479. !     *, +, ? - only special when not after the beginning, (, or | */
  480. ! #define RE_CONTEXT_INDEP_OPS 32
  481.   
  482. ! /* Now define combinations of bits for the standard possibilities.  */
  483. ! #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
  484. ! #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
  485.   #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  486.   #define RE_SYNTAX_EMACS 0
  487.   
  488.   /* The NULL pointer. */
  489. ! #define NULL 0
  490.   
  491.   /* Number of bits in an unsigned char. */
  492.   #define CHARBITS 8
  493. --- 89,222 ----
  494.   #define ISALPHA(c) (isascii(c) && isalpha(c))
  495.   #define ISUPPER(c) (isascii(c) && isupper(c))
  496.   
  497. ! #endif /* not __STDC__ */
  498.   
  499. ! /* If this bit is set, plain parentheses serve as grouping, and backslash
  500.        parentheses are needed for literal searching.
  501. !    If not set, backslash-parentheses are grouping, and plain parentheses
  502.        are for literal searching.  */
  503. ! #define RE_NO_BK_PARENS    ONE
  504.   
  505. ! /* If this bit is set, plain | serves as the `or'-operator, and \| is a 
  506. !      literal.
  507. !    If not set, \| serves as the `or'-operator, and | is a literal.  */
  508. ! #define RE_NO_BK_VBAR (ONE << 1)
  509. ! /* If this bit is not set, plain + or ? serves as an operator, and \+, \? are 
  510. !      literals.
  511. !    If set, \+, \? are operators and plain +, ? are literals.  */
  512. ! #define RE_BK_PLUS_QM (ONE << 2)
  513. ! /* If this bit is set, | binds tighter than ^ or $.
  514. !    If not set, the contrary.  */
  515. ! #define RE_TIGHT_VBAR (ONE << 3)
  516. ! /* If this bit is set, then treat newline as an OR operator.
  517. !    If not set, treat it as a normal character.  */
  518. ! #define RE_NEWLINE_OR (ONE << 4)
  519. ! /* If this bit is set, then special characters may act as normal
  520. !    characters in some contexts. Specifically, this applies to:
  521. !     ^ -- only special at the beginning, or after ( or |;
  522. !     $ -- only special at the end, or before ) or |;
  523. !     *, +, ? -- only special when not after the beginning, (, or |.
  524. !    If this bit is not set, special characters (such as *, ^, and $)
  525. !    always have their special meaning regardless of the surrounding
  526. !    context.  */
  527. ! #define RE_CONTEXT_INDEP_OPS (ONE << 5)
  528. ! /* If this bit is not set, then \ before anything inside [ and ] is taken as 
  529. !      a real \.
  530. !    If set, then such a \ escapes the following character.  This is a
  531. !      special case for awk.  */
  532. ! #define RE_AWK_CLASS_HACK (ONE << 6)
  533. ! /* If this bit is set, then \{ and \} or { and } serve as interval operators.
  534. !    If not set, then \{ and \} and { and } are treated as literals.  */
  535. ! #define RE_INTERVALS (ONE << 7)
  536. ! /* If this bit is not set, then \{ and \} serve as interval operators and 
  537. !      { and } are literals.
  538. !    If set, then { and } serve as interval operators and \{ and \} are 
  539. !      literals.  */
  540. ! #define RE_NO_BK_CURLY_BRACES (ONE << 8)
  541. ! /* If this bit is set, then character classes are supported; they are:
  542. !      [:alpha:],    [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
  543. !      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
  544. !    If not set, then character classes are not supported.  */
  545. ! #define RE_CHAR_CLASSES (ONE << 9)
  546. ! /* If this bit is set, then the dot re doesn't match a null byte.
  547. !    If not set, it does.  */
  548. ! #define RE_DOT_NOT_NULL (ONE << 10)
  549. ! /* If this bit is set, then [^...] doesn't match a newline.
  550. !    If not set, it does.  */
  551. ! #define RE_HAT_NOT_NEWLINE (ONE << 11)
  552. ! /* If this bit is set, back references are recognized.
  553. !    If not set, they aren't.  */
  554. ! #define RE_NO_BK_REFS (ONE << 12)
  555. ! /* If this bit is set, back references must refer to a preceding
  556. !    subexpression.  If not set, a back reference to a nonexistent
  557. !    subexpression is treated as literal characters.  */
  558. ! #define RE_NO_EMPTY_BK_REF (ONE << 13)
  559. ! /* If this bit is set, bracket expressions can't be empty.  
  560. !    If it is set, they can be empty.  */
  561. ! #define RE_NO_EMPTY_BRACKETS (ONE << 14)
  562. ! /* If this bit is set, then *, +, ? and { cannot be first in an re or
  563. !    immediately after a |, or a (.  Furthermore, a | cannot be first or
  564. !    last in an re, or immediately follow another | or a (.  Also, a ^
  565. !    cannot appear in a nonleading position and a $ cannot appear in a
  566. !    nontrailing position (outside of bracket expressions, that is).  */
  567. ! #define RE_CONTEXTUAL_INVALID_OPS (ONE << 15)
  568. ! /* If this bit is set, then +, ? and | aren't recognized as operators.
  569. !    If it's not, they are.  */
  570. ! #define RE_LIMITED_OPS (ONE << 16)
  571. ! /* If this bit is set, then an ending range point has to collate higher
  572. !      or equal to the starting range point.
  573. !    If it's not set, then when the ending range point collates higher
  574. !      than the starting range point, the range is just considered empty.  */
  575. ! #define RE_NO_EMPTY_RANGES (ONE << 17)
  576. ! /* If this bit is set, then a hyphen (-) can't be an ending range point.
  577. !    If it isn't, then it can.  */
  578. ! #define RE_NO_HYPHEN_RANGE_END (ONE << 18)
  579. ! /* Define combinations of bits for the standard possibilities.  */
  580. ! #define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  581. !             | RE_CONTEXT_INDEP_OPS)
  582. ! #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  583. !             | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
  584. ! #define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  585. !             | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
  586.   #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  587.   #define RE_SYNTAX_EMACS 0
  588. + #define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM         \
  589. +             | RE_CHAR_CLASSES | RE_DOT_NOT_NULL         \
  590. +                         | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF     \
  591. +                         | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS        \
  592. +                         | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)    
  593. +                         
  594. + #define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES       \
  595. +             | RE_NO_BK_VBAR | RE_NO_BK_PARENS            \
  596. +                         | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES            \
  597. +                         | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
  598. +                         | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES            \
  599. +                         | RE_NO_HYPHEN_RANGE_END)
  600.   
  601.   /* The NULL pointer. */
  602. ! #ifndef MSDOS
  603. ! #define NULL 0                /* we have it in stdio.h */
  604. ! #endif /* not MSDOS */
  605.   
  606.   /* Number of bits in an unsigned char. */
  607.   #define CHARBITS 8
  608. ***************
  609. *** 295,301 ****
  610.                      class of characters. */
  611.   } _token;
  612.   
  613. ! #else /* ! __STDC__ */
  614.   
  615.   typedef short _token;
  616.   
  617. --- 324,330 ----
  618.                      class of characters. */
  619.   } _token;
  620.   
  621. ! #else /* not __STDC__ */
  622.   
  623.   typedef short _token;
  624.   
  625. ***************
  626. *** 319,325 ****
  627.   #define _RPAREN (_EMPTY + 16)
  628.   #define _SET (_EMPTY + 17)
  629.   
  630. ! #endif /* ! __STDC__ */
  631.   
  632.   /* Sets are stored in an array in the compiled regexp; the index of the
  633.      array corresponding to a given set token is given by _SET_INDEX(t). */
  634. --- 348,354 ----
  635.   #define _RPAREN (_EMPTY + 16)
  636.   #define _SET (_EMPTY + 17)
  637.   
  638. ! #endif /* not __STDC__ */
  639.   
  640.   /* Sets are stored in an array in the compiled regexp; the index of the
  641.      array corresponding to a given set token is given by _SET_INDEX(t). */
  642. ***************
  643. *** 499,505 ****
  644.   
  645.   /* Regsyntax() takes two arguments; the first sets the syntax bits described
  646.      earlier in this file, and the second sets the case-folding flag. */
  647. ! extern void regsyntax(int, int);
  648.   
  649.   /* Compile the given string of the given length into the given struct regexp.
  650.      Final argument is a flag specifying whether to build a searching or an
  651. --- 528,534 ----
  652.   
  653.   /* Regsyntax() takes two arguments; the first sets the syntax bits described
  654.      earlier in this file, and the second sets the case-folding flag. */
  655. ! extern void regsyntax (LONG, int);
  656.   
  657.   /* Compile the given string of the given length into the given struct regexp.
  658.      Final argument is a flag specifying whether to build a searching or an
  659. ***************
  660. *** 547,554 ****
  661.      The user can provide a different regfree() if so desired. */
  662.   extern void regerror(const char *);
  663.   
  664. ! #else /* ! __STDC__ */
  665.   extern void regsyntax(), regcompile(), regfree(), reginit(), regparse();
  666.   extern void reganalyze(), regstate(), regerror();
  667.   extern char *regexecute();
  668. ! #endif
  669. --- 576,583 ----
  670.      The user can provide a different regfree() if so desired. */
  671.   extern void regerror(const char *);
  672.   
  673. ! #else /* not __STDC__ */
  674.   extern void regsyntax(), regcompile(), regfree(), reginit(), regparse();
  675.   extern void reganalyze(), regstate(), regerror();
  676.   extern char *regexecute();
  677. ! #endif /* not __STDC__ */
  678. *** e:\tmp/RCSt1006359    Sat Sep 22 22:33:54 1990
  679. --- grep.c    Sat Sep 22 22:26:48 1990
  680. ***************
  681. *** 4,109 ****
  682.                     BMG speedups added July, 1988
  683.               by James A. Woods and Arthur David Olson
  684.   
  685. !                NO WARRANTY
  686.   
  687. !   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  688. ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  689. ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  690. ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  691. ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  692. ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  693. ! FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  694. ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  695. ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  696. ! CORRECTION.
  697. !  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  698. ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  699. ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  700. ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  701. ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  702. ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  703. ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  704. ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  705. ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  706. ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  707. !         GENERAL PUBLIC LICENSE TO COPY
  708. !   1. You may copy and distribute verbatim copies of this source file
  709. ! as you receive it, in any medium, provided that you conspicuously and
  710. ! appropriately publish on each copy a valid copyright notice "Copyright
  711. !  (C) 1988 Free Software Foundation, Inc."; and include following the
  712. ! copyright notice a verbatim copy of the above disclaimer of warranty
  713. ! and of this License.  You may charge a distribution fee for the
  714. ! physical act of transferring a copy.
  715. !   2. You may modify your copy or copies of this source file or
  716. ! any portion of it, and copy and distribute such modifications under
  717. ! the terms of Paragraph 1 above, provided that you also do the following:
  718. !     a) cause the modified files to carry prominent notices stating
  719. !     that you changed the files and the date of any change; and
  720. !     b) cause the whole of any work that you distribute or publish,
  721. !     that in whole or in part contains or is a derivative of this
  722. !     program or any part thereof, to be licensed at no charge to all
  723. !     third parties on terms identical to those contained in this
  724. !     License Agreement (except that you may choose to grant more extensive
  725. !     warranty protection to some or all third parties, at your option).
  726. !     c) You may charge a distribution fee for the physical act of
  727. !     transferring a copy, and you may at your option offer warranty
  728. !     protection in exchange for a fee.
  729. ! Mere aggregation of another unrelated program with this program (or its
  730. ! derivative) on a volume of a storage or distribution medium does not bring
  731. ! the other program under the scope of these terms.
  732. !   3. You may copy and distribute this program or any portion of it in
  733. ! compiled, executable or object code form under the terms of Paragraphs
  734. ! 1 and 2 above provided that you do the following:
  735. !     a) accompany it with the complete corresponding machine-readable
  736. !     source code, which must be distributed under the terms of
  737. !     Paragraphs 1 and 2 above; or,
  738. !     b) accompany it with a written offer, valid for at least three
  739. !     years, to give any third party free (except for a nominal
  740. !     shipping charge) a complete machine-readable copy of the
  741. !     corresponding source code, to be distributed under the terms of
  742. !     Paragraphs 1 and 2 above; or,
  743. !     c) accompany it with the information you received as to where the
  744. !     corresponding source code may be obtained.  (This alternative is
  745. !     allowed only for noncommercial distribution and only if you
  746. !     received the program in object code or executable form alone.)
  747. ! For an executable file, complete source code means all the source code for
  748. ! all modules it contains; but, as a special exception, it need not include
  749. ! source code for modules which are standard libraries that accompany the
  750. ! operating system on which the executable file runs.
  751. !   4. You may not copy, sublicense, distribute or transfer this program
  752. ! except as expressly provided under this License Agreement.  Any attempt
  753. ! otherwise to copy, sublicense, distribute or transfer this program is void and
  754. ! your rights to use the program under this License agreement shall be
  755. ! automatically terminated.  However, parties who have received computer
  756. ! software programs from you with this License Agreement will not have
  757. ! their licenses terminated so long as such parties remain in full compliance.
  758. !   5. If you wish to incorporate parts of this program into other free
  759. ! programs whose distribution conditions are different, write to the Free
  760. ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  761. ! worked out a simple rule that can be stated here, but we will often permit
  762. ! this.  We will be guided by the two goals of preserving the free status of
  763. ! all derivatives our free software and of promoting the sharing and reuse of
  764. ! software.
  765.   
  766. ! In other words, you are welcome to use, share and improve this program.
  767. ! You are forbidden to forbid anyone else to use, share and improve
  768. ! what you give them.   Help stamp out software-hoarding!  */
  769.   
  770.   #include <ctype.h>
  771.   #include <stdio.h>
  772. --- 4,34 ----
  773.                     BMG speedups added July, 1988
  774.               by James A. Woods and Arthur David Olson
  775.   
  776. !    This program is free software; you can redistribute it and/or modify
  777. !    it under the terms of the GNU General Public License as published by
  778. !    the Free Software Foundation; either version 1, or (at your option)
  779. !    any later version.
  780.   
  781. !    This program is distributed in the hope that it will be useful,
  782. !    but WITHOUT ANY WARRANTY; without even the implied warranty of
  783. !    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  784. !    GNU General Public License for more details.
  785. !    You should have received a copy of the GNU General Public License
  786. !    along with this program; if not, write to the Free Software
  787. !    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  788. ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
  789. !    This port is also distributed under the terms of the
  790. !    GNU General Public License as published by the
  791. !    Free Software Foundation.
  792. !    Please note that this file is not identical to the
  793. !    original GNU release, you should have received this
  794. !    code as patch to the official release.
  795.   
  796. !    $Header: e:/gnu/grep/RCS/grep.c 1.5.0.6 90/09/21 11:48:14 tho Exp $  */
  797.   
  798.   #include <ctype.h>
  799.   #include <stdio.h>
  800. ***************
  801. *** 117,135 ****
  802.   #include "regex.h"
  803.   
  804.   #ifdef __STDC__
  805. ! extern getopt(int, char **, const char *);
  806. ! extern read(int, void *, int);
  807. ! extern open(const char *, int, ...);
  808. ! extern void close();
  809. ! #else
  810.   extern char *strrchr();
  811. - #endif
  812.   
  813. - extern char *optarg;
  814. - extern optind, opterr;
  815.   extern errno;
  816.   extern char *sys_errlist[];
  817.   
  818.   #define MAX(a, b) ((a) > (b) ? (a) : (b))
  819.   
  820.   /* Exit status codes. */
  821. --- 42,79 ----
  822.   #include "regex.h"
  823.   
  824.   #ifdef __STDC__
  825. ! #ifdef MSDOS
  826. ! #include <stdlib.h>
  827. ! extern getopt (int, char **, const char *);
  828. ! extern read (int, void *, int);
  829. ! extern open (const char *, int,...);
  830. ! extern void close (int fd);
  831. ! static void initialize_buffer (void);
  832. ! static int fill_buffer_retaining (int n);
  833. ! static int print_line (char *p, int number, int matching);
  834. ! static int grep (void);
  835. ! extern void usage_and_die (void);
  836. ! extern void main (int argc, char **argv);
  837. ! extern void regerror (char const * s);
  838. ! extern char *execute (struct regexp * r, char *begin, char *end, int newline,
  839. !               int *count, int *try_backref);
  840. ! extern char *bmg_search (unsigned char *buffer, int buflen);
  841. ! extern void bmg_setup (char *pat, int folded);
  842. ! #endif /* MSDOS */
  843. ! #else /* not __STDC__ */
  844.   extern char *strrchr();
  845.   
  846.   extern errno;
  847.   extern char *sys_errlist[];
  848.   
  849. + #endif /* not __STDC__ */
  850. + extern char *optarg;
  851. + extern optind, opterr;
  852.   #define MAX(a, b) ((a) > (b) ? (a) : (b))
  853.   
  854.   /* Exit status codes. */
  855. ***************
  856. *** 542,549 ****
  857. --- 486,499 ----
  858.     exit(ERROR);
  859.   }
  860.   
  861. + #ifndef MSDOS
  862.   static char version[] = "GNU e?grep, version 1.5";
  863. + #else /* MSDOS */
  864. + static char version[] =
  865. +   "GNU e?grep, version 1.5  (compiled " __DATE__ " " __TIME__ " for MS-DOS)";
  866.   
  867. + void
  868. + #endif /* MSDOS */
  869.   main(argc, argv)
  870.        int argc;
  871.        char **argv;
  872. ***************
  873. *** 954,959 ****
  874. --- 904,912 ----
  875.     return(NULL);
  876.   }
  877.   
  878. + #ifdef MSDOS
  879. + void
  880. + #endif
  881.   bmg_setup(pat, folded)            /* compute "boyer-moore" delta table */
  882.     char *pat;
  883.     int folded;
  884. ***************
  885. *** 1015,1047 ****
  886.     return bcopy(s, d, n);
  887.   }
  888.   
  889. ! #else
  890. ! char *
  891. ! index(s, c)
  892. !      char *s;
  893. ! {
  894. !   return strchr(s, c);
  895. ! }
  896. ! char *
  897. ! bcopy(s, d, n)
  898. !      char *s, *d;
  899. ! {
  900. !   return memcpy(d, s, n);
  901. ! }
  902. ! char *
  903. ! bzero(s, n)
  904. !      char *s;
  905. ! {
  906. !   return memset(s, 0, n);
  907. ! }
  908. ! bcmp(s, t, n)
  909. !      char *s, *t;
  910. ! {
  911. !   return memcmp(s, t, n);
  912. ! }
  913. ! #endif
  914. --- 968,971 ----
  915.     return bcopy(s, d, n);
  916.   }
  917.   
  918. ! #endif /* not USG */
  919.