got patch: switch from fseek() to fseeko(), use unary minus while here ok op
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/lib/patch.c b/lib/patch.c
index d7d7afe..3ed493e 100644
--- a/lib/patch.c
+++ b/lib/patch.c
@@ -296,8 +296,8 @@ copy(FILE *tmp, FILE *orig, off_t copypos, off_t pos)
char buf[BUFSIZ];
size_t len, r, w;
- if (fseek(orig, copypos, SEEK_SET) == -1)
- return got_error_from_errno("fseek");
+ if (fseeko(orig, copypos, SEEK_SET) == -1)
+ return got_error_from_errno("fseeko");
while (pos == -1 || copypos < pos) {
len = sizeof(buf);
@@ -362,8 +362,8 @@ locate_hunk(FILE *orig, struct got_patch_hunk *h, off_t *pos, long *lineno)
if (err == NULL) {
*pos = match;
*lineno = match_lineno;
- if (fseek(orig, match, SEEK_SET) == -1)
- err = got_error_from_errno("fseek");
+ if (fseeko(orig, match, SEEK_SET) == -1)
+ err = got_error_from_errno("fseeko");
}
free(line);
@@ -491,8 +491,8 @@ patch_file(struct got_patch *p, const char *path, FILE *tmp, int nop,
* try to apply the hunk again starting the search
* after the previous partial match.
*/
- if (fseek(orig, pos, SEEK_SET) == -1) {
- err = got_error_from_errno("fseek");
+ if (fseeko(orig, pos, SEEK_SET) == -1) {
+ err = got_error_from_errno("fseeko");
goto done;
}
linelen = getline(&line, &linesize, orig);
diff --git a/libexec/got-read-patch/got-read-patch.c b/libexec/got-read-patch/got-read-patch.c
index 96d9789..0e9106a 100644
--- a/libexec/got-read-patch/got-read-patch.c
+++ b/libexec/got-read-patch/got-read-patch.c
@@ -181,8 +181,8 @@ find_patch(int *done, FILE *fp)
break;
/* rewind to previous line */
- if (fseek(fp, linelen * -1, SEEK_CUR) == -1)
- err = got_error_from_errno("fseek");
+ if (fseeko(fp, -linelen, SEEK_CUR) == -1)
+ err = got_error_from_errno("fseeko");
break;
}
}
@@ -352,8 +352,8 @@ parse_hunk(FILE *fp, int *done)
if (err)
goto done;
if (*done) {
- if (fseek(fp, linelen * -1, SEEK_CUR) == -1)
- err = got_error_from_errno("fseek");
+ if (fseeko(fp, -linelen, SEEK_CUR) == -1)
+ err = got_error_from_errno("fseeko");
goto done;
}