Page MenuHomeFreeBSD

D62328.1796332471.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D62328.1796332471.diff

diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -675,12 +675,13 @@
break;
case '[':
- ccl.start = fmt;
if (*fmt == '^') {
ccl.compl = 1;
fmt++;
- } else
+ } else {
ccl.compl = 0;
+ }
+ ccl.start = fmt;
if (*fmt == ']')
fmt++;
while (*fmt != '\0' && *fmt != ']')
diff --git a/lib/libc/tests/stdio/sscanf_test.c b/lib/libc/tests/stdio/sscanf_test.c
--- a/lib/libc/tests/stdio/sscanf_test.c
+++ b/lib/libc/tests/stdio/sscanf_test.c
@@ -393,6 +393,11 @@
*s = '\0';
ATF_CHECK_EQ(2, sscanf("3.1415pi", "%[0-9]%[.]%[0-9\0%[a-z]", s, s, s, s));
ATF_CHECK_STREQ(".", s);
+
+ /* The initial ^ of a negated set is not part of the set */
+ *s = '\0';
+ ATF_CHECK_EQ(1, sscanf("^a", "%[^a]", s));
+ ATF_CHECK_STREQ("^", s);
}
ATF_TP_ADD_TCS(tp)
diff --git a/lib/libc/tests/stdio/swscanf_test.c b/lib/libc/tests/stdio/swscanf_test.c
--- a/lib/libc/tests/stdio/swscanf_test.c
+++ b/lib/libc/tests/stdio/swscanf_test.c
@@ -396,6 +396,11 @@
*s = L'\0';
ATF_CHECK_EQ(2, swscanf(L"3.1415pi", L"%l[0-9]%l[.]%l[0-9\0%l[a-z]", s, s, s, s));
ATF_CHECK_WCSEQ(L".", s);
+
+ /* The initial ^ of a negated set is not part of the set */
+ *s = '\0';
+ ATF_CHECK_EQ(1, swscanf(L"^a", L"%[^a]", s));
+ ATF_CHECK_WCSEQ(L"^", s);
}
ATF_TP_ADD_TCS(tp)

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 3, 9:14 PM (18 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42191999
Default Alt Text
D62328.1796332471.diff (1 KB)

Event Timeline