Browse Source

converted to 4-4

ceriel 37 years ago
parent
commit
b46981f4ce
3 changed files with 28 additions and 8 deletions
  1. 1 1
      lang/pc/libpc/pac.c
  2. 1 1
      lang/pc/libpc/unp.c
  3. 26 6
      lang/pc/libpc/wri.c

+ 1 - 1
lang/pc/libpc/pac.c

@@ -39,7 +39,7 @@ _pac(ad,zd,zp,i,ap) int i; struct descr *ad,*zd; char *zp,*ap; {
 	ap += (i * ad->size);
 	i = (zd->diff + 1) * zd->size;
 	if (zd->size == 1) {
-		assert(ad->size == 2);
+		assert(ad->size == EM_WSIZE);
 		while (--i >= 0)
 			*zp++ = *((int *)ap)++;
 	} else {

+ 1 - 1
lang/pc/libpc/unp.c

@@ -39,7 +39,7 @@ _unp(ad,zd,i,ap,zp) int i; struct descr *ad,*zd; char *ap,*zp; {
 	ap += (i * ad->size);
 	i = (zd->diff + 1) * zd->size;
 	if (zd->size == 1) {
-		assert(ad->size == 2);
+		assert(ad->size == EM_WSIZE);
 		while (--i >= 0)
 			*((int *)ap)++ = *zp++;
 	} else {

+ 26 - 6
lang/pc/libpc/wri.c

@@ -20,13 +20,33 @@
 
 extern		_wstrin();
 
+#if EM_WSIZE==4
+#define SZ 11
+#define MININT -2147483648
+#define STRMININT "-2147483648"
+#endif
+#if EM_WSIZE==2
+#define SZ 6
+#define MININT -32768
+#define STRMININT "-32768"
+#endif
+#if EM_WSIZE==1
+#define SZ 4
+#define MININT -128
+#define STRMININT "-128"
+#endif
+
+#ifndef STRMININT
+Something wrong here!
+#endif
+
 _wsi(w,i,f) int w,i; struct file *f; {
-	char *p; int j; char buf[6];
+	char *p; int j; char buf[SZ];
 
-	p = &buf[6];
+	p = &buf[SZ];
 	if ((j=i) < 0) {
-		if (i == -32768) {
-			_wstrin(w,6,"-32768",f);
+		if (i == MININT) {
+			_wstrin(w,SZ,STRMININT,f);
 			return;
 		}
 		j = -j;
@@ -36,9 +56,9 @@ _wsi(w,i,f) int w,i; struct file *f; {
 	while (j /= 10);
 	if (i<0)
 		*--p = '-';
-	_wstrin(w,&buf[6]-p,p,f);
+	_wstrin(w,&buf[SZ]-p,p,f);
 }
 
 _wri(i,f) int i; struct file *f; {
-	_wsi(6,i,f);
+	_wsi(SZ,i,f);
 }