]> granicus.if.org Git - file/commitdiff
minor fixes
authorChristos Zoulas <christos@zoulas.com>
Fri, 12 Sep 2003 19:39:44 +0000 (19:39 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 12 Sep 2003 19:39:44 +0000 (19:39 +0000)
src/apprentice.c
src/file.c
src/funcs.c
src/print.c

index 65b60c5209e057acf1b51d6eab5bc4fcabe9bbd2..2353dd002ed4e32e9b8f8b5993596176803b6b73 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.63 2003/09/12 19:19:22 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.64 2003/09/12 19:39:44 christos Exp $")
 #endif /* lint */
 
 #define        EATAB {while (isascii((unsigned char) *l) && \
@@ -263,10 +263,11 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
                return -1;
        }
 
-       /* parse it */
-       if (action == FILE_CHECK)       /* print silly verbose header for USG compat. */
+       /* print silly verbose header for USG compat. */
+       if (action == FILE_CHECK)
                (void)fprintf(stderr, "%s\n", hdr);
 
+       /* parse it */
        for (lineno = 1; fgets(line, BUFSIZ, f) != NULL; lineno++) {
                if (line[0]=='#')       /* comment, do not parse */
                        continue;
@@ -682,8 +683,12 @@ getvalue(struct magic_set *ms, struct magic *m, char **p)
        case FILE_PSTRING:
        case FILE_REGEX:
                *p = getstr(ms, *p, m->value.s, sizeof(m->value.s), &slen);
-               if (*p == NULL)
+               if (*p == NULL) {
+                       if (ms->flags & MAGIC_CHECK)
+                               file_magwarn("Cannot get string from `%s'",
+                                   m->value.s);
                        return -1;
+               }
                m->vallen = slen;
                return 0;
        default:
index 8a3568084be72c491a7e7cfd144eb8e797cf1a8f..6cc49d539550b2d0f7dc662e2a69dbe25346c3c6 100644 (file)
@@ -72,7 +72,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: file.c,v 1.80 2003/07/10 21:10:16 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.81 2003/09/12 19:39:44 christos Exp $")
 #endif /* lint */
 
 
@@ -215,7 +215,7 @@ main(int argc, char *argv[])
                        action = FILE_COMPILE;
                        break;
                case 'd':
-                       flags |= MAGIC_DEBUG;
+                       flags |= MAGIC_DEBUG|MAGIC_CHECK;
                        break;
                case 'f':
                        if(action)
index f89bd3be7008320141a1e08551488f987d949832..7d72bd9947541fff099f4bac632bebd8731c3fd0 100644 (file)
@@ -76,10 +76,6 @@ file_error(struct magic_set *ms, const char *f, ...)
        if (ms->haderr)
            return;
        va_start(va, f);
-
-       /* cuz we use stdout for most, stderr here */
-       (void) fflush(stdout); 
-
        (void) vsnprintf(ms->o.buf, ms->o.size, f, va);
        ms->haderr++;
        va_end(va);
index 2bdc9fff740e18d040a307a22b106f532f83b5fd..ee1926deebbabc3af88aa3b08840bbf16915d388 100644 (file)
@@ -46,7 +46,7 @@
 #include <time.h>
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.43 2003/03/26 15:35:30 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.44 2003/09/12 19:39:44 christos Exp $")
 #endif  /* lint */
 
 #define SZOF(a)        (sizeof(a) / sizeof(a[0]))
@@ -150,6 +150,7 @@ file_magwarn(const char *f, ...)
        /* cuz we use stdout for most, stderr here */
        (void) fflush(stdout); 
 
+       (void) fprintf(stderr, "WARNING: ");
        (void) vfprintf(stderr, f, va);
        va_end(va);
        fputc('\n', stderr);