Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jun 2016 18:01:22 +0300
From:      Andrey Chernov <ache@freebsd.org>
To:        Pedro Giffuni <pfg@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r301777 - head/lib/libc/stdio
Message-ID:  <6d1d7aaa-eef0-cafc-b11a-3b81ee3fb230@freebsd.org>
In-Reply-To: <03897eab-0725-7c7a-0edf-04eb44eff6f7@FreeBSD.org>
References:  <201606100521.u5A5Lqa6035072@repo.freebsd.org> <3346cab5-d713-c1ad-5e50-ea8d50ee47b9@freebsd.org> <cd74f302-f089-3208-a6ca-89eb7460d41b@FreeBSD.org> <52d3a4b3-0b52-abd3-8633-909885f12781@freebsd.org> <03897eab-0725-7c7a-0edf-04eb44eff6f7@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 10.06.2016 17:14, Pedro Giffuni wrote:
>> Because now strcoll_l() is used as before and it is broken in wide char
>> converting process. It is broken for _all_, not just for vfscanf()
>> ranges. It should never fail with any args.
>> Real fix should be in strcoll_l().
>>
> 
> Yes, it is broken as before however the objective of r301461 was only
> to address the ABI breakage. If I revert r301777 then I have to backout
> r301461 too, and then we have again the ABI breakage.
> 
> I understand you want to fix all but we are under code freeze and
> I have to go back to a known working (although still broken) state.

I can't make strcoll or vfscanf to drop core in my simple tests.
Too little info in the bug report.
In any case here is vfscanf.c fix attached (by removing collation range).

>> It is dependent. vfscanf() and regcomp() use the same code for range
>> collation. If we remove range collation from everywhere, we save
>> vfscanf(), but strcoll_l() remains broken.
>>
>>
> 
> We have had a broken regex for a very long time, and we new that
> before collation was introduced. I didn't take that decision but
> moving to libtre was a lot more work and we really had to have
> collation now.

No, we have perfectly working single byte regex with collation ranges
for many years until those wchars was invaded the code very recently.


[-- Attachment #2 --]
Index: vfscanf.c
===================================================================
--- vfscanf.c	(revision 301779)
+++ vfscanf.c	(working copy)
@@ -816,9 +816,7 @@
 static const u_char *
 __sccl(char *tab, const u_char *fmt)
 {
-	int c, n, v, i;
-	struct xlocale_collate *table =
-		(struct xlocale_collate*)__get_locale()->components[XLC_COLLATE];
+	int c, n, v;
 
 	/* first `clear' the whole table */
 	c = *fmt++;		/* first char hat => negated scanset */
@@ -871,29 +869,15 @@
 			 * we just stored in the table (c).
 			 */
 			n = *fmt;
-			if (n == ']'
-			    || (table->__collate_load_error ? n < c :
-				__wcollate_range_cmp(table, n, c) < 0
-			       )
-			   ) {
+			if (n == ']' || n < c) {
 				c = '-';
 				break;	/* resume the for(;;) */
 			}
 			fmt++;
-			/* fill in the range */
-			if (table->__collate_load_error) {
-				do {
-					tab[++c] = v;
-				} while (c < n);
-			} else {
-				for (i = 0; i < 256; i ++)
-					if (__wcollate_range_cmp(table, c, i) < 0 &&
-					    __wcollate_range_cmp(table, i, n) <= 0
-					   )
-						tab[i] = v;
-			}
+			do {		/* fill in the range */
+				tab[++c] = v;
+			} while (c < n);
 #if 1	/* XXX another disgusting compatibility hack */
-			c = n;
 			/*
 			 * Alas, the V7 Unix scanf also treats formats
 			 * such as [a-c-e] as `the letters a through e'.

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6d1d7aaa-eef0-cafc-b11a-3b81ee3fb230>