/[global]/global/libutil/strbuf.c
ViewVC logotype

Diff of /global/libutil/strbuf.c

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

revision 1.23 by shigio, Tue May 10 05:17:52 2005 UTC revision 1.24 by h-iwamoto, Mon Jul 18 15:31:50 2005 UTC
# Line 401  strbuf_fgets(sb, ip, flags) Line 401  strbuf_fgets(sb, ip, flags)
401   *      i)      sb      STRBUF structure   *      i)      sb      STRBUF structure
402   *      i)      s       similar to sprintf()   *      i)      s       similar to sprintf()
403   *                      Currently the following format is supported.   *                      Currently the following format is supported.
404   *                      %s, %d, %<number>d, %<number>s   *                      %s, %d, %<number>d, %<number>s, %-<number>d, %-<number>s
405   */   */
406  void  void
407  #ifdef HAVE_STDARG_H  #ifdef HAVE_STDARG_H
# Line 438  strbuf_sprintf(sb, s, va_alist) Line 438  strbuf_sprintf(sb, s, va_alist)
438                  if (*s == '\0')                  if (*s == '\0')
439                          break;                          break;
440                  if (*s == '%') {                  if (*s == '%') {
441                          int c = *++s;                          int c = (unsigned char)*++s;
442                          /*                          /*
443                           * '%%' means '%'.                           * '%%' means '%'.
444                           */                           */
# Line 450  strbuf_sprintf(sb, s, va_alist) Line 450  strbuf_sprintf(sb, s, va_alist)
450                           * we forward the job to snprintf(3).                           * we forward the job to snprintf(3).
451                           * o %<number>d                           * o %<number>d
452                           * o %<number>s                           * o %<number>s
453                             * o %-<number>d
454                             * o %-<number>s
455                           */                           */
456                          else if (isdigit(c)) {                          else if (isdigit(c) || (c == '-' && isdigit((unsigned char)*(s + 1)))) {
457                                  char format[32], buf[1024];                                  char format[32], buf[1024];
458                                  int i = 0;                                  int i = 0;
459    
460                                  format[i++] = '%';                                  format[i++] = '%';
461                                  while (isdigit(*s))                                  if (c == '-')
462                                            format[i++] = *s++;
463                                    while (isdigit((unsigned char)*s))
464                                          format[i++] = *s++;                                          format[i++] = *s++;
465                                  format[i++] = c = *s;                                  format[i++] = c = *s;
466                                  format[i] = '\0';                                  format[i] = '\0';

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26