Commit ad863046 authored by Robert Griesemer's avatar Robert Griesemer

- set initial value in flag variable if provided

R=r
DELTA=10  (9 added, 0 deleted, 1 changed)
OCL=17806
CL=17812
parent cec64a2d
...@@ -111,6 +111,9 @@ type BoolValue struct { ...@@ -111,6 +111,9 @@ type BoolValue struct {
} }
func NewBoolValue(val bool, p *bool) *BoolValue { func NewBoolValue(val bool, p *bool) *BoolValue {
if p != nil {
*p = val
}
return &BoolValue{val, p} return &BoolValue{val, p}
} }
...@@ -164,6 +167,9 @@ type IntValue struct { ...@@ -164,6 +167,9 @@ type IntValue struct {
} }
func NewIntValue(val int64, p *int64) *IntValue { func NewIntValue(val int64, p *int64) *IntValue {
if p != nil {
*p = val
}
return &IntValue{val, p} return &IntValue{val, p}
} }
...@@ -214,6 +220,9 @@ type StringValue struct { ...@@ -214,6 +220,9 @@ type StringValue struct {
} }
func NewStringValue(val string, p *string) *StringValue { func NewStringValue(val string, p *string) *StringValue {
if p != nil {
*p = val
}
return &StringValue{val, p} return &StringValue{val, p}
} }
...@@ -397,7 +406,7 @@ func (f *Flags) ParseOne(index int) (ok bool, next int) ...@@ -397,7 +406,7 @@ func (f *Flags) ParseOne(index int) (ok bool, next int)
} }
} }
name := s[num_minuses : len(s)]; name := s[num_minuses : len(s)];
if len(name) == 0 || name[0] == '-' || name[0]=='=' { if len(name) == 0 || name[0] == '-' || name[0] == '=' {
print("bad flag syntax: ", s, "\n"); print("bad flag syntax: ", s, "\n");
Usage(); Usage();
} }
......
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