From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id AAA02830 for ; Sat, 1 Jun 1996 00:20:04 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA11019; Fri, 31 May 1996 10:08:31 -0400 (EDT) Resent-Date: Fri, 31 May 1996 10:08:31 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199605311408.QAA03582@bolyai.cs.elte.hu> Subject: nicezputs fixes To: zsh-workers@math.gatech.edu (Zsh workers list) Date: Fri, 31 May 1996 16:08:31 +0200 (MET DST) Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL16 (25)] MIME-Version: 1.0 Content-Type: application/pgp; format=text; x-action=sign Content-Transfer-Encoding: 7bit Resent-Message-ID: <"ar7143.0.5i2.Urlhn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1240 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- nicezputs does not work as it should. nicechar() is completely wrong. nicechar should not try to untokenize tokens, it must be done by the calling routine. Below is a patch which fixes these. Probable putpromt and the related functions also need some change which is not done here. This patch completely elliminates niceputc. Zoltan *** Src/utils.c 1996/05/27 17:09:29 2.27 --- Src/utils.c 1996/05/31 14:04:22 *************** *** 80,89 **** case 's': nicezputs(str, stderr); break; ! case 'l': ! while (num--) ! niceputc(*str == Meta ? (str += 2, str[-1] ^ 32) : *str++, stderr); break; case 'd': fprintf(stderr, "%d", num); break; --- 80,94 ---- case 's': nicezputs(str, stderr); break; ! case 'l': { ! char sav; ! num = metalen(str, num); ! sav = str[num]; ! str[num] = '\0'; ! nicezputs(str, stderr); ! str[num] = sav; break; + } case 'd': fprintf(stderr, "%d", num); break; *************** *** 91,97 **** putc('%', stderr); break; case 'c': ! niceputc(num, stderr); break; case 'e': /* print the corresponding message for this errno */ --- 96,102 ---- putc('%', stderr); break; case 'c': ! fputs(nicechar(num), stderr); break; case 'e': /* print the corresponding message for this errno */ *************** *** 111,118 **** } break; } ! } else ! putc(*fmt++, stderr); if (unset(SHINSTDIN) && lineno) fprintf(stderr, " [%ld]\n", lineno); else --- 116,125 ---- } break; } ! } else { ! putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, stderr); ! fmt++; ! } if (unset(SHINSTDIN) && lineno) fprintf(stderr, " [%ld]\n", lineno); else *************** *** 158,170 **** static char buf[6]; char *s = buf; c &= 0xff; - if (itok(c)) { - if (c >= STOUC(Pound) && c <= STOUC(Comma)) - c = ztokens[c - STOUC(Pound)]; - else - c = 0; - goto done; - } if (isprint(c)) goto done; if (c & 0x80) { --- 165,170 ---- *************** *** 194,208 **** return buf; } ! /* Output the visible representation of one character. */ ! ! /**/ ! void ! niceputc(int c, FILE *f) ! { ! fputs(nicechar(c), f); ! } ! /* Output a string's visible representation. */ /**/ --- 194,200 ---- return buf; } ! #if 0 /* Output a string's visible representation. */ /**/ *************** *** 212,217 **** --- 204,210 ---- for (; *s; s++) fputs(nicechar(STOUC(*s)), f); } + #endif /* Return the length of the visible representation of a string. */ *************** *** 3055,3066 **** { int c; ! while (*s) { ! if (*s == Meta) ! c = *++s ^ 32; ! else ! c = *s; ! s++; if(fputs(nicechar(c), stream) < 0) return EOF; } --- 3048,3061 ---- { int c; ! while ((c = *s++)) { ! if (itok(c)) ! if (c <= Comma) ! c = ztokens[c - Pound]; ! else ! continue; ! if (c == Meta) ! c = *s++ ^ 32; if(fputs(nicechar(c), stream) < 0) return EOF; } *************** *** 3076,3088 **** size_t l = 0; int c; ! while (*s) { ! if (*s == Meta) ! c = *++s ^ 32; ! else ! c = *s; ! s++; ! l += strlen(nicechar(STOUC(*s))); } return l; } --- 3071,3085 ---- size_t l = 0; int c; ! while ((c = *s++)) { ! if (itok(c)) ! if (c <= Comma) ! c = ztokens[c - Pound]; ! else ! continue; ! if (c == Meta) ! c = *s++ ^ 32; ! l += strlen(nicechar(STOUC(c))); } return l; } *** Src/exec.c 1996/05/31 12:47:50 2.31 --- Src/exec.c 1996/05/31 14:04:22 *************** *** 137,143 **** char **eep; unmetafy(pth, NULL); ! for (eep = argv; *eep; unmetafy(*eep++, NULL)); for (eep = environ; *eep; eep++) if (**eep == '_' && (*eep)[1] == '=') break; --- 137,145 ---- char **eep; unmetafy(pth, NULL); ! for (eep = argv; *eep; eep++) ! if (*eep != pth) ! unmetafy(*eep, NULL); for (eep = environ; *eep; eep++) if (**eep == '_' && (*eep)[1] == '=') break; *************** *** 206,212 **** * null characters as these cannot be passed to external commands * * anyway. So the result is truncated at the first null char. */ pth = metafy(pth, -1, META_NOALLOC); ! for (eep = argv; *eep; *eep = metafy(*eep, -1, META_NOALLOC), eep++); return eno; } --- 208,216 ---- * null characters as these cannot be passed to external commands * * anyway. So the result is truncated at the first null char. */ pth = metafy(pth, -1, META_NOALLOC); ! for (eep = argv; *eep; eep++) ! if (*eep != pth) ! (void) metafy(*eep, -1, META_NOALLOC); return eno; } -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv iQCVAwUBMa79XgupSCiLN749AQGOQgP9FFaSnTfuhfiWXA3sx1ziwK+Owm69tnri fXgHNWIIzQ98smBGpIIOAZz4+cS//0CMsg54NDs8jFvmQ3MPzG1WDeYyRy6Age0R ta9XTAKeWVKqsCmk6//ocXCPMPYeCe8qSF7qQWN5PgONgtQ6YoCBp2b1OUT+iDHi pJse8yrFBwU= =Bm3d -----END PGP SIGNATURE-----