home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / gnuish / fgrep11.arc / patches < prev    next >
Text File  |  1990-09-24  |  12KB  |  433 lines

  1. *** e:\tmp/RCSt1006358    Mon Sep 24 00:42:52 1990
  2. --- fgrep.c    Mon Sep 24 00:39:18 1990
  3. ***************
  4. *** 19,26 ****
  5. --- 19,62 ----
  6.      The author may be reached (Email) at the address mike@ai.mit.edu,
  7.      or (US mail) as Mike Haertel c/o Free Software Foundation. */
  8.   
  9. + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
  10. +    This port is also distributed under the terms of the
  11. +    GNU General Public License as published by the
  12. +    Free Software Foundation.
  13. +    Please note that this file is not identical to the
  14. +    original GNU release, you should have received this
  15. +    code as patch to the official release.
  16. +    $Header: e:/gnu/fgrep/RCS/fgrep.c 1.1.0.4 90/09/24 00:37:48 tho Exp $
  17. +  */
  18.   #include "std.h"
  19. + #ifdef MSDOS
  20. + char *optarg;                /* interface to getopt() */
  21. + int  optind;
  22. + extern  int getopt (int argc, char **argv, char *optstr);
  23. + static  void error(char const *mesg,int errnum);
  24. + static  void fatal(char const *mesg,int errnum);
  25. + static  void compile(char const *pattern,unsigned int size);
  26. + static  char *execute (char *buf, unsigned int size);
  27. + static  void nlscan (char *lim);
  28. + static  unsigned int prline (char *beg, char sep);
  29. + static  void prpending (char *lim);
  30. + static  int prtext (char *beg, char *lim);
  31. + static  int fillbuf (void);
  32. + static  void initbuf (void);
  33. + static  void resetbuf(int desc,char const *file);
  34. + static  int grepbuf (void);
  35. + static  int grep(int desc,char const *file);
  36. + static  void usage (void);
  37. + extern  void main (int argc, char **argv);
  38. + #include <io.h>
  39. + #else /* not MSDOS */
  40.   #include "unix.h"
  41. + #endif /* not MSDOS */
  42.   
  43.   #include <errno.h>
  44.   #include <stdio.h>
  45. ***************
  46. *** 64,70 ****
  47.   }
  48.   
  49.   /* Interface to handle errors and fix library lossage. */
  50. ! static PTR
  51.   DEFUN(xmalloc, (size), size_t size)
  52.   {
  53.     PTR result;
  54. --- 100,109 ----
  55.   }
  56.   
  57.   /* Interface to handle errors and fix library lossage. */
  58. ! #ifndef MSDOS
  59. ! static
  60. ! #endif
  61. ! PTR
  62.   DEFUN(xmalloc, (size), size_t size)
  63.   {
  64.     PTR result;
  65. ***************
  66. *** 76,82 ****
  67.   }
  68.   
  69.   /* Interface to handle errors and fix some library lossage. */
  70. ! static PTR
  71.   DEFUN(xrealloc, (ptr, size), PTR ptr AND size_t size)
  72.   {
  73.     PTR result;
  74. --- 115,124 ----
  75.   }
  76.   
  77.   /* Interface to handle errors and fix some library lossage. */
  78. ! #ifndef MSDOS
  79. ! static
  80. ! #endif
  81. ! PTR
  82.   DEFUN(xrealloc, (ptr, size), PTR ptr AND size_t size)
  83.   {
  84.     PTR result;
  85. ***************
  86. *** 107,113 ****
  87. --- 149,159 ----
  88.   
  89.     if (match_fold)
  90.       for (i = 0; i < NCHAR; ++i)
  91. + #ifdef MSDOS
  92. +       trans[i] = (char) TOLOWER(i);
  93. + #else
  94.         trans[i] = TOLOWER(i);
  95. + #endif
  96.   
  97.     if (!(kwset = kwsalloc(match_fold ? trans : (const char *) NULL)))
  98.       fatal("memory exhausted", 0);
  99. ***************
  100. *** 232,238 ****
  101. --- 278,288 ----
  102.         printf("%d%c", buftotalnl + 1, sep);
  103.       }
  104.         if (out_byte)
  105. + #ifdef MSDOS                /* MSC 5.1 needs this cast! */
  106. +     printf("%lu%c", buftotalcc + (unsigned long) (beg - buf), sep);
  107. + #else
  108.       printf("%lu%c", buftotalcc + (beg - buf), sep);
  109. + #endif
  110.         while (beg < buflim)
  111.       {
  112.         ++cc;
  113. ***************
  114. *** 442,448 ****
  115. --- 492,507 ----
  116.     return total;
  117.   }
  118.   
  119. + #ifdef MSDOS
  120. + static char Program_Id[] = "fgrep";
  121. + static char RCS_Revision[] = "$Revision: 1.1.0.4 $";
  122. + #define VERSION \
  123. +   "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
  124. +   (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
  125. + #else /* not MSDOS */
  126.   static const char version[] = "GNU fgrep, version 1.1";
  127. + #endif /* not MSDOS */
  128.   
  129.   #define USAGE \
  130.     "usage: %s [-[[AB] ]<num>] [-[CVchilnsvwx]] [-[ef]] <expr> [<files...>]\n"
  131. ***************
  132. *** 454,460 ****
  133. --- 513,524 ----
  134.     exit(2);
  135.   }
  136.   
  137. + #ifdef MSDOS
  138. + void
  139. + #else
  140.   int
  141. + #endif
  142.   DEFUN(main, (argc, argv), int argc AND char *argv[])
  143.   {
  144.     char *keys;
  145. ***************
  146. *** 502,508 ****
  147. --- 566,576 ----
  148.       out_before = out_after = 2;
  149.       break;
  150.         case 'V':
  151. + #ifdef MSDOS
  152. +     fprintf(stderr, VERSION);
  153. + #else
  154.       fprintf(stderr, "%s\n", version);
  155. + #endif
  156.       break;
  157.         case 'b':
  158.       out_byte = 1;
  159. *** e:\tmp/RCSt1006358    Mon Sep 24 00:42:54 1990
  160. --- kwset.c    Mon Sep 24 00:40:24 1990
  161. ***************
  162. *** 19,24 ****
  163. --- 19,36 ----
  164.      The author may be reached (Email) at the address mike@ai.mit.edu,
  165.      or (US mail) as Mike Haertel c/o Free Software Foundation. */
  166.   
  167. + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
  168. +    This port is also distributed under the terms of the
  169. +    GNU General Public License as published by the
  170. +    Free Software Foundation.
  171. +    Please note that this file is not identical to the
  172. +    original GNU release, you should have received this
  173. +    code as patch to the official release.
  174. +    $Header: e:/gnu/fgrep/RCS/kwset.c 1.1.0.3 90/09/24 00:37:52 tho Exp $
  175. +  */
  176.   #include "std.h"
  177.   
  178.   /* The algorithm implemented by these routines bears a startling resemblence
  179. ***************
  180. *** 30,39 ****
  181. --- 42,78 ----
  182.      Vol. 18, No. 6, which describes the failure function used below. */
  183.   
  184.   #include "kwset.h"
  185. + #ifdef MSDOS
  186. + #ifdef USE_OBSTACKS
  187. + #if defined(M_I86CM) || defined(M_I86LM)
  188. + #error The GNU `obstack' macros don't work with far pointers yet!
  189. + #else /* M_I86SM or M_I86MM */
  190.   #include "obstack.h"
  191. + #endif /* M_I86SM or M_I86MM */
  192. + #else /* not USE_OBSTACKS */
  193. + #undef obstack_alloc
  194. + #undef obstack_free
  195. + #undef obstack_init
  196. + #define obstack_alloc(dummy, size)    xmalloc (size)
  197. + #define obstack_free(dummy1, dummy2)
  198. + #define obstack_init(dummy)
  199. + #endif /* not USE_OBSTACKS */
  200. + #else /* not MSDOS */
  201. + #include "obstack.h"
  202. + #endif /* not MSDOS */
  203.   
  204.   #define NCHAR (UCHAR_MAX + 1)
  205. + #ifdef MSDOS            /* walk on the save side */
  206. + #define obstack_chunk_alloc xmalloc
  207. + #else
  208.   #define obstack_chunk_alloc malloc
  209. + #endif
  210.   #define obstack_chunk_free free
  211.   
  212.   /* Balanced tree of edges and labels leaving a given trie node. */
  213. ***************
  214. *** 62,68 ****
  215. --- 101,109 ----
  216.   /* Structure returned opaquely to the caller, containing everything. */
  217.   struct kwset
  218.   {
  219. + #if !defined (MSDOS) || defined (USE_OBSTACKS)
  220.     struct obstack obstack;    /* Obstack for node allocation. */
  221. + #endif
  222.     int words;            /* Number of words in the trie. */
  223.     struct trie *trie;        /* The trie itself. */
  224.     int mind;            /* Minimum depth of an accepting node. */
  225. ***************
  226. *** 207,214 ****
  227. --- 248,260 ----
  228.                 r = links[depth], l = r->llink, t = l->rlink;
  229.                 rl = t->rlink, lr = t->llink;
  230.                 t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
  231. + #ifdef MSDOS
  232. +               l->balance = (char) (t->balance != 1 ? 0 : -1);
  233. +               r->balance = (char) (t->balance != (char) -1 ? 0 : 1);
  234. + #else
  235.                 l->balance = t->balance != 1 ? 0 : -1;
  236.                 r->balance = t->balance != (char) -1 ? 0 : 1;
  237. + #endif
  238.                 t->balance = 0;
  239.                 break;
  240.               }
  241. ***************
  242. *** 225,232 ****
  243. --- 271,283 ----
  244.                 l = links[depth], r = l->rlink, t = r->llink;
  245.                 lr = t->llink, rl = t->rlink;
  246.                 t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
  247. + #ifdef MSDOS
  248. +               l->balance = (char) (t->balance != 1 ? 0 : -1);
  249. +               r->balance = (char) (t->balance != (char) -1 ? 0 : 1);
  250. + #else
  251.                 l->balance = t->balance != 1 ? 0 : -1;
  252.                 r->balance = t->balance != (char) -1 ? 0 : 1;
  253. + #endif
  254.                 t->balance = 0;
  255.                 break;
  256.               }
  257. *** e:\tmp/RCSt1006358    Mon Sep 24 00:42:56 1990
  258. --- kwset.h    Mon Sep 24 00:39:22 1990
  259. ***************
  260. *** 26,32 ****
  261.     size_t size[1];        /* Length of each submatch. */
  262.   };
  263.   
  264. ! #if __STDC__
  265.   
  266.   typedef void *kwset_t;
  267.   
  268. --- 26,32 ----
  269.     size_t size[1];        /* Length of each submatch. */
  270.   };
  271.   
  272. ! #if __STDC__ || defined(MSDOS)
  273.   
  274.   typedef void *kwset_t;
  275.   
  276. *** e:\tmp/RCSt1006358    Mon Sep 24 00:42:58 1990
  277. --- obstack.c    Mon Sep 24 00:42:44 1990
  278. ***************
  279. *** 23,28 ****
  280. --- 23,42 ----
  281.   
  282.   #include "obstack.h"
  283.   
  284. + #ifdef MSDOS
  285. + #include <stdlib.h>
  286. + static  int _obstack_allocated_p (struct obstack *h, void *obj);
  287. + static  void _obstack_free (struct obstack *h, void *obj);
  288. + #endif /* MSDOS */
  289. + #ifdef MSDOS
  290. + /* We don't gain anything from malloc()'ing on a 4k page boundary,
  291. +    if we don't have virtual memory.  We only waste real memory.  */
  292. + #define PAGE_SIZE     256
  293. + #else
  294. + #define PAGE_SIZE    4096
  295. + #endif
  296.   #ifdef __STDC__
  297.   #define POINTER void *
  298.   #else
  299. ***************
  300. *** 76,82 ****
  301.         int extra = 4;
  302.         if (extra < DEFAULT_ROUNDING)
  303.       extra = DEFAULT_ROUNDING;
  304. !       size = 4096 - extra;
  305.       }
  306.   
  307.     h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
  308. --- 90,96 ----
  309.         int extra = 4;
  310.         if (extra < DEFAULT_ROUNDING)
  311.       extra = DEFAULT_ROUNDING;
  312. !       size = PAGE_SIZE - extra;
  313.       }
  314.   
  315.     h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
  316. *** e:\tmp/RCSt1006358    Mon Sep 24 00:42:58 1990
  317. --- obstack.h    Mon Sep 24 00:42:48 1990
  318. ***************
  319. *** 179,184 ****
  320. --- 179,189 ----
  321.   int obstack_alignment_mask (struct obstack *obstack);
  322.   int obstack_chunk_size (struct obstack *obstack);
  323.   
  324. + /* these were missing [tho] */
  325. + extern  void _obstack_begin (struct obstack *h, int size, int alignment,
  326. +                  void *(*chunkfun)(), void (*freefun)());
  327. + extern  void _obstack_newchunk (struct obstack *h, int length);
  328.   #endif /* __STDC__ */
  329.   
  330.   /* Non-ANSI C cannot really support alternative functions for these macros,
  331. *** e:\tmp/RCSt1006358    Mon Sep 24 00:43:00 1990
  332. --- std.c    Mon Sep 24 00:41:24 1990
  333. ***************
  334. *** 1,8 ****
  335. --- 1,22 ----
  336.   /* std.c - compensate for a few missing library functions.
  337.      In the Public Domain; written by Mike Haertel. */
  338.   
  339. + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
  340. +    This port is also distributed under the terms of the
  341. +    GNU General Public License as published by the
  342. +    Free Software Foundation.
  343. +    Please note that this file is not identical to the
  344. +    original GNU release, you should have received this
  345. +    code as patch to the official release.
  346. +    $Header: e:/gnu/fgrep/RCS/std.c 1.1.0.2 90/09/24 00:37:55 tho Exp $
  347. +  */
  348.   #include "std.h"
  349. + #ifndef MSDOS
  350.   #include "unix.h"
  351. + #endif /* MSDOS */
  352.   
  353.   #ifdef X_memmove
  354.   PTR
  355. *** e:\tmp/RCSt1006358    Mon Sep 24 00:43:00 1990
  356. --- std.h    Mon Sep 24 00:39:24 1990
  357. ***************
  358. *** 1,6 ****
  359. --- 1,18 ----
  360.   /* std.h - automagically adapt to old and new compilers.
  361.      In the Public Domain; written by Mike Haertel. */
  362.   
  363. + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
  364. +    This port is also distributed under the terms of the
  365. +    GNU General Public License as published by the
  366. +    Free Software Foundation.
  367. +    Please note that this file is not identical to the
  368. +    original GNU release, you should have received this
  369. +    code as patch to the official release.
  370. +    $Header: e:/gnu/fgrep/RCS/std.h 1.1.0.3 90/09/24 00:38:01 tho Exp $
  371. +  */
  372.   #if __STDC__
  373.   
  374.   #include <stddef.h>
  375. ***************
  376. *** 88,94 ****
  377. --- 100,108 ----
  378.   #endif
  379.   
  380.   /* Declaring this here should be safe.  Some losing <errno.h>'s don't. */
  381. + #ifndef MSDOS
  382.   extern int errno;
  383. + #endif
  384.   
  385.   /* Adapt variable arguments to new implementations (with <stdarg.h>)
  386.      or old (which are assumed to have <varargs.h>). */
  387. ***************
  388. *** 122,127 ****
  389. --- 136,146 ----
  390.   #endif
  391.   
  392.   /* Declarations of traditional library routines. */
  393. + #ifdef MSDOS
  394. + #include <stdlib.h>
  395. + extern void *xmalloc (size_t size);
  396. + extern void *xrealloc (void *ptr, size_t size);
  397. + #else /* not MSDOS */
  398.   extern double EXFUN(atof, (const char *));
  399.   extern int EXFUN(atoi, (const char *));
  400.   extern long int EXFUN(atol, (const char *));
  401. ***************
  402. *** 143,145 ****
  403. --- 162,165 ----
  404.   #ifdef X_strerror
  405.   extern char *EXFUN(strerror, (int));
  406.   #endif
  407. + #endif /* not MSDOS */
  408.