zsh-workers
 help / color / mirror / Atom feed
* [PATCH] Document the EC_NODUP, EC_DUP, EC_DUPTOK triplet.
@ 2020-08-07  7:02 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2020-08-07  7:02 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-07  7:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07  7:02 [PATCH] Document the EC_NODUP, EC_DUP, EC_DUPTOK triplet Daniel Shahaf

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git