aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-01-26 04:56:14 +0000
committerGuy Harris <guy@alum.mit.edu>2000-01-26 04:56:14 +0000
commit32ab13f9ed0b60c1be7209183b10ce5dbd79bae2 (patch)
treec9bb5a205e78e0a0a2f5ff73e4a60888db64ccd4 /util.c
parentb3ff56215780325b81c576cb9a6df1e3d39538df (diff)
downloadwireshark-32ab13f9ed0b60c1be7209183b10ce5dbd79bae2.tar.gz
wireshark-32ab13f9ed0b60c1be7209183b10ce5dbd79bae2.tar.bz2
wireshark-32ab13f9ed0b60c1be7209183b10ce5dbd79bae2.zip
In Win32, treat both '/' and '\' as pathname separators.
svn path=/trunk/; revision=1566
Diffstat (limited to 'util.c')
-rw-r--r--util.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/util.c b/util.c
index 30a6b8cf82..0082f523d2 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.29 2000/01/25 05:48:38 guy Exp $
+ * $Id: util.c,v 1.30 2000/01/26 04:56:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -99,16 +99,24 @@ find_last_pathname_separator(char *path)
char *separator;
#ifdef WIN32
+ char c;
+
/*
- * XXX - do we need to search for '/' as well?
+ * We have to scan for '\' or '/'.
+ * Get to the end of the string.
*/
- if ((separator = strrchr(path, '\\')) == NULL) {
- /*
- * OK, no directories - but there might be a drive
- * letter....
- */
- separator = strchr(path, ':');
+ separator = path + strlen(path); /* points to ending '\0' */
+ while (separator > path) {
+ c = *--separator;
+ if (c == '\\' || c == '/')
+ return separator; /* found it */
}
+
+ /*
+ * OK, we didn't find any, so no directories - but there might
+ * be a drive letter....
+ */
+ return strchr(path, ':');
#else
separator = strrchr(path, '/');
#endif