Initialize identity for sigma < 256
Change-Id: I18305fc2d9f852b4567e25771c01ad190322e224
diff --git a/matrix.go b/matrix.go
index 565de87..567430b 100644
--- a/matrix.go
+++ b/matrix.go
@@ -37,11 +37,16 @@
stateCount: auto.stateCount,
}
- for i := 0; i < 256; i++ {
- mat.sigmaASCII[i] = mat.identity
+ max := 0
+
+ // Init with identity
+ if mat.identity != -1 {
+ for i := 0; i < 256; i++ {
+ mat.sigmaASCII[i] = mat.identity
+ }
+ max = mat.identity
}
- max := 0
for num, sym := range auto.sigmaRev {
if int(sym) < 256 {
mat.sigmaASCII[int(sym)] = num
@@ -272,6 +277,13 @@
sigmaCount := int(bo.Uint16(buf[12:14]))
arraySize := (mat.stateCount + 1) * sigmaCount
+ // Init with identity
+ if mat.identity != -1 {
+ for i := 0; i < 256; i++ {
+ mat.sigmaASCII[i] = mat.identity
+ }
+ }
+
for x := 0; x < sigmaCount; x++ {
sym, _, err := r.ReadRune()
if err == nil && sym != 0 {
@@ -403,11 +415,6 @@
eot = true
}
a = mat.sigmaASCII[int(char)]
-
- if a == 0 && mat.identity != -1 {
- a = mat.identity
- }
-
} else {
a, ok = mat.sigma[char]