From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Chatty little precompiler for _arguments
Date: Thu, 23 Sep 1999 12:28:16 +0200 (MET DST) [thread overview]
Message-ID: <199909231028.MAA24049@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 23 Sep 1999 10:39:25 +0900
Tanaka Akira wrote:
> Also I suppose that `${(qqqq)foo}' should quote foo in $'...' style.
> # I really want this because I frequently use dangeraous characters
> # such as NUL.
This is the easiest solution, just using existing functions (well, not
really existing: I have added nicedupstring() which is like the
existing niceztrdup() but uses heap memory).
The result is maybe not want one wants exactly, e.g. a NUL is printed
as `^@' (its the format used by `bindkey'). Is that ok?
Bye
Sven
diff -u os/subst.c Src/subst.c
--- os/subst.c Thu Sep 23 10:18:57 1999
+++ Src/subst.c Thu Sep 23 11:55:06 1999
@@ -1618,8 +1618,8 @@
opts[PROMPTPERCENT] = opp;
}
if (quotemod) {
- if (--quotetype > 2)
- quotetype = 2;
+ if (--quotetype > 3)
+ quotetype = 3;
if (isarr) {
char **ap;
@@ -1628,7 +1628,10 @@
ap = aval;
if (quotemod > 0) {
- if (quotetype) {
+ if (quotetype == 3)
+ for (; *ap; ap++)
+ *ap = nicedupstring(*ap);
+ else if (quotetype) {
int sl;
char *tmp;
@@ -1665,7 +1668,9 @@
if (!copied)
val = dupstring(val), copied = 1;
if (quotemod > 0) {
- if (quotetype) {
+ if (quotetype == 3)
+ val = nicedupstring(val);
+ else if (quotetype) {
int sl;
char *tmp;
diff -u os/utils.c Src/utils.c
--- os/utils.c Thu Sep 23 11:13:42 1999
+++ Src/utils.c Thu Sep 23 11:57:13 1999
@@ -2867,12 +2867,12 @@
/* Create a visibly-represented duplicate of a string. */
/**/
-char *
-niceztrdup(char const *s)
+static char *
+nicedup(char const *s, int heap)
{
int c, len = strlen(s) * 5;
- char *buf = zalloc(len);
- char *p = buf, *n, *ret;
+ VARARR(char, buf, len);
+ char *p = buf, *n;
while ((c = *s++)) {
if (itok(c)) {
@@ -2887,9 +2887,21 @@
while(*n)
*p++ = *n++;
}
- ret = metafy(buf, p - buf, META_DUP);
- zfree(buf, len);
- return ret;
+ return metafy(buf, p - buf, (heap ? META_HEAPDUP : META_DUP));
+}
+
+/**/
+char *
+niceztrdup(char const *s)
+{
+ return nicedup(s, 0);
+}
+
+/**/
+char *
+nicedupstring(char const *s)
+{
+ return nicedup(s, 1);
}
/* Unmetafy and output a string, displaying special characters readably. */
diff -u od/Zsh/expn.yo Doc/Zsh/expn.yo
--- od/Zsh/expn.yo Wed Sep 22 17:12:32 1999
+++ Doc/Zsh/expn.yo Thu Sep 23 12:01:59 1999
@@ -584,7 +584,9 @@
item(tt(q))(
Quote the resulting words with backslashes. If this flag is given
twice, the resulting words are quoted in single quotes and if it is
-given three times, the words are quoted in double quotes.
+given three times, the words are quoted in double quotes. If it is
+given four times, no real quoting is done, but any special characters
+in the resulting words will be in a human-readable form.
)
item(tt(Q))(
Remove one level of quotes from the resulting words.
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-09-23 10:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-23 10:28 Sven Wischnowsky [this message]
1999-09-23 14:12 ` Tanaka Akira
1999-09-23 15:12 ` Bart Schaefer
1999-09-25 2:53 ` Tanaka Akira
-- strict thread matches above, loose matches on Subject: below --
1999-09-23 14:07 Sven Wischnowsky
1999-09-23 9:13 Sven Wischnowsky
1999-09-23 13:57 ` Tanaka Akira
1999-09-21 7:15 Sven Wischnowsky
1999-09-20 12:57 Sven Wischnowsky
1999-09-20 8:43 Sven Wischnowsky
1999-09-20 12:15 ` PATCH: was: " Sven Wischnowsky
1999-09-20 16:36 ` Bart Schaefer
1999-09-23 1:39 ` Tanaka Akira
1999-09-19 22:57 Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199909231028.MAA24049@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).