aboutsummaryrefslogtreecommitdiffstats
path: root/prog/analysis.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-03-02 16:14:57 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-03-05 12:10:27 +0100
commit002cecf2022de3ab01c87f905477aa3b063d73fc (patch)
tree674ee06d247de287e04017600f7fc52dc7ba58ec /prog/analysis.go
parent5ef8dbdf5a63ccf7e069527dbb2493dc2ef0c319 (diff)
pkg/compiler: allow specifying static size for filename's
Sometimes filenames are embed into structs and need to take fixed space.
Diffstat (limited to 'prog/analysis.go')
-rw-r--r--prog/analysis.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/prog/analysis.go b/prog/analysis.go
index 626af7446..7d5cc0099 100644
--- a/prog/analysis.go
+++ b/prog/analysis.go
@@ -73,11 +73,16 @@ func (s *state) analyzeImpl(c *Call, resources bool) {
case *BufferType:
a := arg.(*DataArg)
if typ.Dir() != DirOut && len(a.Data()) != 0 {
+ val := string(a.Data())
+ // Remove trailing zero padding.
+ for len(val) >= 2 && val[len(val)-1] == 0 && val[len(val)-2] == 0 {
+ val = val[:len(val)-1]
+ }
switch typ.Kind {
case BufferString:
- s.strings[string(a.Data())] = true
+ s.strings[val] = true
case BufferFilename:
- s.files[string(a.Data())] = true
+ s.files[val] = true
}
}
}