Skip to content

Commit

Permalink
Merge pull request #1797 from xushiwei/q
Browse files Browse the repository at this point in the history
ClassNameAndExt: use global replacer
  • Loading branch information
xushiwei authored Mar 8, 2024
2 parents 27e61bc + 0b4db18 commit 40d509f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cl/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ func (p *gmxProject) getScheds(cb *gox.CodeBuilder) []goast.Stmt {
return p.schedStmts
}

var (
repl = strings.NewReplacer(":", "", "#", "", "-", "_", ".", "_")
)

func ClassNameAndExt(file string) (name, clsfile, ext string) {
fname := filepath.Base(file)
clsfile, ext = modfile.SplitFname(fname)
name = clsfile
if strings.ContainsAny(name, ":-.") {
name = strings.NewReplacer(":", "", "-", "_", ".", "_").Replace(name)
if strings.ContainsAny(name, ":#-.") {
name = repl.Replace(name)
}
return
}
Expand Down

0 comments on commit 40d509f

Please sign in to comment.