-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and fix (#2095871)
- Loading branch information
Showing
8 changed files
with
93 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/file-5.*.tar.gz | ||
/file-5.*.tar.gz.asc | ||
/christoskey.asc | ||
/file-5.41.tar.gz.asc |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
From 19bf47777d0002ee884467e45e6ace702e40a4c1 Mon Sep 17 00:00:00 2001 | ||
From: Christos Zoulas <christos@zoulas.com> | ||
Date: Mon, 4 Jul 2022 17:00:51 +0000 | ||
Subject: [PATCH] PR/358: Fix width for -f - (jpalus) | ||
|
||
--- | ||
diff --git a/src/file.c b/src/file.c | ||
index 5300e5af8..bb058ce1e 100644 | ||
--- a/src/file.c | ||
+++ b/src/file.c | ||
@@ -32,7 +32,7 @@ | ||
#include "file.h" | ||
|
||
#ifndef lint | ||
-FILE_RCSID("@(#)$File: file.c,v 1.195 2022/06/02 15:45:43 christos Exp $") | ||
+FILE_RCSID("@(#)$File: file.c,v 1.196 2022/07/04 17:00:51 christos Exp $") | ||
#endif /* lint */ | ||
|
||
#include "magic.h" | ||
@@ -506,35 +506,47 @@ unwrap(struct magic_set *ms, const char *fn) | ||
size_t llen = 0; | ||
int wid = 0, cwid; | ||
int e = 0; | ||
+ size_t fi = 0, fimax = 100; | ||
+ char **flist = malloc(sizeof(*flist) * fimax); | ||
|
||
- if (strcmp("-", fn) == 0) { | ||
+ if (flist == NULL) | ||
+out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list"); | ||
+ | ||
+ if (strcmp("-", fn) == 0) | ||
f = stdin; | ||
- wid = 1; | ||
- } else { | ||
+ else { | ||
if ((f = fopen(fn, "r")) == NULL) { | ||
file_warn("Cannot open `%s'", fn); | ||
return 1; | ||
} | ||
- | ||
- while ((len = getline(&line, &llen, f)) > 0) { | ||
- if (line[len - 1] == '\n') | ||
- line[len - 1] = '\0'; | ||
- cwid = file_mbswidth(ms, line); | ||
- if (cwid > wid) | ||
- wid = cwid; | ||
- } | ||
- | ||
- rewind(f); | ||
} | ||
|
||
while ((len = getline(&line, &llen, f)) > 0) { | ||
if (line[len - 1] == '\n') | ||
line[len - 1] = '\0'; | ||
- e |= process(ms, line, wid); | ||
+ if (fi >= fimax) { | ||
+ fimax += 100; | ||
+ char **nf = realloc(flist, fimax * sizeof(*flist)); | ||
+ if (nf == NULL) | ||
+ goto out; | ||
+ } | ||
+ flist[fi++] = line; | ||
+ cwid = file_mbswidth(ms, line); | ||
+ if (cwid > wid) | ||
+ wid = cwid; | ||
+ line = NULL; | ||
+ llen = 0; | ||
+ } | ||
+ | ||
+ fimax = fi; | ||
+ for (fi = 0; fi < fimax; fi++) { | ||
+ e |= process(ms, flist[fi], wid); | ||
+ free(flist[fi]); | ||
} | ||
+ free(flist); | ||
|
||
- free(line); | ||
- (void)fclose(f); | ||
+ if (f != stdin) | ||
+ (void)fclose(f); | ||
return e; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
SHA512 (file-5.42.tar.gz) = 33c3c339a561c6cf787cc06a16444a971c62068b01827612c948207a9714107b617bed8148cd67e6280cb1c62ad4dfb1205fb8486ea9c042ce7e19b067d3bb05 | ||
SHA512 (file-5.42.tar.gz.asc) = a7105c48f6c671638f5fb7f18f9b193d108456655b4c734208e00aca36fab54dd330ec2fdc3ff29fb78adbc16874af4fb0916c560e50228f82003a8cd258491a | ||
SHA512 (christoskey.asc) = 952323eb3c0cd3ae1b6c059e301b176fd60b61c76789b96c800a995253bd8dd88182617a2358fbe09b9571cd642fd4098dd0d91152a6347669324d79b12f94ee | ||
SHA512 (file-5.41.tar.gz.asc) = fc342ed92efde3f0400f61acd35d8f2d793788f3a2b8a53fbe9255dc04a036fa16b33294c184630b62471d825d5304a5c6580fcde654eea01b02e57dfbd50632 | ||
SHA512 (file-5.41.tar.gz) = bbf2d8e39450b31d0ba8d76d202790fea953775657f942f06e6dc9091798d4a395f7205e542388e4a25b6a4506d07f36c5c4da37cfce0734133e9203a3b00654 |