From e3296f2155e3ac61d5ac6e8b4fdedb56cfbf23dd Mon Sep 17 00:00:00 2001 From: linghuazaii <1285470650@qq.com> Date: Fri, 29 Jul 2016 19:47:11 +0800 Subject: [PATCH] Change int64_t to long int and delete exclude stdint.h --- src/iniparser.c | 21 +++++++++------------ src/iniparser.h | 5 ++--- test/CuTest.c | 2 +- test/CuTest.h | 3 +-- test/test_iniparser.c | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/iniparser.c b/src/iniparser.c index 8c98fbc..7abc008 100644 --- a/src/iniparser.c +++ b/src/iniparser.c @@ -390,7 +390,7 @@ const char * iniparser_getstring(const dictionary * d, const char * key, const c /*-------------------------------------------------------------------------*/ /** - @brief Get the string associated to a key, convert to an int + @brief Get the string associated to a key, convert to an long int @param d Dictionary to search @param key Key string to look for @param notfound Value to return in case of error @@ -411,22 +411,21 @@ const char * iniparser_getstring(const dictionary * d, const char * key, const c Warning: the conversion may overflow in various ways. Conversion is totally outsourced to strtol(), see the associated man page for overflow handling. - - Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int iniparser_getint(const dictionary * d, const char * key, int notfound) +long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound) { const char * str ; str = iniparser_getstring(d, key, INI_INVALID_KEY); if (str==INI_INVALID_KEY) return notfound ; - return (int)strtol(str, NULL, 0); + return strtol(str, NULL, 0); } + /*-------------------------------------------------------------------------*/ /** - @brief Get the string associated to a key, convert to an int64_t + @brief Get the string associated to a key, convert to an int @param d Dictionary to search @param key Key string to look for @param notfound Value to return in case of error @@ -447,15 +446,13 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound) Warning: the conversion may overflow in various ways. Conversion is totally outsourced to strtol(), see the associated man page for overflow handling. + + Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int64_t iniparser_getlongint(const dictionary * d, const char * key, int64_t notfound) +int iniparser_getint(const dictionary * d, const char * key, int notfound) { - const char * str ; - - str = iniparser_getstring(d, key, INI_INVALID_KEY); - if (str==INI_INVALID_KEY) return notfound ; - return strtol(str, NULL, 0); + return (int)iniparser_getlongint(d, key, notfound); } /*-------------------------------------------------------------------------*/ diff --git a/src/iniparser.h b/src/iniparser.h index b78f492..e0f9b95 100644 --- a/src/iniparser.h +++ b/src/iniparser.h @@ -17,7 +17,6 @@ #include #include #include -#include /* * The following #include is necessary on many Unixes but not Linux. @@ -193,7 +192,7 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound); /*-------------------------------------------------------------------------*/ /** - @brief Get the string associated to a key, convert to an int64_t + @brief Get the string associated to a key, convert to an long int @param d Dictionary to search @param key Key string to look for @param notfound Value to return in case of error @@ -216,7 +215,7 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound); handling. */ /*--------------------------------------------------------------------------*/ -int64_t iniparser_getlongint(const dictionary * d, const char * key, int64_t notfound); +long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound); /*-------------------------------------------------------------------------*/ diff --git a/test/CuTest.c b/test/CuTest.c index a5a496d..463f170 100644 --- a/test/CuTest.c +++ b/test/CuTest.c @@ -212,7 +212,7 @@ void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line, const cha } void CuAssertLongIntEquals_LineMsg(CuTest *tc, const char *file, int line, const char *message, - int64_t expected, int64_t actual) + long int expected, long int actual) { char buf[STRING_MAX]; if (expected == actual) return; diff --git a/test/CuTest.h b/test/CuTest.h index 9845fef..0f58592 100644 --- a/test/CuTest.h +++ b/test/CuTest.h @@ -3,7 +3,6 @@ #include #include -#include #define CUTEST_VERSION "CuTest 1.5" @@ -67,7 +66,7 @@ void CuAssertIntEquals_LineMsg(CuTest* tc, int expected, int actual); void CuAssertLongIntEquals_LineMsg(CuTest *tc, const char *file, int line, const char *message, - int64_t expected, int64_t actual); + long int expected, long int actual); void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, double expected, double actual, double delta); diff --git a/test/test_iniparser.c b/test/test_iniparser.c index 3119f5b..fc9c3e8 100644 --- a/test/test_iniparser.c +++ b/test/test_iniparser.c @@ -343,7 +343,7 @@ void Test_iniparser_getlongint(CuTest *tc) unsigned i; char key_name[64]; dictionary *dic; - const struct { int64_t num; const char *value; } good_val[] = { + const struct { long int num; const char *value; } good_val[] = { { 0, "0" }, { 1, "1" }, { -1, "-1" }, -- GitLab