Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/file resolve conflicts
details: https://anonhg.NetBSD.org/src/rev/0badf83121a6
branches: trunk
changeset: 513055:0badf83121a6
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Jul 22 22:53:00 2001 +0000
description:
resolve conflicts
diffstat:
usr.bin/file/apprentice.c | 217 ++++++++++++--
usr.bin/file/compress.c | 89 +++++-
usr.bin/file/config.h | 2 +-
usr.bin/file/file.1 | 24 +-
usr.bin/file/file.c | 35 +-
usr.bin/file/file.h | 26 +-
usr.bin/file/magdir/animation | 20 +-
usr.bin/file/magdir/apple | 28 +-
usr.bin/file/magdir/archive | 2 +
usr.bin/file/magdir/audio | 10 +-
usr.bin/file/magdir/database | 6 +-
usr.bin/file/magdir/elf | 33 +-
usr.bin/file/magdir/filesystems | 17 +-
usr.bin/file/magdir/freebsd | 9 +
usr.bin/file/magdir/images | 18 +
usr.bin/file/magdir/jpeg | 4 +-
usr.bin/file/magdir/magic | 4 +-
usr.bin/file/magdir/mail.news | 4 +
usr.bin/file/magdir/motorola | 18 +
usr.bin/file/magdir/msdos | 6 +-
usr.bin/file/magdir/sniffer | 28 +-
usr.bin/file/magdir/softquad | 1 -
usr.bin/file/magic.5 | 4 +-
usr.bin/file/magic.mime | 12 +-
usr.bin/file/patchlevel.h | 19 +-
usr.bin/file/print.c | 82 +++-
usr.bin/file/softmagic.c | 596 +++++++++++++++++++++++++++++++++++++--
27 files changed, 1120 insertions(+), 194 deletions(-)
diffs (truncated from 2211 to 300 lines):
diff -r d9868ecf4d09 -r 0badf83121a6 usr.bin/file/apprentice.c
--- a/usr.bin/file/apprentice.c Sun Jul 22 22:31:55 2001 +0000
+++ b/usr.bin/file/apprentice.c Sun Jul 22 22:53:00 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apprentice.c,v 1.23 2001/05/09 14:05:52 simonb Exp $ */
+/* $NetBSD: apprentice.c,v 1.24 2001/07/22 22:53:00 pooka Exp $ */
/*
* apprentice - make one pass through /etc/magic, learning its secrets.
@@ -27,6 +27,7 @@
* 4. This notice may not be removed or altered.
*/
+#include "file.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -35,17 +36,17 @@
#ifdef QUICK
#include <fcntl.h>
#include <unistd.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#endif
-#include "file.h"
#include <sys/cdefs.h>
#ifndef lint
#if 0
-FILE_RCSID("@(#)Id: apprentice.c,v 1.34 2001/03/11 20:29:16 christos Exp ")
+FILE_RCSID("@(#)Id: apprentice.c,v 1.42 2001/07/22 21:04:15 christos Exp ")
#else
-__RCSID("$NetBSD: apprentice.c,v 1.23 2001/05/09 14:05:52 simonb Exp $");
+__RCSID("$NetBSD: apprentice.c,v 1.24 2001/07/22 22:53:00 pooka Exp $");
#endif
#endif /* lint */
@@ -53,7 +54,23 @@
isspace((unsigned char) *l)) ++l;}
#define LOWCASE(l) (isupper((unsigned char) (l)) ? \
tolower((unsigned char) (l)) : (l))
+/*
+ * Work around a bug in headers on Digital Unix.
+ * At least confirmed for: OSF1 V4.0 878
+ */
+#if defined(__osf__) && defined(__DECC)
+#ifdef MAP_FAILED
+#undef MAP_FAILED
+#endif
+#endif
+#ifndef MAP_FAILED
+#define MAP_FAILED (void *) -1
+#endif
+
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
#ifdef __EMX__
char PATHSEP=';';
@@ -70,17 +87,15 @@
static int apprentice_1 __P((const char *, int));
static int apprentice_file __P((struct magic **, uint32 *,
const char *, int));
-#ifdef QUICK
static void byteswap __P((struct magic *, uint32));
static void bs1 __P((struct magic *));
static uint16 swap2 __P((uint16));
static uint32 swap4 __P((uint32));
-static char * mkdbname __P((const char *));
+static char *mkdbname __P((const char *));
static int apprentice_map __P((struct magic **, uint32 *,
const char *, int));
static int apprentice_compile __P((struct magic **, uint32 *,
const char *, int));
-#endif
static int maxmagic = 0;
@@ -129,7 +144,6 @@
struct mlist *ml;
int rv = -1;
-#ifdef QUICK
if (action == COMPILE) {
rv = apprentice_file(&magic, &nmagic, fn, action);
if (rv == 0)
@@ -141,10 +155,7 @@
if ((rv = apprentice_map(&magic, &nmagic, fn, action)) != 0)
(void)fprintf(stderr, "%s: Using regular magic file `%s'\n",
progname, fn);
-#endif /* COMPILE_ONLY */
-#endif /* QUICK */
-#ifndef COMPILE_ONLY
if (rv != 0)
rv = apprentice_file(&magic, &nmagic, fn, action);
@@ -152,7 +163,8 @@
return rv;
if ((ml = malloc(sizeof(*ml))) == NULL) {
- (void) fprintf(stderr, "%s: Out of memory.\n", progname);
+ (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
+ strerror(errno));
if (action == CHECK)
return -1;
}
@@ -184,7 +196,8 @@
mlist.next = mlist.prev = &mlist;
mfn = malloc(strlen(fn)+1);
if (mfn == NULL) {
- (void) fprintf(stderr, "%s: Out of memory.\n", progname);
+ (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
+ strerror(errno));
if (action == CHECK)
return -1;
else
@@ -239,7 +252,8 @@
maxmagic = MAXMAGIS;
*magicp = (struct magic *) calloc(sizeof(struct magic), maxmagic);
if (*magicp == NULL) {
- (void) fprintf(stderr, "%s: Out of memory.\n", progname);
+ (void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
+ strerror(errno));
if (action == CHECK)
return -1;
}
@@ -293,12 +307,16 @@
case DATE:
case BEDATE:
case LEDATE:
+ case LDATE:
+ case BELDATE:
+ case LELDATE:
case LONG:
case BELONG:
case LELONG:
v = (int32) v;
break;
case STRING:
+ case PSTRING:
break;
default:
magwarn("can't happen: m->type=%d\n",
@@ -327,8 +345,8 @@
maxmagic += ALLOC_INCR;
if ((m = (struct magic *) realloc(*magicp,
sizeof(struct magic) * maxmagic)) == NULL) {
- (void) fprintf(stderr, "%s: Out of memory.\n",
- progname);
+ (void) fprintf(stderr, "%s: Out of memory (%s).\n",
+ progname, strerror(errno));
if (*magicp)
free(*magicp);
if (action == CHECK)
@@ -355,7 +373,7 @@
}
if (m->cont_level != 0 && *l == '&') {
++l; /* step over */
- m->flag |= ADD;
+ m->flag |= OFFADD;
}
/* get offset, then skip over it */
@@ -399,12 +417,46 @@
}
l++;
}
- s = l;
- if (*l == '+' || *l == '-') l++;
- if (isdigit((unsigned char)*l)) {
+ if (*l == '~') {
+ m->in_op = OPINVERSE;
+ l++;
+ }
+ switch (*l) {
+ case '&':
+ m->in_op |= OPAND;
+ l++;
+ break;
+ case '|':
+ m->in_op |= OPOR;
+ l++;
+ break;
+ case '^':
+ m->in_op |= OPXOR;
+ l++;
+ break;
+ case '+':
+ m->in_op |= OPADD;
+ l++;
+ break;
+ case '-':
+ m->in_op |= OPMINUS;
+ l++;
+ break;
+ case '*':
+ m->in_op |= OPMULTIPLY;
+ l++;
+ break;
+ case '/':
+ m->in_op |= OPDIVIDE;
+ l++;
+ break;
+ case '%':
+ m->in_op |= OPMODULO;
+ l++;
+ break;
+ }
+ if (isdigit((unsigned char)*l))
m->in_offset = strtoul(l, &t, 0);
- if (*s == '-') m->in_offset = - m->in_offset;
- }
else
t = l;
if (*t++ != ')')
@@ -428,6 +480,10 @@
#define NLESHORT 7
#define NLELONG 6
#define NLEDATE 6
+#define NPSTRING 7
+#define NLDATE 5
+#define NBELDATE 7
+#define NLELDATE 7
if (*l == 'u') {
++l;
@@ -471,18 +527,80 @@
} else if (strncmp(l, "ledate", NLEDATE)==0) {
m->type = LEDATE;
l += NLEDATE;
+ } else if (strncmp(l, "pstring", NPSTRING)==0) {
+ m->type = PSTRING;
+ l += NPSTRING;
+ } else if (strncmp(l, "ldate", NLDATE)==0) {
+ m->type = LDATE;
+ l += NLDATE;
+ } else if (strncmp(l, "beldate", NBELDATE)==0) {
+ m->type = BELDATE;
+ l += NBELDATE;
+ } else if (strncmp(l, "leldate", NLELDATE)==0) {
+ m->type = LELDATE;
+ l += NLELDATE;
} else {
magwarn("type %s invalid", l);
return -1;
}
/* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
- if (*l == '&') {
+ /* New and improved: ~ & | ^ + - * / % -- exciting, isn't it? */
+ if (*l == '~') {
+ if (STRING != m->type && PSTRING != m->type)
+ m->mask_op = OPINVERSE;
+ ++l;
+ }
+ switch (*l) {
+ case '&':
+ m->mask_op |= OPAND;
+ ++l;
+ m->mask = signextend(m, strtoul(l, &l, 0));
+ eatsize(&l);
+ break;
+ case '|':
+ m->mask_op |= OPOR;
+ ++l;
+ m->mask = signextend(m, strtoul(l, &l, 0));
+ eatsize(&l);
+ break;
+ case '^':
+ m->mask_op |= OPXOR;
++l;
m->mask = signextend(m, strtoul(l, &l, 0));
eatsize(&l);
- } else if (STRING == m->type) {
- m->mask = 0L;
- if (*l == '/') {
+ break;
+ case '+':
+ m->mask_op |= OPADD;
+ ++l;
+ m->mask = signextend(m, strtoul(l, &l, 0));
+ eatsize(&l);
+ break;
+ case '-':
+ m->mask_op |= OPMINUS;
+ ++l;
+ m->mask = signextend(m, strtoul(l, &l, 0));
+ eatsize(&l);
+ break;
+ case '*':
+ m->mask_op |= OPMULTIPLY;
+ ++l;
+ m->mask = signextend(m, strtoul(l, &l, 0));
+ eatsize(&l);
+ break;
+ case '%':
+ m->mask_op |= OPMODULO;
Home |
Main Index |
Thread Index |
Old Index