Freitag, 4. Januar 2013

TRE

About

TRE is a library which implements regular expressions with an "approximate matching" ability. For the notion of approximation, the edit-distance is used (also known as Levenshtein distance).

TRE Installation / Quickstart

1. Download package

Website: http://laurikari.net/tre/
File: tre-0.8.0.tar.bz2

2. Build package

cd /prj/tre-0.8.0
sh
export CFLAGS='-fdata-sections -ffunction-sections -O3'
sh configure --enable-static
make

3. Install static libs

cd lib\.libs
mkdir "%USERPROFILE%\lib\tre\"
cp -v *.a "%USERPROFILE%/lib/tre/"

4. Install dynamic libs and tools

cd lib\.libs
mkdir "%USERPROFILE%\bin\tre\"
cp -v *.dll "%USERPROFILE%\bin\tre\"
cd \prj\tre-0.8.0\src\.libs
cp -v agrep.exe "%USERPROFILE%\bin\tre\"

5. Install manpages

cd \prj\tre-0.8.0\doc
mkdir "C:\cygwin\home\%USERNAME%\man\tre\"
mkdir "C:\cygwin\home\%USERNAME%\man\tre\man1\"
cp -v *.1 "C:\cygwin\home\%USERNAME%\man\tre\man1\"

6. Install headers

cd \prj\tre-0.8.0\lib
mkdir "%USERPROFILE%\include\tre\"
cp -v regex.h tre.h tre-config.h "%USERPROFILE%\include\tre\"

7. Add the above paths to custom environment script: env-tre.bat

Create file %USERPROFILE%\bin\env-tre.bat which makes the following environment changes:
Static libs in LIBRARY_PATH
Dynamic libs and tools in PATH
Headers in CPATH
Manpages in MANPATH

8. Compile the test program with dynamic linking

cd \prj\tre-0.8.0\src
cp -v agrep.c "%USERPROFILE%\Desktop"
cd "%USERPROFILE%\Desktop"
env-tre
gcc -Wall -DPACKAGE_BUGREPORT="\"Nobody@Nowhere.Com\"" -o agrep agrep.c -ltre -s
# agrep.exe: 23040 Bytes

9. Compile the test program with static linking

gcc -Wall -DPACKAGE_BUGREPORT="\"Nobody@Nowhere.Com\"" -o agrep agrep.c -static -ltre -lintl -liconv -s
# agrep.exe: 1138176 Bytes

10. Compile the test program with static linking and "--gc-sections"

env-ldneo
gcc %CFLAGS% -DPACKAGE_BUGREPORT="\"Nobody@Nowhere.Com\"" -o agrep agrep.c -static -ltre -lintl -liconv -Wl,--gc-sections -s
# agrep.exe: 1113088 Bytes (Would probably be smaller if libintl and libiconv were rebuilt with -fdata-sections -ffunction-sections)

References

http://laurikari.net/tre/

Keine Kommentare:

Kommentar veröffentlichen