From f9f24fab933266ab8e12da7eef4cc2a906f77350 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 3 May 2007 06:10:32 +0000 Subject: Added code to use boost::lexical_cast<>. --- configure | 20 ++++++++++---------- configure.in | 2 +- src/main.cc | 2 +- src/system.hh | 1 + src/textual.cc | 2 +- src/value.cc | 2 +- src/xpath.cc | 2 +- tests/numerics/BasicAmount.cc | 12 ++++++------ 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/configure b/configure index 934235df..7a154c74 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for ledger 3.0-git. +# Generated by GNU Autoconf 2.61 for ledger 3.0-git-lexical_cast. # # Report bugs to . # @@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='ledger' PACKAGE_TARNAME='ledger' -PACKAGE_VERSION='3.0-git' -PACKAGE_STRING='ledger 3.0-git' +PACKAGE_VERSION='3.0-git-lexical_cast' +PACKAGE_STRING='ledger 3.0-git-lexical_cast' PACKAGE_BUGREPORT='johnw@newartisans.com' ac_unique_file="ledger" @@ -1424,7 +1424,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ledger 3.0-git to adapt to many kinds of systems. +\`configure' configures ledger 3.0-git-lexical_cast to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1494,7 +1494,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ledger 3.0-git:";; + short | recursive ) echo "Configuration of ledger 3.0-git-lexical_cast:";; esac cat <<\_ACEOF @@ -1605,7 +1605,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ledger configure 3.0-git +ledger configure 3.0-git-lexical_cast generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1619,7 +1619,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ledger $as_me 3.0-git, which was +It was created by ledger $as_me 3.0-git-lexical_cast, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2310,7 +2310,7 @@ fi # Define the identity of the package. PACKAGE='ledger' - VERSION='3.0-git' + VERSION='3.0-git-lexical_cast' cat >>confdefs.h <<_ACEOF @@ -21967,7 +21967,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ledger $as_me 3.0-git, which was +This file was extended by ledger $as_me 3.0-git-lexical_cast, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -22020,7 +22020,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -ledger config.status 3.0-git +ledger config.status 3.0-git-lexical_cast configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index d72e668f..769f3e8a 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ AC_PREREQ(2.59) -AC_INIT(ledger, 3.0-git, johnw@newartisans.com) +AC_INIT(ledger, 3.0-git-lexical_cast, johnw@newartisans.com) AC_CONFIG_SRCDIR(ledger) AM_INIT_AUTOMAKE diff --git a/src/main.cc b/src/main.cc index ade5b6a1..ae3d0d46 100644 --- a/src/main.cc +++ b/src/main.cc @@ -408,7 +408,7 @@ int main(int argc, char * argv[], char * envp[]) #if defined(TRACING_ON) if (i + 1 < argc && std::strcmp(argv[i], "--trace") == 0) { ledger::_log_level = LOG_TRACE; - ledger::_trace_level = std::atoi(argv[i + 1]); + ledger::_trace_level = lexical_cast(argv[i + 1]); i++; } #endif diff --git a/src/system.hh b/src/system.hh index fe1e7b7f..34319d75 100644 --- a/src/system.hh +++ b/src/system.hh @@ -106,6 +106,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/src/textual.cc b/src/textual.cc index 0a4c7333..5fe13e6d 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -774,7 +774,7 @@ unsigned int textual_parser_t::parse(std::istream& in, case 'Y': // set current year #if 0 // jww (2007-04-18): Need to set this up again - date_t::current_year = std::atoi(skip_ws(line + 1)); + date_t::current_year = lexical_cast(skip_ws(line + 1)); #endif break; diff --git a/src/value.cc b/src/value.cc index d5d4e655..b181df8f 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1647,7 +1647,7 @@ void value_t::in_place_cast(type_t cast_type) break; } if (alldigits) { - long temp = std::atol((*(string **) data)->c_str()); + long temp = lexical_cast((*(string **) data)->c_str()); destroy(); *(long *) data = temp; } else { diff --git a/src/xpath.cc b/src/xpath.cc index 1dabd871..a7e1e661 100644 --- a/src/xpath.cc +++ b/src/xpath.cc @@ -654,7 +654,7 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const int id = -1; if (std::isdigit(ident[0])) { node.reset(new op_t(op_t::ARG_INDEX)); - node->arg_index = std::atol(ident.c_str()); + node->arg_index = lexical_cast(ident.c_str()); } else if ((id = document_t::lookup_builtin_id(ident)) != -1) { node.reset(new op_t(op_t::NODE_ID)); diff --git a/tests/numerics/BasicAmount.cc b/tests/numerics/BasicAmount.cc index c1a1f0fa..de249ae5 100644 --- a/tests/numerics/BasicAmount.cc +++ b/tests/numerics/BasicAmount.cc @@ -17,8 +17,8 @@ void BasicAmountTestCase::testConstructors() amount_t x3(123.456); amount_t x5("123456"); amount_t x6("123.456"); - amount_t x7(std::string("123456")); - amount_t x8(std::string("123.456")); + amount_t x7(string("123456")); + amount_t x8(string("123.456")); amount_t x9(x3); amount_t x10(x6); amount_t x11(x8); @@ -76,8 +76,8 @@ void BasicAmountTestCase::testAssignment() x3 = 123.456; x5 = "123456"; x6 = "123.456"; - x7 = std::string("123456"); - x8 = std::string("123.456"); + x7 = string("123456"); + x8 = string("123.456"); x9 = x3; x10 = amount_t(x6); @@ -415,8 +415,8 @@ void BasicAmountTestCase::testNegation() amount_t x3(-123.456); amount_t x5("-123456"); amount_t x6("-123.456"); - amount_t x7(std::string("-123456")); - amount_t x8(std::string("-123.456")); + amount_t x7(string("-123456")); + amount_t x8(string("-123.456")); amount_t x9(- x3); assertEqual(amount_t(0L), x0); -- cgit v1.2.3