Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fixing slash to HOST_DIRSEP #3856

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/db/dbmi_driver/d_mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int make_parent_dir(char *path, int mode)
char *slash;
int stat;

slash = rfind(path, '/');
slash = rfind(path, HOST_DIRSEP);
if (slash == NULL || slash == path)
return DB_OK; /* no parent dir to make. return ok */

Expand All @@ -83,7 +83,7 @@ static int make_parent_dir(char *path, int mode)
else {
stat = DB_FAILED;
}
*slash = '/'; /* put the slash back into the path */
*slash = HOST_DIRSEP; /* put the slash back into the path */

return stat;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/display/r_raster.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int D_open_driver(void)
if (!p && (m || c)) {
char *cmd;
char progname[GPATH_MAX];
char sep[2] = {HOST_DIRSEP, '\0'};

cmd = G_recreate_command();

Expand All @@ -108,9 +109,9 @@ int D_open_driver(void)
char element[GPATH_MAX];

G_temp_element(element);
strcat(element, "/");
strcat(element, sep);
strcat(element, "MONITORS");
strcat(element, "/");
strcat(element, sep);
strcat(element, m);
G_file_name(progname, element, "render.py", G_mapset());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/gis/copy_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int G_recursive_copy(const char *src, const char *dst)

if (G_lstat(dst, &sb) == 0 && S_ISDIR(sb.st_mode)) {
char path[GPATH_MAX];
const char *p = strrchr(src, '/');
const char *p = strrchr(src, HOST_DIRSEP);

/* src => dst/src */
sprintf(path, "%s/%s", dst, (p ? p + 1 : src));
Expand Down
6 changes: 3 additions & 3 deletions lib/gis/mapset_msc.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ int make_mapset_element_impl(const char *p_path, const char *p_element,
p++;
/* add trailing slash if missing */
--p;
if (*p++ != '/') {
*p++ = '/';
if (*p++ != HOST_DIRSEP) {
*p++ = HOST_DIRSEP;
*p = 0;
}

/* now append element, one directory at a time, to path */
while (1) {
if (*element == '/' || *element == 0) {
if (*element == HOST_DIRSEP || *element == 0) {
*p = 0;
char *msg = NULL;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere in the lines below one more change is needed to avoid issues like this (see OSGeo4W CI run log):

+ v.in.ascii --o -z format=standard input=data/random_points.ref output=random_points
ERROR: Unable to make mapset element vector/random_points
 (C:\Users\runneradmin\nc_spm_full_v2alpha2\__vector_v_what_rast3_test.v.what.rast3_fv_az845_621_4592\vector/random_points): No such file or directory

Expand Down
6 changes: 4 additions & 2 deletions lib/gis/tempfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ void G_temp_element(char *element)
void G__temp_element(char *element, int tmp)
{
const char *machine;
char sep[2] = {HOST_DIRSEP, '\0'};

strcpy(element, ".tmp");
machine = G__machine_name();
if (machine != NULL && *machine != 0) {
strcat(element, "/");
strcat(element, sep);
strcat(element, machine);
}

Expand All @@ -185,11 +186,12 @@ void G__temp_element(char *element, int tmp)
void G__temp_element_basedir(char *element, const char *basedir)
{
const char *machine;
char sep[2] = {HOST_DIRSEP, '\0'};

strcpy(element, ".tmp");
machine = G__machine_name();
if (machine != NULL && *machine != 0) {
strcat(element, "/");
strcat(element, sep);
strcat(element, machine);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/raster/gdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void read_gdal_options(void)
p = G_find_key_value("directory", key_val);
if (!p)
p = "gdal";
if (*p == '/') {
if (*p == HOST_DIRSEP) {
st->opts.dir = G_store(p);
}
else {
Expand Down
Loading