Closed dkosovic closed 1 week ago
I replaced the existing strip trailing whitespaces while loop with the following and it seems to work correctly:
mptr--;
while (mptr > make && *mptr == ' ') {
/*
* Strip trailing whitespace
*/
*mptr = '\0';
mptr--;
}
Yeah, we're missing an "else break" in the while loop, will re-refactor to fix this.
[master c1f619435] Fix make-and-model whitespace trimming (Issue #1096)
[2.4.x 5cc470c8d] Fix make-and-model whitespace trimming (Issue #1096)
The strip trailing whitespace code introduced with commit https://github.com/OpenPrinting/cups/commit/04bb2af4521b56c1699a2c2431c56c05a7102e69 seems broken.
If we start with a make-and-model string of "Hewlett Packard LaserJet 2024 Series", we end up with
make
="Hewlett" andmodel
="Printer".Below is standalone C test code that demonstrates how the strip trailing whitespace code introduced with that commit is broken, it's basically the same as the CUPS 2.4.11 code, but has some printf statements to see what's happening:
The output from the above showing
make
progressively getting truncated on spaces:Although I didn't add test code for
model
, it is pretty obvious in the original code whymodel
becomes "Printer" as there is no longer a separate model part left after the above:https://github.com/OpenPrinting/cups/blob/7d535f73e407a72dfb5c5e83549a5ba27219dfcd/cups/ppd-cache.c#L3339-L3346