#!/usr/bin/python
# -*- coding: utf-8 -*-
# gperf_fold_key_conv.py
-# Copyright (c) 2016-2017 K.Kosako
+# Copyright (c) 2016-2018 K.Kosako
import sys
import re
REG_LINE_GPERF = re.compile('#line .+gperf"')
-REG_HASH_FUNC = re.compile('hash\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+unsigned\s+int\s+len\s*\)')
+REG_HASH_FUNC = re.compile('hash\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+size_t\s+len\s*\)')
REG_STR_AT = re.compile('str\[(\d+)\]')
REG_RETURN_TYPE = re.compile('^const\s+short\s+int\s*\*')
-REG_FOLD_KEY = re.compile('unicode_fold(\d)_key\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+unsigned\s+int\s+len\)')
+REG_FOLD_KEY = re.compile('unicode_fold(\d)_key\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+size_t\s+len\)')
REG_ENTRY = re.compile('\{".*?",\s*(-?\d+)\s*\}')
REG_IF_LEN = re.compile('if\s*\(\s*len\s*<=\s*MAX_WORD_LENGTH.+')
REG_GET_HASH = re.compile('(?:register\s+)?(?:unsigned\s+)?int\s+key\s*=\s*hash\s*\(str,\s*len\);')
#!/usr/bin/python
# -*- coding: utf-8 -*-
# gperf_unfold_key_conv.py
-# Copyright (c) 2016-2017 K.Kosako
+# Copyright (c) 2016-2018 K.Kosako
import sys
import re
REG_LINE_GPERF = re.compile('#line .+gperf"')
-REG_HASH_FUNC = re.compile('hash\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+unsigned\s+int\s+len\s*\)')
+REG_HASH_FUNC = re.compile('hash\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+size_t\s+len\s*\)')
REG_STR_AT = re.compile('str\[(\d+)\]')
-REG_UNFOLD_KEY = re.compile('unicode_unfold_key\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+unsigned\s+int\s+len\)')
+REG_UNFOLD_KEY = re.compile('unicode_unfold_key\s*\(register\s+const\s+char\s*\*\s*str,\s*register\s+size_t\s+len\)')
REG_ENTRY = re.compile('\{".+?",\s*/\*(.+?)\*/\s*(-?\d+),\s*(\d)\}')
REG_EMPTY_ENTRY = re.compile('\{"",\s*(-?\d+),\s*(\d)\}')
REG_IF_LEN = re.compile('if\s*\(\s*len\s*<=\s*MAX_WORD_LENGTH.+')
#!/bin/sh
-TMP=gperf.tmp
+GPERF=/usr/bin/gperf
+
+TMP0=gperf0.tmp
+TMP1=gperf1.tmp
+TMP2=gperf2.tmp
+TMP3=gperf3.tmp
+
GPERF_OPT='-n -C -T -c -t -j1 -L ANSI-C '
./make_unicode_fold_data.py > unicode_fold_data.c
-gperf ${GPERF_OPT} -F,-1,0 -N unicode_unfold_key unicode_unfold_key.gperf > ${TMP}
-./gperf_unfold_key_conv.py < ${TMP} > unicode_unfold_key.c
+${GPERF} ${GPERF_OPT} -F,-1,0 -N unicode_unfold_key unicode_unfold_key.gperf > ${TMP0}
+./gperf_unfold_key_conv.py < ${TMP0} > unicode_unfold_key.c
-gperf ${GPERF_OPT} -F,-1 -N unicode_fold1_key unicode_fold1_key.gperf > ${TMP}
-./gperf_fold_key_conv.py 1 < ${TMP} > unicode_fold1_key.c
+${GPERF} ${GPERF_OPT} -F,-1 -N unicode_fold1_key unicode_fold1_key.gperf > ${TMP1}
+./gperf_fold_key_conv.py 1 < ${TMP1} > unicode_fold1_key.c
-gperf ${GPERF_OPT} -F,-1 -N unicode_fold2_key unicode_fold2_key.gperf > ${TMP}
-./gperf_fold_key_conv.py 2 < ${TMP} > unicode_fold2_key.c
+${GPERF} ${GPERF_OPT} -F,-1 -N unicode_fold2_key unicode_fold2_key.gperf > ${TMP2}
+./gperf_fold_key_conv.py 2 < ${TMP2} > unicode_fold2_key.c
-gperf ${GPERF_OPT} -F,-1 -N unicode_fold3_key unicode_fold3_key.gperf > ${TMP}
-./gperf_fold_key_conv.py 3 < ${TMP} > unicode_fold3_key.c
+${GPERF} ${GPERF_OPT} -F,-1 -N unicode_fold3_key unicode_fold3_key.gperf > ${TMP3}
+./gperf_fold_key_conv.py 3 < ${TMP3} > unicode_fold3_key.c
-rm -f ${TMP}
+rm -f ${TMP0} ${TMP1} ${TMP2} ${TMP3}
+rm -f unicode_unfold_key.gperf unicode_fold1_key.gperf unicode_fold2_key.gperf unicode_fold3_key.gperf
exit 0
#!/bin/sh
NAME=unicode_property_data
-TMP=gperf.tmp
-#GPERF_OPT='-P -Q prop_name_pool -C -c -t -j1 -L ANSI-C --ignore-case'
+TMP1=gperf1.tmp
+TMP2=gperf2.tmp
+GPERF=/usr/bin/gperf
+
GPERF_OPT='-T -C -c -t -j1 -L ANSI-C --ignore-case --pic -Q unicode_prop_name_pool'
-POOL_CAST='s/\(int *\)\(long *\)&\(\(struct +unicode_prop_name_pool_t *\* *\) *0\)->unicode_prop_name_pool_str([^,]+)/pool_offset(\1)/g'
+POOL_CAST='s/\(int *\)\(size_t *\)&\(\(struct +unicode_prop_name_pool_t *\* *\) *0\)->unicode_prop_name_pool_str([^,]+)/pool_offset(\1)/g'
./make_unicode_property_data.py > ${NAME}.gperf
./make_unicode_property_data.py -posix > ${NAME}_posix.gperf
-gperf ${GPERF_OPT} -N unicode_lookup_property_name --output-file ${TMP} ${NAME}.gperf
-sed -e 's/^#line.*$//g' ${TMP} | sed -r "${POOL_CAST}" > ${NAME}.c
-gperf ${GPERF_OPT} -N unicode_lookup_property_name --output-file ${TMP} ${NAME}_posix.gperf
-sed -e 's/^#line.*$//g' ${TMP} | sed -r "${POOL_CAST}" > ${NAME}_posix.c
+${GPERF} ${GPERF_OPT} -N unicode_lookup_property_name --output-file ${TMP1} ${NAME}.gperf
+sed -e 's/^#line.*$//g' ${TMP1} | sed -r "${POOL_CAST}" > ${NAME}.c
+${GPERF} ${GPERF_OPT} -N unicode_lookup_property_name --output-file ${TMP2} ${NAME}_posix.gperf
+sed -e 's/^#line.*$//g' ${TMP2} | sed -r "${POOL_CAST}" > ${NAME}_posix.c
-rm -f ${NAME}.gperf ${NAME}_posix.gperf ${TMP}
+rm -f ${NAME}.gperf ${NAME}_posix.gperf ${TMP1} ${TMP2}
exit 0
extern int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
extern struct PropertyNameCtype* euc_jp_lookup_property_name P_((register const char *str, register unsigned int len));
extern struct PropertyNameCtype* sjis_lookup_property_name P_((register const char *str, register unsigned int len));
-/* extern const struct PropertyNameCtype* unicode_lookup_property_name P_((register const char *str, register unsigned int len)); */
+/* extern const struct PropertyNameCtype* unicode_lookup_property_name P_((register const char *str, register size_t len)); */
/* in enc/unicode.c */
extern int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));