[BACK]Return to vfwscanf.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / stdio

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/stdio/vfwscanf.c between version 1.6 and 1.6.6.1

version 1.6, 2009/02/21 17:20:01 version 1.6.6.1, 2012/04/17 00:05:25
Line 49  __RCSID("$NetBSD$");
Line 49  __RCSID("$NetBSD$");
 #include "namespace.h"  #include "namespace.h"
 #include <ctype.h>  #include <ctype.h>
 #include <inttypes.h>  #include <inttypes.h>
   #include <assert.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <stddef.h>  #include <stddef.h>
Line 120  vfwscanf(FILE * __restrict fp, const wch
Line 121  vfwscanf(FILE * __restrict fp, const wch
         _SET_ORIENTATION(fp, 1);          _SET_ORIENTATION(fp, 1);
         ret = __vfwscanf_unlocked(fp, fmt, ap);          ret = __vfwscanf_unlocked(fp, fmt, ap);
         FUNLOCKFILE(fp);          FUNLOCKFILE(fp);
         return (ret);          return ret;
 }  }
   
 #define SCANF_SKIP_SPACE() \  #define SCANF_SKIP_SPACE() \
Line 147  __vfwscanf_unlocked(FILE * __restrict fp
Line 148  __vfwscanf_unlocked(FILE * __restrict fp
         wchar_t *p0;            /* saves original value of p when necessary */          wchar_t *p0;            /* saves original value of p when necessary */
         int nassigned;          /* number of fields assigned */          int nassigned;          /* number of fields assigned */
         int nconversions;       /* number of conversions */          int nconversions;       /* number of conversions */
         int nread;              /* number of characters consumed from fp */          size_t nread;           /* number of characters consumed from fp */
         int base;               /* base argument to conversion function */          int base;               /* base argument to conversion function */
         wchar_t buf[BUF];       /* buffer for numeric conversions */          wchar_t buf[BUF];       /* buffer for numeric conversions */
         const wchar_t *ccls;    /* character class start */          const wchar_t *ccls;    /* character class start */
Line 174  __vfwscanf_unlocked(FILE * __restrict fp
Line 175  __vfwscanf_unlocked(FILE * __restrict fp
         for (;;) {          for (;;) {
                 c = *fmt++;                  c = *fmt++;
                 if (c == 0)                  if (c == 0)
                         return (nassigned);                          return nassigned;
                 if (iswspace(c)) {                  if (iswspace(c)) {
                         while ((c = __fgetwc_unlock(fp)) != WEOF &&                          while ((c = __fgetwc_unlock(fp)) != WEOF &&
                             iswspace(c))                              iswspace(c))
Line 327  literal:
Line 328  literal:
                         if (flags & SUPPRESS)   /* ??? */                          if (flags & SUPPRESS)   /* ??? */
                                 continue;                                  continue;
                         if (flags & SHORTSHORT)                          if (flags & SHORTSHORT)
                                 *va_arg(ap, char *) = nread;                                  *va_arg(ap, char *) = (char)nread;
                         else if (flags & SHORT)                          else if (flags & SHORT)
                                 *va_arg(ap, short *) = nread;                                  *va_arg(ap, short *) = (short)nread;
                         else if (flags & LONG)                          else if (flags & LONG)
                                 *va_arg(ap, long *) = nread;                                  *va_arg(ap, long *) = nread;
                         else if (flags & LONGLONG)                          else if (flags & LONGLONG)
Line 341  literal:
Line 342  literal:
                         else if (flags & PTRDIFFT)                          else if (flags & PTRDIFFT)
                                 *va_arg(ap, ptrdiff_t *) = nread;                                  *va_arg(ap, ptrdiff_t *) = nread;
                         else                          else
                                 *va_arg(ap, int *) = nread;                                  *va_arg(ap, int *) = (int)nread;
                         continue;                          continue;
   
                 default:                  default:
Line 351  literal:
Line 352  literal:
                  * Disgusting backwards compatibility hack.     XXX                   * Disgusting backwards compatibility hack.     XXX
                  */                   */
                 case '\0':      /* compat */                  case '\0':      /* compat */
                         return (EOF);                          return EOF;
                 }                  }
   
                 /*                  /*
Line 450  literal:
Line 451  literal:
                                         *p++ = (wchar_t)wi;                                          *p++ = (wchar_t)wi;
                                 if (wi != WEOF)                                  if (wi != WEOF)
                                         ungetwc(wi, fp);                                          ungetwc(wi, fp);
                                 n = p - p0;                                  _DIAGASSERT(__type_fit(int, p - p0));
                                   n = (int)(p - p0);
                                 if (n == 0)                                  if (n == 0)
                                         goto match_failure;                                          goto match_failure;
                                 *p = 0;                                  *p = 0;
Line 699  literal:
Line 701  literal:
                                         *va_arg(ap, int *) = (int)res;                                          *va_arg(ap, int *) = (int)res;
                                 nassigned++;                                  nassigned++;
                         }                          }
                         nread += p - buf;                          _DIAGASSERT(__type_fit(int, p - buf));
                           nread += (int)(p - buf);
                         nconversions++;                          nconversions++;
                         break;                          break;
   
Line 736  literal:
Line 739  literal:
                 }                  }
         }          }
 input_failure:  input_failure:
         return (nconversions != 0 ? nassigned : EOF);          return nconversions != 0 ? nassigned : EOF;
 match_failure:  match_failure:
         return (nassigned);          return nassigned;
 }  }
   
 #ifndef NO_FLOATING_POINT  #ifndef NO_FLOATING_POINT
Line 891  parsedone:
Line 894  parsedone:
         while (commit < --p)          while (commit < --p)
                 ungetwc(*p, fp);                  ungetwc(*p, fp);
         *++commit = '\0';          *++commit = '\0';
         return (commit - buf);          _DIAGASSERT(__type_fit(int, commit - buf));
           return (int)(commit - buf);
 }  }
 #endif  #endif

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.6.6.1

CVSweb <webmaster@jp.NetBSD.org>