Commit 19692bee authored by Russ Cox's avatar Russ Cox

treat "" as empty

R=r
DELTA=10  (10 added, 0 deleted, 0 changed)
OCL=27479
CL=27481
parent 816f5b31
...@@ -308,6 +308,8 @@ func empty(v reflect.Value, indirect_ok bool) bool { ...@@ -308,6 +308,8 @@ func empty(v reflect.Value, indirect_ok bool) bool {
return true return true
} }
switch v.Type().Kind() { switch v.Type().Kind() {
case reflect.StringKind:
return v.(reflect.StringValue).Get() == "";
case reflect.StructKind: case reflect.StructKind:
return false; return false;
case reflect.ArrayKind: case reflect.ArrayKind:
......
...@@ -29,6 +29,7 @@ type S struct { ...@@ -29,6 +29,7 @@ type S struct {
data []T; data []T;
pdata []*T; pdata []*T;
empty []*T; empty []*T;
emptystring string;
null []*T; null []*T;
} }
...@@ -162,14 +163,21 @@ var tests = []*Test { ...@@ -162,14 +163,21 @@ var tests = []*Test {
"HEADER=78\n" "HEADER=78\n"
"Header=77\n" "Header=77\n"
}, },
&Test{ &Test{
"{raw}\n" "{raw}\n"
"{raw|html}\n", "{raw|html}\n",
"&<>!@ #$%^\n" "&<>!@ #$%^\n"
"&amp;&lt;&gt;!@ #$%^\n" "&amp;&lt;&gt;!@ #$%^\n"
}, },
&Test{
"{.section emptystring}emptystring{.end}\n"
"{.section header}header{.end}\n",
"\nheader\n"
},
} }
func TestAll(t *testing.T) { func TestAll(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment