iu-coreutils icon indicating copy to clipboard operation
iu-coreutils copied to clipboard

lnum.c doesnt handle lines longer than 1024 chars

Open su8 opened this issue 7 years ago • 2 comments

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

su8 avatar Dec 09 '17 22:12 su8

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.

su8 avatar Dec 09 '17 22:12 su8

https://github.com/joshhartigan/iu-coreutils/blob/46bfa8d008c000fe6d0a1c78d3d6e7143700f942/lnum.c#L17

Shadowing the function read() isn't pretty.

su8 avatar Dec 17 '17 19:12 su8