[BACK]Return to gnum4.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / m4

Diff for /src/usr.bin/m4/gnum4.c between version 1.32 and 1.33

version 1.32, 2006/03/20 10:55:19 version 1.33, 2006/03/20 20:27:45
Line 503 
Line 503 
 }  }
   
 void  void
   doformat(const char *argv[], int argc)
   {
           const char *format = argv[2];
           int pos = 3;
           while (*format != 0) {
                   if (*format != '%') {
                           addchar(*format++);
                   } else {
                           format++;
                           if (*format == '%' || *format == 0) {
                                   addchar('%');
                                   if (*format == '%')
                                           format++;
                           } else {
                               int left_padded = 0;
                               unsigned long width;
                               size_t l;
   
                               if (*format == '-') {
                                   left_padded = 1;
                                   format++;
                               }
                               width = strtoul(format, &format, 10);
                               if (*format != 's') {
                                   m4errx(1, "Unsupported format specification: %s.", argv[2]);
                               }
                               format++;
                               if (pos >= argc)
                                   m4errx(1, "Format with too many values.");
                               l = strlen(argv[pos]);
                               if (!left_padded) {
                                       while (l < width--)
                                               addchar(' ');
                               }
                               addchars(argv[pos++], l);
                               if (left_padded) {
                                   while (l < width--)
                                           addchar(' ');
                               }
                           }
                   }
           }
           pbstr(getstring());
   }
   
   void
 doesyscmd(const char *cmd)  doesyscmd(const char *cmd)
 {  {
         int p[2];          int p[2];

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33