From 6a532a6d902044b7b8cfe6b8bace820d25a16345 Mon Sep 17 00:00:00 2001 From: oda Date: Wed, 10 Jun 2015 12:32:55 +0900 Subject: [PATCH] Fix runtime error: index out of range --- convert.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/convert.go b/convert.go index 1e8b1c9..2669785 100644 --- a/convert.go +++ b/convert.go @@ -223,17 +223,17 @@ var regFuncName = regexp.MustCompile(`[^a-zA-Z0-9_]`) // prevent conflict based on name translation. func safeFunctionName(name string, knownFuncs map[string]int) string { var inBytes, outBytes []byte + var toUpper bool name = strings.ToLower(name) inBytes = []byte(name) for i := 0; i < len(inBytes); i++ { if regFuncName.Match([]byte{inBytes[i]}) { - for j := i; j < len(inBytes) && regFuncName.Match([]byte{inBytes[j]}); j++ { - i++ - } + toUpper = true + } else if toUpper { outBytes = append(outBytes, []byte(strings.ToUpper(string(inBytes[i])))...) - // bytes[i] = strings.ToUpper(string(byte)) + toUpper = false } else { outBytes = append(outBytes, inBytes[i]) }