mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-13 01:31:18 +02:00
21730: fix metafication of nicechar and pwd
This commit is contained in:
parent
ba9bad6c0e
commit
dc060607e9
3 changed files with 41 additions and 16 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-09-17 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
|
||||||
|
|
||||||
|
* 21730: Src/builtin.c, Src/utils.c: nicechar(), used in
|
||||||
|
prompts and other forms of formatted output, didn't return
|
||||||
|
a metafied string with confusing results. Also outputting
|
||||||
|
pwd didn't unmetafy it in one place.
|
||||||
|
|
||||||
2005-09-14 Doug Kearns <djkea2@gus.gscit.monash.edu.au>
|
2005-09-14 Doug Kearns <djkea2@gus.gscit.monash.edu.au>
|
||||||
|
|
||||||
* unposted: Completion/Unix/Command/_rake: update for version 0.6.0
|
* unposted: Completion/Unix/Command/_rake: update for version 0.6.0
|
||||||
|
|
|
@ -699,7 +699,7 @@ bin_dirs(UNUSED(char *name), char **argv, Options ops, UNUSED(int func))
|
||||||
else
|
else
|
||||||
fmt = " ";
|
fmt = " ";
|
||||||
if (OPT_ISSET(ops,'l'))
|
if (OPT_ISSET(ops,'l'))
|
||||||
fputs(pwd, stdout);
|
zputs(pwd, stdout);
|
||||||
else
|
else
|
||||||
fprintdir(pwd, stdout);
|
fprintdir(pwd, stdout);
|
||||||
for (node = firstnode(dirstack); node; incnode(node)) {
|
for (node = firstnode(dirstack); node; incnode(node)) {
|
||||||
|
|
46
Src/utils.c
46
Src/utils.c
|
@ -146,7 +146,7 @@ zerrmsg(const char *fmt, const char *str, int num)
|
||||||
putc('%', stderr);
|
putc('%', stderr);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
fputs(nicechar(num), stderr);
|
zputs(nicechar(num), stderr);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
/* print the corresponding message for this errno */
|
/* print the corresponding message for this errno */
|
||||||
|
@ -195,15 +195,21 @@ putshout(int c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn a character into a visible representation thereof. The visible *
|
/*
|
||||||
* string is put together in a static buffer, and this function returns *
|
* Turn a character into a visible representation thereof. The visible
|
||||||
* a pointer to it. Printable characters stand for themselves, DEL is *
|
* string is put together in a static buffer, and this function returns
|
||||||
* represented as "^?", newline and tab are represented as "\n" and *
|
* a pointer to it. Printable characters stand for themselves, DEL is
|
||||||
* "\t", and normal control characters are represented in "^C" form. *
|
* represented as "^?", newline and tab are represented as "\n" and
|
||||||
* Characters with bit 7 set, if unprintable, are represented as "\M-" *
|
* "\t", and normal control characters are represented in "^C" form.
|
||||||
* followed by the visible representation of the character with bit 7 *
|
* Characters with bit 7 set, if unprintable, are represented as "\M-"
|
||||||
* stripped off. Tokens are interpreted, rather than being treated as *
|
* followed by the visible representation of the character with bit 7
|
||||||
* literal characters. */
|
* stripped off. Tokens are interpreted, rather than being treated as
|
||||||
|
* literal characters.
|
||||||
|
*
|
||||||
|
* Note that the returned string is metafied, so that it must be
|
||||||
|
* treated like any other zsh internal string (and not, for example,
|
||||||
|
* output directly).
|
||||||
|
*/
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
mod_export char *
|
mod_export char *
|
||||||
|
@ -238,6 +244,16 @@ nicechar(int c)
|
||||||
c += 0x40;
|
c += 0x40;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
/*
|
||||||
|
* The resulting string is still metafied, so check if
|
||||||
|
* we are returning a character in the range that needs metafication.
|
||||||
|
* This can't happen if the character is printed "nicely", so
|
||||||
|
* this results in a maximum of two bytes total (plus the null).
|
||||||
|
*/
|
||||||
|
if (itok(c)) {
|
||||||
|
*s++ = Meta;
|
||||||
|
*s++ = c ^ 32;
|
||||||
|
} else
|
||||||
*s++ = c;
|
*s++ = c;
|
||||||
*s = 0;
|
*s = 0;
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -292,7 +308,7 @@ void
|
||||||
nicefputs(char *s, FILE *f)
|
nicefputs(char *s, FILE *f)
|
||||||
{
|
{
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
fputs(nicechar(STOUC(*s)), f);
|
zputs(nicechar(STOUC(*s)), f);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3177,7 +3193,7 @@ wcs_zputs(wchar_t const *s, FILE *stream)
|
||||||
static char *
|
static char *
|
||||||
nicedup(char const *s, int heap)
|
nicedup(char const *s, int heap)
|
||||||
{
|
{
|
||||||
int c, len = strlen(s) * 5;
|
int c, len = strlen(s) * 5 + 1;
|
||||||
VARARR(char, buf, len);
|
VARARR(char, buf, len);
|
||||||
char *p = buf, *n;
|
char *p = buf, *n;
|
||||||
|
|
||||||
|
@ -3190,11 +3206,13 @@ nicedup(char const *s, int heap)
|
||||||
}
|
}
|
||||||
if (c == Meta)
|
if (c == Meta)
|
||||||
c = *s++ ^ 32;
|
c = *s++ ^ 32;
|
||||||
|
/* The result here is metafied */
|
||||||
n = nicechar(c);
|
n = nicechar(c);
|
||||||
while(*n)
|
while(*n)
|
||||||
*p++ = *n++;
|
*p++ = *n++;
|
||||||
}
|
}
|
||||||
return metafy(buf, p - buf, (heap ? META_HEAPDUP : META_DUP));
|
*p = '\0';
|
||||||
|
return heap ? dupstring(buf) : ztrdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@ -3228,7 +3246,7 @@ nicezputs(char const *s, FILE *stream)
|
||||||
}
|
}
|
||||||
if (c == Meta)
|
if (c == Meta)
|
||||||
c = *s++ ^ 32;
|
c = *s++ ^ 32;
|
||||||
if(fputs(nicechar(c), stream) < 0)
|
if(zputs(nicechar(c), stream) < 0)
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue