-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of JASC-PAL #620
base: master
Are you sure you want to change the base?
Refactor of JASC-PAL #620
Conversation
Simplified the line-reading function to use `fgets()` which handles windows/unix line endings internally. Simplified the main palette-reading function, and consolidated all the error checking logic in it. I added checks for as many errors I could think of, but happy to add more checks if anyone has suggestions. Thanks to my friend Lito, who knows C much better than me, and workshopped the bones of this refactor with me.
Colour number parsing reverted to use `ParseNumber()` to handle long to int conversion and malformed line errors Colour number error message reverted to specify minimum value (1) Colour channels checked for being in-bounds before assignment
Sorry for the delay. After more testing I'm still seeing some error messages worse than before.
and the error I get now is
|
No rush, I really appreciate you looking over this. I tried to replicate the issue, but adding your example line to a new test set palette didn't produce the same results. Could you share the palette you were testing with? Here's the full set of test palettes I've been using to check the changes I've made, now including 'five colours.pal'. I run them all with |
Fixed range on number of colours error message to [1, 256] Added newlines to colour component out-of-range errors Co-Authored-By: Sophia <[email protected]>
New test set with a palette with an out-of-range colour component |
I changed this color |
@waterwheels This is because It's probably better to avoid trying to |
Thank you, that confirms my current line of testing. Increasing the max line length arbitrarily large 'solves' this issue, but that's not really a solution, so I'm working on having |
Unfortunately |
Fixed error where `\r` in a windows line-ending palette could fit in line buffer but the following `\n` would exceed it and cause the next line read to be empty. Func now checks what index the first newline char is found at, and if it's greater than the max length - 3 (to account for `\r\n\0`) throws a line too long error.
Added checks to successful line reading of JASC-PAL, version code, and num colours lines. Additionally added a check that the number of colours line is max 3 chars long (excluding `\0`) to make sure we're not just parsing the first colour channel Co-Authored-By: Sophia <[email protected]>
Simplified the line-reading function to use
fgets()
which handles windows/unix line endings internally. Simplified the main palette-reading function, and consolidated all the error checking logic in it.I added checks for as many errors I could think of, but happy to add more checks if anyone has suggestions.
Thanks to my friend Lito, who knows C much better than me, and workshopped the bones of this refactor with me.