SCP: Avoid warning on OS X which shouldn't be necessary
This commit is contained in:
parent
0e544b71ff
commit
a40d23fd53
1 changed files with 14 additions and 7 deletions
21
sim_fio.c
21
sim_fio.c
|
@ -764,10 +764,12 @@ const char *p;
|
||||||
|
|
||||||
if (((*filepath == '\'') || (*filepath == '"')) &&
|
if (((*filepath == '\'') || (*filepath == '"')) &&
|
||||||
(filepath[strlen (filepath) - 1] == *filepath)) {
|
(filepath[strlen (filepath) - 1] == *filepath)) {
|
||||||
tempfilepath = malloc (1 + strlen (filepath));
|
size_t temp_size = 1 + strlen (filepath);
|
||||||
|
|
||||||
|
tempfilepath = malloc (temp_size);
|
||||||
if (tempfilepath == NULL)
|
if (tempfilepath == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
strlcpy (tempfilepath, 1 + filepath, 1 + strlen (filepath));
|
strlcpy (tempfilepath, 1 + filepath, temp_size);
|
||||||
tempfilepath[strlen (tempfilepath) - 1] = '\0';
|
tempfilepath[strlen (tempfilepath) - 1] = '\0';
|
||||||
filepath = tempfilepath;
|
filepath = tempfilepath;
|
||||||
}
|
}
|
||||||
|
@ -776,28 +778,33 @@ if ((filepath[1] == ':') ||
|
||||||
(filepath[0] == '\\')){
|
(filepath[0] == '\\')){
|
||||||
tot_len = 1 + strlen (filepath);
|
tot_len = 1 + strlen (filepath);
|
||||||
fullpath = malloc (tot_len);
|
fullpath = malloc (tot_len);
|
||||||
if (fullpath == NULL)
|
if (fullpath == NULL) {
|
||||||
|
free (tempfilepath);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
strcpy (fullpath, filepath);
|
strcpy (fullpath, filepath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char dir[PATH_MAX+1] = "";
|
char dir[PATH_MAX+1] = "";
|
||||||
char *wd = sim_getcwd(dir, sizeof (dir));
|
char *wd = sim_getcwd(dir, sizeof (dir));
|
||||||
|
|
||||||
if (wd == NULL)
|
if (wd == NULL) {
|
||||||
|
free (tempfilepath);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
tot_len = 1 + strlen (filepath) + 1 + strlen (dir);
|
tot_len = 1 + strlen (filepath) + 1 + strlen (dir);
|
||||||
fullpath = malloc (tot_len);
|
fullpath = malloc (tot_len);
|
||||||
if (fullpath == NULL)
|
if (fullpath == NULL) {
|
||||||
|
free (tempfilepath);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
strlcpy (fullpath, dir, tot_len);
|
strlcpy (fullpath, dir, tot_len);
|
||||||
strlcat (fullpath, "/", tot_len);
|
strlcat (fullpath, "/", tot_len);
|
||||||
strlcat (fullpath, filepath, tot_len);
|
strlcat (fullpath, filepath, tot_len);
|
||||||
}
|
}
|
||||||
while ((c = strchr (fullpath, '\\'))) /* standardize on / directory separator */
|
while ((c = strchr (fullpath, '\\'))) /* standardize on / directory separator */
|
||||||
*c = '/';
|
*c = '/';
|
||||||
while ((c = strstr (fullpath, "//"))) /* strip out redundant / characters */
|
while ((c = strstr (fullpath + 1, "//"))) /* strip out redundant / characters (leaving the option for a leading //) */
|
||||||
memmove (c, c + 1, 1 + strlen (c + 1));
|
memmove (c, c + 1, 1 + strlen (c + 1));
|
||||||
while ((c = strstr (fullpath, "/./"))) /* strip out irrelevant /./ sequences */
|
while ((c = strstr (fullpath, "/./"))) /* strip out irrelevant /./ sequences */
|
||||||
memmove (c, c + 2, 1 + strlen (c + 2));
|
memmove (c, c + 2, 1 + strlen (c + 2));
|
||||||
|
|
Loading…
Add table
Reference in a new issue