2019-09-01 HaO maxicode sizeof issue fixed by Christian Schmitz

This commit is contained in:
Harald Oehlmann 2019-09-01 18:14:21 +02:00
parent ba4294a02e
commit 89c2ee6f1d

View File

@ -119,21 +119,21 @@ void maxi_bump(int set[], int character[], int bump_posn) {
} }
/* If the value is present in array, return the value, else return badvalue */ /* If the value is present in array, return the value, else return badvalue */
int value_in_array(int val, int arr[], int badvalue){ int value_in_array(int val, int arr[], int badvalue, int arrLength){
int i; int i;
for(i = 0; i < sizeof(arr); i++){ for(i = 0; i < arrLength; i++){
if(arr[i] == val) return val; if(arr[i] == val) return val;
} }
return badvalue; return badvalue;
} }
/* Choose the best set from previous and next set in the range of the setval array, if no value can be found we return setval[0] */ /* Choose the best set from previous and next set in the range of the setval array, if no value can be found we return setval[0] */
int bestSurroundingSet(int index, int length, int set[], int setval[]) { int bestSurroundingSet(int index, int length, int set[], int setval[], int setLength) {
int badValue = -1; int badValue = -1;
int option1 = value_in_array(set[index - 1], setval, badValue); int option1 = value_in_array(set[index - 1], setval, badValue, setLength);
if (index + 1 < length) { if (index + 1 < length) {
// we have two options to check (previous & next) // we have two options to check (previous & next)
int option2 = value_in_array(set[index + 1], setval, badValue); int option2 = value_in_array(set[index + 1], setval, badValue, setLength);
if (option2 != badValue && option1 > option2) { if (option2 != badValue && option1 > option2) {
return option2; return option2;
} }
@ -188,7 +188,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
/* Special character */ /* Special character */
if (character[i] == 13) { if (character[i] == 13) {
/* Carriage Return */ /* Carriage Return */
set[i] = bestSurroundingSet(i, length, set, set15); set[i] = bestSurroundingSet(i, length, set, set15, 2);
if (set[i] == 5) { if (set[i] == 5) {
character[i] = 13; character[i] = 13;
} else { } else {
@ -199,7 +199,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 28)) { if ((done == 0) && (character[i] == 28)) {
/* FS */ /* FS */
set[i] = bestSurroundingSet(i, length, set, set12345); set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) { if (set[i] == 5) {
character[i] = 32; character[i] = 32;
} }
@ -208,7 +208,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 29)) { if ((done == 0) && (character[i] == 29)) {
/* GS */ /* GS */
set[i] = bestSurroundingSet(i, length, set, set12345); set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) { if (set[i] == 5) {
character[i] = 33; character[i] = 33;
} }
@ -217,7 +217,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 30)) { if ((done == 0) && (character[i] == 30)) {
/* RS */ /* RS */
set[i] = bestSurroundingSet(i, length, set, set12345); set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 5) { if (set[i] == 5) {
character[i] = 34; character[i] = 34;
} }
@ -226,7 +226,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 32)) { if ((done == 0) && (character[i] == 32)) {
/* Space */ /* Space */
set[i] = bestSurroundingSet(i, length, set, set12345); set[i] = bestSurroundingSet(i, length, set, set12345, 5);
if (set[i] == 1) { if (set[i] == 1) {
character[i] = 32; character[i] = 32;
} else if (set[i] == 2) { } else if (set[i] == 2) {
@ -239,7 +239,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 44)) { if ((done == 0) && (character[i] == 44)) {
/* Comma */ /* Comma */
set[i] = bestSurroundingSet(i, length, set, set12); set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) { if (set[i] == 2) {
character[i] = 48; character[i] = 48;
} }
@ -248,7 +248,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 46)) { if ((done == 0) && (character[i] == 46)) {
/* Full Stop */ /* Full Stop */
set[i] = bestSurroundingSet(i, length, set, set12); set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) { if (set[i] == 2) {
character[i] = 49; character[i] = 49;
} }
@ -257,7 +257,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 47)) { if ((done == 0) && (character[i] == 47)) {
/* Slash */ /* Slash */
set[i] = bestSurroundingSet(i, length, set, set12); set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) { if (set[i] == 2) {
character[i] = 50; character[i] = 50;
} }
@ -266,7 +266,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
if ((done == 0) && (character[i] == 58)) { if ((done == 0) && (character[i] == 58)) {
/* Colon */ /* Colon */
set[i] = bestSurroundingSet(i, length, set, set12); set[i] = bestSurroundingSet(i, length, set, set12, 2);
if (set[i] == 2) { if (set[i] == 2) {
character[i] = 51; character[i] = 51;
} }