diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/str.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/include/str.h b/include/str.h index 9a748366..f73c6212 100644 --- a/include/str.h +++ b/include/str.h @@ -45,21 +45,23 @@ strcata(CHAR8 *dest, const CHAR8 *src) static inline __attribute__((unused)) CHAR8 * -translate_slashes(char *str) +translate_slashes(CHAR8 *out, const char *str) { int i; int j; - if (str == NULL) - return (CHAR8 *)str; + if (str == NULL || out == NULL) + return NULL; for (i = 0, j = 0; str[i] != '\0'; i++, j++) { if (str[i] == '\\') { - str[j] = '/'; + out[j] = '/'; if (str[i+1] == '\\') i++; - } + } else + out[j] = str[i]; } - return (CHAR8 *)str; + out[j] = '\0'; + return out; } #endif /* SHIM_STR_H */ |
