RPA Toolkit
work on windows build for REX
authorMartin Stoilov <martin@rpasearch.com>
Wed, 22 Feb 2012 06:41:06 +0000 (22:41 -0800)
committerMartin Stoilov <martin@rpasearch.com>
Wed, 22 Feb 2012 06:41:06 +0000 (22:41 -0800)
17 files changed:
build/windows/i386/makefile
build/windows/x64/makefile
rex/build/windows/i386/makefile [new file with mode: 0644]
rex/build/windows/rex.mk [new file with mode: 0644]
rex/build/windows/x64/makefile [new file with mode: 0644]
rex/rexcompiler.c
rex/rexdfa.c
rex/rexdfa.h
rex/rextransition.c
rex/rextransition.h
rexgrep/build/windows/i386/makefile
rexgrep/build/windows/x64/makefile
rexgrep/rexgrep.c
rexgrep/unix/rexgrepdep.h
rexgrep/win32/main.c
rexgrep/win32/rexgrepdep.c
rexgrep/win32/rexgrepdep.h

index bca3252..1470179 100644 (file)
@@ -26,7 +26,8 @@ SUBPROJECTS= \
        $(RPATK_DIR)\rlib\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rvm\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rpa\build\$(PORT)\$(ARCH)+ \
-       $(RPATK_DIR)\rgrep\build\$(PORT)\$(ARCH)+ \
+       $(RPATK_DIR)\rex\build\$(PORT)\$(ARCH)+ \
+       $(RPATK_DIR)\rpagrep\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rjs\build\$(PORT)\$(ARCH)+ \
 
 
index acb3b84..172a2f9 100644 (file)
@@ -26,7 +26,8 @@ SUBPROJECTS= \
        $(RPATK_DIR)\rlib\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rvm\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rpa\build\$(PORT)\$(ARCH)+ \
-       $(RPATK_DIR)\rgrep\build\$(PORT)\$(ARCH)+ \
+       $(RPATK_DIR)\rex\build\$(PORT)\$(ARCH)+ \
+       $(RPATK_DIR)\rpagrep\build\$(PORT)\$(ARCH)+ \
        $(RPATK_DIR)\rjs\build\$(PORT)\$(ARCH)+ \
 
 
diff --git a/rex/build/windows/i386/makefile b/rex/build/windows/i386/makefile
new file mode 100644 (file)
index 0000000..22831a4
--- /dev/null
@@ -0,0 +1,60 @@
+
+!IF "$(BLDCFG)" == ""
+BLDCFG=debug
+!ENDIF 
+
+!IF "$(BLDCFG)" != "release" && "$(BLDCFG)" != "debug"
+!MESSAGE Invalid configuration "$(BLDCFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro BLDCFG on the command line. For example:
+!MESSAGE 
+!MESSAGE nmake /f makefile BLDCFG=debug
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "release" ( Win32 x86 release build )
+!MESSAGE "debug"   ( Win32 x86 debug build)
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF
+
+PORT=windows
+ARCH=i386
+SRC_DIR=..\..\..
+RPATK_DIR=..\..\..\..
+INCLUDE_DIRS=/I"$(RPATK_DIR)" /I"$(RPATK_DIR)\arch\$(PORT)\$(ARCH)"
+
+
+!IF "$(BLDCFG)" == "release"
+
+OUTDIR=.\out
+CPP_FLAGS=/nologo $(INCLUDE_DIRS) /Zp1 /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fo"$(OUTDIR)\\" /FD /c 
+
+!ELSEIF  "$(BLDCFG)" == "debug"
+
+OUTDIR=.\out
+CPP_FLAGS=/nologo $(INCLUDE_DIRS) /Zp1 /Zi /W3 /EHsc  /Od /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "_CONSOLE" /Fo"$(OUTDIR)\\" /FD  /c
+
+!ENDIF
+
+CPP_FLAGS=$(CPP_FLAGS)
+
+!IF "$(DBG_CONSOLE)" == "shut"
+CPP_FLAGS=$(CPP_FLAGS) /D "_SHUT_CONSOLE"
+!ENDIF
+
+
+CPP=cl.exe
+LINK32=lib.exe
+LINK32_FLAGS=/nologo /machine:I386 /out:"$(OUTDIR)\$(TARGET)"
+# LINK32=link.exe
+# LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\$(TARGET)" 
+
+include "..\rex.mk"
diff --git a/rex/build/windows/rex.mk b/rex/build/windows/rex.mk
new file mode 100644 (file)
index 0000000..49cdb35
--- /dev/null
@@ -0,0 +1,66 @@
+TARGET=rex.lib\r
+LINK32_OBJS= \\r
+       "$(OUTDIR)\rexcompiler.obj" \\r
+       "$(OUTDIR)\rexdb.obj" \\r
+       "$(OUTDIR)\rexdfa.obj" \\r
+       "$(OUTDIR)\rexdfaconv.obj" \\r
+       "$(OUTDIR)\rexdfasimulator.obj" \\r
+       "$(OUTDIR)\rexfragment.obj" \\r
+       "$(OUTDIR)\rexnfasimulator.obj" \\r
+       "$(OUTDIR)\rexstate.obj" \\r
+       "$(OUTDIR)\rextransition.obj" \\r
+\r
+\r
+ALL : "$(OUTDIR)\$(TARGET)"\r
+\r
+CLEAN :\r
+       -@erase "$(OUTDIR)\$(TARGET)"\r
+       -@erase $(LINK32_OBJS)\r
+       -@erase *.pdb *.idb *.pch\r
+       -@rd /S /Q "$(OUTDIR)"\r
+\r
+"$(OUTDIR)" :\r
+       if not exist "$(OUTDIR)\$(NULL)" mkdir "$(OUTDIR)"\r
+\r
+\r
+"$(OUTDIR)\$(TARGET)" : "$(OUTDIR)" $(LINK32_OBJS)\r
+       $(LINK32) @<<\r
+       $(LINK32_FLAGS) $(LINK32_OBJS)\r
+<<\r
+\r
+SOURCE="$(SRC_DIR)\rexcompiler.c"\r
+"$(OUTDIR)\rexcompiler.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexdb.c"\r
+"$(OUTDIR)\rexdb.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexdfa.c"\r
+"$(OUTDIR)\rexdfa.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexdfaconv.c"\r
+"$(OUTDIR)\rexdfaconv.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexdfasimulator.c"\r
+"$(OUTDIR)\rexdfasimulator.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexfragment.c"\r
+"$(OUTDIR)\rexfragment.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexnfasimulator.c"\r
+"$(OUTDIR)\rexnfasimulator.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+\r
+SOURCE="$(SRC_DIR)\rexstate.c"\r
+"$(OUTDIR)\rexstate.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
+    \r
+SOURCE="$(SRC_DIR)\rextransition.c"\r
+"$(OUTDIR)\rextransition.obj" : $(SOURCE) $(OUTDIR)\r
+    $(CPP) $(CPP_FLAGS) $(SOURCE)\r
\ No newline at end of file
diff --git a/rex/build/windows/x64/makefile b/rex/build/windows/x64/makefile
new file mode 100644 (file)
index 0000000..77b65f2
--- /dev/null
@@ -0,0 +1,60 @@
+
+!IF "$(BLDCFG)" == ""
+BLDCFG=debug
+!ENDIF 
+
+!IF "$(BLDCFG)" != "release" && "$(BLDCFG)" != "debug"
+!MESSAGE Invalid configuration "$(BLDCFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro BLDCFG on the command line. For example:
+!MESSAGE 
+!MESSAGE nmake /f makefile BLDCFG=debug
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "release" ( Win32 x86 release build )
+!MESSAGE "debug"   ( Win32 x86 debug build)
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF
+
+PORT=windows
+ARCH=x64
+SRC_DIR=..\..\..
+RPATK_DIR=..\..\..\..
+INCLUDE_DIRS=/I"$(RPATK_DIR)" /I"$(RPATK_DIR)\arch\$(PORT)\$(ARCH)"
+
+
+!IF "$(BLDCFG)" == "release"
+
+OUTDIR=.\out
+CPP_FLAGS=/nologo $(INCLUDE_DIRS) /Zp1 /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Fo"$(OUTDIR)\\" /FD /c 
+
+!ELSEIF  "$(BLDCFG)" == "debug"
+
+OUTDIR=.\out
+CPP_FLAGS=/nologo $(INCLUDE_DIRS) /Zp1 /Zi /W3 /EHsc  /Od /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "_CONSOLE" /Fo"$(OUTDIR)\\" /FD  /c
+
+!ENDIF
+
+CPP_FLAGS=$(CPP_FLAGS)
+
+!IF "$(DBG_CONSOLE)" == "shut"
+CPP_FLAGS=$(CPP_FLAGS) /D "_SHUT_CONSOLE"
+!ENDIF
+
+
+CPP=cl.exe
+LINK32=lib.exe
+LINK32_FLAGS=/nologo /LTCG /out:"$(OUTDIR)\$(TARGET)"
+# LINK32=link.exe
+# LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\$(TARGET)" 
+
+include "..\rex.mk"
index 71e5658..269d268 100644 (file)
@@ -68,7 +68,7 @@ static int rex_compiler_isspace(int c)
 
 static int rex_compiler_isblank(int c)
 {
-       return isblank(c);
+       return r_strchr(" \t", c) ? 1 : 0;
 }
 
 
@@ -486,8 +486,6 @@ static int rex_compiler_qfactor(rexcompiler_t *co, rexdb_t *rexdb)
                                frag1 = rex_fragment_cat(rexdb, frag1, frag2);
                                FPUSH(co, frag1);
                        }
-//                     fwrite(fstart, 1, fend - fstart, stdout);
-//                     fprintf(stdout, "{%ld,%ld}\n", co->fromcount, co->tocount);
                        co->start = saved_start;
                        co->end = saved_end;
                        co->ptr = saved_ptr;
index 7bd916c..6de0644 100644 (file)
@@ -117,9 +117,8 @@ rexuint_t rex_dfa_next(rexdfa_t *dfa, rexuint_t nstate, rexchar_t input)
                        max = mid;
                }
        }
-       min -= (min > 0) ? 1 : 0;
-       t = REX_DFA_TRANSITION(dfa, nstate, min);
-       return (input >= t->lowin && input <= t->highin) ? t->state : 0;
+       t = REX_DFA_TRANSITION(dfa, nstate, min-1);
+       return t->state;
 }
 
 
index 9154bfb..0a2830b 100644 (file)
@@ -61,6 +61,58 @@ typedef REX_CHAR_TYPE rexchar_t;
 #define REX_CHAR_MAX ((rexchar_t)-1)
 #define REX_CHAR_MIN ((rexchar_t)0)
 
+
+/**
+ * Define DFA sub-state.
+ */
+typedef struct rexdfss_s {
+       rexuint_t type;                                 /**< This is the original NFA state type(substate of a DFA state). */
+       rexuint_t uid;                                  /**< Unique ID of the NFA state(substate of a DFA state). */
+       rexuserdata_t userdata;                 /**< If this is an accepting sub-state, this parameter has the value specified in the @ref rex_db_addexpression call.
+                                                                                This parameter is used to track which regular expression is matching, when the DFA gets to accepting state. */
+} rexdfss_t;
+
+
+/**
+ * Define DFA transition.
+ */
+typedef struct rexdft_s {
+       rexchar_t lowin;                                /**< Low input boundary */
+       rexchar_t highin;                               /**< High input boundary */
+       rexuint_t state;                                /**< New state to go to if the input is within the boundary */
+} rexdft_t;
+
+
+/**
+ * State definition
+ */
+typedef struct rexdfs_s {
+       rexuint_t type;                                 /**< Type of DFA state. */
+       rexuint_t trans;                                /**< The offset of the first transition for this state in the dfa->trans array. */
+       rexuint_t ntrans;                               /**< Total number of transitions. */
+       rexuint_t accsubstates;                 /**< The offset of the first accepting sub-state for this state in the dfa->accsubstates array. */
+       rexuint_t naccsubstates;                /**< Total number of accepting sub-states. */
+       rexuint_t substates;                    /**< The offset of the first sub-state for this state in the dfa->substates array. */
+       rexuint_t nsubstates;                   /**< Total number of sub-states. */
+} rexdfs_t;
+
+
+/**
+ * Define DFA.
+ */
+typedef struct rexdfa_s {
+       rexuint_t nstates;                              /**< Total number of states. */
+       rexdfs_t *states;                               /**< Array of states */
+       rexuint_t ntrans;                               /**< Total number of transitions */
+       rexdft_t *trans;                                /**< Array of transitions, all states transitions are recorded here. Each state keeps the offset of its first transition it this array */
+       rexuint_t naccsubstates;                /**< Total number of accepting substates */
+       rexdfss_t *accsubstates;                /**< Array of accepting sub-states, all states accepting sub-states are recorded here. */
+       rexuint_t nsubstates;                   /**< Total number of substates */
+       rexdfss_t *substates;                   /**< Array of sub-states, all states sub-states are recorded here. */
+       rexuword_t reserved[64];
+} rexdfa_t;
+
+
 /**
  * Definition of state types.
  */
@@ -143,7 +195,7 @@ typedef enum {
                        rexuint_t mid, min = 0, max = REX_DFA_STATE(__dfa__, __nstate__)->ntrans; \
                        while (max > min) { \
                                mid = (min + max)/2; \
-                               t = REX_DFA_TRANSITION(__dfa__, nstate, mid); \
+                               t = REX_DFA_TRANSITION(__dfa__, __nstate__, mid); \
                                if ((__input__) >= t->lowin) { \
                                        min = mid + 1; \
                                } else { \
@@ -154,59 +206,6 @@ typedef enum {
                        (t->state); \
                })
 
-
-
-/**
- * Define DFA sub-state.
- */
-typedef struct rexdfss_s {
-       rexuint_t type;                                 /**< This is the original NFA state type(substate of a DFA state). */
-       rexuint_t uid;                                  /**< Unique ID of the NFA state(substate of a DFA state). */
-       rexuserdata_t userdata;                 /**< If this is an accepting sub-state, this parameter has the value specified in the @ref rex_db_addexpression call.
-                                                                                This parameter is used to track which regular expression is matching, when the DFA gets to accepting state. */
-} rexdfss_t;
-
-
-/**
- * Define DFA transition.
- */
-typedef struct rexdft_s {
-       rexchar_t lowin;                                /**< Low input boundary */
-       rexchar_t highin;                               /**< High input boundary */
-       rexuint_t state;                                /**< New state to go to if the input is within the boundary */
-} rexdft_t;
-
-
-/**
- * State definition
- */
-typedef struct rexdfs_s {
-       rexuint_t type;                                 /**< Type of DFA state. */
-       rexuint_t trans;                                /**< The offset of the first transition for this state in the dfa->trans array. */
-       rexuint_t ntrans;                               /**< Total number of transitions. */
-       rexuint_t accsubstates;                 /**< The offset of the first accepting sub-state for this state in the dfa->accsubstates array. */
-       rexuint_t naccsubstates;                /**< Total number of accepting sub-states. */
-       rexuint_t substates;                    /**< The offset of the first sub-state for this state in the dfa->substates array. */
-       rexuint_t nsubstates;                   /**< Total number of sub-states. */
-} rexdfs_t;
-
-
-/**
- * Define DFA.
- */
-typedef struct rexdfa_s {
-       rexuint_t nstates;                              /**< Total number of states. */
-       rexdfs_t *states;                               /**< Array of states */
-       rexuint_t ntrans;                               /**< Total number of transitions */
-       rexdft_t *trans;                                /**< Array of transitions, all states transitions are recorded here. Each state keeps the offset of its first transition it this array */
-       rexuint_t naccsubstates;                /**< Total number of accepting substates */
-       rexdfss_t *accsubstates;                /**< Array of accepting sub-states, all states accepting sub-states are recorded here. */
-       rexuint_t nsubstates;                   /**< Total number of substates */
-       rexdfss_t *substates;                   /**< Array of sub-states, all states sub-states are recorded here. */
-       rexuword_t reserved[64];
-} rexdfa_t;
-
-
 rexdfa_t *rex_dfa_create(rexuint_t nstates, rexuint_t ntrans, rexuint_t naccsubstates, rexuint_t nsubstates);
 void rex_dfa_destroy(rexdfa_t *dfa);
 void rex_dfa_dumpstate(rexdfa_t *dfa, rexuint_t nstate);
index 07d760a..caa84f7 100644 (file)
@@ -175,74 +175,6 @@ startover:
 }
 
 
-void rex_transitions_uniqueranges(rarray_t *dest, rarray_t *src)
-{
-       long i, j;
-       rex_transition_t *it, *jt, *t;
-       rex_transition_t temp;
-
-       r_memset(&temp, 0, sizeof(temp));
-       for (j = 0; j < r_array_length(src); j++) {
-               t = (rex_transition_t *)r_array_slot(src, j);
-               temp.lowin = t->lowin;
-               temp.highin = t->highin;
-               r_array_add(dest, &temp);
-       }
-
-startover:
-       for (i = 0; i < r_array_length(dest); i++) {
-               it = (rex_transition_t *)r_array_slot(dest, i);
-               for (j = 0; j < r_array_length(dest); j++) {
-                       jt = (rex_transition_t *)r_array_slot(dest, j);
-                       rexchar_t a1 = it->lowin;
-                       rexchar_t a2 = it->highin;
-                       rexchar_t b1 = jt->lowin;
-                       rexchar_t b2 = jt->highin;
-
-                       if (i == j) {
-                               /*
-                                * Same transition.
-                                */
-                               continue;
-                       }
-                       if (a1 == b1 && a2 == b2) {
-                               /*
-                                * The same. Remove one
-                                */
-                               r_array_delete(dest, j);
-                               goto startover;
-                       } else if (b1 > a1 && b2 < a2) {
-                               it->lowin = a1;
-                               it->highin = b1 - 1;
-                               jt->lowin = b1;
-                               jt->highin = b2;
-                               rex_transitions_add(dest, b2+1, a2, 0, 0);
-                               goto startover;
-                       } else if (b1 > a1 && b1 <= a2 && b2 > a2) {
-                               it->lowin = a1;
-                               it->highin = b1-1;
-                               jt->lowin = b1;
-                               jt->highin = a2;
-                               rex_transitions_add(dest, a2+1, b2, 0, 0);
-                               goto startover;
-                       } else if (a1 == b1 && b2 < a2) {
-                               it->lowin = a1;
-                               it->highin = b2;
-                               jt->lowin = b2+1;
-                               jt->highin = a2;
-                               goto startover;
-                       } else if (b1 > a1 && b2 == a2) {
-                               it->lowin = a1;
-                               it->highin = b1-1;
-                               jt->lowin = b1;
-                               jt->highin = b2;
-                               goto startover;
-                       }
-               }
-       }
-}
-
-
 void rex_transitions_renamedestination(rarray_t *trans, long dstold, long dstnew)
 {
        long index;
index 299dc12..90d5612 100644 (file)
@@ -63,7 +63,6 @@ typedef struct rex_transition_s {
 rex_transition_t *rex_transitions_add(rarray_t *trans, rexchar_t c1, rexchar_t c2, unsigned long srcuid, unsigned long dstuid);
 rex_transition_t *rex_transitions_add_e(rarray_t *etrans, unsigned long srcuid, unsigned long dstuid);
 void rex_transitions_normalize(rarray_t *trans);
-void rex_transitions_uniqueranges(rarray_t *dest, rarray_t *src);
 void rex_transitions_negative(rarray_t *dtrans, rarray_t *strans, unsigned long srcuid, unsigned long dstuid);
 rex_transition_t *rex_transitions_find(rarray_t *trans, rexchar_t c);
 void rex_transitions_renamedestination(rarray_t *trans, long dstold, long dstnew);
index fba06b5..8cd999c 100644 (file)
@@ -25,14 +25,13 @@ NULL=nul
 !ENDIF
 
 
-RGREP=rgrep.exe
+RGREP=rexgrep.exe
 PORT=windows
 ARCH=i386
 SRC_DIR=..\..\..
 DEPSRC_DIR=..\..\..\win32
 RPATK_DIR=..\..\..\..
-RPA_LIB="$(RPATK_DIR)\rpa\build\$(PORT)\$(ARCH)\out\rpa.lib"
-RVM_LIB="$(RPATK_DIR)\rvm\build\$(PORT)\$(ARCH)\out\rvm.lib"
+REX_LIB="$(RPATK_DIR)\rex\build\$(PORT)\$(ARCH)\out\rex.lib"
 RLIB_LIB="$(RPATK_DIR)\rlib\build\$(PORT)\$(ARCH)\out\rlib.lib"
 INCLUDE_DIRS=/I"$(SRC_DIR)" /I"$(SRC_DIR)\win32" /I"$(RPATK_DIR)" /I"$(RPATK_DIR)\arch\$(PORT)\$(ARCH)"
 
@@ -51,7 +50,7 @@ LINK_DEBUG=/DEBUG
 !ENDIF
 
 CPP_FLAGS=$(CPP_FLAGS)
-LIBS=$(RPA_LIB) $(RVM_LIB) $(RLIB_LIB)
+LIBS=$(REX_LIB) $(RLIB_LIB)
 
 CPP=cl.exe
 # LINK32=lib.exe
@@ -60,10 +59,9 @@ LINK32=link.exe
 LINK32_FLAGS=$(LIBS) kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /incremental:no /machine:I386 $(LINK_DEBUG)
 
 RGREP_OBJS= \
-       "$(OUTDIR)\rpagrep.obj" \
-       "$(OUTDIR)\rpagreputf.obj" \
+       "$(OUTDIR)\rexgrep.obj" \
        "$(OUTDIR)\fsenumwin.obj" \
-       "$(OUTDIR)\rpagrepdep.obj" \
+       "$(OUTDIR)\rexgrepdep.obj" \
        "$(OUTDIR)\main.obj" \
        
 
@@ -85,16 +83,12 @@ CLEAN :
 <<
 
 
-SOURCE="$(SRC_DIR)\rpagrep.c"
-"$(OUTDIR)\rpagrep.obj" : $(SOURCE) "$(OUTDIR)"
+SOURCE="$(SRC_DIR)\rexgrep.c"
+"$(OUTDIR)\rexgrep.obj" : $(SOURCE) "$(OUTDIR)"
        $(CPP) $(CPP_FLAGS) $(SOURCE)
 
-SOURCE="$(SRC_DIR)\rpagreputf.c"
-"$(OUTDIR)\rpagreputf.obj" : $(SOURCE) "$(OUTDIR)"
-       $(CPP) $(CPP_FLAGS) $(SOURCE)
-
-SOURCE="$(DEPSRC_DIR)\rpagrepdep.c"
-"$(OUTDIR)\rpagrepdep.obj" : $(SOURCE) "$(OUTDIR)"
+SOURCE="$(DEPSRC_DIR)\rexgrepdep.c"
+"$(OUTDIR)\rexgrepdep.obj" : $(SOURCE) "$(OUTDIR)"
        $(CPP) $(CPP_FLAGS) $(SOURCE)
 
 SOURCE="$(DEPSRC_DIR)\fsenumwin.c"
index 5d768cf..aabfe34 100644 (file)
@@ -25,14 +25,13 @@ NULL=nul
 !ENDIF
 
 
-RGREP=rgrep.exe
+RGREP=rexgrep.exe
 PORT=windows
 ARCH=x64
 SRC_DIR=..\..\..
 DEPSRC_DIR=..\..\..\win32
 RPATK_DIR=..\..\..\..
-RPA_LIB="$(RPATK_DIR)\rpa\build\$(PORT)\$(ARCH)\out\rpa.lib"
-RVM_LIB="$(RPATK_DIR)\rvm\build\$(PORT)\$(ARCH)\out\rvm.lib"
+REX_LIB="$(RPATK_DIR)\rex\build\$(PORT)\$(ARCH)\out\rex.lib"
 RLIB_LIB="$(RPATK_DIR)\rlib\build\$(PORT)\$(ARCH)\out\rlib.lib"
 INCLUDE_DIRS=/I"$(SRC_DIR)" /I"$(SRC_DIR)\win32" /I"$(RPATK_DIR)" /I"$(RPATK_DIR)\arch\$(PORT)\$(ARCH)"
 
@@ -51,7 +50,7 @@ LINK_DEBUG=/DEBUG
 !ENDIF
 
 CPP_FLAGS=$(CPP_FLAGS)
-LIBS=$(RPA_LIB) $(RVM_LIB) $(RLIB_LIB)
+LIBS=$(REX_LIB) $(RLIB_LIB)
 
 CPP=cl.exe
 # LINK32=lib.exe
@@ -60,12 +59,12 @@ LINK32=link.exe
 LINK32_FLAGS=$(LIBS) kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /incremental:no $(LINK_DEBUG)
 
 RGREP_OBJS= \
-       "$(OUTDIR)\rpagrep.obj" \
-       "$(OUTDIR)\rpagreputf.obj" \
-       "$(OUTDIR)\fsenumwin.obj" \
-       "$(OUTDIR)\rpagrepdep.obj" \
        "$(OUTDIR)\main.obj" \
-       
+       "$(OUTDIR)\fsenumwin.obj" \
+       "$(OUTDIR)\rexgrep.obj" \
+
+#      "$(OUTDIR)\rexgrepdep.obj" \
+
 
 ALL : "$(OUTDIR)\$(RGREP)"
 
@@ -85,16 +84,16 @@ CLEAN :
 <<
 
 
-SOURCE="$(SRC_DIR)\rpagrep.c"
-"$(OUTDIR)\rpagrep.obj" : $(SOURCE) "$(OUTDIR)"
+SOURCE="$(SRC_DIR)\rexgrep.c"
+"$(OUTDIR)\rexgrep.obj" : $(SOURCE) "$(OUTDIR)"
        $(CPP) $(CPP_FLAGS) $(SOURCE)
 
-SOURCE="$(SRC_DIR)\rpagreputf.c"
-"$(OUTDIR)\rpagreputf.obj" : $(SOURCE) "$(OUTDIR)"
+SOURCE="$(SRC_DIR)\rexgreputf.c"
+"$(OUTDIR)\rexgreputf.obj" : $(SOURCE) "$(OUTDIR)"
        $(CPP) $(CPP_FLAGS) $(SOURCE)
 
-SOURCE="$(DEPSRC_DIR)\rpagrepdep.c"
-"$(OUTDIR)\rpagrepdep.obj" : $(SOURCE) "$(OUTDIR)"
+SOURCE="$(DEPSRC_DIR)\rexgrepdep.c"
+"$(OUTDIR)\rexgrepdep.obj" : $(SOURCE) "$(OUTDIR)"
        $(CPP) $(CPP_FLAGS) $(SOURCE)
 
 SOURCE="$(DEPSRC_DIR)\fsenumwin.c"
index 958f248..184fe6f 100644 (file)
@@ -100,7 +100,7 @@ int rex_grep_match(rexgrep_t *pGrep, const char* input, const char *end)
                rexdfs_t *s;
 
                while ((inc = r_utf8_mbtowc(&wc, (const unsigned char*)input, (const unsigned char*)end)) > 0) {
-                       if ((nstate = REX_DFA_NEXT(dfa, nstate, wc)) <= 0)
+                       if ((nstate = rex_dfa_next(dfa, nstate, wc)) == 0)
                                break;
                        input += inc;
                        s = REX_DFA_STATE(dfa, nstate);
index 6a51c46..2a0be96 100644 (file)
@@ -18,8 +18,8 @@
  *  Martin Stoilov <martin@rpasearch.com>
  */
 
-#ifndef _RPAGREPDEP_H_
-#define _RPAGREPDEP_H_
+#ifndef _REXGREPDEP_H_
+#define _REXGREPDEP_H_
 
 
 #ifdef __cplusplus
index 943138b..34259f6 100644 (file)
 #include <windows.h>
 #include "rlib/rmem.h"
 #include "rlib/rarray.h"
-#include "rpa/rpadbex.h"
-#include "rpagrep.h"
-#include "rpagrepdep.h"
+#include "rlib/rbuffer.h"
+#include "rex/rexdfaconv.h"
+#include "rex/rexdfa.h"
+//#include "rexgrep.h"
+//#include "rexgrepdep.h"
 
-rpa_buffer_t * rpa_buffer_from_wchar(const wchar_t *wstr);
+rbuffer_t * rex_buffer_from_wchar(const wchar_t *wstr);
 
 
 int usage(int argc, const wchar_t *argv[])
 {
-           fwprintf(stderr, L"RPA Grep with RPA Engine: %s \n", rpa_dbex_version());
-               fwprintf(stderr, L"Copyright (C) 2010 Martin Stoilov\n\n");
+               fwprintf(stderr, L"REX Grep - Work in progress...\n");
+               fwprintf(stderr, L"Copyright (C) 2012 Martin Stoilov\n\n");
 
                fwprintf(stderr, L"Usage: \n %s [OPTIONS] <filename>\n", argv[0]);
                fwprintf(stderr, L" OPTIONS:\n");
-               fwprintf(stderr, L"\t-e patterns              BNF Expression.\n");
-               fwprintf(stderr, L"\t-f patternfile           Read the BNF rules from a file, the last pattern will be executed.\n");
-               fwprintf(stderr, L"\t-i                       Ignore case.\n");
-               fwprintf(stderr, L"\t-m                       Match.\n");
-               fwprintf(stderr, L"\t-p                       Parse.\n");
+               fwprintf(stderr, L"\t-e patterns              Regular Expression.\n");
+               fwprintf(stderr, L"\t-f patternfile           Read Regular Expressions from a file.\n");
+               fwprintf(stderr, L"\t-b binfile               Use DFA from binfile.\n");
+               fwprintf(stderr, L"\t-c                       Compile DFA and save to binfile. Use -b option to specify the name of the file.\n");
+               fwprintf(stderr, L"\t-o, --only-matching      Show only the part of a line matching PATTERN\n");
                fwprintf(stderr, L"\t-l                       Line mode.\n");
-               fwprintf(stderr, L"\t-16                      Force UTF16 encoding.\n");
-               fwprintf(stderr, L"\t-b                       Force byte encoding.\n");
-               fwprintf(stderr, L"\t-d                       Dump a production in a tree format.\n");
-               fwprintf(stderr, L"\t-t                       Display time elapsed.\n");
-               fwprintf(stderr, L"\t-L, --list-rules         List all patterns.\n");
+               fwprintf(stderr, L"\t-N                       Use NFA.\n");
+               fwprintf(stderr, L"\t-D                       Dump states.\n");
+               fwprintf(stderr, L"\t-S                       Include DFA substates.\n");
+               fwprintf(stderr, L"\t-q                       Quiet mode.\n");
+               fwprintf(stderr, L"\t-t                       Display statistics. Works only when built in DEBUG mode.\n");
+               fwprintf(stderr, L"\t-s string                Search in string.\n");
                fwprintf(stderr, L"\t-v                       Display version information.\n");
                fwprintf(stderr, L"\t-h, --help               Display this help.\n");
-               fwprintf(stderr, L"\t    --debug-compile      Display debug compilation information.\n");
-               fwprintf(stderr, L"\t    --dump-info          Display rules info.\n");
-               fwprintf(stderr, L"\t    --dump-code rule     Display compiled code for rule.\n");
-               fwprintf(stderr, L"\t    --dump-alias         Display alias info.\n");
-               fwprintf(stderr, L"\t    --dump-records       Display rules parsing records.\n");
-               fwprintf(stderr, L"\t    --no-optimizations   Disable optimizations.\n");
-               fwprintf(stderr, L"\t    --exec-debug         Execute in debug mode.\n");
-               fwprintf(stderr, L"\t    --no-cache           Disable execution cache.\n");
-               fwprintf(stderr, L"\t    --no-bitmap          Disable expression bitmap use.\n");
 
                return 0;
 }
@@ -66,251 +60,7 @@ int usage(int argc, const wchar_t *argv[])
 
 int wmain(int argc, const wchar_t* argv[])
 {
-       unsigned long sckb;
-       int ret, scanned = 0;
-       long i;
-       rpa_grep_t *pGrep = NULL;
-       rarray_t *buffers;
 
-       buffers = r_array_create(sizeof(rpa_buffer_t *));
-       pGrep = rpa_grep_create();
-
-       if (argc <= 1) {
-               usage(argc, argv);
-               goto end;
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-t") == 0) {
-                       pGrep->showtime = 1;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--help") == 0 || wcscmp(argv[i], L"-help") == 0 || wcscmp(argv[i], L"/?") == 0 || wcscmp(argv[i], L"-h") == 0) {
-                       usage(argc, argv);
-                       goto end;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--no-bitmap") == 0) {
-                       rpa_dbex_cfgset(pGrep->hDbex, RPA_DBEXCFG_BITMAP, 0);
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--no-optimizations") == 0) {
-                       rpa_grep_optimizations(pGrep, 0);
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-c") == 0) {
-                       if (++i < argc) {
-                               rpa_buffer_t *pattern = rpa_buffer_from_wchar(argv[i]);
-                               if (!pattern) {
-                                       goto error;
-                               }
-                               rpa_grep_setup_callback(pGrep, pattern);
-                               rpa_buffer_destroy(pattern);
-                       }
-               }
-       }
-
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-f") == 0) {
-                       if (++i < argc) {
-                               rpa_buffer_t *pattern = rpa_buffer_map_file(argv[i]);
-                               if (pattern) {
-                                       ret = rpa_grep_load_pattern(pGrep, pattern);
-                                       r_array_add(buffers, &pattern);
-                               } else {
-                                       ret = -1;
-                               }
-                               if (ret < 0)
-                                       goto error;
-                       }
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-e") == 0) {
-                       if (++i < argc) {
-                               rpa_buffer_t *pattern = rpa_buffer_from_wchar(argv[i]);
-                               if (!pattern) {
-                                       goto error;
-                               }
-                               ret = rpa_grep_load_string_pattern(pGrep, pattern);
-                               rpa_buffer_destroy(pattern);
-                               if (ret < 0)
-                                       goto error;
-
-                       }
-               } 
-       }
-
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--dump-code") == 0) {
-                       if (rpa_dbex_compile(pGrep->hDbex) == 0) {
-                               if (++i < argc) {
-                                       rpa_buffer_t *code = rpa_buffer_from_wchar(argv[i]);
-                                       rpa_dbex_dumpcode(pGrep->hDbex, rpa_dbex_lookup_s(pGrep->hDbex, code->s));
-                                       rpa_buffer_destroy(code);
-                               }
-                       }
-                       goto end;
-               }
-       }
-
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--dump-info") == 0) {
-                       rpa_grep_dump_pattern_info(pGrep);
-                       goto end;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--debug-compile") == 0) {
-                       rpa_grep_debug_compile(pGrep);
-                       goto end;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--dump-alias") == 0) {
-                       rpa_grep_dump_alias_info(pGrep);
-                       goto end;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--dump-records") == 0) {
-                       rpa_grep_dump_pattern_records(pGrep);
-                       goto end;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--exec-debug") == 0) {
-                       pGrep->execdebug = 1;
-               }
-       }
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"--no-cache") == 0) {
-                       pGrep->disablecache = 1;
-               }
-       }
-
-
-       if (rpa_dbex_compile(pGrep->hDbex) < 0) {
-               rpa_errinfo_t errinfo;
-               rpa_dbex_lasterrorinfo(pGrep->hDbex, &errinfo);
-               if (errinfo.code == RPA_E_UNRESOLVEDSYMBOL) {
-                       fprintf(stdout, "ERROR: Unresolved Symbol: %s\n", errinfo.name);
-               } else {
-                       fprintf(stdout, "ERROR %ld: Compilation failed.\n", errinfo.code);
-               }
-               goto end;
-       }
-
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-L") == 0) {
-                       rpa_grep_list_patterns(pGrep);
-                       goto end;
-               } else if (wcscmp(argv[i], L"-d") == 0) {
-                       if (++i < argc) {
-                               rpa_buffer_t *pattern = rpa_buffer_from_wchar(argv[i]);
-                               if (!pattern) {
-                                       goto error;
-                               }
-                               rpa_grep_dump_pattern_tree(pGrep, pattern);
-                               rpa_buffer_destroy(pattern);
-                               goto end;
-                       }
-               } else if (wcscmp(argv[i], L"-i") == 0) {
-                       pGrep->icase = 1;
-               } else if (wcscmp(argv[i], L"-l") == 0) {
-                       pGrep->greptype = RPA_GREPTYPE_SCANLINES;
-               } else if (wcscmp(argv[i], L"-m") == 0) {
-                       pGrep->greptype = RPA_GREPTYPE_MATCH;
-               } else if (wcscmp(argv[i], L"-p") == 0) {
-                       pGrep->greptype = RPA_GREPTYPE_PARSE;
-               } else if (wcscmp(argv[i], L"-a") == 0) {
-                       pGrep->greptype = RPA_GREPTYPE_PARSEAST;
-               } else if (wcscmp(argv[i], L"-16") == 0) {
-                       pGrep->forceEncoding = RPA_GREP_FORCE_UTF16;
-               } else if (wcscmp(argv[i], L"-b") == 0) {
-                       pGrep->forceEncoding = RPA_GREP_FORCE_BYTE;
-               }
-               
-       }
-
-
-       for (i = 1; i < argc; i++) {
-               if (wcscmp(argv[i], L"-s") == 0) {
-                       if (++i < argc) {
-                               rpa_buffer_t *buf = rpa_buffer_from_wchar(argv[i]);
-                               rpa_grep_scan_buffer(pGrep, buf);
-                               rpa_buffer_destroy(buf);
-                               ++scanned;
-                       }
-               }
-       }
-
-       /* scan files */
-       for (i = 1; i < argc; i++) {
-               if (argv[i][0] != L'-') {
-                       ++scanned;
-                       rpa_grep_scan_path(pGrep, argv[i]);
-               } else if (argv[i][1] == L'e' || argv[i][1] == L'f' || argv[i][1] == L'c' || argv[i][1] == L'C'){
-                       ++i;
-               }
-               
-       }
-
-       if (!scanned) {
-               rpa_buffer_t *buf = rpa_buffer_loadfile(stdin);
-               if (buf) {
-                       rpa_grep_scan_buffer(pGrep, buf);
-                       rpa_buffer_destroy(buf);
-               }
-       }
-
-end:
-       for (i = 0; i < (long)r_array_length(buffers); i++) {
-               rpa_buffer_destroy(r_array_index(buffers, i, rpa_buffer_t*));
-       }
-       r_object_destroy((robject_t*)buffers);
-       rpa_grep_close(pGrep);
-
-
-       rpa_grep_close(pGrep);
-       sckb = (unsigned long)(pGrep->scsize/1024);
-
-       if (pGrep->showtime) {
-               unsigned long milsec;
-               unsigned long minutes;
-               double sec;
-               milsec = pGrep->scanmilisec;
-               if (milsec == 0)
-                       milsec = 1;
-               minutes = milsec/60000;
-               sec = (milsec%60000)/1000.0;
-               fwprintf(stdout, L"\ntime: %0ldm%1.3fs, %ld KB (%ld KB/sec), stack: %ld KB, memory: %ld KB (leaked %ld Bytes), cachehit: %ld \n", 
-                               minutes, sec, sckb, 1000*sckb/milsec, pGrep->usedstack / 1000, (long)r_debug_get_maxmem()/1000, (long)r_debug_get_allocmem(),
-                               pGrep->cachehit);
-       }
-
-       rpa_grep_destroy(pGrep);
-       return pGrep->ret;
-
-error:
-       rpa_grep_destroy(pGrep);
-       return 2;
+       usage(argc, argv);
+       return 0;
 }
index 6bcb90c..03d7d71 100644 (file)
 #include <windows.h>
 #include <stdio.h>
 #include <wchar.h>
-#include "rpagrep.h"
-#include "rpagrepdep.h"
+#include "rexgrep.h"
+#include "rexgrepdep.h"
 #include "fsenumwin.h"
-#include "rpagreputf.h"
 
 
-void rpa_buffer_unmap_file(rpa_buffer_t *buf)
+void rex_buffer_unmap_file(rex_buffer_t *buf)
 {
        HANDLE hFile = INVALID_HANDLE_VALUE;
        HANDLE hMapping = 0;
@@ -47,16 +46,16 @@ void rpa_buffer_unmap_file(rpa_buffer_t *buf)
 }
 
 
-rpa_buffer_t * rpa_buffer_map_file(const wchar_t *pFileName)
+rex_buffer_t * rex_buffer_map_file(const wchar_t *pFileName)
 {
-       rpa_buffer_t *buf;
+       rex_buffer_t *buf;
        char *pMappedView = 0;
        HANDLE hFile = INVALID_HANDLE_VALUE;
        HANDLE hMapping = 0;
        unsigned __int64 fileSize;
        DWORD sizeLo, sizeHi;
 
-       buf = (rpa_buffer_t *)malloc(sizeof(rpa_buffer_t));
+       buf = (rex_buffer_t *)malloc(sizeof(rex_buffer_t));
        if (!buf)
                goto error;
        hFile = CreateFile(pFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0);
@@ -74,7 +73,7 @@ rpa_buffer_t * rpa_buffer_map_file(const wchar_t *pFileName)
        buf->userdata1 = (void*)hMapping;
        buf->s = pMappedView;
        buf->size = (unsigned long)fileSize;
-       buf->destroy = rpa_buffer_unmap_file;
+       buf->destroy = rex_buffer_unmap_file;
        return buf;
 
 error:
@@ -85,13 +84,13 @@ error:
        if (pMappedView)
                UnmapViewOfFile(pMappedView);
        free(buf);
-       return (rpa_buffer_t*)0;
+       return (rex_buffer_t*)0;
 }
 
 
-rpa_buffer_t * rpa_buffer_from_wchar(const wchar_t *wstr)
+rex_buffer_t * rex_buffer_from_wchar(const wchar_t *wstr)
 {
-       rpa_buffer_t *buf;
+       rex_buffer_t *buf;
        int ret;
        int wideLen = (int)wcslen(wstr) + 1;
        int sizeNeeded = WideCharToMultiByte(
@@ -103,8 +102,8 @@ rpa_buffer_t * rpa_buffer_from_wchar(const wchar_t *wstr)
                0,
                NULL,
                NULL);
-       if (!(buf = rpa_buffer_alloc(sizeNeeded)))
-               return (rpa_buffer_t*)0;
+       if (!(buf = rex_buffer_alloc(sizeNeeded)))
+               return (rex_buffer_t*)0;
        ret = WideCharToMultiByte(
                                CP_UTF8,
                                0,
@@ -115,7 +114,7 @@ rpa_buffer_t * rpa_buffer_from_wchar(const wchar_t *wstr)
                                NULL,
                                NULL);
        if (ret <= 0) {
-               rpa_buffer_destroy(buf);
+               rex_buffer_destroy(buf);
                return NULL;
        }
        return buf;
@@ -123,45 +122,45 @@ rpa_buffer_t * rpa_buffer_from_wchar(const wchar_t *wstr)
 }
 
 
-void rpa_grep_print_filename(rpa_grep_t *pGrep)
+void rex_grep_print_filename(rexgrep_t *pGrep)
 {
        if (pGrep->filename) {
-               rpa_grep_output_utf16_string(pGrep, pGrep->filename);
-               rpa_grep_output_utf16_string(pGrep, L":\n");
+               rex_grep_output_utf16_string(pGrep, pGrep->filename);
+               rex_grep_output_utf16_string(pGrep, L":\n");
        }
        
 }
 
 
-void rpa_grep_scan_path(rpa_grep_t *pGrep, const wchar_t *path)
+void rex_grep_scan_path(rexgrep_t *pGrep, const wchar_t *path)
 {
        fs_enum_ptr pFSE;
-       rpa_buffer_t *buf;
+       rex_buffer_t *buf;
 
        if ((pFSE = fse_create(path))) {
        while (fse_next_file(pFSE)) {
                pGrep->filename = (void*)fseFileName(pFSE);
-               buf = rpa_buffer_map_file((const wchar_t*)pGrep->filename);
+               buf = rex_buffer_map_file((const wchar_t*)pGrep->filename);
                if (buf) {
-                               rpa_grep_scan_buffer(pGrep, buf);
+                               rex_grep_scan_buffer(pGrep, buf);
                                pGrep->scsize += buf->size;
-                               rpa_buffer_destroy(buf);
+                               rex_buffer_destroy(buf);
                        }
                } 
                fse_destroy(pFSE);
        } else {
                pGrep->filename = (void*)path;
-               buf = rpa_buffer_map_file((const wchar_t*)pGrep->filename);
+               buf = rex_buffer_map_file((const wchar_t*)pGrep->filename);
                if (buf) {
-                       rpa_grep_scan_buffer(pGrep, buf);
+                       rex_grep_scan_buffer(pGrep, buf);
                        pGrep->scsize += buf->size;
-                       rpa_buffer_destroy(buf);
+                       rex_buffer_destroy(buf);
                }
        }
 }
 
 
-void rpa_grep_output_char(int c)
+void rex_grep_output_char(int c)
 {
        int ret;
        int garbage = 0;
@@ -174,7 +173,7 @@ void rpa_grep_output_char(int c)
        }
 
        output[0] = output[1] = output[2] = 0;
-       ret = rpa_grep_utf16_wctomb(c, (unsigned char*)output, sizeof(output));
+       ret = rex_grep_utf16_wctomb(c, (unsigned char*)output, sizeof(output));
        if (ret > 0) {
                fwprintf(stdout, L"%s", output);
        }
index d5c11d4..6cc24b0 100644 (file)
  *  Martin Stoilov <martin@rpasearch.com>
  */
 
-#ifndef _RPAGREPDEP_H_
-#define _RPAGREPDEP_H_
+#ifndef _REXGREPDEP_H_
+#define _REXGREPDEP_H_
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-rpa_buffer_t * rpa_buffer_map_file(const wchar_t *filename);
-void rpa_grep_scan_path(rpa_grep_t *pGrep, const wchar_t *path);
+
+rbuffer_t * rex_buffer_map_file(const wchar_t *filename);
+void rex_grep_scan_path(rexgrep_t *pGrep, const wchar_t *path);
 
 
 #ifdef __cplusplus