shithub: riscv

Download patch

ref: db7d1ed2b11cf17c3fc110eeede13ceba17fef33
parent: 713beb6d423144456a458c7bb984a29ae70b3a9e
author: spew <devnull@localhost>
date: Thu Aug 18 04:52:58 EDT 2016

fix awk format printing bugs (thanks aiju)

--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -895,18 +895,21 @@
 		case 'd': case 'i':
 			flag = 2;
 			if(*(s-1) == 'l') break;
-			*(t-1) = 'l';
+			t[-1] = 'l';
 			*t = 'd';
 			*++t = '\0';
 			break;
 		case 'u':
 			flag = *(s-1) == 'l' ? 2 : 3;
-			*t++ = 'u';
+			t[-1] = 'u';
 			*t++ = 'd';
 			*t = '\0';
 			break;				
 		case 'o': case 'x': case 'X':
 			flag = *(s-1) == 'l' ? 2 : 3;
+			t[-1] = 'u';
+			*t++ = *s;
+			*t = '\0';
 			break;
 		case 's':
 			flag = 4;
@@ -939,7 +942,7 @@
 			break;
 		case 1:	sprint(p, fmt, getfval(x)); break;
 		case 2:	sprint(p, fmt, (long) getfval(x)); break;
-		case 3:	sprint(p, fmt, (int) getfval(x)); break;
+		case 3: sprint(p, fmt, (int) getfval(x)); break;
 		case 4:
 			t = getsval(x);
 			n = strlen(t);