zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] Document the EC_NODUP, EC_DUP, EC_DUPTOK triplet.
Date: Fri,  7 Aug 2020 07:02:43 +0000	[thread overview]
Message-ID: <20200807070242.21561-1-danielsh@tarpaulin.shahaf.local2> (raw)

All uses reviewed; no functional change.
---
The ecgetstr() docstring is incomplete, I'm afraid, but I'm sending this
as is since it's an improvement and I need to test something in the new
archive scripts.

Cheers,

Daniel

 Src/parse.c |  7 +++++++
 Src/zsh.h   | 23 ++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/Src/parse.c b/Src/parse.c
index 10c9b4c29..b09c7989a 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2828,6 +2828,13 @@ freeeprog(Eprog p)
     }
 }
 
+/*
+ * dup is of type 'enum ec_dup_t'.
+ *
+ * If tokflag is not NULL, *tokflag will be set to 1 if the string contains
+ * tokens and to 0 otherwise.
+ */
+
 /**/
 char *
 ecgetstr(Estate s, int dup, int *tokflag)
diff --git a/Src/zsh.h b/Src/zsh.h
index a97e83192..94f5099c6 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -862,9 +862,26 @@ struct eccstr {
     int hashval;
 };
 
-#define EC_NODUP  0
-#define EC_DUP    1
-#define EC_DUPTOK 2
+/*
+ * Values for the "dup" parameter to ecgetstr().
+ */
+enum ec_dup_t {
+    /* 
+     * Make no promises about how the return value is allocated, except that
+     * the caller does not need to explicitly free it.  It might be heap allocated,
+     * a static string, or anything in between.
+     */
+    EC_NODUP = 0,
+
+    /* Allocate the return value from the heap. */
+    EC_DUP = 1,
+
+    /* 
+     * If the string contains tokens (as indicated by the least significant bit
+     * of the wordcode), behave as EC_DUP; otherwise, as EC_NODUP.
+     */
+    EC_DUPTOK = 2
+};
 
 /* See comment at the top of Src/parse.c for details. */
 #define WC_CODEBITS 5


                 reply	other threads:[~2020-08-07  7:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200807070242.21561-1-danielsh@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /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).