-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
lib/psdriver: Fix issues with wrong type of arguments to printf #3551
base: main
Are you sure you want to change the base?
Conversation
Each call to the printf function or a related function should include the type and sequence of arguments defined by the format. If the function is passed arguments of a different type or in a different sequence then the arguments are reinterpreted to fit the type and sequence expected, resulting in unpredictable behavior.
This alters the output from int to float, which may not be the expected/wanted outcome. Bear in mind a postscript file is being produced. Just mention this as a caution. |
I can change it to do an explicit cast to an int, the issue is just with an implicit cast between types. I wasn't 100% sure what was appropriate, but it's an easy fix to make. |
I'm not saying this is wrong, only that it changes the output. Looking at the other psdriver functions, formatting of double is made with |
I can't fine specs for PostScript BITMAP to see if these numbers can be floats. Conversion to int would preserve the current behavior. |
I have tried in the last weeks too to find the specs, of at least BOX and BITMAP, but didn't find the info I was looking for. |
There is the PostScript Language Reference. (A couple of weeks ago I was able to download from there, now not...). PostScript is a script language and grass/lib/psdriver/psdriver.ps Lines 50 to 56 in f13a492
This is used later in: grass/lib/psdriver/draw_bitmap.c Line 7 in f13a492
I believe, the The problem I have was to trigger this code, it is likely only implemented as needed for comply to the driver interface: Line 44 in f13a492
Knowing who is behind this driver, the code is likely broadly correct, working, but never put up to the test. |
Each call to the printf function or a related function should include the type and sequence of arguments defined by the format. If the function is passed arguments of a different type or in a different sequence then the arguments are reinterpreted to fit the type and sequence expected, resulting in unpredictable behavior.