forked from github/server
Ich habe mich geirrt, was das Verhalten von atoi in Windows angeht. Alles zurueck.
This commit is contained in:
parent
01edb1e204
commit
57be0f2e6a
4 changed files with 4 additions and 34 deletions
|
@ -180,8 +180,9 @@ int destroy_cmd(unit * u, struct order *ord)
|
|||
s = gettoken(token, sizeof(token));
|
||||
|
||||
if (s && *s) {
|
||||
n = str_atoi(s);
|
||||
|
||||
ERRNO_CHECK();
|
||||
n = atoi(s);
|
||||
errno = 0;
|
||||
if (n <= 0) {
|
||||
n = INT_MAX;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -35,14 +34,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
int str_atoi(const char *str)
|
||||
{
|
||||
int e = errno;
|
||||
int i = atoi(str);
|
||||
errno = e;
|
||||
return i;
|
||||
}
|
||||
|
||||
size_t str_strlcpy(char *dst, const char *src, size_t len)
|
||||
{
|
||||
#ifdef HAVE_BSDSTRING
|
||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#define STRINGS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -27,7 +28,6 @@ extern "C" {
|
|||
|
||||
void str_replace(char *buffer, size_t size, const char *tmpl, const char *var, const char *value);
|
||||
int str_hash(const char *s);
|
||||
int str_atoi(const char *s);
|
||||
size_t str_slprintf(char * dst, size_t size, const char * format, ...);
|
||||
size_t str_strlcpy(char *dst, const char *src, size_t len);
|
||||
size_t str_strlcat(char *dst, const char *src, size_t len);
|
||||
|
|
|
@ -71,27 +71,6 @@ static void test_str_hash(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 140703196, str_hash("Hodor"));
|
||||
}
|
||||
|
||||
static void test_str_atoi(CuTest * tc)
|
||||
{
|
||||
errno = 0;
|
||||
CuAssertIntEquals(tc, 0, str_atoi("0"));
|
||||
CuAssertIntEquals(tc, 4, str_atoi("4"));
|
||||
CuAssertIntEquals(tc, 42, str_atoi("42"));
|
||||
CuAssertIntEquals(tc, -4, str_atoi("-4"));
|
||||
CuAssertIntEquals(tc, 0, errno);
|
||||
CuAssertIntEquals(tc, 4, str_atoi("4a"));
|
||||
CuAssertIntEquals(tc, 8, str_atoi("08"));
|
||||
CuAssertIntEquals(tc, 0, str_atoi("0x8"));
|
||||
CuAssertIntEquals(tc, 0, str_atoi("a"));
|
||||
CuAssertIntEquals(tc, 0, errno);
|
||||
errno = ERANGE;
|
||||
CuAssertIntEquals(tc, 0, str_atoi("a"));
|
||||
CuAssertIntEquals(tc, ERANGE, errno);
|
||||
errno = EINVAL;
|
||||
CuAssertIntEquals(tc, 0, str_atoi("a"));
|
||||
CuAssertIntEquals(tc, EINVAL, errno);
|
||||
}
|
||||
|
||||
static void test_str_slprintf(CuTest * tc)
|
||||
{
|
||||
char buffer[32];
|
||||
|
@ -178,7 +157,6 @@ static void test_sbstring(CuTest * tc)
|
|||
CuSuite *get_strings_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_str_atoi);
|
||||
SUITE_ADD_TEST(suite, test_str_hash);
|
||||
SUITE_ADD_TEST(suite, test_str_escape);
|
||||
SUITE_ADD_TEST(suite, test_str_escape_ex);
|
||||
|
|
Loading…
Reference in a new issue