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
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++)
;
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 */