Author: pfg
Date: Fri Feb  3 21:38:23 2012
New Revision: 230961
URL: http://svn.freebsd.org/changeset/base/230961

Log:
  MFC:  r230027
  
  Style cleanups for printf.
  
  PR:           bin/152934
  Approved by:  jhb (mentor)
  Obtained from:        Illumos

Modified:
  stable/9/usr.bin/printf/printf.c
Directory Properties:
  stable/9/usr.bin/printf/   (props changed)

Modified: stable/9/usr.bin/printf/printf.c
==============================================================================
--- stable/9/usr.bin/printf/printf.c    Fri Feb  3 21:30:31 2012        
(r230960)
+++ stable/9/usr.bin/printf/printf.c    Fri Feb  3 21:38:23 2012        
(r230961)
@@ -66,21 +66,21 @@ static const char rcsid[] =
 #include "error.h"
 #endif
 
-#define PF(f, func) do { \
-       char *b = NULL; \
-       if (havewidth) \
-               if (haveprec) \
+#define PF(f, func) do {                                               \
+       char *b = NULL;                                                 \
+       if (havewidth)                                                  \
+               if (haveprec)                                           \
                        (void)asprintf(&b, f, fieldwidth, precision, func); \
-               else \
-                       (void)asprintf(&b, f, fieldwidth, func); \
-       else if (haveprec) \
-               (void)asprintf(&b, f, precision, func); \
-       else \
-               (void)asprintf(&b, f, func); \
-       if (b) { \
-               (void)fputs(b, stdout); \
-               free(b); \
-       } \
+               else                                                    \
+                       (void)asprintf(&b, f, fieldwidth, func);        \
+       else if (haveprec)                                              \
+               (void)asprintf(&b, f, precision, func);                 \
+       else                                                            \
+               (void)asprintf(&b, f, func);                            \
+       if (b) {                                                        \
+               (void)fputs(b, stdout);                                 \
+               free(b);                                                \
+       }                                                               \
 } while (0)
 
 static int      asciicode(void);
@@ -357,10 +357,10 @@ mknum(char *str, char ch)
 static int
 escape(char *fmt, int percent, size_t *len)
 {
-       char *save, *store;
-       int value, c;
+       char *save, *store, c;
+       int value;
 
-       for (save = store = fmt; (c = *fmt); ++fmt, ++store) {
+       for (save = store = fmt; ((c = *fmt) != 0); ++fmt, ++store) {
                if (c != '\\') {
                        *store = c;
                        continue;
@@ -414,7 +414,7 @@ escape(char *fmt, int percent, size_t *l
                                *store++ = '%';
                                *store = '%';
                        } else
-                               *store = value;
+                               *store = (char)value;
                        break;
                default:
                        *store = *fmt;
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to