home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
gnuish
/
fgrep11.arc
/
patches
< prev
next >
Wrap
Text File
|
1990-09-24
|
12KB
|
433 lines
*** e:\tmp/RCSt1006358 Mon Sep 24 00:42:52 1990
--- fgrep.c Mon Sep 24 00:39:18 1990
***************
*** 19,26 ****
--- 19,62 ----
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fgrep/RCS/fgrep.c 1.1.0.4 90/09/24 00:37:48 tho Exp $
+ */
+
#include "std.h"
+ #ifdef MSDOS
+ char *optarg; /* interface to getopt() */
+ int optind;
+ extern int getopt (int argc, char **argv, char *optstr);
+
+ static void error(char const *mesg,int errnum);
+ static void fatal(char const *mesg,int errnum);
+ static void compile(char const *pattern,unsigned int size);
+ static char *execute (char *buf, unsigned int size);
+ static void nlscan (char *lim);
+ static unsigned int prline (char *beg, char sep);
+ static void prpending (char *lim);
+ static int prtext (char *beg, char *lim);
+ static int fillbuf (void);
+ static void initbuf (void);
+ static void resetbuf(int desc,char const *file);
+ static int grepbuf (void);
+ static int grep(int desc,char const *file);
+ static void usage (void);
+ extern void main (int argc, char **argv);
+
+ #include <io.h>
+ #else /* not MSDOS */
#include "unix.h"
+ #endif /* not MSDOS */
#include <errno.h>
#include <stdio.h>
***************
*** 64,70 ****
}
/* Interface to handle errors and fix library lossage. */
! static PTR
DEFUN(xmalloc, (size), size_t size)
{
PTR result;
--- 100,109 ----
}
/* Interface to handle errors and fix library lossage. */
! #ifndef MSDOS
! static
! #endif
! PTR
DEFUN(xmalloc, (size), size_t size)
{
PTR result;
***************
*** 76,82 ****
}
/* Interface to handle errors and fix some library lossage. */
! static PTR
DEFUN(xrealloc, (ptr, size), PTR ptr AND size_t size)
{
PTR result;
--- 115,124 ----
}
/* Interface to handle errors and fix some library lossage. */
! #ifndef MSDOS
! static
! #endif
! PTR
DEFUN(xrealloc, (ptr, size), PTR ptr AND size_t size)
{
PTR result;
***************
*** 107,113 ****
--- 149,159 ----
if (match_fold)
for (i = 0; i < NCHAR; ++i)
+ #ifdef MSDOS
+ trans[i] = (char) TOLOWER(i);
+ #else
trans[i] = TOLOWER(i);
+ #endif
if (!(kwset = kwsalloc(match_fold ? trans : (const char *) NULL)))
fatal("memory exhausted", 0);
***************
*** 232,238 ****
--- 278,288 ----
printf("%d%c", buftotalnl + 1, sep);
}
if (out_byte)
+ #ifdef MSDOS /* MSC 5.1 needs this cast! */
+ printf("%lu%c", buftotalcc + (unsigned long) (beg - buf), sep);
+ #else
printf("%lu%c", buftotalcc + (beg - buf), sep);
+ #endif
while (beg < buflim)
{
++cc;
***************
*** 442,448 ****
--- 492,507 ----
return total;
}
+
+ #ifdef MSDOS
+ static char Program_Id[] = "fgrep";
+ static char RCS_Revision[] = "$Revision: 1.1.0.4 $";
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+ #else /* not MSDOS */
static const char version[] = "GNU fgrep, version 1.1";
+ #endif /* not MSDOS */
#define USAGE \
"usage: %s [-[[AB] ]<num>] [-[CVchilnsvwx]] [-[ef]] <expr> [<files...>]\n"
***************
*** 454,460 ****
--- 513,524 ----
exit(2);
}
+
+ #ifdef MSDOS
+ void
+ #else
int
+ #endif
DEFUN(main, (argc, argv), int argc AND char *argv[])
{
char *keys;
***************
*** 502,508 ****
--- 566,576 ----
out_before = out_after = 2;
break;
case 'V':
+ #ifdef MSDOS
+ fprintf(stderr, VERSION);
+ #else
fprintf(stderr, "%s\n", version);
+ #endif
break;
case 'b':
out_byte = 1;
*** e:\tmp/RCSt1006358 Mon Sep 24 00:42:54 1990
--- kwset.c Mon Sep 24 00:40:24 1990
***************
*** 19,24 ****
--- 19,36 ----
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fgrep/RCS/kwset.c 1.1.0.3 90/09/24 00:37:52 tho Exp $
+ */
+
#include "std.h"
/* The algorithm implemented by these routines bears a startling resemblence
***************
*** 30,39 ****
--- 42,78 ----
Vol. 18, No. 6, which describes the failure function used below. */
#include "kwset.h"
+
+ #ifdef MSDOS
+
+ #ifdef USE_OBSTACKS
+ #if defined(M_I86CM) || defined(M_I86LM)
+ #error The GNU `obstack' macros don't work with far pointers yet!
+ #else /* M_I86SM or M_I86MM */
#include "obstack.h"
+ #endif /* M_I86SM or M_I86MM */
+ #else /* not USE_OBSTACKS */
+ #undef obstack_alloc
+ #undef obstack_free
+ #undef obstack_init
+ #define obstack_alloc(dummy, size) xmalloc (size)
+ #define obstack_free(dummy1, dummy2)
+ #define obstack_init(dummy)
+ #endif /* not USE_OBSTACKS */
+
+ #else /* not MSDOS */
+
+ #include "obstack.h"
+
+ #endif /* not MSDOS */
+
#define NCHAR (UCHAR_MAX + 1)
+ #ifdef MSDOS /* walk on the save side */
+ #define obstack_chunk_alloc xmalloc
+ #else
#define obstack_chunk_alloc malloc
+ #endif
#define obstack_chunk_free free
/* Balanced tree of edges and labels leaving a given trie node. */
***************
*** 62,68 ****
--- 101,109 ----
/* Structure returned opaquely to the caller, containing everything. */
struct kwset
{
+ #if !defined (MSDOS) || defined (USE_OBSTACKS)
struct obstack obstack; /* Obstack for node allocation. */
+ #endif
int words; /* Number of words in the trie. */
struct trie *trie; /* The trie itself. */
int mind; /* Minimum depth of an accepting node. */
***************
*** 207,214 ****
--- 248,260 ----
r = links[depth], l = r->llink, t = l->rlink;
rl = t->rlink, lr = t->llink;
t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
+ #ifdef MSDOS
+ l->balance = (char) (t->balance != 1 ? 0 : -1);
+ r->balance = (char) (t->balance != (char) -1 ? 0 : 1);
+ #else
l->balance = t->balance != 1 ? 0 : -1;
r->balance = t->balance != (char) -1 ? 0 : 1;
+ #endif
t->balance = 0;
break;
}
***************
*** 225,232 ****
--- 271,283 ----
l = links[depth], r = l->rlink, t = r->llink;
lr = t->llink, rl = t->rlink;
t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl;
+ #ifdef MSDOS
+ l->balance = (char) (t->balance != 1 ? 0 : -1);
+ r->balance = (char) (t->balance != (char) -1 ? 0 : 1);
+ #else
l->balance = t->balance != 1 ? 0 : -1;
r->balance = t->balance != (char) -1 ? 0 : 1;
+ #endif
t->balance = 0;
break;
}
*** e:\tmp/RCSt1006358 Mon Sep 24 00:42:56 1990
--- kwset.h Mon Sep 24 00:39:22 1990
***************
*** 26,32 ****
size_t size[1]; /* Length of each submatch. */
};
! #if __STDC__
typedef void *kwset_t;
--- 26,32 ----
size_t size[1]; /* Length of each submatch. */
};
! #if __STDC__ || defined(MSDOS)
typedef void *kwset_t;
*** e:\tmp/RCSt1006358 Mon Sep 24 00:42:58 1990
--- obstack.c Mon Sep 24 00:42:44 1990
***************
*** 23,28 ****
--- 23,42 ----
#include "obstack.h"
+ #ifdef MSDOS
+ #include <stdlib.h>
+ static int _obstack_allocated_p (struct obstack *h, void *obj);
+ static void _obstack_free (struct obstack *h, void *obj);
+ #endif /* MSDOS */
+
+ #ifdef MSDOS
+ /* We don't gain anything from malloc()'ing on a 4k page boundary,
+ if we don't have virtual memory. We only waste real memory. */
+ #define PAGE_SIZE 256
+ #else
+ #define PAGE_SIZE 4096
+ #endif
+
#ifdef __STDC__
#define POINTER void *
#else
***************
*** 76,82 ****
int extra = 4;
if (extra < DEFAULT_ROUNDING)
extra = DEFAULT_ROUNDING;
! size = 4096 - extra;
}
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
--- 90,96 ----
int extra = 4;
if (extra < DEFAULT_ROUNDING)
extra = DEFAULT_ROUNDING;
! size = PAGE_SIZE - extra;
}
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
*** e:\tmp/RCSt1006358 Mon Sep 24 00:42:58 1990
--- obstack.h Mon Sep 24 00:42:48 1990
***************
*** 179,184 ****
--- 179,189 ----
int obstack_alignment_mask (struct obstack *obstack);
int obstack_chunk_size (struct obstack *obstack);
+ /* these were missing [tho] */
+ extern void _obstack_begin (struct obstack *h, int size, int alignment,
+ void *(*chunkfun)(), void (*freefun)());
+ extern void _obstack_newchunk (struct obstack *h, int length);
+
#endif /* __STDC__ */
/* Non-ANSI C cannot really support alternative functions for these macros,
*** e:\tmp/RCSt1006358 Mon Sep 24 00:43:00 1990
--- std.c Mon Sep 24 00:41:24 1990
***************
*** 1,8 ****
--- 1,22 ----
/* std.c - compensate for a few missing library functions.
In the Public Domain; written by Mike Haertel. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fgrep/RCS/std.c 1.1.0.2 90/09/24 00:37:55 tho Exp $
+ */
+
#include "std.h"
+ #ifndef MSDOS
#include "unix.h"
+ #endif /* MSDOS */
#ifdef X_memmove
PTR
*** e:\tmp/RCSt1006358 Mon Sep 24 00:43:00 1990
--- std.h Mon Sep 24 00:39:24 1990
***************
*** 1,6 ****
--- 1,18 ----
/* std.h - automagically adapt to old and new compilers.
In the Public Domain; written by Mike Haertel. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fgrep/RCS/std.h 1.1.0.3 90/09/24 00:38:01 tho Exp $
+ */
+
#if __STDC__
#include <stddef.h>
***************
*** 88,94 ****
--- 100,108 ----
#endif
/* Declaring this here should be safe. Some losing <errno.h>'s don't. */
+ #ifndef MSDOS
extern int errno;
+ #endif
/* Adapt variable arguments to new implementations (with <stdarg.h>)
or old (which are assumed to have <varargs.h>). */
***************
*** 122,127 ****
--- 136,146 ----
#endif
/* Declarations of traditional library routines. */
+ #ifdef MSDOS
+ #include <stdlib.h>
+ extern void *xmalloc (size_t size);
+ extern void *xrealloc (void *ptr, size_t size);
+ #else /* not MSDOS */
extern double EXFUN(atof, (const char *));
extern int EXFUN(atoi, (const char *));
extern long int EXFUN(atol, (const char *));
***************
*** 143,145 ****
--- 162,165 ----
#ifdef X_strerror
extern char *EXFUN(strerror, (int));
#endif
+ #endif /* not MSDOS */