-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Strip the leading SDL_ from the pixel format name #2477
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A one-line change to achieve this could be passing pixel_format_name + 4
directly instead of the copying to new memory. This of course, assumes that pixel_format_name
is a non-null pointer and the string has atleast 4 chars (which should be checked, either way)
if (!strncmp(pixel_format_name, "SDL_", 4)) {
pixel_format_name += 4
} (untested code) |
The vidinfo type also has a getter, defined a bit above the str function. This currently does not even return a value for pixel format, so I think this could be an opportunity to fix that (and of course, strip "SDL_" off there as well). ps: |
Yeah I realised that too as I made my comment, but then it's safer (more future-proof) this way and does no harm. |
Should work now:
Output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Documented the 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR 🎉
Fixes issue #1741.
I'm not sure this is the best way to strip 4 characters from a C string, so please let me know.