Trivial diff to avoid storing the result of getc() into a `char'
variable, and comparing the variable to EOF later on, since on platforms
where `char' is unsigned by default (such as arm and powerpc), EOF can't
fit a `char'.

While there avoid writing past a local buffer.

Index: sync.c
===================================================================
RCS file: /cvs/src/games/sail/sync.c,v
retrieving revision 1.9
diff -u -p -r1.9 sync.c
--- sync.c      27 Oct 2009 23:59:27 -0000      1.9
+++ sync.c      19 Jun 2011 15:16:52 -0000
@@ -253,16 +253,18 @@ Sync()
                if (isstr != 0 && isstr != 1)
                        goto bad;
                if (isstr) {
+                       int ch;
                        char *p;
+
                        for (p = buf;;) {
-                               switch (*p++ = getc(sync_fp)) {
+                               ch = getc(sync_fp);
+                               switch (ch) {
                                case '\n':
-                                       p--;
                                case EOF:
                                        break;
                                default:
-                                       if (p >= buf + sizeof buf)
-                                               p--;
+                                       if (p < buf + sizeof buf)
+                                               *p++ = ch;
                                        continue;
                                }
                                break;

Reply via email to