iu-coreutils
iu-coreutils copied to clipboard
lnum.c doesnt handle lines longer than 1024 chars
Also no format specifier is used to tell to the program to scan until the newline character is met.
edit: I've mistaken f/scanf with fgets
The solution which I would like to propose is to read the file content at once with malloc, and split the string into tokens. This way no matter how long a single line could be, it will be numbered properly. I will use this strategy to contribute around 10 programs later on next week.
https://github.com/joshhartigan/iu-coreutils/blob/46bfa8d008c000fe6d0a1c78d3d6e7143700f942/lnum.c#L17
Shadowing the function read() isn't pretty.