Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
af1a3f9
)
Allow safe_fname() to tweak up to two name at a time.
author
Wayne Davison
<wayned@samba.org>
Mon, 26 Jul 2004 16:34:36 +0000
(16:34 +0000)
committer
Wayne Davison
<wayned@samba.org>
Mon, 26 Jul 2004 16:34:36 +0000
(16:34 +0000)
util.c
patch
|
blob
|
blame
|
history
diff --git
a/util.c
b/util.c
index
e7be7d7
..
13987b9
100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-902,17
+902,20
@@
int pop_dir(char *dir)
/**
* Return the filename, turning any newlines into '?'s. This ensures that
/**
* Return the filename, turning any newlines into '?'s. This ensures that
- * outputting it on a line of its own cannot generate an empty line.
+ * outputting it on a line of its own cannot generate an empty line. This
+ * function can handle only 2 names at a time!
**/
const char *safe_fname(const char *fname)
{
**/
const char *safe_fname(const char *fname)
{
- static char fbuf[MAXPATHLEN];
+ static char fbuf1[MAXPATHLEN], fbuf2[MAXPATHLEN];
+ static char *fbuf = fbuf2;
char *nl = strchr(fname, '\n');
if (!nl)
return fname;
char *nl = strchr(fname, '\n');
if (!nl)
return fname;
- strlcpy(fbuf, fname, sizeof fbuf);
+ fbuf = fbuf == fbuf1 ? fbuf2 : fbuf1;
+ strlcpy(fbuf, fname, MAXPATHLEN);
nl = fbuf + (nl - (char *)fname);
do {
*nl = '?';
nl = fbuf + (nl - (char *)fname);
do {
*nl = '?';