Improve string util API

Use prefixed names and improve documentation.
This commit is contained in:
Romain Vimont
2021-11-12 23:08:19 +01:00
parent 9a0bd545d5
commit 979ce64dc0
12 changed files with 169 additions and 134 deletions

View File

@@ -19,12 +19,12 @@ sc_file_get_executable_path(void) {
return NULL;
}
buf[len] = '\0';
return utf8_from_wide_char(buf);
return sc_str_from_wchars(buf);
}
bool
sc_file_is_regular(const char *path) {
wchar_t *wide_path = utf8_to_wide_char(path);
wchar_t *wide_path = sc_str_to_wchars(path);
if (!wide_path) {
LOGC("Could not allocate wide char string");
return false;

View File

@@ -13,7 +13,7 @@ build_cmd(char *cmd, size_t len, const char *const argv[]) {
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
// only make it work for this very specific program
// (don't handle escaping nor quotes)
size_t ret = xstrjoin(cmd, argv, ' ', len);
size_t ret = sc_str_join(cmd, argv, ' ', len);
if (ret >= len) {
LOGE("Command too long (%" SC_PRIsizet " chars)", len - 1);
return false;
@@ -88,7 +88,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
goto error_close_stderr;
}
wchar_t *wide = utf8_to_wide_char(cmd);
wchar_t *wide = sc_str_to_wchars(cmd);
free(cmd);
if (!wide) {
LOGC("Could not allocate wide char string");