$DragonFly: src/gnu/usr.bin/cc41/cc_prep/patches/c-format.c.patch,v 1.1 2006/09/27 12:10:34 corecode Exp $
--- c-format.c 2006-09-16 20:11:29.000000000 +0200
+++ c-format.c 2006-09-26 01:05:46.000000000 +0200
@@ -506,6 +506,19 @@
{ "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL },
/* GNU conversion specifiers. */
{ "m", 0, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", NULL },
+ /* BSD conversion specifiers. */
+ /* DragonFly kernel extensions (src/sys/kern/subr_prf.c).
+ The format %b is supported to decode error registers.
+ Its usage is: printf("reg=%b\n", regval, "*");
+ which produces: reg=3
+ The format %D provides a hexdump given a pointer and separator string:
+ ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX
+ ("%*D", len, ptr, " ") -> XX XX XX XX ...
+ */
+ { "D", 1, STD_EXT, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL },
+ { "b", 1, STD_EXT, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", NULL },
+ { "ry", 0, STD_EXT, { T89_I, BADLEN, BADLEN, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "i", NULL },
+ { "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 },
{ NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
};
@@ -1800,6 +1813,56 @@
}
}
+ if (*format_chars == 'b')
+ {
+ /* There should be an int arg to control the string arg. */
+ if (params == 0)
+ {
+ warning (OPT_Wformat, "too few arguments for format");
+ return;
+ }
+ if (info->first_arg_num != 0)
+ {
+ cur_param = TREE_VALUE (params);
+ params = TREE_CHAIN (params);
+ ++arg_num;
+ if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
+ != integer_type_node)
+ &&
+ (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
+ != unsigned_type_node))
+ {
+ warning (OPT_Wformat, "bitmap is not type int (arg %d)",
+ arg_num);
+ }
+ }
+ }
+ if (*format_chars == 'D')
+ {
+ /* There should be an unsigned char * arg before the string arg. */
+ if (params == 0)
+ {
+ warning (OPT_Wformat, "too few arguments for format");
+ return;
+ }
+ if (info->first_arg_num != 0)
+ {
+ tree cur_type;
+
+ cur_param = TREE_VALUE (params);
+ params = TREE_CHAIN (params);
+ ++arg_num;
+ cur_type = TREE_TYPE (cur_param);
+ if (TREE_CODE (cur_type) != POINTER_TYPE
+ || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type))
+ != unsigned_char_type_node)
+ {
+ warning (OPT_Wformat, "ethernet address is not type unsigned char * (arg %d)",
+ arg_num);
+ }
+ }
+ }
+
format_char = *format_chars;
if (format_char == 0
|| (!(fki->flags & (int) FMT_FLAG_FANCY_PERCENT_OK)
@@ -1930,7 +1993,7 @@
y2k_level = 2;
if (y2k_level == 3)
warning (OPT_Wformat_y2k, "%<%%%c%> yields only last 2 digits of "
- "year in some locales", format_char);
+ "year in some locales on non-BSD systems", format_char);
else if (y2k_level == 2)
warning (OPT_Wformat_y2k, "%<%%%c%> yields only last 2 digits of "
"year", format_char);