Date: 24 Apr 2002 18:24:31 -0700
From: Seth Kingsley <sethk@meowfishies.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: bin/37437: Add HTTP-style support to {vis,unvis}(1).
Message-ID: <20020425012431.39461.qmail@magnesium.net>
next in thread | raw e-mail | index | archive | help
>Number: 37437
>Category: bin
>Synopsis: Add HTTP-style support to {vis,unvis}(1).
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Apr 24 18:30:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Seth Kingsley
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD neko.home.meowfishies.com 5.0-CURRENT FreeBSD
5.0-CURRENT #7: Sat Apr 6 18:32:18 PST 2002
sethk@neko.home.meowfishies.com:/usr/src/sys/i386/compile/NEKO i386
>Description:
Implement an -h option to the vis(1) and unvis(1) filters for
processing HTTP-style URL encoding and decoding. The default
for unvis(1) is only to detect HTTP-style character encoding in
input if explicitly directed to.
>How-To-Repeat:
N/A
>Fix:
Index: vis/vis.1
===================================================================
RCS file: /home/ncvs/src/usr.bin/vis/vis.1,v
retrieving revision 1.8
diff -u -p -r1.8 vis.1
--- vis/vis.1 2002/04/20 12:17:56 1.8
+++ vis/vis.1 2002/04/25 01:22:07
@@ -67,6 +67,13 @@ represent a minimum of change to the inp
.It Fl c
Request a format which displays a small subset of the
non-printable characters using C-style backslash sequences.
+.It Fl h
+Request a format which displays non-printable characters using
+a HTTP-style encoding, as described in RFC 1808. The form is
+.Ql Li %dd ,
+where
+.Nm d
+represents a hexidecimal digit.
.It Fl F
Causes
.Nm
Index: vis/vis.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/vis/vis.c,v
retrieving revision 1.9
diff -u -p -r1.9 vis.c
--- vis/vis.c 2002/03/22 01:42:42 1.9
+++ vis/vis.c 2002/04/25 01:22:14
@@ -69,7 +69,7 @@ main(argc, argv)
(void) setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc, argv, "nwctsobfF:ld")) != -1)
+ while ((ch = getopt(argc, argv, "nwchtsobfF:ld")) != -1)
switch((char)ch) {
case 'n':
none++;
@@ -80,6 +80,9 @@ main(argc, argv)
case 'c':
eflags |= VIS_CSTYLE;
break;
+ case 'h':
+ eflags |= VIS_HTTPSTYLE;
+ break;
case 't':
eflags |= VIS_TAB;
break;
@@ -132,9 +135,9 @@ static void
usage()
{
#ifdef DEBUG
- fprintf(stderr, "usage: vis [-cbflnostwd] [-F foldwidth] [file ...]\n");
+ fprintf(stderr, "usage: vis [-chbflnostwd] [-F foldwidth] [file ...]\n");
#else
- fprintf(stderr, "usage: vis [-cbflnostw] [-F foldwidth] [file ...]\n");
+ fprintf(stderr, "usage: vis [-chbflnostw] [-F foldwidth] [file ...]\n");
#endif
exit(1);
}
Index: unvis/unvis.1
===================================================================
RCS file: /home/ncvs/src/usr.bin/unvis/unvis.1,v
retrieving revision 1.6
diff -u -p -r1.6 unvis.1
--- unvis/unvis.1 2001/07/10 14:16:27 1.6
+++ unvis/unvis.1 2002/04/25 01:22:15
@@ -40,6 +40,7 @@
.Nd "revert a visual representation of data back to original form"
.Sh SYNOPSIS
.Nm
+.Op Fl h
.Op Ar
.Sh DESCRIPTION
.Nm Unvis
@@ -47,6 +48,11 @@ is the inverse function of
.Xr vis 1 .
It reverts
a visual representation of data back to its original form on standard output.
+If the
+.Fl h
+option is specified, extra processing is done for HTTP-style URL
+encoding, as described in
+.Xr vis 1 .
.Sh SEE ALSO
.Xr vis 1 ,
.Xr unvis 3 ,
Index: unvis/unvis.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/unvis/unvis.c,v
retrieving revision 1.8
diff -u -p -r1.8 unvis.c
--- unvis/unvis.c 2002/03/22 01:42:40 1.8
+++ unvis/unvis.c 2002/04/25 01:22:16
@@ -51,7 +51,7 @@ static const char rcsid[] =
#include <unistd.h>
#include <vis.h>
-void process(FILE *, const char *);
+void process(FILE *, const char *, int);
static void usage(void);
int
@@ -61,9 +61,13 @@ main(argc, argv)
{
FILE *fp;
int ch;
+ int flags = 0;
- while ((ch = getopt(argc, argv, "")) != -1)
+ while ((ch = getopt(argc, argv, "h")) != -1)
switch((char)ch) {
+ case 'h':
+ flags |= VIS_HTTPSTYLE;
+ break;
case '?':
default:
usage();
@@ -74,27 +78,28 @@ main(argc, argv)
if (*argv)
while (*argv) {
if ((fp=fopen(*argv, "r")) != NULL)
- process(fp, *argv);
+ process(fp, *argv, flags);
else
warn("%s", *argv);
argv++;
}
else
- process(stdin, "<stdin>");
+ process(stdin, "<stdin>", flags);
exit(0);
}
static void
usage()
{
- fprintf(stderr, "usage: unvis [file ...]\n");
+ fprintf(stderr, "usage: unvis [-h] [file ...]\n");
exit(1);
}
void
-process(fp, filename)
+process(fp, filename, flags)
FILE *fp;
const char *filename;
+ int flags;
{
register int offset = 0, c, ret;
int state = 0;
@@ -103,7 +108,7 @@ process(fp, filename)
while ((c = getc(fp)) != EOF) {
offset++;
again:
- switch(ret = unvis(&outc, (char)c, &state, 0)) {
+ switch(ret = unvis(&outc, (char)c, &state, flags)) {
case UNVIS_VALID:
putchar(outc);
break;
@@ -121,6 +126,6 @@ process(fp, filename)
errx(1, "bad return value (%d), can't happen", ret);
}
}
- if (unvis(&outc, (char)0, &state, UNVIS_END) == UNVIS_VALID)
+ if (unvis(&outc, (char)0, &state, UNVIS_END | flags) == UNVIS_VALID)
putchar(outc);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020425012431.39461.qmail>
