From: Reuben Thomas Date: Sun, 24 Feb 2008 01:13:13 +0000 (+0000) Subject: Change magic.nospflag to a flag bit in magic.flag. X-Git-Tag: FILE5_05~450 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9835e378b57cf7b13c11d9aea06439c93424ab5;p=file Change magic.nospflag to a flag bit in magic.flag. --- diff --git a/src/apprentice.c b/src/apprentice.c index 415b9de6..1119468d 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -49,7 +49,7 @@ #include #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.124 2008/02/19 18:38:38 rrt Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.125 2008/02/24 01:13:13 rrt Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -1211,13 +1211,12 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp, EATAB; if (l[0] == '\b') { ++l; - m->nospflag = 1; + m->flag |= NOSPACE; } else if ((l[0] == '\\') && (l[1] == 'b')) { ++l; ++l; - m->nospflag = 1; - } else - m->nospflag = 0; + m->flag |= NOSPACE; + } for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); ) continue; if (i == sizeof(m->desc)) { diff --git a/src/file.h b/src/file.h index 1670ca78..4fafffa8 100644 --- a/src/file.h +++ b/src/file.h @@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.99 2008/02/24 01:06:08 rrt Exp $ + * @(#)$File: file.h,v 1.100 2008/02/24 01:13:13 rrt Exp $ */ #ifndef __file_h__ @@ -107,18 +107,21 @@ struct magic { /* Word 1 */ uint16_t cont_level; /* level of ">" */ - uint8_t nospflag; /* supress space character */ uint8_t flag; #define INDIR 1 /* if '(...)' appears */ #define OFFADD 2 /* if '>&' or '>...(&' appears */ #define INDIROFFADD 4 /* if '>&(' appears */ #define UNSIGNED 8 /* comparison is unsigned */ +#define NOSPACE 16 /* suppress space character before output */ +#define TEXTTEST 32 /* test is for a text type (set only + for top-level tests) */ + uint8_t dummy1; /* Word 2 */ uint8_t reln; /* relation (0=eq, '>'=gt, etc) */ uint8_t vallen; /* length of string value, if any */ - uint8_t type; /* int, short, long or string. */ - uint8_t in_type; /* type of indirrection */ + uint8_t type; /* comparison type (FILE_*) */ + uint8_t in_type; /* type of indirection */ #define FILE_INVALID 0 #define FILE_BYTE 1 #define FILE_SHORT 2 @@ -181,10 +184,10 @@ struct magic { uint8_t mask_op; /* operator for mask */ #ifdef ENABLE_CONDITIONALS uint8_t cond; /* conditional type */ - uint8_t dummy1; + uint8_t dummy2; #else - uint8_t dummy1; uint8_t dummy2; + uint8_t dummy3; #endif #define FILE_OPS "&|^+-*/%" diff --git a/src/softmagic.c b/src/softmagic.c index 4661eff0..1c8f6a84 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -38,7 +38,7 @@ #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.112 2008/02/19 00:58:59 rrt Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.113 2008/02/24 01:13:13 rrt Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -240,7 +240,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic, */ /* space if previous printed */ if (need_separator - && (m->nospflag == 0) + && ((m->flag & NOSPACE) == 0) && *MAGIC_DESC) { if (file_printf(ms, " ") == -1) return -1;