bammi@dsrgsun.ces.cwru.edu (Jwahar R. Bammi) (12/14/88)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # tos.cdiff # minix.cdiff # This archive created: Wed Dec 14 04:36:28 1988 # By: Jwahar R. Bammi(Case Western Reserve University) # Uucp: {decvax,sun,att}!cwjcc!dsrgsun!bammi # Csnet: bammi@dsrgsun.ces.CWRU.edu # Arpa: bammi@dsrgsun.ces.CWRU.edu # export PATH; PATH=/bin:$PATH echo shar: extracting "'tos.cdiff'" '(8855 characters)' if test -f 'tos.cdiff' then echo shar: over-writing existing file "'tos.cdiff'" fi sed 's/^X//' << \SHAR_EOF > 'tos.cdiff' X*** Makefile.dist Mon Nov 28 01:24:50 1988 X--- Makefile Mon Dec 12 14:44:15 1988 X*************** X*** 26,32 **** X fprintf.o fputc.o fputs.o fread.o \ X freopen.o fseek.o fstat.o ftell.o \ X fwrite.o gcvt.o getopt.o getwd.o \ X! index.o ioctl.o isatty.o ldexp.o \ X lseek.o memccpy.o memchr.o \ X memcmp.o memcpy.o memory.o \ X memset.o nsort.o open.o opendir.o \ X--- 26,32 ---- X fprintf.o fputc.o fputs.o fread.o \ X freopen.o fseek.o fstat.o ftell.o \ X fwrite.o gcvt.o getopt.o getwd.o \ X! index.o ioctl.o isatty.o ldexp.o modf.o frexp.o \ X lseek.o memccpy.o memchr.o \ X memcmp.o memcpy.o memory.o \ X memset.o nsort.o open.o opendir.o \ X*** sfguts.c.dist Wed Dec 14 02:48:00 1988 X--- sfguts.c Tue Dec 13 19:08:08 1988 X*************** X*** 5,148 **** X #include <stdio.h> X X fscanf(f, fmt, args) FILE *f; char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = f; X! _sfcp = NULL; X! return _dosf(fmt, &args); X } X X scanf(fmt, args) char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = stdin; X! _sfcp = NULL; X! return _dosf(fmt, &args); X } X X sscanf(s, fmt, args) char *s; char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = NULL; X! _sfcp = s; X! return _dosf(fmt, &args); X } X! X _dosf(fmt, args) char *fmt; int **args; { X! int assigned, wid, lng, skip, *ip, f, c, m, base; X! long n, *lp; X! char *cp; X! assigned = 0; X! c = _sfget(); X! while ((f = *fmt++) && c != EOF) { X! if (f <= ' ') { /* skip spaces */ X! while (c <= ' ' && c != EOF) X! c = _sfget(); X } X! else if (f != '%') { /* match character */ X! if (c != f) X! return assigned; X } X! else { X! wid = lng = skip = 0; X! if ((f = *fmt++) == '*') { /* skip assignment */ X! skip++; X! f = *fmt++; X! } X! while (f >= '0' && f <= '9') { /* width of value */ X! wid = wid * 10 + f - '0'; X! f = *fmt++; X! } X! if (f == 'l') { /* long */ X! lng++; X! f = *fmt++; X! } X! else if (f == 'h') { /* short */ X! f = *fmt++; X! } X! switch (f) { /* conversion spec */ X! case '%': X! if (c != '%') return assigned; X! c = _sfget(); X! break; X! case 'c': X! if (wid == 0) { X! cp = (char * )*args++; X! if (!skip) { X! *cp = c; X! assigned++; X! } X! c = _sfget(); X! break; X! } X! case 's': X! cp = (char * )*args++; X! while (c <= ' ' && c != EOF) X! c = _sfget(); X! while (c > ' ' && c != EOF) { X! if (!skip) *cp++ = c; X! c = _sfget(); X! if (--wid == 0) break; X! } X! *cp = 0; X! if (!skip) assigned++; X! break; X! case 'D': case 'X': case 'O': X! lng = 1; X! f = f - 'A' + 'a'; X! case 'd': case 'x': case 'o': X! base = (f == 'x' ? 16 : f == 'o' ? 8 : 10); X! n = 0L; X! while (c != EOF && c <= ' ') X! c = _sfget(); X! if ((m = _sfnum(c, base)) < 0) X! return assigned; X! do { X! n = n * base + m; X! c = _sfget(); X! m = _sfnum(c, base); X! if (--wid == 0) break; X! } while (m >= 0); X! if (!skip) { X! if (lng) { X! lp = (long * )*args++; X! *lp = n; X! } X! else { X! ip = *args++; X! *ip = n; X! } X! assigned++; X! } X! break; X! case 'e': case 'f': case 'E': case 'F': X! /* no floats implemented */ X! return -2; X! default: X! return assigned; X! } X } X } X! return f == 0 ? assigned : EOF; X } X X X _sfnum(c, base) { X! if (c >= '0' && c <= '9') X! return c - '0'; X! else if (base == 16 && c >= 'a' && c <= 'f') X! return c - 'a' + 10; X! else if (base == 16 && c >= 'A' && c <= 'F') X! return c - 'A' + 10; X! else return -1; X } X X _sfget() { X! extern char *_sfcp; X! extern FILE *_sffp; X! if (_sffp) return getc(_sffp); X! if (_sfcp && *_sfcp) return *_sfcp++; X! return EOF; X } X X char *_sfcp; /* char pointer for scanf input string */ X--- 5,234 ---- X #include <stdio.h> X X fscanf(f, fmt, args) FILE *f; char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = f; X! _sfcp = NULL; X! return _dosf(fmt, &args); X } X X scanf(fmt, args) char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = stdin; X! _sfcp = NULL; X! return _dosf(fmt, &args); X } X X sscanf(s, fmt, args) char *s; char *fmt; int *args; { X! extern char *_sfcp; X! extern FILE *_sffp; X! _sffp = NULL; X! _sfcp = s; X! return _dosf(fmt, &args); X } X! X! #define isdigit(ch) (ch >= '0' && ch <= '9') X! X! /* eval f * 10**p */ X! static double _fraise(f, p) X! double f; X! int p; X! { X! if(p > 0) X! while(p--) X! f *= 10.0; X! else X! while(p++) X! f /= 10.0; X! return f; X! } X! X! X _dosf(fmt, args) char *fmt; int **args; { X! int assigned, wid, lng, skip, *ip, f, c, m, base; X! long n, *lp; X! char *cp; X! double fval, *dp; X! float *fp; X! short sign, done_some; X! X! assigned = 0; X! c = _sfget(); X! while ((f = *fmt++) && c != EOF) { X! if (f <= ' ') { /* skip spaces */ X! while (c <= ' ' && c != EOF) X! c = _sfget(); X! } X! else if (f != '%') { /* match character */ X! if (c != f) X! return assigned; X! } X! else { X! wid = lng = skip = 0; X! if ((f = *fmt++) == '*') { /* skip assignment */ X! skip++; X! f = *fmt++; X! } X! while (f >= '0' && f <= '9') { /* width of value */ X! wid = wid * 10 + f - '0'; X! f = *fmt++; X! } X! if (f == 'l') { /* long */ X! lng++; X! f = *fmt++; X! } X! else if (f == 'h') { /* short */ X! f = *fmt++; X! } X! switch (f) { /* conversion spec */ X! case '%': X! if (c != '%') return assigned; X! c = _sfget(); X! break; X! case 'c': X! if (wid == 0) { X! cp = (char * )*args++; X! if (!skip) { X! *cp = c; X! assigned++; X! } X! c = _sfget(); X! break; X } X! case 's': X! cp = (char * )*args++; X! while (c <= ' ' && c != EOF) X! c = _sfget(); X! while (c > ' ' && c != EOF) { X! if (!skip) *cp++ = c; X! c = _sfget(); X! if (--wid == 0) break; X } X! *cp = 0; X! if (!skip) assigned++; X! break; X! case 'D': case 'X': case 'O': X! lng = 1; X! f = f - 'A' + 'a'; X! case 'd': case 'x': case 'o': X! base = (f == 'x' ? 16 : f == 'o' ? 8 : 10); X! n = 0L; X! while (c != EOF && c <= ' ') X! c = _sfget(); X! if ((m = _sfnum(c, base)) < 0) X! return assigned; X! do { X! n = n * base + m; X! c = _sfget(); X! m = _sfnum(c, base); X! if (--wid == 0) break; X! } while (m >= 0); X! if (!skip) { X! if (lng) { X! lp = (long * )*args++; X! *lp = n; X! } X! else { X! ip = *args++; X! *ip = n; X! } X! assigned++; X } X+ break; X+ /* ++jrb */ X+ case 'e': case 'f': case 'g': case 'E': case 'F': case 'G': X+ done_some = 0; X+ if((f == 'E') || (f == 'F') || (f == 'G')) lng++; X+ fval = 0.0; /* our result value */ X+ sign = 0; /* assume positive */ X+ if (wid == 0) X+ wid = 0x7fff; /* very wide */ X+ if (wid && c == '+') X+ c = _sfget (); X+ else if (wid && c == '-') { X+ sign = 1; X+ c = _sfget (); X+ } X+ while (wid && isdigit(c)) { X+ --wid; X+ fval = fval * 10.0 + (c - '0'); X+ c = _sfget (); X+ done_some = 1; X+ } X+ if(c == '.') X+ { X+ double factor = 1.0/10.0; X+ c = _sfget (); X+ while (--wid && isdigit(c)) X+ { X+ fval = fval + ((c - '0') * factor); X+ factor = factor/10.0; X+ c = _sfget(); X+ done_some = 1; X+ } X+ } X+ if(done_some && sign) X+ fval = -fval; X+ sign = 0; X+ if(((c == 'E') || (c == 'e')) && done_some) X+ { X+ int pow = 0; X+ c = _sfget (); X+ if((c == '+') || (c == '-')) X+ { X+ if(c == '-') sign = 1; X+ wid--; X+ c = _sfget(); X+ } X+ X+ while(--wid && isdigit(c)) X+ { X+ pow = pow * 10 + (c -'0'); X+ c = _sfget(); X+ } X+ fval = _fraise(fval, (sign == 1)? -pow : pow); X+ } X+ if (!skip) { X+ if (lng) X+ { X+ dp = (double *)*args++; X+ *dp = fval; X+ } X+ else X+ { X+ fp = (float *)*args++; X+ *fp = (float) fval; X+ } X+ assigned++; X+ } X+ break; X+ X+ default: X+ return assigned; X+ } X } X! } X! return f == 0 ? assigned : EOF; X } X X X _sfnum(c, base) { X! if (c >= '0' && c <= '9') X! return c - '0'; X! else if (base == 16 && c >= 'a' && c <= 'f') X! return c - 'a' + 10; X! else if (base == 16 && c >= 'A' && c <= 'F') X! return c - 'A' + 10; X! else return -1; X } X X _sfget() { X! extern char *_sfcp; X! extern FILE *_sffp; X! if (_sffp) return getc(_sffp); X! if (_sfcp && *_sfcp) return *_sfcp++; X! return EOF; X } X X char *_sfcp; /* char pointer for scanf input string */ SHAR_EOF if test 8855 -ne "`wc -c 'tos.cdiff'`" then echo shar: error transmitting "'tos.cdiff'" '(should have been 8855 characters)' fi echo shar: extracting "'minix.cdiff'" '(8097 characters)' if test -f 'minix.cdiff' then echo shar: over-writing existing file "'minix.cdiff'" fi sed 's/^X//' << \SHAR_EOF > 'minix.cdiff' X*** doprintf.c.dist Tue Dec 13 18:37:34 1988 X--- doprintf.c Wed Dec 14 04:07:57 1988 X*************** X*** 82,89 **** X--- 82,92 ---- X * and is probably not as precise as some would want, but its X * good enough for rock & roll. X * X+ * 12/10/88 added rounding ++jrb X+ * X */ X #define MAXWIDTH 30 /* chosen arb. */ X+ #define LOG2 3.01029995663981200e-01 /* log base 10 of 2 */ X X typedef enum { EFORMAT, FFORMAT, GFORMAT } FORMAT_TYPE; X static void _flofmt(); X*************** X*** 99,104 **** X--- 102,109 ---- X char mybuf[MAXWIDTH+1]; X int pow; X int sign; X+ double least; X+ extern double ldexp(); X #ifdef KLUDGEDIV X long l; X int i; X*************** X*** 115,120 **** X--- 120,135 ---- X } X else sign = 0; X X+ /* round it off at precision -- add 5.0E-(precision+1) */ X+ least = ldexp(0.5, -((int)((double)precision/LOG2 + 0.5))); X+ if(least > val) X+ { X+ least = 0.0; X+ precision = MAXWIDTH; X+ } X+ else X+ val += least; X+ X #ifdef DDD X printf("sign %d\n", sign); X #endif X*************** X*** 155,163 **** X precision -= ((precision + pow) - MAXWIDTH); X X #ifdef KLUDGEDIV X! _flofmt(&mybuf[i], val, precision); X #else X! _flofmt(mybuf, val, precision+pow); X #endif X X #ifdef DDD X--- 170,178 ---- X precision -= ((precision + pow) - MAXWIDTH); X X #ifdef KLUDGEDIV X! _flofmt(&mybuf[i], val, least, precision); X #else X! _flofmt(mybuf, val, least, precision+pow); X #endif X X #ifdef DDD X*************** X*** 186,196 **** X pow -= 1; X *q++ = *p++; X *q++ = '.'; X while(*p != '\0') X *q++ = *p++; X! *q++ = 'E'; X if(pow >= 0) X *q++ = '+'; X p = itoa(pow); X while(*p != '\0') *q++ = *p++; X *q = '\0'; X--- 201,220 ---- X pow -= 1; X *q++ = *p++; X *q++ = '.'; X+ if(*p == '\0') X+ *q++ = '0'; X while(*p != '\0') X *q++ = *p++; X! *q++ = 'e'; X if(pow >= 0) X *q++ = '+'; X+ else X+ { X+ *q++ = '-'; X+ pow = -pow; X+ } X+ if(pow < 10) X+ *q++ = '0'; X p = itoa(pow); X while(*p != '\0') *q++ = *p++; X *q = '\0'; X*************** X*** 205,214 **** X *q++ = '-'; X while(pow-- > 0) X *q++ = *p++; X! *q++ = '.'; X! while(*p != '\0') X! *q++ = *p++; X! X *q = '\0'; X return q; X } X--- 229,240 ---- X *q++ = '-'; X while(pow-- > 0) X *q++ = *p++; X! if(*p != '\0') X! { X! *q++ = '.'; X! while(*p != '\0') X! *q++ = *p++; X! } X *q = '\0'; X return q; X } X*************** X*** 223,229 **** X X /* anyone have a good heuristic to decide between F and E */ X /* formats ??? */ X! if((pow + leading) > 4) goto efmt; X goto ffmt; X } X } X--- 249,256 ---- X X /* anyone have a good heuristic to decide between F and E */ X /* formats ??? */ X! if((leading > 6) || (precision > 6) || ((pow+precision) > 10)) X! goto efmt; X goto ffmt; X } X } X*************** X*** 232,240 **** X X X /* the formatter for flona -- basic body from pfgutc.c Tos Gcc lib */ X! static void _flofmt(buf, val, precision) X char * buf; X! double val; X int precision; X { X long int_part; X--- 259,267 ---- X X X /* the formatter for flona -- basic body from pfgutc.c Tos Gcc lib */ X! static void _flofmt(buf, val, least, precision) X char * buf; X! double val, least; X int precision; X { X long int_part; X*************** X*** 248,254 **** X for (i = 0 ; i < MAXWIDTH ; i++) X digit[i] = 0; X for (i = 0, ndigits = 0 ; X! ((val > 0) && (ndigits < precision) && (i < MAXWIDTH)); i++) X { X val = val * 10.0; X int_part = val; X--- 275,281 ---- X for (i = 0 ; i < MAXWIDTH ; i++) X digit[i] = 0; X for (i = 0, ndigits = 0 ; X! ((val > least) && (ndigits < precision) && (i < MAXWIDTH)); i++) X { X val = val * 10.0; X int_part = val; X*** scanf.c.dist Tue Dec 13 18:41:52 1988 X--- scanf.c Tue Dec 13 19:00:32 1988 X*************** X*** 6,11 **** X--- 6,14 ---- X * obviously a no-no. Changed that real quick. X * - added [0-9] style scansets X * ++jrb bammi@dsrgsun.ces.cwru.edu X+ * X+ * 12/10/88 minor bugfix to accept floating #'s of the for .nnnn X+ * ++jrb X */ X X X*************** X*** 340,351 **** X sign = 1; X rnc (); X } X! while (width-- && isdigit(ic)) { X fval = fval * 10.0 + (ic - '0'); X rnc (); X done_some = 1; X } X! if((ic == '.') && done_some) X { X double factor = 1.0/10.0; X rnc (); X--- 343,355 ---- X sign = 1; X rnc (); X } X! while (width && isdigit(ic)) { X! width--; X fval = fval * 10.0 + (ic - '0'); X rnc (); X done_some = 1; X } X! if(ic == '.') X { X double factor = 1.0/10.0; X rnc (); X*************** X*** 353,358 **** X--- 357,363 ---- X { X fval = fval + ((ic - '0') * factor); X factor = factor/10.0; X+ done_some = 1; X rnc(); X } X } X*** strncpy.c.dist Mon Nov 14 08:38:00 1988 X--- strncpy.c Fri Dec 2 04:51:00 1988 X*************** X*** 1,17 **** X! char *strncpy(s1, s2, n) X! register char *s1, *s2; X! int n; X { X! /* Copy s2 to s1, but at most n characters. */ X! X! char *original = s1; X! X! while (*s2 != 0) { X! *s1++ = *s2++; X! if (--n == 0) break; X! } X! /* ++jrb fix from net -- thanks bds@lzaz.ATT.COM */ X! while (--n >= 0) *s1++ = 0; X! X! return(original); X } X--- 1,14 ---- X! char *strncpy(dest, src, count) X! register char *dest, *src; X! register int count; X { X! register char *save = dest; X! X! while(count-- > 0) X! { X! if((*dest++ = *src++) == '\0') X! break; X! } X! while(count-- > 0) *dest++ = '\0'; X! return(save); X } X*** Makefile.16.dist1 Wed Nov 30 03:48:45 1988 X--- Makefile.16 Sat Dec 10 01:57:04 1988 X*************** X*** 35,41 **** X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \ X stsndrec.o stsetjmp.o X X! O5 = getopt.o alloca.o getwd.o ldexp.o atof.o eprintf.o X X GNUSTUFF = fixnum.o sflonum.o dflonum.o X X--- 35,42 ---- X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \ X stsndrec.o stsetjmp.o X X! O5 = getopt.o alloca.o getwd.o atof.o eprintf.o X! O6 = ldexp.o frexp.o modf.o X X GNUSTUFF = fixnum.o sflonum.o dflonum.o X X*************** X*** 52,65 **** X rm -f $(O3) X rm -f $(O4) X rm -f $(O5) X rm -f $(GNUSTUFF) X rm -f $(SFILES) X X X! libc.a: $(O1) $(O2) $(O3) $(O4) $(O5) $(GNUSTUFF) X rm -f $@ X $(AR) srv $@ $(O1) $(O2) $(O3) X! $(AR) srv $@ $(O4) $(O5) $(GNUSTUFF) X X crtso.o: stcrtso.s X $(AS) $? X--- 53,67 ---- X rm -f $(O3) X rm -f $(O4) X rm -f $(O5) X+ rm -f $(O6) X rm -f $(GNUSTUFF) X rm -f $(SFILES) X X X! libc.a: $(O1) $(O2) $(O3) $(O4) $(O5) $(O6) $(GNUSTUFF) X rm -f $@ X $(AR) srv $@ $(O1) $(O2) $(O3) X! $(AR) srv $@ $(O4) $(O5) $(O6) $(GNUSTUFF) X X crtso.o: stcrtso.s X $(AS) $? X*************** X*** 76,83 **** X stsndrec.s : stsndrec.cpp X X # X! # Note: dflonum.c *must* be compiled with 32 bit ints X # (no -mshort flag to gcc) X # X dflonum.o : dflonum.c flonum.h X $(CC) -O -DATARI_ST -c dflonum.c X--- 78,94 ---- X stsndrec.s : stsndrec.cpp X X # X! # Note: the following *must* be compiled with 32 bit ints X # (no -mshort flag to gcc) X # X dflonum.o : dflonum.c flonum.h X $(CC) -O -DATARI_ST -c dflonum.c X+ X+ ldexp.o : ldexp.c flonum.h X+ $(CC) -O -DATARI_ST -DSHORTLIB -c ldexp.c X+ X+ frexp.o : frexp.c flonum.h X+ $(CC) -O -DATARI_ST -c -DSHORTLIB frexp.c X+ X+ modf.o : modf.c flonum.h X+ $(CC) -O -DATARI_ST -c modf.c X*** Makefile.32.dist1 Wed Nov 30 03:48:19 1988 X--- Makefile.32 Thu Dec 8 17:52:53 1988 X*************** X*** 37,43 **** X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \ X stsndrec.o stsetjmp.o X X! O5 = getopt.o alloca.o getwd.o ldexp.o atof.o eprintf.o X X GNUSTUFF = fixnum.o sflonum.o dflonum.o X X--- 37,43 ---- X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \ X stsndrec.o stsetjmp.o X X! O5 = getopt.o alloca.o getwd.o atof.o eprintf.o ldexp.o frexp.o modf.o X X GNUSTUFF = fixnum.o sflonum.o dflonum.o X SHAR_EOF if test 8097 -ne "`wc -c 'minix.cdiff'`" then echo shar: error transmitting "'minix.cdiff'" '(should have been 8097 characters)' fi # End of shell archive exit 0 usenet: {decvax,sun}!cwjcc!dsrgsun!bammi jwahar r. bammi csnet: bammi@dsrgsun.ces.CWRU.edu arpa: bammi@dsrgsun.ces.CWRU.edu compuServe: 71515,155