Browse Source

fix formular parse detection bug

remotes/origin/Input_Handling
Sophia Weber 11 months ago
parent
commit
0dc484092b
  1. 10
      src/inputHandling.c
  2. 2
      src/inputHandling.h

10
src/inputHandling.c

@ -25,13 +25,12 @@ void input() {
} else { } else {
printf("Formular %s not supported", temp.formel); printf("Formular %s not supported", temp.formel);
} }
} }
//Leerzeichen löschen //Leerzeichen löschen
void deleteWhitespace(){ void deleteWhitespace(){
for(int i=0; i<STRINGL; i++){ for(int i=0; i<STRINGL; i++){
if(a[i]==' '){
if((a[i]==' ')||(a[i]=='\n')||(a[i]=='\r')){
for (int j=i; j<STRINGL; j++){ for (int j=i; j<STRINGL; j++){
a[j]=a[j+1]; a[j]=a[j+1];
} }
@ -48,6 +47,7 @@ op readFunction(char* data, int length){
case '/': return opDiv; case '/': return opDiv;
case '*': return opMult; case '*': return opMult;
case '^': return opExp; case '^': return opExp;
case '\0': return opEmpty;
} }
} }
return opNotSupported; return opNotSupported;
@ -83,10 +83,10 @@ char* getnumbers(char* data, int length, calc_op* structure_ref){ //input sind:
token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter
} }
structure_ref->arraylength=i; //Länge des Arrays (also zu berechnende Zahlen) gespeichert structure_ref->arraylength=i; //Länge des Arrays (also zu berechnende Zahlen) gespeichert
if (readFunction(splitPnt, strlen(splitPnt)!=opNotSupported)){
return splitPnt;
} else {
if (readFunction(splitPnt, strlen(splitPnt)+1)!=opNotSupported){
return NULL; return NULL;
} else {
return splitPnt;
} }
} }

2
src/inputHandling.h

@ -2,7 +2,7 @@
#define INPUTHANDLING_H #define INPUTHANDLING_H
typedef enum{ typedef enum{
opAdd, opSub, opDiv, opMult, opExp, opLog, opNotSupported
opAdd, opSub, opDiv, opMult, opExp, opLog, opEmpty, opNotSupported
}op; }op;
typedef struct { typedef struct {

Loading…
Cancel
Save