summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/printk.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-02-06 23:15:57 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-02-06 23:15:57 +0000
commit6728035e8b29b78debc7ea7773f9d169b2968c65 (patch)
treec820982046a714996431a4993f491f4193848afa /cpukit/libcsupport/src/printk.c
parent4273e70b1cc17952a22382d7c4a5acc5e088b556 (diff)
downloadrtems-6728035e8b29b78debc7ea7773f9d169b2968c65.tar.bz2
2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/printk.c: Added width and padding for %s. * libmisc/cpuuse/cpuusagereport.c: Support object names that are strings longer than 4 chanracters.
Diffstat (limited to '')
-rw-r--r--cpukit/libcsupport/src/printk.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/cpukit/libcsupport/src/printk.c b/cpukit/libcsupport/src/printk.c
index e8ccbd7da6..97895ab75d 100644
--- a/cpukit/libcsupport/src/printk.c
+++ b/cpukit/libcsupport/src/printk.c
@@ -63,7 +63,6 @@ static void printNum(
}
}
-
/*
* vprintk
*
@@ -79,13 +78,14 @@ void vprintk(
)
{
char c, *str;
- int lflag, base, sign, width, lead;
+ int lflag, base, sign, width, lead, minus;
for (; *fmt != '\0'; fmt++) {
lflag = 0;
base = 0;
sign = 0;
width = 0;
+ minus = 0;
lead = ' ';
if (*fmt == '%') {
fmt++;
@@ -93,6 +93,10 @@ void vprintk(
lead = '0';
fmt++;
}
+ if (*fmt == '-' ) {
+ minus = 1;
+ fmt++;
+ }
while (*fmt >= '0' && *fmt <= '9' ) {
width *= 10;
width += (*fmt - '0');
@@ -111,8 +115,29 @@ void vprintk(
case 'x': case 'X': base = 16; sign = 0; break;
case 'p': base = 16; sign = 0; break;
case 's':
- for (str = va_arg(ap, char *); *str; str++)
- BSP_output_char(*str);
+ { int i, len;
+ char *s;
+
+ str = va_arg(ap, char *);
+
+ /* calculate length of string */
+ for ( len=0, s=str ; *s ; len++, s++ )
+ ;
+
+ /* leading spaces */
+ if ( !minus )
+ for ( i=len ; i<width ; i++ )
+ BSP_output_char(' ');
+
+ /* output the string */
+ for ( i=0 ; i<width && *str ; str++ )
+ BSP_output_char(*str);
+
+ /* trailing spaces */
+ if ( minus )
+ for ( i=len ; i<width ; i++ )
+ BSP_output_char(' ');
+ }
break;
case 'c':
BSP_output_char(va_arg(ap, int));