diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-01-12 17:38:30 +0100 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-01-12 17:38:30 +0100 |
commit | baca7635a3db27bae911ab6ebe928e5c2cc5a155 (patch) | |
tree | e9bde5656d208cd03f954a624aa564b195617220 /src | |
parent | dad8f3b9ecf5794f1b3c539878f91ee106d28448 (diff) | |
download | polecat-baca7635a3db27bae911ab6ebe928e5c2cc5a155.tar.gz polecat-baca7635a3db27bae911ab6ebe928e5c2cc5a155.zip |
replace float with int math, silence conversions, improve wine call […]
improve parser logic and math reuse
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 3 | ||||
-rw-r--r-- | src/net.c | 2 | ||||
-rw-r--r-- | src/tar.c | 3 | ||||
-rw-r--r-- | src/wine.c | 20 |
4 files changed, 7 insertions, 21 deletions
diff --git a/src/common.c b/src/common.c index 29aa3db..151e3a7 100644 --- a/src/common.c +++ b/src/common.c @@ -80,7 +80,8 @@ int makeDir(const char* path) return mkdir(path, 0755); } -int removeDir(const char *path) { +int removeDir(const char *path) +{ DIR *d = opendir(path); size_t path_len = strlen(path); int r = -1; @@ -34,7 +34,7 @@ static int xferinfo(UNUSED void *p, curl_off_t dltotal, curl_off_t dlnow, UNUSED { curl_off_t progress = 0; if (dltotal != 0) - progress = ((float)dlnow / dltotal) * 100; + progress = (dlnow * 100) / dltotal; fprintf(stderr, "\rProgress: %3" CURL_FORMAT_CURL_OFF_T "%%", progress); @@ -22,7 +22,8 @@ static int copy_data(struct archive* ar, struct archive* aw) if (r == ARCHIVE_EOF) return (ARCHIVE_OK); if (r < ARCHIVE_OK) return (r); - r = archive_write_data_block(aw, buff, size, offset); + // why does read return an int but write not? + r = (int)archive_write_data_block(aw, buff, size, offset); if (r < ARCHIVE_OK) { @@ -233,24 +233,8 @@ COMMAND(wine, run) if (isFile(winepath)) { - // quote the winepath so whitespace won't cause trouble - { - char winepathcpy[PATH_MAX] = {0}; - strncat(winepathcpy, "\"", sizeof(winepathcpy) - strlen(winepathcpy) - 1); - strncat(winepathcpy, winepath, sizeof(winepathcpy) - strlen(winepathcpy) - 1); - strncat(winepathcpy, "\"", sizeof(winepathcpy) - strlen(winepathcpy) - 1); - strncpy(winepath, winepathcpy, sizeof(winepathcpy)); - } - - for (int i = 2; i < argc; ++i) - { - // make sure the passed arguments are in quotes so spaces don't cause problems - strncat(winepath, " \"", sizeof(winepath) - strlen(winepath) - 1); - strncat(winepath, argv[i], sizeof(winepath) - strlen(winepath) - 1); - strncat(winepath, "\"", sizeof(winepath) - strlen(winepath) - 1); - } - - return system(winepath); + argv[1] = winepath; + return execvp(winepath, argv+1); } else { |