PERFORCE change 147709 for review
Konrad Jankowski
konrad at FreeBSD.org
Mon Aug 18 11:15:10 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=147709
Change 147709 by konrad at vspredator on 2008/08/18 11:14:10
Finally, fix the bug which caused above then second level sorting to be skipped.
Also, fix a possible stack overwriting if __collate_info->directive_count > COLL_WEIGHTS_MAX.
Minor enhacement to generate_apple - can now regenerate just one file, instead of them all.
Affected files ...
.. //depot/projects/soc2008/konrad_collation/colldef.apple/parse.y#6 edit
.. //depot/projects/soc2008/konrad_collation/libc/locale/collate.c#8 edit
.. //depot/projects/soc2008/konrad_collation/libc/string/strxfrm.c#9 edit
.. //depot/projects/soc2008/konrad_collation/libc/string/wcscoll.c#7 edit
.. //depot/projects/soc2008/konrad_collation/scripts/generate_apple.sh#3 edit
Differences ...
==== //depot/projects/soc2008/konrad_collation/colldef.apple/parse.y#6 (text+ko) ====
@@ -286,11 +286,13 @@
if (localedef) {
if (nsubst[0] == nsubst[1] && (nsubst[0] == 0 ||
memcmp(__collate_substitute_table[0], __collate_substitute_table[1], nsubst[0] * sizeof(struct __collate_st_subst)) == 0)) {
- info.flags |= COLLATE_SUBST_DUP;
+ if (COLL_WEIGHTS_MAX == 2)
+ info.flags |= COLLATE_SUBST_DUP;
nsubst[1] = 0;
}
} else {
- info.flags |= COLLATE_SUBST_DUP;
+ if (COLL_WEIGHTS_MAX == 2)
+ info.flags |= COLLATE_SUBST_DUP;
nsubst[1] = 0;
}
==== //depot/projects/soc2008/konrad_collation/libc/locale/collate.c#8 (text+ko) ====
@@ -178,8 +178,12 @@
vp += info.subst_count[0] * sizeof(struct __collate_st_subst);
} else
TMP->__substitute_table[0] = NULL;
- if (info.flags & COLLATE_SUBST_DUP)
+ if (info.flags & COLLATE_SUBST_DUP) {
+#ifdef LOCALE_DEBUG
+ fprintf(stderr, "COLLATE_SUBST_DUP in effect\n");
+#endif
TMP->__substitute_table[1] = TMP->__substitute_table[0];
+ }
else if (info.subst_count[1] > 0) {
TMP->__substitute_table[1] = (struct __collate_st_subst *)vp;
vp += info.subst_count[1] * sizeof(struct __collate_st_subst);
@@ -242,6 +246,8 @@
#ifdef LOCALE_DEBUG
fprintf(stderr, "__collate_load_tables: loaded successfully\n");
#endif
+ if (__collate_info->directive_count > COLL_WEIGHTS_MAX)
+ __collate_info->directive_count = COLL_WEIGHTS_MAX;
return (_LDP_LOADED);
}
@@ -520,6 +526,9 @@
else
t = (const wchar_t *)src;
sverrno = errno;
+#ifdef LOCALE_DEBUG
+ fprintf(stderr, "allocating xf[%d]\n", pass);
+#endif
if ((xf[pass] = (wchar_t *)malloc(sizeof(wchar_t) *
(wcslen(t) + 1))) == NULL) {
errno = sverrno;
==== //depot/projects/soc2008/konrad_collation/libc/string/strxfrm.c#9 (text+ko) ====
@@ -138,7 +138,7 @@
}
sverrno = errno;
free(wcs);
- for (i = 0; i < COLL_WEIGHTS_MAX; i++)
+ for (i = 0; i < __collate_data->__info.directive_count; i++)
free(xf[i]);
errno = sverrno;
==== //depot/projects/soc2008/konrad_collation/libc/string/wcscoll.c#7 (text+ko) ====
@@ -60,7 +60,8 @@
if ((info->directive[0] & NOTFORWARD) ||
(info->directive[1] & NOTFORWARD) ||
(!(info->flags && COLLATE_SUBST_DUP) &&
- (info->subst_count[0] > 0 || info->subst_count[1] > 0))) {
+ (info->subst_count[0] > 0 || info->subst_count[1] > 0)) ||
+ COLL_WEIGHTS_MAX > 2) {
int direc, pass;
for(pass = 0; pass < info->directive_count; pass++) {
direc = info->directive[pass];
==== //depot/projects/soc2008/konrad_collation/scripts/generate_apple.sh#3 (text+ko) ====
@@ -1,8 +1,12 @@
#!/bin/sh
[ -d ../locale ] || mkdir ../locale
+MASK="*"
+if [ "$1" != "" ]; then
+ MASK="$1"
+fi
-for f in `echo ../posix/*.src`; do
+for f in `echo ../posix/$MASK.src`; do
NAME=`echo $f | awk -F '.' ' { print $3 } ' | \
awk -F '/' ' { print $3 } '`
NAME="$NAME.UTF-8"
@@ -11,5 +15,4 @@
[ -d ../locale/$NAME ] || mkdir ../locale/$NAME
../colldef.apple/colldef -o ../locale/$NAME/LC_COLLATE collate_in.src
done
-rm colldef_in.src
-rm colldef_in.src.simple
+rm collate_in.src
More information about the p4-projects
mailing list