From de9822e1de2e3f46cbd5e21811b08539f6d014f3 Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson Date: Thu, 16 Sep 2010 00:56:03 +0200 Subject: [PATCH 1/3] ifconfig/flags,options,printif: Correct format strings for "unix". --- ChangeLog | 8 ++++++++ ifconfig/flags.c | 3 +++ ifconfig/options.c | 4 ++-- ifconfig/printif.c | 9 ++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5cb717b..6a35bfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-09-16 Mats Erik Andersson + + * ifconfig/flags.c (flag_char_tab): Include IFF_SIMPLEX. + * ifconfig/printif.c (put_int): Correct the position of "#" modifier. + (put_int): Implement modifier "h" for short integers, etcetera. + (put_flags): Declare "unsigned short" to correctly interpret flags. + * ifconfig/options.c (formats/unix): Correct some format strings. + 2010-09-15 Mats Erik Andersson * ifconfig/if_nameindex.c: Protect using HAVE_STRUCT_IF_NAMEINDEX. diff --git a/ifconfig/flags.c b/ifconfig/flags.c index 29b9162..279b295 100644 --- a/ifconfig/flags.c +++ b/ifconfig/flags.c @@ -407,6 +407,9 @@ static struct if_flag_char flag_char_tab[] = { #ifdef IFF_MASTER { IFF_MASTER, 'm' }, #endif +#ifdef IFF_SIMPLEX + { IFF_SIMPLEX, 'S' }, +#endif { IFF_RUNNING, 'R' }, { IFF_UP, 'U' }, { 0 } diff --git a/ifconfig/options.c b/ifconfig/options.c index 7e1c309..dcd38d9 100644 --- a/ifconfig/options.c +++ b/ifconfig/options.c @@ -139,10 +139,10 @@ struct format formats[] = { "Traditional UNIX interface listing. Default for Solaris and HPUX.", "${format}{check-existence}" "${ifdisplay?}{" - "${name}: flags=${flags}{number}<${flags}{string}{,}>" + "${name}: flags=${flags}{number}{%hx}<${flags}{string}{,}>" "${mtu?}{ mtu ${mtu}}${\\n}" "${addr?}{${\\t}inet ${addr}" - " netmask ${netmask}{0}{%02x}${netmask}{1}{%02x}" + " netmask ${netmask}{0}{%#02x}${netmask}{1}{%02x}" "${netmask}{2}{%02x}${netmask}{3}{%02x}" "${brdaddr?}{ broadcast ${brdaddr}}${\\n}}" "${exists?}{hwtype?}{${hwtype?}{${\\t}${hwtype}" diff --git a/ifconfig/printif.c b/ifconfig/printif.c index 03cdf80..9e73a78 100644 --- a/ifconfig/printif.c +++ b/ifconfig/printif.c @@ -153,12 +153,15 @@ put_int (format_data_t form, int argc, char *argv[], int nr) { p++; - while (isdigit (*p)) + if (*p == '#') p++; - if (*p == '#') + while (isdigit (*p)) p++; + if ((*p == 'h' || *p == 'H') && p[1]) + ++p; /* Half length modifier, go to type specifier. */ + switch (*p) { default: @@ -294,7 +297,7 @@ void put_flags (format_data_t form, int argc, char *argv[], short flags) { /* XXX */ - short int f = 1; + unsigned short int f = 1; const char *name; int first = 1; -- 1.6.3.3