about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-09-10 19:11:53 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-09-10 19:11:53 +0000
commit6c887892f9e6261f65767f6fcbeedd27c1137f16 (patch)
treefc2ec36079a4fd7c95452336f1c2abafe438ee85 /Src
parent80acfd135cb41dc63b2e037fe8c18bcf46ce929c (diff)
downloadzsh-6c887892f9e6261f65767f6fcbeedd27c1137f16.tar.gz
zsh-6c887892f9e6261f65767f6fcbeedd27c1137f16.tar.xz
zsh-6c887892f9e6261f65767f6fcbeedd27c1137f16.zip
22685: make printf "%d" \"X handle multibyte characters
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 979075392..dbe50d13c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3938,7 +3938,8 @@ bin_print(char *name, char **args, Options ops, int func)
 		    char *b;
 		    int l;
 		    if (*c == 'b') {
-			b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l,
+			b = getkeystring(metafy(curarg, curlen, META_USEHEAP),
+					 &l,
 					 OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
 					 GETKEYS_PRINTF, &nnl);
 		    } else {
@@ -4004,11 +4005,25 @@ bin_print(char *name, char **args, Options ops, int func)
 
 	    if (type > 0) {
 		if (curarg && (*curarg == '\'' || *curarg == '"' )) {
+		    convchar_t cc;
+#ifdef MULTIBYTE_SUPPORT
+		    if (isset(MULTIBYTE)) {
+			mb_metacharinit();
+			(void)mb_metacharlenconv(metafy(curarg+1, curlen-1,
+							META_USEHEAP), &cc);
+		    }
+		    else
+			cc = WEOF;
+		    if (cc == WEOF)
+			cc = (curlen > 1) ? STOUC(curarg[1]) : 0;
+#else
+		    cc = (curlen > 1) ? STOUC(curarg[1]) : 0;
+#endif
 		    if (type == 2) {
-			doubleval = STOUC(curarg[1]);
+			doubleval = cc;
 			print_val(doubleval);
 		    } else {
-			intval = STOUC(curarg[1]);
+			intval = cc;
 			print_val(intval);
 		    }
 		} else {