Skip to content

xdu.c: static void parse_file(char* filename) is faulty #26

Closed
thomas opened this issue Jun 29, 2021 · 3 comments
Closed

xdu.c: static void parse_file(char* filename) is faulty #26

thomas opened this issue Jun 29, 2021 · 3 comments

Comments

@thomas
Copy link
Contributor

thomas commented Jun 29, 2021

Assuming a directory like '1234_bla', then du -k 1234_bla | xdu would display '_bla' at top level.

This is due to (scanning whitespace and numbers):

        while ((*buff >= '0' && *buff <= '9')
            || (*buff == ' ' || *buff == '\t')) {
            buff++;

A possible fix (scan for non-ws at the beginning, than for ws):

        while (*buff != ' ' && *buff != '\t') { buff++; }
        while (*buff == ' ' || *buff == '\t') { buff++; }

@donald
Copy link
Contributor

donald commented Jun 29, 2021

Better. OTOH, sscanf already found the end of number+whitespaces. Position of rest could be captured with "%n"

Addendum: Format string needs an additional " " to skip whitespace. "%lld %n" might do.

@wwwutz
Copy link
Contributor

wwwutz commented Jun 29, 2021

with "%n".

Please do not use this as SSID.

thomas added a commit that referenced this issue Jul 9, 2021
Former version would also take leading numbers
from du records.
(Closes github issue #26)
@thomas
Copy link
Contributor Author

thomas commented Jul 9, 2021

Closed by d7f8c84

@thomas thomas closed this as completed Jul 9, 2021
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants