From owner-freebsd-bugs Mon May 20 6: 6:56 2002 Delivered-To: freebsd-bugs@freebsd.org Received: from smtp.noos.fr (aragon.noos.net [212.198.2.75]) by hub.freebsd.org (Postfix) with ESMTP id E3AF537B403 for ; Mon, 20 May 2002 06:06:45 -0700 (PDT) Received: (qmail 55370222 invoked by uid 0); 20 May 2002 13:06:43 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.75 (qmail-ldap-1.03) with SMTP for ; 20 May 2002 13:06:43 -0000 Received: from gits.gits.dyndns.org (cdn7plf2ftgcsvtl@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g4KD6gi2024505; Mon, 20 May 2002 15:06:42 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g4KD6gke024504; Mon, 20 May 2002 15:06:42 +0200 (CEST) (envelope-from root) Message-Id: <200205201306.g4KD6gke024504@gits.gits.dyndns.org> Subject: Re: bin/26005: MIME quoted-printable encoding added to vis/unvis + bug fix In-Reply-To: <200103221930.f2MJU1999167@freefall.freebsd.org> To: freebsd gnats , freebsd bugs Date: Mon, 20 May 2002 15:06:41 +0200 (CEST) From: Cyrille Lefevre Reply-To: cyrille.lefevre@laposte.net X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --ELM1021900001-24230-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII On Mar 22, 2001 11:30:01 am -0800, gnats-admin@FreeBSD.org wrote: humm! bug fix related to changes in vis(3). patch supplied. Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net --ELM1021900001-24230-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-patch Content-Disposition: attachment; filename=vis-2.patch Content-Description: vis-2.patch Index: lib/libc/gen/vis.c =================================================================== RCS file: /home/ncvs/src/lib/libc/gen/vis.c,v retrieving revision 1.5.8.2 diff -u -r1.5.8.2 vis.c --- lib/libc/gen/vis.c 5 Mar 2001 09:44:34 -0000 1.5.8.2 +++ lib/libc/gen/vis.c 22 Apr 2002 12:06:47 -0000 @@ -54,33 +54,84 @@ int c, nextc; register int flag; { - c = (unsigned char)c; + static int lastc = EOF; + + if (flag & VIS_QPSTYLE) { + /* Described in RFC 2045 */ + if (c == '\n') { + if (isascii(lastc) && isblank(lastc)) { + *dst++ = '='; + *dst++ = c; + } + *dst++ = c; + goto done; + } + if (c == '=' || !(isascii(c) && (isgraph(c) || isblank(c)))) { + *dst++ = '='; + snprintf(dst, 4, "%02X", c); + dst += 2; + goto done; + } + } if (flag & VIS_HTTPSTYLE) { - /* Described in RFC 1808 */ - if (!(isalnum(c) /* alpha-numeric */ + if (!( +#define RFC 0 +#if RFC == 2396 + isalnum(c) /* alpha-numeric */ + /* reserved */ + || c == ';' || c == '/' || c == '?' || c == ':' + || c == '@' || c == '&' || c == '=' || c == '+' + || c == '$' || c == ',' + /* mark */ + || c == '-' || c == '_' || c == '.' || c == '!' + || c == '~' || c == '*' || c == '\'' || c == '(' + || c == ')' + /* delims */ + || c == '<' || c == '>' || c == '#' || c == '%' + || c == '"' + /* unwise */ + || c == '{' || c == '}' || c == '|' || c == '\\' + || c == '^' || c == '[' || c == ']' || c == '`' +#elif RFC == 1808 /* obsoleted by RFC2396 */ + isalnum(c) /* alpha-numeric */ /* safe */ - || c == '$' || c == '-' || c == '_' || c == '.' || c == '+' + || c == '$' || c == '-' || c == '_' || c == '.' + || c == '+' /* extra */ || c == '!' || c == '*' || c == '\'' || c == '(' - || c == ')' || c == ',')) { + || c == ')' || c == ',' + /* national */ + || c == '{' || c == '}' || c == '|' || c == '\\' + || c == '^' || c == '~' || c == '[' || c == ']' + || c == '`' + /* reserved */ + || c == ';' || c == '/' || c == '?' || c == ':' + || c == '@' || c == '&' || c == '=' + /* punctuation */ + || c == '<' || c == '>' || c == '#' || c == '%' + || c == '"' +#else /* same as above, but faster. */ + isgraph(c) && isascii(c) +#endif + )) { *dst++ = '%'; - snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c); + snprintf(dst, 4, "%02X", c); dst += 2; goto done; } } if (isgraph(c) || - ((flag & VIS_SP) == 0 && c == ' ') || - ((flag & VIS_TAB) == 0 && c == '\t') || - ((flag & VIS_NL) == 0 && c == '\n') || - ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) { + (c == ' ' && !(flag & VIS_SP)) || + (c == '\t' && !(flag & VIS_TAB)) || + (c == '\n' && !(flag & VIS_NL)) || + ((c == '\b' || c == '\007' || c == '\r') && (flag & VIS_SAFE))) { *dst++ = c; - if (c == '\\' && (flag & VIS_NOSLASH) == 0) + if (c == '\\' && + !(flag & (VIS_NOSLASH|VIS_QPSTYLE|VIS_HTTPSTYLE))) *dst++ = '\\'; - *dst = '\0'; - return (dst); + goto done; } if (flag & VIS_CSTYLE) { @@ -133,9 +184,9 @@ } if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) { *dst++ = '\\'; - *dst++ = ((u_char)c >> 6 & 07) + '0'; - *dst++ = ((u_char)c >> 3 & 07) + '0'; - *dst++ = ((u_char)c & 07) + '0'; + *dst++ = (c >> 6 & 07) + '0'; + *dst++ = (c >> 3 & 07) + '0'; + *dst++ = (c & 07) + '0'; goto done; } if ((flag & VIS_NOSLASH) == 0) @@ -155,6 +206,7 @@ *dst++ = c; } done: + lastc = c; *dst = '\0'; return (dst); } @@ -175,10 +227,10 @@ register const char *src; int flag; { - register char c; - char *start; + register int c; + char *start = dst; - for (start = dst; (c = *src); ) + while ( (c = *src) ) dst = vis(dst, c, flag, *++src); *dst = '\0'; return (dst - start); @@ -191,16 +243,15 @@ register size_t len; int flag; { - int c; - char *start; + register int c; + char *start = dst; - for (start = dst; len > 1; len--) { + while (len-- > 1) { c = *src; dst = vis(dst, c, flag, *++src); } - if (len) - dst = vis(dst, *src, flag, '\0'); + if (!len) + dst = vis(dst, *src, flag, 0); *dst = '\0'; - return (dst - start); } --ELM1021900001-24230-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message