Skip to content
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

cupstestppd always warns on Windows and Mac files #2874

Closed
michaelrsweet opened this issue Jul 3, 2008 · 3 comments
Closed

cupstestppd always warns on Windows and Mac files #2874

michaelrsweet opened this issue Jul 3, 2008 · 3 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.3-current
CUPS.org User: DavidG

The logic in cupstestppd.c:check_basics is incorrect.

Following the logic in the source code, the first line ending it will come across in a Windows or Mac file is a carriage return. If the next character is a line feed, then the this character is discarded from the input stream and the variable eol is set to EOL_CRLF, otherwise it is set to EOL_CR.

The next time the a carriage return is encountered in the input stream, the variable 'mixed' is set to 1 because 'eol' is not equal to EOL_NONE, even though the line ending may be legitimate. Ideally, 'mixed' should only be set if the current line's ending is DIFFERENT from what is stored in 'eol', not if an 'eol' has already been detected.

Basically, the first line's ending is detected correctly, but the second line's ending triggers 'mixed = 1;' simply because 'eol != EOL_NONE'.

This only affects CRLF and CR line endings because the LF line endings have an additional conditional before setting 'mixed = 1'; and this conditional should be applied to CRLF and CR as well.

Attached is my proposed fix that works logically in my head but I have not compiled or tested it.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Moving to 1.3.x...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str2874.patch":

Index: systemv/cupstestppd.c

--- systemv/cupstestppd.c (revision 7725)
+++ systemv/cupstestppd.c (working copy)
@@ -1628,12 +1628,12 @@

       if (eol == EOL_NONE)
    eol = EOL_CRLF;
  • else
    
  • else if (eol != EOL_CRLF)
    mixed = 1;
    
    }
    else if (eol == EOL_NONE)
    eol = EOL_CR;
  •    else
    
  •    else if (eol != EOL_CR)
    
    mixed = 1;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant