return pmem;
}
-/*
- * Custom xstrlen()
- */
-static size_t
-xstrlen(const char *s)
-{
- static size_t len;
- len = 0;
-
- if (!s)
- return len;
-
- while (*s)
- ++len, ++s;
-
- return len;
-}
-
/*
* Just a safe strncpy(3)
* Always null ('\0') terminates if both src and dest are valid pointers.
if (!src || !dest || !n)
return 0;
- len = xstrlen(src) + 1;
+ len = strlen(src) + 1;
if (n > len)
n = len;
else if (len > n)
return len;
}
-/*
- * Custom strcmp(), just what we need.
- * Returns 0 if same, -ve if s1 < s2, +ve if s1 > s2.
- */
-static int
-xstrcmp(const char *s1, const char *s2)
-{
- if (!s1 || !s2)
- return -1;
-
- while (*s1 && *s1 == *s2)
- ++s1, ++s2;
-
- return *s1 - *s2;
-}
-
/*
* The poor man's implementation of memrchr(3).
* We are only looking for '/' in this program.
xstrlcpy(buf, path, PATH_MAX);
/* Find last '/'. */
- last_slash = xmemrchr((uchar *)buf, '/', xstrlen(buf));
+ last_slash = xmemrchr((uchar *)buf, '/', strlen(buf));
if (last_slash != NULL && last_slash != buf && last_slash[1] == '\0') {
/* Determine whether all remaining characters are slashes. */
{
static char *base;
- base = xmemrchr((uchar *)path, '/', xstrlen(path));
+ base = xmemrchr((uchar *)path, '/', strlen(path));
return base ? base + 1 : path;
}
if (!s || !*s)
return s;
- size_t len = xstrlen(s) - 1;
+ size_t len = strlen(s) - 1;
while (len != 0 && (isspace(s[len]) || s[len] == '/'))
--len;
return NULL;
for (r = 0; bookmark[r].key && r < BM_MAX; ++r) {
- if (xstrcmp(bookmark[r].key, key) == 0) {
+ if (strcmp(bookmark[r].key, key) == 0) {
if (bookmark[r].loc[0] == '~') {
char *home = getenv("HOME");
DPRINTF_S(fname);
for (i = 0; i < n; ++i)
- if (xstrcmp(fname, dents[i].name) == 0)
+ if (strcmp(fname, dents[i].name) == 0)
return i;
return 0;
}
/* Strip trailing slashes */
- for (i = xstrlen(path) - 1; i > 0; --i)
+ for (i = strlen(path) - 1; i > 0; --i)
if (path[i] == '/')
path[i] = '\0';
else
ncols = PATH_MAX;
/* No text wrapping in cwd line */
- /* Show CWD: - xstrlen(CWD) - 1 = 6 */
+ /* Show CWD: - strlen(CWD) - 1 = 6 */
g_buf[ncols - 6] = '\0';
printw(CWD "%s\n\n", g_buf);
if (truecd == 0) {
/* Probable change in dir */
/* No-op if it's the same directory */
- if (xstrcmp(path, newpath) == 0)
+ if (strcmp(path, newpath) == 0)
break;
oldname[0] = '\0';
goto nochange;
}
- if (xstrcmp(path, dir) == 0) {
+ if (strcmp(path, dir) == 0) {
break;
}
case SEL_CDLAST: // fallthrough
case SEL_VISIT:
if (sel == SEL_VISIT) {
- if (xstrcmp(mark, path) == 0)
+ if (strcmp(mark, path) == 0)
break;
tmp = mark;
if (!xdiraccess(newpath))
goto nochange;
- if (xstrcmp(path, newpath) == 0)
+ if (strcmp(path, newpath) == 0)
break;
oldname[0] = '\0';
break;
/* Allow only relative, same dir paths */
- if (tmp[0] == '/' || xstrcmp(xbasename(tmp), tmp) != 0) {
+ if (tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0) {
printmsg(messages[STR_INPUT_ID]);
goto nochange;
}
break;
/* Allow only relative, same dir paths */
- if (tmp[0] == '/' || xstrcmp(xbasename(tmp), tmp) != 0) {
+ if (tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0) {
printmsg(messages[STR_INPUT_ID]);
goto nochange;
}
/* Skip renaming to same name */
- if (xstrcmp(tmp, dents[cur].name) == 0)
+ if (strcmp(tmp, dents[cur].name) == 0)
break;
/* Open the descriptor to currently open directory */
goto begin;
case SEL_RUNARG:
run = xgetenv(env, run);
- if ((!run || !run[0]) && (xstrcmp("VISUAL", env) == 0))
+ if ((!run || !run[0]) && (strcmp("VISUAL", env) == 0))
run = editor ? editor : xgetenv("EDITOR", "vi");
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
break;