Commit 116c828c authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

add asserts, plus a few more cosmetic fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2257 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 11 additions and 2 deletions
+11 -2
......@@ -167,6 +167,8 @@ CVS code -
is_blank_char()
- Rewrite to use ctype functions instead of checking directly
for spaces and tabs. (DLR)
revstrstr(), revstristr()
- Add asserts. (DLR)
- winio.c:
titlebar()
- Rename some variables for consistency, make space an int
......
......@@ -209,8 +209,7 @@ const char *nstristr(const char *haystack, const char *needle)
assert(haystack != NULL && needle != NULL);
for (; *haystack != '\0'; haystack++) {
const char *p = haystack;
const char *q = needle;
const char *p = haystack, *q = needle;
for (; tolower(*p) == tolower(*q) && *q != '\0'; p++, q++)
;
......@@ -228,28 +227,36 @@ const char *nstristr(const char *haystack, const char *needle)
const char *revstrstr(const char *haystack, const char *needle, const
char *rev_start)
{
assert(haystack != NULL && needle != NULL && rev_start != NULL);
for (; rev_start >= haystack; rev_start--) {
const char *r, *q;
for (r = rev_start, q = needle; *q == *r && *q != '\0'; r++, q++)
;
if (*q == '\0')
return rev_start;
}
return NULL;
}
const char *revstristr(const char *haystack, const char *needle, const
char *rev_start)
{
assert(haystack != NULL && needle != NULL && rev_start != NULL);
for (; rev_start >= haystack; rev_start--) {
const char *r = rev_start, *q = needle;
for (; tolower(*q) == tolower(*r) && *q != '\0'; r++, q++)
;
if (*q == '\0')
return rev_start;
}
return NULL;
}
#endif /* !NANO_SMALL */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment