Fixed vfscanf() which needed strtoq(), and strtouq().

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1666 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-10-26 00:10:49 +00:00
parent deab46426d
commit 25c7a73eed
+12 -12
View File
@@ -41,7 +41,7 @@
#include "local.h" #include "local.h"
#ifdef FLOATING_POINT #ifdef FLOATING_POINT
#include "floatio.h" # include "floatio.h"
#endif #endif
#define BUF 513 /* Maximum length of numeric string. */ #define BUF 513 /* Maximum length of numeric string. */
@@ -77,7 +77,7 @@
#define CT_CHAR 0 /* %c conversion */ #define CT_CHAR 0 /* %c conversion */
#define CT_CCL 1 /* %[...] conversion */ #define CT_CCL 1 /* %[...] conversion */
#define CT_STRING 2 /* %s conversion */ #define CT_STRING 2 /* %s conversion */
#define CT_INT 3 /* integer, i.e., strtoq or strtouq */ #define CT_INT 3 /* integer, i.e., strtoll or strtoull */
#define CT_FLOAT 4 /* floating, i.e., strtod */ #define CT_FLOAT 4 /* floating, i.e., strtod */
#define u_char unsigned char #define u_char unsigned char
@@ -103,8 +103,8 @@ __svfscanf(fp, fmt0, ap)
register char *p0; /* saves original value of p when necessary */ register char *p0; /* saves original value of p when necessary */
int nassigned; /* number of fields assigned */ int nassigned; /* number of fields assigned */
int nread; /* number of characters consumed from fp */ int nread; /* number of characters consumed from fp */
int base; /* base argument to strtoq/strtouq */ int base; /* base argument to strtoll/strtoull */
uint64 (*ccfn)(); /* conversion function (strtoq/strtouq) */ uint64 (*ccfn)(); /* conversion function (strtoll/strtoull) */
char ccltab[256]; /* character class table for %[...] */ char ccltab[256]; /* character class table for %[...] */
char buf[BUF]; /* buffer for numeric conversions */ char buf[BUF]; /* buffer for numeric conversions */
@@ -184,13 +184,13 @@ literal:
/* FALLTHROUGH */ /* FALLTHROUGH */
case 'd': case 'd':
c = CT_INT; c = CT_INT;
ccfn = (uint64 (*)())strtoq; ccfn = (uint64 (*)())strtoll;
base = 10; base = 10;
break; break;
case 'i': case 'i':
c = CT_INT; c = CT_INT;
ccfn = (uint64 (*)())strtoq; ccfn = (uint64 (*)())strtoll;
base = 0; base = 0;
break; break;
@@ -199,13 +199,13 @@ literal:
/* FALLTHROUGH */ /* FALLTHROUGH */
case 'o': case 'o':
c = CT_INT; c = CT_INT;
ccfn = strtouq; ccfn = strtoull;
base = 8; base = 8;
break; break;
case 'u': case 'u':
c = CT_INT; c = CT_INT;
ccfn = strtouq; ccfn = strtoull;
base = 10; base = 10;
break; break;
@@ -213,7 +213,7 @@ literal:
case 'x': case 'x':
flags |= PFXOK; /* enable 0x prefixing */ flags |= PFXOK; /* enable 0x prefixing */
c = CT_INT; c = CT_INT;
ccfn = strtouq; ccfn = strtoull;
base = 16; base = 16;
break; break;
@@ -245,7 +245,7 @@ literal:
case 'p': /* pointer format is like hex */ case 'p': /* pointer format is like hex */
flags |= POINTER | PFXOK; flags |= POINTER | PFXOK;
c = CT_INT; c = CT_INT;
ccfn = strtouq; ccfn = strtoull;
base = 16; base = 16;
break; break;
@@ -270,7 +270,7 @@ literal:
if (isupper(c)) if (isupper(c))
flags |= LONG; flags |= LONG;
c = CT_INT; c = CT_INT;
ccfn = (uint64 (*)())strtoq; ccfn = (uint64 (*)())strtoll;
base = 10; base = 10;
break; break;
} }
@@ -412,7 +412,7 @@ literal:
continue; continue;
case CT_INT: case CT_INT:
/* scan an integer as if by strtoq/strtouq */ /* scan an integer as if by strtoll/strtoull */
#ifdef hardway #ifdef hardway
if (width == 0 || width > sizeof(buf) - 1) if (width == 0 || width > sizeof(buf) - 1)
width = sizeof(buf) - 1; width = sizeof(buf) - 1;