1
0
Fork 0

07: C: Fix some warnings

This commit is contained in:
Mia Herkt 2022-12-07 22:30:30 +01:00
parent 6060b590d3
commit 3e5e62fe7b
Signed by: mia
GPG key ID: 72E154B8622EC191

View file

@ -55,19 +55,20 @@ int main(void) {
char l[64];
entry *root = calloc(1, sizeof(entry));
root->isdir++;
entry *current;
entry *current = root;
size_t S = 0, G = 0, required = 0;
while (fgets(l, 64, stdin)) {
l[strlen(l) - 1] = '\0';
if (l[0] == '$') {
if (l[2] == 'c')
if (l[2] == 'c') {
if (l[5] == '/')
current = root;
else if (l[5] == '.')
current = current->parent;
else
current = findent(current, 1, l + 5);
}
} else if (l[0] == 'd') {
if (!findent(current, 1, l + 4))
addent(current, 1, l + 4);
@ -89,11 +90,12 @@ int main(void) {
current->n_entries--;
current = (current->entries++)[0];
} else {
if (current->isdir)
if (current->isdir) {
if (current->size < 100000)
S += current->size;
else if (current->size >= required && (current->size < G || !G))
G = current->size;
}
current = current->parent;
}