Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads
On Wed, 28 Oct 2015 10:07:44 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Of course when run from the command prompt $REPLY is *correctly* being
> set as a global, so there shouldn't be a warning.
>
> However:
>
> burner% zmodload zsh/net/tcp
> burner% setopt warncreateglobal
> burner% print $+REPLY
> 0
> burner% () { ztcp localhost 12345 }
> burner% print ${(t)REPLY}
> integer
> burner%
>
> So no warning, no. setiparam() is coming in at too low a level.
I wonder if the existing setsparam() etc. functions, which are currently
just aliases or front-ends for assignsparam() etc. with no warnings,
could be modified to add the flag based on the option? That would save
a lot of mess in the following (although setiparam_no_convert() still
needs to be a separate function --- unless we decide setiparam() should
always do that but that's not obviously correct).
pws
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index f683496..c5adcd4 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -132,7 +132,9 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
/* allow to be closed explicitly */
fdtable[sfd] = FDT_EXTERNAL;
- setiparam("REPLY", sfd);
+ assigniparam_no_convert(
+ "REPLY", (zlong)sfd,
+ isset(WARNCREATEGLOBAL) ? ASSPM_WARN_CREATE : 0);
if (verbose)
printf("%s listener is on fd %d\n", soun.sun_path, sfd);
@@ -220,7 +222,9 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
sfd = rfd;
}
- setiparam("REPLY", sfd);
+ assigniparam_no_convert(
+ "REPLY", (zlong)sfd,
+ isset(WARNCREATEGLOBAL) ? ASSPM_WARN_CREATE : 0);
if (verbose)
printf("new connection from %s is on fd %d\n", soun.sun_path, sfd);
@@ -261,7 +265,9 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
fdtable[sfd] = FDT_EXTERNAL;
}
- setiparam("REPLY", sfd);
+ assigniparam_no_convert(
+ "REPLY", (zlong)sfd,
+ isset(WARNCREATEGLOBAL) ? ASSPM_WARN_CREATE : 0);
if (verbose)
printf("%s is now on fd %d\n", soun.sun_path, sfd);
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index 7b0dcc7..b16d21c 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -461,7 +461,9 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
- setiparam("REPLY", sess->fd);
+ assigniparam_no_convert(
+ "REPLY", (zlong)sess->fd,
+ isset(WARNCREATEGLOBAL) ? ASSPM_WARN_CREATE : 0);
if (verbose)
printf("%d listener is on fd %d\n", ntohs(sess->sock.in.sin_port), sess->fd);
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 9741ee2..1100489 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -464,7 +464,9 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
#endif
errno == EINTR));
- setiparam("REPLY", master);
+ assigniparam_no_convert(
+ "REPLY", (zlong)master,
+ isset(WARNCREATEGLOBAL) ? ASSPM_WARN_CREATE : 0);
return 0;
}
diff --git a/Src/params.c b/Src/params.c
index a8abb28..9ed998f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3025,6 +3025,24 @@ setiparam(char *s, zlong val)
return setnparam(s, mnval);
}
+/*
+ * Set an integer parameter without forcing creation of an integer type.
+ * This is useful if the integer is going to be set to a parmaeter which
+ * would usually be scalar but may not exist.
+ */
+
+/**/
+mod_export Param
+assigniparam_no_convert(char *s, zlong val, int flags)
+{
+ /*
+ * If the target is already an integer, thisgets converted
+ * back. Low technology rules.
+ */
+ char buf[BDIGBUFSIZE];
+ convbase(buf, val, 10);
+ return assignsparam(s, ztrdup(buf), flags);
+}
/* Unset a parameter */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author