Commit 64cdd351 by Benjamin Kosnik

locale_facets.tcc (num_get<char>::_M_extract): Fix signage, exponent, and…

locale_facets.tcc (num_get<char>::_M_extract): Fix signage, exponent, and scientific formatting issues.


2000-05-31  Russell Davidson  <russell@ehess.cnrs-mrs.fr>

	* bits/locale_facets.tcc (num_get<char>::_M_extract): Fix signage,
	exponent, and scientific formatting issues.
	* testsuite/27_io/istream_extractor_arith.cc (test09): Add tests.

From-SVN: r34328
parent b2c62b3c
2000-05-31 Russell Davidson <russell@ehess.cnrs-mrs.fr>
* bits/locale_facets.tcc (num_get<char>::_M_extract): Fix signage,
exponent, scientific formatting issues.
* testsuite/27_io/istream_extractor_arith.cc (test09): Add tests.
2000-05-31 Branko Cibej <branko.cibej@hermes.si> 2000-05-31 Branko Cibej <branko.cibej@hermes.si>
* bits/limits_generic.h (numeric_limits<wchar_t>): Use WCHAR_MIN * bits/limits_generic.h (numeric_limits<wchar_t>): Use WCHAR_MIN
...@@ -13,6 +19,8 @@ ...@@ -13,6 +19,8 @@
* acinclude.m4 (GLIBCPP_ENABLE_LONG_LONG): Add strtoull checks... * acinclude.m4 (GLIBCPP_ENABLE_LONG_LONG): Add strtoull checks...
* mkcheck.in (SH_FLAG): Add in -Wl,--rpath -Wl,$LIB_PATH. Tweaks.
2000-05-31 Steven King <sxking@uswest.net> 2000-05-31 Steven King <sxking@uswest.net>
* shadow/time.h: fix typo * shadow/time.h: fix typo
......
...@@ -313,6 +313,9 @@ namespace std ...@@ -313,6 +313,9 @@ namespace std
int __sep_pos = 0; int __sep_pos = 0;
int __pos = 0; int __pos = 0;
bool __testdec = false; bool __testdec = false;
bool __testEE = false;
bool __testsign = false;
bool __testEEsign = false;
const char* __lits = __fmt->_S_literals; const char* __lits = __fmt->_S_literals;
while (__valid && __beg != __end) while (__valid && __beg != __end)
...@@ -322,17 +325,42 @@ namespace std ...@@ -322,17 +325,42 @@ namespace std
const char* __p = strchr(__fmt->_S_literals, __c); const char* __p = strchr(__fmt->_S_literals, __c);
// NB: strchr returns true for __c == 0x0 // NB: strchr returns true for __c == 0x0
if (__p && __c) if (__p && __c)
{ {
if ((__p >= &__lits[__cache_type::_S_digits + __base] // Check for sign and accept if appropriate.
&& __p < &__lits[__cache_type::_S_digits_end]) || if ((__p == &__lits[__cache_type::_S_minus])
(__p >= &__lits[__cache_type::_S_udigits+__base] || (__p == &__lits[__cache_type::_S_plus]))
&& __p < &__lits[__cache_type::_S_udigits_end])) {
if (__testEE)
{
if (__testEEsign) break;
__testEEsign = true;
}
else
{
if (__testsign) break;
__testsign = true;
}
}
// Check for exponential part and accept if appropriate.
else if ((__p == &__lits[__cache_type::_S_ee])
|| (__p == &__lits[__cache_type::_S_Ee]))
{ {
if (!(__fp && (__p == &__lits[__cache_type::_S_ee] if (!__fp || __testEE || !__testsign) break;
|| __p == &__lits[__cache_type::_S_Ee]))) __testEE = true;
break;
} }
// Check for appropriate digits. If found, too late for a sign
else if ((__p >= &__lits[__cache_type::_S_digits]
&& __p < &__lits[__cache_type::_S_digits+__base])
|| (__p >= &__lits[__cache_type::_S_udigits]
&& __p < &__lits[__cache_type::_S_udigits+__base]))
{
__testsign = true;
if (__testEE) __testEEsign = true;
}
// Nothing else will do
else break;
__xtrc[__pos] = __c; __xtrc[__pos] = __c;
++__pos; ++__pos;
++__sep_pos; ++__sep_pos;
......
#!/usr/bin/env bash #!/usr/bin/env bash
# 2000-05-17 bkoz
# Script to do automated testing and data collection # Script to do automated testing and data collection
# for various test files, so that we don't have to do this by hand on # for various test files, so that we don't have to do this by hand on
# every test file. It attempts to collect some diagnostic info about # every test file. It attempts to collect some diagnostic info about
...@@ -61,14 +59,10 @@ fi ...@@ -61,14 +59,10 @@ fi
#LIB_PATH == where to find the build library binaries. #LIB_PATH == where to find the build library binaries.
if [ $WHICH != "1" ]; then if [ $WHICH != "1" ]; then
LIB_PATH="-L$BUILD_DIR/src/.libs" LIB_PATH="$BUILD_DIR/src/.libs"
# BSD seems to want this
# LIB_PATH="-L$BUILD_DIR/src/.libs -R$BUILD_DIR/src/.libs"
CXX="../../gcc/g++ -B../../gcc/" CXX="../../gcc/g++ -B../../gcc/"
elif [ $WHICH -eq 1 ]; then elif [ $WHICH -eq 1 ]; then
LIB_PATH="-L$PREFIX_DIR/lib" LIB_PATH="$PREFIX_DIR/lib"
# BSD seems to want this
# LIB_PATH="-L$PREFIX_DIR/lib -R$PREFIX_DIR/lib"
CXX="$PREFIX_DIR/bin/g++" CXX="$PREFIX_DIR/bin/g++"
fi fi
...@@ -77,10 +71,10 @@ fi ...@@ -77,10 +71,10 @@ fi
#CXX_FLAG="-g -O2 -DDEBUG_ASSERT " #CXX_FLAG="-g -O2 -DDEBUG_ASSERT "
CXX_FLAG="-g -DDEBUG_ASSERT " CXX_FLAG="-g -DDEBUG_ASSERT "
# a specific flag to force the use of shared libraries, if any # a specific flag(s) to force the use of shared libraries, if any
SH_FLAG="" SH_FLAG=""
# a specific flag to force the use of static libraries, if any # a specific flag(s) to force the use of static libraries, if any
ST_FLAG="-static" ST_FLAG="-static"
# Set up the testing directory, which should be in a directory called # Set up the testing directory, which should be in a directory called
...@@ -183,8 +177,8 @@ test_file() ...@@ -183,8 +177,8 @@ test_file()
# eventually have to calculate time_t anyhow. Or 3) just grab two # eventually have to calculate time_t anyhow. Or 3) just grab two
# time_t's (no more overhead than grabbing two date(1)'s). # time_t's (no more overhead than grabbing two date(1)'s).
COMP_TIME_START=$($TEST_DIR/printnow) COMP_TIME_START=$($TEST_DIR/printnow)
$CXX $CXX_FLAG $S_FLAG $INC_PATH $LIB_PATH $FILENAME \ $CXX $CXX_FLAG $S_FLAG $INC_PATH -L$LIB_PATH -Wl,--rpath -Wl,$LIB_PATH \
-o $EXENAME 2>> $LOG_FILE $FILENAME -o $EXENAME 2>> $LOG_FILE
COMP_TIME_END=$($TEST_DIR/printnow) COMP_TIME_END=$($TEST_DIR/printnow)
if [ $COMP_TIME_START -lt $COMP_TIME_END ]; then if [ $COMP_TIME_START -lt $COMP_TIME_END ]; then
...@@ -293,8 +287,8 @@ test_file() ...@@ -293,8 +287,8 @@ test_file()
#fi #fi
else else
# the file did not compile. Write out compilation info to the log file. # the file did not compile. Write out compilation info to the log file.
echo "$CXX $CXX_FLAG $ST_FLAG $INC_PATH $LIB_PATH $CNAME -o $EXENAME" \ echo "$CXX $CXX_FLAG $S_FLAG $INC_PATH -L$LIB_PATH -Wl,--rpath -Wl,$LIB_PATH \
2>> $LOG_FILE $FILENAME -o $EXENAME" 2>> $LOG_FILE
RESULT="-" RESULT="-"
TEXT="0" TEXT="0"
......
...@@ -355,6 +355,29 @@ void test08() ...@@ -355,6 +355,29 @@ void test08()
#endif #endif
} }
bool test09()
{
bool test = true;
std::string st("2.456e3-+0.567e-2");
std::stringbuf sb(st);
std::istream is(&sb);
double f1 = 0, f2 = 0;
char c;
(is>>std::ws) >> f1;
(is>>std::ws) >> c;
(is>>std::ws) >> f2;
test = f1 == 2456;
test &= f2 == 0.00567;
test &= c == '-';
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
}
int main() int main()
{ {
test01(); test01();
...@@ -364,6 +387,7 @@ int main() ...@@ -364,6 +387,7 @@ int main()
test06(); test06();
test07(); test07();
test08(); test08();
test09();
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment