Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / gnu / usr.bin / cc41 / cc_prep / patches / c-format.c.patch
1 $DragonFly: src/gnu/usr.bin/cc41/cc_prep/patches/c-format.c.patch,v 1.1 2006/09/27 12:10:34 corecode Exp $
2 --- c-format.c  2006-09-16 20:11:29.000000000 +0200
3 +++ c-format.c  2006-09-26 01:05:46.000000000 +0200
4 @@ -506,6 +506,19 @@
5    { "S",   1, STD_EXT, { TEX_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",       "R",  NULL },
6    /* GNU conversion specifiers.  */
7    { "m",   0, STD_EXT, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",       "",   NULL },
8 +  /* BSD conversion specifiers.  */
9 +  /* DragonFly kernel extensions (src/sys/kern/subr_prf.c).
10 +     The format %b is supported to decode error registers.
11 +     Its usage is:     printf("reg=%b\n", regval, "<base><arg>*");
12 +     which produces:   reg=3<BITTWO,BITONE>
13 +     The format %D provides a hexdump given a pointer and separator string:
14 +     ("%6D", ptr, ":")         -> XX:XX:XX:XX:XX:XX
15 +     ("%*D", len, ptr, " ")    -> XX XX XX XX ...
16 +   */
17 +  { "D",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "cR",  NULL },
18 +  { "b",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "",    NULL   },
19 +  { "ry",  0, STD_EXT, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i",   NULL  },
20 +  { "z",   0, STD_EXT, { T89_UI,  T99_UC,  T89_US,  T89_UL,  T9L_ULL, TEX_ULL, T99_ST,  T99_UPD, T99_UIM }, "-wp0#",     "i",  NULL },
21    { NULL,  0, 0, NOLENGTHS, NULL, NULL, NULL }
22  };
23  
24 @@ -1800,6 +1813,56 @@
25             }
26         }
27  
28 +      if (*format_chars == 'b')
29 +       {
30 +         /* There should be an int arg to control the string arg.  */
31 +         if (params == 0)
32 +           {
33 +             warning (OPT_Wformat, "too few arguments for format");
34 +             return;
35 +           }
36 +           if (info->first_arg_num != 0)
37 +           {
38 +             cur_param = TREE_VALUE (params);
39 +             params = TREE_CHAIN (params);
40 +             ++arg_num;
41 +             if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
42 +                  != integer_type_node)
43 +                 &&
44 +                 (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
45 +                  != unsigned_type_node))
46 +               {
47 +                 warning (OPT_Wformat, "bitmap is not type int (arg %d)",
48 +                                 arg_num);
49 +               }
50 +           }
51 +       }
52 +      if (*format_chars == 'D')
53 +       {
54 +         /* There should be an unsigned char * arg before the string arg.  */
55 +         if (params == 0)
56 +           {
57 +             warning (OPT_Wformat, "too few arguments for format");
58 +             return;
59 +           }
60 +           if (info->first_arg_num != 0)
61 +           {
62 +             tree cur_type;
63 +
64 +             cur_param = TREE_VALUE (params);
65 +             params = TREE_CHAIN (params);
66 +             ++arg_num;
67 +             cur_type = TREE_TYPE (cur_param);
68 +             if (TREE_CODE (cur_type) != POINTER_TYPE
69 +                 || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type))
70 +                    != unsigned_char_type_node)
71 +               {
72 +                 warning (OPT_Wformat, "ethernet address is not type unsigned char * (arg %d)",
73 +                                 arg_num);
74 +               }
75 +           }
76 +        }
77 +
78        format_char = *format_chars;
79        if (format_char == 0
80           || (!(fki->flags & (int) FMT_FLAG_FANCY_PERCENT_OK)
81 @@ -1930,7 +1993,7 @@
82             y2k_level = 2;
83           if (y2k_level == 3)
84             warning (OPT_Wformat_y2k, "%<%%%c%> yields only last 2 digits of "
85 -                    "year in some locales", format_char);
86 +                    "year in some locales on non-BSD systems", format_char);
87           else if (y2k_level == 2)
88             warning (OPT_Wformat_y2k, "%<%%%c%> yields only last 2 digits of "
89                      "year", format_char);