Magellan Linux

Diff of /trunk/mkinitrd-magellan/klibc/usr/dash/bltin/printf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 814 by niro, Sat Sep 1 22:45:15 2007 UTC revision 815 by niro, Fri Apr 24 18:32:46 2009 UTC
# Line 40  Line 40 
40  #include <string.h>  #include <string.h>
41  #include <unistd.h>  #include <unistd.h>
42    
43  static char *conv_escape_str(char *);  static int conv_escape_str(char *);
44  static char *conv_escape(char *, int *);  static char *conv_escape(char *, int *);
45  static int getchr(void);  static int getchr(void);
46  static intmax_t getintmax(void);  static intmax_t getintmax(void);
# Line 157  pc: Line 157  pc:
157   switch (ch) {   switch (ch) {
158    
159   case 'b': {   case 'b': {
160   char *p = conv_escape_str(getstr());   int done = conv_escape_str(getstr());
161     char *p = stackblock();
162   *fmt = 's';   *fmt = 's';
163   PF(start, p);   PF(start, p);
164   /* escape if a \c was encountered */   /* escape if a \c was encountered */
165   if (rval & 0x100)   if (done)
166   goto out;   goto out;
167   *fmt = 'b';   *fmt = 'b';
168   break;   break;
# Line 212  pc: Line 213  pc:
213   } while (gargv != argv && *gargv);   } while (gargv != argv && *gargv);
214    
215  out:  out:
216   return (rval & ~0x100);   return rval;
217  err:  err:
218   return 1;   return 1;
219  }  }
# Line 222  err: Line 223  err:
223   * Print SysV echo(1) style escape string   * Print SysV echo(1) style escape string
224   * Halts processing string if a \c escape is encountered.   * Halts processing string if a \c escape is encountered.
225   */   */
226  static char *  static int
227  conv_escape_str(char *str)  conv_escape_str(char *str)
228  {  {
229   int ch;   int ch;
# Line 241  conv_escape_str(char *str) Line 242  conv_escape_str(char *str)
242   ch = *str++;   ch = *str++;
243   if (ch == 'c') {   if (ch == 'c') {
244   /* \c as in SYSV echo - abort all processing.... */   /* \c as in SYSV echo - abort all processing.... */
245   rval |= 0x100;   ch = 0x100;
  ch = 0;  
246   continue;   continue;
247   }   }
248    
# Line 269  conv_escape_str(char *str) Line 269  conv_escape_str(char *str)
269   /* Finally test for sequences valid in the format string */   /* Finally test for sequences valid in the format string */
270   str = conv_escape(str - 1, &c);   str = conv_escape(str - 1, &c);
271   ch = c;   ch = c;
272   } while (STPUTC(ch, cp), ch);   } while (STPUTC(ch, cp), (char)ch);
273    
274   return stackblock();   return ch;
275  }  }
276    
277  /*  /*
# Line 451  echocmd(int argc, char **argv) Line 451  echocmd(int argc, char **argv)
451   do {   do {
452   char c;   char c;
453    
454   c = *(*argv)++;   nonl += conv_escape_str(*argv);
455   if (!c)   outstr(stackblock(), outs);
456   goto next;   if (nonl > 0)
  if (c != '\\')  
  goto print;  
   
  outstr(conv_escape_str(*argv - 1), outs);  
  if (rval & 0x100)  
457   break;   break;
458  next:  
459   c = ' ';   c = ' ';
460   if (!*++argv) {   if (!*++argv) {
461  end:  end:
# Line 469  end: Line 464  end:
464   }   }
465   c = '\n';   c = '\n';
466   }   }
 print:  
467   outc(c, outs);   outc(c, outs);
468   } while (*argv);   } while (*argv);
469   return 0;   return 0;

Legend:
Removed from v.814  
changed lines
  Added in v.815