Merge pull request #96 from tsu-ku-ne/master

Fix runtime error: index out of range
pull/4/head
Jim Teeuwen 2015-06-10 11:06:00 +02:00
commit eb723d5626
1 changed files with 4 additions and 4 deletions

View File

@ -223,17 +223,17 @@ var regFuncName = regexp.MustCompile(`[^a-zA-Z0-9_]`)
// prevent conflict based on name translation. // prevent conflict based on name translation.
func safeFunctionName(name string, knownFuncs map[string]int) string { func safeFunctionName(name string, knownFuncs map[string]int) string {
var inBytes, outBytes []byte var inBytes, outBytes []byte
var toUpper bool
name = strings.ToLower(name) name = strings.ToLower(name)
inBytes = []byte(name) inBytes = []byte(name)
for i := 0; i < len(inBytes); i++ { for i := 0; i < len(inBytes); i++ {
if regFuncName.Match([]byte{inBytes[i]}) { if regFuncName.Match([]byte{inBytes[i]}) {
for j := i; j < len(inBytes) && regFuncName.Match([]byte{inBytes[j]}); j++ { toUpper = true
i++ } else if toUpper {
}
outBytes = append(outBytes, []byte(strings.ToUpper(string(inBytes[i])))...) outBytes = append(outBytes, []byte(strings.ToUpper(string(inBytes[i])))...)
// bytes[i] = strings.ToUpper(string(byte)) toUpper = false
} else { } else {
outBytes = append(outBytes, inBytes[i]) outBytes = append(outBytes, inBytes[i])
} }