projects
/
gnulib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
84dd1ea
)
* lib/tmpdir.c: Simplify code to add slash; no need for a loop.
author
Paul Eggert
<eggert@cs.ucla.edu>
Mon, 15 Jul 2013 20:32:24 +0000
(13:32 -0700)
committer
Paul Eggert
<eggert@cs.ucla.edu>
Mon, 15 Jul 2013 20:32:48 +0000
(13:32 -0700)
ChangeLog
patch
|
blob
|
history
lib/tmpdir.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index
6929de0
..
9b0cccd
100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-7,6
+7,7
@@
(path_search): Don't put slash after directory if __VMS.
Problem reported by Steven M. Schweda in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-07/msg00019.html>.
(path_search): Don't put slash after directory if __VMS.
Problem reported by Steven M. Schweda in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-07/msg00019.html>.
+ Simplify code to add slash; no need for a loop.
Do not remove trailing slash from "//".
Do not assume dlen <= INT_MAX.
Do not remove trailing slash from "//".
Do not assume dlen <= INT_MAX.
diff --git
a/lib/tmpdir.c
b/lib/tmpdir.c
index
aa2164d
..
405c4bd
100644
(file)
--- a/
lib/tmpdir.c
+++ b/
lib/tmpdir.c
@@
-89,11
+89,7
@@
path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
{
const char *d;
size_t dlen, plen;
{
const char *d;
size_t dlen, plen;
-#ifdef __VMS
- bool add_slash = false;
-#else
- bool add_slash = true;
-#endif
+ bool add_slash;
if (!pfx || !pfx[0])
{
if (!pfx || !pfx[0])
{
@@
-143,13
+139,12
@@
path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
}
}
}
}
- /* Remove trailing slashes, except remove just one from "//". */
dlen = strlen (dir);
dlen = strlen (dir);
- if (dlen == 2 && ISSLASH (dir[0]) && ISSLASH (dir[1]))
- dlen--;
- else
- while (0 < dlen && ISSLASH (dir[dlen - 1]))
- dlen--;
+ add_slash = dlen != 0 && !ISSLASH (dir[dlen - 1]);
+#ifdef __VMS
+ if (dlen != 0 && dir[dlen - 1] == ':')
+ add_slash = false;
+#endif
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
if (tmpl_len < dlen + add_slash + plen + 6 + 1)
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
if (tmpl_len < dlen + add_slash + plen + 6 + 1)