From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20468 invoked by alias); 28 Oct 2015 17:44:55 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37007 Received: (qmail 6846 invoked from network); 28 Oct 2015 17:44:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-26-563109934c62 Date: Wed, 28 Oct 2015 17:44:48 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads Message-id: <20151028174448.70594180@pwslap01u.europe.root.pri> In-reply-to: <151028100744.ZM18361@torch.brasslantern.com> References: <151015172503.ZM30721@torch.brasslantern.com> <151027194317.ZM17099@torch.brasslantern.com> <151027202340.ZM17146@torch.brasslantern.com> <20151028093504.756c22b1@pwslap01u.europe.root.pri> <151028100744.ZM18361@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsVy+t/xa7qTOQ3DDL7sF7M42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGb+WahT0ylVM3fePtYHxpXgXIyeHhICJxIXWB6wQtpjEhXvr 2boYuTiEBJYySpx5fIgZJCEkMINJ4tJfD4jENkaJd3dnMoIkWARUJQ5/7wOz2QQMJaZumg1m iwhoSew4eZIJxBYWiJO4vPw72CBeAXuJRws2gdVwClhJXFxzgxliaD+zxNYr/8ES/AL6Elf/ fmKCOMleYuaVM4wQzYISPybfYwGxmYEWbN7WxAphy0tsXvMW6lJ1iRt3d7NPYBSahaRlFpKW WUhaFjAyr2IUTS1NLihOSs810itOzC0uzUvXS87P3cQICdqvOxiXHrM6xCjAwajEwyuwxSBM iDWxrLgy9xCjBAezkgivNIthmBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHembvehwgJpCeWpGan phakFsFkmTg4pRoYgyQ5P31kXPXlkUSlQ6Hi9Pl3zj/9H/ZL8zZn1Y27G3rzsqtWewnsSO88 s6SO/Xf7yvtBTJPZTnQcEJab3Wp8rm+6Q1HnPivnS5pBqwKavua8etq+Pv5y507RB9aHBFzt ur9onPznx6d/xYFhWvj6ROXDE38VmL8rTm1aFlHqVG50W/KL88QtSizFGYmGWsxFxYkAQE+w pVYCAAA= On Wed, 28 Oct 2015 10:07:44 -0700 Bart Schaefer 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 */