]> granicus.if.org Git - file/commitdiff
add -b and -bb option... I need to re-think this because it breaks compatibility
authorChristos Zoulas <christos@zoulas.com>
Tue, 23 Oct 2007 21:26:55 +0000 (21:26 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 23 Oct 2007 21:26:55 +0000 (21:26 +0000)
.cvsignore
ChangeLog
doc/.cvsignore [new file with mode: 0644]
magic/.cvsignore [new file with mode: 0644]
python/.cvsignore [new file with mode: 0644]
src/.cvsignore [new file with mode: 0644]
src/file.c
src/file_opts.h

index d89921897ae6b00d4a280883194d448ed042c839..948f00a94f544b846e8e1b2d1a64a66cb94fdae8 100644 (file)
@@ -1 +1,7 @@
 autom4te.cache
+Makefile
+config.h
+config.log
+config.status
+libtool
+stamp-h1
index 223ef46893619fb7866474854ca95dfce214abbc..ced051b916f1a38fa6040a9dc500a15b3ac0d0c8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-23  5:25 Christos Zoulas <christos@zoulas.com>
+
+       * Add --with-filename, and --no-filename (Reuben Thomas)
+
 2007-10-23  3:59 Christos Zoulas <christos@zoulas.com>
 
        * Rest of the mime split (Reuben Thomas)
diff --git a/doc/.cvsignore b/doc/.cvsignore
new file mode 100644 (file)
index 0000000..afdbc3e
--- /dev/null
@@ -0,0 +1,4 @@
+Makefile\r
+*.1\r
+*.3\r
+*.4\r
diff --git a/magic/.cvsignore b/magic/.cvsignore
new file mode 100644 (file)
index 0000000..7ad882c
--- /dev/null
@@ -0,0 +1,3 @@
+Makefile\r
+magic\r
+*.mgc\r
diff --git a/python/.cvsignore b/python/.cvsignore
new file mode 100644 (file)
index 0000000..a8f619d
--- /dev/null
@@ -0,0 +1 @@
+Makefile\r
diff --git a/src/.cvsignore b/src/.cvsignore
new file mode 100644 (file)
index 0000000..ab6fbe7
--- /dev/null
@@ -0,0 +1,12 @@
+.deps\r
+Makefile
+config.h
+config.log
+config.status
+libtool
+stamp-h1
+.libs\r
+*.lo\r
+*.la\r
+Makefile\r
+file\r
index 557adb16a1305cccd4c5157a496c6a1b06e370f0..39c1ec487695a4d90876a1df0693c3f07052d5ad 100644 (file)
@@ -206,19 +206,26 @@ main(int argc, char *argv[])
                        case 0:
                                help();
                                break;
-                       case 10:
+                       case 5:
+                               bflag++;
+                               break;
+                       case 6:
+                               bflag = 0;
+                               break;
+                       case 12:
                                flags |= MAGIC_MIME_TYPE;
                                break;
-                       case 11:
+                       case 13:
                                flags |= MAGIC_MIME_ENCODING;
                                break;
                        }
+                       break;
 #endif
                case '0':
                        nulsep = 1;
                        break;
                case 'b':
-                       ++bflag;
+                       bflag++;
                        break;
                case 'c':
                        action = FILE_CHECK;
@@ -277,9 +284,9 @@ main(int argc, char *argv[])
                        flags |= MAGIC_DEVICES;
                        break;
                case 'v':
-                       (void)fprintf(stdout, "%s-%d.%.2d\n", progname,
+                       (void)fprintf(stderr, "%s-%d.%.2d\n", progname,
                                       FILE_VERSION_MAJOR, patchlevel);
-                       (void)fprintf(stdout, "magic file from %s\n",
+                       (void)fprintf(stderr, "magic file from %s\n",
                                       magicfile);
                        return 1;
                case 'z':
@@ -337,6 +344,13 @@ main(int argc, char *argv[])
                        if (nw > wid)
                                wid = nw;
                }
+               /*
+                * If bflag is only set once, set it depending on
+                * number of files
+                */
+               if (bflag == 1) {
+                       bflag = optind >= argc - 1;
+               }
                for (; optind < argc; optind++)
                        process(argv[optind], wid);
        }
@@ -541,13 +555,14 @@ usage(void)
 private void
 help(void)
 {
-       (void)puts(
+       (void)fputs(
 "Usage: file [OPTION...] [FILE...]\n"
-"Determine file type of FILEs.\n");
+"Determine type of FILEs.\n"
+"\n", stderr);
 #define OPT(shortname, longname, opt, doc)      \
-        printf("  -%c, --" longname doc, shortname);
+        fprintf(stderr, "  -%c, --" longname doc, shortname);
 #define OPT_LONGONLY(longname, opt, doc)        \
-        printf("      --" longname doc);
+        fprintf(stderr, "      --" longname doc);
 #include "file_opts.h"
 #undef OPT
 #undef OPT_LONGONLY
index f46cf99b57adb8a9a91d89f1388cec71068903fb..7f377a41af8e95063f209c8b0829eb7fd0cfa135 100644 (file)
@@ -1,5 +1,3 @@
-/* $File$ */
-
 /*
  * Table of command-line options
  *
@@ -10,6 +8,8 @@
  *
  * N.B. The long options' order must correspond to the code in file.c,
  * and OPTSTRING must be kept up-to-date with the short options.
+ * Pay particular attention to the numbers of long-only options in the
+ * switch statement!
  */
 
 OPT_LONGONLY("help", 0, "                 display this help and exit\n")
@@ -17,7 +17,14 @@ OPT('v', "version", 0, "              output version information and exit\n")
 OPT('m', "magic-file", 1, " LIST      use LIST as a colon-separated list of magic\n"
     "                               number files\n")
 OPT('z', "uncompress", 0, "           try to look inside compressed files\n")
-OPT('b', "brief", 0, "                do not prepend filenames to output lines\n")
+OPT('b', "brief", 0, "                do not prepend filenames to output lines\n"
+    "                               If this flag is specified once, then\n"
+    "                               the filename is printed if more than one\n"
+    "                               files are tested.  If this flag is specified\n"
+    "                               more than once, then filenames are never printed\n")
+OPT_LONGONLY("no-filename", 0, "          synonym for --brief\n")
+OPT_LONGONLY("with-filename", 0, "        print the file name for each match.  This is\n"
+    "                               the default.\n")
 OPT('c', "checking-printout", 0, "    print the parsed form of the magic file, use in\n"
     "                               conjunction with -m to debug a new magic file\n"
     "                               before installing it\n")