shithub: riscv

Download patch

ref: a7b06e0fdd02355b2dc9ce2349afbd25bf8287a3
parent: cde69a78225ee3b8c5e46ddb98ce4bd599d4f355
author: aiju <devnull@localhost>
date: Tue Sep 29 16:49:28 EDT 2015

timepic: string support

--- a/sys/src/cmd/timepic.c
+++ b/sys/src/cmd/timepic.c
@@ -55,6 +55,7 @@
 	SYM = -2,
 	NUM = -3,
 	EOF = -4,
+	STR = -5,
 };
 
 static int
@@ -71,6 +72,7 @@
 		case SYM: return fmtprint(f, "'%s'", sname);
 		case NUM: return fmtprint(f, "%g", sval);
 		case EOF: return fmtprint(f, "EOF");
+		case STR: return fmtprint(f, "%#q", sname);
 		default: return fmtprint(f, "%d", n);
 		}
 }
@@ -210,6 +212,14 @@
 		*p = 0;
 		return SYM;
 	}
+	if(c == '\''){
+		for(p = sname; c = Bgetc(bp), c != '\'' || Bgetc(bp) == '\''; )
+			if(p < sname + sizeof(sname) - 1)
+				*p++ = c;
+		Bungetc(bp);
+		*p = 0;
+		return STR;
+	}
 	return c;
 }
 
@@ -337,6 +347,9 @@
 			return VH;
 		e->data = smprint("%g", sval);
 		return VMULT;
+	case STR:
+		e->data = strdup(sname);
+		return VMULT;
 	default:
 		error(lineno, "unexpected %T", t);
 		return VZ;
@@ -651,6 +664,9 @@
 			else
 				signal(s->name);
 			break;
+		case STR:
+			signal(sname);
+			break;
 		case CMD:
 			if(strcmp(sname, "TPE") == 0)
 				goto end;
@@ -714,6 +730,7 @@
 	int i;
 
 	fmtinstall('T', Tfmt);
+	quotefmtinstall();
 
 	ARGBEGIN {
 	default: usage();