OSDN Git Service

Workaround error in stdin/global FILE handling
authorDylan Simon <dylan@dylex.net>
Sun, 7 Feb 2010 06:43:45 +0000 (01:43 -0500)
committerDylan Simon <dylan@dylex.net>
Sun, 7 Feb 2010 06:43:45 +0000 (01:43 -0500)
For some reason,
FILE *fp[2] = { (&__sF[0]), (&__sF[0]) };
was making the compiler define a local uninitialized version of __sF
which ended up in the final executable and broke stdio.  This seems like
a compiler bug to me.

editors/diff.c

index e4d74ab..5b7b51f 100644 (file)
@@ -658,9 +658,11 @@ static bool diff(FILE* fp[2], char *file[2])
 
 static int diffreg(char *file[2])
 {
-       FILE *fp[2] = { stdin, stdin };
+       FILE *fp[2];
        bool binary = false, differ = false;
        int status = STATUS_SAME;
+       fp[0] = stdin;
+       fp[1] = stdin;
 
        for (int i = 0; i < 2; i++) {
                int fd = open_or_warn_stdin(file[i]);