.
OBS-URL: https://build.opensuse.org/package/show/Base:System/file?expand=0&rev=230
This commit is contained in:
parent
80e2bcab7a
commit
a9dfab85e6
@ -1,168 +1,181 @@
|
|||||||
---
|
From f67fe8bb658fbc19df76128e1012580cf135da78 Mon Sep 17 00:00:00 2001
|
||||||
src/apprentice.c | 71 ++++---------------------------------------------------
|
From: Christos Zoulas <christos@zoulas.com>
|
||||||
src/cdf.c | 53 +++--------------------------------------
|
Date: Wed, 20 Oct 2021 13:56:15 +0000
|
||||||
2 files changed, 10 insertions(+), 114 deletions(-)
|
Subject: [PATCH] Use the system byte swapping functions if available (Werner
|
||||||
|
Fink)
|
||||||
|
|
||||||
|
---
|
||||||
|
ChangeLog | 4 ++++
|
||||||
|
configure.ac | 4 ++--
|
||||||
|
src/apprentice.c | 28 ++++++++++++++++++++++++----
|
||||||
|
src/cdf.c | 18 +++++++++++++++++-
|
||||||
|
4 files changed, 47 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git ChangeLog ChangeLog
|
||||||
|
index 0bb334c9..0be9711b 100644
|
||||||
|
--- ChangeLog
|
||||||
|
+++ ChangeLog
|
||||||
|
@@ -1,3 +1,7 @@
|
||||||
|
+2021-10-20 9:55 Christos Zoulas <christos@zoulas.com>
|
||||||
|
+
|
||||||
|
+ * use the system byte swapping functions if available (Werner Fink)
|
||||||
|
+
|
||||||
|
2021-10-18 11:57 Christos Zoulas <christos@zoulas.com>
|
||||||
|
|
||||||
|
* release 5.41
|
||||||
|
diff --git configure.ac configure.ac
|
||||||
|
index ccc57e13..528bb40d 100644
|
||||||
|
--- configure.ac
|
||||||
|
+++ configure.ac
|
||||||
|
@@ -99,10 +99,10 @@ gl_VISIBILITY
|
||||||
|
dnl Checks for headers
|
||||||
|
AC_HEADER_MAJOR
|
||||||
|
AC_HEADER_SYS_WAIT
|
||||||
|
-AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h)
|
||||||
|
+AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h)
|
||||||
|
AC_CHECK_HEADERS(utime.h wchar.h wctype.h)
|
||||||
|
AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
|
||||||
|
-AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h)
|
||||||
|
+AC_CHECK_HEADERS(sys/bswap.h sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h)
|
||||||
|
if test "$enable_zlib" != "no"; then
|
||||||
|
AC_CHECK_HEADERS(zlib.h)
|
||||||
|
fi
|
||||||
|
diff --git src/apprentice.c src/apprentice.c
|
||||||
|
index eb3b4a59..8f51b922 100644
|
||||||
--- src/apprentice.c
|
--- src/apprentice.c
|
||||||
+++ src/apprentice.c 2021-10-19 08:56:33.418646912 +0000
|
+++ src/apprentice.c
|
||||||
@@ -50,7 +50,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.
|
@@ -32,7 +32,7 @@
|
||||||
|
#include "file.h"
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
-FILE_RCSID("@(#)$File: apprentice.c,v 1.309 2021/09/24 13:59:19 christos Exp $")
|
||||||
|
+FILE_RCSID("@(#)$File: apprentice.c,v 1.310 2021/10/20 13:56:15 christos Exp $")
|
||||||
|
#endif /* lint */
|
||||||
|
|
||||||
|
#include "magic.h"
|
||||||
|
@@ -50,6 +50,12 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.309 2021/09/24 13:59:19 christos Exp $")
|
||||||
#endif
|
#endif
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
-
|
+#ifdef HAVE_BYTESWAP_H
|
||||||
+#include <byteswap.h>
|
+#include <byteswap.h>
|
||||||
|
+#endif
|
||||||
|
+#ifdef HAVE_SYS_BSWAP_H
|
||||||
|
+#include <sys/bswap.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
|
||||||
#define EATAB {while (isascii(CAST(unsigned char, *l)) && \
|
#define EATAB {while (isascii(CAST(unsigned char, *l)) && \
|
||||||
isspace(CAST(unsigned char, *l))) ++l;}
|
@@ -124,9 +130,21 @@ private void mlist_free_all(struct magic_set *);
|
||||||
@@ -124,9 +124,11 @@ private void mlist_free_all(struct magic
|
|
||||||
private void mlist_free(struct mlist *);
|
private void mlist_free(struct mlist *);
|
||||||
private void byteswap(struct magic *, uint32_t);
|
private void byteswap(struct magic *, uint32_t);
|
||||||
private void bs1(struct magic *);
|
private void bs1(struct magic *);
|
||||||
-private uint16_t swap2(uint16_t);
|
|
||||||
-private uint32_t swap4(uint32_t);
|
|
||||||
-private uint64_t swap8(uint64_t);
|
|
||||||
+
|
+
|
||||||
|
+#if defined(HAVE_BYTESWAP_H)
|
||||||
+#define swap2(x) bswap_16(x)
|
+#define swap2(x) bswap_16(x)
|
||||||
+#define swap4(x) bswap_32(x)
|
+#define swap4(x) bswap_32(x)
|
||||||
+#define swap8(x) bswap_64(x)
|
+#define swap8(x) bswap_64(x)
|
||||||
|
+#elif defined(HAVE_SYS_BSWAP_H)
|
||||||
|
+#define swap2(x) bswap16(x)
|
||||||
|
+#define swap4(x) bswap32(x)
|
||||||
|
+#define swap8(x) bswap64(x)
|
||||||
|
+#else
|
||||||
|
private uint16_t swap2(uint16_t);
|
||||||
|
private uint32_t swap4(uint32_t);
|
||||||
|
private uint64_t swap8(uint64_t);
|
||||||
|
+#endif
|
||||||
+
|
+
|
||||||
private char *mkdbname(struct magic_set *, const char *, int);
|
private char *mkdbname(struct magic_set *, const char *, int);
|
||||||
private struct magic_map *apprentice_buf(struct magic_set *, struct magic *,
|
private struct magic_map *apprentice_buf(struct magic_set *, struct magic *,
|
||||||
size_t);
|
size_t);
|
||||||
@@ -3355,67 +3357,6 @@ byteswap(struct magic *magic, uint32_t n
|
@@ -3355,6 +3373,7 @@ byteswap(struct magic *magic, uint32_t nmagic)
|
||||||
bs1(&magic[i]);
|
bs1(&magic[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
-/*
|
+#if !defined(HAVE_BYTESWAP_H) && !defined(HAVE_SYS_BSWAP_H)
|
||||||
- * swap a short
|
/*
|
||||||
- */
|
* swap a short
|
||||||
-private uint16_t
|
*/
|
||||||
-swap2(uint16_t sv)
|
@@ -3394,7 +3413,7 @@ swap8(uint64_t sv)
|
||||||
-{
|
uint64_t rv;
|
||||||
- uint16_t rv;
|
uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
|
||||||
- d[0] = s[1];
|
|
||||||
- d[1] = s[0];
|
|
||||||
- return rv;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * swap an int
|
|
||||||
- */
|
|
||||||
-private uint32_t
|
|
||||||
-swap4(uint32_t sv)
|
|
||||||
-{
|
|
||||||
- uint32_t rv;
|
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
|
||||||
- d[0] = s[3];
|
|
||||||
- d[1] = s[2];
|
|
||||||
- d[2] = s[1];
|
|
||||||
- d[3] = s[0];
|
|
||||||
- return rv;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * swap a quad
|
|
||||||
- */
|
|
||||||
-private uint64_t
|
|
||||||
-swap8(uint64_t sv)
|
|
||||||
-{
|
|
||||||
- uint64_t rv;
|
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
|
||||||
-#if 0
|
-#if 0
|
||||||
- d[0] = s[3];
|
+# if 0
|
||||||
- d[1] = s[2];
|
d[0] = s[3];
|
||||||
- d[2] = s[1];
|
d[1] = s[2];
|
||||||
- d[3] = s[0];
|
d[2] = s[1];
|
||||||
- d[4] = s[7];
|
@@ -3403,7 +3422,7 @@ swap8(uint64_t sv)
|
||||||
- d[5] = s[6];
|
d[5] = s[6];
|
||||||
- d[6] = s[5];
|
d[6] = s[5];
|
||||||
- d[7] = s[4];
|
d[7] = s[4];
|
||||||
-#else
|
-#else
|
||||||
- d[0] = s[7];
|
+# else
|
||||||
- d[1] = s[6];
|
d[0] = s[7];
|
||||||
- d[2] = s[5];
|
d[1] = s[6];
|
||||||
- d[3] = s[4];
|
d[2] = s[5];
|
||||||
- d[4] = s[3];
|
@@ -3412,9 +3431,10 @@ swap8(uint64_t sv)
|
||||||
- d[5] = s[2];
|
d[5] = s[2];
|
||||||
- d[6] = s[1];
|
d[6] = s[1];
|
||||||
- d[7] = s[0];
|
d[7] = s[0];
|
||||||
-#endif
|
-#endif
|
||||||
- return rv;
|
+# endif
|
||||||
-}
|
return rv;
|
||||||
-
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
protected uintmax_t
|
protected uintmax_t
|
||||||
file_varint2uintmax_t(const unsigned char *us, int t, size_t *l)
|
file_varint2uintmax_t(const unsigned char *us, int t, size_t *l)
|
||||||
{
|
diff --git src/cdf.c src/cdf.c
|
||||||
|
index b5ad2f6a..874a6ed3 100644
|
||||||
--- src/cdf.c
|
--- src/cdf.c
|
||||||
+++ src/cdf.c 2021-10-19 08:53:37.577690786 +0000
|
+++ src/cdf.c
|
||||||
@@ -48,6 +48,7 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.120 202
|
@@ -35,7 +35,7 @@
|
||||||
|
#include "file.h"
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
-FILE_RCSID("@(#)$File: cdf.c,v 1.120 2021/09/24 13:59:19 christos Exp $")
|
||||||
|
+FILE_RCSID("@(#)$File: cdf.c,v 1.121 2021/10/20 13:56:15 christos Exp $")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
@@ -48,6 +48,12 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.120 2021/09/24 13:59:19 christos Exp $")
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
+#ifdef HAVE_BYTESWAP_H
|
||||||
+#include <byteswap.h>
|
+#include <byteswap.h>
|
||||||
|
+#endif
|
||||||
|
+#ifdef HAVE_SYS_BSWAP_H
|
||||||
|
+#include <sys/bswap.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
#ifndef EFTYPE
|
#ifndef EFTYPE
|
||||||
#define EFTYPE EINVAL
|
#define EFTYPE EINVAL
|
||||||
@@ -124,55 +125,9 @@ cdf_calloc(const char *file __attribute_
|
@@ -124,6 +130,15 @@ cdf_calloc(const char *file __attribute__((__unused__)),
|
||||||
return calloc(n, u);
|
return calloc(n, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
-/*
|
+#if defined(HAVE_BYTESWAP_H)
|
||||||
- * swap a short
|
+# define _cdf_tole2(x) bswap_16(x)
|
||||||
- */
|
+# define _cdf_tole4(x) bswap_32(x)
|
||||||
-static uint16_t
|
+# define _cdf_tole8(x) bswap_64(x)
|
||||||
-_cdf_tole2(uint16_t sv)
|
+#elif defined(HAVE_SYS_BSWAP_H)
|
||||||
-{
|
+# define _cdf_tole2(x) bswap16(x)
|
||||||
- uint16_t rv;
|
+# define _cdf_tole4(x) bswap32(x)
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
+# define _cdf_tole8(x) bswap64(x)
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
+#else
|
||||||
- d[0] = s[1];
|
/*
|
||||||
- d[1] = s[0];
|
* swap a short
|
||||||
- return rv;
|
*/
|
||||||
-}
|
@@ -173,6 +188,7 @@ _cdf_tole8(uint64_t sv)
|
||||||
-
|
d[7] = s[0];
|
||||||
-/*
|
return rv;
|
||||||
- * swap an int
|
}
|
||||||
- */
|
+#endif
|
||||||
-static uint32_t
|
|
||||||
-_cdf_tole4(uint32_t sv)
|
|
||||||
-{
|
|
||||||
- uint32_t rv;
|
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
|
||||||
- d[0] = s[3];
|
|
||||||
- d[1] = s[2];
|
|
||||||
- d[2] = s[1];
|
|
||||||
- d[3] = s[0];
|
|
||||||
- return rv;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * swap a quad
|
|
||||||
- */
|
|
||||||
-static uint64_t
|
|
||||||
-_cdf_tole8(uint64_t sv)
|
|
||||||
-{
|
|
||||||
- uint64_t rv;
|
|
||||||
- uint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));
|
|
||||||
- uint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));
|
|
||||||
- d[0] = s[7];
|
|
||||||
- d[1] = s[6];
|
|
||||||
- d[2] = s[5];
|
|
||||||
- d[3] = s[4];
|
|
||||||
- d[4] = s[3];
|
|
||||||
- d[5] = s[2];
|
|
||||||
- d[6] = s[1];
|
|
||||||
- d[7] = s[0];
|
|
||||||
- return rv;
|
|
||||||
-}
|
|
||||||
+#define _cdf_tole2(x) bswap_16(x)
|
|
||||||
+#define _cdf_tole4(x) bswap_32(x)
|
|
||||||
+#define _cdf_tole8(x) bswap_64(x)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* grab a uint32_t from a possibly unaligned address, and return it in
|
* grab a uint32_t from a possibly unaligned address, and return it in
|
||||||
|
--
|
||||||
|
2.26.2
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Oct 21 08:33:48 UTC 2021 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
|
- Now file-5.23-endian.patch is at upstream git repository, use it
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Oct 21 06:24:35 UTC 2021 - Dr. Werner Fink <werner@suse.de>
|
Thu Oct 21 06:24:35 UTC 2021 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
- Remove file-5.38-allow-readlinkat.dif as already doen in latest
|
- Remove file-5.38-allow-readlinkat.dif as already done in latest
|
||||||
file 5.41
|
file 5.41
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user