Mail Archives: djgpp-workers/2009/03/28/09:32:22
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-workers-bounces using -f
|
X-Recipient: | djgpp-workers AT delorie DOT com
|
Date: | Sat, 28 Mar 2009 15:04:41 +0100
|
From: | "Juan Manuel Guerrero" <juan DOT guerrero AT gmx DOT de>
|
Message-ID: | <20090328140441.259460@gmx.net>
|
MIME-Version: | 1.0
|
Subject: | Implementation for %[aA] conversion specifier support for scanf fmaily
|
| of functions
|
To: | djgpp-workers AT delorie DOT com
|
X-Authenticated: | #27081556
|
X-Flags: | 0001
|
X-Mailer: | WWW-Mail 6100 (Global Message Exchange)
|
X-Priority: | 3
|
X-Provags-ID: | V01U2FsdGVkX18AzY8YbN8AcQ/RmJQFPs7zSPNup7spio7FClpies
|
| Yut/j425a6pQIitK5IfpzKEPoa+RZR7TWwzA==
|
X-GMX-UID: | Sxf2fGYWbmwoSCZJ9TZLpABPUzc4cpHa
|
X-FuHaFi: | 0.44
|
Reply-To: | djgpp-workers AT delorie DOT com
|
Some time ago I commited a patch to support hex floats in the strtod family of
functions. Now, this can be used to implement the %[aA] conversion support for
the scanf family of functions.
Regards,
Juan M. Guerrero
2009-02-02 Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
Diffs against djgpp CVS head of 2009-03-25.
* src/libc/ansi/stdio/doscan.c: Support for %[aA] conversion specifier
added.
* src/libc/ansi/stdio/scanf.txh: Information about %[aA] conversion
specifier added.
* src/docs/kb/wc204.txi: Info about %[aA] conversion specifier for
doscan() added.
* tests/libc/ansi/stdio/tscanf.c: Test case for %[aA] conversion specifier
added.
diff -aprNU3 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi
--- djgpp.orig/src/docs/kb/wc204.txi 2009-02-01 11:22:26 +0000
+++ djgpp/src/docs/kb/wc204.txi 2009-03-28 14:48:22 +0000
@@ -1176,3 +1176,9 @@ stored in the member @code{name} of the
and used by @code{readdir}, @code{rewinddir} and @code{__set_need_fake_dot_dotdot}.
Now it only contains the canonicalized path to the directory without a terminating slash.
Those functions that require the trailing search pattern @code{/*.*} will append it.
+
+@findex _doscan AT r{, and C99 conversion specifiers}
+@findex scanf AT r{, and C99 conversion specifiers}
+The @code{a}, @code{A} and @code{F} conversion specifiers
+are now supported by @code{_doscan} and the @code{scanf}
+family of functions.
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/doscan.c djgpp/src/libc/ansi/stdio/doscan.c
--- djgpp.orig/src/libc/ansi/stdio/doscan.c 2004-04-08 16:11:04 +0000
+++ djgpp/src/libc/ansi/stdio/doscan.c 2009-03-28 14:48:22 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2009 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
@@ -44,7 +45,7 @@ static char _sctab[256] = {
};
static int nchars = 0;
-static char decimal = '.';
+static char decimal_point = '.';
int
_doscan(FILE *iop, const char *fmt, va_list argp)
@@ -61,7 +62,7 @@ _doscan_low(FILE *iop, int (*scan_getc)(
int *ptr, fileended, size;
int suppressed;
- decimal = localeconv()->decimal_point[0];
+ decimal_point = localeconv()->decimal_point[0];
nchars = 0;
nmatch = 0;
fileended = 0;
@@ -228,12 +229,12 @@ _innum(int *ptr, int type, int len, int
lcval = 0;
ndigit = 0;
scale = INT;
- if (type=='e'||type=='f'||type=='g')
+ if (type=='a'||type=='e'||type=='f'||type=='g')
scale = FLOAT;
base = 10;
if (type=='o')
base = 8;
- else if (type=='x'||type=='p')
+ else if (type=='x'||type=='p'||type=='a')
base = 16;
np = numbuf;
expseen = 0;
@@ -258,7 +259,7 @@ _innum(int *ptr, int type, int len, int
cpos++;
if (c == '0' && cpos == 1 && type == 'i')
base = 8;
- if ((c == 'x' || c == 'X') && (type == 'i' || type == 'x')
+ if ((c == 'x' || c == 'X') && (type == 'a' || type == 'i' || type == 'x')
&& cpos == 2 && lcval == 0)
{
base = 16;
@@ -283,13 +284,13 @@ _innum(int *ptr, int type, int len, int
lcval += c;
c = c1;
continue;
- } else if (c==decimal) {
- if (base!=10 || scale==INT)
+ } else if (c==decimal_point) {
+ if (scale==INT || base==8)
break;
ndigit++;
continue;
- } else if ((c=='e'||c=='E') && expseen==0) {
- if (base!=10 || scale==INT || ndigit==0)
+ } else if ((c=='e'||c=='E'||c=='p'||c=='P') && expseen==0) {
+ if (scale==INT || base==8 || ndigit==0)
break;
expseen++;
*np++ = c;
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/scanf.txh djgpp/src/libc/ansi/stdio/scanf.txh
--- djgpp.orig/src/libc/ansi/stdio/scanf.txh 2003-01-29 12:28:44 +0000
+++ djgpp/src/libc/ansi/stdio/scanf.txh 2009-03-28 14:48:22 +0000
@@ -115,6 +115,12 @@ Convert the input to a @code{ptrdiff_t}
Convert the input to a @code{size_t} using 10 as the base.
+
+@item a
+@itemx A
+
+Convert the input of the form [+|-]0xH.HHHHp|P[+|-]DDD to a floating point number (a @code{float}).
+
@item e
@itemx E
@itemx f
@@ -124,6 +130,11 @@ Convert the input to a @code{size_t} usi
Convert the input to a floating point number (a @code{float}).
+@item la
+@itemx lA
+
+Convert the input of the form [+|-]0xH.HHHHp|P[+|-]DDD to a floating point number (a @code{double}).
+
@item le
@itemx lE
@itemx lf
@@ -131,7 +142,14 @@ Convert the input to a floating point nu
@itemx lg
@itemx lG
-Convert the input to a @code{double}.
+Convert the input to a floating point number (a @code{double}).
+
+@item La
+@itemx LA
+@item lla
+@itemx llA
+
+Convert the input of the form [+|-]0xH.HHHHp|P[+|-]DDD to a floating point number (a @code{double}).
@item Le
@itemx LE
@@ -146,7 +164,7 @@ Convert the input to a @code{double}.
@itemx llg
@itemx llG
-Convert the input to a @code{long double}.
+Convert the input to a floating point number (a @code{long double}.
@item i
diff -aprNU3 djgpp.orig/tests/libc/ansi/stdio/tscanf.c djgpp/tests/libc/ansi/stdio/tscanf.c
--- djgpp.orig/tests/libc/ansi/stdio/tscanf.c 2002-06-08 13:54:12 +0000
+++ djgpp/tests/libc/ansi/stdio/tscanf.c 2009-03-28 14:48:22 +0000
@@ -119,6 +119,7 @@ int convert_and_print (const char *fmt,
return converted;
}
+ case 'a': case 'A':
case 'e': case 'E':
case 'f':
case 'g': case 'G':
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
- Raw text -