Merge from vendor branch ZLIB:
[dragonfly.git] / gnu / usr.bin / cc3 / cc_int / patches / c-format.c.patch
1 $DragonFly: src/gnu/usr.bin/cc3/cc_int/patches/Attic/c-format.c.patch,v 1.1 2004/03/05 21:38:44 joerg Exp $
2 --- c-format.c.orig     Tue Feb 24 18:37:09 2004
3 +++ c-format.c  Tue Feb 24 18:43:03 2004
4 @@ -762,6 +762,18 @@
5    { "S",   1, STD_EXT, { TEX_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "R"  },
6    /* GNU conversion specifiers.  */
7    { "m",   0, STD_EXT, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      ""   },
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" },
18 +  { "b",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      ""   },
19 +  { "ry",  0, STD_EXT, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i"  },
20    { NULL,  0, 0, NOLENGTHS, NULL, NULL }
21  };
22  
23 @@ -1898,6 +1910,57 @@
24             }
25         }
26  
27 +      if (*format_chars == 'b')
28 +       {
29 +         /* There should be an int arg to control the string arg.  */
30 +         if (params == 0)
31 +           {
32 +             status_warning (status, "too few arguments for format");
33 +             return;
34 +           }
35 +           if (info->first_arg_num != 0)
36 +           {
37 +             cur_param = TREE_VALUE (params);
38 +             params = TREE_CHAIN (params);
39 +             ++arg_num;
40 +             if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
41 +                  != integer_type_node)
42 +                 &&
43 +                 (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
44 +                  != unsigned_type_node))
45 +               {
46 +                 status_warning (status, "bitmap is not type int (arg %d)",
47 +                                 arg_num);
48 +               }
49 +           }
50 +       }
51 +      if (*format_chars == 'D')
52 +       {
53 +         /* There should be an unsigned char * arg before the string arg.  */
54 +         if (params == 0)
55 +           {
56 +             status_warning (status, "too few arguments for format");
57 +             return;
58 +           }
59 +           if (info->first_arg_num != 0)
60 +           {
61 +             tree cur_type;
62 +
63 +             cur_param = TREE_VALUE (params);
64 +             params = TREE_CHAIN (params);
65 +             ++arg_num;
66 +             cur_type = TREE_TYPE (cur_param);
67 +             if (TREE_CODE (cur_type) != POINTER_TYPE
68 +                 || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type))
69 +                    != unsigned_char_type_node)
70 +               {
71 +                 status_warning (status,
72 +                     "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 @@ -2024,7 +2087,7 @@
82           else if (strchr (fci->flags2, '2') != 0)
83             y2k_level = 2;
84           if (y2k_level == 3)
85 -           status_warning (status, "`%%%c' yields only last 2 digits of year in some locales",
86 +           status_warning (status, "`%%%c' yields only last 2 digits of year in some locales on non-BSD systems",
87                             format_char);
88           else if (y2k_level == 2)
89             status_warning (status, "`%%%c' yields only last 2 digits of year", format_char);