aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-01-12 17:38:30 +0100
committerJan200101 <sentrycraft123@gmail.com>2021-01-12 17:38:30 +0100
commitbaca7635a3db27bae911ab6ebe928e5c2cc5a155 (patch)
treee9bde5656d208cd03f954a624aa564b195617220 /src
parentdad8f3b9ecf5794f1b3c539878f91ee106d28448 (diff)
downloadpolecat-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.c3
-rw-r--r--src/net.c2
-rw-r--r--src/tar.c3
-rw-r--r--src/wine.c20
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;
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
{