mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-06 21:25:03 -05:00
lua -- remove strtol and strtoul replace with rb->strtol and rb->strtoul
Change-Id: Ib7ba358b6488b946404c0c4cd8773e948810a7f7
This commit is contained in:
parent
dada036b10
commit
8a773fb29f
7 changed files with 8 additions and 87 deletions
|
|
@ -3,7 +3,4 @@ version 0.31 which is licensed under the GPL version 2:
|
||||||
|
|
||||||
gmtime.c
|
gmtime.c
|
||||||
strftime.c
|
strftime.c
|
||||||
strpbrk.c
|
|
||||||
strtol.c
|
|
||||||
strtoul.c
|
|
||||||
strstr.c
|
strstr.c
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ rocklib_img.c
|
||||||
tlsf_helper.c
|
tlsf_helper.c
|
||||||
strftime.c
|
strftime.c
|
||||||
strpbrk.c
|
strpbrk.c
|
||||||
strtoul.c
|
|
||||||
strtol.c
|
|
||||||
strstr.c
|
strstr.c
|
||||||
rocklua.c
|
rocklua.c
|
||||||
luadir.c
|
luadir.c
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,6 @@
|
||||||
|
|
||||||
extern char curpath[MAX_PATH];
|
extern char curpath[MAX_PATH];
|
||||||
struct tm *gmtime(const time_t *timep);
|
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);
|
size_t strftime(char* dst, size_t max, const char* format, const struct tm* tm);
|
||||||
long lfloor(long x);
|
long lfloor(long x);
|
||||||
long lpow(long x, long y);
|
long lpow(long x, long y);
|
||||||
|
|
@ -64,6 +62,8 @@ int splash_scroller(int timeout, const char* str);
|
||||||
#define strcmp rb->strcmp
|
#define strcmp rb->strcmp
|
||||||
#define strcpy rb->strcpy
|
#define strcpy rb->strcpy
|
||||||
#define strlen rb->strlen
|
#define strlen rb->strlen
|
||||||
|
#define strtol rb->strtol
|
||||||
|
#define strtoul rb->strtoul
|
||||||
#define yield() rb->yield()
|
#define yield() rb->yield()
|
||||||
|
|
||||||
#endif /* _ROCKCONF_H_ */
|
#endif /* _ROCKCONF_H_ */
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
@ -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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
|
||||||
|
|
@ -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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue