Made to work with some other compilers
authorceriel <none@none>
Fri, 13 Feb 1987 09:40:08 +0000 (09:40 +0000)
committerceriel <none@none>
Fri, 13 Feb 1987 09:40:08 +0000 (09:40 +0000)
modules/src/object/rd_bytes.c
modules/src/object/wr_bytes.c

index e46f4cb..3c9822f 100644 (file)
@@ -1,5 +1,10 @@
 #define MININT         (1 << (sizeof(int) * 8 - 1))
-#define MAXCHUNK       (-(MININT + 1)) /* Highest count we write(2).   */
+#define MAXCHUNK       (~MININT)       /* Highest count we read(2).    */
+/* Unfortunately, MAXCHUNK is too large with some  compilers. Put it in
+   an int!
+*/
+
+int maxchunk = MAXCHUNK;
 
 /*
  * We don't have to worry about byte order here.
@@ -12,7 +17,7 @@ rd_bytes(fd, string, cnt)
 {
 
        while (cnt) {
-               register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt;
+               register int n = cnt >= maxchunk ? maxchunk : cnt;
 
                if (read(fd, string, n) != n)
                        rd_fatal();
index 8dccc4b..55e8932 100644 (file)
@@ -1,5 +1,10 @@
 #define MININT         (1 << (sizeof(int) * 8 - 1))
-#define MAXCHUNK       (-(MININT + 1)) /* Highest count we write(2).   */
+#define MAXCHUNK       (~MININT)       /* Highest count we write(2).   */
+/* Notice that MAXCHUNK itself might be too large with some compilers.
+   You have to put it in an int!
+*/
+
+int maxchunk = MAXCHUNK;
 
 /*
  * Just write "cnt" bytes to file-descriptor "fd".
@@ -10,7 +15,7 @@ wr_bytes(fd, string, cnt)
 {
 
        while (cnt) {
-               register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt;
+               register int n = cnt >= maxchunk ? maxchunk : cnt;
 
                if (write(fd, string, n) != n)
                        wr_fatal();