Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
3e97e6d7
...
3e97e6d7732112df440a9d044cb0427dc1b57f2f
authored
2003-07-26 11:20:05 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mu_strcasestr): New function.
1 parent
66033faa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
include/mailutils/mutil.h
mailbox/mutil.c
include/mailutils/mutil.h
View file @
3e97e6d
...
...
@@ -115,6 +115,10 @@ extern char * mu_expand_path_pattern __P((const char *pattern,
extern
int
mu_rfc2822_references
__P
((
message_t
msg
,
char
**
pstr
));
extern
int
mu_rfc2822_in_reply_to
__P
((
message_t
msg
,
char
**
pstr
));
/* Find NEEDLE in the HAYSTACK. Case insensitive comparison */
extern
char
*
mu_strcasestr
__P
((
const
char
*
haystack
,
const
char
*
needle
));
#ifdef __cplusplus
}
...
...
mailbox/mutil.c
View file @
3e97e6d
...
...
@@ -1019,3 +1019,81 @@ mu_rfc2822_in_reply_to (message_t msg, char **pstr)
}
return
MU_ERR_FAILURE
;
}
/* Based on strstr from GNU libc (Stephen R. van den Berg,
berg@pool.informatik.rwth-aachen.de) */
char
*
mu_strcasestr
(
const
char
*
a_haystack
,
const
char
*
a_needle
)
{
register
const
unsigned
char
*
haystack
=
(
unsigned
char
*
)
a_haystack
,
*
needle
=
(
unsigned
char
*
)
a_needle
;
register
unsigned
int
b
,
c
;
#define U(c) toupper (c)
if
((
b
=
U
(
*
needle
)))
{
haystack
--
;
do
{
if
(
!
(
c
=
*++
haystack
))
goto
ret0
;
}
while
(
U
(
c
)
!=
b
);
if
(
!
(
c
=
*++
needle
))
goto
foundneedle
;
c
=
U
(
c
);
++
needle
;
goto
jin
;
for
(;;)
{
register
unsigned
int
a
;
register
const
unsigned
char
*
rhaystack
,
*
rneedle
;
do
{
if
(
!
(
a
=
*++
haystack
))
goto
ret0
;
if
(
U
(
a
)
==
b
)
break
;
if
(
!
(
a
=
*++
haystack
))
goto
ret0
;
shloop:
;
}
while
(
U
(
a
)
!=
b
);
jin:
if
(
!
(
a
=
*++
haystack
))
goto
ret0
;
if
(
U
(
a
)
!=
c
)
goto
shloop
;
if
(
U
(
*
(
rhaystack
=
haystack
--
+
1
))
==
(
a
=
U
(
*
(
rneedle
=
needle
))))
do
{
if
(
!
a
)
goto
foundneedle
;
if
(
U
(
*++
rhaystack
)
!=
(
a
=
U
(
*++
needle
)))
break
;
if
(
!
a
)
goto
foundneedle
;
}
while
(
U
(
*++
rhaystack
)
==
(
a
=
U
(
*++
needle
)));
needle
=
rneedle
;
if
(
!
a
)
break
;
}
}
foundneedle:
return
(
char
*
)
haystack
;
ret0:
return
NULL
;
#undef U
}
...
...
Please
register
or
sign in
to post a comment