From 443b8b8a9a2a335a4da7ca7e6839abd2c1d029da Mon Sep 17 00:00:00 2001
From: Sophia Weber <sophia-irmhild.weber1@informatik.hs-fulda.de>
Date: Sun, 28 Jan 2024 12:12:25 +0100
Subject: [PATCH] refactoring: unambiguous variables

---
 src/inputHandling.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/inputHandling.c b/src/inputHandling.c
index 3d1ff4a..6229f21 100644
--- a/src/inputHandling.c
+++ b/src/inputHandling.c
@@ -26,9 +26,9 @@ void input(char* formulaString, int length) {
 
 //Leerzeichen löschen
 void deleteWhitespace(char* formulaString, int length){
-    for(int i=0; i<length; i++){
-        if((formulaString[i] == ' ') || (formulaString[i] == '\n') || (formulaString[i] == '\r')){
-            for (int j=i; j<length; j++){
+    for(int stringPos=0; stringPos < length; stringPos++){
+        if((formulaString[stringPos] == ' ') || (formulaString[stringPos] == '\n') || (formulaString[stringPos] == '\r')){
+            for (int j=stringPos; j < length; j++){
                 formulaString[j]=formulaString[j + 1];
             }
         }
@@ -37,8 +37,8 @@ void deleteWhitespace(char* formulaString, int length){
 
 //Einfachste Rechenoperationen lesen
 op readFunction(char* formulaString, int length){
-    for(int i=0; i<length; i++){
-        switch (formulaString[i]){
+    for(int stringCount=0; stringCount < length; stringCount++){
+        switch (formulaString[stringCount]){
             case '+': return opAdd;
             case '-': return opSub;
             case '/': return opDiv;
@@ -54,7 +54,7 @@ op readFunction(char* formulaString, int length){
 char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //input sind: string, länge vom String, berechnungsstruct
     // char tmp[length];
     char* splitPnt;
-    int i = 0;
+    int numPos = 0;
     char delimiter;
     switch (formulaRef->funktionstyp) {
         case opAdd:
@@ -74,12 +74,12 @@ char* getNumbers(char* formulaString, int length, calc_op* formulaRef){ //input
     // memcpy(tmp, formulaString, length);     //string kopiert
     char *token = strtok(formulaString, &delimiter); //An der Stelle von dem ersten Plus wird ein NULL (Stringende) gesetzt
     while (token != NULL) {
-        formulaRef->array[i] = atof(token);  // String zu double konvertiert
-        i++;
+        formulaRef->array[numPos] = atof(token);  // String zu double konvertiert
+        numPos++;
         splitPnt = token;
         token = strtok(NULL, "+"); //Sucht von der letzten Plus-Stelle an weiter
     }
-    formulaRef->arraylength=i; //Länge des Arrays (also zu berechnende Zahlen) gespeichert
+    formulaRef->arraylength=numPos; //Länge des Arrays (also zu berechnende Zahlen) gespeichert
     op type = readFunction(splitPnt, strlen(splitPnt)+1);
     if (type != opNotSupported && type != opEmpty){
         return splitPnt;
@@ -103,8 +103,8 @@ void showStruct(calc_op* formulaRef){
             printf("Fehler bei Auswahl der Rechenoperationen \n");
     }
     printf("Calculation Variables:\n");
-    for (int i = 0; i < formulaRef->arraylength; ++i) {
-        printf("Array[%i] = %f\n", i, formulaRef->array[i]);
+    for (int arrayCount = 0; arrayCount < formulaRef->arraylength; ++arrayCount) {
+        printf("Array[%i] = %f\n", arrayCount, formulaRef->array[arrayCount]);
     }
     printf("Result: %f", formulaRef->result);
 }
\ No newline at end of file