Re: useless use of void context work-around
[p5sagit/p5-mst-13.2.git] / djgpp / djgpp.c
index 5a8fc5f..4e390cf 100644 (file)
@@ -122,17 +122,14 @@ convretcode (pTHX_ int rc,char *prog,int fl)
     if (rc < 0 && ckWARN(WARN_EXEC))
         Perl_warner(aTHX_ WARN_EXEC,"Can't %s \"%s\": %s",
                    fl ? "exec" : "spawn",prog,Strerror (errno));
-    if (rc > 0)
+    if (rc >= 0)
         return rc << 8;
-    if (rc < 0)
-        return 255 << 8;
-    return 0;
+    return -1;
 }
 
 int
 do_aspawn (pTHX_ SV *really,SV **mark,SV **sp)
 {
-    dTHR;
     int  rc;
     char **a,*tmps,**argv; 
     STRLEN n_a;
@@ -435,3 +432,22 @@ Perl_DJGPP_init (int *argcp,char ***argvp)
         strcpy (perlprefix,"..");
 }
 
+int
+djgpp_fflush (FILE *fp)
+{
+    int res;
+
+    if ((res = fflush(fp)) == 0 && fp) {
+       Stat_t s;
+       if (Fstat(fileno(fp), &s) == 0 && !S_ISSOCK(s.st_mode))
+           res = fsync(fileno(fp));
+    }
+/*
+ * If the flush succeeded but set end-of-file, we need to clear
+ * the error because our caller may check ferror().  BTW, this
+ * probably means we just flushed an empty file.
+ */
+    if (res == 0 && fp && ferror(fp) == EOF) clearerr(fp);
+
+    return res;
+}