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