summaryrefslogtreecommitdiff
path: root/protoReformat.go
diff options
context:
space:
mode:
Diffstat (limited to 'protoReformat.go')
-rw-r--r--protoReformat.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/protoReformat.go b/protoReformat.go
index 8b49879..77cc723 100644
--- a/protoReformat.go
+++ b/protoReformat.go
@@ -8,6 +8,7 @@ import (
"iter"
"os"
"regexp"
+ "strconv"
"strings"
sync "sync"
@@ -565,6 +566,23 @@ func (msg *FormatMsg) formatVarLine(line string, dbg string) string {
vartype, varname, id, end := tokenMsgVar(line)
end = strings.TrimSpace(end)
+
+ if argv.Renumber {
+ // allows auto-renumbering
+ newint, err := strconv.Atoi(id)
+ if err != nil {
+ log.Info("i is wrong", msg, err)
+ panic("what?")
+ }
+ msg.Counter += 1
+ if int(msg.Counter) != newint {
+ // panic("you can't count")
+ log.Info("counter is wrong", newint, id, msg.Header)
+ }
+ id = fmt.Sprintf("%d", msg.Counter)
+ }
+ // log.Info("counter =", newint, msg.Header)
+ // msg.Counter = int32(newint)
id = id + ";"
newline := fmt.Sprintf(hmm, vartype, varname, id, end)