summaryrefslogtreecommitdiff
path: root/legacy/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-04-20 07:51:58 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-04-20 07:51:58 +0000
commitf9f6d76e9a2fef943632145c7e204ec7a4f1db71 (patch)
treec11780e72c148621a6d024366342179c80c252d0 /legacy/evil
parentc8412af4373fc5fc037888c12a22d77379ca9b22 (diff)
* NEWS:
* src/lib/evil_string.c: * src/lib/evil_string.h: Add strcasestr() API. SVN revision: 70350
Diffstat (limited to 'legacy/evil')
-rw-r--r--legacy/evil/ChangeLog7
-rw-r--r--legacy/evil/NEWS1
-rw-r--r--legacy/evil/src/lib/evil_string.c34
-rw-r--r--legacy/evil/src/lib/evil_string.h18
4 files changed, 60 insertions, 0 deletions
diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog
index 199e2e8b16..17ed8062d0 100644
--- a/legacy/evil/ChangeLog
+++ b/legacy/evil/ChangeLog
@@ -1,3 +1,10 @@
12012-04-20 Vincent Torri <doursse at users dot sf dot net>
2
3 * NEWS:
4 * src/lib/evil_string.c:
5 * src/lib/evil_string.h:
6 Add strcasestr() API.
7
12012-04-12 Vincent Torri <doursse at users dot sf dot net> 82012-04-12 Vincent Torri <doursse at users dot sf dot net>
2 9
3 * NEWS: 10 * NEWS:
diff --git a/legacy/evil/NEWS b/legacy/evil/NEWS
index 938e40926f..aacc92a14a 100644
--- a/legacy/evil/NEWS
+++ b/legacy/evil/NEWS
@@ -5,6 +5,7 @@ Evil NEWS - User visible changes.
5** Add evil_path_is_absolute() API 5** Add evil_path_is_absolute() API
6** Add POSIX printf() family functions 6** Add POSIX printf() family functions
7** Add S_ISLNK macro 7** Add S_ISLNK macro
8** Add strcasestr() API
8** Do not declare and define localtime_r() if it's already defined 9** Do not declare and define localtime_r() if it's already defined
9 10
10* Evil 1.0: 11* Evil 1.0:
diff --git a/legacy/evil/src/lib/evil_string.c b/legacy/evil/src/lib/evil_string.c
index 5a89d6815f..ffbe308b67 100644
--- a/legacy/evil/src/lib/evil_string.c
+++ b/legacy/evil/src/lib/evil_string.c
@@ -92,3 +92,37 @@ int strcasecmp(const char *s1, const char *s2)
92} 92}
93 93
94#endif /* _MSC_VER */ 94#endif /* _MSC_VER */
95
96char *strcasestr(const char *haystack, const char *needle)
97{
98 size_t length_needle;
99 size_t length_haystack;
100 size_t i;
101
102 if (!haystack || !needle)
103 return NULL;
104
105 length_needle = strlen(needle);
106 length_haystack = strlen(haystack) - length_needle + 1;
107
108 for (i = 0; i < length_haystack; i++)
109 {
110 size_t j;
111
112 for (j = 0; j < length_needle; j++)
113 {
114 unsigned char c1;
115 unsigned char c2;
116
117 c1 = haystack[i+j];
118 c2 = needle[j];
119 if (toupper(c1) != toupper(c2))
120 goto next;
121 }
122 return (char *) haystack + i;
123 next:
124 ;
125 }
126
127 return NULL;
128}
diff --git a/legacy/evil/src/lib/evil_string.h b/legacy/evil/src/lib/evil_string.h
index cce9636c3c..9141eba762 100644
--- a/legacy/evil/src/lib/evil_string.h
+++ b/legacy/evil/src/lib/evil_string.h
@@ -125,6 +125,24 @@ EAPI int strcasecmp(const char *s1, const char *s2);
125 125
126#endif /* _MSC_VER */ 126#endif /* _MSC_VER */
127 127
128/**
129 * @brief Locatea substring into a string, ignoring case.
130 *
131 * @param haystack The string to search in.
132 * @param needle The substring to find.
133 * @return
134 *
135 * This function locates the string @p needle into the string @p haystack,
136 * ignoring the case of the characters. It returns apointer to the
137 * beginning of the substring, or NULL if the substring is not found.
138 * If @p haystack or @p needle are @c NULL, this function returns @c NULL.
139 *
140 * Conformity: Non applicable.
141 *
142 * Supported OS: Windows XP, Windows CE
143 */
144EAPI char *strcasestr(const char *haystack, const char *needle);
145
128 146
129/** 147/**
130 * @} 148 * @}