diff --git a/apps/plugins/lua/README b/apps/plugins/lua/README index 06cfd6f8f8..a56b500091 100644 --- a/apps/plugins/lua/README +++ b/apps/plugins/lua/README @@ -3,7 +3,4 @@ version 0.31 which is licensed under the GPL version 2: gmtime.c strftime.c - strpbrk.c - strtol.c - strtoul.c strstr.c diff --git a/apps/plugins/lua/SOURCES b/apps/plugins/lua/SOURCES index 481bf7672f..a188915a38 100644 --- a/apps/plugins/lua/SOURCES +++ b/apps/plugins/lua/SOURCES @@ -33,8 +33,6 @@ rocklib_img.c tlsf_helper.c strftime.c strpbrk.c -strtoul.c -strtol.c strstr.c rocklua.c luadir.c diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h index 503c2c7dec..9ff42e1d6c 100644 --- a/apps/plugins/lua/rockconf.h +++ b/apps/plugins/lua/rockconf.h @@ -43,8 +43,6 @@ extern char curpath[MAX_PATH]; struct tm *gmtime(const time_t *timep); -long strtol(const char *nptr, char **endptr, int base); -unsigned long strtoul(const char *str, char **endptr, int base); size_t strftime(char* dst, size_t max, const char* format, const struct tm* tm); long lfloor(long x); long lpow(long x, long y); @@ -64,6 +62,8 @@ int splash_scroller(int timeout, const char* str); #define strcmp rb->strcmp #define strcpy rb->strcpy #define strlen rb->strlen +#define strtol rb->strtol +#define strtoul rb->strtoul #define yield() rb->yield() #endif /* _ROCKCONF_H_ */ diff --git a/apps/plugins/lua/strtol.c b/apps/plugins/lua/strtol.c deleted file mode 100644 index 564494643d..0000000000 --- a/apps/plugins/lua/strtol.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "rocklibc.h" - -extern unsigned long int strtoul(const char *ptr, char **endptr, int base); - -#define ABS_LONG_MIN LONG_MAX -long int strtol(const char *nptr, char **endptr, int base) -{ - int neg=0; - unsigned long int v; - const char*orig=nptr; - - while(__unlikely(isspace(*nptr))) nptr++; - - if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; } - v=strtoul(nptr,endptr,base); - if (endptr && *endptr==nptr) *endptr=(char *)orig; - if (__unlikely(v>=ABS_LONG_MIN)) { - if (v==ABS_LONG_MIN && neg) { - errno=0; - return v; - } - errno=ERANGE; - return (neg?LONG_MIN:LONG_MAX); - } - return (neg?-v:v); -} - diff --git a/apps/plugins/lua/strtoul.c b/apps/plugins/lua/strtoul.c deleted file mode 100644 index 834721f05b..0000000000 --- a/apps/plugins/lua/strtoul.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "rocklibc.h" - -unsigned long int strtoul(const char *ptr, char **endptr, int base) -{ - int neg = 0, overflow = 0; - unsigned long int v=0; - const char* orig; - const char* nptr=ptr; - - while(__unlikely(isspace(*nptr))) ++nptr; - - if (*nptr == '-') { neg=1; nptr++; } - else if (*nptr == '+') ++nptr; - orig=nptr; - if (base==16 && nptr[0]=='0') goto skip0x; - if (base) { - register unsigned int b=base-2; - if (__unlikely(b>34)) { errno=EINVAL; return 0; } - } else { - if (*nptr=='0') { - base=8; -skip0x: - if ((nptr[1]=='x'||nptr[1]=='X') && isxdigit(nptr[2])) { - nptr+=2; - base=16; - } - } else - base=10; - } - while(__likely(*nptr)) { - register unsigned char c=*nptr; - c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff); - if (__unlikely(c>=base)) break; /* out of base */ - { - register unsigned long x=(v&0xff)*base+c; - register unsigned long w=(v>>8)*base+(x>>8); - if (w>(ULONG_MAX>>8)) overflow=1; - v=(w<<8)+(x&0xff); - } - ++nptr; - } - if (__unlikely(nptr==orig)) { /* no conversion done */ - nptr=ptr; - errno=EINVAL; - v=0; - } - if (endptr) *endptr=(char *)nptr; - if (overflow) { - errno=ERANGE; - return ULONG_MAX; - } - return (neg?-v:v); -} diff --git a/firmware/libc/strtol.c b/firmware/libc/strtol.c index a38acac025..71186755da 100644 --- a/firmware/libc/strtol.c +++ b/firmware/libc/strtol.c @@ -1,3 +1,6 @@ +/* The following file is (with slight modifications for Rockbox) from dietlibc +* version 0.31 which is licensed under the GPL version 2: */ + #include #include #include diff --git a/firmware/libc/strtoul.c b/firmware/libc/strtoul.c index 34a8ae47c2..2cbd80796a 100644 --- a/firmware/libc/strtoul.c +++ b/firmware/libc/strtoul.c @@ -1,3 +1,6 @@ +/* The following file is (with slight modifications for Rockbox) from dietlibc +* version 0.31 which is licensed under the GPL version 2: */ + #include #include #include