summaryrefslogtreecommitdiffstats
path: root/contrib/groff/libgroff/searchpath.cc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/groff/libgroff/searchpath.cc')
-rw-r--r--contrib/groff/libgroff/searchpath.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/contrib/groff/libgroff/searchpath.cc b/contrib/groff/libgroff/searchpath.cc
index 730b5d9..a857c25 100644
--- a/contrib/groff/libgroff/searchpath.cc
+++ b/contrib/groff/libgroff/searchpath.cc
@@ -25,6 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "lib.h"
#include "searchpath.h"
+#include "nonposix.h"
search_path::search_path(const char *envvar, const char *standard)
{
@@ -32,7 +33,7 @@ search_path::search_path(const char *envvar, const char *standard)
if (e && standard) {
dirs = new char[strlen(e) + strlen(standard) + 2];
strcpy(dirs, e);
- strcat(dirs, ":");
+ strcat(dirs, PATH_SEP);
strcat(dirs, standard);
}
else
@@ -59,11 +60,11 @@ void search_path::command_line_dir(const char *s)
char *p = dirs;
p += old_len - init_len;
if (init_len == 0)
- *p++ = ':';
+ *p++ = PATH_SEP[0];
memcpy(p, s, slen);
p += slen;
if (init_len > 0) {
- *p++ = ':';
+ *p++ = PATH_SEP[0];
memcpy(p, old + old_len - init_len, init_len);
p += init_len;
}
@@ -75,7 +76,7 @@ void search_path::command_line_dir(const char *s)
FILE *search_path::open_file(const char *name, char **pathp)
{
assert(name != 0);
- if (*name == '/' || dirs == 0 || *dirs == '\0') {
+ if (IS_ABSOLUTE(name) || dirs == 0 || *dirs == '\0') {
FILE *fp = fopen(name, "r");
if (fp) {
if (pathp)
@@ -88,10 +89,10 @@ FILE *search_path::open_file(const char *name, char **pathp)
unsigned namelen = strlen(name);
char *p = dirs;
for (;;) {
- char *end = strchr(p, ':');
+ char *end = strchr(p, PATH_SEP[0]);
if (!end)
end = strchr(p, '\0');
- int need_slash = end > p && end[-1] != '/';
+ int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;
char *path = new char[(end - p) + need_slash + namelen + 1];
memcpy(path, p, end - p);
if (need_slash)
OpenPOWER on IntegriCloud