diff options
author | June McEnroe <june@causal.agency> | 2019-01-12 15:09:52 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-01-12 15:09:52 -0500 |
commit | f57d2c62e896a2017f72956c72d873a67259004a (patch) | |
tree | 6c3c39d72613165043cd2633e5fff477ef37d9aa /bin | |
parent | Install gnupg2 from pkgsrc and symlink gpg (diff) | |
download | src-f57d2c62e896a2017f72956c72d873a67259004a.tar.gz src-f57d2c62e896a2017f72956c72d873a67259004a.zip |
Set PSlit like NetBSD sh
Diffstat (limited to '')
-rw-r--r-- | bin/cash/histedit.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/bin/cash/histedit.c b/bin/cash/histedit.c index 3c77c6e8..92d8170a 100644 --- a/bin/cash/histedit.c +++ b/bin/cash/histedit.c @@ -177,10 +177,26 @@ sethistsize(const char *hs) } void -setpslit(const char *lit) { - if (el != NULL && *lit < 0x20) { - el_set(el, EL_PROMPT_ESC, getprompt, *lit); - el_set(el, EL_RPROMPT_ESC, getrprompt, *lit); +setpslit(const char *lit_ch) { + wchar_t wc; + + if (!(iflag && editing && el)) + return; + + if (lit_ch == NULL) { + el_set(el, EL_PROMPT, getprompt); + el_set(el, EL_RPROMPT, getrprompt); + return; + } + + mbtowc(&wc, NULL, 1); /* state init */ + + if (mbtowc(&wc, lit_ch, strlen(lit_ch)) <= 0) { + el_set(el, EL_PROMPT, getprompt); + el_set(el, EL_RPROMPT, getrprompt); + } else { + el_set(el, EL_PROMPT_ESC, getprompt, (int)wc); + el_set(el, EL_RPROMPT_ESC, getrprompt, (int)wc); } } |