1#! /bin/sh 2 3set -e 4 5IN="../update-pcre" 6PCRE=$1 7 8if [ "x$PCRE" = x ] || [ "x$PCRE" = x--help ] || [ "x$PCRE" = x-h ]; then 9 cat >&2 << EOF 10 11$0 PCRE-DIR 12 13 Updates the local PCRE copy with a different version of the library, 14 contained in the directory PCRE-DIR. 15 16 This will delete the content of the local pcre directory, copy the 17 necessary files from PCRE-DIR, and generate other needed files, such 18 as Makefile.am 19EOF 20 exit 21fi 22 23if [ ! -f gregex.h ]; then 24 echo "This script should be executed from the directory containing gregex.c." 2> /dev/null 25 exit 1 26fi 27 28if [ ! -f "${PCRE}/Makefile.in" ] || [ ! -f "${PCRE}/pcre_compile.c" ]; then 29 echo "'${PCRE}' does not contain a valid PCRE version." 2> /dev/null 30 exit 1 31fi 32 33 34echo "Deleting old PCRE library" 35mv pcre/.svn tmp-pcre-svn 36rm -R pcre 2> /dev/null 37mkdir pcre 38cd pcre 39 40# pcre_chartables.c is generated by dfatables. 41# We do not want to compile and execute dfatables.c every time, because 42# this could be a problem (e.g. when cross-compiling), so now generate 43# the file and then distribute it with GRegex. 44echo "Generating pcre_chartables.c" 45cp -R "${PCRE}" tmp-build 46( 47cd tmp-build || exit 1 48./configure --enable-utf8 --enable-unicode-properties --disable-cpp > /dev/null 49make pcre_chartables.c > /dev/null 50cat > ../pcre_chartables.c << \EOF 51/* This file is autogenerated by ../update-pcre/update.sh during 52 * the update of the local copy of PCRE. 53 */ 54EOF 55cat pcre_chartables.c >> ../pcre_chartables.c 56) 57rm -R tmp-build 58 59# Compiled C files. 60echo "Generating makefiles" 61all_files=$(awk '/^OBJ = /, /^\\s*$/ ' \ 62 '{' \ 63 'sub("^OBJ = ", "");' \ 64 'sub(".@OBJEXT@[[:blank:]]*\\\\\\\\", "");' \ 65 'sub("\\\\$\\\\(POSIX_OBJ\\\\)", "");' \ 66 'print;' \ 67 '}' \ 68 "${PCRE}/Makefile.in") 69 70# Headers. 71included_files="pcre.h pcre_internal.h ucp.h ucpinternal.h" 72 73# Generate Makefile.am. 74cat $IN/Makefile.am-1 > Makefile.am 75for name in $all_files; do 76 echo " $name.c \\" >> Makefile.am 77 if [ "${name}" != pcre_chartables ]; then 78 # pcre_chartables.c is a generated file. 79 cp "${PCRE}/${name}.c" . 80 fi 81done 82for f in $included_files; do 83 echo " $f \\" >> Makefile.am 84 cp "${PCRE}/${f}" . 85done 86cat $IN/Makefile.am-2 >> Makefile.am 87 88echo "Patching PCRE" 89 90# Copy the license. 91cp "${PCRE}/COPYING" . 92 93# Use glib for memory allocation. 94patch > /dev/null < $IN/memory.patch 95 96# Copy the modified version of pcre_valid_utf8.c. 97cp $IN/pcre_valid_utf8.c . 98 99# Copy the modified version of pcre_ucp_searchfuncs.c that uses glib 100# for Unicode properties. 101cp $IN/pcre_ucp_searchfuncs.c . 102patch > /dev/null < $IN/ucp.patch 103 104# Remove the digitab array in pcre_compile.c. 105patch > /dev/null < $IN/digitab.patch 106sed -i -e 's/(digitab\[\(.*\)\] & ctype_digit)/g_ascii_isdigit(\1)/' pcre_compile.c 107sed -i -e 's/(digitab\[\(.*\)\] & ctype_xdigit)/g_ascii_isxdigit(\1)/' pcre_compile.c 108 109# Reduce the number of relocations. 110python $IN/make_utt.py 111patch > /dev/null < $IN/utt.patch 112patch > /dev/null < $IN/table-reduction.patch 113 114# Copy back the old SVN directory. 115mv ../tmp-pcre-svn .svn 116 117 118cat << EOF 119 120Update completed. You now should check that everything is working. 121Remember to update the regex syntax doc with the new features 122(docs/reference/glib/regex-syntax.sgml) and to run the tests. 123EOF 124 125