Browse Source

Import upstream version 5.32

Christos Zoulas 6 years ago
parent
commit
20bf0442ee

+ 25 - 1
ChangeLog

@@ -1,3 +1,27 @@
+2017-09-02  11:53  Christos Zoulas <christos@zoulas.com>
+
+	* release 5.32
+
+2017-08-28  16:37  Christos Zoulas <christos@zoulas.com>
+
+	* Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski)
+
+2017-08-27  03:55  Christos Zoulas <christos@zoulas.com>
+
+	* Fix always true condition (Thomas Jarosch)
+
+2017-05-24  17:30  Christos Zoulas <christos@zoulas.com>
+
+	* pickier parsing of numeric values in magic files.
+
+2017-05-23  17:55  Christos Zoulas <christos@zoulas.com>
+
+	* PR/615 add magic_getflags()
+
+2017-05-23  13:55  Christos Zoulas <christos@zoulas.com>
+
+	* release 5.31
+
 2017-03-17  20:32  Christos Zoulas <christos@zoulas.com>
 2017-03-17  20:32  Christos Zoulas <christos@zoulas.com>
 
 
 	* remove trailing spaces from magic files
 	* remove trailing spaces from magic files
@@ -417,7 +441,7 @@
 		`
 		`
 2013-11-06  14:40  Christos Zoulas <christos@zoulas.com>
 2013-11-06  14:40  Christos Zoulas <christos@zoulas.com>
 
 
-	* fix erroneous non-zero exit code from non-existant file and message
+	* fix erroneous non-zero exit code from non-existent file and message
 
 
 2013-10-29  14:25  Christos Zoulas <christos@zoulas.com>
 2013-10-29  14:25  Christos Zoulas <christos@zoulas.com>
 
 

+ 84 - 60
config.guess

@@ -1,8 +1,8 @@
 #! /bin/sh
 #! /bin/sh
 # Attempt to guess a canonical system name.
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2017 Free Software Foundation, Inc.
 
 
-timestamp='2015-03-04'
+timestamp='2017-01-01'
 
 
 # This file is free software; you can redistribute it and/or modify it
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ timestamp='2015-03-04'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 #
 # You can get the latest version of this script from:
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 #
 #
 # Please send patches to <config-patches@gnu.org>.
 # Please send patches to <config-patches@gnu.org>.
 
 
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 GNU config.guess ($timestamp)
 
 
 Originally written by Per Bothner.
 Originally written by Per Bothner.
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2017 Free Software Foundation, Inc.
 
 
 This is free software; see the source for copying conditions.  There is NO
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	esac
 	# The Operating System including object format, if it has switched
 	# The Operating System including object format, if it has switched
-	# to ELF recently, or will in the future.
+	# to ELF recently (or will in the future) and ABI.
 	case "${UNAME_MACHINE_ARCH}" in
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    earm*)
+		os=netbsdelf
+		;;
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
 			| grep -q __ELF__
@@ -221,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		release='-gnu'
 		release='-gnu'
 		;;
 		;;
 	    *)
 	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
 		;;
 		;;
 	esac
 	esac
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
@@ -237,6 +240,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
 	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
 	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
 	exit ;;
 	exit ;;
+    *:LibertyBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE}
+	exit ;;
     *:ekkoBSD:*:*)
     *:ekkoBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
 	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
 	exit ;;
 	exit ;;
@@ -249,6 +256,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:MirBSD:*:*)
     *:MirBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
 	exit ;;
+    *:Sortix:*:*)
+	echo ${UNAME_MACHINE}-unknown-sortix
+	exit ;;
     alpha:OSF1:*:*)
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	case $UNAME_RELEASE in
 	*4.0)
 	*4.0)
@@ -265,42 +275,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
 	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
 	case "$ALPHA_CPU_TYPE" in
 	case "$ALPHA_CPU_TYPE" in
 	    "EV4 (21064)")
 	    "EV4 (21064)")
-		UNAME_MACHINE="alpha" ;;
+		UNAME_MACHINE=alpha ;;
 	    "EV4.5 (21064)")
 	    "EV4.5 (21064)")
-		UNAME_MACHINE="alpha" ;;
+		UNAME_MACHINE=alpha ;;
 	    "LCA4 (21066/21068)")
 	    "LCA4 (21066/21068)")
-		UNAME_MACHINE="alpha" ;;
+		UNAME_MACHINE=alpha ;;
 	    "EV5 (21164)")
 	    "EV5 (21164)")
-		UNAME_MACHINE="alphaev5" ;;
+		UNAME_MACHINE=alphaev5 ;;
 	    "EV5.6 (21164A)")
 	    "EV5.6 (21164A)")
-		UNAME_MACHINE="alphaev56" ;;
+		UNAME_MACHINE=alphaev56 ;;
 	    "EV5.6 (21164PC)")
 	    "EV5.6 (21164PC)")
-		UNAME_MACHINE="alphapca56" ;;
+		UNAME_MACHINE=alphapca56 ;;
 	    "EV5.7 (21164PC)")
 	    "EV5.7 (21164PC)")
-		UNAME_MACHINE="alphapca57" ;;
+		UNAME_MACHINE=alphapca57 ;;
 	    "EV6 (21264)")
 	    "EV6 (21264)")
-		UNAME_MACHINE="alphaev6" ;;
+		UNAME_MACHINE=alphaev6 ;;
 	    "EV6.7 (21264A)")
 	    "EV6.7 (21264A)")
-		UNAME_MACHINE="alphaev67" ;;
+		UNAME_MACHINE=alphaev67 ;;
 	    "EV6.8CB (21264C)")
 	    "EV6.8CB (21264C)")
-		UNAME_MACHINE="alphaev68" ;;
+		UNAME_MACHINE=alphaev68 ;;
 	    "EV6.8AL (21264B)")
 	    "EV6.8AL (21264B)")
-		UNAME_MACHINE="alphaev68" ;;
+		UNAME_MACHINE=alphaev68 ;;
 	    "EV6.8CX (21264D)")
 	    "EV6.8CX (21264D)")
-		UNAME_MACHINE="alphaev68" ;;
+		UNAME_MACHINE=alphaev68 ;;
 	    "EV6.9A (21264/EV69A)")
 	    "EV6.9A (21264/EV69A)")
-		UNAME_MACHINE="alphaev69" ;;
+		UNAME_MACHINE=alphaev69 ;;
 	    "EV7 (21364)")
 	    "EV7 (21364)")
-		UNAME_MACHINE="alphaev7" ;;
+		UNAME_MACHINE=alphaev7 ;;
 	    "EV7.9 (21364A)")
 	    "EV7.9 (21364A)")
-		UNAME_MACHINE="alphaev79" ;;
+		UNAME_MACHINE=alphaev79 ;;
 	esac
 	esac
 	# A Pn.n version is a patched version.
 	# A Pn.n version is a patched version.
 	# A Vn.n version is a released version.
 	# A Vn.n version is a released version.
 	# A Tn.n version is a released field test version.
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	# 1.2 uses "1.2" for uname -r.
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
 	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
 	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
 	exitcode=$?
 	exitcode=$?
 	trap '' 0
 	trap '' 0
@@ -373,16 +383,16 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	exit ;;
 	exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	eval $set_cc_for_build
 	eval $set_cc_for_build
-	SUN_ARCH="i386"
+	SUN_ARCH=i386
 	# If there is a compiler, see if it is configured for 64-bit objects.
 	# If there is a compiler, see if it is configured for 64-bit objects.
 	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
 	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
 	# This test works for both compilers.
 	# This test works for both compilers.
-	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
 	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
 	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
 		grep IS_64BIT_ARCH >/dev/null
 		grep IS_64BIT_ARCH >/dev/null
 	    then
 	    then
-		SUN_ARCH="x86_64"
+		SUN_ARCH=x86_64
 	    fi
 	    fi
 	fi
 	fi
 	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
@@ -407,7 +417,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	exit ;;
 	exit ;;
     sun*:*:4.2BSD:*)
     sun*:*:4.2BSD:*)
 	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
 	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3
 	case "`/bin/arch`" in
 	case "`/bin/arch`" in
 	    sun3)
 	    sun3)
 		echo m68k-sun-sunos${UNAME_RELEASE}
 		echo m68k-sun-sunos${UNAME_RELEASE}
@@ -632,13 +642,13 @@ EOF
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
 		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
 		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
 		    case "${sc_cpu_version}" in
 		    case "${sc_cpu_version}" in
-		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
+		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
 		      532)                      # CPU_PA_RISC2_0
 		      532)                      # CPU_PA_RISC2_0
 			case "${sc_kernel_bits}" in
 			case "${sc_kernel_bits}" in
-			  32) HP_ARCH="hppa2.0n" ;;
-			  64) HP_ARCH="hppa2.0w" ;;
-			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+			  32) HP_ARCH=hppa2.0n ;;
+			  64) HP_ARCH=hppa2.0w ;;
+			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
 			esac ;;
 			esac ;;
 		    esac
 		    esac
 		fi
 		fi
@@ -677,11 +687,11 @@ EOF
 		    exit (0);
 		    exit (0);
 		}
 		}
 EOF
 EOF
-		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
 		fi ;;
 		fi ;;
 	esac
 	esac
-	if [ ${HP_ARCH} = "hppa2.0w" ]
+	if [ ${HP_ARCH} = hppa2.0w ]
 	then
 	then
 	    eval $set_cc_for_build
 	    eval $set_cc_for_build
 
 
@@ -694,12 +704,12 @@ EOF
 	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
 	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
 	    # => hppa64-hp-hpux11.23
 	    # => hppa64-hp-hpux11.23
 
 
-	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
 		grep -q __LP64__
 		grep -q __LP64__
 	    then
 	    then
-		HP_ARCH="hppa2.0w"
+		HP_ARCH=hppa2.0w
 	    else
 	    else
-		HP_ARCH="hppa64"
+		HP_ARCH=hppa64
 	    fi
 	    fi
 	fi
 	fi
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
@@ -804,14 +814,14 @@ EOF
 	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit ;;
 	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
 	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
 	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
 	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
 	exit ;;
     5000:UNIX_System_V:4.*:*)
     5000:UNIX_System_V:4.*:*)
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
 	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
 	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
@@ -893,7 +903,7 @@ EOF
 	exit ;;
 	exit ;;
     *:GNU/*:*:*)
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
 	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
 	exit ;;
 	exit ;;
     i*86:Minix:*:*)
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	echo ${UNAME_MACHINE}-pc-minix
@@ -916,7 +926,7 @@ EOF
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
 	esac
 	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
 	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
 	exit ;;
     arc:Linux:*:* | arceb:Linux:*:*)
     arc:Linux:*:* | arceb:Linux:*:*)
@@ -962,6 +972,9 @@ EOF
     ia64:Linux:*:*)
     ia64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
 	exit ;;
+    k1om:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     m32r*:Linux:*:*)
     m32r*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
 	exit ;;
@@ -987,6 +1000,9 @@ EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
 	;;
+    mips64el:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     openrisc*:Linux:*:*)
     openrisc*:Linux:*:*)
 	echo or1k-unknown-linux-${LIBC}
 	echo or1k-unknown-linux-${LIBC}
 	exit ;;
 	exit ;;
@@ -1019,6 +1035,9 @@ EOF
     ppcle:Linux:*:*)
     ppcle:Linux:*:*)
 	echo powerpcle-unknown-linux-${LIBC}
 	echo powerpcle-unknown-linux-${LIBC}
 	exit ;;
 	exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
     s390:Linux:*:* | s390x:Linux:*:*)
 	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
 	exit ;;
@@ -1038,7 +1057,7 @@ EOF
 	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
 	exit ;;
     x86_64:Linux:*:*)
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
 	exit ;;
     xtensa*:Linux:*:*)
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1117,7 +1136,7 @@ EOF
 	# uname -m prints for DJGPP always 'pc', but it prints nothing about
 	# uname -m prints for DJGPP always 'pc', but it prints nothing about
 	# the processor, so we play safe by assuming i586.
 	# the processor, so we play safe by assuming i586.
 	# Note: whatever this is, it MUST be the same as what config.sub
 	# Note: whatever this is, it MUST be the same as what config.sub
-	# prints for the "djgpp" host, or else GDB configury will decide that
+	# prints for the "djgpp" host, or else GDB configure will decide that
 	# this is a cross-build.
 	# this is a cross-build.
 	echo i586-pc-msdosdjgpp
 	echo i586-pc-msdosdjgpp
 	exit ;;
 	exit ;;
@@ -1266,6 +1285,9 @@ EOF
     SX-8R:SUPER-UX:*:*)
     SX-8R:SUPER-UX:*:*)
 	echo sx8r-nec-superux${UNAME_RELEASE}
 	echo sx8r-nec-superux${UNAME_RELEASE}
 	exit ;;
 	exit ;;
+    SX-ACE:SUPER-UX:*:*)
+	echo sxace-nec-superux${UNAME_RELEASE}
+	exit ;;
     Power*:Rhapsody:*:*)
     Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	exit ;;
 	exit ;;
@@ -1279,9 +1301,9 @@ EOF
 	    UNAME_PROCESSOR=powerpc
 	    UNAME_PROCESSOR=powerpc
 	fi
 	fi
 	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
 	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
-	    if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
 		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
 		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		    (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		    (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
 		    grep IS_64BIT_ARCH >/dev/null
 		    grep IS_64BIT_ARCH >/dev/null
 		then
 		then
 		    case $UNAME_PROCESSOR in
 		    case $UNAME_PROCESSOR in
@@ -1303,7 +1325,7 @@ EOF
 	exit ;;
 	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
 	UNAME_PROCESSOR=`uname -p`
 	UNAME_PROCESSOR=`uname -p`
-	if test "$UNAME_PROCESSOR" = "x86"; then
+	if test "$UNAME_PROCESSOR" = x86; then
 		UNAME_PROCESSOR=i386
 		UNAME_PROCESSOR=i386
 		UNAME_MACHINE=pc
 		UNAME_MACHINE=pc
 	fi
 	fi
@@ -1334,7 +1356,7 @@ EOF
 	# "uname -m" is not consistent, so use $cputype instead. 386
 	# "uname -m" is not consistent, so use $cputype instead. 386
 	# is converted to i386 for consistency with other x86
 	# is converted to i386 for consistency with other x86
 	# operating systems.
 	# operating systems.
-	if test "$cputype" = "386"; then
+	if test "$cputype" = 386; then
 	    UNAME_MACHINE=i386
 	    UNAME_MACHINE=i386
 	else
 	else
 	    UNAME_MACHINE="$cputype"
 	    UNAME_MACHINE="$cputype"
@@ -1376,7 +1398,7 @@ EOF
 	echo i386-pc-xenix
 	echo i386-pc-xenix
 	exit ;;
 	exit ;;
     i*86:skyos:*:*)
     i*86:skyos:*:*)
-	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'`
 	exit ;;
 	exit ;;
     i*86:rdos:*:*)
     i*86:rdos:*:*)
 	echo ${UNAME_MACHINE}-pc-rdos
 	echo ${UNAME_MACHINE}-pc-rdos
@@ -1387,23 +1409,25 @@ EOF
     x86_64:VMkernel:*:*)
     x86_64:VMkernel:*:*)
 	echo ${UNAME_MACHINE}-unknown-esx
 	echo ${UNAME_MACHINE}-unknown-esx
 	exit ;;
 	exit ;;
+    amd64:Isilon\ OneFS:*:*)
+	echo x86_64-unknown-onefs
+	exit ;;
 esac
 esac
 
 
 cat >&2 <<EOF
 cat >&2 <<EOF
 $0: unable to guess system type
 $0: unable to guess system type
 
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite
+config.guess and config.sub with the latest versions from:
 
 
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
 and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
 
 
 config.guess timestamp = $timestamp
 config.guess timestamp = $timestamp
 
 

+ 35 - 17
config.sub

@@ -1,8 +1,8 @@
 #! /bin/sh
 #! /bin/sh
 # Configuration validation subroutine script.
 # Configuration validation subroutine script.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2017 Free Software Foundation, Inc.
 
 
-timestamp='2015-03-08'
+timestamp='2017-01-01'
 
 
 # This file is free software; you can redistribute it and/or modify it
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ timestamp='2015-03-08'
 # Otherwise, we print the canonical config type on stdout and succeed.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 
 # You can get the latest version of this script from:
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 
 # This file is supposed to be the same for all GNU packages
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
 # and recognize all the CPU types, system types and aliases
@@ -53,8 +53,7 @@ timestamp='2015-03-08'
 me=`echo "$0" | sed -e 's,.*/,,'`
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 
 usage="\
 usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
 
 
 Canonicalize a configuration name.
 Canonicalize a configuration name.
 
 
@@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 version="\
 GNU config.sub ($timestamp)
 GNU config.sub ($timestamp)
 
 
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2017 Free Software Foundation, Inc.
 
 
 This is free software; see the source for copying conditions.  There is NO
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -118,7 +117,7 @@ case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | \
+  kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -255,6 +254,7 @@ case $basic_machine in
 	| arc | arceb \
 	| arc | arceb \
 	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 	| avr | avr32 \
 	| avr | avr32 \
+	| ba \
 	| be32 | be64 \
 	| be32 | be64 \
 	| bfin \
 	| bfin \
 	| c4x | c8051 | clipper \
 	| c4x | c8051 | clipper \
@@ -301,11 +301,12 @@ case $basic_machine in
 	| open8 | or1k | or1knd | or32 \
 	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
+	| pru \
 	| pyramid \
 	| pyramid \
 	| riscv32 | riscv64 \
 	| riscv32 | riscv64 \
 	| rl78 | rx \
 	| rl78 | rx \
 	| score \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -376,6 +377,7 @@ case $basic_machine in
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
 	| avr-* | avr32-* \
+	| ba-* \
 	| be32-* | be64-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
@@ -427,13 +429,15 @@ case $basic_machine in
 	| orion-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+	| pru-* \
 	| pyramid-* \
 	| pyramid-* \
+	| riscv32-* | riscv64-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
 	| tahoe-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tile*-* \
 	| tile*-* \
@@ -518,7 +522,7 @@ case $basic_machine in
 		basic_machine=i386-pc
 		basic_machine=i386-pc
 		os=-aros
 		os=-aros
 		;;
 		;;
-        asmjs)
+	asmjs)
 		basic_machine=asmjs-unknown
 		basic_machine=asmjs-unknown
 		;;
 		;;
 	aux)
 	aux)
@@ -641,6 +645,14 @@ case $basic_machine in
 		basic_machine=m68k-bull
 		basic_machine=m68k-bull
 		os=-sysv3
 		os=-sysv3
 		;;
 		;;
+	e500v[12])
+		basic_machine=powerpc-unknown
+		os=$os"spe"
+		;;
+	e500v[12]-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=$os"spe"
+		;;
 	ebmon29k)
 	ebmon29k)
 		basic_machine=a29k-amd
 		basic_machine=a29k-amd
 		os=-ebmon
 		os=-ebmon
@@ -1020,7 +1032,7 @@ case $basic_machine in
 	ppc-* | ppcbe-*)
 	ppc-* | ppcbe-*)
 		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
-	ppcle | powerpclittle | ppc-le | powerpc-little)
+	ppcle | powerpclittle)
 		basic_machine=powerpcle-unknown
 		basic_machine=powerpcle-unknown
 		;;
 		;;
 	ppcle-* | powerpclittle-*)
 	ppcle-* | powerpclittle-*)
@@ -1030,7 +1042,7 @@ case $basic_machine in
 		;;
 		;;
 	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
 	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
-	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+	ppc64le | powerpc64little)
 		basic_machine=powerpc64le-unknown
 		basic_machine=powerpc64le-unknown
 		;;
 		;;
 	ppc64le-* | powerpc64little-*)
 	ppc64le-* | powerpc64little-*)
@@ -1376,18 +1388,18 @@ case $os in
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 	      | -sym* | -kopensolaris* | -plan9* \
 	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* | -aros* | -cloudabi* \
+	      | -aos* | -aros* | -cloudabi* | -sortix* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -bitrig* | -openbsd* | -solidbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* | -cegcc* \
+	      | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
@@ -1396,7 +1408,8 @@ case $os in
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
+	      | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 		;;
 	-qnx*)
 	-qnx*)
@@ -1528,6 +1541,8 @@ case $os in
 		;;
 		;;
 	-nacl*)
 	-nacl*)
 		;;
 		;;
+	-ios)
+		;;
 	-none)
 	-none)
 		;;
 		;;
 	*)
 	*)
@@ -1623,6 +1638,9 @@ case $basic_machine in
 	sparc-* | *-sun)
 	sparc-* | *-sun)
 		os=-sunos4.1.1
 		os=-sunos4.1.1
 		;;
 		;;
+	pru-*)
+		os=-elf
+		;;
 	*-be)
 	*-be)
 		os=-beos
 		os=-beos
 		;;
 		;;

+ 10 - 10
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for file 5.31.
+# Generated by GNU Autoconf 2.69 for file 5.32.
 #
 #
 # Report bugs to <christos@astron.com>.
 # Report bugs to <christos@astron.com>.
 #
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 # Identity of this package.
 PACKAGE_NAME='file'
 PACKAGE_NAME='file'
 PACKAGE_TARNAME='file'
 PACKAGE_TARNAME='file'
-PACKAGE_VERSION='5.31'
-PACKAGE_STRING='file 5.31'
+PACKAGE_VERSION='5.32'
+PACKAGE_STRING='file 5.32'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_URL=''
 PACKAGE_URL=''
 
 
@@ -1328,7 +1328,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
   cat <<_ACEOF
-\`configure' configures file 5.31 to adapt to many kinds of systems.
+\`configure' configures file 5.32 to adapt to many kinds of systems.
 
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 
@@ -1398,7 +1398,7 @@ fi
 
 
 if test -n "$ac_init_help"; then
 if test -n "$ac_init_help"; then
   case $ac_init_help in
   case $ac_init_help in
-     short | recursive ) echo "Configuration of file 5.31:";;
+     short | recursive ) echo "Configuration of file 5.32:";;
    esac
    esac
   cat <<\_ACEOF
   cat <<\_ACEOF
 
 
@@ -1509,7 +1509,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
 if $ac_init_version; then
   cat <<\_ACEOF
   cat <<\_ACEOF
-file configure 5.31
+file configure 5.32
 generated by GNU Autoconf 2.69
 generated by GNU Autoconf 2.69
 
 
 Copyright (C) 2012 Free Software Foundation, Inc.
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2165,7 +2165,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 running configure, to aid debugging if configure makes a mistake.
 
 
-It was created by file $as_me 5.31, which was
+It was created by file $as_me 5.32, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
 
   $ $0 $@
   $ $0 $@
@@ -3031,7 +3031,7 @@ fi
 
 
 # Define the identity of the package.
 # Define the identity of the package.
  PACKAGE='file'
  PACKAGE='file'
- VERSION='5.31'
+ VERSION='5.32'
 
 
 
 
 cat >>confdefs.h <<_ACEOF
 cat >>confdefs.h <<_ACEOF
@@ -15075,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 # values after options handling.
 ac_log="
 ac_log="
-This file was extended by file $as_me 5.31, which was
+This file was extended by file $as_me 5.32, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_FILES    = $CONFIG_FILES
@@ -15141,7 +15141,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 ac_cs_version="\\
-file config.status 5.31
+file config.status 5.32
 configured by $0, generated by GNU Autoconf 2.69,
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
   with options \\"\$ac_cs_config\\"
 
 

+ 1 - 1
configure.ac

@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([file],[5.31],[christos@astron.com])
+AC_INIT([file],[5.32],[christos@astron.com])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 

+ 11 - 2
doc/libmagic.man

@@ -1,4 +1,4 @@
-.\" $File: libmagic.man,v 1.40 2016/03/31 17:51:12 christos Exp $
+.\" $File: libmagic.man,v 1.41 2017/05/23 21:54:07 christos Exp $
 .\"
 .\"
 .\" Copyright (c) Christos Zoulas 2003.
 .\" Copyright (c) Christos Zoulas 2003.
 .\" All Rights Reserved.
 .\" All Rights Reserved.
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd September 11, 2015
+.Dd May 23, 2017
 .Dt LIBMAGIC 3
 .Dt LIBMAGIC 3
 .Os
 .Os
 .Sh NAME
 .Sh NAME
@@ -35,6 +35,7 @@
 .Nm magic_errno ,
 .Nm magic_errno ,
 .Nm magic_descriptor ,
 .Nm magic_descriptor ,
 .Nm magic_buffer ,
 .Nm magic_buffer ,
+.Nm magic_getflags ,
 .Nm magic_setflags ,
 .Nm magic_setflags ,
 .Nm magic_check ,
 .Nm magic_check ,
 .Nm magic_compile ,
 .Nm magic_compile ,
@@ -64,6 +65,8 @@
 .Ft const char *
 .Ft const char *
 .Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length"
 .Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length"
 .Ft int
 .Ft int
+.Fn magic_getflags "magic_t cookie"
+.Ft int
 .Fn magic_setflags "magic_t cookie" "int flags"
 .Fn magic_setflags "magic_t cookie" "int flags"
 .Ft int
 .Ft int
 .Fn magic_check "magic_t cookie" "const char *filename"
 .Fn magic_check "magic_t cookie" "const char *filename"
@@ -206,6 +209,12 @@ argument with
 bytes size.
 bytes size.
 .Pp
 .Pp
 The
 The
+.Fn magic_getflags
+functions returns a value representing current
+.Ar flags
+set.
+.Pp
+The
 .Fn magic_setflags
 .Fn magic_setflags
 function sets the
 function sets the
 .Ar flags
 .Ar flags

+ 6 - 5
magic/Magdir/adventure

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: adventure,v 1.16 2017/03/17 21:35:28 christos Exp $
+# $File: adventure,v 1.17 2017/07/03 16:03:40 christos Exp $
 # adventure: file(1) magic for Adventure game files
 # adventure: file(1) magic for Adventure game files
 #
 #
 # from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
 # from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
@@ -36,11 +36,12 @@
 >0	ubyte			<9
 >0	ubyte			<9
 >>16	belong&0xfe00f0f0	0x3030
 >>16	belong&0xfe00f0f0	0x3030
 >>>0	ubyte			< 10
 >>>0	ubyte			< 10
->>>>2	ubeshort		< 10
+>>>>2	ubeshort		x
 >>>>>18	regex			[0-9][0-9][0-9][0-9][0-9][0-9]
 >>>>>18	regex			[0-9][0-9][0-9][0-9][0-9][0-9]
->>>>>>0	ubyte			< 10	Infocom (Z-machine %d,
->>>>>>>2	ubeshort	< 10 	Release %d /
->>>>>>>>18	string		>\0	Serial %.6s)
+>>>>>>0	ubyte			< 10	Infocom (Z-machine %d
+>>>>>>>2	ubeshort	x 	\b, Release %d
+>>>>>>>>18	string		>\0	\b, Serial %.6s
+>>>>>>>>18	string		x	\b)
 !:strength + 40
 !:strength + 40
 !:mime	application/x-zmachine
 !:mime	application/x-zmachine
 
 

+ 6 - 4
magic/Magdir/animation

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: animation,v 1.61 2017/04/01 18:26:03 christos Exp $
+# $File: animation,v 1.63 2017/05/26 14:33:07 christos Exp $
 # animation:  file(1) magic for animation/movie formats
 # animation:  file(1) magic for animation/movie formats
 #
 #
 # animation formats
 # animation formats
@@ -46,9 +46,11 @@
 >>11	byte		4		\b v4 (H.263/AMR GSM 6.10)
 >>11	byte		4		\b v4 (H.263/AMR GSM 6.10)
 >>11	byte		5		\b v5 (H.263/AMR GSM 6.10)
 >>11	byte		5		\b v5 (H.263/AMR GSM 6.10)
 >>11	byte		6		\b v6 (ITU H.264/AMR GSM 6.10)
 >>11	byte		6		\b v6 (ITU H.264/AMR GSM 6.10)
->>11	byte		a		\b C.S0050-0 V1.0
->>11	byte		b		\b C.S0050-0-A V1.0.0
->>11	byte		c		\b C.S0050-0-B V1.0
+# http://www.3gpp2.org/Public_html/Specs/C.S0050-B_v1.0_070521.pdf
+# Section 8.1.1, corresponds to a, b, c
+>>11	byte		0x61		\b C.S0050-0 V1.0
+>>11	byte		0x62		\b C.S0050-0-A V1.0.0
+>>11	byte		0x63		\b C.S0050-0-B V1.0
 >8	string		3ge		\b, MPEG v4 system, 3GPP
 >8	string		3ge		\b, MPEG v4 system, 3GPP
 !:mime	video/3gpp
 !:mime	video/3gpp
 >>11	byte		6		\b, Release 6 MBMS Extended Presentations
 >>11	byte		6		\b, Release 6 MBMS Extended Presentations

+ 6 - 6
magic/Magdir/archive

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: archive,v 1.107 2017/03/20 19:51:15 christos Exp $
+# $File: archive,v 1.108 2017/08/30 13:45:10 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #           extracting compressed archives)
 #
 #
@@ -565,12 +565,12 @@
 # check header level 0 1 2 3
 # check header level 0 1 2 3
 >>>20	ubyte		<4
 >>>20	ubyte		<4
 # check 2nd, 3th and 4th character of method id
 # check 2nd, 3th and 4th character of method id
->>>>3	regex		\^(lh[0-9a-ex]|lz[s2-8]|pm[012]|pc1)		\b\040
+>>>>3	regex		\^(lh[0-9a-ex]|lz[s2-8]|pm[012]|pc1)		\b 
 !:mime	application/x-lzh-compressed
 !:mime	application/x-lzh-compressed
 # creator type "LHA "
 # creator type "LHA "
 !:apple	????LHA
 !:apple	????LHA
 # display archive type name like "LHa/LZS archive data" or "LArc archive"
 # display archive type name like "LHa/LZS archive data" or "LArc archive"
->>>>>2	string		-lz		\b\040
+>>>>>2	string		-lz		\b 
 !:ext	lzs
 !:ext	lzs
 # already known  -lzs- -lz4- -lz5- with old names
 # already known  -lzs- -lz4- -lz5- with old names
 >>>>>>2	string	-lzs		LHa/LZS archive data
 >>>>>>2	string	-lzs		LHa/LZS archive data
@@ -584,12 +584,12 @@
 # LHice archiver use ".ICE" as name extension instead usual one ".lzh"
 # LHice archiver use ".ICE" as name extension instead usual one ".lzh"
 # FOOBAR archiver use ".foo" as name extension instead usual one
 # FOOBAR archiver use ".foo" as name extension instead usual one
 # "Florain Orjanov's and Olga Bachetska's ARchiver" not found at the moment
 # "Florain Orjanov's and Olga Bachetska's ARchiver" not found at the moment
->>>>>>>2	string	-lh1		\b\040
+>>>>>>>2	string	-lh1		\b 
 !:ext lha/lzh/ice
 !:ext lha/lzh/ice
 >>>>>>3	regex		\^lh[23d]	LHa 2.x? archive data
 >>>>>>3	regex		\^lh[23d]	LHa 2.x? archive data
 >>>>>>3	regex		\^lh[7]		LHa (2.x)/LHark archive data
 >>>>>>3	regex		\^lh[7]		LHa (2.x)/LHark archive data
 >>>>>>3	regex		\^lh[456]	LHa (2.x) archive data
 >>>>>>3	regex		\^lh[456]	LHa (2.x) archive data
->>>>>>>2	string	-lh5		\b\040
+>>>>>>>2	string	-lh5		\b 
 # https://en.wikipedia.org/wiki/BIOS
 # https://en.wikipedia.org/wiki/BIOS
 # Some mainboard BIOS like Award use LHa compression. So archives with unusal extension are found like
 # Some mainboard BIOS like Award use LHa compression. So archives with unusal extension are found like
 # bios.rom , kd7_v14.bin, 1010.004, ...
 # bios.rom , kd7_v14.bin, 1010.004, ...
@@ -599,7 +599,7 @@
 # UNLHA32 2.67a
 # UNLHA32 2.67a
 >>>>>>2	string		-lhx		LHa (UNLHA32) archive
 >>>>>>2	string		-lhx		LHa (UNLHA32) archive
 # lha archives with standard file name extensions ".lha" ".lzh"
 # lha archives with standard file name extensions ".lha" ".lzh"
->>>>>>3	regex		!\^(lh1|lh5)	\b\040
+>>>>>>3	regex		!\^(lh1|lh5)	\b 
 !:ext lha/lzh
 !:ext lha/lzh
 # this should not happen if all -lh variants are described
 # this should not happen if all -lh variants are described
 >>>>>>2	default		x		LHa (unknown) archive
 >>>>>>2	default		x		LHa (unknown) archive

+ 2 - 2
magic/Magdir/audio

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: audio,v 1.79 2017/03/17 22:20:22 christos Exp $
+# $File: audio,v 1.80 2017/08/13 00:21:47 christos Exp $
 # audio:  file(1) magic for sound formats (see also "iff")
 # audio:  file(1) magic for sound formats (see also "iff")
 #
 #
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@@ -745,7 +745,7 @@
 # second of release (0-59)
 # second of release (0-59)
 >>9		ubyte		x	\b:%.2d
 >>9		ubyte		x	\b:%.2d
 # if you select a language like german on your garmin device
 # if you select a language like german on your garmin device
-# you can only select voice modules with correponding language byte ID like 1
+# you can only select voice modules with corresponding language byte ID like 1
 >>18		ubyte		x	\b, language ID %d
 >>18		ubyte		x	\b, language ID %d
 # pointer to 1st audio WAV sample
 # pointer to 1st audio WAV sample
 >>16		uleshort	>0
 >>16		uleshort	>0

+ 10 - 0
magic/Magdir/bhl

@@ -0,0 +1,10 @@
+
+#------------------------------------------------------------------------------
+# $File: bhl,v 1.1 2017/06/11 22:20:02 christos Exp $
+# BlockHashLoc
+# ext: bhl
+# Marco Pontello marcopon@gmail.com
+# reference: https://github.com/MarcoPon/BlockHashLoc
+0	string	BlockHashLoc\x1a	BlockHashLoc recovery info,
+>13	byte	x			version %d
+!:ext   bhl

+ 41 - 18
magic/Magdir/c-lang

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: c-lang,v 1.25 2017/03/17 21:35:28 christos Exp $
+# $File: c-lang,v 1.26 2017/08/14 07:40:38 christos Exp $
 # c-lang:  file(1) magic for C and related languages programs
 # c-lang:  file(1) magic for C and related languages programs
 #
 #
 # The strength is to beat standard HTML
 # The strength is to beat standard HTML
@@ -11,46 +11,69 @@
 !:mime	text/x-bcpl
 !:mime	text/x-bcpl
 
 
 # C
 # C
-0	regex	\^#include	C source text
-!:strength +25
+# Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
+0	regex	\^#include			C
+>0	regex	\^class[[:space:]]+
+>>&0	regex 	\\{[\.\*]\\}(;)?$			\b++
+>&0	clear	x				source text
+!:strength + 13
+!:mime	text/x-c
+0	regex	\^#[[:space:]]*pragma	C source text
+!:mime	text/x-c
+0	regex	\^#[[:space:]]*(if\|ifn)def
+>&0	regex	\^#[[:space:]]*endif$	C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^char[\ \t\n]+	C source text
+0	regex	\^#[[:space:]]*(if\|ifn)def
+>&0	regex	\^#[[:space:]]*define	C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^double[\ \t\n]+		C source text
+0	regex	\^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$			C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^extern[\ \t\n]+		C source text
+0	regex	\^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$			C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^float[\ \t\n]+		C source text
+0	regex	\^[[:space:]]*extern[[:space:]]+		C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^struct[\ \t\n]+		C source text
+0	regex	\^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$			C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	regex	\^union[\ \t\n]+		C source text
+0	regex	\^struct[[:space:]]+		C source text
 !:mime	text/x-c
 !:mime	text/x-c
-0	search/8192	main(		C source text
+0	regex	\^union[[:space:]]+		C source text
+!:mime	text/x-c
+0	search/8192	main(
+>&0 regex	\\)[[:space:]]*\\{		C source text
 !:mime	text/x-c
 !:mime	text/x-c
 
 
 # C++
 # C++
 # The strength of these rules is increased so they beat the C rules above
 # The strength of these rules is increased so they beat the C rules above
-0	regex	\^template[\ \t]+<.*>[\ \t\n]+	C++ source text
+0	regex	\^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{	C++ source text
+!:strength + 30
+!:mime	text/x-c++
+# using namespace [namespace] or using std::[lib]
+0	regex	\^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*;		C++ source text
+!:strength + 30
+!:mime	text/x-c++
+0	regex	\^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$	C++ source text
 !:strength + 30
 !:strength + 30
 !:mime	text/x-c++
 !:mime	text/x-c++
-0	regex	\^virtual[\ \t\n]+		C++ source text
+0	regex	\^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$		C++ source text
 !:strength + 30
 !:strength + 30
 !:mime	text/x-c++
 !:mime	text/x-c++
-0	regex	\^class[\ \t\n]+		C++ source text
-# But class is reduced to avoid beating php (Jens Schleusener)
+# But class alone is reduced to avoid beating php (Jens Schleusener)
+0	regex	\^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$		C++ source text
 !:strength + 13
 !:strength + 13
 !:mime	text/x-c++
 !:mime	text/x-c++
-0	regex	\^public:		C++ source text
+0	regex	\^[[:space:]]*public:		C++ source text
+!:strength + 30
+!:mime	text/x-c++
+0	regex	\^[[:space:]]*private:		C++ source text
 !:strength + 30
 !:strength + 30
 !:mime	text/x-c++
 !:mime	text/x-c++
-0	regex	\^private:		C++ source text
+0	regex	\^[[:space:]]*protected:		C++ source text
 !:strength + 30
 !:strength + 30
 !:mime	text/x-c++
 !:mime	text/x-c++
 
 
 # Objective-C
 # Objective-C
-0	regex	\^#import	Objective-C source text
-!:strength +25
+0	regex	\^#import			Objective-C source text
+!:strength + 25
 !:mime	text/x-objective-c
 !:mime	text/x-objective-c
 
 
 # From: Mikhail Teterin <mi@aldan.algebra.com>
 # From: Mikhail Teterin <mi@aldan.algebra.com>

+ 8 - 3
magic/Magdir/cad

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: cad,v 1.14 2017/03/17 21:35:28 christos Exp $
+# $File: cad,v 1.15 2017/06/24 15:24:56 christos Exp $
 # autocad:  file(1) magic for cad files
 # autocad:  file(1) magic for cad files
 #
 #
 
 
@@ -147,8 +147,13 @@
 >0x02	byte	0xfe
 >0x02	byte	0xfe
 >>0x04	beshort	0x1800		CIT raster CAD
 >>0x04	beshort	0x1800		CIT raster CAD
 
 
-# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
-#16	beshort		0x3d3d		image/x-3ds
+# 3DS (3d Studio files)
+0	leshort		0x4d4d
+>6	leshort		0x2
+>>8	lelong		0xa
+>>>16	leshort		0x3d3d	3D Studio model
+!:mime	image/x-3ds
+!:extension 3ds
 
 
 # MegaCAD 2D/3D drawing (.prt)
 # MegaCAD 2D/3D drawing (.prt)
 # http://megacad.de/
 # http://megacad.de/

+ 2 - 2
magic/Magdir/cafebabe

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: cafebabe,v 1.22 2017/03/17 21:35:28 christos Exp $
+# $File: cafebabe,v 1.23 2017/05/25 20:07:23 christos Exp $
 # Cafe Babes unite!
 # Cafe Babes unite!
 #
 #
 # Since Java bytecode and Mach-O universal binaries have the same magic number,
 # Since Java bytecode and Mach-O universal binaries have the same magic number,
@@ -47,7 +47,7 @@
 
 
 0	name		mach-o		\b [
 0	name		mach-o		\b [
 >0	use		mach-o-cpu	\b
 >0	use		mach-o-cpu	\b
->(8.L)	indirect			\b:
+>(8.L)	indirect	x		\b:
 >0	belong		x		\b]
 >0	belong		x		\b]
 
 
 0	belong		0xcafebabe
 0	belong		0xcafebabe

+ 3 - 3
magic/Magdir/commands

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: commands,v 1.57 2017/04/04 20:34:24 christos Exp $
+# $File: commands,v 1.59 2017/08/14 07:40:38 christos Exp $
 # commands:  file(1) magic for various shells and interpreters
 # commands:  file(1) magic for various shells and interpreters
 #
 #
 #0	string/w	:			shell archive or script for antique kernel text
 #0	string/w	:			shell archive or script for antique kernel text
@@ -56,7 +56,7 @@
 !:mime	text/x-awk
 !:mime	text/x-awk
 0	string/wt	#!\ /usr/bin/awk	awk script text executable
 0	string/wt	#!\ /usr/bin/awk	awk script text executable
 !:mime	text/x-awk
 !:mime	text/x-awk
-0	regex/4096	=^[A-Za-z0-9_]{0,100}BEGIN[A-Za-z0-9_]{0,100}[{]	awk or perl script text
+0	regex/4096	=^[\040\t\f\r\n]{0,100}BEGIN[\040\t\f\r\n]{0,100}[{]	awk or perl script text
 
 
 # AT&T Bell Labs' Plan 9 shell
 # AT&T Bell Labs' Plan 9 shell
 0	string/wt	#!\ /bin/rc	Plan 9 rc shell script text executable
 0	string/wt	#!\ /bin/rc	Plan 9 rc shell script text executable
@@ -84,7 +84,7 @@
 # PHP scripts
 # PHP scripts
 # Ulf Harnhammar <ulfh@update.uu.se>
 # Ulf Harnhammar <ulfh@update.uu.se>
 0	search/1/c	=<?php			PHP script text
 0	search/1/c	=<?php			PHP script text
-!:strength + 10
+!:strength + 30
 !:mime	text/x-php
 !:mime	text/x-php
 0	search/1	=<?\n			PHP script text
 0	search/1	=<?\n			PHP script text
 !:mime	text/x-php
 !:mime	text/x-php

+ 2 - 2
magic/Magdir/compress

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: compress,v 1.67 2017/03/17 21:35:28 christos Exp $
+# $File: compress,v 1.68 2017/05/25 20:07:23 christos Exp $
 # compress:  file(1) magic for pure-compression formats (no archives)
 # compress:  file(1) magic for pure-compression formats (no archives)
 #
 #
 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -223,7 +223,7 @@
 # Zstandard/LZ4 skippable frames
 # Zstandard/LZ4 skippable frames
 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
 0         lelong&0xFFFFFFF0  0x184D2A50
 0         lelong&0xFFFFFFF0  0x184D2A50
->(4.l+8)  indirect
+>(4.l+8)  indirect	x
 
 
 # Zstandard Dictionary ID subroutine
 # Zstandard Dictionary ID subroutine
 0     name        zstd-dictionary-id
 0     name        zstd-dictionary-id

+ 11 - 2
magic/Magdir/console

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: console,v 1.30 2017/03/17 21:35:28 christos Exp $
+# $File: console,v 1.32 2017/08/13 00:21:47 christos Exp $
 # Console game magic
 # Console game magic
 # Toby Deshane <hac@shoelace.digivill.net>
 # Toby Deshane <hac@shoelace.digivill.net>
 
 
@@ -413,6 +413,15 @@
 >0x1E	byte	x		\b, Rev.%02u)
 >0x1E	byte	x		\b, Rev.%02u)
 >0x12	byte	2		(DSi enhanced)
 >0x12	byte	2		(DSi enhanced)
 >0x12	byte	3		(DSi only)
 >0x12	byte	3		(DSi only)
+# Secure Area check.
+>0x20		lelong	<0x4000		(homebrew)
+>0x20		lelong	>0x3FFF
+>>0x4000	lequad	0x0000000000000000	(multiboot)
+>>0x4000	lequad	!0x0000000000000000
+>>>0x4000	lequad	0xE7FFDEFFE7FFDEFF	(decrypted)
+>>>0x4000	lequad	!0xE7FFDEFFE7FFDEFF
+>>>>0x1000	lequad	0x0000000000000000	(encrypted)
+>>>>0x1000	lequad	!0x0000000000000000	(mask ROM)
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
 # nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot.
@@ -796,7 +805,7 @@
 
 
 # Type: Nintendo 3DS Homebrew Application.
 # Type: Nintendo 3DS Homebrew Application.
 # From: David Korth <gerbilsoft@gerbilsoft.com>
 # From: David Korth <gerbilsoft@gerbilsoft.com>
-# Refernece: https://3dbrew.org/wiki/3DSX_Format
+# Reference: https://3dbrew.org/wiki/3DSX_Format
 0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
 0	string	3DSX	Nintendo 3DS Homebrew Application (3DSX)
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------

+ 2 - 2
magic/Magdir/database

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: database,v 1.51 2017/04/28 16:28:16 christos Exp $
+# $File: database,v 1.52 2017/08/13 00:21:47 christos Exp $
 # database:  file(1) magic for various databases
 # database:  file(1) magic for various databases
 #
 #
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@@ -207,7 +207,7 @@
 >>>>>>>>>>>>>8		uleshort	>0		\b, at offset %d
 >>>>>>>>>>>>>8		uleshort	>0		\b, at offset %d
 >>>>>>>>>>>>>(8.s+1)	ubyte		>0
 >>>>>>>>>>>>>(8.s+1)	ubyte		>0
 >>>>>>>>>>>>>>&-1	string		>\0		1st record "%s"
 >>>>>>>>>>>>>>&-1	string		>\0		1st record "%s"
-# for multiple index files (*.MDX) Production flag,tag numbers(<=0x30),tag length(<=0x20), reserverd (NULL)
+# for multiple index files (*.MDX) Production flag,tag numbers(<=0x30),tag length(<=0x20), reserved (NULL)
 >>>>>>>24	ubelong&0x0133f7ff	>0
 >>>>>>>24	ubelong&0x0133f7ff	>0
 # test for reserved NULL byte
 # test for reserved NULL byte
 >>>>>>>>47	ubyte			0
 >>>>>>>>47	ubyte			0

+ 3 - 1
magic/Magdir/dump

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: dump,v 1.14 2017/03/17 21:35:28 christos Exp $
+# $File: dump,v 1.16 2017/07/22 19:21:02 christos Exp $
 # dump:  file(1) magic for dump file format--for new and old dump filesystems
 # dump:  file(1) magic for dump file format--for new and old dump filesystems
 #
 #
 # We specify both byte orders in order to recognize byte-swapped dumps.
 # We specify both byte orders in order to recognize byte-swapped dumps.
@@ -69,6 +69,8 @@
 >0	use	old-dump-be
 >0	use	old-dump-be
 
 
 24	lelong	60012		new-fs dump file (little endian),
 24	lelong	60012		new-fs dump file (little endian),
+# to correctly recognize '*.mo' GNU message catalog (little endian)
+!:strength - 15
 >0	use	\^new-dump-be
 >0	use	\^new-dump-be
 
 
 24	lelong	60011		old-fs dump file (little endian),
 24	lelong	60011		old-fs dump file (little endian),

+ 14 - 5
magic/Magdir/filesystems

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: filesystems,v 1.120 2017/03/24 19:29:26 christos Exp $
+# $File: filesystems,v 1.122 2017/07/21 10:34:41 christos Exp $
 # filesystems:  file(1) magic for different filesystems
 # filesystems:  file(1) magic for different filesystems
 #
 #
 0	name	partid
 0	name	partid
@@ -1959,11 +1959,10 @@
 32769	string    CD001
 32769	string    CD001
 # mime line at that position does not work
 # mime line at that position does not work
 # to display CD-ROM (70=81-11) after MBR (113=40+72+1), partition-table (71=50+21) and before Apple Driver Map (51)
 # to display CD-ROM (70=81-11) after MBR (113=40+72+1), partition-table (71=50+21) and before Apple Driver Map (51)
-!:strength -11
+#!:strength -11
 # to display CD-ROM (114=81+33) before MBR (113=40+72+1), partition-table (71=50+21) and Apple Driver Map (51)
 # to display CD-ROM (114=81+33) before MBR (113=40+72+1), partition-table (71=50+21) and Apple Driver Map (51)
-# does not work
-#!:strength +33
->0	use cdrom
+!:strength +34
+>0	use	cdrom
 
 
 # .cso files
 # .cso files
 # Reference: http://pismotec.com/ciso/ciso.h
 # Reference: http://pismotec.com/ciso/ciso.h
@@ -2388,3 +2387,13 @@
 >>>>>>>>0x1B	ubyte	0x30		\b, media=1D
 >>>>>>>>0x1B	ubyte	0x30		\b, media=1D
 >>>>>>>>0x1B	ubyte	0x40		\b, media=1DD
 >>>>>>>>0x1B	ubyte	0x40		\b, media=1DD
 >>>>>>>>0x1A	ubyte	0x10		\b, write-protected
 >>>>>>>>0x1A	ubyte	0x10		\b, write-protected
+
+# HDD Raw Copy Tool disk image, file extension: .imgc
+# From Benjamin Vanheuverzwijn <bvanheu@gmail.com>
+0	pstring	HDD\ Raw\ Copy\ Tool	%s
+>0x100	pstring	x			%s
+>0x200	pstring	x			- HD model: %s
+#>0x300	pstring	x			unknown %s
+>0x400	pstring	x			serial: %s
+#>0x500	pstring	x			unknown: %s
+!:ext	imgc

+ 43 - 43
magic/Magdir/flash

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: flash,v 1.12 2017/02/07 23:25:26 christos Exp $
+# $File: flash,v 1.14 2017/05/25 20:09:55 christos Exp $
 # flash:	file(1) magic for Macromedia Flash file format
 # flash:	file(1) magic for Macromedia Flash file format
 #
 #
 # See
 # See
@@ -10,45 +10,45 @@
 #	en/devnet/swf/pdf/swf-file-format-spec.pdf page 27
 #	en/devnet/swf/pdf/swf-file-format-spec.pdf page 27
 #
 #
 
 
-0   name        swf-details
-
->0      string      F
->>8     byte&0xfd   0x08    Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
->>8     byte&0xfe   0x10    Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
->>8     byte        0x18    Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
->>8     beshort&ff87 0x2000 Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
->>8     beshort&ffe0 0x3000 Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
->>8     byte&0x7    0
->>>8    ubyte       >0x2f
->>>>9   ubyte       <0x20   Macromedia Flash data
-!:mime  application/x-shockwave-flash
->>>>>3  byte        x       \b, version %d
-
->0      string      C
->>8     byte        0x78    Macromedia Flash data (compressed)
-!:mime  application/x-shockwave-flash
->>>3    byte        x       \b, version %d
-
->0      string      Z
->>8     byte        0x5d    Macromedia Flash data (lzma compressed)
-!:mime  application/x-shockwave-flash
->>>3    byte        x      \b, version %d
-
-
-1   string      WS
->4  ulelong     >14
->>3 ubyte       !0
->>>0   use      swf-details
+0   name	swf-details
+
+>0	string		F
+>>8	byte&0xfd	0x08		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+>>8	byte&0xfe	0x10		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+>>8	byte		0x18		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+>>8	beshort&0xff87	0x2000		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+>>8	beshort&0xffe0	0x3000		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+>>8	byte&0x7	0
+>>>8	ubyte		>0x2f
+>>>>9	ubyte		<0x20		Macromedia Flash data
+!:mime	application/x-shockwave-flash
+>>>>>3	byte		x		\b, version %d
+
+>0	string		C
+>>8	byte		0x78		Macromedia Flash data (compressed)
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+
+>0	string		Z
+>>8	byte		0x5d		Macromedia Flash data (lzma compressed)
+!:mime	application/x-shockwave-flash
+>>>3	byte		x		\b, version %d
+
+
+1	string		WS
+>4	ulelong		>14
+>>3	ubyte		!0
+>>>0	use		swf-details
 
 
 # From: Cal Peake <cp@absolutedigital.net>
 # From: Cal Peake <cp@absolutedigital.net>
 0	string		FLV\x01		Macromedia Flash Video
 0	string		FLV\x01		Macromedia Flash Video
@@ -56,7 +56,7 @@
 
 
 #
 #
 # Yosu Gomez
 # Yosu Gomez
-0       string AGD2\xbe\xb8\xbb\xcd\x00 Macromedia Freehand 7 Document
-0       string AGD3\xbe\xb8\xbb\xcc\x00 Macromedia Freehand 8 Document
+0	string	AGD2\xbe\xb8\xbb\xcd\x00	Macromedia Freehand 7 Document
+0	string	AGD3\xbe\xb8\xbb\xcc\x00	Macromedia Freehand 8 Document
 # From Dave Wilson
 # From Dave Wilson
-0	string AGD4\xbe\xb8\xbb\xcb\x00	Macromedia Freehand 9 Document
+0	string	AGD4\xbe\xb8\xbb\xcb\x00	Macromedia Freehand 9 Document

+ 147 - 9
magic/Magdir/fonts

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: fonts,v 1.35 2017/03/17 21:35:28 christos Exp $
+# $File: fonts,v 1.37 2017/06/24 00:39:00 christos Exp $
 # fonts:  file(1) magic for font data
 # fonts:  file(1) magic for font data
 #
 #
 0	search/1	FONT		ASCII vfont text
 0	search/1	FONT		ASCII vfont text
@@ -136,21 +136,159 @@
 >4	beshort		>0		version %d
 >4	beshort		>0		version %d
 
 
 # True Type fonts
 # True Type fonts
-0	string	\000\001\000\000\000	TrueType font data
-!:mime application/x-font-ttf
+# Modified by: Joerg Jenderek
+# URL: https://en.wikipedia.org/wiki/TrueType
+# Reference: https://developer.apple.com/fonts/TrueType-Reference-Manual/
+#
+# sfnt version "typ1" used by some Apple, but no example found
+0	string	typ1
+>0	use		sfnt-font
+>0	use		sfnt-names
+# sfnt version "true" used by some Apple
+0	string	true
+>0	use		sfnt-font
+>0	use		sfnt-names
+# GRR: below test is too general
+# sfnt version often 0x00010000
+0	string	\000\001\000\000
+>0	use		sfnt-font
+>0	use		sfnt-names
+#	validate and display sfnt font data like number of tables
+0	name		sfnt-font
+# file 5.30 version assumes 00FFh as maximal number of tables
+#>4	ubeshort	<0x0100		
+# maximal 27 tables found like in Skia.ttf
+# 46 different table names mentioned on Apple specification
+# skip 1st sequence of DOS 2 backup with path separator (\~92 or /~47) misinterpreted as table number
+>4	ubeshort	<47		
+# skip bad examples with garbage table names like in a5.show HYPERC MAC
+# tag names consist of up to four characters padded with spaces at end like
+# BASE DSIG OS/2 Zapf acnt glyf cvt vmtx xref ...
+>>12	regex/4l	\^[A-Za-z][A-Za-z][A-Za-z/][A-Za-z2\ ]	
+#>>>0	ubelong	x	\b, sfnt version 0x%x
+>>>0	ubelong	!0x4f54544f	TrueType
+!:mime	application/font-sfnt
+#!:mime	font/ttf
+!:apple	????tfil
+# .ttf for TrueType font
+# EUDC.tte created by privat character editor %WINDIR%\system32\eudcedit.exe
+!:ext	ttf/tte
+# sfnt version 4F54544Fh~OTTO
+>>>0	ubelong	=0x4f54544f	OpenType
+!:mime	application/font-sfnt
+#!:mime	font/otf
+!:apple	????OTTO
+!:ext	otf
+>>>0	ubelong	x		Font data
+# DSIG=44454947h table name implies a digitally signed font
+# search range = number of tables * 16 =< maximal number of tables * 16 = 27 * 16 = 432
+>>>12	search/432	DSIG		\b, digitally signed
+>>>4	ubeshort	x		\b, %d tables
+# minimal 9 tables found like in NISC18030.ttf
+#>>>4	ubeshort	<10		TMIN
+#>>>4	ubeshort	>24		TBIG
+# table directory entries
+>>>12	string		x		\b, 1st "%4.4s"
+
+#	search and display 1st name in sfnt font which is often copyright text
+#	does not work inside font collections
+0	name		sfnt-names
+# search for naming table
+>12	search/432/s	name		
+# biggest offset 0x0100bd28 like Windows10 Fonts\simsunb.ttf
+#>>>>&8	ubelong		>0x0100bd27	BIGGEST OFFSET
+>>&8	ubelong		>0x00100000	
+# offset of name table
+>>>&-4	ubelong		x		\b, name offset 0x%x
+# GRR: pointer to name table only works if offset ~< FILE_BYTES_MAX = 100000h defined in src\file.h
+>>&8	ubelong		<0x00100000	
+>>>&-16	ubelong		x		
+# name table
+>>>>(&8.L)	ubequad	x		
+# invalid format selector 
+#>>>>>&-8	ubeshort	!0	\b, invalid selector %x
+# minimal 3 name records found like in c:\Program Files (x86)\Tesseract-OCR\tessdata\pdf.ttf
+# maximal 1227 name records found like in Apple Chancery.ttf
+#>>>>>&-6	ubeshort	<0x4	mincount
+#>>>>>&-6	ubeshort	>130	maxcount
+>>>>>&-6	ubeshort	x	\b, %d names
+# offset to start of string storage from start of table
+#>>>>>&-4	ubeshort	x	\b, record offset %d
+# 1st name record
+# string offset from start of storage area 
+#>>>>>&8		ubeshort	x	\b, string offset %d
+# string length
+#>>>>>&6		ubeshort	x	\b, string length %d
+# minimal name string 7 like in c:\Program Files (x86)\Kodi\addons\webinterface.default\lib\video-js\font\VideoJS.ttf
+# also found 0 like in SWZCONLN.TTF
+#>>>>>&6		ubeshort	<8	MIN STRING
+# maximal name string 806 like in c:\Windows\Fonts\palabi.ttf
+#>>>>>&6		ubeshort	>805	MAX STRING
+# platform identifier: 0~Apple Unicode, 1~Macintosh, 3~Microsoft
+#>>>>>&-2	ubeshort	>3	BAD PLATFORM
+>>>>>&-2	ubeshort	0	\b, Unicode
+>>>>>&-2	ubeshort	1	\b, Macintosh
+>>>>>&-2	ubeshort	3	\b, Microsoft
+# languageID (0~english Macintosh, 0409h~english Microsoft, ...)
+>>>>>&2		ubeshort	>0	\b, language 0x%x
+# name identifiers
+# often 0~copyright, 1~font, 2~font subfamily, 5~version, 13~license, 19~sample, ...
+>>>>>&4		ubeshort	>0	\b, type %d string
+# platform specific encoding:
+# 0~undefined character set, 1~UGL set with Unicode, 3~Unicode 2.0 BMP only, 4~Unicode 2.0
+#>>>>>&0		ubeshort	x	\b, %d encoding
+>>>>>&0		ubeshort	0	
+# handle only name string offset 0 because do not know how to add 2 relative offsets
+>>>>>>&6		ubeshort	0	
+>>>>>>>&(&-14.S-18)	ubyte		!0	
+# GRR: instead 806 only first MAXstring = 96 characters are displayed as defined in src\file.h
+# often copyright string that starts like \251 2006 The Monotype Corporation
+>>>>>>>>&-1		string		x	\b, %-11.96s
+# test for unicode string
+>>>>>>>&(&-14.S-18)	ubyte		0	
+>>>>>>>>&0		lestring16	x	\b, %-11.96s
+# unicode encoding
+>>>>>&0		ubeshort	>0	
+>>>>>>&6		ubeshort	0	
+>>>>>>>&(&-14.S-17)	lestring16	x	\b, %-11.96s
 
 
 0	string		\007\001\001\000Copyright\ (c)\ 199	Adobe Multiple Master font
 0	string		\007\001\001\000Copyright\ (c)\ 199	Adobe Multiple Master font
 0	string		\012\001\001\000Copyright\ (c)\ 199	Adobe Multiple Master font
 0	string		\012\001\001\000Copyright\ (c)\ 199	Adobe Multiple Master font
 
 
 # TrueType/OpenType font collections (.ttc)
 # TrueType/OpenType font collections (.ttc)
+# URL: https://en.wikipedia.org/wiki/OpenType
 # http://www.microsoft.com/typography/otspec/otff.htm
 # http://www.microsoft.com/typography/otspec/otff.htm
-0	string		ttcf		TrueType font collection data
->4	belong		0x00010000	\b, 1.0
->>8	belong		>0		\b, %d fonts
->4	belong		0x00020000	\b, 2.0
->>8	belong		>0		\b, %d fonts
+# Modified by: Joerg Jenderek
+# Note:	container for TrueType, OpenType font
+0	string		ttcf
+# skip ASCII text
+>4	ubyte		0		
+# sfnt version often 0x00010000 of 1st table is TrueType
+>>(12.L)	ubelong	!0x4f54544f	TrueType
+#!:mime	font/ttf
+!:apple	????tfil
+!:ext	ttc
+# sfnt version 4F54544Fh~OTTO of 1st table is OpenType font 
+>>(12.L)	ubelong	=0x4f54544f	OpenType
+#!:mime	font/otf
+!:apple	????OTTO
+# no example found for otc
+!:ext	ttc/otc
+>>4	ubyte		x		font collection data
+!:mime	application/font-sfnt
+#!:mime	font/collection
+# TCC version
+>>4	belong		0x00010000	\b, 1.0
+>>4	belong		0x00020000	\b, 2.0
+>>8	ubelong		>0		\b, %d fonts
+# array offset size = fonts * offsetsize = fonts * 4
+>>(8.L*4) ubequad	x		
 # 0x44454947 = 'DSIG'
 # 0x44454947 = 'DSIG'
->>>16	belong		0x44534947	\b, digitally signed
+>>>&4	belong		0x44534947	\b, digitally signed
+# offset to 1st font
+>>12	ubelong		x		\b, at 0x%x
+# point to 1st font that starts with sfnt version
+>>(12.L) use		sfnt-font
 
 
 # Opentype font data from Avi Bercovich
 # Opentype font data from Avi Bercovich
 0	string		OTTO		OpenType font data
 0	string		OTTO		OpenType font data

+ 10 - 0
magic/Magdir/gconv

@@ -0,0 +1,10 @@
+
+#------------------------------------------------------------------------------
+# $File: gconv
+# gconv: file(1) magic for iconv/gconv module configuration cache
+#
+# Magic number defined in glibc/iconv/iconvconfig.h as GCONVCACHE_MAGIC
+#
+# From: Marek Cermak <macermak@redhat.com>
+#
+0		lelong		0x20010324 	gconv module configuration cache data

+ 2 - 2
magic/Magdir/icc

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: icc,v 1.4 2017/03/17 22:20:22 christos Exp $
+# $File: icc,v 1.5 2017/08/13 00:21:47 christos Exp $
 # icc:  file(1) magic for International Color Consortium file formats
 # icc:  file(1) magic for International Color Consortium file formats
 
 
 #
 #
@@ -48,7 +48,7 @@
 # 5th platform
 # 5th platform
 >>>40	string		TGNT		Taligent
 >>>40	string		TGNT		Taligent
 
 
-# remaing "l" "e" of "color profile" printed later to avoid error
+# remaining "l" "e" of "color profile" printed later to avoid error
 >>>40	string		x 		color profi
 >>>40	string		x 		color profi
 #>>>40	string		x		(%.4s)
 #>>>40	string		x		(%.4s)
 !:mime	application/vnd.iccprofile
 !:mime	application/vnd.iccprofile

+ 39 - 25
magic/Magdir/images

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: images,v 1.123 2017/04/04 20:34:24 christos Exp $
+# $File: images,v 1.126 2017/06/11 22:25:44 christos Exp $
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # XPM bitmaps)
 # XPM bitmaps)
 #
 #
@@ -35,11 +35,6 @@
 >>>16	ubyte			<33
 >>>16	ubyte			<33
 # skip more by looking for pixel size 0Fh 10h 18h 20h
 # skip more by looking for pixel size 0Fh 10h 18h 20h
 >>>>16	ubyte&0xC0		0x00
 >>>>16	ubyte&0xC0		0x00
-# skip 260-16.ico by looking for no color map
->>>>>1	ubyte			0
-# implies no first map entry
->>>>>>3	uleshort		0
->>>>>>>0	use		tga-image
 # Color Map
 # Color Map
 >>>>>1	belong&0xfff7ffff	0x01010000
 >>>>>1	belong&0xfff7ffff	0x01010000
 >>>>>>0		use		tga-image
 >>>>>>0		use		tga-image
@@ -47,6 +42,12 @@
 >>>>>>0		use		tga-image
 >>>>>>0		use		tga-image
 >>>>>1	belong&0xfff7ffff	0x00030000
 >>>>>1	belong&0xfff7ffff	0x00030000
 >>>>>>0		use		tga-image
 >>>>>>0		use		tga-image
+>>>>>1	default			x
+# skip 260-16.ico by looking for no color map
+>>>>>>1	ubyte			0
+# implies no first map entry
+>>>>>>>3	uleshort		0
+>>>>>>>>0	use		tga-image
 #	display tga bitmap image information
 #	display tga bitmap image information
 0	name				tga-image
 0	name				tga-image
 >2	ubyte		<34		Targa image data
 >2	ubyte		<34		Targa image data
@@ -175,42 +176,42 @@
 >>>&0	regex		=[0-9]{1,50}			\b %s
 >>>&0	regex		=[0-9]{1,50}			\b %s
 
 
 0	search/1	P1
 0	search/1	P1
->0	regex/4		P1[A-Za-z0-9_]
+>0	regex/4		P1[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, bitmap
 >>>0	string		x	\b, bitmap
 !:strength + 45
 !:strength + 45
 !:mime	image/x-portable-bitmap
 !:mime	image/x-portable-bitmap
 
 
 0	search/1	P2
 0	search/1	P2
->0	regex/4		P2[A-Za-z0-9_]
+>0	regex/4		P2[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, greymap
 >>>0	string		x	\b, greymap
 !:strength + 45
 !:strength + 45
 !:mime	image/x-portable-greymap
 !:mime	image/x-portable-greymap
 
 
 0	search/1	P3
 0	search/1	P3
->0	regex/4		P3[A-Za-z0-9_]
+>0	regex/4		P3[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, pixmap
 >>>0	string		x	\b, pixmap
 !:strength + 45
 !:strength + 45
 !:mime	image/x-portable-pixmap
 !:mime	image/x-portable-pixmap
 
 
 0	string		P4
 0	string		P4
->0	regex/4		P4[A-Za-z0-9_]
+>0	regex/4		P4[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, rawbits, bitmap
 >>>0	string		x	\b, rawbits, bitmap
 !:strength + 45
 !:strength + 45
 !:mime	image/x-portable-bitmap
 !:mime	image/x-portable-bitmap
 
 
 0	string		P5
 0	string		P5
->0	regex/4		P5[A-Za-z0-9_]
+>0	regex/4		P5[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, rawbits, greymap
 >>>0	string		x	\b, rawbits, greymap
 !:strength + 45
 !:strength + 45
 !:mime	image/x-portable-greymap
 !:mime	image/x-portable-greymap
 
 
 0	string		P6
 0	string		P6
->0	regex/4		P6[A-Za-z0-9_]
+>0	regex/4		P6[\040\t\f\r\n]
 >>0	use		netpbm
 >>0	use		netpbm
 >>>0	string		x	\b, rawbits, pixmap
 >>>0	string		x	\b, rawbits, pixmap
 !:strength + 45
 !:strength + 45
@@ -418,22 +419,35 @@
 # (Greg Roelofs, newt@uchicago.edu)
 # (Greg Roelofs, newt@uchicago.edu)
 # (Albert Cahalan, acahalan@cs.uml.edu)
 # (Albert Cahalan, acahalan@cs.uml.edu)
 #
 #
-# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
+# 137 P N G \r \n ^Z \n [4-byte length] I H D R [HEAD data] [HEAD crc] ...
 #
 #
-0	string		\x89PNG\x0d\x0a\x1a\x0a		PNG image data
+
+# IHDR parser
+0	name		png-ihdr
+>0	belong		x		\b, %d x
+>4	belong		x		%d,
+>8	byte		x		%d-bit
+>9	byte		0		grayscale,
+>9	byte		2		\b/color RGB,
+>9	byte		3		colormap,
+>9	byte		4		gray+alpha,
+>9	byte		6		\b/color RGBA,
+#>10	byte		0		deflate/32K,
+>12	byte		0		non-interlaced
+>12	byte		1		interlaced
+
+# Standard PNG image.
+0	string		\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0DIHDR	PNG image data
+!:mime	image/png
+!:strength +10
+>16	use		png-ihdr
+
+# Apple CgBI PNG image.
+0	string		\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x04CgBI
+>24	string  	\x00\x00\x00\x0DIHDR	PNG image data (CgBI)
 !:mime	image/png
 !:mime	image/png
 !:strength +10
 !:strength +10
->16	belong		x		\b, %d x
->20	belong		x		%d,
->24	byte		x		%d-bit
->25	byte		0		grayscale,
->25	byte		2		\b/color RGB,
->25	byte		3		colormap,
->25	byte		4		gray+alpha,
->25	byte		6		\b/color RGBA,
-#>26	byte		0		deflate/32K,
->28	byte		0		non-interlaced
->28	byte		1		interlaced
+>>32	use		png-ihdr
 
 
 # possible GIF replacements; none yet released!
 # possible GIF replacements; none yet released!
 # (Greg Roelofs, newt@uchicago.edu)
 # (Greg Roelofs, newt@uchicago.edu)

+ 4 - 1
magic/Magdir/m4

@@ -1,6 +1,9 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: m4,v 1.1 2011/12/08 12:12:46 rrt Exp $
+# $File: m4,v 1.2 2017/08/14 07:40:38 christos Exp $
 # make:  file(1) magic for M4 scripts
 # make:  file(1) magic for M4 scripts
 #
 #
 0	regex	\^dnl\ 		M4 macro processor script text
 0	regex	\^dnl\ 		M4 macro processor script text
 !:mime	text/x-m4
 !:mime	text/x-m4
+0	regex	\^AC_DEFUN\\(\\[	M4 macro processor script text
+!:strength + 15
+!:mime	text/x-m4

+ 4 - 4
magic/Magdir/msdos

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: msdos,v 1.118 2017/05/20 19:55:27 christos Exp $
+# $File: msdos,v 1.120 2017/08/13 00:21:47 christos Exp $
 # msdos:  file(1) magic for MS-DOS files
 # msdos:  file(1) magic for MS-DOS files
 #
 #
 
 
@@ -820,7 +820,7 @@
 # Windows icons
 # Windows icons
 # Update: Joerg Jenderek
 # Update: Joerg Jenderek
 # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
 # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
-# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG
+# Note: similar to Windows CURsor. container for BMP (only DIB part) or PNG
 0   belong  0x00000100
 0   belong  0x00000100
 >9  byte    0
 >9  byte    0
 >>0 byte    x
 >>0 byte    x
@@ -891,7 +891,7 @@
 # Windows non-animated cursors
 # Windows non-animated cursors
 # Update: Joerg Jenderek
 # Update: Joerg Jenderek
 # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
 # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
-# Note: similiar to Windows ICOn. container for BMP ( only DIB part)
+# Note: similar to Windows ICOn. container for BMP ( only DIB part)
 # GRR: line below is too general as it catches also Lotus 1-2-3 files
 # GRR: line below is too general as it catches also Lotus 1-2-3 files
 0   belong  0x00000200
 0   belong  0x00000200
 >9  byte    0
 >9  byte    0
@@ -998,7 +998,7 @@
 
 
 # TNEF magic From "Joomy" <joomy@se-ed.net>
 # TNEF magic From "Joomy" <joomy@se-ed.net>
 # Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
 # Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
-0	leshort		0x223e9f78	TNEF
+0	lelong		0x223e9f78	TNEF
 !:mime	application/vnd.ms-tnef
 !:mime	application/vnd.ms-tnef
 
 
 # Norton Guide (.NG , .HLP) files added by Joerg Jenderek from source NG2HTML.C
 # Norton Guide (.NG , .HLP) files added by Joerg Jenderek from source NG2HTML.C

+ 4 - 1
magic/Magdir/msvc

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: msvc,v 1.8 2017/03/17 22:20:22 christos Exp $
+# $File: msvc,v 1.9 2017/08/02 08:15:20 christos Exp $
 # msvc:  file(1) magic for msvc
 # msvc:  file(1) magic for msvc
 # "H. Nanosecond" <aldomel@ix.netcom.com>
 # "H. Nanosecond" <aldomel@ix.netcom.com>
 # Microsoft visual C
 # Microsoft visual C
@@ -54,6 +54,9 @@
 # Page Count for msoo-dll.pdb 4379h
 # Page Count for msoo-dll.pdb 4379h
 >>>0x32	leshort	x	\b*%d bytes
 >>>0x32	leshort	x	\b*%d bytes
 
 
+# Reference: https://github.com/Microsoft/vstest/pull/856/commits/fdc7a9f074ca5a8dfeec83b1be9162bf0cf4000d
+0       string/c bsjb\001\000\001\000\000\000\000\000\f\000\000\000pdb\ v1.0     Microsoft Rosyln C# debugging symbols version 1.0
+
 #.sbr
 #.sbr
 0	string	\000\002\000\007\000	MSVC .sbr
 0	string	\000\002\000\007\000	MSVC .sbr
 >5	string 	>\0	%s
 >5	string 	>\0	%s

+ 6 - 1
magic/Magdir/pdf

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: pdf,v 1.8 2015/01/11 18:19:18 christos Exp $
+# $File: pdf,v 1.9 2017/05/24 17:35:20 christos Exp $
 # pdf:  file(1) magic for Portable Document Format
 # pdf:  file(1) magic for Portable Document Format
 #
 #
 
 
@@ -20,3 +20,8 @@
 !:mime application/vnd.fdf
 !:mime application/vnd.fdf
 >5      byte            x               \b, version %c
 >5      byte            x               \b, version %c
 >7      byte            x               \b.%c
 >7      byte            x               \b.%c
+
+0	search/256	%PDF-		PDF document
+!:mime	application/pdf
+>&0	byte		x		\b, version %c
+>&2	byte		x		\b.%c

+ 26 - 6
magic/Magdir/python

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: python,v 1.31 2017/04/11 14:59:28 christos Exp $
+# $File: python,v 1.34 2017/08/14 07:40:38 christos Exp $
 # python:  file(1) magic for python
 # python:  file(1) magic for python
 #
 #
 # Outlook puts """ too for urgent messages
 # Outlook puts """ too for urgent messages
@@ -24,7 +24,11 @@
 0	belong		0x6c0c0d0a	python 3.2 byte-compiled
 0	belong		0x6c0c0d0a	python 3.2 byte-compiled
 0	belong		0x9e0c0d0a	python 3.3 byte-compiled
 0	belong		0x9e0c0d0a	python 3.3 byte-compiled
 0	belong		0xee0c0d0a	python 3.4 byte-compiled
 0	belong		0xee0c0d0a	python 3.4 byte-compiled
-0	belong		0x160d0d0a	python 3.5 byte-compiled
+0	belong		0x160d0d0a	python 3.5.1- byte-compiled
+0	belong		0x170d0d0a	python 3.5.2+ byte-compiled
+0	belong		0x330d0d0a	python 3.6 byte-compiled
+0	belong		0x3e0d0d0a	python 3.7 byte-compiled
+
 
 
 0	search/1/w	#!\ /usr/bin/python	Python script text executable
 0	search/1/w	#!\ /usr/bin/python	Python script text executable
 !:strength + 15
 !:strength + 15
@@ -51,6 +55,17 @@
 !:strength + 15
 !:strength + 15
 !:mime text/x-python
 !:mime text/x-python
 
 
+# if __name__ == "__main__":
+0 search/4096 if\ __name__
+>&0 search/64 '__main__'	Python script text executable
+>&0 search/64 "__main__"	Python script text executable
+!:strength + 15
+!:mime text/x-python
+
+# import module [as abrev]
+0	regex	\^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
+!:mime text/x-python
+
 # comments
 # comments
 #0	search/4096	'''
 #0	search/4096	'''
 #>&0	regex	.*'''$	Python script text executable
 #>&0	regex	.*'''$	Python script text executable
@@ -64,14 +79,19 @@
 # except: or finally:
 # except: or finally:
 # block
 # block
 0	search/4096	try:
 0	search/4096	try:
->&0	regex	\^[A-Za-z0-9_]*except.*:	Python script text executable
+>&0	regex	\^[[:space:]]*except.*:$	Python script text executable
 !:strength + 15
 !:strength + 15
 !:mime text/x-python
 !:mime text/x-python
 >&0	search/4096	finally:	Python script text executable
 >&0	search/4096	finally:	Python script text executable
 !:mime text/x-python
 !:mime text/x-python
 
 
-# def name(args, args):
-0	regex	 \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
->&0	regex	\ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable
+# class name[(base classes,)]: [pass]
+0	regex	\^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$		Python script text executable
+!:strength + 15
 !:mime text/x-python
 !:mime text/x-python
+
+# def name(*args, **kwargs):
+0	regex	 \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
+>&0	regex	 \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable
 !:strength + 15
 !:strength + 15
+!:mime text/x-python

+ 28 - 9
magic/Magdir/ruby

@@ -1,32 +1,51 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: ruby,v 1.6 2016/07/27 09:46:29 rrt Exp $
+# $File: ruby,v 1.7 2017/08/14 13:39:18 christos Exp $
 # ruby:  file(1) magic for Ruby scripting language
 # ruby:  file(1) magic for Ruby scripting language
 # URL:  http://www.ruby-lang.org/
 # URL:  http://www.ruby-lang.org/
 # From: Reuben Thomas <rrt@sc3d.org>
 # From: Reuben Thomas <rrt@sc3d.org>
 
 
 # Ruby scripts
 # Ruby scripts
-0	search/1/w	#!\ /usr/bin/ruby	Ruby script text executable
+0	search/1/w	#!\ /usr/bin/ruby				Ruby script text executable
 !:strength + 15
 !:strength + 15
 !:mime text/x-ruby
 !:mime text/x-ruby
 0	search/1/w	#!\ /usr/local/bin/ruby	Ruby script text executable
 0	search/1/w	#!\ /usr/local/bin/ruby	Ruby script text executable
 !:strength + 15
 !:strength + 15
 !:mime text/x-ruby
 !:mime text/x-ruby
-0	search/1	#!/usr/bin/env\ ruby	Ruby script text executable
+0	search/1	#!/usr/bin/env\ ruby				Ruby script text executable
 !:strength + 15
 !:strength + 15
 !:mime text/x-ruby
 !:mime text/x-ruby
-0	search/1	#!\ /usr/bin/env\ ruby	Ruby script text executable
+0	search/1	#!\ /usr/bin/env\ ruby			Ruby script text executable
 !:strength + 15
 !:strength + 15
 !:mime text/x-ruby
 !:mime text/x-ruby
 
 
 # What looks like ruby, but does not have a shebang
 # What looks like ruby, but does not have a shebang
 # (modules and such)
 # (modules and such)
 # From: Lubomir Rintel <lkundrak@v3.sk>
 # From: Lubomir Rintel <lkundrak@v3.sk>
-0	regex		\^[\ \t]*require[\ \t]'[A-Za-z_/]+'
->0	regex		include\ [A-Z]|def\ [a-z]|\ do$
->>0	regex		\^[\ \t]*end([\ \t]*[;#].*)?$		Ruby script text
+0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'
+>0	regex		def\ [a-z]|\ do$
+>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
+!:strength + 30
 !:mime	text/x-ruby
 !:mime	text/x-ruby
-0	regex		\^[\ \t]*(class|module)[\ \t][A-Z]
+0	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
 >0	regex		(modul|includ)e\ [A-Z]|def\ [a-z]
 >0	regex		(modul|includ)e\ [A-Z]|def\ [a-z]
->>0	regex		\^[\ \t]*end([\ \t]*[;#].*)?$		Ruby module source text
+>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
+!:strength + 30
+!:mime	text/x-ruby
+# Classes with no modules or defs, beats simple ASCII
+0	regex		\^[[:space:]]*(class|module)[[:space:]][A-Z]
+>&0	regex	\^[[:space:]]*end([[:space:]]+[;#if].*)?$		Ruby script text
+!:strength + 10
+!:mime	text/x-ruby
+# Looks for function definition to balance python magic
+# def name (args)
+# end
+0	regex		\^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z]
+>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
+!:strength + 10
+!:mime	text/x-ruby
+
+0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'	Ruby script text
+!:mime	text/x-ruby
+0 regex 	\^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+	Ruby script text
 !:mime	text/x-ruby
 !:mime	text/x-ruby

+ 2 - 2
magic/Magdir/sendmail

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sendmail,v 1.9 2017/03/17 21:35:28 christos Exp $
+# $File: sendmail,v 1.10 2017/08/13 00:21:47 christos Exp $
 # sendmail:  file(1) magic for sendmail config files
 # sendmail:  file(1) magic for sendmail config files
 #
 #
 # XXX - byte order?
 # XXX - byte order?
@@ -15,7 +15,7 @@
 # http://www.sendmail.com/sm/open_source/docs/older_release_notes/
 # http://www.sendmail.com/sm/open_source/docs/older_release_notes/
 # freezed configuration file (dbm format?) created from sendmal.cf with -bz
 # freezed configuration file (dbm format?) created from sendmal.cf with -bz
 # by older sendmail. til version 8.6 support for frozen configuration files is removed
 # by older sendmail. til version 8.6 support for frozen configuration files is removed
-# valid version numbers look like "7.14.4" and should be simliar to output of commands
+# valid version numbers look like "7.14.4" and should be similar to output of commands
 # "sendmail -d0 -bt < /dev/null |grep -i Version" or "egrep '^DZ' /etc/sendmail.cf"
 # "sendmail -d0 -bt < /dev/null |grep -i Version" or "egrep '^DZ' /etc/sendmail.cf"
 >16	regex/s	=^[0-78][0-9.]{4}	Sendmail frozen configuration
 >16	regex/s	=^[0-78][0-9.]{4}	Sendmail frozen configuration
 # normally only /etc/sendmail.fc or /var/adm/sendmail/sendmail.fc
 # normally only /etc/sendmail.fc or /var/adm/sendmail/sendmail.fc

+ 7 - 7
magic/Magdir/sgml

@@ -1,10 +1,10 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sgml,v 1.36 2016/12/01 15:40:52 christos Exp $
+# $File: sgml,v 1.37 2017/07/23 08:23:33 christos Exp $
 # Type:	SVG Vectorial Graphics
 # Type:	SVG Vectorial Graphics
 # From:	Noel Torres <tecnico@ejerciciosresueltos.com>
 # From:	Noel Torres <tecnico@ejerciciosresueltos.com>
-0	string		\<?xml\ version="
->15	string		>\0
+0	string		\<?xml\ version=
+>14	regex		['"\ \t]*[0-9.]+['"\ \t]*
 >>19	search/4096	\<svg			SVG Scalable Vector Graphics image
 >>19	search/4096	\<svg			SVG Scalable Vector Graphics image
 !:mime	image/svg+xml
 !:mime	image/svg+xml
 >>19	search/4096	\<gnc-v2		GnuCash file
 >>19	search/4096	\<gnc-v2		GnuCash file
@@ -13,16 +13,16 @@
 !:mime	image/svg
 !:mime	image/svg
 
 
 # Sitemap file
 # Sitemap file
-0	string/t		\<?xml\ version="
->15	string		>\0
+0	string/t		\<?xml\ version=
+>14	regex		['"\ \t]*[0-9.]+['"\ \t]*
 >>19	search/4096	\<urlset		XML Sitemap document text
 >>19	search/4096	\<urlset		XML Sitemap document text
 !:mime	application/xml-sitemap
 !:mime	application/xml-sitemap
 
 
 # OpenStreetMap XML (.osm)
 # OpenStreetMap XML (.osm)
 # http://wiki.openstreetmap.org/wiki/OSM_XML
 # http://wiki.openstreetmap.org/wiki/OSM_XML
 # From: Markus Heidelberg <markus.heidelberg@web.de>
 # From: Markus Heidelberg <markus.heidelberg@web.de>
-0	string		\<?xml\ version="
->15	string		>\0
+0	string		\<?xml\ version=
+>14	regex		['"\ \t]*[0-9.]+['"\ \t]*
 >>19	search/4096	\<osm			OpenStreetMap XML data
 >>19	search/4096	\<osm			OpenStreetMap XML data
 
 
 # xhtml
 # xhtml

+ 2 - 2
magic/Magdir/yara

@@ -1,7 +1,7 @@
 
 
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: yara,v 1.1 2016/10/30 00:38:01 christos Exp $
+# $File: yara,v 1.2 2017/05/25 20:07:23 christos Exp $
 # yara:  file(1) magic for http://virustotal.github.io/yara/
 # yara:  file(1) magic for http://virustotal.github.io/yara/
 #
 #
 
 
@@ -9,7 +9,7 @@
 >4	lelong	>2047
 >4	lelong	>2047
 >8	byte	<20	YARA 3.x compiled rule set
 >8	byte	<20	YARA 3.x compiled rule set
 # version
 # version
->>8	clear
+>>8	clear	x
 >>8	byte	6	created with version 3.3.0
 >>8	byte	6	created with version 3.3.0
 >>8	byte	8	created with version 3.4.0
 >>8	byte	8	created with version 3.4.0
 >>8	byte	11	created with version 3.5.0
 >>8	byte	11	created with version 3.5.0

+ 3 - 1
magic/Makefile.am

@@ -1,5 +1,5 @@
 #
 #
-# $File: Makefile.am,v 1.124 2017/04/11 14:52:15 christos Exp $
+# $File: Makefile.am,v 1.126 2017/08/10 11:01:38 christos Exp $
 #
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
 MAGIC_DIR = $(top_srcdir)/magic
@@ -35,6 +35,7 @@ $(MAGIC_FRAGMENT_DIR)/audio \
 $(MAGIC_FRAGMENT_DIR)/basis \
 $(MAGIC_FRAGMENT_DIR)/basis \
 $(MAGIC_FRAGMENT_DIR)/ber \
 $(MAGIC_FRAGMENT_DIR)/ber \
 $(MAGIC_FRAGMENT_DIR)/bflt \
 $(MAGIC_FRAGMENT_DIR)/bflt \
+$(MAGIC_FRAGMENT_DIR)/bhl \
 $(MAGIC_FRAGMENT_DIR)/bioinformatics \
 $(MAGIC_FRAGMENT_DIR)/bioinformatics \
 $(MAGIC_FRAGMENT_DIR)/blackberry \
 $(MAGIC_FRAGMENT_DIR)/blackberry \
 $(MAGIC_FRAGMENT_DIR)/blcr \
 $(MAGIC_FRAGMENT_DIR)/blcr \
@@ -98,6 +99,7 @@ $(MAGIC_FRAGMENT_DIR)/fsav \
 $(MAGIC_FRAGMENT_DIR)/fusecompress \
 $(MAGIC_FRAGMENT_DIR)/fusecompress \
 $(MAGIC_FRAGMENT_DIR)/games \
 $(MAGIC_FRAGMENT_DIR)/games \
 $(MAGIC_FRAGMENT_DIR)/gcc \
 $(MAGIC_FRAGMENT_DIR)/gcc \
+$(MAGIC_FRAGMENT_DIR)/gconv \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/gimp \
 $(MAGIC_FRAGMENT_DIR)/gimp \

+ 3 - 1
magic/Makefile.in

@@ -273,7 +273,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 top_srcdir = @top_srcdir@
 
 
 #
 #
-# $File: Makefile.am,v 1.124 2017/04/11 14:52:15 christos Exp $
+# $File: Makefile.am,v 1.126 2017/08/10 11:01:38 christos Exp $
 #
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
 MAGIC_DIR = $(top_srcdir)/magic
@@ -307,6 +307,7 @@ $(MAGIC_FRAGMENT_DIR)/audio \
 $(MAGIC_FRAGMENT_DIR)/basis \
 $(MAGIC_FRAGMENT_DIR)/basis \
 $(MAGIC_FRAGMENT_DIR)/ber \
 $(MAGIC_FRAGMENT_DIR)/ber \
 $(MAGIC_FRAGMENT_DIR)/bflt \
 $(MAGIC_FRAGMENT_DIR)/bflt \
+$(MAGIC_FRAGMENT_DIR)/bhl \
 $(MAGIC_FRAGMENT_DIR)/bioinformatics \
 $(MAGIC_FRAGMENT_DIR)/bioinformatics \
 $(MAGIC_FRAGMENT_DIR)/blackberry \
 $(MAGIC_FRAGMENT_DIR)/blackberry \
 $(MAGIC_FRAGMENT_DIR)/blcr \
 $(MAGIC_FRAGMENT_DIR)/blcr \
@@ -370,6 +371,7 @@ $(MAGIC_FRAGMENT_DIR)/fsav \
 $(MAGIC_FRAGMENT_DIR)/fusecompress \
 $(MAGIC_FRAGMENT_DIR)/fusecompress \
 $(MAGIC_FRAGMENT_DIR)/games \
 $(MAGIC_FRAGMENT_DIR)/games \
 $(MAGIC_FRAGMENT_DIR)/gcc \
 $(MAGIC_FRAGMENT_DIR)/gcc \
+$(MAGIC_FRAGMENT_DIR)/gconv \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/gimp \
 $(MAGIC_FRAGMENT_DIR)/gimp \

+ 119 - 40
src/apprentice.c

@@ -32,7 +32,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.260 2017/04/28 16:27:58 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.262 2017/08/28 13:39:18 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -612,8 +612,7 @@ buffer_apprentice(struct magic_set *ms, struct magic **bufs,
 	if (nbufs == 0)
 	if (nbufs == 0)
 		return -1;
 		return -1;
 
 
-	if (ms->mlist[0] != NULL)
-		file_reset(ms);
+	(void)file_reset(ms, 0);
 
 
 	init_file_tables();
 	init_file_tables();
 
 
@@ -656,8 +655,7 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
 	int file_err, errs = -1;
 	int file_err, errs = -1;
 	size_t i;
 	size_t i;
 
 
-	if (ms->mlist[0] != NULL)
-		file_reset(ms);
+	(void)file_reset(ms, 0);
 
 
 	if ((fn = magic_getpath(fn, action)) == NULL)
 	if ((fn = magic_getpath(fn, action)) == NULL)
 		return -1;
 		return -1;
@@ -779,6 +777,59 @@ nonmagic(const char *str)
 	return rv == 0 ? 1 : rv;	/* Return at least 1 */
 	return rv == 0 ? 1 : rv;	/* Return at least 1 */
 }
 }
 
 
+
+private size_t
+typesize(int type)
+{
+	switch (type) {
+	case FILE_BYTE:
+		return 1;
+
+	case FILE_SHORT:
+	case FILE_LESHORT:
+	case FILE_BESHORT:
+		return 2;
+
+	case FILE_LONG:
+	case FILE_LELONG:
+	case FILE_BELONG:
+	case FILE_MELONG:
+		return 4;
+
+	case FILE_DATE:
+	case FILE_LEDATE:
+	case FILE_BEDATE:
+	case FILE_MEDATE:
+	case FILE_LDATE:
+	case FILE_LELDATE:
+	case FILE_BELDATE:
+	case FILE_MELDATE:
+	case FILE_FLOAT:
+	case FILE_BEFLOAT:
+	case FILE_LEFLOAT:
+		return 4;
+
+	case FILE_QUAD:
+	case FILE_BEQUAD:
+	case FILE_LEQUAD:
+	case FILE_QDATE:
+	case FILE_LEQDATE:
+	case FILE_BEQDATE:
+	case FILE_QLDATE:
+	case FILE_LEQLDATE:
+	case FILE_BEQLDATE:
+	case FILE_QWDATE:
+	case FILE_LEQWDATE:
+	case FILE_BEQWDATE:
+	case FILE_DOUBLE:
+	case FILE_BEDOUBLE:
+	case FILE_LEDOUBLE:
+		return 8;
+	default:
+		return (size_t)~0;
+	}
+}
+
 /*
 /*
  * Get weight of this magic entry, for sorting purposes.
  * Get weight of this magic entry, for sorting purposes.
  */
  */
@@ -786,7 +837,7 @@ private size_t
 apprentice_magic_strength(const struct magic *m)
 apprentice_magic_strength(const struct magic *m)
 {
 {
 #define MULT 10
 #define MULT 10
-	size_t v, val = 2 * MULT;	/* baseline strength */
+	size_t ts, v, val = 2 * MULT;	/* baseline strength */
 
 
 	switch (m->type) {
 	switch (m->type) {
 	case FILE_DEFAULT:	/* make sure this sorts last */
 	case FILE_DEFAULT:	/* make sure this sorts last */
@@ -795,41 +846,13 @@ apprentice_magic_strength(const struct magic *m)
 		return 0;
 		return 0;
 
 
 	case FILE_BYTE:
 	case FILE_BYTE:
-		val += 1 * MULT;
-		break;
-
 	case FILE_SHORT:
 	case FILE_SHORT:
 	case FILE_LESHORT:
 	case FILE_LESHORT:
 	case FILE_BESHORT:
 	case FILE_BESHORT:
-		val += 2 * MULT;
-		break;
-
 	case FILE_LONG:
 	case FILE_LONG:
 	case FILE_LELONG:
 	case FILE_LELONG:
 	case FILE_BELONG:
 	case FILE_BELONG:
 	case FILE_MELONG:
 	case FILE_MELONG:
-		val += 4 * MULT;
-		break;
-
-	case FILE_PSTRING:
-	case FILE_STRING:
-		val += m->vallen * MULT;
-		break;
-
-	case FILE_BESTRING16:
-	case FILE_LESTRING16:
-		val += m->vallen * MULT / 2;
-		break;
-
-	case FILE_SEARCH:
-		val += m->vallen * MAX(MULT / m->vallen, 1);
-		break;
-
-	case FILE_REGEX:
-		v = nonmagic(m->value.s);
-		val += v * MAX(MULT / v, 1);
-		break;
-
 	case FILE_DATE:
 	case FILE_DATE:
 	case FILE_LEDATE:
 	case FILE_LEDATE:
 	case FILE_BEDATE:
 	case FILE_BEDATE:
@@ -841,9 +864,6 @@ apprentice_magic_strength(const struct magic *m)
 	case FILE_FLOAT:
 	case FILE_FLOAT:
 	case FILE_BEFLOAT:
 	case FILE_BEFLOAT:
 	case FILE_LEFLOAT:
 	case FILE_LEFLOAT:
-		val += 4 * MULT;
-		break;
-
 	case FILE_QUAD:
 	case FILE_QUAD:
 	case FILE_BEQUAD:
 	case FILE_BEQUAD:
 	case FILE_LEQUAD:
 	case FILE_LEQUAD:
@@ -859,7 +879,29 @@ apprentice_magic_strength(const struct magic *m)
 	case FILE_DOUBLE:
 	case FILE_DOUBLE:
 	case FILE_BEDOUBLE:
 	case FILE_BEDOUBLE:
 	case FILE_LEDOUBLE:
 	case FILE_LEDOUBLE:
-		val += 8 * MULT;
+		ts = typesize(m->type);
+		if (ts == (size_t)~0)
+			abort();
+		val += ts * MULT;
+		break;
+
+	case FILE_PSTRING:
+	case FILE_STRING:
+		val += m->vallen * MULT;
+		break;
+
+	case FILE_BESTRING16:
+	case FILE_LESTRING16:
+		val += m->vallen * MULT / 2;
+		break;
+
+	case FILE_SEARCH:
+		val += m->vallen * MAX(MULT / m->vallen, 1);
+		break;
+
+	case FILE_REGEX:
+		v = nonmagic(m->value.s);
+		val += v * MAX(MULT / v, 1);
 		break;
 		break;
 
 
 	case FILE_INDIRECT:
 	case FILE_INDIRECT:
@@ -2623,9 +2665,46 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
 	default:
 	default:
 		if (m->reln != 'x') {
 		if (m->reln != 'x') {
 			char *ep;
 			char *ep;
+			uint64_t ull;
 			errno = 0;
 			errno = 0;
-			m->value.q = file_signextend(ms, m,
-			    (uint64_t)strtoull(*p, &ep, 0));
+			ull = (uint64_t)strtoull(*p, &ep, 0);
+			m->value.q = file_signextend(ms, m, ull);
+			if (*p == ep) {
+				file_magwarn(ms, "Unparseable number `%s'", *p);
+			} else {
+				size_t ts = typesize(m->type);
+				uint64_t x;
+				const char *q;
+
+				if (ts == (size_t)~0) {
+					file_magwarn(ms, "Expected numeric type got `%s'",
+					    type_tbl[m->type].name);
+				}
+				for (q = *p; isspace((unsigned char)*q); q++)
+					continue;
+				if (*q == '-')
+					ull = -(int64_t)ull;
+				switch (ts) {
+				case 1:
+					x = ull & ~0xffULL;
+					break;
+				case 2:
+					x = ull & ~0xffffULL;
+					break;
+				case 4:
+					x = ull & ~0xffffffffULL;
+					break;
+				case 8:
+					x = 0;
+					break;
+				default:
+					abort();
+				}
+				if (x) {
+					file_magwarn(ms, "Overflow for numeric type `%s' value %#" PRIx64,
+					    type_tbl[m->type].name, ull);
+				}
+			}
 			if (errno == 0) {
 			if (errno == 0) {
 				*p = ep;
 				*p = ep;
 				eatsize(p);
 				eatsize(p);

+ 2 - 2
src/compress.c

@@ -35,7 +35,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.104 2017/03/29 15:57:48 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.105 2017/05/25 00:13:03 christos Exp $")
 #endif
 #endif
 
 
 #include "magic.h"
 #include "magic.h"
@@ -751,7 +751,7 @@ err:
 	} else if (!WIFEXITED(status)) {
 	} else if (!WIFEXITED(status)) {
 		DPRINTF("Child not exited (%#x)\n", status);
 		DPRINTF("Child not exited (%#x)\n", status);
 	} else if (WEXITSTATUS(status) != 0) {
 	} else if (WEXITSTATUS(status) != 0) {
-		DPRINTF("Child exited (%#u)\n", WEXITSTATUS(status));
+		DPRINTF("Child exited (%#x)\n", WEXITSTATUS(status));
 	}
 	}
 
 
 	closefd(fdp[STDIN_FILENO], 0);
 	closefd(fdp[STDIN_FILENO], 0);

+ 2 - 2
src/file.h

@@ -27,7 +27,7 @@
  */
  */
 /*
 /*
  * file.h - definitions for file(1) program
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.182 2017/04/07 19:46:44 christos Exp $
+ * @(#)$File: file.h,v 1.183 2017/08/28 13:39:18 christos Exp $
  */
  */
 
 
 #ifndef __file_h__
 #ifndef __file_h__
@@ -447,7 +447,7 @@ protected size_t file_printedlen(const struct magic_set *);
 protected int file_replace(struct magic_set *, const char *, const char *);
 protected int file_replace(struct magic_set *, const char *, const char *);
 protected int file_printf(struct magic_set *, const char *, ...)
 protected int file_printf(struct magic_set *, const char *, ...)
     __attribute__((__format__(__printf__, 2, 3)));
     __attribute__((__format__(__printf__, 2, 3)));
-protected int file_reset(struct magic_set *);
+protected int file_reset(struct magic_set *, int);
 protected int file_tryelf(struct magic_set *, int, const unsigned char *,
 protected int file_tryelf(struct magic_set *, int, const unsigned char *,
     size_t);
     size_t);
 protected int file_trycdf(struct magic_set *, int, const unsigned char *,
 protected int file_trycdf(struct magic_set *, int, const unsigned char *,

+ 14 - 5
src/fsmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.76 2015/04/09 20:01:41 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.77 2017/05/24 19:17:50 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -104,14 +104,13 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 {
 {
 	int ret, did = 0;
 	int ret, did = 0;
 	int mime = ms->flags & MAGIC_MIME;
 	int mime = ms->flags & MAGIC_MIME;
+	int silent = ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION);
 #ifdef	S_IFLNK
 #ifdef	S_IFLNK
 	char buf[BUFSIZ+4];
 	char buf[BUFSIZ+4];
 	ssize_t nch;
 	ssize_t nch;
 	struct stat tstatbuf;
 	struct stat tstatbuf;
 #endif
 #endif
 
 
-	if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))
-		return 0;
 	if (fn == NULL)
 	if (fn == NULL)
 		return 0;
 		return 0;
 
 
@@ -168,7 +167,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 	}
 	}
 
 
 	ret = 1;
 	ret = 1;
-	if (!mime) {
+	if (!mime && !silent) {
 #ifdef S_ISUID
 #ifdef S_ISUID
 		if (sb->st_mode & S_ISUID)
 		if (sb->st_mode & S_ISUID)
 			if (file_printf(ms, "%ssetuid", COMMA) == -1)
 			if (file_printf(ms, "%ssetuid", COMMA) == -1)
@@ -191,6 +190,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "directory") == -1)
 			if (handle_mime(ms, mime, "directory") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else if (file_printf(ms, "%sdirectory", COMMA) == -1)
 		} else if (file_printf(ms, "%sdirectory", COMMA) == -1)
 			return -1;
 			return -1;
 		break;
 		break;
@@ -208,6 +208,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "chardevice") == -1)
 			if (handle_mime(ms, mime, "chardevice") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else {
 		} else {
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
 # ifdef dv_unit
 # ifdef dv_unit
@@ -242,6 +243,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "blockdevice") == -1)
 			if (handle_mime(ms, mime, "blockdevice") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else {
 		} else {
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
 # ifdef dv_unit
 # ifdef dv_unit
@@ -270,6 +272,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "fifo") == -1)
 			if (handle_mime(ms, mime, "fifo") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else if (file_printf(ms, "%sfifo (named pipe)", COMMA) == -1)
 		} else if (file_printf(ms, "%sfifo (named pipe)", COMMA) == -1)
 			return -1;
 			return -1;
 		break;
 		break;
@@ -279,6 +282,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "door") == -1)
 			if (handle_mime(ms, mime, "door") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else if (file_printf(ms, "%sdoor", COMMA) == -1)
 		} else if (file_printf(ms, "%sdoor", COMMA) == -1)
 			return -1;
 			return -1;
 		break;
 		break;
@@ -294,6 +298,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (mime) {
 			if (mime) {
 				if (handle_mime(ms, mime, "symlink") == -1)
 				if (handle_mime(ms, mime, "symlink") == -1)
 					return -1;
 					return -1;
+			} else if (silent) {
 			} else if (file_printf(ms,
 			} else if (file_printf(ms,
 			    "%sunreadable symlink `%s' (%s)", COMMA, fn,
 			    "%sunreadable symlink `%s' (%s)", COMMA, fn,
 			    strerror(errno)) == -1)
 			    strerror(errno)) == -1)
@@ -323,6 +328,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 						if (handle_mime(ms, mime,
 						if (handle_mime(ms, mime,
 						    "x-path-too-long") == -1)
 						    "x-path-too-long") == -1)
 							return -1;
 							return -1;
+					} else if (silent) {
 					} else if (file_printf(ms,
 					} else if (file_printf(ms,
 					    "%spath too long: `%s'", COMMA,
 					    "%spath too long: `%s'", COMMA,
 					    fn) == -1)
 					    fn) == -1)
@@ -352,6 +358,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (mime) {
 			if (mime) {
 				if (handle_mime(ms, mime, "symlink") == -1)
 				if (handle_mime(ms, mime, "symlink") == -1)
 					return -1;
 					return -1;
+			} else if (silent) {
 			} else if (file_printf(ms, "%ssymbolic link to %s",
 			} else if (file_printf(ms, "%ssymbolic link to %s",
 			    COMMA, buf) == -1)
 			    COMMA, buf) == -1)
 				return -1;
 				return -1;
@@ -364,6 +371,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 		if (mime) {
 			if (handle_mime(ms, mime, "socket") == -1)
 			if (handle_mime(ms, mime, "socket") == -1)
 				return -1;
 				return -1;
+		} else if (silent) {
 		} else if (file_printf(ms, "%ssocket", COMMA) == -1)
 		} else if (file_printf(ms, "%ssocket", COMMA) == -1)
 			return -1;
 			return -1;
 		break;
 		break;
@@ -386,6 +394,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (mime) {
 			if (mime) {
 				if (handle_mime(ms, mime, "x-empty") == -1)
 				if (handle_mime(ms, mime, "x-empty") == -1)
 					return -1;
 					return -1;
+			} else if (silent) {
 			} else if (file_printf(ms, "%sempty", COMMA) == -1)
 			} else if (file_printf(ms, "%sempty", COMMA) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
@@ -399,7 +408,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		/*NOTREACHED*/
 		/*NOTREACHED*/
 	}
 	}
 
 
-	if (!mime && did && ret == 0) {
+	if (!silent && !mime && did && ret == 0) {
 	    if (file_printf(ms, " ") == -1)
 	    if (file_printf(ms, " ") == -1)
 		    return -1;
 		    return -1;
 	}
 	}

+ 3 - 3
src/funcs.c

@@ -27,7 +27,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.92 2017/04/07 20:10:24 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.93 2017/08/28 13:39:18 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -328,9 +328,9 @@ simple:
 #endif
 #endif
 
 
 protected int
 protected int
-file_reset(struct magic_set *ms)
+file_reset(struct magic_set *ms, int checkloaded)
 {
 {
-	if (ms->mlist[0] == NULL) {
+	if (checkloaded && ms->mlist[0] == NULL) {
 		file_error(ms, 0, "no magic files loaded");
 		file_error(ms, 0, "no magic files loaded");
 		return -1;
 		return -1;
 	}
 	}

+ 13 - 4
src/magic.c

@@ -33,7 +33,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: magic.c,v 1.100 2016/07/18 11:43:05 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.102 2017/08/28 13:39:18 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -167,7 +167,7 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 {
 {
 	if (fdwReason == DLL_PROCESS_ATTACH)
 	if (fdwReason == DLL_PROCESS_ATTACH)
 		_w32_dll_instance = hinstDLL;
 		_w32_dll_instance = hinstDLL;
-	return TRUE;
+	return 1;
 }
 }
 #endif
 #endif
 
 
@@ -409,7 +409,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 	int	ispipe = 0;
 	int	ispipe = 0;
 	off_t	pos = (off_t)-1;
 	off_t	pos = (off_t)-1;
 
 
-	if (file_reset(ms) == -1)
+	if (file_reset(ms, 1) == -1)
 		goto out;
 		goto out;
 
 
 	/*
 	/*
@@ -538,7 +538,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
 {
 {
 	if (ms == NULL)
 	if (ms == NULL)
 		return NULL;
 		return NULL;
-	if (file_reset(ms) == -1)
+	if (file_reset(ms, 1) == -1)
 		return NULL;
 		return NULL;
 	/*
 	/*
 	 * The main work is done here!
 	 * The main work is done here!
@@ -568,6 +568,15 @@ magic_errno(struct magic_set *ms)
 }
 }
 
 
 public int
 public int
+magic_getflags(struct magic_set *ms)
+{
+	if (ms == NULL)
+		return -1;
+
+	return ms->flags;
+}
+
+public int
 magic_setflags(struct magic_set *ms, int flags)
 magic_setflags(struct magic_set *ms, int flags)
 {
 {
 	if (ms == NULL)
 	if (ms == NULL)

+ 30 - 0
src/magic.h.in

@@ -73,6 +73,35 @@
 	0			  \
 	0			  \
 )
 )
 
 
+#define MAGIC_SNPRINTB "\177\020\
+b\0debug\0\
+b\1symlink\0\
+b\2compress\0\
+b\3devices\0\
+b\4mime_type\0\
+b\5continue\0\
+b\6check\0\
+b\7preserve_atime\0\
+b\10raw\0\
+b\11error\0\
+b\12mime_encoding\0\
+b\13apple\0\
+b\14no_check_compress\0\
+b\15no_check_tar\0\
+b\16no_check_soft\0\
+b\17no_check_sapptype\0\
+b\20no_check_elf\0\
+b\21no_check_text\0\
+b\22no_check_cdf\0\
+b\23no_check_reserved0\0\
+b\24no_check_tokens\0\
+b\25no_check_encoding\0\
+b\26no_check_reserved1\0\
+b\27no_check_reserved2\0\
+b\30extension\0\
+b\31transp_compression\0\
+"
+
 /* Defined for backwards compatibility (renamed) */
 /* Defined for backwards compatibility (renamed) */
 #define	MAGIC_NO_CHECK_ASCII	MAGIC_NO_CHECK_TEXT
 #define	MAGIC_NO_CHECK_ASCII	MAGIC_NO_CHECK_TEXT
 
 
@@ -97,6 +126,7 @@ const char *magic_descriptor(magic_t, int);
 const char *magic_buffer(magic_t, const void *, size_t);
 const char *magic_buffer(magic_t, const void *, size_t);
 
 
 const char *magic_error(magic_t);
 const char *magic_error(magic_t);
+int magic_getflags(magic_t);
 int magic_setflags(magic_t, int);
 int magic_setflags(magic_t, int);
 
 
 int magic_version(void);
 int magic_version(void);

+ 4 - 4
src/readelf.c

@@ -27,7 +27,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.136 2017/03/29 19:09:52 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.138 2017/08/27 07:55:02 christos Exp $")
 #endif
 #endif
 
 
 #ifdef BUILTIN_ELF
 #ifdef BUILTIN_ELF
@@ -511,7 +511,7 @@ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
     size_t noff, size_t doff, int *flags)
     size_t noff, size_t doff, int *flags)
 {
 {
 	if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
 	if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
-	    type == NT_GNU_BUILD_ID && (descsz >= 4 || descsz <= 20)) {
+	    type == NT_GNU_BUILD_ID && (descsz >= 4 && descsz <= 20)) {
 		uint8_t desc[20];
 		uint8_t desc[20];
 		const char *btype;
 		const char *btype;
 		uint32_t i;
 		uint32_t i;
@@ -1209,8 +1209,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 	size_t nbadcap = 0;
 	size_t nbadcap = 0;
 	void *nbuf;
 	void *nbuf;
 	off_t noff, coff, name_off;
 	off_t noff, coff, name_off;
-	uint64_t cap_hw1 = 0;	/* SunOS 5.x hardware capabilites */
-	uint64_t cap_sf1 = 0;	/* SunOS 5.x software capabilites */
+	uint64_t cap_hw1 = 0;	/* SunOS 5.x hardware capabilities */
+	uint64_t cap_sf1 = 0;	/* SunOS 5.x software capabilities */
 	char name[50];
 	char name[50];
 	ssize_t namesize;
 	ssize_t namesize;
 
 

+ 1 - 1
src/readelf.h

@@ -141,7 +141,7 @@ typedef struct {
 #define	SHT_SYMTAB	2
 #define	SHT_SYMTAB	2
 #define	SHT_NOTE	7
 #define	SHT_NOTE	7
 #define	SHT_DYNSYM	11
 #define	SHT_DYNSYM	11
-#define	SHT_SUNW_cap	0x6ffffff5	/* SunOS 5.x hw/sw capabilites */
+#define	SHT_SUNW_cap	0x6ffffff5	/* SunOS 5.x hw/sw capabilities */
 
 
 /* elf type */
 /* elf type */
 #define	ELFDATANONE	0		/* e_ident[EI_DATA] */
 #define	ELFDATANONE	0		/* e_ident[EI_DATA] */

+ 2 - 2
src/softmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.248 2017/04/21 16:54:57 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.249 2017/06/19 18:30:25 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -1199,7 +1199,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 			const char *end;
 			const char *end;
 			size_t lines, linecnt, bytecnt;
 			size_t lines, linecnt, bytecnt;
 
 
-			if (s == NULL) {
+			if (s == NULL || nbytes < offset) {
 				ms->search.s_len = 0;
 				ms->search.s_len = 0;
 				ms->search.s = NULL;
 				ms->search.s = NULL;
 				return 0;
 				return 0;

+ 2 - 2
src/vasprintf.c

@@ -88,7 +88,7 @@ type:  d i o u x X f e g E G c s p n
 
 
 
 
 The function needs to allocate memory to store the full text before to
 The function needs to allocate memory to store the full text before to
-actually writting it.  i.e if you want to fnprintf() 1000 characters, the
+actually writing it.  i.e if you want to fnprintf() 1000 characters, the
 functions will allocate 1000 bytes.
 functions will allocate 1000 bytes.
 This behaviour can be modified: you have to customise the code to flush the
 This behaviour can be modified: you have to customise the code to flush the
 internal buffer (writing to screen or file) when it reach a given size. Then
 internal buffer (writing to screen or file) when it reach a given size. Then
@@ -108,7 +108,7 @@ you use strange formats.
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.14 2017/08/13 00:21:47 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include <assert.h>
 #include <assert.h>

+ 2 - 0
tests/Makefile.am

@@ -7,6 +7,8 @@ escapevel.result \
 escapevel.testfile \
 escapevel.testfile \
 gedcom.result \
 gedcom.result \
 gedcom.testfile \
 gedcom.testfile \
+hddrawcopytool.result \
+hddrawcopytool.testfile \
 issue311docx.result \
 issue311docx.result \
 issue311docx.testfile
 issue311docx.testfile
 
 

+ 2 - 0
tests/Makefile.in

@@ -296,6 +296,8 @@ escapevel.result \
 escapevel.testfile \
 escapevel.testfile \
 gedcom.result \
 gedcom.result \
 gedcom.testfile \
 gedcom.testfile \
+hddrawcopytool.result \
+hddrawcopytool.testfile \
 issue311docx.result \
 issue311docx.result \
 issue311docx.testfile
 issue311docx.testfile
 
 

+ 1 - 0
tests/hddrawcopytool.result

@@ -0,0 +1 @@
+HDD Raw Copy Tool 1.10 - HD model: ST500DM0 02-1BD142 serial: 51D20233A7C0

BIN
tests/hddrawcopytool.testfile


+ 2 - 1
tests/test.c

@@ -80,7 +80,8 @@ main(int argc, char **argv)
 		return 10;
 		return 10;
 	}
 	}
 	if (magic_load(ms, NULL) == -1) {
 	if (magic_load(ms, NULL) == -1) {
-		(void)fprintf(stderr, "ERROR loading with NULL file: %s\n", magic_error(ms));
+		(void)fprintf(stderr, "ERROR loading with NULL file: %s\n",
+		    magic_error(ms));
 		return 11;
 		return 11;
 	}
 	}