implement atoi so it doesn't change errno (for now)

This commit is contained in:
Enno Rehling 2018-10-20 09:58:50 +02:00
parent 130ecf3167
commit c7c306b0e5
3 changed files with 11 additions and 1 deletions

View file

@ -179,7 +179,8 @@ int destroy_cmd(unit * u, struct order *ord)
s = gettoken(token, sizeof(token));
if (s && *s) {
n = atoi((const char *)s);
n = atoi10((const char *)s);
if (n <= 0) {
n = INT_MAX;
}

View file

@ -23,6 +23,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
int atoi10(const char *str)
{
int i = atoi(str);
errno = 0;
return i;
}
int atoi36(const char *str)
{

View file

@ -31,6 +31,7 @@ extern "C" {
const char *itoa36(int i);
const char *itoa10(int i);
extern int atoi36(const char *s);
extern int atoi10(const char *s);
int i10toi36(int i);
#ifdef __cplusplus