Module Name:    src
Committed By:   christos
Date:           Sat Nov 27 19:46:25 UTC 2010

Modified Files:
        src/usr.bin/unvis: unvis.1 unvis.c

Log Message:
add -H and -e


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/unvis/unvis.1
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/unvis/unvis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/unvis/unvis.1
diff -u src/usr.bin/unvis/unvis.1:1.7 src/usr.bin/unvis/unvis.1:1.8
--- src/usr.bin/unvis/unvis.1:1.7	Thu Apr 22 02:55:15 2004
+++ src/usr.bin/unvis/unvis.1	Sat Nov 27 14:46:25 2010
@@ -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 ,

Index: src/usr.bin/unvis/unvis.c
diff -u src/usr.bin/unvis/unvis.c:1.12 src/usr.bin/unvis/unvis.c:1.13
--- src/usr.bin/unvis/unvis.c:1.12	Tue Feb 10 18:06:31 2009
+++ src/usr.bin/unvis/unvis.c	Sat Nov 27 14:46:25 2010
@@ -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;

Reply via email to