Minor changes. imalloc uses xmalloc now.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 26 Sep 1994 16:30:55 +0000 (16:30 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 26 Sep 1994 16:30:55 +0000 (16:30 +0000)
dfa/Makefile
dfa/agrep.c
dfa/imalloc.c
dfa/readfile.c

index d1b05b8..5c5c02e 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.1 1994-09-26 10:16:52 adam Exp $
+# $Id: Makefile,v 1.2 1994-09-26 16:30:55 adam Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include
@@ -12,6 +12,7 @@ DEFS=$(INCLUDE) -DYACC -DYYDEBUG=1 -DMEMDEBUG=1
 LIB=../lib/dfa.a 
 PO = regexp.o imalloc.o states.o set.o bset.o
 CPP=cc -E
+YACC=yacc
 
 all: $(LIB)
 
@@ -44,12 +45,12 @@ depend1:
        mv Makefile Makefile.tmp
        $(YACC) $(YFLAGS) regexp.y
        sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) -M $(DEFS) *.c |sed 's/y\.tab\.o/regexp.o/g' >>Makefile
+       $(CPP) -M $(DEFS) *.c |sed 's/y\.tab\.o/regexp.o/g'|sed 's/y\.tab\.c/regexp.y/g' >>Makefile
        -rm Makefile.tmp
 
 depend2:
        $(YACC) $(YFLAGS) regexp.y
-       $(CPP) -M $(DEFS) *.c |sed 's/y\.tab\.o/regexp.o/g' >.depend
+       $(CPP) -M $(DEFS) *.c |sed 's/y\.tab\.o/regexp.o/g'|sed 's/y\.tab\.c/regexp.y/g' >.depend
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 758c865..3c4e242 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: agrep.c,v $
- * Revision 1.1  1994-09-26 10:16:52  adam
+ * Revision 1.2  1994-09-26 16:30:56  adam
+ * Minor changes. imalloc uses xmalloc now.
+ *
+ * Revision 1.1  1994/09/26  10:16:52  adam
  * First version of dfa module in alex. This version uses yacc to parse
  * regular expressions. This should be hand-made instead.
  *
@@ -22,8 +25,8 @@
 
 
 #include <util.h>
+#include <dfa.h>
 #include "imalloc.h"
-#include "dfa.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -61,11 +64,9 @@ char **argv;
             {
                 switch( **argv )
                 {
-#ifdef __STDC__
                 case 'V':
                     fprintf( stderr, "%s: %s %s\n", prog, __DATE__, __TIME__ );
                     continue;
-#endif
                 case 'v':
                     dfa_verbose = 1;
                     continue;
@@ -261,7 +262,7 @@ char **argv;
             if( !pattern )
             {
                 pattern = *argv;
-                i = parse_dfa( dfa, &pattern, grep_chars );
+                i = parse_dfa( dfa, &pattern, dfa_thompson_chars );
                 if( i || *pattern )
                 {
                     fprintf( stderr, "%s: illegal pattern\n", prog );
index 64df1fe..7e9ec71 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: imalloc.c,v $
- * Revision 1.1  1994-09-26 10:16:54  adam
+ * Revision 1.2  1994-09-26 16:30:56  adam
+ * Minor changes. imalloc uses xmalloc now.
+ *
+ * Revision 1.1  1994/09/26  10:16:54  adam
  * First version of dfa module in alex. This version uses yacc to parse
  * regular expressions. This should be hand-made instead.
  *
@@ -31,7 +34,7 @@ void *imalloc (size_t size)
 {
 #ifdef MEMDEBUG
     size_t words = (4*sizeof(unsigned) -1 + size)/sizeof(unsigned);
-    char *p = (char *)malloc( words*sizeof(unsigned) );
+    char *p = (char *)xmalloc( words*sizeof(unsigned) );
     if( !p )
         log (LOG_FATAL, "No memory: imalloc(%u); c/f %d/%d; %ld/%ld",
            size, alloc_calls, free_calls, alloc, max_alloc );
@@ -45,7 +48,7 @@ void *imalloc (size_t size)
     ++alloc_calls;
     return (void *) p;
 #else
-    void *p = (void *)malloc( size );
+    void *p = (void *)xmalloc( size );
     if( !p )
         log (LOG_FATAL, "Out of memory (imalloc)" );
     return p;
@@ -56,7 +59,7 @@ void *icalloc (size_t size)
 {
 #ifdef MEMDEBUG
     unsigned words = (4*sizeof(unsigned) -1 + size)/sizeof(unsigned);
-    char *p = (char *) calloc( words*sizeof(unsigned), 1 );
+    char *p = (char *) xcalloc( words*sizeof(unsigned), 1 );
     if( !p )
         log (LOG_FATAL, "No memory: icalloc(%u); c/f %d/%d; %ld/%ld",
            size, alloc_calls, free_calls, alloc, max_alloc );
@@ -70,7 +73,7 @@ void *icalloc (size_t size)
     ++alloc_calls;
     return (void *)p;
 #else
-    void p = (void) calloc( size, 1 );
+    void p = (void) xcalloc( size, 1 );
     if( !p )
         log (LOG_FATAL, "Out of memory (icalloc)" );
     return p;
@@ -94,14 +97,14 @@ void i_free (void *p)
     alloc -= size;
     if( alloc < 0L )
         log (LOG_FATAL,"Internal: ifree(%u) negative alloc.", size );
-    free( (unsigned *) p-2 );
+    xfree( (unsigned *) p-2 );
 }
 #else
 #ifndef ANSI
 void i_free (void *p)
 {
     if (p)
-        free( p );
+        xfree( p );
 }
 #endif
 #endif
index cd3f6e4..f0e4aed 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: readfile.c,v $
- * Revision 1.1  1994-09-26 10:16:56  adam
+ * Revision 1.2  1994-09-26 16:30:57  adam
+ * Minor changes. imalloc uses xmalloc now.
+ *
+ * Revision 1.1  1994/09/26  10:16:56  adam
  * First version of dfa module in alex. This version uses yacc to parse
  * regular expressions. This should be hand-made instead.
  *
@@ -35,7 +38,7 @@ static void
     read_tail   (void);
 
 static char
-    *read_line  ();
+    *read_line  (void);
 
 static void prep (char **s)
 {
@@ -96,9 +99,9 @@ static void read_rules (DFA **dfap)
             prep( &s );                   
             /* now parse regular expression */
            if (ccluse)
-                i = parse_dfa( dfa, &s, ccl_chars );
+                i = parse_dfa( dfa, &s, dfa_ccl_chars );
             else
-                i = parse_dfa( dfa, &s, thompson_chars );
+                i = parse_dfa( dfa, &s, dfa_thompson_chars );
 
             if( dfa->rule > 1 )
                 fputs( "\t\tYY_BREAK\n", outf );