mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Remove redundant builtin.TrimQuotes function
This commit is contained in:
1 parent
404b149a9a
commit
5f5791e56d
5 files changed
+5
-13
No files matched your search
@@ -442,7 +442,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
case t.KeyError, t.KeyStatus, t.KeySuspension:
|
||||
status := g.statusMap[n.ID1()]
|
||||
if status.name == "" {
|
||||
msg := builtin.TrimQuotes(n.ID1().Str(g.tm))
|
||||
msg, _ := t.Unescape(n.ID1().Str(g.tm))
|
||||
z := builtin.StatusMap[msg]
|
||||
if z.Message == "" {
|
||||
return fmt.Errorf("no status code for %q", msg)
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/google/wuffs/lang/builtin"
|
||||
"github.com/google/wuffs/lang/generate"
|
||||
|
||||
a "github.com/google/wuffs/lang/ast"
|
||||
@@ -180,7 +179,7 @@ func (h *genHelper) genDirDependencies(qualifiedFilenames []string) error {
|
||||
continue
|
||||
}
|
||||
useDirname := h.tm.ByID(n.Use().Path())
|
||||
useDirname = builtin.TrimQuotes(useDirname)
|
||||
useDirname, _ = t.Unescape(useDirname)
|
||||
if err := h.gen(useDirname, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -60,10 +60,3 @@ func init() {
|
||||
|
||||
// TODO: a collection of forbidden variable names like and, or, not, as, ref,
|
||||
// deref, false, true, in, out, this, u8, u16, etc?
|
||||
|
||||
func TrimQuotes(s string) string {
|
||||
if len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"' {
|
||||
return s[1 : len(s)-1]
|
||||
}
|
||||
return s
|
||||
}
|
||||
+2
-2
@@ -22,7 +22,6 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/google/wuffs/lang/base38"
|
||||
"github.com/google/wuffs/lang/builtin"
|
||||
|
||||
a "github.com/google/wuffs/lang/ast"
|
||||
t "github.com/google/wuffs/lang/token"
|
||||
@@ -246,8 +245,9 @@ func (c *Checker) checkStatus(node *a.Node) error {
|
||||
n := node.Status()
|
||||
id := n.Message()
|
||||
if other, ok := c.statuses[id]; ok {
|
||||
s, _ := t.Unescape(id.Str(c.tm))
|
||||
return &Error{
|
||||
Err: fmt.Errorf("check: duplicate status %q", builtin.TrimQuotes(id.Str(c.tm))),
|
||||
Err: fmt.Errorf("check: duplicate status %q", s),
|
||||
Filename: n.Filename(),
|
||||
Line: n.Line(),
|
||||
OtherFilename: other.Status.Filename(),
|
||||
|
||||
+1
-1
@@ -633,7 +633,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
if s, ok := q.c.statuses[n.ID1()]; ok {
|
||||
declaredKeyword = s.Status.Keyword()
|
||||
} else {
|
||||
msg := builtin.TrimQuotes(n.ID1().Str(q.tm))
|
||||
msg, _ := t.Unescape(n.ID1().Str(q.tm))
|
||||
z, ok := builtin.StatusMap[msg]
|
||||
if !ok {
|
||||
return fmt.Errorf("check: no error or status with message %q", msg)
|
||||
|
||||
Reference in new issue
Block a user