diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 17:32:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-17 17:32:54 +0300 |
commit | 5513da65b24a3ce77b1709acea841475115f3a7a (patch) | |
tree | 20bd4d26f20ac63ebf776cea3a0220c11258f06d /source/blender/blenlib/intern/path_util.c | |
parent | f19ecdeec64506415b9a9f75293df866691bbd28 (diff) |
Cleanup: trailing space for BLI
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 8add24c989d..cff11ec0361 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -188,7 +188,7 @@ void BLI_cleanup_path(const char *relabase, char *path) path = path + 2; /* leave the initial "//" untouched */ } } - + /* Note * memmove(start, eind, strlen(eind) + 1); * is the same as @@ -196,7 +196,7 @@ void BLI_cleanup_path(const char *relabase, char *path) * except strcpy should not be used because there is overlap, * so use memmove's slightly more obscure syntax - Campbell */ - + #ifdef WIN32 while ( (start = strstr(path, "\\..\\")) ) { eind = start + strlen("\\..\\") - 1; @@ -523,12 +523,12 @@ void BLI_path_rel(char *file, const char *relfile) const char *lslash; char temp[FILE_MAX]; char res[FILE_MAX]; - + /* if file is already relative, bail out */ if (BLI_path_is_rel(file)) { return; } - + /* also bail out if relative path is not set */ if (relfile[0] == '\0') { return; @@ -580,11 +580,11 @@ void BLI_path_rel(char *file, const char *relfile) BLI_str_replace_char(temp + BLI_path_unc_prefix_len(temp), '\\', '/'); BLI_str_replace_char(file + BLI_path_unc_prefix_len(file), '\\', '/'); - + /* remove /./ which confuse the following slash counting... */ BLI_cleanup_path(NULL, file); BLI_cleanup_path(NULL, temp); - + /* the last slash in the file indicates where the path part ends */ lslash = BLI_last_slash(temp); @@ -611,7 +611,7 @@ void BLI_path_rel(char *file, const char *relfile) } } - /* we might have passed the slash when the beginning of a dir matches + /* we might have passed the slash when the beginning of a dir matches * so we rewind. Only check on the actual filename */ if (*q != '/') { @@ -620,11 +620,11 @@ void BLI_path_rel(char *file, const char *relfile) else if (*p != '/') { while ( (p >= temp) && (*p != '/') ) { --p; --q; } } - + r += BLI_strcpy_rlen(r, "//"); /* p now points to the slash that is at the beginning of the part - * where the path is different from the relative path. + * where the path is different from the relative path. * We count the number of directories we need to go up in the * hierarchy to arrive at the common 'prefix' of the path */ @@ -638,7 +638,7 @@ void BLI_path_rel(char *file, const char *relfile) /* don't copy the slash at the beginning */ r += BLI_strcpy_rlen(r, q + 1); - + #ifdef WIN32 BLI_str_replace_char(res + 2, '/', '\\'); #endif @@ -733,7 +733,7 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end) ch_end++; } i = ch_end - 1; /* keep searching */ - + /* don't break, there may be a slash after this that invalidates the previous #'s */ } } @@ -950,7 +950,7 @@ bool BLI_path_abs(char *path, const char *basepath) } /* we are checking here if we have an absolute path that is not in the current - * blend file as a lib main - we are basically checking for the case that a + * blend file as a lib main - we are basically checking for the case that a * UNIX root '/' is passed. */ if (!wasrelative && !BLI_path_is_abs(path)) { @@ -967,20 +967,20 @@ bool BLI_path_abs(char *path, const char *basepath) } #else BLI_strncpy(tmp, path, sizeof(tmp)); - + /* Check for loading a windows path on a posix system - * in this case, there is no use in trying C:/ since it + * in this case, there is no use in trying C:/ since it * will never exist on a unix os. - * + * * Add a / prefix and lowercase the driveletter, remove the : * C:\foo.JPG -> /c/foo.JPG */ - + if (isalpha(tmp[0]) && tmp[1] == ':' && (tmp[2] == '\\' || tmp[2] == '/') ) { tmp[1] = tolower(tmp[0]); /* replace ':' with driveletter */ - tmp[0] = '/'; + tmp[0] = '/'; /* '\' the slash will be converted later */ } - + #endif /* push slashes into unix mode - strings entering this part are @@ -1009,7 +1009,7 @@ bool BLI_path_abs(char *path, const char *basepath) const int baselen = (int) (lslash - base) + 1; /* length up to and including last "/" */ /* use path for temp storage here, we copy back over it right away */ BLI_strncpy(path, tmp + 2, FILE_MAX); /* strip "//" */ - + memcpy(tmp, base, baselen); /* prefix with base up to last "/" */ BLI_strncpy(tmp + baselen, path, sizeof(tmp) - baselen); /* append path after "//" */ BLI_strncpy(path, tmp, FILE_MAX); /* return as result */ @@ -1055,7 +1055,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen) #endif bool wasrelative = true; const int filelen = strlen(path); - + #ifdef WIN32 if ((filelen >= 3 && BLI_path_is_abs(path)) || BLI_path_is_unc(path)) wasrelative = false; @@ -1063,7 +1063,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen) if (filelen >= 2 && path[0] == '/') wasrelative = false; #endif - + if (wasrelative) { char cwd[FILE_MAX]; /* in case the full path to the blend isn't used */ @@ -1076,7 +1076,7 @@ bool BLI_path_cwd(char *path, const size_t maxlen) printf("Could not get the current working directory - $PWD for an unknown reason.\n"); } } - + return wasrelative; } @@ -1297,10 +1297,10 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c /* Resolve relative references */ if (relabase && dir[0] == '/' && dir[1] == '/') { char *lslash; - + /* Get the file name, chop everything past the last slash (ie. the filename) */ strcpy(string, relabase); - + lslash = (char *)BLI_last_slash(string); if (lslash) *(lslash + 1) = 0; @@ -1325,7 +1325,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c else { /* we're out of luck here, guessing the first valid drive, usually c:\ */ get_default_root(string); } - + /* ignore leading slashes */ while (*dir == '/' || *dir == '\\') dir++; } @@ -1343,12 +1343,12 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c } /* since we've now removed all slashes, put back one slash at the end. */ strcat(string, "/"); - + while (*file && (*file == '/' || *file == '\\')) /* Trim slashes from the front of file */ file++; - + strcat(string, file); - + /* Push all slashes to the system preferred direction */ BLI_path_native_slash(string); } @@ -1539,7 +1539,7 @@ void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t d dir[0] = '\0'; } } - + if (file) { BLI_strncpy(file, string + lslash, filelen); } @@ -1792,10 +1792,10 @@ const char *BLI_first_slash(const char *string) { const char * const ffslash = strchr(string, '/'); const char * const fbslash = strchr(string, '\\'); - + if (!ffslash) return fbslash; else if (!fbslash) return ffslash; - + return (ffslash < fbslash) ? ffslash : fbslash; } @@ -1807,9 +1807,9 @@ const char *BLI_last_slash(const char *string) const char * const lfslash = strrchr(string, '/'); const char * const lbslash = strrchr(string, '\\'); - if (!lfslash) return lbslash; + if (!lfslash) return lbslash; else if (!lbslash) return lfslash; - + return (lfslash > lbslash) ? lfslash : lbslash; } |