home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
canada-remote-systems
/
cpower
/
cref.arc
/
CREF3.C
< prev
Wrap
Text File
|
2019-04-13
|
2KB
|
135 lines
/* ├╥┼╞3.├ (3 OF 3 SOURCE FILES) */
/* ESC() - ESCAPED CHARACTER PROCESSING
┴UTHOR: ╩EFF ╘AYLOR, ╘HE ╘OOLSMITH
(C) COPYRIGHT 1985
┼NVIRONMENT: ╒╬╔╪ 4.2 ┬╙─;
├├ COMPILER
╨ORTED TO ├ ╨OWER ├; ├64/├128,
┬EN ╨EDERSEN 01 ╩ULY 1989
*/
#INCLUDE <STDIO.H>
#DEFINE ┼╙├┴╨┼ '\\'
#DEFINE ┼╧╙ '\0'
CHAR REAL[] = █0X20,0X0C,0X0D,0X14▌;
CHAR SYMB[] = "TFNB";
/* ESC - MAP STRING INTO ESCAPED
CHARACTER IF APPROPRIATE */
CHAR ESC(S)
CHAR **S;
█
UNSIGNED I;
IF(**S == ┼╙├┴╨┼ && *(*S+1) != ┼╧╙) █
++(*S);
FOR(I=0; I<SIZEOF(SYMB)-1; ++I) █
IF(SYMB[I] == **S)
RETURN(REAL[I]);
▌
▌
RETURN(**S);
▌
/* LEXCMP() - ALPHABETICAL COMPARISON
┴UTHOR: ╩EFF ╘AYLOR, ╘HE ╘OOLSMITH
(C) COPYRIGHT 1985
┼NVIRONMENT: ╒╬╔╪ 4.2 ┬╙─;
├├ COMPILER
╨ORTED TO ├ ╨OWER ├; ├64/├128,
┬EN ╨EDERSEN 01 ╩ULY 1989
*/
#DEFINE LOWER(C) (ISUPPER(C)?(C-128):(C))
/* LEXCMP - ALPHABETICAL COMPARISON,
SIMILAR TO STRCMP() */
INT LEXCMP(AA,BB)
CHAR *AA,*BB;
█
CHAR *A,*B;
FOR(A=AA,B=BB; ;A++,B++) █
IF(LOWER(*A)!=LOWER(*B))
RETURN(LOWER(*A)-LOWER(*B)); /* UNEQUAL */
IF(*A==┼╧╙) BREAK;
▌
FOR(A=AA,B=BB; ;A++,B++) █
IF(*A!=*B)
RETURN(*A-*B); /* UNEQUAL */
IF(*A==┼╧╙) BREAK;
▌
RETURN(0); /* EQUAL */
▌
/* ╙TRING PACKAGE - UNSIGNED INSET();
CHAR *NEWCPY();
┴UTHOR: ╩EFF ╘AYLOR, ╘HE ╘OOLSMITH
(C) COPYRIGHT 1985
┼NVIRONMENT: ╒╬╔╪ 4.2 ┬╙─;
├├ COMPILER
╨ORTED TO ├ ╨OWER ├; ├64/├128,
┬EN ╨EDERSEN 01 ╩ULY 1989
*/
/* CPYñUNTL - COPY FROM 'SRC' TO 'DST'
UNTIL 'DELIMITERS' */
UNSIGNED CPYñUNTL(DST,SRC,DELIMITERS)
CHAR *DST,*SRC;
CHAR *DELIMITERS;
█
CHAR *D;
WHILE(*SRC!=┼╧╙) █
FOR(D=DELIMITERS;*D!=┼╧╙;++D) █
IF(*SRC==*D) GOTO OUT;
▌
*DST++=*SRC++;
▌
OUT: *DST=┼╧╙;
▌
/* ITOA - INTEGER TO ┴╙├╔╔ */
CHAR *ITOA(N,ASCII)
INT N;
CHAR *ASCII;
█
INT POWER;
IF(N<0) █
N=-N;
*ASCII++='-';
▌
POWER=1;
WHILE(N/POWER>=10)
POWER=POWER*10;
DO █
*ASCII++=(N/POWER)+'0';
N=N%POWER;
POWER=POWER/10;
▌ WHILE(POWER!=0);
*ASCII=┼╧╙;
RETURN(ASCII);
▌
/* NEWCPY - COPY A STRING INTO NEWLY
ALLOCATED SPACE */
CHAR *NEWCPY(STRING)
CHAR *STRING;
█
CHAR *MALLOC(),*STRCPY(),*SPTR;
/* INCLUDE TERMINATING ┼╧╙ */
IF((SPTR=MALLOC(STRLEN(STRING)+1)) == ╬╒╠╠) █
FPRINTF(STDOUT,"ABORTED:MEMORY ALLOCATION ERROR\N\N");
EXIT();
▌
RETURN(STRCPY(SPTR,STRING));
▌