From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32716 invoked from network); 18 Oct 2022 15:08:20 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Oct 2022 15:08:20 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1666105700; b=l6izTs10t64jqXXDgBbDPLllM4ptfYSmPq6rYkpKdgtZwI4fGpuc89VjFUcjDSZVlOnU8EtgnA 0S3uMWUcTyy78rNvAZNZnB1wCqzu/AQw3JDDFt1GMdoT8rpdkSeBAG/abAVuAvZkwf72Cg30rG PfttBW9Hs/6BBRVOggNsMW0NdmfXtCBk79pGLx1nM5PVF7VSKAxD9qZ3af09Niv0L8/4RsHItL YL6pqmIT0bsZ6cW4Gn/0JL9DHCTiFfdHXsgbngyGwNnZbVqjOmj1oi1utLmZIKvwOZc45clIkw dbB/wKTuy/64Lhgx0LnypcXuE+vJ1Ni368YO+EVvvEpisw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd01010-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.26; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1666105700; bh=GuE9/9ghvyIMhacXuZUZyy0EDZ4qeXt9RYlKzWkQhMo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=SYjzL1GAzrgm1XqRy7Sn5JMQLeR0duv4wjdh30u1xFbJl6wdfbPXU4iFg5E3jDXs99MEVSEcQg FqQb8N5PC4BljVAIcRD6zku1+3Vg469bVQewrstTNn2ngaAqcBc8KyHuAVwd3pvK5HsHCr2kSb xYJlpb180sxViMK5oPG6YZ0HzOzq6CUDf7VGgI4LhA2WR7v/eYGsxXdtOV4c8wFbqrUD4KqD/h wjMIifl0jLPLWnggy8PJLnod5kFGKam0blw61I3Iw2p4vdNpDL5byZacVBefAIj5omhS2p9RSb tE2sikOQ+hkZsB0+jr9021tn9fILUCXJf9V/TjT4Y/aFpg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=KyuafwWAlP2ACcl2HgfjLGIPb3KysX03yKHPkY5BS/E=; b=kNTJa8wTZuoqNtLQpMxFaJF5l3 C20ECbksN3jhgmVQFoaKthTUfjZuktGPMSImSfxdrnXaItubvfXcb23NiWZBBBVEg7xe23Zn4rdXa iLZvEnZ9DDh660Mjq/Th52JlaHbuozsyI4EqpPV6UCvwAh8cEBau0tM3ADhzFct/74Ffg9uA/Jwoy ZJArRdzF+YdDBQOQ0SeE4Vo7GUdgiGg50mdlDDYbwRysXUGLJPyZK1+4nmhNxuOejpNU/NKoGMo1I olEem1zGrlTtsz0M+i9ERjgzBgpspXCfdVB3+vD7O6edMeW5ziHr9VOTGIKkf6TcDWkopO0ip3wKk c/cV78Yg==; Received: by zero.zsh.org with local id 1okoCZ-000MZZ-Sd; Tue, 18 Oct 2022 15:08:19 +0000 Authentication-Results: zsh.org; iprev=pass (snd01010-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.26; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd01010-bg.im.kddi.ne.jp ([27.86.113.26]:52417 helo=dfmta1031.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1okoCG-000MDz-KW; Tue, 18 Oct 2022 15:08:02 +0000 Received: from mail.biglobe.ne.jp by omta1031.biglobe.ne.jp with ESMTP id <20221018150756453.SWWH.9121.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Wed, 19 Oct 2022 00:07:56 +0900 From: "Jun. T" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH] out of memory error after "edit-command-line" Date: Wed, 19 Oct 2022 00:07:55 +0900 References: To: zsh-workers@zsh.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 50789 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: > 2022/08/13 9:10, Bart Schaefer wrote: >=20 > The following patch fixes this example, but might only be a partial > fix for problems with locally flipping the state of various options > (MONITOR, BANGHIST, SHINSTDIN come to mind). I think really we should > be looping over the options and calling dosetopt() for each one > instead of just memcpy'ing the saved set back on top of the original > ... or at least we need a mapping of the subset of options that have > extra code associated with a change via setopt. In dosetopt(), only MONITOR, EMACSMODE/VIMODE and SUNKEYBOARDHACK have extra code other than new_opts[optno] =3D value. MONITOR: dosetopt() has the extra code only when setting MONITOR to ON. This suggests that just restoring opts[] is enough in doshfunc() when finishing a function, because: If MONITOR was initially off and was set to on locally in a function, no other code will be run even if we call dosetopt() to set it back to = off. If MONITOR was initially on, then the extra code had been already run, and when it was set to off locally in a function nothing extra was done; so again just opts[MONITOR]=3Don is enough in doshfunc().... Is this = correct? EMACS/VI: % bindkey -v % () { setopt localoptions emacs; } % (still using emacs binding) We need to restore the keymap in doshfunc() as in dosetopt(). The problem is that the options EMACS and VI can both be off. In doshfunc() we can't tell to which keymap we should link the 'main' keymap because both EMACS and VI may be off in the saved opts[]. The patch below forces 'bindkey -e/-v' to set the option EMACS or VI. Is this OK? SUNKEYBOARDHACK: this is simple. For inittyptab(): dosetopt() calls inittyptab() if BANGHIST or SHINSTDIN changes. With the patch below doshfunc() calls inittyptab() if BANGHIST, SHINSTDIN or MULTIBYTE changes (This should solve the original problem as Bart's patch). In addition, I think dosetopt() should call inittyptab() also when MULTIBYTE option changes. Otherwise, we will get troubles if MULTIBYTE option is changed not by the setopt builtin but by directly assigning to $options[multibyte]. (bin_setopt() always calls inittyptab(), but this may be redundant) I _hope_ there is no other option that require extra code in doshfunc(). diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index d90838f03..c0a12f71a 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -799,8 +799,11 @@ bin_bindkey(char *name, char **argv, Options ops, = UNUSED(int func)) zwarnnam(name, "no such keymap `%s'", kmname); return 1; } - if(OPT_ISSET(ops,'e') || OPT_ISSET(ops,'v')) + if(OPT_ISSET(ops,'e') || OPT_ISSET(ops,'v')) { linkkeymap(km, "main", 0); + opts[OPT_ISSET(ops,'e') ? EMACSMODE : VIMODE] =3D 1; + opts[OPT_ISSET(ops,'e') ? VIMODE : EMACSMODE] =3D 0; + } } else { kmname =3D NULL; km =3D NULL; diff --git a/Src/exec.c b/Src/exec.c index f2911807c..6b70e8be9 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5961,11 +5961,27 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int = noreturnval) emulation =3D funcsave->emulation; sticky =3D funcsave->sticky; } else if (isset(LOCALOPTIONS)) { + /* we need to call inittyptab() if these options change */ + int init_typtab =3D +#ifdef MULTIBYTE_SUPPORT + funcsave->opts[MULTIBYTE] !=3D opts[MULTIBYTE] = || +#endif + funcsave->opts[BANGHIST] !=3D opts[BANGHIST] || + funcsave->opts[SHINSTDIN] !=3D opts[SHINSTDIN]; + /* just restoring opts[] is not sufficient for these options = */ + if (funcsave->opts[EMACSMODE] !=3D opts[EMACSMODE] || + funcsave->opts[VIMODE] !=3D opts[VIMODE]) + zleentry(ZLE_CMD_SET_KEYMAP, + funcsave->opts[VIMODE] ? VIMODE : EMACSMODE); + if (funcsave->opts[SUNKEYBOARDHACK] !=3D = opts[SUNKEYBOARDHACK]) + keyboardhackchar =3D funcsave->opts[SUNKEYBOARDHACK] ? = '`' : '\0'; /* restore all shell options except PRIVILEGED and = RESTRICTED */ funcsave->opts[PRIVILEGED] =3D opts[PRIVILEGED]; funcsave->opts[RESTRICTED] =3D opts[RESTRICTED]; memcpy(opts, funcsave->opts, sizeof(opts)); emulation =3D funcsave->emulation; + if (init_typtab) + inittyptab(); } else { /* just restore a couple. */ opts[XTRACE] =3D funcsave->opts[XTRACE]; diff --git a/Src/options.c b/Src/options.c index a1fe918fc..a994b563e 100644 --- a/Src/options.c +++ b/Src/options.c @@ -904,7 +904,11 @@ dosetopt(int optno, int value, int force, char = *new_opts) keyboardhackchar =3D (value ? '`' : '\0'); } new_opts[optno] =3D value; - if (optno =3D=3D BANGHIST || optno =3D=3D SHINSTDIN) + if ( +#ifdef MULTIBYTE_SUPPORT + optno =3D=3D MULTIBYTE || +#endif + optno =3D=3D BANGHIST || optno =3D=3D SHINSTDIN) inittyptab(); return 0; }