From owner-p4-projects@FreeBSD.ORG Mon Aug 18 11:15:09 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7360F1065693; Mon, 18 Aug 2008 11:15:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F5E2106567B for ; Mon, 18 Aug 2008 11:15:09 +0000 (UTC) (envelope-from konrad@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A1A5E8FC16 for ; Mon, 18 Aug 2008 11:15:07 +0000 (UTC) (envelope-from konrad@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7IBF7c6023656 for ; Mon, 18 Aug 2008 11:15:07 GMT (envelope-from konrad@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7IBF7ne023652 for perforce@freebsd.org; Mon, 18 Aug 2008 11:15:07 GMT (envelope-from konrad@FreeBSD.org) Date: Mon, 18 Aug 2008 11:15:07 GMT Message-Id: <200808181115.m7IBF7ne023652@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to konrad@FreeBSD.org using -f From: Konrad Jankowski To: Perforce Change Reviews Cc: Subject: PERFORCE change 147709 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 11:15:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=147709 Change 147709 by konrad@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