Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
cd692f27
Commit
cd692f27
authored
Jan 14, 2014
by
Hisham Muhammad
Browse files
There was a bug in my implementaion. No reason not to use the glibc version.
parent
7fd5e804
Changes
2
Show whitespace changes
Inline
Side-by-side
String.c
View file @
cd692f27
...
@@ -16,6 +16,7 @@ in the source distribution for its full text.
...
@@ -16,6 +16,7 @@ in the source distribution for its full text.
/*{
/*{
#define String_startsWith(s, match) (strstr((s), (match)) == (s))
#define String_startsWith(s, match) (strstr((s), (match)) == (s))
#define String_contains_i(s1, s2) (strcasestr(s1, s2) != NULL)
}*/
}*/
char
*
String_cat
(
const
char
*
s1
,
const
char
*
s2
)
{
char
*
String_cat
(
const
char
*
s1
,
const
char
*
s2
)
{
...
@@ -91,17 +92,6 @@ void String_freeArray(char** s) {
...
@@ -91,17 +92,6 @@ void String_freeArray(char** s) {
free
(
s
);
free
(
s
);
}
}
int
String_contains_i
(
const
char
*
s
,
const
char
*
match
)
{
int
lens
=
strlen
(
s
);
int
lenmatch
=
strlen
(
match
);
for
(
int
i
=
0
;
i
<
lens
-
lenmatch
;
i
++
)
{
if
(
strncasecmp
(
s
,
match
,
strlen
(
match
))
==
0
)
return
1
;
s
++
;
}
return
0
;
}
char
*
String_getToken
(
const
char
*
line
,
const
unsigned
short
int
numMatch
)
{
char
*
String_getToken
(
const
char
*
line
,
const
unsigned
short
int
numMatch
)
{
const
unsigned
short
int
len
=
strlen
(
line
);
const
unsigned
short
int
len
=
strlen
(
line
);
char
inWord
=
0
;
char
inWord
=
0
;
...
...
String.h
View file @
cd692f27
...
@@ -10,6 +10,7 @@ in the source distribution for its full text.
...
@@ -10,6 +10,7 @@ in the source distribution for its full text.
*/
*/
#define String_startsWith(s, match) (strstr((s), (match)) == (s))
#define String_startsWith(s, match) (strstr((s), (match)) == (s))
#define String_contains_i(s1, s2) (strcasestr(s1, s2) != NULL)
char
*
String_cat
(
const
char
*
s1
,
const
char
*
s2
);
char
*
String_cat
(
const
char
*
s1
,
const
char
*
s2
);
...
@@ -21,8 +22,6 @@ char** String_split(const char* s, char sep, int* n);
...
@@ -21,8 +22,6 @@ char** String_split(const char* s, char sep, int* n);
void
String_freeArray
(
char
**
s
);
void
String_freeArray
(
char
**
s
);
int
String_contains_i
(
const
char
*
s
,
const
char
*
match
);
char
*
String_getToken
(
const
char
*
line
,
const
unsigned
short
int
numMatch
);
char
*
String_getToken
(
const
char
*
line
,
const
unsigned
short
int
numMatch
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment