Skip to content

Commit

Permalink
reapply: update to new version 5.42
Browse files Browse the repository at this point in the history
and fix (#2095871)
  • Loading branch information
vmihalko committed Jul 21, 2022
1 parent 874c9f6 commit def8ebf
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .gitignore
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
41 changes: 0 additions & 41 deletions file-5.41-javascript-magic.patch

This file was deleted.

31 changes: 0 additions & 31 deletions file-5.41-json-magic.patch

This file was deleted.

35 changes: 0 additions & 35 deletions file-5.41-json-tests-fix.patch

This file was deleted.

35 changes: 0 additions & 35 deletions file-5.41-json-tests.patch

This file was deleted.

83 changes: 83 additions & 0 deletions file-5.42-fix-stdin-input.patch
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;
}

17 changes: 7 additions & 10 deletions file.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

Summary: Utility for determining file types
Name: file
Version: 5.41
Release: 7%{?dist}
Version: 5.42
Release: 1%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
Source1: http://ftp.astron.com/pub/file/file-%{version}.tar.gz.asc
Expand All @@ -29,14 +29,8 @@ Patch0: file-localmagic.patch
Patch1: file-4.17-rpm-name.patch
Patch2: file-5.04-volume_key.patch

# Upstream commit: https://github.com/file/file/commit/f687fa2b92cd9231
Patch3: file-5.41-javascript-magic.patch
# Upstream commit: https://github.com/file/file/commit/c49e7805fd8aa48b
Patch4: file-5.41-json-magic.patch
# Upstream commit: https://github.com/file/file/commit/3012be8ca1cdee72
Patch5: file-5.41-json-tests.patch
# Upstream commit: https://github.com/file/file/commit/e83f5046ef2d8967
Patch6: file-5.41-json-tests-fix.patch
# Upstream commit: https://github.com/file/file/commit/19bf47777d0002ee884467e45e6ace702e40a4c1
Patch3: file-5.42-fix-stdin-input.patch

URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
Expand Down Expand Up @@ -222,6 +216,9 @@ make -C tests check
%endif

%changelog
* Thu Jul 21 2022 Vincent Mihalkovic <vmihalko@redhat.com> - 5.42-1
- update to new version 5.42

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.41-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

Expand Down
4 changes: 2 additions & 2 deletions sources
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

0 comments on commit def8ebf

Please sign in to comment.