PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
strtok_r.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#define SYSCLIB_DISABLE_BUILTINS
12#include <sysclib.h>
13
14char *strtok_r(char *s, const char *delim, char **lasts)
15{
16 char *result;
17 const char *v4;
18 int v5;
19 int v6;
20 int v7;
21 char *v9;
22 const char *v10;
23 int v11;
24 char v12;
25
26 if (s || (s = *lasts, result = 0, *lasts))
27 {
28 do
29 {
30 v7 = (u8)*s;
31 if (!*s++)
32 {
33 break;
34 }
35 v4 = delim;
36 v5 = 0;
37 if (*delim)
38 {
39 v6 = *(u8 *)delim << 24;
40 while (v6 >> 24 != (char)v7)
41 {
42 v6 = *(u8 *)++v4 << 24;
43 if (!*v4)
44 {
45 goto LABEL_9;
46 }
47 }
48 v5 = 1;
49 }
50LABEL_9:
51 ;
52 }
53 while (v5);
54 v9 = s - 1;
55 if (v7)
56 {
57 do
58 {
59LABEL_18:
60 v12 = *s;
61 if (!*s++)
62 {
63 *lasts = 0;
64 return v9;
65 }
66 v10 = delim;
67 }
68 while (!*delim);
69 v11 = *(u8 *)delim << 24;
70 while (1)
71 {
72 v10 += 1;
73 if (v11 >> 24 == v12)
74 {
75 break;
76 }
77 v11 = *(u8 *)v10 << 24;
78 if (!*v10)
79 {
80 goto LABEL_18;
81 }
82 }
83 result = v9;
84 *(s - 1) = 0;
85 *lasts = s;
86 }
87 else
88 {
89 *lasts = 0;
90 return 0;
91 }
92 }
93 return result;
94}