diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-03-21 02:50:16 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-03-21 02:50:16 +0000 |
commit | 1f64c87b23834a8bc2fa2a0a90dcf10ccd6d19f5 (patch) | |
tree | 3f682bae3dd914ffe5ea40a83efe38751044e5f4 | |
parent | 77f7e399bc91f19e09f9398ae212bae5d52a7174 (diff) |
Instead of duplicating rcs_suffixes and running strsep on it again,
just use the previous suffixes. Since all slashes were replaced
with NULs, reading `suffixes' will give the first extension.
OK xsa@
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 9822714f011..b63ad5e8810 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.80 2006/03/21 02:45:09 ray Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.81 2006/03/21 02:50:15 ray Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -319,7 +319,6 @@ rcs_choosefile(const char *filename) break; } } - xfree(suffixes); /* * If `ret' is still NULL no RCS file with any extension exists @@ -327,23 +326,17 @@ rcs_choosefile(const char *filename) */ if (ret == NULL) { /* - * XXX - We shouldn't need to do strsep again, - * suffixes should now be NUL separated. + * `suffixes' should now be NUL separated, so the first + * extension can be read just by reading `suffixes'. */ - next = suffixes = xstrdup(rcs_suffixes); - /* Get first extension again. */ - if ((ext = strsep(&next, "/")) == NULL) { - xfree(suffixes); - return (NULL); - } - if (strlcat(rcspath, ext, sizeof(rcspath)) >= sizeof(rcspath)) { + if (strlcat(rcspath, suffixes, sizeof(rcspath)) >= sizeof(rcspath)) { xfree(suffixes); return (NULL); } ret = xstrdup(rcspath); - xfree(suffixes); } + xfree(suffixes); return (ret); } |