[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/3] Oddities in dealing with the path of a stem
From: |
Jouke Witteveen |
Subject: |
[PATCH v2 3/3] Oddities in dealing with the path of a stem |
Date: |
Sat, 26 Oct 2019 12:24:29 +0200 |
User-agent: |
Mutt/1.12.2 (2019-09-21) |
Make the code match the comments.
---
src/implicit.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/implicit.c b/src/implicit.c
index e400dc6..f7b8c15 100644
--- a/src/implicit.c
+++ b/src/implicit.c
@@ -266,7 +266,7 @@ pattern_search (struct file *file, int archive,
/* Set LASTSLASH to point at the last slash in FILENAME
but not counting any slash at the end. (foo/bar/ counts as
bar/ in directory foo/, not empty in directory foo/bar/.) */
- lastslash = strrchr (filename, '/');
+ lastslash = memrchr (filename, '/', namelen - 1);
#ifdef VMS
if (lastslash == NULL)
lastslash = strrchr (filename, ']');
@@ -279,18 +279,16 @@ pattern_search (struct file *file, int archive,
/* Handle backslashes (possibly mixed with forward slashes)
and the case of "d:file". */
{
- char *bslash = strrchr (filename, '\\');
+ char *bslash = memrchr (filename, '\\', namelen - 1);
if (lastslash == 0 || bslash > lastslash)
lastslash = bslash;
if (lastslash == 0 && filename[0] && filename[1] == ':')
lastslash = filename + 1;
}
#endif
- if (lastslash != 0 && lastslash[1] == '\0')
- lastslash = 0;
}
- pathlen = lastslash - filename + 1;
+ pathlen = lastslash ? lastslash - filename + 1 : 0;
/* First see which pattern rules match this target and may be considered.
Put them in TRYRULES. */
--
2.23.0
- [PATCH v2 3/3] Oddities in dealing with the path of a stem,
Jouke Witteveen <=