In CDL, there's a few sequence point issues in eps.c in the functions eps_writeMono() and eps_writeMonoRGB(). I think I know what was intended by the code but since the actual behavior of the code is not well-defined, I have to ask what the intended behavior is. Both sections use the MONO macro from eps.h:
PHP Formatted Code
#define MONO(rd,gn,bl) ((int)(rd*11 + gn*16 + bl*5) >> 5) /*.33R+ .5G+ .17B*/
The parameters of this macro are missing their parenthesis guards and it should itself be changed to
PHP Formatted Code
#define MONO(rd,gn,bl) ((int)((rd)*11 + (gn)*16 + (bl)*5) >> 5) /*.33R+ .5G+ .17B*/
to prevent unintuitive behavior. For example using the current definition, if x and y are some values, MONO(x+y,0,0) would not in general be equal to MONO((x+y),0,0). (Also, off the top of my head I don't know where the ".33R+ .5G+ .17B" values come from and if they are calculated or ad hoc.)
In
eps_writeMono(), here's the offending statement:
PHP Formatted Code
pval
= (uchar
) MONO
(cmap
->r[*pix
], cmap
->g[*pix
], cmap
->b[*pix
++]);
I think this line is intended to do
PHP Formatted Code
pval
= (uchar
) MONO
(cmap
->r[*pix
], cmap
->g[*pix
], cmap
->b[*pix
]); pix
++;
Similarly, in
eps_writeMonoRGB(), there are two statements like this
PHP Formatted Code
pval
= (uchar
) MONO
(*pix
++, *pix
++, *pix
++);
I think this line, which is far more problematic than the previous one, is intended as
PHP Formatted Code
pval
= (uchar
) MONO
(*pix
, *pix
, *pix
); pix
+=3;
Currently, when compiled, these statements issue sequence-point warnings from gcc:
PHP Formatted Code
eps
.c
: In
function ‘eps_writeMono’
:
eps
.c
:813:25: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
eps
.c
:813:25: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
eps
.c
: In
function ‘eps_writeMonoRGB’
:
eps
.c
:860:20: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
eps
.c
:860:20: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
eps
.c
:867:20: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
eps
.c
:867:20: warning
: operation on ‘pix’ may be undefined
[-Wsequence
-point
]
Since by definition the interpretation of these statements is compiler dependent, I cannot say for sure what the intended meaning. I think the intended behavior is obvious and that I've guessed correctly but could I get confirmation that:
a) the MONO macro's change is good
b) my suggested meaning for eps_writeMono()'s statement
c) my suggested meaning for the eps_writeMonoRGB()'s statement.
Cheers,
Jason