some code cleanup

This commit is contained in:
leca 2023-02-25 01:58:58 +03:00
parent f910dc9387
commit 3a98096bfd
1 changed files with 7 additions and 3 deletions

10
main.c
View File

@ -42,6 +42,7 @@ void insertInStartString(commandLine *cmdLine, int* toInsert ) {
for (int i = rows - 2; i > 0 ; i --)
for (int j = 0; j < cols; j ++)
cmdLine[i].string[j] = cmdLine[i - 1].string[j];
for (int i = 0; i < cols; i ++)
cmdLine[0].string[i] = toInsert[i];
}
@ -50,11 +51,13 @@ void insertInStartCommandLine(commandLine *cmdLine, commandLine toInsert, int ar
for (int i = arrayLength - 1; i > 0 ; i --) {
for (int j = 0; j < cmdLine[i - 1].length; j ++)
cmdLine[i].string[j] = cmdLine[i - 1].string[j];
cmdLine[i].length = cmdLine[i - 1].length;
cmdLine[i].position = cmdLine[i - 1].position;
}
for (int i = 0; i < toInsert.length; i ++)
cmdLine[0].string[i] = toInsert.string[i];
cmdLine[0].length = toInsert.length;
cmdLine[0].position = toInsert.position;
}
@ -62,6 +65,7 @@ void insertInStartCommandLine(commandLine *cmdLine, commandLine toInsert, int ar
void insert(int *cmd_string, int toInsert , int position, int len) {
for (int i = len + 1; i > position; i --)
cmd_string[i] = cmd_string[i - 1];
cmd_string[position] = toInsert;
}
@ -85,9 +89,9 @@ void resetBuffer (commandLine *buffer) {
}
void copyCommandLine(commandLine* destination, commandLine source) {
for (int i = 0; i < source.length; i ++) {
for (int i = 0; i < source.length; i ++)
destination->string[i] = source.string[i];
}
destination->position = source.position;
destination->length = source.length;
@ -172,8 +176,8 @@ int main (int argc, char* argv[]) {
for (int i = 0; i < 10; i ++) {
printf("%i (%i symbols): ", i, history[i].length);
for (int j = 0; j < history[i].length; j ++)
printf("%c", history[i].string[j]);
printf("\n");
}
break;