some fixes
authorceriel <none@none>
Fri, 10 Jul 1987 09:06:19 +0000 (09:06 +0000)
committerceriel <none@none>
Fri, 10 Jul 1987 09:06:19 +0000 (09:06 +0000)
lang/cem/libcc/gen/asctime.c
lang/cem/libcc/gen/ecvt.c
lang/cem/libcc/gen/rand.c

index 5332b8e..b3709f1 100644 (file)
@@ -28,20 +28,20 @@ asctime(tm)
        pb = two_digits(
                two_digits(
                   two_digits(
-                     two_digits(pb, tm->tm_mday),
-                     tm->tm_hour),
-                  tm->tm_min),
-               tm->tm_sec);
+                     two_digits(pb, tm->tm_mday, 0),
+                     tm->tm_hour, 1),
+                  tm->tm_min, 1),
+               tm->tm_sec, 1);
        four_digits(pb, tm->tm_year+1900);
        return(buf);
 }
 
 static char *
-two_digits(pb, i)
+two_digits(pb, i, nospace)
        register char *pb;
 {
        *pb = (i / 10) % 10 + '0';
-       if (*pb == '0') *pb = ' ';
+       if (!nospace && *pb == '0') *pb = ' ';
        pb++;
        *pb++ = (i % 10) + '0';
        return ++pb;
index f91fcf3..84ca9f3 100644 (file)
@@ -52,9 +52,9 @@ cvt(value, ndigit, decpt, sign, ecvtflag)
                           the conversion to "int" truncates
                        */
                        if (pe >= &buf1[NDIGITS]) {
-                               pb = &buf1[NDIGITS-10];
-                               while (pb > buf1) *--pb = *--pe;
-                               pe = &buf[NDIGITS-10];
+                               pb = &buf1[10];
+                               pe = &buf1[0];
+                               while (pb < &buf1[NDIGITS]) *pe++ = *pb++;
                        }
                        *pe++ = (int)((value+.05) * 10) + '0';
                        pointpos++;
index e0fef45..7395bf0 100644 (file)
@@ -4,7 +4,11 @@ static long seed = 1L;
 int rand()
 {
   seed = (1103515245L * seed + 12345) & 0x7FFFFFFF;
-  return((int) ((seed >> 8) & 077777));
+#if EM_WSIZE == 4
+  return (int) seed;
+#else
+  return ((int)(seed >> 8) & 0x7FFF);
+#endif
 }
 
 srand(n)