From: Eric S. Raymond Date: Tue, 6 Jun 2017 13:21:46 +0000 (-0400) Subject: Replace homebrew IABS() with C kubrary labs(3). X-Git-Tag: 1.1~605 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=4d6078d8a8a8288fd26e7fadcdb46c5e9bd06087;p=open-adventure.git Replace homebrew IABS() with C kubrary labs(3). --- diff --git a/actions1.c b/actions1.c index 791e0c2..25e05df 100644 --- a/actions1.c +++ b/actions1.c @@ -598,7 +598,7 @@ L9320: if(OBJ != RUG) return(2011); L8330: SPK=228; K=LOCSND[LOC]; if(K == 0) goto L8332; - RSPEAK(IABS(K)); + RSPEAK(labs(K)); if(K < 0) return(2012); SPK=0; L8332: SETPRM(1,ZZWORD,0); diff --git a/advent.h b/advent.h index e23f88e..443ab0a 100644 --- a/advent.h +++ b/advent.h @@ -65,7 +65,6 @@ extern void fSAVEIO(long,long,long*); #define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR) extern void DATIME(long*, long*); -extern long IABS(long); extern long MOD(long,long); extern void set_seed(long); diff --git a/init.c b/init.c index c5486cf..b229767 100644 --- a/init.c +++ b/init.c @@ -184,7 +184,7 @@ static int finish_init(void) { ABB[I]=0; if(LTEXT[I] == 0 || KEY[I] == 0) goto L1102; K=KEY[I]; - if(MOD(IABS(TRAVEL[K]),1000) == 1)COND[I]=2; + if(MOD(labs(TRAVEL[K]),1000) == 1)COND[I]=2; L1102: ATLOC[I]=0; } /* end loop */ diff --git a/main.c b/main.c index 6c55127..4982369 100644 --- a/main.c +++ b/main.c @@ -236,12 +236,12 @@ L6010: DTOTAL=0; KK=DLOC[I]; KK=KEY[KK]; if(KK == 0) goto L6016; -L6012: NEWLOC=MOD(IABS(TRAVEL[KK])/1000,1000); +L6012: NEWLOC=MOD(labs(TRAVEL[KK])/1000,1000); {long x = J-1; if(NEWLOC > 300 || !INDEEP(NEWLOC) || NEWLOC == ODLOC[I] || (J > 1 && NEWLOC == TK[x]) || J >= 20 || NEWLOC == DLOC[I] || FORCED(NEWLOC) || (I == 6 && CNDBIT(NEWLOC,3)) || - IABS(TRAVEL[KK])/1000000 == 100) goto L6014;} + labs(TRAVEL[KK])/1000000 == 100) goto L6014;} TK[J]=NEWLOC; J=J+1; L6014: KK=KK+1; @@ -530,7 +530,7 @@ L8: KK=KEY[LOC]; OLDLC2=OLDLOC; OLDLOC=LOC; -L9: LL=IABS(TRAVEL[KK]); +L9: LL=labs(TRAVEL[KK]); if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10; if(TRAVEL[KK] < 0) goto L50; KK=KK+1; @@ -543,7 +543,7 @@ L11: NEWLOC=LL/1000; if(PROP[K] != NEWLOC/100-3) goto L16; L12: if(TRAVEL[KK] < 0)BUG(25); KK=KK+1; - NEWLOC=IABS(TRAVEL[KK])/1000; + NEWLOC=labs(TRAVEL[KK])/1000; if(NEWLOC == LL) goto L12; LL=NEWLOC; goto L11; @@ -630,11 +630,11 @@ L20: K=OLDLOC; RSPEAK(K2); return true; -L21: LL=MOD((IABS(TRAVEL[KK])/1000),1000); +L21: LL=MOD((labs(TRAVEL[KK])/1000),1000); if(LL == K) goto L25; if(LL > 300) goto L22; J=KEY[LL]; - if(FORCED(LL) && MOD((IABS(TRAVEL[J])/1000),1000) == K)K2=KK; + if(FORCED(LL) && MOD((labs(TRAVEL[J])/1000),1000) == K)K2=KK; L22: if(TRAVEL[KK] < 0) goto L23; KK=KK+1; goto L21; @@ -644,7 +644,7 @@ L23: KK=K2; RSPEAK(140); return true; -L25: K=MOD(IABS(TRAVEL[KK]),1000); +L25: K=MOD(labs(TRAVEL[KK]),1000); KK=KEY[LOC]; goto L9; diff --git a/misc.c b/misc.c index 2c8855f..33e16e6 100644 --- a/misc.c +++ b/misc.c @@ -22,7 +22,7 @@ long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE; BLANK=BLKLIN; K=N; NPARMS=1; -L10: L=IABS(LINES[K])-1; +L10: L=labs(LINES[K])-1; K=K+1; LNLENG=0; LNPOSN=1; @@ -52,7 +52,7 @@ L32: if(LNPOSN > LNLENG) goto L40; if(PRMTYP < 1 || PRMTYP > 9) goto L30; SHFTXT(LNPOSN+2,PRMTYP-2); LNPOSN=LNPOSN+PRMTYP; - PARM=IABS(PARMS[NPARMS]); + PARM=labs(PARMS[NPARMS]); NEG=0; if(PARMS[NPARMS] < 0)NEG=9; /* 390 */ for (I=1; I<=PRMTYP; I++) { @@ -121,7 +121,7 @@ long I, M; M=PTEXT[MSG]; if(SKIP < 0) goto L9; for (I=0; I<=SKIP; I++) { -L1: M=IABS(LINES[M]); +L1: M=labs(LINES[M]); if(LINES[M] >= 0) goto L1; /*etc*/ ; } /* end loop */ @@ -313,13 +313,13 @@ long ALPH1, ALPH2, BYTE, DIV, I, W; ALPH1=13*CASE+24; - ALPH2=26*IABS(CASE)+ALPH1; - if(IABS(CASE) > 1)ALPH1=ALPH2; + ALPH2=26*labs(CASE)+ALPH1; + if(labs(CASE) > 1)ALPH1=ALPH2; /* ALPH1&2 DEFINE RANGE OF WRONG-CASE CHARS, 11-36 OR 37-62 OR EMPTY. */ DIV=64L*64L*64L*64L; W=WORD; /* 18 */ for (I=1; I<=5; I++) { - if(W <= 0 && STATE == 0 && IABS(CASE) <= 1)return; + if(W <= 0 && STATE == 0 && labs(CASE) <= 1)return; BYTE=W/DIV; if(STATE != 0 || BYTE != 63) goto L12; STATE=63; @@ -852,5 +852,4 @@ void DATIME(long* D, long* T) { *T = (long) tv.tv_usec; } -long IABS(N)long N; {return(N<0? -N : N);} long MOD(N,M)long N, M; {return(N%M);}