07: C: Fix some warnings
This commit is contained in:
parent
6060b590d3
commit
3e5e62fe7b
|
@ -55,19 +55,20 @@ int main(void) {
|
||||||
char l[64];
|
char l[64];
|
||||||
entry *root = calloc(1, sizeof(entry));
|
entry *root = calloc(1, sizeof(entry));
|
||||||
root->isdir++;
|
root->isdir++;
|
||||||
entry *current;
|
entry *current = root;
|
||||||
size_t S = 0, G = 0, required = 0;
|
size_t S = 0, G = 0, required = 0;
|
||||||
|
|
||||||
while (fgets(l, 64, stdin)) {
|
while (fgets(l, 64, stdin)) {
|
||||||
l[strlen(l) - 1] = '\0';
|
l[strlen(l) - 1] = '\0';
|
||||||
if (l[0] == '$') {
|
if (l[0] == '$') {
|
||||||
if (l[2] == 'c')
|
if (l[2] == 'c') {
|
||||||
if (l[5] == '/')
|
if (l[5] == '/')
|
||||||
current = root;
|
current = root;
|
||||||
else if (l[5] == '.')
|
else if (l[5] == '.')
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
else
|
else
|
||||||
current = findent(current, 1, l + 5);
|
current = findent(current, 1, l + 5);
|
||||||
|
}
|
||||||
} else if (l[0] == 'd') {
|
} else if (l[0] == 'd') {
|
||||||
if (!findent(current, 1, l + 4))
|
if (!findent(current, 1, l + 4))
|
||||||
addent(current, 1, l + 4);
|
addent(current, 1, l + 4);
|
||||||
|
@ -89,11 +90,12 @@ int main(void) {
|
||||||
current->n_entries--;
|
current->n_entries--;
|
||||||
current = (current->entries++)[0];
|
current = (current->entries++)[0];
|
||||||
} else {
|
} else {
|
||||||
if (current->isdir)
|
if (current->isdir) {
|
||||||
if (current->size < 100000)
|
if (current->size < 100000)
|
||||||
S += current->size;
|
S += current->size;
|
||||||
else if (current->size >= required && (current->size < G || !G))
|
else if (current->size >= required && (current->size < G || !G))
|
||||||
G = current->size;
|
G = current->size;
|
||||||
|
}
|
||||||
|
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue