]> granicus.if.org Git - file/commitdiff
Change magic.nospflag to a flag bit in magic.flag.
authorReuben Thomas <rrt@sc3d.org>
Sun, 24 Feb 2008 01:13:13 +0000 (01:13 +0000)
committerReuben Thomas <rrt@sc3d.org>
Sun, 24 Feb 2008 01:13:13 +0000 (01:13 +0000)
src/apprentice.c
src/file.h
src/softmagic.c

index 415b9de61353e6ae020997739d9772a96dbb8acd..1119468da53c1bf2ef652a059131533f4cba6e05 100644 (file)
@@ -49,7 +49,7 @@
 #include <dirent.h>
 
 #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)) {
index 1670ca787899809c55100ab9523f4579fbf34c7b..4fafffa86de8a75cb0e17259a42eae170bd3b2a1 100644 (file)
@@ -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__
 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        "&|^+-*/%"
index 4661eff094f4ddbb4c4ad18c02020328d799b079..1c8f6a84515fa57d7e6f281dc264f2c528d8beef 100644 (file)
@@ -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;