The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0048-Fix-a-problem-with-scanning-wide-chars.patch
1 From 12846e741d925630a4079ac02290b28c6f00b887 Mon Sep 17 00:00:00 2001
2 From: Nathan Sidwell <nathan@codesourcery.com>
3 Date: Fri, 22 Mar 2013 17:46:52 +0100
4 Subject: [PATCH] Fix a problem with scanning wide chars.
5
6 We found that the testcase
7
8 int
9 main (void)
10 {
11   wchar_t s[10];
12   memset (s, 0, sizeof (s));
13   int r = sscanf ("s", "%ls", s);
14   printf ("%d\n", r);
15   printf ("%ls\n", s);
16   return 0;
17 }
18
19 printed
20 0
21 <blankline>
22
23 rather than the expected
24 1
25 s
26
27 The problem was the enum in _scanf.c, which has had a 'CONV_m' value
28 inserted. The attached patch fixes the problem in __psfs_parse_spec by
29 not presuming a particular displacement between the two sets of
30 char-like conversion values. With this patch the above program produces
31 the expected output.
32
33 Signed-off-by: Nathan Sidwell <nathan@codesourcery.com>
34 Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
35 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
36 ---
37  libc/stdio/_scanf.c |    6 +++---
38  1 file changed, 3 insertions(+), 3 deletions(-)
39
40 diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
41 index 952853c..3848a09 100644
42 --- a/libc/stdio/_scanf.c
43 +++ b/libc/stdio/_scanf.c
44 @@ -429,8 +429,8 @@ libc_hidden_def(vswscanf)
45  /*                       npxXoudif eEgG  CS  cs[ */
46  /* NOTE: the 'm' flag must come before any convs that support it */
47  
48 -/* NOTE: Ordering is important!  In particular, CONV_LEFTBRACKET
49 - * must immediately precede CONV_c. */
50 +/* NOTE: Ordering is important!  The CONV_{C,S,LEFTBRACKET} must map
51 +   simply to their lowercase equivalents.  */
52  
53  enum {
54         CONV_n = 0,
55 @@ -921,7 +921,7 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
56                                 psfs->dataargtype = PA_FLAG_LONG;
57                         } else if ((p_m_spec_chars >= CONV_c)
58                                 && (psfs->dataargtype & PA_FLAG_LONG)) {
59 -                               p_m_spec_chars -= 3; /* lc -> C, ls -> S, l[ -> ?? */
60 +                               p_m_spec_chars -= CONV_c - CONV_C; /* lc -> C, ls -> S, l[ -> ?? */
61                         }
62  
63                         psfs->conv_num = p_m_spec_chars;
64 -- 
65 1.7.10.4
66