Hello,

In Cygwin 1,7.1, sprintf() with the format string having an 8th bit set
appears to be broken. Sample code (where I've indicated the backslashes in
the comments, in case they are stripped out by the mailer):

#include <stdio.h>

int main (void)
{
    unsigned char foo[30] = "";
    unsigned char bar[30] = "";
    unsigned char xxx[30] = "";
    sprintf (foo, "\100%s", "ABCD"); /* this is backslash one zero zero   */
    sprintf (bar, "\300%s", "ABCD"); /* this is backslash three zero zero */
    sprintf (xxx, "\300ABCD");       /* this is backslash three zero zero */
    printf ("%d %d %d %d %d\n", foo[0],foo[1],foo[2],foo[3],foo[4]);
    printf ("%d %d %d %d %d\n", bar[0],bar[1],bar[2],bar[3],bar[4]);
    printf ("%d %d %d %d %d\n", xxx[0],xxx[1],xxx[2],xxx[3],xxx[4]);
    return 0;
}

gives:

64 65 66 67 68
0 0 0 0 0
192 65 66 67 68

The second line of the output should be the same as the third.

This problem is likely to affect programs using xterm as a pseudo-terminal.
The number octal 300 (decimal 192) isn't significant here.

Regards, Joe Quinsey



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to