Skip to content

Commit

Permalink
Rename PATH_SEP to DIR_SEP
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Oct 24, 2021
1 parent 6b348da commit 4d44b57
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ esac

case $host_os in
msys*|mingw32*)
PATH_SEP=\\\\
DIR_SEP=\\\\
;;
*)
PATH_SEP=/
DIR_SEP=/
;;
esac

AC_DEFINE_UNQUOTED([PATH_SEP], ["$PATH_SEP"], [Path separator])
AC_DEFINE_UNQUOTED([DIR_SEP], ["$DIR_SEP"], [Directory separator])
AC_DEFINE_UNQUOTED([EXEEXT], ["$EXEEXT"], [Executable file extension])

case $host_os in
Expand Down
4 changes: 2 additions & 2 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static libdwarf_handle_t *libdwarf_handle_for_file(const char *fname)
fatal("ELF library too old");

int fd;
if (strchr(fname, PATH_SEP[0]))
if (strchr(fname, DIR_SEP[0]))
fd = open(fname, O_RDONLY);
else {
char LOCAL *full = search_path(fname);
Expand Down Expand Up @@ -752,7 +752,7 @@ static void unwind_parse_vhdl_symbol(debug_frame_t *frame)
if (lib == NULL)
return;

const char *slash = strrchr(frame->module, PATH_SEP[0]);
const char *slash = strrchr(frame->module, DIR_SEP[0]);
char *file LOCAL = xstrdup(slash ? slash + 1 : frame->module);
if (file[0] != '_')
return;
Expand Down
12 changes: 6 additions & 6 deletions src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static lib_t lib_find_at(const char *name, const char *path, bool exact)
{
char dir[PATH_MAX];
char *p = dir + checked_sprintf(dir, sizeof(dir) - 4 - strlen(name),
"%s" PATH_SEP, path);
"%s" DIR_SEP, path);
bool found = false;

if (!exact) {
Expand All @@ -320,7 +320,7 @@ static lib_t lib_find_at(const char *name, const char *path, bool exact)
}

char marker[PATH_MAX];
checked_sprintf(marker, sizeof(marker), "%s" PATH_SEP "_NVC_LIB", dir);
checked_sprintf(marker, sizeof(marker), "%s" DIR_SEP "_NVC_LIB", dir);
if (access(marker, F_OK) < 0)
return NULL;

Expand All @@ -330,7 +330,7 @@ static lib_t lib_find_at(const char *name, const char *path, bool exact)
static text_buf_t *lib_file_path(lib_t lib, const char *name)
{
text_buf_t *tb = tb_new();
tb_printf(tb, "%s" PATH_SEP "%s", lib->path, name);
tb_printf(tb, "%s" DIR_SEP "%s", lib->path, name);
return tb;
}

Expand Down Expand Up @@ -369,7 +369,7 @@ lib_t lib_new(const char *name, const char *path)
fatal("invalid character '%c' in library name", *p);
}

char *lockf LOCAL = xasprintf("%s" PATH_SEP "%s", path, "_NVC_LIB");
char *lockf LOCAL = xasprintf("%s" DIR_SEP "%s", path, "_NVC_LIB");

struct stat buf;
if (stat(path, &buf) == 0) {
Expand Down Expand Up @@ -584,7 +584,7 @@ void lib_destroy(lib_t lib)
struct dirent *e;
while ((e = readdir(d))) {
if (e->d_name[0] != '.') {
checked_sprintf(buf, sizeof(buf), "%s" PATH_SEP "%s",
checked_sprintf(buf, sizeof(buf), "%s" DIR_SEP "%s",
lib->path, e->d_name);
if (unlink(buf) < 0)
perror("unlink");
Expand Down Expand Up @@ -947,7 +947,7 @@ void lib_realpath(lib_t lib, const char *name, char *buf, size_t buflen)
assert(lib != NULL);

if (name)
checked_sprintf(buf, buflen, "%s" PATH_SEP "%s", lib->path, name);
checked_sprintf(buf, buflen, "%s" DIR_SEP "%s", lib->path, name);
else
strncpy(buf, lib->path, buflen);
}
Expand Down
2 changes: 1 addition & 1 deletion src/nvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ static void parse_work_name(char *str, const char **name, const char **path)
{
char *split = strchr(str, ':');
if (split == NULL) {
char *slash = strrchr(str, *PATH_SEP) ?: strrchr(str, '/');
char *slash = strrchr(str, *DIR_SEP) ?: strrchr(str, '/');
if (slash == NULL)
*name = *path = str;
else {
Expand Down
4 changes: 2 additions & 2 deletions src/rt/cover.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ static const char *cover_file_url(cover_file_t *f)
static char buf[256];
checked_sprintf(buf, sizeof(buf) - 6, "report_%s.html", f->name);
for (char *p = buf; *(p + 5) != '\0'; p++) {
if (*p == PATH_SEP[0] || *p == '.')
if (*p == DIR_SEP[0] || *p == '.')
*p = '_';
}
return buf;
Expand Down Expand Up @@ -571,7 +571,7 @@ static void cover_html_footer(FILE *fp)

static void cover_report_file(cover_file_t *f, const char *dir)
{
char *buf LOCAL = xasprintf("%s" PATH_SEP "%s", dir, cover_file_url(f));
char *buf LOCAL = xasprintf("%s" DIR_SEP "%s", dir, cover_file_url(f));
FILE *fp = lib_fopen(lib_work(), buf, "w");
if (fp == NULL)
fatal("failed to create %s", buf);
Expand Down
2 changes: 1 addition & 1 deletion src/rt/fst.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void fst_init(const char *file, tree_t top, e_node_t e_root,
if (vcdfile == NULL)
fatal_errno("%s", file);

tmpfst = xasprintf("%s" PATH_SEP "temp.fst", tmpdir);
tmpfst = xasprintf("%s" DIR_SEP "temp.fst", tmpdir);
fst_ctx = fstWriterCreate(tmpfst, 1);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ char *search_path(const char *name)

char LOCAL *tmp = xstrdup(path);
for (char *p = strtok(tmp, ":"); p; p = strtok(NULL, ":")) {
char *full = xasprintf("%s"PATH_SEP"%s", p, name);
char *full = xasprintf("%s"DIR_SEP"%s", p, name);

struct stat sb;
if (stat(full, &sb) == 0)
Expand Down
16 changes: 8 additions & 8 deletions test/run_regr.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static bool remove_dir(const char *path)
struct dirent *e;
while ((e = readdir(d))) {
if (e->d_name[0] != '.') {
snprintf(buf, sizeof(buf), "%s" PATH_SEP "%s", path, e->d_name);
snprintf(buf, sizeof(buf), "%s" DIR_SEP "%s", path, e->d_name);
if (e->d_type == DT_DIR && !remove_dir(buf))
goto out_close;
else if (e->d_type == DT_REG && unlink(buf) < 0)
Expand All @@ -526,12 +526,12 @@ static bool remove_dir(const char *path)
#endif

__attribute__((unused))
static int make_dir(const char *name)
static bool make_dir(const char *name)
{
#ifdef __MINGW32__
return mkdir(name);
return mkdir(name) == 0;
#else
return mkdir(name, 0777);
return mkdir(name, 0777) == 0;
#endif
}

Expand Down Expand Up @@ -602,7 +602,7 @@ static bool run_test(test_t *test)

if (!enter_test_directory(test, dir)) {
set_attr(ANSI_FG_RED);
printf("failed (error creating test directory %s)\n", strerror(errno));
printf("failed (error creating test directory: %s)\n", strerror(errno));
set_attr(ANSI_RESET);
return false;
}
Expand All @@ -620,18 +620,18 @@ static bool run_test(test_t *test)

if (test->flags & F_SHELL) {
push_arg(&args, "/bin/sh");
push_arg(&args, "%s" PATH_SEP "regress" PATH_SEP "%s.sh",
push_arg(&args, "%s" DIR_SEP "regress" DIR_SEP "%s.sh",
test_dir, test->name);
}
else {
push_arg(&args, "%s" PATH_SEP "nvc%s", bin_dir, EXEEXT);
push_arg(&args, "%s" DIR_SEP "nvc%s", bin_dir, EXEEXT);
push_std(test, &args);

if (test->flags & F_WORKLIB)
push_arg(&args, "--work=%s", test->work);

push_arg(&args, "-a");
push_arg(&args, "%s" PATH_SEP "regress" PATH_SEP "%s.vhd",
push_arg(&args, "%s" DIR_SEP "regress" DIR_SEP "%s.vhd",
test_dir, test->name);

if (test->flags & F_RELAX)
Expand Down
2 changes: 1 addition & 1 deletion test/test_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void setup(void)
tmp = "/tmp";
}

char *path LOCAL = xasprintf("%s" PATH_SEP "test_lib", tmp);
char *path LOCAL = xasprintf("%s" DIR_SEP "test_lib", tmp);
work = lib_new("test_lib", path);
fail_if(work == NULL);
}
Expand Down

0 comments on commit 4d44b57

Please sign in to comment.