aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/string.c
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
commit9f4891f95070c66ea9f1aba99d72724d4ab24e5a (patch)
tree723e3ef2118a3d1a9e6dafa811ed1b8b1bc9196e /libpsn00b/libc/string.c
parent6762c39551ded059450d17d8bb0cb80642c8aaab (diff)
downloadpsn00bsdk-9f4891f95070c66ea9f1aba99d72724d4ab24e5a.tar.gz
Revised makefiles, added strtok(), command line arguments, SetHeapSize(), moved ISR and callback system to psxetc, moved debug font to psxgpu, fixed CD-ROM library crashing on PSIO, fixed interrupt callback setup to fix crashing on ResetGraph()
Diffstat (limited to 'libpsn00b/libc/string.c')
-rw-r--r--libpsn00b/libc/string.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/libpsn00b/libc/string.c b/libpsn00b/libc/string.c
index 0b7307d..e11ed67 100644
--- a/libpsn00b/libc/string.c
+++ b/libpsn00b/libc/string.c
@@ -302,6 +302,48 @@ double strtod(const char *nptr, char **endptr)
return (i + d)*s;
}
+/* implementation by Lameguy64, behaves like OpenWatcom's strtok() */
+/* BIOS strtok seemed either bugged, or designed for wide chars */
+
+static char *_strtok_curpos;
+static char *_strtok_endpos;
+
+char *strtok( char *s1, char *s2 )
+{
+ char *c,*t;
+
+ if( s1 )
+ {
+ _strtok_curpos = s1;
+ _strtok_endpos = s1+strlen( s1 );
+ }
+ else
+ {
+ if( _strtok_curpos >= _strtok_endpos )
+ return( NULL );
+ }
+
+ if( !*_strtok_curpos )
+ return( NULL );
+
+ if( c = strstr( _strtok_curpos, s2 ) )
+ {
+ *c = 0;
+ t = _strtok_curpos;
+ _strtok_curpos = c+1;
+ return( t );
+ }
+ else
+ {
+ t = _strtok_curpos;
+ _strtok_curpos += strlen( t );
+ return( t );
+ }
+
+ return( NULL );
+
+} /* strtok */
+
long double strtold(const char *nptr, char **endptr)
{
return (long double)strtod(nptr, endptr);
@@ -310,4 +352,4 @@ long double strtold(const char *nptr, char **endptr)
float strtof(const char *nptr, char **endptr)
{
return (float)strtod(nptr, endptr);
-}
+} \ No newline at end of file