Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/unvis add -H and -e



details:   https://anonhg.NetBSD.org/src/rev/8c8f5975de14
branches:  trunk
changeset: 759079:8c8f5975de14
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 27 19:46:25 2010 +0000

description:
add -H and -e

diffstat:

 usr.bin/unvis/unvis.1 |  25 ++++++++++++++++++++++---
 usr.bin/unvis/unvis.c |  45 ++++++++++++++++++++++++++++-----------------
 2 files changed, 50 insertions(+), 20 deletions(-)

diffs (155 lines):

diff -r 680cb9248b38 -r 8c8f5975de14 usr.bin/unvis/unvis.1
--- a/usr.bin/unvis/unvis.1     Sat Nov 27 19:44:54 2010 +0000
+++ b/usr.bin/unvis/unvis.1     Sat Nov 27 19:46:25 2010 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: unvis.1,v 1.7 2004/04/22 06:55:15 lukem Exp $
+.\"    $NetBSD: unvis.1,v 1.8 2010/11/27 19:46:25 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)unvis.1    8.1 (Berkeley) 6/6/93
 .\"
-.Dd April 22, 2004
+.Dd November 27, 2010
 .Dt UNVIS 1
 .Os
 .Sh NAME
@@ -37,7 +37,10 @@
 .Nd "revert a visual representation of data back to original form"
 .Sh SYNOPSIS
 .Nm
+.Op Fl e
+.Op Fl H
 .Op Fl h
+.Op Fl m
 .Op Ar file ...
 .Sh DESCRIPTION
 .Nm
@@ -48,10 +51,26 @@
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl e
+Don't decode \e escaped sequences.
+.It Fl H
+Decode using the URI encoding from RFC 1866.
+.Pq Dv VIS_HTTP1866
 .It Fl h
 Decode using the URI encoding from RFC 1808.
-.Pq Dv VIS_HTTPSTYLE
+.Pq Dv VIS_HTTP1808
+.It Fl m
+Decode using mime style.
+.Pq Dv VIS_MIMESTYLE
 .El
+.Pp
+Mixing
+.Fl h
+or
+.Fl H
+with
+.Fl m
+is not supported.
 .Sh SEE ALSO
 .Xr vis 1 ,
 .Xr unvis 3 ,
diff -r 680cb9248b38 -r 8c8f5975de14 usr.bin/unvis/unvis.c
--- a/usr.bin/unvis/unvis.c     Sat Nov 27 19:44:54 2010 +0000
+++ b/usr.bin/unvis/unvis.c     Sat Nov 27 19:46:25 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: unvis.c,v 1.12 2009/02/10 23:06:31 christos Exp $      */
+/*     $NetBSD: unvis.c,v 1.13 2010/11/27 19:46:25 christos Exp $      */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)unvis.c    8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: unvis.c,v 1.12 2009/02/10 23:06:31 christos Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.13 2010/11/27 19:46:25 christos Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -48,21 +48,25 @@
 #include <unistd.h>
 #include <vis.h>
 
-static int eflags;
-
-static void process(FILE *fp, const char *filename);
+static void process(FILE *, const char *, int);
 
 int
 main(int argc, char *argv[])
 {
        FILE *fp;
-       int ch;
+       int ch, eflags = 0;
 
        setprogname(argv[0]);
-       while ((ch = getopt(argc, argv, "hm")) != -1)
+       while ((ch = getopt(argc, argv, "eHhm")) != -1)
                switch((char)ch) {
+               case 'e':
+                       eflags |= VIS_NOESCAPE;
+                       break;
+               case 'H':
+                       eflags |= VIS_HTTP1866;
+                       break;
                case 'h':
-                       eflags |= VIS_HTTPSTYLE;
+                       eflags |= VIS_HTTP1808;
                        break;
                case 'm':
                        eflags |= VIS_MIMESTYLE;
@@ -70,31 +74,38 @@
                case '?':
                default:
                        (void)fprintf(stderr,
-                           "Usage: %s [-h|-m] [file...]\n", getprogname());
-                       return 1;
+                           "Usage: %s [-e] [-Hh | -m] [file...]\n",
+                           getprogname());
+                       return EXIT_FAILURE;
                }
        argc -= optind;
        argv += optind;
 
-       if ((eflags & (VIS_HTTPSTYLE|VIS_MIMESTYLE)) ==
-           (VIS_HTTPSTYLE|VIS_MIMESTYLE))
-               errx(1, "Can't specify -m and -h at the same time");
+       switch (eflags & (VIS_HTTP1808|VIS_HTTP1866|VIS_MIMESTYLE)) {
+       case VIS_HTTP1808|VIS_MIMESTYLE:
+       case VIS_HTTP1866|VIS_MIMESTYLE:
+       case VIS_HTTP1808|VIS_HTTP1866|VIS_MIMESTYLE:
+               errx(EXIT_FAILURE, "Can't mix -m with -h and/or -H");
+               /*NOTREACHED*/
+       default:
+               break;
+       }
 
        if (*argv)
                while (*argv) {
                        if ((fp = fopen(*argv, "r")) != NULL)
-                               process(fp, *argv);
+                               process(fp, *argv, eflags);
                        else
                                warn("%s", *argv);
                        argv++;
                }
        else
-               process(stdin, "<stdin>");
-       return 0;
+               process(stdin, "<stdin>", eflags);
+       return EXIT_SUCCESS;
 }
 
 static void
-process(FILE *fp, const char *filename)
+process(FILE *fp, const char *filename, int eflags)
 {
        int offset = 0, c, ret;
        int state = 0;



Home | Main Index | Thread Index | Old Index