From baca7635a3db27bae911ab6ebe928e5c2cc5a155 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 12 Jan 2021 17:38:30 +0100 Subject: replace float with int math, silence conversions, improve wine call […] improve parser logic and math reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common.c | 3 ++- src/net.c | 2 +- src/tar.c | 3 ++- src/wine.c | 20 ++------------------ 4 files changed, 7 insertions(+), 21 deletions(-) (limited to 'src') 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; diff --git a/src/net.c b/src/net.c index a90533b..b2851db 100644 --- a/src/net.c +++ b/src/net.c @@ -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); diff --git a/src/tar.c b/src/tar.c index 6e90aa5..cbaf875 100644 --- a/src/tar.c +++ b/src/tar.c @@ -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) { diff --git a/src/wine.c b/src/wine.c index d067ca6..1a21eb8 100644 --- a/src/wine.c +++ b/src/wine.c @@ -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 { -- cgit v1.2.3