Change all text/source files to LF line endings.

This commit is contained in:
Stephen Heumann 2017-10-21 18:40:19 -05:00
parent 0c71404b58
commit 46b6aa389f
559 changed files with 83353 additions and 559 deletions

668
Asm.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

180
CC.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

15
CC.rez Executable file → Normal file
View File

@ -1 +1,14 @@
#include "types.rez" resource rVersion(1) { { 2, /* Major revision */ 1, /* Minor revision */ 1, /* Bug version */ beta, /* Release stage */ 3, /* Non-final release # */ }, verUS, /* Region code */ "ORCA/C", /* Short version number */ "Copyright 1997, Byte Works, Inc." /* Long version number */ };
#include "types.rez"
resource rVersion(1) {
{
2, /* Major revision */
1, /* Minor revision */
1, /* Bug version */
beta, /* Release stage */
3, /* Non-final release # */
},
verUS, /* Region code */
"ORCA/C", /* Short version number */
"Copyright 1997, Byte Works, Inc." /* Long version number */
};

15
CC.rez2 Executable file → Normal file
View File

@ -1 +1,14 @@
#include "types.rez" resource rVersion(1) { { 2, /* Major revision */ 0, /* Minor revision */ 3, /* Bug version */ release, /* Release stage */ 0, /* Non-final release # */ }, verUS, /* Region code */ "ORCA/C (small memory)", /* Short version number */ "Copyright 1994, Byte Works, Inc." /* Long version number */ };
#include "types.rez"
resource rVersion(1) {
{
2, /* Major revision */
0, /* Minor revision */
3, /* Bug version */
release, /* Release stage */
0, /* Non-final release # */
},
verUS, /* Region code */
"ORCA/C (small memory)", /* Short version number */
"Copyright 1994, Byte Works, Inc." /* Long version number */
};

81
CCommon.asm Executable file → Normal file
View File

@ -1 +1,80 @@
mcopy ccommon.macros **************************************************************** * * CopyString - copy a string * * Inputs: * toPtr - location to copy to * fromPtr - location to copy from * **************************************************************** * CopyString start subroutine (4:toPtr,4:fromPtr),0 short I,M lda [fromPtr] sta [toPtr] tay lb1 lda [fromPtr],Y sta [toPtr],Y dey bne lb1 long I,M return end **************************************************************** * * Hash - find hash displacement * * Finds the displacement into an array of pointers using a * hash function. * * Inputs: * sPtr - points to string to find hash for * * Outputs: * Returns the disp into the hash table * **************************************************************** * Hash start hashSize equ 876 # hash buckets - 1 sum equ 0 hash length equ 2 length of string subroutine (4:sPtr),4 stz sum default to bucket 0 lda [sPtr] set the length of the string and #$00FF sta length ldy #1 start with char 1 lda [sPtr] if 1st char is '~', start with char 6 and #$FF00 cmp #'~'*256 bne lb1 ldy #6 lb1 lda [sPtr],Y get the value to add in and #$3F3F cpy length if there is only 1 char left then bne lb2 and #$00FF and out the high byte lb2 clc add it to the sum adc sum sta sum iny next char iny cpy length ble lb1 mod2 sum,#hashSize+1 return disp asl sum asl sum return 2:sum end
mcopy ccommon.macros
****************************************************************
*
* CopyString - copy a string
*
* Inputs:
* toPtr - location to copy to
* fromPtr - location to copy from
*
****************************************************************
*
CopyString start
subroutine (4:toPtr,4:fromPtr),0
short I,M
lda [fromPtr]
sta [toPtr]
tay
lb1 lda [fromPtr],Y
sta [toPtr],Y
dey
bne lb1
long I,M
return
end
****************************************************************
*
* Hash - find hash displacement
*
* Finds the displacement into an array of pointers using a
* hash function.
*
* Inputs:
* sPtr - points to string to find hash for
*
* Outputs:
* Returns the disp into the hash table
*
****************************************************************
*
Hash start
hashSize equ 876 # hash buckets - 1
sum equ 0 hash
length equ 2 length of string
subroutine (4:sPtr),4
stz sum default to bucket 0
lda [sPtr] set the length of the string
and #$00FF
sta length
ldy #1 start with char 1
lda [sPtr] if 1st char is '~', start with char 6
and #$FF00
cmp #'~'*256
bne lb1
ldy #6
lb1 lda [sPtr],Y get the value to add in
and #$3F3F
cpy length if there is only 1 char left then
bne lb2
and #$00FF and out the high byte
lb2 clc add it to the sum
adc sum
sta sum
iny next char
iny
cpy length
ble lb1
mod2 sum,#hashSize+1 return disp
asl sum
asl sum
return 2:sum
end

258
CCommon.macros Executable file → Normal file
View File

@ -1 +1,257 @@
MACRO &lab subroutine &parms,&work &lab anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+3+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc sec sbc #&work tcs inc a phd tcd mend MACRO &lab return &r &lab anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g aif &totallen=0,.f lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .f pld tsc clc adc #&worklen+&totallen tcs phb plx ply lda &r+8 pha lda &r+6 pha lda &r+4 pha lda &r+2 pha lda &r pha phy phx plb rtl mexit .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend MACRO &LAB MOD2 &N1,&N2,&N3 AIF C:&N3,.A LCLC &N3 &N3 SETC &N1 .A &LAB ~SETM LCLC &C &C AMID "&N2",1,1 AIF "{"="&C",.B AIF "["="&C",.B ~OP LDX,&N2 AGO .C .B ~LDA &N2 TAX .C ~LDA &N1 JSL ~MOD2 ~STA &N3 ~RESTM MEND MACRO &LAB ~SETM &LAB ANOP AIF C:&~LA,.B GBLB &~LA GBLB &~LI .B &~LA SETB S:LONGA &~LI SETB S:LONGI AIF S:LONGA.AND.S:LONGI,.A REP #32*(.NOT.&~LA)+16*(.NOT.&~LI) LONGA ON LONGI ON .A MEND MACRO &LAB ~RESTM &LAB ANOP AIF (&~LA+&~LI)=2,.I SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI) AIF &~LA,.H LONGA OFF .H AIF &~LI,.I LONGI OFF .I MEND MACRO &LAB ~LDA &OP LCLC &C &C AMID "&OP",1,1 AIF "&C"<>"{",.B &C AMID "&OP",L:&OP,1 AIF "&C"="}",.A MNOTE "Missing closing '}'",2 &OP SETC &OP} .A &OP AMID "&OP",2,L:&OP-2 &OP SETC (&OP) .B &LAB LDA &OP MEND MACRO &LAB ~STA &OP LCLC &C &C AMID "&OP",1,1 AIF "&C"<>"{",.B &C AMID "&OP",L:&OP,1 AIF "&C"="}",.A MNOTE "Missing closing '}'",2 &OP SETC &OP} .A &OP AMID "&OP",2,L:&OP-2 &OP SETC (&OP) .B &LAB STA &OP MEND MACRO &LAB ~OP &OPC,&OP LCLC &C &C AMID "&OP",1,1 AIF "&C"<>"{",.B &C AMID "&OP",L:&OP,1 AIF "&C"="}",.A MNOTE "Missing closing '}'",2 &OP SETC &OP} .A &OP AMID "&OP",2,L:&OP-2 &OP SETC (&OP) .B &LAB &OPC &OP MEND MACRO &LAB BLE &BP &LAB BLT &BP BEQ &BP MEND MACRO &LAB LONG &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB REP #&M*32+&I*16 AIF .NOT.&M,.B LONGA ON .B AIF .NOT.&I,.C LONGI ON .C MEND MACRO &LAB SHORT &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB SEP #&M*32+&I*16 AIF .NOT.&M,.B LONGA OFF .B AIF .NOT.&I,.C LONGI OFF .C MEND
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
aif &totallen=0,.f
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.f
pld
tsc
clc
adc #&worklen+&totallen
tcs
phb
plx
ply
lda &r+8
pha
lda &r+6
pha
lda &r+4
pha
lda &r+2
pha
lda &r
pha
phy
phx
plb
rtl
mexit
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend
MACRO
&LAB MOD2 &N1,&N2,&N3
AIF C:&N3,.A
LCLC &N3
&N3 SETC &N1
.A
&LAB ~SETM
LCLC &C
&C AMID "&N2",1,1
AIF "{"="&C",.B
AIF "["="&C",.B
~OP LDX,&N2
AGO .C
.B
~LDA &N2
TAX
.C
~LDA &N1
JSL ~MOD2
~STA &N3
~RESTM
MEND
MACRO
&LAB ~SETM
&LAB ANOP
AIF C:&~LA,.B
GBLB &~LA
GBLB &~LI
.B
&~LA SETB S:LONGA
&~LI SETB S:LONGI
AIF S:LONGA.AND.S:LONGI,.A
REP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
LONGA ON
LONGI ON
.A
MEND
MACRO
&LAB ~RESTM
&LAB ANOP
AIF (&~LA+&~LI)=2,.I
SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
AIF &~LA,.H
LONGA OFF
.H
AIF &~LI,.I
LONGI OFF
.I
MEND
MACRO
&LAB ~LDA &OP
LCLC &C
&C AMID "&OP",1,1
AIF "&C"<>"{",.B
&C AMID "&OP",L:&OP,1
AIF "&C"="}",.A
MNOTE "Missing closing '}'",2
&OP SETC &OP}
.A
&OP AMID "&OP",2,L:&OP-2
&OP SETC (&OP)
.B
&LAB LDA &OP
MEND
MACRO
&LAB ~STA &OP
LCLC &C
&C AMID "&OP",1,1
AIF "&C"<>"{",.B
&C AMID "&OP",L:&OP,1
AIF "&C"="}",.A
MNOTE "Missing closing '}'",2
&OP SETC &OP}
.A
&OP AMID "&OP",2,L:&OP-2
&OP SETC (&OP)
.B
&LAB STA &OP
MEND
MACRO
&LAB ~OP &OPC,&OP
LCLC &C
&C AMID "&OP",1,1
AIF "&C"<>"{",.B
&C AMID "&OP",L:&OP,1
AIF "&C"="}",.A
MNOTE "Missing closing '}'",2
&OP SETC &OP}
.A
&OP AMID "&OP",2,L:&OP-2
&OP SETC (&OP)
.B
&LAB &OPC &OP
MEND
MACRO
&LAB BLE &BP
&LAB BLT &BP
BEQ &BP
MEND
MACRO
&LAB LONG &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB REP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA ON
.B
AIF .NOT.&I,.C
LONGI ON
.C
MEND
MACRO
&LAB SHORT &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB SEP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA OFF
.B
AIF .NOT.&I,.C
LONGI OFF
.C
MEND

970
CCommon.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

116
CGC.asm Executable file → Normal file
View File

@ -1 +1,115 @@
mcopy cgc.macros **************************************************************** * * CnvSX - Convert floating point to SANE extended * * Inputs: * rec - pointer to a record * **************************************************************** * CnvSX start rec equ 4 record containing values rec_real equ 0 disp to real value rec_ext equ 8 disp to extended (SANE) value tsc set up DP phd tcd ph4 rec push addr of real number clc push addr of SANE number lda rec adc #rec_ext tax lda rec+2 adc #0 pha phx fd2x convert TOS to extended move4 0,4 return pld pla pla rtl end **************************************************************** * * CnvSC - Convert floating point to SANE comp * * Inputs: * rec - pointer to a record * **************************************************************** * CnvSC start rec equ 4 record containing values rec_real equ 0 disp to real value rec_ext equ 8 disp to extended (SANE) value rec_cmp equ 18 disp to comp (SANE) value tsc set up DP phd tcd ph4 rec push addr of real number clc push addr of SANE number lda rec adc #rec_ext tax lda rec+2 adc #0 pha phx fd2x convert TOS to extended clc push addr of SANE number lda rec adc #rec_ext tax lda rec+2 adc #0 pha phx clc push addr of COMP number lda rec adc #rec_cmp tax lda rec+2 adc #0 pha phx fx2c convert TOS to extended move4 0,4 return pld pla pla rtl end **************************************************************** * * InitLabels - initialize the labels array * * Outputs: * labelTab - initialized * intLabel - initialized * **************************************************************** * InitLabels start maxLabel equ 2400 ! with labelTab[0] do begin lda #-1 val := -1; sta labelTab+6 sta labelTab+8 stz labelTab defined := false; stz labelTab+2 chain := nil; stz labelTab+4 ! end; {with} ldx #labelTab for i := 1 to maxLabel do ldy #labelTab+10 labelTab[i] := labelTab[0]; lda #maxLabel*10-1 mvn labelTab,labelTab stz intLabel intLabel := 0; rtl end
mcopy cgc.macros
****************************************************************
*
* CnvSX - Convert floating point to SANE extended
*
* Inputs:
* rec - pointer to a record
*
****************************************************************
*
CnvSX start
rec equ 4 record containing values
rec_real equ 0 disp to real value
rec_ext equ 8 disp to extended (SANE) value
tsc set up DP
phd
tcd
ph4 rec push addr of real number
clc push addr of SANE number
lda rec
adc #rec_ext
tax
lda rec+2
adc #0
pha
phx
fd2x convert TOS to extended
move4 0,4 return
pld
pla
pla
rtl
end
****************************************************************
*
* CnvSC - Convert floating point to SANE comp
*
* Inputs:
* rec - pointer to a record
*
****************************************************************
*
CnvSC start
rec equ 4 record containing values
rec_real equ 0 disp to real value
rec_ext equ 8 disp to extended (SANE) value
rec_cmp equ 18 disp to comp (SANE) value
tsc set up DP
phd
tcd
ph4 rec push addr of real number
clc push addr of SANE number
lda rec
adc #rec_ext
tax
lda rec+2
adc #0
pha
phx
fd2x convert TOS to extended
clc push addr of SANE number
lda rec
adc #rec_ext
tax
lda rec+2
adc #0
pha
phx
clc push addr of COMP number
lda rec
adc #rec_cmp
tax
lda rec+2
adc #0
pha
phx
fx2c convert TOS to extended
move4 0,4 return
pld
pla
pla
rtl
end
****************************************************************
*
* InitLabels - initialize the labels array
*
* Outputs:
* labelTab - initialized
* intLabel - initialized
*
****************************************************************
*
InitLabels start
maxLabel equ 2400
! with labelTab[0] do begin
lda #-1 val := -1;
sta labelTab+6
sta labelTab+8
stz labelTab defined := false;
stz labelTab+2 chain := nil;
stz labelTab+4
! end; {with}
ldx #labelTab for i := 1 to maxLabel do
ldy #labelTab+10 labelTab[i] := labelTab[0];
lda #maxLabel*10-1
mvn labelTab,labelTab
stz intLabel intLabel := 0;
rtl
end

189
CGC.macros Executable file → Normal file
View File

@ -1 +1,188 @@
macro &l move4 &m1,&m2 lclb &yistwo &l ~setm ~lda &m1 ~sta &m2 ~lda.h &m1 ~sta.h &m2 ~restm mend macro &l ph4 &n1 aif "&n1"="*",.f lclc &c &l anop &c amid &n1,1,1 aif "&c"="#",.d aif s:longa=1,.a rep #%00100000 .a aif "&c"<>"{",.b &c amid &n1,l:&n1,1 aif "&c"<>"}",.g &n1 amid &n1,2,l:&n1-2 ldy #2 lda (&n1),y pha lda (&n1) pha ago .e .b aif "&c"<>"[",.c ldy #2 lda &n1,y pha lda &n1 pha ago .e .c aif "&c"<>"<",.c1 &n1 amid &n1,2,l:&n1-1 pei &n1+2 pei &n1 ago .e .c1 lda &n1+2 pha lda &n1 pha ago .e .d &n1 amid &n1,2,l:&n1-1 pea +(&n1)|-16 pea &n1 ago .f .e aif s:longa=1,.f sep #%00100000 .f mexit .g mnote "Missing closing '}'",16 mend macro &l ~lda &op lclc &c &c amid "&op",1,1 aif "&c"<>"{",.b &c amid "&op",l:&op,1 aif "&c"="}",.a mnote "Missing closing '}'",2 &op setc &op} .a &op amid "&op",2,l:&op-2 &op setc (&op) .b &l lda &op mend macro &l ~lda.h &op &l anop lclc &c &c amid "&op",1,1 aif "&c"="[",.b aif "&c"<>"{",.d &c amid "&op",l:&op,1 aif "&c"="}",.a mnote "Missing closing '}'",2 &op setc &op} .a &op amid "&op",2,l:&op-2 &op setc (&op) .b aif &yistwo,.c &yistwo setb 1 ldy #2 .c &op setc "&op,y" lda &op mexit .d aif "&c"<>"#",.e &op amid "&op",2,l:&op-1 &op setc "#^&op" lda &op mexit .e lda 2+&op mend macro &l ~restm &l anop aif (&~la+&~li)=2,.i sep #32*(.not.&~la)+16*(.not.&~li) aif &~la,.h longa off .h aif &~li,.i longi off .i mend macro &l ~setm &l anop aif c:&~la,.b gblb &~la gblb &~li .b &~la setb s:longa &~li setb s:longi aif s:longa.and.s:longi,.a rep #32*(.not.&~la)+16*(.not.&~li) longa on longi on .a mend macro &l ~sta &op lclc &c &c amid "&op",1,1 aif "&c"<>"{",.b &c amid "&op",l:&op,1 aif "&c"="}",.a mnote "Missing closing '}'",2 &op setc &op} .a &op amid "&op",2,l:&op-2 &op setc (&op) .b &l sta &op mend macro &l ~sta.h &op &l anop lclc &c &c amid "&op",1,1 aif "&c"="[",.b aif "&c"<>"{",.d &c amid "&op",l:&op,1 aif "&c"="}",.a mnote "Missing closing '}'",2 &op setc &op} .a &op amid "&op",2,l:&op-2 &op setc (&op) .b aif &yistwo,.c &yistwo setb 1 ldy #2 .c &op setc "&op,y" sta &op mexit .d sta 2+&op mend MACRO &LAB FD2X &LAB PEA $010E LDX #$090A JSL $E10000 MEND MACRO &LAB FX2C &LAB PEA $0510 LDX #$090A JSL $E10000 MEND
macro
&l move4 &m1,&m2
lclb &yistwo
&l ~setm
~lda &m1
~sta &m2
~lda.h &m1
~sta.h &m2
~restm
mend
macro
&l ph4 &n1
aif "&n1"="*",.f
lclc &c
&l anop
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l ~lda &op
lclc &c
&c amid "&op",1,1
aif "&c"<>"{",.b
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
&l lda &op
mend
macro
&l ~lda.h &op
&l anop
lclc &c
&c amid "&op",1,1
aif "&c"="[",.b
aif "&c"<>"{",.d
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
aif &yistwo,.c
&yistwo setb 1
ldy #2
.c
&op setc "&op,y"
lda &op
mexit
.d
aif "&c"<>"#",.e
&op amid "&op",2,l:&op-1
&op setc "#^&op"
lda &op
mexit
.e
lda 2+&op
mend
macro
&l ~restm
&l anop
aif (&~la+&~li)=2,.i
sep #32*(.not.&~la)+16*(.not.&~li)
aif &~la,.h
longa off
.h
aif &~li,.i
longi off
.i
mend
macro
&l ~setm
&l anop
aif c:&~la,.b
gblb &~la
gblb &~li
.b
&~la setb s:longa
&~li setb s:longi
aif s:longa.and.s:longi,.a
rep #32*(.not.&~la)+16*(.not.&~li)
longa on
longi on
.a
mend
macro
&l ~sta &op
lclc &c
&c amid "&op",1,1
aif "&c"<>"{",.b
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
&l sta &op
mend
macro
&l ~sta.h &op
&l anop
lclc &c
&c amid "&op",1,1
aif "&c"="[",.b
aif "&c"<>"{",.d
&c amid "&op",l:&op,1
aif "&c"="}",.a
mnote "Missing closing '}'",2
&op setc &op}
.a
&op amid "&op",2,l:&op-2
&op setc (&op)
.b
aif &yistwo,.c
&yistwo setb 1
ldy #2
.c
&op setc "&op,y"
sta &op
mexit
.d
sta 2+&op
mend
MACRO
&LAB FD2X
&LAB PEA $010E
LDX #$090A
JSL $E10000
MEND
MACRO
&LAB FX2C
&LAB PEA $0510
LDX #$090A
JSL $E10000
MEND

125
CGC.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

799
CGI.Comments Executable file → Normal file

File diff suppressed because one or more lines are too long

369
CGI.Debug Executable file → Normal file

File diff suppressed because one or more lines are too long

1297
CGI.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

4735
DAG.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

266
DAG2.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

165
Exp.macros Executable file → Normal file
View File

@ -1 +1,164 @@
MACRO &lab subroutine &parms,&work &lab anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+3+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc sec sbc #&work tcs inc a phd tcd mend MACRO &lab return &r &lab anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g aif &totallen=0,.f lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .f pld tsc clc adc #&worklen+&totallen tcs phb plx ply lda &r+8 pha lda &r+6 pha lda &r+4 pha lda &r+2 pha lda &r pha phy phx plb rtl mexit .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend MACRO &LAB BGT &BP &LAB BEQ *+4 BGE &BP MEND MACRO &LAB BLE &BP &LAB BLT &BP BEQ &BP MEND MACRO &LAB MOVE4 &F,&T &LAB ~SETM LDA 2+&F STA 2+&T LDA &F STA &T ~RESTM MEND MACRO &LAB ~SETM &LAB ANOP AIF C:&~LA,.B GBLB &~LA GBLB &~LI .B &~LA SETB S:LONGA &~LI SETB S:LONGI AIF S:LONGA.AND.S:LONGI,.A REP #32*(.NOT.&~LA)+16*(.NOT.&~LI) LONGA ON LONGI ON .A MEND MACRO &LAB ~RESTM &LAB ANOP AIF (&~LA+&~LI)=2,.I SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI) AIF &~LA,.H LONGA OFF .H AIF &~LI,.I LONGI OFF .I MEND
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
aif &totallen=0,.f
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.f
pld
tsc
clc
adc #&worklen+&totallen
tcs
phb
plx
ply
lda &r+8
pha
lda &r+6
pha
lda &r+4
pha
lda &r+2
pha
lda &r
pha
phy
phx
plb
rtl
mexit
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend
MACRO
&LAB BGT &BP
&LAB BEQ *+4
BGE &BP
MEND
MACRO
&LAB BLE &BP
&LAB BLT &BP
BEQ &BP
MEND
MACRO
&LAB MOVE4 &F,&T
&LAB ~SETM
LDA 2+&F
STA 2+&T
LDA &F
STA &T
~RESTM
MEND
MACRO
&LAB ~SETM
&LAB ANOP
AIF C:&~LA,.B
GBLB &~LA
GBLB &~LI
.B
&~LA SETB S:LONGA
&~LI SETB S:LONGI
AIF S:LONGA.AND.S:LONGI,.A
REP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
LONGA ON
LONGI ON
.A
MEND
MACRO
&LAB ~RESTM
&LAB ANOP
AIF (&~LA+&~LI)=2,.I
SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
AIF &~LA,.H
LONGA OFF
.H
AIF &~LI,.I
LONGI OFF
.I
MEND

389
Expression.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

3727
Expression.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

5649
Gen.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

1944
Header.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

150
Header2.pas Executable file → Normal file
View File

@ -1 +1,149 @@
{$optimize 7} {---------------------------------------------------------------} { } { Header } { } { Handles saving and reading precompiled headers. } { } {---------------------------------------------------------------} unit Header; {$LibPrefix '0/obj/'} interface uses CCommon, MM, Scanner, Symbol, CGI; {$segment 'scanner'} var inhibitHeader: boolean; {should .sym includes be blocked?} procedure EndInclude (chPtr: ptr); { Saves symbols created by the include file } { } { Parameters: } { chPtr - chPtr when the file returned } { } { Notes: } { 1. Call this subroutine right after processing an } { include file. } { 2. Declared externally in Symbol.pas } procedure FlagPragmas (pragma: pragmas); { record the effects of a pragma } { } { parameters: } { pragma - pragma to record } { } { Notes: } { 1. Defined as extern in Scanner.pas } { 2. For the purposes of this unit, the segment statement is } { treated as a pragma. } procedure InitHeader (var fName: gsosOutString); { look for a header file, reading it if it exists } { } { parameters: } { fName - source file name (var for efficiency) } procedure TermHeader; { Stop processing the header file } { } { Note: This is called when the first code-generating } { subroutine is found, and again when the compile ends. It } { closes any open symbol file, and should take no action if } { called twice. } procedure StartInclude (name: gsosOutStringPtr); { Marks the start of an include file } { } { Notes: } { 1. Call this subroutine right after opening an include } { file. } { 2. Defined externally in Scanner.pas } {---------------------------------------------------------------} implementation procedure EndInclude {chPtr: ptr}; { Saves symbols created by the include file } { } { Parameters: } { chPtr - chPtr when the file returned } { } { Notes: } { 1. Call this subroutine right after processing an } { include file. } { 2. Declared externally in Symbol.pas } begin {EndInclude} end; {EndInclude} procedure FlagPragmas {pragma: pragmas}; { record the effects of a pragma } { } { parameters: } { pragma - pragma to record } { } { Notes: } { 1. Defined as extern in Scanner.pas } { 2. For the purposes of this unit, the segment statement is } { treated as a pragma. } begin {FlagPragmas} end; {FlagPragmas} procedure InitHeader {var fName: gsosOutString}; { look for a header file, reading it if it exists } { } { parameters: } { fName - source file name (var for efficiency) } begin {InitHeader} end; {InitHeader} procedure StartInclude {name: gsosOutStringPtr}; { Marks the start of an include file } { } { Notes: } { 1. Call this subroutine right after opening an include } { file. } { 2. Defined externally in Scanner.pas } begin {StartInclude} end; {StartInclude} procedure TermHeader; { Stop processing the header file } { } { Note: This is called when the first code-generating } { subroutine is found, and again when the compile ends. It } { closes any open symbol file, and should take no action if } { called twice. } begin {TermHeader} end; {TermHeader} end.
{$optimize 7}
{---------------------------------------------------------------}
{ }
{ Header }
{ }
{ Handles saving and reading precompiled headers. }
{ }
{---------------------------------------------------------------}
unit Header;
{$LibPrefix '0/obj/'}
interface
uses CCommon, MM, Scanner, Symbol, CGI;
{$segment 'scanner'}
var
inhibitHeader: boolean; {should .sym includes be blocked?}
procedure EndInclude (chPtr: ptr);
{ Saves symbols created by the include file }
{ }
{ Parameters: }
{ chPtr - chPtr when the file returned }
{ }
{ Notes: }
{ 1. Call this subroutine right after processing an }
{ include file. }
{ 2. Declared externally in Symbol.pas }
procedure FlagPragmas (pragma: pragmas);
{ record the effects of a pragma }
{ }
{ parameters: }
{ pragma - pragma to record }
{ }
{ Notes: }
{ 1. Defined as extern in Scanner.pas }
{ 2. For the purposes of this unit, the segment statement is }
{ treated as a pragma. }
procedure InitHeader (var fName: gsosOutString);
{ look for a header file, reading it if it exists }
{ }
{ parameters: }
{ fName - source file name (var for efficiency) }
procedure TermHeader;
{ Stop processing the header file }
{ }
{ Note: This is called when the first code-generating }
{ subroutine is found, and again when the compile ends. It }
{ closes any open symbol file, and should take no action if }
{ called twice. }
procedure StartInclude (name: gsosOutStringPtr);
{ Marks the start of an include file }
{ }
{ Notes: }
{ 1. Call this subroutine right after opening an include }
{ file. }
{ 2. Defined externally in Scanner.pas }
{---------------------------------------------------------------}
implementation
procedure EndInclude {chPtr: ptr};
{ Saves symbols created by the include file }
{ }
{ Parameters: }
{ chPtr - chPtr when the file returned }
{ }
{ Notes: }
{ 1. Call this subroutine right after processing an }
{ include file. }
{ 2. Declared externally in Symbol.pas }
begin {EndInclude}
end; {EndInclude}
procedure FlagPragmas {pragma: pragmas};
{ record the effects of a pragma }
{ }
{ parameters: }
{ pragma - pragma to record }
{ }
{ Notes: }
{ 1. Defined as extern in Scanner.pas }
{ 2. For the purposes of this unit, the segment statement is }
{ treated as a pragma. }
begin {FlagPragmas}
end; {FlagPragmas}
procedure InitHeader {var fName: gsosOutString};
{ look for a header file, reading it if it exists }
{ }
{ parameters: }
{ fName - source file name (var for efficiency) }
begin {InitHeader}
end; {InitHeader}
procedure StartInclude {name: gsosOutStringPtr};
{ Marks the start of an include file }
{ }
{ Notes: }
{ 1. Call this subroutine right after opening an include }
{ file. }
{ 2. Defined externally in Scanner.pas }
begin {StartInclude}
end; {StartInclude}
procedure TermHeader;
{ Stop processing the header file }
{ }
{ Note: This is called when the first code-generating }
{ subroutine is found, and again when the compile ends. It }
{ closes any open symbol file, and should take no action if }
{ called twice. }
begin {TermHeader}
end; {TermHeader}
end.

116
MM.asm Executable file → Normal file
View File

@ -1 +1,115 @@
mcopy mm.macros **************************************************************** * * Calloc - Allocate memory from a pool and set it to 0. * * Inputs: * bytes - number of bytes to allocate * useGlobalPool - should the memory come from the global * (or local) pool * * Outputs: * ptr - points to the first byte of the allocated memory * **************************************************************** * Calloc start ptr equ 0 pointer to reserved memory subroutine (2:bytes),4 ph2 bytes reserve the memory jsl Malloc sta ptr save the pointer to the memory stx ptr+2 lda bytes if there are an odd number of bytes then tay lsr a bcc lb1 short M zero the first byte lda #0 dey sta [ptr],Y long M lb1 tyx done if there are no more bytes beq lb4 lda #0 dey branch if the next word is the zeroth dey beq lb3 lb2 sta [ptr],Y zero full words dey dey bne lb2 lb3 sta [ptr] zero the last word lb4 return 4:ptr return the pointer end **************************************************************** * * GCalloc - Allocate and clear memory from the global pool. * * Inputs: * bytes - number of bytes to allocate * * Outputs: * ptr - points to the first byte of the allocated memory * **************************************************************** * GCalloc start ptr equ 0 pointer to reserved memory subroutine (2:bytes),4 ph2 bytes reserve the memory jsl GMalloc sta ptr save the pointer to the memory stx ptr+2 lda bytes if there are an odd number of bytes then tay lsr a bcc lb1 short M zero the first byte lda #0 dey sta [ptr],Y long M lb1 tyx done if there are no more bytes beq lb4 lda #0 dey branch if the next word is the zeroth dey beq lb3 lb2 sta [ptr],Y zero full words dey dey bne lb2 lb3 sta [ptr] zero the last word lb4 return 4:ptr return the pointer end **************************************************************** * * Malloc - Allocate memory from a pool. * * Inputs: * bytes - number of bytes to allocate * useGlobalPool - should the memory come from the global * (or local) pool * * Outputs: * ptr - points to the first byte of the allocated memory * **************************************************************** * Malloc start lda useGlobalPool jne GMalloc jmp LMalloc end
mcopy mm.macros
****************************************************************
*
* Calloc - Allocate memory from a pool and set it to 0.
*
* Inputs:
* bytes - number of bytes to allocate
* useGlobalPool - should the memory come from the global
* (or local) pool
*
* Outputs:
* ptr - points to the first byte of the allocated memory
*
****************************************************************
*
Calloc start
ptr equ 0 pointer to reserved memory
subroutine (2:bytes),4
ph2 bytes reserve the memory
jsl Malloc
sta ptr save the pointer to the memory
stx ptr+2
lda bytes if there are an odd number of bytes then
tay
lsr a
bcc lb1
short M zero the first byte
lda #0
dey
sta [ptr],Y
long M
lb1 tyx done if there are no more bytes
beq lb4
lda #0
dey branch if the next word is the zeroth
dey
beq lb3
lb2 sta [ptr],Y zero full words
dey
dey
bne lb2
lb3 sta [ptr] zero the last word
lb4 return 4:ptr return the pointer
end
****************************************************************
*
* GCalloc - Allocate and clear memory from the global pool.
*
* Inputs:
* bytes - number of bytes to allocate
*
* Outputs:
* ptr - points to the first byte of the allocated memory
*
****************************************************************
*
GCalloc start
ptr equ 0 pointer to reserved memory
subroutine (2:bytes),4
ph2 bytes reserve the memory
jsl GMalloc
sta ptr save the pointer to the memory
stx ptr+2
lda bytes if there are an odd number of bytes then
tay
lsr a
bcc lb1
short M zero the first byte
lda #0
dey
sta [ptr],Y
long M
lb1 tyx done if there are no more bytes
beq lb4
lda #0
dey branch if the next word is the zeroth
dey
beq lb3
lb2 sta [ptr],Y zero full words
dey
dey
bne lb2
lb3 sta [ptr] zero the last word
lb4 return 4:ptr return the pointer
end
****************************************************************
*
* Malloc - Allocate memory from a pool.
*
* Inputs:
* bytes - number of bytes to allocate
* useGlobalPool - should the memory come from the global
* (or local) pool
*
* Outputs:
* ptr - points to the first byte of the allocated memory
*
****************************************************************
*
Malloc start
lda useGlobalPool
jne GMalloc
jmp LMalloc
end

196
MM.macros Executable file → Normal file
View File

@ -1 +1,195 @@
MACRO &lab subroutine &parms,&work &lab anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+3+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc sec sbc #&work tcs inc a phd tcd mend MACRO &lab return &r &lab anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g aif &totallen=0,.f lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .f pld tsc clc adc #&worklen+&totallen tcs phb plx ply lda &r+8 pha lda &r+6 pha lda &r+4 pha lda &r+2 pha lda &r pha phy phx plb rtl mexit .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend MACRO &LAB JNE &BP &LAB BEQ *+5 BRL &BP MEND MACRO &LAB LONG &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB REP #&M*32+&I*16 AIF .NOT.&M,.B LONGA ON .B AIF .NOT.&I,.C LONGI ON .C MEND MACRO &LAB PH2 &N1 LCLC &C &LAB ANOP &C AMID &N1,1,1 AIF "&C"="#",.D AIF S:LONGA=1,.A REP #%00100000 .A AIF "&C"<>"{",.B &C AMID &N1,L:&N1,1 AIF "&C"<>"}",.G &N1 AMID &N1,2,L:&N1-2 LDA (&N1) PHA AGO .E .B LDA &N1 PHA AGO .E .D &N1 AMID &N1,2,L:&N1-1 PEA &N1 AGO .F .E AIF S:LONGA=1,.F SEP #%00100000 .F MEXIT .G MNOTE "Missing closing '}'",16 MEND MACRO &LAB SHORT &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB SEP #&M*32+&I*16 AIF .NOT.&M,.B LONGA OFF .B AIF .NOT.&I,.C LONGI OFF .C MEND
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
aif &totallen=0,.f
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.f
pld
tsc
clc
adc #&worklen+&totallen
tcs
phb
plx
ply
lda &r+8
pha
lda &r+6
pha
lda &r+4
pha
lda &r+2
pha
lda &r
pha
phy
phx
plb
rtl
mexit
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend
MACRO
&LAB JNE &BP
&LAB BEQ *+5
BRL &BP
MEND
MACRO
&LAB LONG &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB REP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA ON
.B
AIF .NOT.&I,.C
LONGI ON
.C
MEND
MACRO
&LAB PH2 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDA (&N1)
PHA
AGO .E
.B
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB SHORT &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB SEP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA OFF
.B
AIF .NOT.&I,.C
LONGI OFF
.C
MEND

233
MM.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

163
Native.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

119
Native.macros Executable file → Normal file
View File

@ -1 +1,118 @@
MACRO &lab subroutine &parms,&work &lab anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+3+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc sec sbc #&work tcs inc a phd tcd mend MACRO &lab return &r &lab anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g aif &totallen=0,.f lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .f pld tsc clc adc #&worklen+&totallen tcs phb plx ply lda &r+8 pha lda &r+6 pha lda &r+4 pha lda &r+2 pha lda &r pha phy phx plb rtl mexit .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
aif &totallen=0,.f
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.f
pld
tsc
clc
adc #&worklen+&totallen
tcs
phb
plx
ply
lda &r+8
pha
lda &r+6
pha
lda &r+4
pha
lda &r+2
pha
lda &r
pha
phy
phx
plb
rtl
mexit
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend

2317
Native.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

1242
Native2.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

229
ObjOut.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

254
ObjOut.macros Executable file → Normal file
View File

@ -1 +1,253 @@
MACRO &LAB LONG &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB REP #&M*32+&I*16 AIF .NOT.&M,.B LONGA ON .B AIF .NOT.&I,.C LONGI ON .C MEND MACRO &LAB PH4 &N1 LCLC &C &LAB ANOP &C AMID &N1,1,1 AIF "&C"="#",.D AIF S:LONGA=1,.A REP #%00100000 .A AIF "&C"<>"{",.B &C AMID &N1,L:&N1,1 AIF "&C"<>"}",.G &N1 AMID &N1,2,L:&N1-2 LDY #2 LDA (&N1),Y PHA LDA (&N1) PHA AGO .E .B AIF "&C"<>"[",.C LDY #2 LDA &N1,Y PHA LDA &N1 PHA AGO .E .C LDA &N1+2 PHA LDA &N1 PHA AGO .E .D &N1 AMID &N1,2,L:&N1-1 PEA +(&N1)|-16 PEA &N1 AGO .F .E AIF S:LONGA=1,.F SEP #%00100000 .F MEXIT .G MNOTE "Missing closing '}'",16 MEND MACRO &LAB SHORT &A,&B LCLB &I LCLB &M &A AMID &A,1,1 &M SETB ("&A"="M").OR.("&A"="m") &I SETB ("&A"="I").OR.("&A"="i") AIF C:&B=0,.A &B AMID &B,1,1 &M SETB ("&B"="M").OR.("&B"="m").OR.&M &I SETB ("&B"="I").OR.("&B"="i").OR.&I .A &LAB SEP #&M*32+&I*16 AIF .NOT.&M,.B LONGA OFF .B AIF .NOT.&I,.C LONGI OFF .C MEND MACRO &LAB INC4 &A &LAB ~SETM INC &A BNE ~&SYSCNT INC 2+&A ~&SYSCNT ~RESTM MEND MACRO &LAB ~SETM &LAB ANOP AIF C:&~LA,.B GBLB &~LA GBLB &~LI .B &~LA SETB S:LONGA &~LI SETB S:LONGI AIF S:LONGA.AND.S:LONGI,.A REP #32*(.NOT.&~LA)+16*(.NOT.&~LI) LONGA ON LONGI ON .A MEND MACRO &LAB ~RESTM &LAB ANOP AIF (&~LA+&~LI)=2,.I SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI) AIF &~LA,.H LONGA OFF .H AIF &~LI,.I LONGI OFF .I MEND MACRO &LAB PUT2 &N1,&F1,&CR,&ERROUT AIF C:&F1,.A LCLC &F1 &F1 SETC #0 .A &LAB ~SETM PH2 &N1 PH2 &F1 PH2 #C:&CR PH2 #C:&ERROUT JSL ~PUT2 ~RESTM MEND MACRO &LAB PUT4 &N1,&F1,&CR,&ERROUT AIF C:&F1,.A LCLC &F1 &F1 SETC #0 .A &LAB ~SETM PH4 &N1 PH2 &F1 PH2 #C:&CR PH2 #C:&ERROUT JSL ~PUT4 ~RESTM MEND MACRO &LAB PUTS &N1,&F1,&CR,&ERROUT &LAB ~SETM LCLC &C &C AMID "&N1",1,1 AIF "&C"<>"#",.C AIF L:&N1>127,.A BRA ~&SYSCNT AGO .B .A BRL ~&SYSCNT .B &N1 AMID "&N1",2,L:&N1-1 ~L&SYSCNT DC I1"L:~S&SYSCNT" ~S&SYSCNT DC C&N1 ~&SYSCNT ANOP &N1 SETC ~L&SYSCNT-1 AIF C:&F1=0,.D .C ~PUSHA &N1 AIF C:&F1,.C1 PEA 0 AGO .C2 .C1 PH2 &F1 .C2 PH2 #C:&CR PH2 #C:&ERROUT JSL ~PUTS ~RESTM MEXIT .D PEA ~L&SYSCNT|-16 PEA ~L&SYSCNT LDX #$1C0C+(C:&ERROUT*256)-(512*C:&CR) JSL $E10000 ~RESTM MEND MACRO &LAB ~PUSHA &N1 LCLC &C &LAB ANOP &C AMID &N1,1,1 AIF "&C"<>"{",.B &C AMID &N1,L:&N1,1 AIF "&C"<>"}",.G &N1 AMID &N1,2,L:&N1-2 SEP #$20 LONGA OFF LDA #0 PHA REP #$20 LONGA ON PHK LDA &N1 PHA MEXIT .B AIF "&C"<>"[",.C &N1 AMID &N1,2,L:&N1-2 LDA &N1+2 PHA LDA &N1 PHA MEXIT .C PEA +(&N1)|-16 PEA &N1 MEXIT .G MNOTE "Missing closing '}'",16 MEND MACRO &LAB PH2 &N1 LCLC &C &LAB ANOP &C AMID &N1,1,1 AIF "&C"="#",.D AIF S:LONGA=1,.A REP #%00100000 .A AIF "&C"<>"{",.B &C AMID &N1,L:&N1,1 AIF "&C"<>"}",.G &N1 AMID &N1,2,L:&N1-2 LDA (&N1) PHA AGO .E .B LDA &N1 PHA AGO .E .D &N1 AMID &N1,2,L:&N1-1 PEA &N1 AGO .F .E AIF S:LONGA=1,.F SEP #%00100000 .F MEXIT .G MNOTE "Missing closing '}'",16 MEND
MACRO
&LAB LONG &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB REP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA ON
.B
AIF .NOT.&I,.C
LONGI ON
.C
MEND
MACRO
&LAB PH4 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDY #2
LDA (&N1),Y
PHA
LDA (&N1)
PHA
AGO .E
.B
AIF "&C"<>"[",.C
LDY #2
LDA &N1,Y
PHA
LDA &N1
PHA
AGO .E
.C
LDA &N1+2
PHA
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA +(&N1)|-16
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB SHORT &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB SEP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA OFF
.B
AIF .NOT.&I,.C
LONGI OFF
.C
MEND
MACRO
&LAB INC4 &A
&LAB ~SETM
INC &A
BNE ~&SYSCNT
INC 2+&A
~&SYSCNT ~RESTM
MEND
MACRO
&LAB ~SETM
&LAB ANOP
AIF C:&~LA,.B
GBLB &~LA
GBLB &~LI
.B
&~LA SETB S:LONGA
&~LI SETB S:LONGI
AIF S:LONGA.AND.S:LONGI,.A
REP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
LONGA ON
LONGI ON
.A
MEND
MACRO
&LAB ~RESTM
&LAB ANOP
AIF (&~LA+&~LI)=2,.I
SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
AIF &~LA,.H
LONGA OFF
.H
AIF &~LI,.I
LONGI OFF
.I
MEND
MACRO
&LAB PUT2 &N1,&F1,&CR,&ERROUT
AIF C:&F1,.A
LCLC &F1
&F1 SETC #0
.A
&LAB ~SETM
PH2 &N1
PH2 &F1
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUT2
~RESTM
MEND
MACRO
&LAB PUT4 &N1,&F1,&CR,&ERROUT
AIF C:&F1,.A
LCLC &F1
&F1 SETC #0
.A
&LAB ~SETM
PH4 &N1
PH2 &F1
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUT4
~RESTM
MEND
MACRO
&LAB PUTS &N1,&F1,&CR,&ERROUT
&LAB ~SETM
LCLC &C
&C AMID "&N1",1,1
AIF "&C"<>"#",.C
AIF L:&N1>127,.A
BRA ~&SYSCNT
AGO .B
.A
BRL ~&SYSCNT
.B
&N1 AMID "&N1",2,L:&N1-1
~L&SYSCNT DC I1"L:~S&SYSCNT"
~S&SYSCNT DC C&N1
~&SYSCNT ANOP
&N1 SETC ~L&SYSCNT-1
AIF C:&F1=0,.D
.C
~PUSHA &N1
AIF C:&F1,.C1
PEA 0
AGO .C2
.C1
PH2 &F1
.C2
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUTS
~RESTM
MEXIT
.D
PEA ~L&SYSCNT|-16
PEA ~L&SYSCNT
LDX #$1C0C+(C:&ERROUT*256)-(512*C:&CR)
JSL $E10000
~RESTM
MEND
MACRO
&LAB ~PUSHA &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
SEP #$20
LONGA OFF
LDA #0
PHA
REP #$20
LONGA ON
PHK
LDA &N1
PHA
MEXIT
.B
AIF "&C"<>"[",.C
&N1 AMID &N1,2,L:&N1-2
LDA &N1+2
PHA
LDA &N1
PHA
MEXIT
.C
PEA +(&N1)|-16
PEA &N1
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PH2 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDA (&N1)
PHA
AGO .E
.B
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND

596
ObjOut.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

235
ObjOut2.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

596
ObjOut2.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

3937
Parser.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

648
Scanner.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

32
Scanner.debug Executable file → Normal file
View File

@ -1 +1,31 @@
procedure PrintTokenList (tp: tokenListRecordPtr); {debug} begin if tp <> nil then begin PrintTokenList(tp^.next); PrintToken(tp^.token); end; {if} end; procedure PrintMacroTable; {debug} { print the macro definitions } var i: 0..hashSize; {loop/index variable} mp: macroRecordPtr; {used to trace macro lists} begin {PrintMacroTable} for i := 0 to hashSize do begin mp := macros^[i]; while mp <> nil do begin write(' ', mp^.name^, '(', mp^.parameters:1, ') ['); PrintTokenList(mp^.tokens); writeln(']'); mp := mp^.next; end; {while} end; {for} write('(Press RETURN to continue)'); readln; end; {PrintMacroTable}
procedure PrintTokenList (tp: tokenListRecordPtr); {debug}
begin
if tp <> nil then begin
PrintTokenList(tp^.next);
PrintToken(tp^.token);
end; {if}
end;
procedure PrintMacroTable; {debug}
{ print the macro definitions }
var
i: 0..hashSize; {loop/index variable}
mp: macroRecordPtr; {used to trace macro lists}
begin {PrintMacroTable}
for i := 0 to hashSize do begin
mp := macros^[i];
while mp <> nil do begin
write(' ', mp^.name^, '(', mp^.parameters:1, ') [');
PrintTokenList(mp^.tokens);
writeln(']');
mp := mp^.next;
end; {while}
end; {for}
write('(Press RETURN to continue)');
readln;
end; {PrintMacroTable}

532
Scanner.macros Executable file → Normal file

File diff suppressed because one or more lines are too long

4051
Scanner.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

104
Symbol.Print Executable file → Normal file
View File

@ -1 +1,103 @@
procedure PrintOneSymbol {ip: identPtr}; { Print a symbol } { } { Parameters: } { ip - identifier to print } procedure PrintClass (class: tokenEnum); { Print the class of a symbol } { } { Parameters: } { class - class of the symbol } begin {PrintClass} case class of autosy: write('auto'); externsy: write('extern'); ident: write('ident'); otherwise: write(ord(class):1); end; {case} end; {PrintClass} procedure PrintType (tp: typePtr); { Print a type } { } { Parameters: } { tp - type pointer } begin {PrintType} with tp^ do begin write(' ', size:1, ' byte '); if isConstant then write('constant '); case kind of scalarType : writeln('scalar'); arrayType : begin writeln(elements: 1, ' element array of'); PrintType(aType); end; pointerType : begin writeln(' pointer to'); PrintType(pType); end; functionType: begin writeln(' function returning'); PrintType(fType); end; enumConst : writeln('enumeration (', eval: 1, ')'); enumType : writeln('enum type'); definedType : begin writeln('defined type of'); PrintType(dType); end; structType : writeln('struct: ', ord4(tp):1); unionType : writeln('union'); end; {case} end; {with} end; {PrintType} begin {PrintOneSymbol} with ip^ do begin writeln; {start with a blank line} write(name^, {write id info} ': isForwardDeclared = ', isForwardDeclared, '; class = '); PrintClass(class); writeln; PrintType(iType); {print type info} end; {with} end; {PrintOneSymbol} procedure PrintTable {sym: symbolTablePtr}; { print a symbol table } { } { parameters: } { sym - symbol table to print } var i: integer; {loop variable} ip: identPtr; {current symbol} begin {PrintTable} if sym <> nil then begin writeln; {write header} writeln('Symbols:'); writeln('========'); for i := 0 to hashSize do begin {loop over all hash buckets} ip := sym^.buckets[i]; {trace through all symbols in this bucket} while ip <> nil do begin PrintOneSymbol(ip); {print a symbol} ip := ip^.next; {next symbol} end; {while} end; {for} end; {if} end; {PrintTable}
procedure PrintOneSymbol {ip: identPtr};
{ Print a symbol }
{ }
{ Parameters: }
{ ip - identifier to print }
procedure PrintClass (class: tokenEnum);
{ Print the class of a symbol }
{ }
{ Parameters: }
{ class - class of the symbol }
begin {PrintClass}
case class of
autosy: write('auto');
externsy: write('extern');
ident: write('ident');
otherwise: write(ord(class):1);
end; {case}
end; {PrintClass}
procedure PrintType (tp: typePtr);
{ Print a type }
{ }
{ Parameters: }
{ tp - type pointer }
begin {PrintType}
with tp^ do begin
write(' ', size:1, ' byte ');
if isConstant then
write('constant ');
case kind of
scalarType : writeln('scalar');
arrayType : begin
writeln(elements: 1, ' element array of');
PrintType(aType);
end;
pointerType : begin
writeln(' pointer to');
PrintType(pType);
end;
functionType: begin
writeln(' function returning');
PrintType(fType);
end;
enumConst : writeln('enumeration (', eval: 1, ')');
enumType : writeln('enum type');
definedType : begin
writeln('defined type of');
PrintType(dType);
end;
structType : writeln('struct: ', ord4(tp):1);
unionType : writeln('union');
end; {case}
end; {with}
end; {PrintType}
begin {PrintOneSymbol}
with ip^ do begin
writeln; {start with a blank line}
write(name^, {write id info}
': isForwardDeclared = ', isForwardDeclared,
'; class = ');
PrintClass(class);
writeln;
PrintType(iType); {print type info}
end; {with}
end; {PrintOneSymbol}
procedure PrintTable {sym: symbolTablePtr};
{ print a symbol table }
{ }
{ parameters: }
{ sym - symbol table to print }
var
i: integer; {loop variable}
ip: identPtr; {current symbol}
begin {PrintTable}
if sym <> nil then begin
writeln; {write header}
writeln('Symbols:');
writeln('========');
for i := 0 to hashSize do begin {loop over all hash buckets}
ip := sym^.buckets[i]; {trace through all symbols in this bucket}
while ip <> nil do begin
PrintOneSymbol(ip); {print a symbol}
ip := ip^.next; {next symbol}
end; {while}
end; {for}
end; {if}
end; {PrintTable}

25
Symbol.asm Executable file → Normal file
View File

@ -1 +1,24 @@
mcopy symbol.macros **************************************************************** * * ClearTable - set the symbol table to zeros * * Inputs: * table - symbol table address * **************************************************************** * ClearTable private tableSize equ 7026 sizeof(symbolTable) subroutine (4:table),0 ldy #tableSize-2 lda #0 lb1 sta [table],Y dey dey bpl lb1 return end
mcopy symbol.macros
****************************************************************
*
* ClearTable - set the symbol table to zeros
*
* Inputs:
* table - symbol table address
*
****************************************************************
*
ClearTable private
tableSize equ 7026 sizeof(symbolTable)
subroutine (4:table),0
ldy #tableSize-2
lda #0
lb1 sta [table],Y
dey
dey
bpl lb1
return
end

119
Symbol.macros Executable file → Normal file
View File

@ -1 +1,118 @@
MACRO &lab subroutine &parms,&work &lab anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+3+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc sec sbc #&work tcs inc a phd tcd mend MACRO &lab return &r &lab anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g aif &totallen=0,.f lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .f pld tsc clc adc #&worklen+&totallen tcs phb plx ply lda &r+8 pha lda &r+6 pha lda &r+4 pha lda &r+2 pha lda &r pha phy phx plb rtl mexit .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+1 sta &worklen+&totallen+1 lda &worklen sta &worklen+&totallen .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
aif &totallen=0,.f
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.f
pld
tsc
clc
adc #&worklen+&totallen
tcs
phb
plx
ply
lda &r+8
pha
lda &r+6
pha
lda &r+4
pha
lda &r+2
pha
lda &r
pha
phy
phx
plb
rtl
mexit
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend

1536
Symbol.pas Executable file → Normal file

File diff suppressed because one or more lines are too long

877
Table.asm Executable file → Normal file

File diff suppressed because one or more lines are too long

25
Table.macros Executable file → Normal file
View File

@ -1 +1,24 @@
MACRO &LAB ENUM &LIST,&START &LAB ANOP AIF C:&~ENUM,.A GBLA &~ENUM .A AIF C:&START=0,.B &~ENUM SETA &START .B LCLA &CNT &CNT SETA 1 .C &LIST(&CNT) EQU &~ENUM &~ENUM SETA &~ENUM+1 &CNT SETA &CNT+1 AIF &CNT<=C:&LIST,^C MEND MACRO &LAB STR8 &STR &LAB DC I1'L:A&SYSCNT' A&SYSCNT DC C'&STR' DS 8-L:A&SYSCNT MEND
MACRO
&LAB ENUM &LIST,&START
&LAB ANOP
AIF C:&~ENUM,.A
GBLA &~ENUM
.A
AIF C:&START=0,.B
&~ENUM SETA &START
.B
LCLA &CNT
&CNT SETA 1
.C
&LIST(&CNT) EQU &~ENUM
&~ENUM SETA &~ENUM+1
&CNT SETA &CNT+1
AIF &CNT<=C:&LIST,^C
MEND
MACRO
&LAB STR8 &STR
&LAB DC I1'L:A&SYSCNT'
A&SYSCNT DC C'&STR'
DS 8-L:A&SYSCNT
MEND

44
Table.pas Executable file → Normal file
View File

@ -1 +1,43 @@
{$optimize 7} {---------------------------------------------------------------} { } { Table } { } { Initialized arrays and records. } { } {---------------------------------------------------------------} unit Table; {$LibPrefix '0/obj/'} interface uses CCommon; var {from scanner.pas} {----------------} charKinds: array[minChar..maxChar] of charEnum; {character kinds} charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols} reservedWords: array[autosy..whilesy] of string[8]; {reserved word strings} wordHash: array[0..23] of tokenEnum; {for hashing reserved words} {from ASM.PAS} {------------} {names of the opcodes} names: array[opcode] of packed array[1..3] of char; {binary values for the opcodes} iOpcodes: array[o_clc..o_xce] of byte; rOpcodes: array[o_bcc..o_bvs] of byte; nOpcodes: array[o_adc..o_tsb,operands] of byte; {from EXPRESSION.PAS} {-------------------} icp: array[tokenEnum] of byte; {in-commong priorities} isp: array[tokenEnum] of byte; {in-stack priorities} implementation end.
{$optimize 7}
{---------------------------------------------------------------}
{ }
{ Table }
{ }
{ Initialized arrays and records. }
{ }
{---------------------------------------------------------------}
unit Table;
{$LibPrefix '0/obj/'}
interface
uses CCommon;
var
{from scanner.pas}
{----------------}
charKinds: array[minChar..maxChar] of charEnum; {character kinds}
charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols}
reservedWords: array[autosy..whilesy] of string[8]; {reserved word strings}
wordHash: array[0..23] of tokenEnum; {for hashing reserved words}
{from ASM.PAS}
{------------}
{names of the opcodes}
names: array[opcode] of packed array[1..3] of char;
{binary values for the opcodes}
iOpcodes: array[o_clc..o_xce] of byte;
rOpcodes: array[o_bcc..o_bvs] of byte;
nOpcodes: array[o_adc..o_tsb,operands] of byte;
{from EXPRESSION.PAS}
{-------------------}
icp: array[tokenEnum] of byte; {in-commong priorities}
isp: array[tokenEnum] of byte; {in-stack priorities}
implementation
end.

24
Tests/Conformance/C11.4.2.1.CC Executable file → Normal file
View File

@ -1 +1,23 @@
/* Conformance Test 11.4.2.1: Type qualifiers should be allowed both in */ /* type casts and in the type-specifiers for */ /* field lists. */ #include <stdio.h> struct foo { int i; const j; volatile k; } ; main () { int i,j; j = 4; i = (const) j; i = (volatile) j; printf ("Passed Conformance Test 11.4.2.1\n"); }
/* Conformance Test 11.4.2.1: Type qualifiers should be allowed both in */
/* type casts and in the type-specifiers for */
/* field lists. */
#include <stdio.h>
struct foo {
int i;
const j;
volatile k;
} ;
main ()
{
int i,j;
j = 4;
i = (const) j;
i = (volatile) j;
printf ("Passed Conformance Test 11.4.2.1\n");
}

44
Tests/Conformance/C13.1.0.1.CC Executable file → Normal file
View File

@ -1 +1,43 @@
/* Conformance Test 13.1.0.1: Verification of standard library types and */ /* NULL */ #include <stddef.h> extended e1 [800]; main () { int i [10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int *i1 = i; int *i2 = &i [2]; long diff; unsigned long size; static ptrdiff_t TestPtrdiff_t (int *int1Ptr, int *int2Ptr); diff = TestPtrdiff_t (i2, i1); if (diff != 2) goto Fail; size = sizeof(e1); if (size != 8000) goto Fail; if (NULL != 0) goto Fail; printf ("Passed Conformance Test 13.1.0.1\n"); return; Fail: printf ("Failed Conformance Test 13.1.0.1\n"); } /*****************************************************************************/ static ptrdiff_t TestPtrdiff_t (int *int1Ptr, int *int2Ptr) { return int1Ptr - int2Ptr; }
/* Conformance Test 13.1.0.1: Verification of standard library types and */
/* NULL */
#include <stddef.h>
extended e1 [800];
main ()
{
int i [10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int *i1 = i;
int *i2 = &i [2];
long diff;
unsigned long size;
static ptrdiff_t TestPtrdiff_t (int *int1Ptr, int *int2Ptr);
diff = TestPtrdiff_t (i2, i1);
if (diff != 2)
goto Fail;
size = sizeof(e1);
if (size != 8000)
goto Fail;
if (NULL != 0)
goto Fail;
printf ("Passed Conformance Test 13.1.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 13.1.0.1\n");
}
/*****************************************************************************/
static ptrdiff_t TestPtrdiff_t (int *int1Ptr, int *int2Ptr)
{
return int1Ptr - int2Ptr;
}

149
Tests/Conformance/C14.1.0.1.CC Executable file → Normal file
View File

@ -1 +1,148 @@
/* Conformance Test 14.1.0.1: Verification of isalnum, isalpha, isascii, */ /* and iscntrl */ #include <ctype.h> main () { int i, j; char ch; short k; long L; unsigned int ui1; unsigned long ul1; unsigned char uc; /* isalnum: returns 0 if char is not in ['0'..'9', 'a'..'z', 'A'..'Z'] */ for (ch = '0'; ch <= '9'; ch++) { j = isalnum (ch); if (j == 0) goto Fail; } for (uc = 'a'; uc <= 'z'; uc++) { j = isalnum (uc); if (j == 0) goto Fail; } for (uc = 'A'; uc <= 'Z'; uc++) { j = isalnum (uc); if (j == 0) goto Fail; } j = isalnum ('~'); if (j != 0) goto Fail; /* isalpha: returns 0 if char is not in ['a'..'z', 'A'..'Z'] */ for (ch = '0'; ch <= '9'; ch++) { j = isalpha (ch); if (j != 0) goto Fail; } for (uc = 'a'; uc <= 'z'; uc++) { j = isalpha (uc); if (j == 0) goto Fail; } for (uc = 'A'; uc <= 'Z'; uc++) { j = isalpha (uc); if (j == 0) goto Fail; } j = isalpha ('~'); if (j != 0) goto Fail; /* isascii: returns 0 if int is not in the range 0..128 */ for (k = 0, i = 0; i < 20; k++, i++) { j = isascii (k); if (j == 0) goto Fail; } for (uc = 20, i = 20; i < 39; uc++, i++) { j = isascii (uc); if (j == 0) goto Fail; } for (ch = 39, i = 39; i < 57; ch++, i++) { j = isascii (ch); if (j == 0) goto Fail; } for (L = 57, i = 57; i < 75; L++, i++) { j = isascii (L); if (j == 0) goto Fail; } for (ui1 = 75, i = 75; i < 93; ui1++, i++) { j = isascii (ui1); if (j == 0) goto Fail; } for (ul1 = 93, i = 93; i < 128; ul1++, i++) { j = isascii (ul1); if (j == 0) goto Fail; } for (i = 128; i < 256; i++) { j = isascii (i); if (j != 0) goto Fail; } /* iscntrl: returns 0 if char is not in [0..31, 127] */ for (i = 0; i <= 31; i++) { j = iscntrl ( (char) (i) ); if (j == 0) goto Fail; } if ( (j = iscntrl (127)) == 0 ) goto Fail; for (i = 32; i < 127; i++) { if ( (j = iscntrl ( (char) (i) )) != 0 ) goto Fail; } printf ("Passed Conformance Test 14.1.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.1.0.1\n"); }
/* Conformance Test 14.1.0.1: Verification of isalnum, isalpha, isascii, */
/* and iscntrl */
#include <ctype.h>
main ()
{
int i, j;
char ch;
short k;
long L;
unsigned int ui1;
unsigned long ul1;
unsigned char uc;
/* isalnum: returns 0 if char is not in ['0'..'9', 'a'..'z', 'A'..'Z'] */
for (ch = '0'; ch <= '9'; ch++)
{
j = isalnum (ch);
if (j == 0)
goto Fail;
}
for (uc = 'a'; uc <= 'z'; uc++)
{
j = isalnum (uc);
if (j == 0)
goto Fail;
}
for (uc = 'A'; uc <= 'Z'; uc++)
{
j = isalnum (uc);
if (j == 0)
goto Fail;
}
j = isalnum ('~');
if (j != 0)
goto Fail;
/* isalpha: returns 0 if char is not in ['a'..'z', 'A'..'Z'] */
for (ch = '0'; ch <= '9'; ch++)
{
j = isalpha (ch);
if (j != 0)
goto Fail;
}
for (uc = 'a'; uc <= 'z'; uc++)
{
j = isalpha (uc);
if (j == 0)
goto Fail;
}
for (uc = 'A'; uc <= 'Z'; uc++)
{
j = isalpha (uc);
if (j == 0)
goto Fail;
}
j = isalpha ('~');
if (j != 0)
goto Fail;
/* isascii: returns 0 if int is not in the range 0..128 */
for (k = 0, i = 0; i < 20; k++, i++)
{
j = isascii (k);
if (j == 0)
goto Fail;
}
for (uc = 20, i = 20; i < 39; uc++, i++)
{
j = isascii (uc);
if (j == 0)
goto Fail;
}
for (ch = 39, i = 39; i < 57; ch++, i++)
{
j = isascii (ch);
if (j == 0)
goto Fail;
}
for (L = 57, i = 57; i < 75; L++, i++)
{
j = isascii (L);
if (j == 0)
goto Fail;
}
for (ui1 = 75, i = 75; i < 93; ui1++, i++)
{
j = isascii (ui1);
if (j == 0)
goto Fail;
}
for (ul1 = 93, i = 93; i < 128; ul1++, i++)
{
j = isascii (ul1);
if (j == 0)
goto Fail;
}
for (i = 128; i < 256; i++)
{
j = isascii (i);
if (j != 0)
goto Fail;
}
/* iscntrl: returns 0 if char is not in [0..31, 127] */
for (i = 0; i <= 31; i++)
{
j = iscntrl ( (char) (i) );
if (j == 0)
goto Fail;
}
if ( (j = iscntrl (127)) == 0 )
goto Fail;
for (i = 32; i < 127; i++)
{
if ( (j = iscntrl ( (char) (i) )) != 0 )
goto Fail;
}
printf ("Passed Conformance Test 14.1.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.1.0.1\n");
}

62
Tests/Conformance/C14.2.0.1.CC Executable file → Normal file
View File

@ -1 +1,61 @@
/* Conformance Test 14.2.0.1: Verification of iscsym, iscymf */ #include <ctype.h> main () { int i, j; char ch; unsigned char uc; /* iscsym: returns 0 if char is not in ['0'..'9', 'a'..'z', 'A'..'Z', '_'] */ /* iscsymf: returns 0 if char is not in ['a'..'z', 'A'..'Z', '_'] */ for (ch = '0'; ch <= '9'; ch++) { j = iscsym (ch); if (j == 0) goto Fail; j = iscsymf (ch); if (j != 0) goto Fail; } for (uc = 'a'; uc <= 'z'; uc++) { j = iscsym (uc); if (j == 0) goto Fail; j = iscsymf (uc); if (j == 0) goto Fail; } for (uc = 'A'; uc <= 'Z'; uc++) { j = iscsym (uc); if (j == 0) goto Fail; j = iscsymf (uc); if (j == 0) goto Fail; } j = iscsym ('_'); if (j == 0) goto Fail; j = iscsymf ('_'); if (j == 0) goto Fail; j = iscsym ('~'); if (j != 0) goto Fail; printf ("Passed Conformance Test 14.2.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.2.0.1\n"); }
/* Conformance Test 14.2.0.1: Verification of iscsym, iscymf */
#include <ctype.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* iscsym: returns 0 if char is not in ['0'..'9', 'a'..'z', 'A'..'Z', '_'] */
/* iscsymf: returns 0 if char is not in ['a'..'z', 'A'..'Z', '_'] */
for (ch = '0'; ch <= '9'; ch++)
{
j = iscsym (ch);
if (j == 0)
goto Fail;
j = iscsymf (ch);
if (j != 0)
goto Fail;
}
for (uc = 'a'; uc <= 'z'; uc++)
{
j = iscsym (uc);
if (j == 0)
goto Fail;
j = iscsymf (uc);
if (j == 0)
goto Fail;
}
for (uc = 'A'; uc <= 'Z'; uc++)
{
j = iscsym (uc);
if (j == 0)
goto Fail;
j = iscsymf (uc);
if (j == 0)
goto Fail;
}
j = iscsym ('_');
if (j == 0)
goto Fail;
j = iscsymf ('_');
if (j == 0)
goto Fail;
j = iscsym ('~');
if (j != 0)
goto Fail;
printf ("Passed Conformance Test 14.2.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.2.0.1\n");
}

88
Tests/Conformance/C14.3.0.1.CC Executable file → Normal file
View File

@ -1 +1,87 @@
/* Conformance Test 14.3.0.1: Verification of isdigit, isodigit, isxdigit */ #include <ctype.h> main () { int i, j; char ch; unsigned char uc; /* isdigit: returns 0 if char is not in ['0'..'9'] */ /* isodigit: returns 0 if char is not in ['0'..'7'] */ /* isxdigit: returns 0 if char is not in ['0'..'9', 'a'..'f', 'A'..'F'] */ for (ch = '0'; ch < '8'; ch++) { j = isdigit (ch); if (j == 0) goto Fail; j = isodigit (ch); if (j == 0) goto Fail; j = isxdigit (ch); if (j == 0) goto Fail; } for (ch = '8'; ch <= '9'; ch++) { j = isdigit (ch); if (j == 0) goto Fail; j = isodigit (ch); if (j != 0) goto Fail; j = isxdigit (ch); if (j == 0) goto Fail; } for (uc = 'a'; uc <= 'f'; uc++) { j = isdigit (uc); if (j != 0) goto Fail; j = isodigit (uc); if (j != 0) goto Fail; j = isxdigit (uc); if (j == 0) goto Fail; } for (uc = 'A'; uc <= 'F'; uc++) { j = isdigit (uc); if (j != 0) goto Fail; j = isodigit (uc); if (j != 0) goto Fail; j = isxdigit (uc); if (j == 0) goto Fail; } for (uc = 'G'; uc <= 'Z'; uc++) { j = isdigit (uc); if (j != 0) goto Fail; j = isodigit (uc); if (j != 0) goto Fail; j = isxdigit (uc); if (j != 0) goto Fail; } printf ("Passed Conformance Test 14.3.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.3.0.1\n"); }
/* Conformance Test 14.3.0.1: Verification of isdigit, isodigit, isxdigit */
#include <ctype.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* isdigit: returns 0 if char is not in ['0'..'9'] */
/* isodigit: returns 0 if char is not in ['0'..'7'] */
/* isxdigit: returns 0 if char is not in ['0'..'9', 'a'..'f', 'A'..'F'] */
for (ch = '0'; ch < '8'; ch++)
{
j = isdigit (ch);
if (j == 0)
goto Fail;
j = isodigit (ch);
if (j == 0)
goto Fail;
j = isxdigit (ch);
if (j == 0)
goto Fail;
}
for (ch = '8'; ch <= '9'; ch++)
{
j = isdigit (ch);
if (j == 0)
goto Fail;
j = isodigit (ch);
if (j != 0)
goto Fail;
j = isxdigit (ch);
if (j == 0)
goto Fail;
}
for (uc = 'a'; uc <= 'f'; uc++)
{
j = isdigit (uc);
if (j != 0)
goto Fail;
j = isodigit (uc);
if (j != 0)
goto Fail;
j = isxdigit (uc);
if (j == 0)
goto Fail;
}
for (uc = 'A'; uc <= 'F'; uc++)
{
j = isdigit (uc);
if (j != 0)
goto Fail;
j = isodigit (uc);
if (j != 0)
goto Fail;
j = isxdigit (uc);
if (j == 0)
goto Fail;
}
for (uc = 'G'; uc <= 'Z'; uc++)
{
j = isdigit (uc);
if (j != 0)
goto Fail;
j = isodigit (uc);
if (j != 0)
goto Fail;
j = isxdigit (uc);
if (j != 0)
goto Fail;
}
printf ("Passed Conformance Test 14.3.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.3.0.1\n");
}

41
Tests/Conformance/C14.5.0.1.CC Executable file → Normal file
View File

@ -1 +1,40 @@
/* Conformance Test 14.5.0.1: Verification of islower, isupper */ #include <ctype.h> main () { int i, j; char ch; unsigned char uc; /* islower: returns 0 if char is not in ['a'..'z'] */ /* isupper: returns 0 if char is not in ['A'..'Z'] */ for (uc = 'a'; uc <= 'z'; uc++) { j = islower (uc); if (j == 0) goto Fail; j = isupper (uc); if (j != 0) goto Fail; } for (ch = 'A'; ch <= 'Z'; ch++) { j = islower (ch); if (j != 0) goto Fail; j = isupper (ch); if (j == 0) goto Fail; } printf ("Passed Conformance Test 14.5.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.5.0.1\n"); }
/* Conformance Test 14.5.0.1: Verification of islower, isupper */
#include <ctype.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* islower: returns 0 if char is not in ['a'..'z'] */
/* isupper: returns 0 if char is not in ['A'..'Z'] */
for (uc = 'a'; uc <= 'z'; uc++)
{
j = islower (uc);
if (j == 0)
goto Fail;
j = isupper (uc);
if (j != 0)
goto Fail;
}
for (ch = 'A'; ch <= 'Z'; ch++)
{
j = islower (ch);
if (j != 0)
goto Fail;
j = isupper (ch);
if (j == 0)
goto Fail;
}
printf ("Passed Conformance Test 14.5.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.5.0.1\n");
}

38
Tests/Conformance/C14.6.0.1.CC Executable file → Normal file
View File

@ -1 +1,37 @@
/* Conformance Test 14.6.0.1: Verification of isspace function */ #include <ctype.h> main () { int i, j; char ch; unsigned char uc; /* isspace: returns 0 if char is not in [ \t \r \n \v \f] */ j = isspace (' '); if (j == 0) goto Fail; for (uc = 9; uc <= '\r'; uc++) { j = isspace (uc); if (j == 0) goto Fail; } for (ch = 'A'; ch <= 'Z'; ch++) { j = isspace (ch); if (j != 0) goto Fail; } printf ("Passed Conformance Test 14.6.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.6.0.1\n"); }
/* Conformance Test 14.6.0.1: Verification of isspace function */
#include <ctype.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* isspace: returns 0 if char is not in [ \t \r \n \v \f] */
j = isspace (' ');
if (j == 0)
goto Fail;
for (uc = 9; uc <= '\r'; uc++)
{
j = isspace (uc);
if (j == 0)
goto Fail;
}
for (ch = 'A'; ch <= 'Z'; ch++)
{
j = isspace (ch);
if (j != 0)
goto Fail;
}
printf ("Passed Conformance Test 14.6.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.6.0.1\n");
}

75
Tests/Conformance/C14.7.0.1.CC Executable file → Normal file
View File

@ -1 +1,74 @@
/* Conformance Test 14.7.0.1: Verification of toascii function */ #include <ctype.h> main () { int i, j; char ch; short k; long L; unsigned int ui1; unsigned long ul1; unsigned char uc; /* toascii: returns ASCII value of any integral value by returning only */ /* the 7 low order bits */ for (k = 0, i = 0; i < 20; k++, i++) { j = toascii (k); if (j != k) goto Fail; } for (uc = 20, i = 20; i < 39; uc++, i++) { j = toascii (uc); if (j != uc) goto Fail; } for (ch = 39, i = 39; i < 57; ch++, i++) { j = toascii (ch); if (j != ch) goto Fail; } for (L = 57, i = 57; i < 75; L++, i++) { j = toascii (L); if (j != L) goto Fail; } for (ui1 = 75, i = 75; i < 93; ui1++, i++) { j = toascii (ui1); if (j != ui1) goto Fail; } for (ul1 = 93, i = 93; i < 128; ul1++, i++) { j = toascii (ul1); if (j != ul1) goto Fail; } for (k = 0, i = 128; i < 256; k++, i++) /* check truncation */ { j = toascii (i); if (j != k) goto Fail; } printf ("Passed Conformance Test 14.7.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.7.0.1\n"); }
/* Conformance Test 14.7.0.1: Verification of toascii function */
#include <ctype.h>
main ()
{
int i, j;
char ch;
short k;
long L;
unsigned int ui1;
unsigned long ul1;
unsigned char uc;
/* toascii: returns ASCII value of any integral value by returning only */
/* the 7 low order bits */
for (k = 0, i = 0; i < 20; k++, i++)
{
j = toascii (k);
if (j != k)
goto Fail;
}
for (uc = 20, i = 20; i < 39; uc++, i++)
{
j = toascii (uc);
if (j != uc)
goto Fail;
}
for (ch = 39, i = 39; i < 57; ch++, i++)
{
j = toascii (ch);
if (j != ch)
goto Fail;
}
for (L = 57, i = 57; i < 75; L++, i++)
{
j = toascii (L);
if (j != L)
goto Fail;
}
for (ui1 = 75, i = 75; i < 93; ui1++, i++)
{
j = toascii (ui1);
if (j != ui1)
goto Fail;
}
for (ul1 = 93, i = 93; i < 128; ul1++, i++)
{
j = toascii (ul1);
if (j != ul1)
goto Fail;
}
for (k = 0, i = 128; i < 256; k++, i++) /* check truncation */
{
j = toascii (i);
if (j != k)
goto Fail;
}
printf ("Passed Conformance Test 14.7.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.7.0.1\n");
}

50
Tests/Conformance/C14.8.0.1.CC Executable file → Normal file
View File

@ -1 +1,49 @@
/* Conformance Test 14.8.0.1: Verification of toint function */ #include <ctype.h> #include <stdio.h> main () { int i, j; char ch; unsigned char uc; /* toint: returns 0-9 for char in ['0'..'9'] and 10-15 for char in */ /* ['a'..'f'] or ['A'..'F'] */ for (uc = '0', i = 0; i < 10; uc++, i++) { j = toint (uc); if (j != i) goto Fail; } for (ch = 'A', i = 10; ch <= 'F'; ch++, i++) { j = toint (ch); if (j != i) goto Fail; } for (ch = 'a', i = 10; ch <= 'f'; ch++, i++) { j = toint (ch); if (j != i) goto Fail; } for (ch = 'G'; ch <= 'Z'; ch++) { j = toint (ch); if (j != EOF) goto Fail; } printf ("Passed Conformance Test 14.8.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.8.0.1\n"); }
/* Conformance Test 14.8.0.1: Verification of toint function */
#include <ctype.h>
#include <stdio.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* toint: returns 0-9 for char in ['0'..'9'] and 10-15 for char in */
/* ['a'..'f'] or ['A'..'F'] */
for (uc = '0', i = 0; i < 10; uc++, i++)
{
j = toint (uc);
if (j != i)
goto Fail;
}
for (ch = 'A', i = 10; ch <= 'F'; ch++, i++)
{
j = toint (ch);
if (j != i)
goto Fail;
}
for (ch = 'a', i = 10; ch <= 'f'; ch++, i++)
{
j = toint (ch);
if (j != i)
goto Fail;
}
for (ch = 'G'; ch <= 'Z'; ch++)
{
j = toint (ch);
if (j != EOF)
goto Fail;
}
printf ("Passed Conformance Test 14.8.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.8.0.1\n");
}

61
Tests/Conformance/C14.9.0.1.CC Executable file → Normal file
View File

@ -1 +1,60 @@
/* Conformance Test 14.9.0.1: Verification of tolower, _tolower, toupper, */ /* _toupper functions */ #include <ctype.h> main () { int i, j; char ch; unsigned char uc; /* tolower: converts uppercase letter to lowercase letter; if character */ /* is not alphabetic, then just returns character unchanged */ for (ch = 'A', uc = 'a'; uc <= 'z'; ch++, uc++) { j = tolower (ch); if (j != uc) goto Fail; j = _tolower (ch); if (j != uc) goto Fail; j = tolower (uc); if (j != uc) goto Fail; j = _tolower (uc); if (j != uc) goto Fail; } /* toupper: converts lowercase letter to uppercase letter; if character */ /* is not alphabetic, then just returns character unchanged */ for (ch = 'A', uc = 'a'; uc <= 'z'; ch++, uc++) { j = toupper (uc); if (j != ch) goto Fail; j = _toupper (uc); if (j != ch) goto Fail; j = toupper (ch); if (j != ch) goto Fail; j = _toupper (ch); if (j != ch) goto Fail; } printf ("Passed Conformance Test 14.9.0.1\n"); return; Fail: printf ("Failed Conformance Test 14.9.0.1\n"); }
/* Conformance Test 14.9.0.1: Verification of tolower, _tolower, toupper, */
/* _toupper functions */
#include <ctype.h>
main ()
{
int i, j;
char ch;
unsigned char uc;
/* tolower: converts uppercase letter to lowercase letter; if character */
/* is not alphabetic, then just returns character unchanged */
for (ch = 'A', uc = 'a'; uc <= 'z'; ch++, uc++)
{
j = tolower (ch);
if (j != uc)
goto Fail;
j = _tolower (ch);
if (j != uc)
goto Fail;
j = tolower (uc);
if (j != uc)
goto Fail;
j = _tolower (uc);
if (j != uc)
goto Fail;
}
/* toupper: converts lowercase letter to uppercase letter; if character */
/* is not alphabetic, then just returns character unchanged */
for (ch = 'A', uc = 'a'; uc <= 'z'; ch++, uc++)
{
j = toupper (uc);
if (j != ch)
goto Fail;
j = _toupper (uc);
if (j != ch)
goto Fail;
j = toupper (ch);
if (j != ch)
goto Fail;
j = _toupper (ch);
if (j != ch)
goto Fail;
}
printf ("Passed Conformance Test 14.9.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 14.9.0.1\n");
}

46
Tests/Conformance/C15.1.0.1.CC Executable file → Normal file
View File

@ -1 +1,45 @@
/* Conformance Test 15.1.0.1: Verification of strcat, strncat functions */ #include <string.h> main () { char s1 [80] = "this is the first string argument"; char s2 [80] = ", and this is the second string argument!"; char s3 [160] = ""; strcpy(s3, strcat (s1, s2)); if (strlen (s3) != 74) goto Fail; if (strcmp (s3, "this is the first string argument, and this is the \ second string argument!")) goto Fail; strcpy(s1, "this is the first string argument"); strcpy(s3, strncat (s1, s2, 17)); if (strlen (s3) != 50) goto Fail; if (strcmp (s3, "this is the first string argument, and this is the")) goto Fail; strcpy(s1, "this is the first string argument"); strcpy(s3, strncat (s1, s2, 50)); if (strlen (s3) != 74) goto Fail; if (strcmp (s3, "this is the first string argument, and this is the \ second string argument!")) goto Fail; strcpy(s1, "this is the first string argument"); strcpy(s1, strncat (s1, s2, -5)); if (strcmp (s1, "this is the first string argument")) goto Fail; printf ("Passed Conformance Test 15.1.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.1.0.1\n"); }
/* Conformance Test 15.1.0.1: Verification of strcat, strncat functions */
#include <string.h>
main ()
{
char s1 [80] = "this is the first string argument";
char s2 [80] = ", and this is the second string argument!";
char s3 [160] = "";
strcpy(s3, strcat (s1, s2));
if (strlen (s3) != 74)
goto Fail;
if (strcmp (s3, "this is the first string argument, and this is the \
second string argument!"))
goto Fail;
strcpy(s1, "this is the first string argument");
strcpy(s3, strncat (s1, s2, 17));
if (strlen (s3) != 50)
goto Fail;
if (strcmp (s3, "this is the first string argument, and this is the"))
goto Fail;
strcpy(s1, "this is the first string argument");
strcpy(s3, strncat (s1, s2, 50));
if (strlen (s3) != 74)
goto Fail;
if (strcmp (s3, "this is the first string argument, and this is the \
second string argument!"))
goto Fail;
strcpy(s1, "this is the first string argument");
strcpy(s1, strncat (s1, s2, -5));
if (strcmp (s1, "this is the first string argument"))
goto Fail;
printf ("Passed Conformance Test 15.1.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.1.0.1\n");
}

40
Tests/Conformance/C15.2.0.1.CC Executable file → Normal file
View File

@ -1 +1,39 @@
/* Conformance Test 15.2.0.1: Verification of strcmp, strncmp functions */ #include <string.h> main () { int i; char s1 [] = "this is a string argument "; char s2 [] = "this is a string argument!"; char s3 [160] = ""; i = strcmp (s1, s2); /* ensure strcmp reports s1 < s2 */ if (i >= 0) goto Fail; i = strcmp (s2, s1); if (i <= 0) goto Fail; i = strncmp (s1, s2, 100); /* should compare all chars */ if (i >= 0) goto Fail; i = strncmp (s1, s2, 25); /* should compare 1st 25 chars */ if (i != 0) goto Fail; i = strncmp (s1, s2, -90L); /* should just return 0 */ if (i != 0) goto Fail; printf ("Passed Conformance Test 15.2.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.2.0.1\n"); }
/* Conformance Test 15.2.0.1: Verification of strcmp, strncmp functions */
#include <string.h>
main ()
{
int i;
char s1 [] = "this is a string argument ";
char s2 [] = "this is a string argument!";
char s3 [160] = "";
i = strcmp (s1, s2); /* ensure strcmp reports s1 < s2 */
if (i >= 0)
goto Fail;
i = strcmp (s2, s1);
if (i <= 0)
goto Fail;
i = strncmp (s1, s2, 100); /* should compare all chars */
if (i >= 0)
goto Fail;
i = strncmp (s1, s2, 25); /* should compare 1st 25 chars */
if (i != 0)
goto Fail;
i = strncmp (s1, s2, -90L); /* should just return 0 */
if (i != 0)
goto Fail;
printf ("Passed Conformance Test 15.2.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.2.0.1\n");
}

40
Tests/Conformance/C15.3.0.1.CC Executable file → Normal file
View File

@ -1 +1,39 @@
/* Conformance Test 15.3.0.1: Verification of strcpy, strncpy functions */ #include <stddef.h> #include <string.h> main () { char s1 [80] = "this is the first string argument"; char s2 [80] = ", and this is the second string argument!"; char *strPtr; size_t i; strPtr = strcpy (s1, s2); if (( (i = strlen (strPtr)) != 41 ) || (strPtr != s1)) goto Fail; if (strcmp (s1, ", and this is the second string argument!")) goto Fail; strcpy(s1, "this is the first string argument"); strPtr = strncpy (s1, s2, 10); if (( (i = strlen (strPtr)) != 33 ) || (strPtr != s1)) goto Fail; if (strcmp (s1, ", and thise first string argument")) goto Fail; strcpy (s1, ", and thise first string argument"); strPtr = strncpy (s1, s2, -9L); if (( (i = strlen (strPtr)) != 33 ) || (strPtr != s1)) goto Fail; if (strcmp (s1, ", and thise first string argument")) goto Fail; printf ("Passed Conformance Test 15.3.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.3.0.1\n"); }
/* Conformance Test 15.3.0.1: Verification of strcpy, strncpy functions */
#include <stddef.h>
#include <string.h>
main ()
{
char s1 [80] = "this is the first string argument";
char s2 [80] = ", and this is the second string argument!";
char *strPtr;
size_t i;
strPtr = strcpy (s1, s2);
if (( (i = strlen (strPtr)) != 41 ) || (strPtr != s1))
goto Fail;
if (strcmp (s1, ", and this is the second string argument!"))
goto Fail;
strcpy(s1, "this is the first string argument");
strPtr = strncpy (s1, s2, 10);
if (( (i = strlen (strPtr)) != 33 ) || (strPtr != s1))
goto Fail;
if (strcmp (s1, ", and thise first string argument"))
goto Fail;
strcpy (s1, ", and thise first string argument");
strPtr = strncpy (s1, s2, -9L);
if (( (i = strlen (strPtr)) != 33 ) || (strPtr != s1))
goto Fail;
if (strcmp (s1, ", and thise first string argument"))
goto Fail;
printf ("Passed Conformance Test 15.3.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.3.0.1\n");
}

63
Tests/Conformance/C15.5.0.1.CC Executable file → Normal file
View File

@ -1 +1,62 @@
/* Conformance Test 15.5.0.1: Verification of strchr, strpos, strrchr, and */ /* strrpos functions */ #include <stddef.h> #include <string.h> main () { char s1 [80] = "this is the first string argument"; char *strPtr; size_t i; strPtr = strchr (s1, 's'); /* search s1 for 1st occurrence of 's' */ if (strPtr == NULL) goto Fail; if (strPtr != &(s1 [3])) goto Fail; strPtr = strchr (s1, 'z'); /* search s1 for char not in s1 */ if (strPtr != NULL) goto Fail; i = strpos (s1, 'f'); /* find position of 1st 'f' in s1 */ if (i != 12) goto Fail; i = strpos (s1, 'x'); /* find position of char not in s1 */ if (i != -1) goto Fail; i = strpos (s1, '\0'); /* find position of terminating null */ if (i != 33) goto Fail; strPtr = strrchr (s1, 's'); /* search s1 for last occurrence of 's' */ if (strPtr == NULL) goto Fail; if (strPtr != &(s1 [18])) goto Fail; strPtr = strrchr (s1, 'z'); /* search s1 for char not in s1 */ if (strPtr != NULL) goto Fail; i = strrpos (s1, 'g'); /* find position of last 'g' in s1 */ if (i != 27) goto Fail; i = strrpos (s1, 'x'); /* find position of char not in s1 */ if (i != -1) goto Fail; i = strrpos (s1, '\0'); /* find position of terminating null */ if (i != 33) goto Fail; printf ("Passed Conformance Test 15.5.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.5.0.1\n"); }
/* Conformance Test 15.5.0.1: Verification of strchr, strpos, strrchr, and */
/* strrpos functions */
#include <stddef.h>
#include <string.h>
main ()
{
char s1 [80] = "this is the first string argument";
char *strPtr;
size_t i;
strPtr = strchr (s1, 's'); /* search s1 for 1st occurrence of 's' */
if (strPtr == NULL)
goto Fail;
if (strPtr != &(s1 [3]))
goto Fail;
strPtr = strchr (s1, 'z'); /* search s1 for char not in s1 */
if (strPtr != NULL)
goto Fail;
i = strpos (s1, 'f'); /* find position of 1st 'f' in s1 */
if (i != 12)
goto Fail;
i = strpos (s1, 'x'); /* find position of char not in s1 */
if (i != -1)
goto Fail;
i = strpos (s1, '\0'); /* find position of terminating null */
if (i != 33)
goto Fail;
strPtr = strrchr (s1, 's'); /* search s1 for last occurrence of 's' */
if (strPtr == NULL)
goto Fail;
if (strPtr != &(s1 [18]))
goto Fail;
strPtr = strrchr (s1, 'z'); /* search s1 for char not in s1 */
if (strPtr != NULL)
goto Fail;
i = strrpos (s1, 'g'); /* find position of last 'g' in s1 */
if (i != 27)
goto Fail;
i = strrpos (s1, 'x'); /* find position of char not in s1 */
if (i != -1)
goto Fail;
i = strrpos (s1, '\0'); /* find position of terminating null */
if (i != 33)
goto Fail;
printf ("Passed Conformance Test 15.5.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.5.0.1\n");
}

80
Tests/Conformance/C15.6.0.1.CC Executable file → Normal file
View File

@ -1 +1,79 @@
/* Conformance Test 15.6.0.1: Verification of strspn, strcspn, strpbrk, and */ /* strrpbrk functions */ #include <stddef.h> #include <string.h> main () { char s1 [80] = "a b c d e f g h i j k : ' - _ + "; char *strPtr; size_t i; /* strspn: find length of first run of chars from set */ i = strspn (s1, " abcde cbad "); /* search s1 for only chars in set */ if (i != 10) goto Fail; i = strspn (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */ if (i != 32) /* should return length (s1) */ goto Fail; i = strspn (s1, ""); /* should return 0 */ if (i != 0) goto Fail; /* strcspn: find length of first run of chars not in set */ i = strcspn (s1, "fg:"); /* search s1 for chars not in set */ if (i != 10) goto Fail; i = strcspn (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */ if (i != 0) /* should return 0 */ goto Fail; i = strcspn (s1, ""); /* should return strlen */ if (i != strlen(s1)) goto Fail; /* strpbrk: return pointer to 1st char in set */ strPtr = strpbrk (s1, "fg:"); /* search s1 for chars not in set */ if (strPtr != &(s1 [10])) goto Fail; strPtr = strpbrk (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */ if (strPtr != s1) /* should return ptr to start*/ goto Fail; strPtr = strpbrk (s1, ""); /* should return NULL */ if (strPtr != NULL) goto Fail; /* strrpbrk: return pointer to last char in set */ strPtr = strrpbrk (s1, "fg:"); /* search s1 for last char in set */ if (strPtr != &(s1 [22])) goto Fail; strPtr = strrpbrk (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */ if (strPtr != &(s1[31])) goto Fail; strPtr = strrpbrk (s1, ""); /* should return ptr to end of string */ if (strPtr != NULL) goto Fail; printf ("Passed Conformance Test 15.6.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.6.0.1\n"); }
/* Conformance Test 15.6.0.1: Verification of strspn, strcspn, strpbrk, and */
/* strrpbrk functions */
#include <stddef.h>
#include <string.h>
main ()
{
char s1 [80] = "a b c d e f g h i j k : ' - _ + ";
char *strPtr;
size_t i;
/* strspn: find length of first run of chars from set */
i = strspn (s1, " abcde cbad "); /* search s1 for only chars in set */
if (i != 10)
goto Fail;
i = strspn (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */
if (i != 32) /* should return length (s1) */
goto Fail;
i = strspn (s1, ""); /* should return 0 */
if (i != 0)
goto Fail;
/* strcspn: find length of first run of chars not in set */
i = strcspn (s1, "fg:"); /* search s1 for chars not in set */
if (i != 10)
goto Fail;
i = strcspn (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */
if (i != 0) /* should return 0 */
goto Fail;
i = strcspn (s1, ""); /* should return strlen */
if (i != strlen(s1))
goto Fail;
/* strpbrk: return pointer to 1st char in set */
strPtr = strpbrk (s1, "fg:"); /* search s1 for chars not in set */
if (strPtr != &(s1 [10]))
goto Fail;
strPtr = strpbrk (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */
if (strPtr != s1) /* should return ptr to start*/
goto Fail;
strPtr = strpbrk (s1, ""); /* should return NULL */
if (strPtr != NULL)
goto Fail;
/* strrpbrk: return pointer to last char in set */
strPtr = strrpbrk (s1, "fg:"); /* search s1 for last char in set */
if (strPtr != &(s1 [22]))
goto Fail;
strPtr = strrpbrk (s1, " +_-':kjihgfedcba"); /* all chars in set are in s1 */
if (strPtr != &(s1[31]))
goto Fail;
strPtr = strrpbrk (s1, ""); /* should return ptr to end of string */
if (strPtr != NULL)
goto Fail;
printf ("Passed Conformance Test 15.6.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.6.0.1\n");
}

26
Tests/Conformance/C15.7.0.1.CC Executable file → Normal file
View File

@ -1 +1,25 @@
/* Conformance Test 15.7.0.1: Verification of strstr function */ #include <stddef.h> #include <string.h> main () { char string [] = " this is the source string, a source string"; char *strPtr; strPtr = strstr (string, "source string"); if (strPtr != (&( (string) [(13)] )) ) goto Fail; strPtr = strstr (string, "source string!"); if (strPtr != NULL) goto Fail; printf ("Passed Conformance Test 15.7.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.7.0.1\n"); }
/* Conformance Test 15.7.0.1: Verification of strstr function */
#include <stddef.h>
#include <string.h>
main ()
{
char string [] = " this is the source string, a source string";
char *strPtr;
strPtr = strstr (string, "source string");
if (strPtr != (&( (string) [(13)] )) )
goto Fail;
strPtr = strstr (string, "source string!");
if (strPtr != NULL)
goto Fail;
printf ("Passed Conformance Test 15.7.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.7.0.1\n");
}

107
Tests/Conformance/C15.7.0.2.CC Executable file → Normal file
View File

@ -1 +1,106 @@
/* Conformance Test 15.7.0.2: Verification of strtok function */ #include <stddef.h> #include <string.h> main () { char string [] = " this is the source string, so creative! oh, yes"; char *strPtr; /* First call to strtok pass the string to be parsed; subsequent calls */ /* just pass a NULL pointer. Separating character is space to start. */ strPtr = strtok (string, " "); if (strPtr != (&( (string) [(1)] )) ) goto Fail; strPtr = strtok (NULL, " "); if (strPtr != &string [6]) goto Fail; strPtr = strtok (NULL, " "); if (strPtr != &string [9]) goto Fail; strPtr = strtok (NULL, " "); if (strPtr != &string [13]) goto Fail; strPtr = strtok (NULL, ","); /* now change the separator set */ if (strPtr != &string [20]) goto Fail; strPtr = strtok (NULL, ","); if (strPtr != &string [27]) goto Fail; strPtr = strtok (NULL, "! &*"); /* make last calls to strtok */ if (strPtr != &string [45]) /* address of '\0' at end of string */ goto Fail; strPtr = strtok (NULL, " "); if (strPtr != NULL) goto Fail; /* Check tokenized string created by successive calls to strtok. */ strcpy(string, " this is the source string, so creative! oh, yes"); strPtr = strtok (string, " "); if (strcmp (strPtr, "this")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "is")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "the")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "source")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "string,")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "so")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "creative!")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "oh,")) goto Fail; strPtr = strtok (NULL, " "); if (strcmp (strPtr, "yes")) goto Fail; /* Check "special" cases: string is the null string, and the string */ /* contains only separator characters */ strPtr = strtok ("", " "); if (strPtr != NULL) goto Fail; strPtr = strtok ("abc", "abc"); if (strPtr != NULL) goto Fail; printf ("Passed Conformance Test 15.7.0.2\n"); return; Fail: printf ("Failed Conformance Test 15.7.0.2\n"); }
/* Conformance Test 15.7.0.2: Verification of strtok function */
#include <stddef.h>
#include <string.h>
main ()
{
char string [] = " this is the source string, so creative! oh, yes";
char *strPtr;
/* First call to strtok pass the string to be parsed; subsequent calls */
/* just pass a NULL pointer. Separating character is space to start. */
strPtr = strtok (string, " ");
if (strPtr != (&( (string) [(1)] )) )
goto Fail;
strPtr = strtok (NULL, " ");
if (strPtr != &string [6])
goto Fail;
strPtr = strtok (NULL, " ");
if (strPtr != &string [9])
goto Fail;
strPtr = strtok (NULL, " ");
if (strPtr != &string [13])
goto Fail;
strPtr = strtok (NULL, ","); /* now change the separator set */
if (strPtr != &string [20])
goto Fail;
strPtr = strtok (NULL, ",");
if (strPtr != &string [27])
goto Fail;
strPtr = strtok (NULL, "! &*"); /* make last calls to strtok */
if (strPtr != &string [45]) /* address of '\0' at end of string */
goto Fail;
strPtr = strtok (NULL, " ");
if (strPtr != NULL)
goto Fail;
/* Check tokenized string created by successive calls to strtok. */
strcpy(string, " this is the source string, so creative! oh, yes");
strPtr = strtok (string, " ");
if (strcmp (strPtr, "this"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "is"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "the"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "source"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "string,"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "so"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "creative!"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "oh,"))
goto Fail;
strPtr = strtok (NULL, " ");
if (strcmp (strPtr, "yes"))
goto Fail;
/* Check "special" cases: string is the null string, and the string */
/* contains only separator characters */
strPtr = strtok ("", " ");
if (strPtr != NULL)
goto Fail;
strPtr = strtok ("abc", "abc");
if (strPtr != NULL)
goto Fail;
printf ("Passed Conformance Test 15.7.0.2\n");
return;
Fail:
printf ("Failed Conformance Test 15.7.0.2\n");
}

38
Tests/Conformance/C15.8.0.1.CC Executable file → Normal file
View File

@ -1 +1,37 @@
/* Conformance Test 15.8.0.1: Verification of strtod library function */ #include <stdlib.h> #include <math.h> #include <errno.h> main () { double d1; char string [] = " -32767 0567 -3.4e+2 "; char *strPtr; d1 = strtod (string, &strPtr); if (fabs(d1 - -32767.0) > 0.00001) goto Fail; if (strPtr != &string [8]) goto Fail; d1 = strtod (strPtr, &strPtr); if (fabs(d1 - 567.00) > 0.00001) goto Fail; if (strPtr != &string [14]) goto Fail; d1 = strtod (strPtr, &strPtr); if (fabs(d1 - (-340.00)) > 0.00001) goto Fail; if (strPtr != &string [23]) goto Fail; printf ("Passed Conformance Test 15.8.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.8.0.1\n"); }
/* Conformance Test 15.8.0.1: Verification of strtod library function */
#include <stdlib.h>
#include <math.h>
#include <errno.h>
main ()
{
double d1;
char string [] = " -32767 0567 -3.4e+2 ";
char *strPtr;
d1 = strtod (string, &strPtr);
if (fabs(d1 - -32767.0) > 0.00001)
goto Fail;
if (strPtr != &string [8])
goto Fail;
d1 = strtod (strPtr, &strPtr);
if (fabs(d1 - 567.00) > 0.00001)
goto Fail;
if (strPtr != &string [14])
goto Fail;
d1 = strtod (strPtr, &strPtr);
if (fabs(d1 - (-340.00)) > 0.00001)
goto Fail;
if (strPtr != &string [23])
goto Fail;
printf ("Passed Conformance Test 15.8.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.8.0.1\n");
}

64
Tests/Conformance/C15.8.0.2.CC Executable file → Normal file
View File

@ -1 +1,63 @@
/* Conformance Test 15.8.0.2: Verification of strtol, strtoul functions */ #include <stdlib.h> #include <limits.h> #include <errno.h> #include <string.h> #include <stdio.h> void main (void) { long L1; unsigned long UL1; char string [] = " -2147483647 0xfFfFfFfF 1111 077 0xffffffffff zz "; char *strPtr; L1 = strtol (string, &strPtr, 0); if (L1 != -(0x7fFfFfff)) goto Fail; if (strPtr != &string [13]) goto Fail; UL1 = strtoul (strPtr, &strPtr, 16); /* bases 10-36 can be letters */ if (UL1 != 4294967295ul) goto Fail; if (strPtr != &string [25]) goto Fail; L1 = strtol (strPtr, &strPtr, 2); if (L1 != 15) goto Fail; if (strPtr != &string [31]) goto Fail; UL1 = strtoul (strPtr, &strPtr, 8); if (UL1 != 63) goto Fail; if (strPtr != &string [36]) goto Fail; L1 = strtol (strPtr, &strPtr, 16); if (errno != ERANGE) goto Fail; UL1 = strtoul (strPtr, &strPtr, 16); if (errno != ERANGE) goto Fail; L1 = strtol ("zz", &strPtr, 0); if (errno != ERANGE) goto Fail; UL1 = strtoul ("xx", &strPtr, 0); if (errno != ERANGE) goto Fail; printf ("Passed Conformance Test 15.8.0.2\n"); return; Fail: printf ("Failed Conformance Test 15.8.0.2\n"); }
/* Conformance Test 15.8.0.2: Verification of strtol, strtoul functions */
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
void main (void)
{
long L1;
unsigned long UL1;
char string [] = " -2147483647 0xfFfFfFfF 1111 077 0xffffffffff zz ";
char *strPtr;
L1 = strtol (string, &strPtr, 0);
if (L1 != -(0x7fFfFfff))
goto Fail;
if (strPtr != &string [13])
goto Fail;
UL1 = strtoul (strPtr, &strPtr, 16); /* bases 10-36 can be letters */
if (UL1 != 4294967295ul)
goto Fail;
if (strPtr != &string [25])
goto Fail;
L1 = strtol (strPtr, &strPtr, 2);
if (L1 != 15)
goto Fail;
if (strPtr != &string [31])
goto Fail;
UL1 = strtoul (strPtr, &strPtr, 8);
if (UL1 != 63)
goto Fail;
if (strPtr != &string [36])
goto Fail;
L1 = strtol (strPtr, &strPtr, 16);
if (errno != ERANGE)
goto Fail;
UL1 = strtoul (strPtr, &strPtr, 16);
if (errno != ERANGE)
goto Fail;
L1 = strtol ("zz", &strPtr, 0);
if (errno != ERANGE)
goto Fail;
UL1 = strtoul ("xx", &strPtr, 0);
if (errno != ERANGE)
goto Fail;
printf ("Passed Conformance Test 15.8.0.2\n");
return;
Fail:
printf ("Failed Conformance Test 15.8.0.2\n");
}

30
Tests/Conformance/C15.9.0.1.CC Executable file → Normal file
View File

@ -1 +1,29 @@
/* Conformance Test 15.9.0.1: Verification of atof, atoi, atol functions */ #include <stdlib.h> main () { double d1; int i; long L; d1 = atof ("3.5e-22"); if (d1 != 3.5e-22) goto Fail; i = atoi ("-32765"); if (i != -32765) goto Fail; L = atol ("100000"); if (L != 100000) goto Fail; printf ("Passed Conformance Test 15.9.0.1\n"); return; Fail: printf ("Failed Conformance Test 15.9.0.1\n"); }
/* Conformance Test 15.9.0.1: Verification of atof, atoi, atol functions */
#include <stdlib.h>
main ()
{
double d1;
int i;
long L;
d1 = atof ("3.5e-22");
if (d1 != 3.5e-22)
goto Fail;
i = atoi ("-32765");
if (i != -32765)
goto Fail;
L = atol ("100000");
if (L != 100000)
goto Fail;
printf ("Passed Conformance Test 15.9.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 15.9.0.1\n");
}

69
Tests/Conformance/C16.1.0.1.CC Executable file → Normal file
View File

@ -1 +1,68 @@
/* Conformance Test 16.1.0.1: Verification of memchr, memcmp, memcpy, memmove */ /* library functions */ #include <stddef.h> #include <string.h> #include <stdlib.h> main () { int i; char *rgn, *ptr1; char string [] = "Here is a string to copy to the first region!!! "; rgn = (char *) malloc (512); /* allocate some memory for test */ if (rgn == NULL) goto Fail1; /* Copy the string into the allocated area. */ ptr1 = (char *) (memcpy (rgn, string, sizeof(string)+1)); if (strcmp(ptr1,string)) goto Fail; /* Ensure memmove works for overlapping regions. */ memmove (rgn+40, rgn, sizeof(string)+1); if (strcmp(string, rgn+40)) goto Fail; /* Test memchr by searching region for characters. */ ptr1 = (char *) memchr (string, 'n', 50); if (ptr1 != string+14) goto Fail; ptr1 = (char *) (memchr (string, 'Z', 88)); if (ptr1 != NULL) goto Fail; /* Verify that the region has the correct characters. */ i = memcmp ( (char *) (rgn), (char *) (rgn + 40), 39); if (i) goto Fail; i = memcmp ( string, "Here is a string", 17); if (i <= 0) goto Fail; free (rgn); printf ("Passed Conformance Test 16.1.0.1\n"); return; Fail: printf ("Failed Conformance Test 16.1.0.1\n"); return; Fail1: printf ("Unable to allocate memory for Conformance Test 16.1.0.1\n"); return; }
/* Conformance Test 16.1.0.1: Verification of memchr, memcmp, memcpy, memmove */
/* library functions */
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
main ()
{
int i;
char *rgn, *ptr1;
char string [] = "Here is a string to copy to the first region!!! ";
rgn = (char *) malloc (512); /* allocate some memory for test */
if (rgn == NULL)
goto Fail1;
/* Copy the string into the allocated area. */
ptr1 = (char *) (memcpy (rgn, string, sizeof(string)+1));
if (strcmp(ptr1,string))
goto Fail;
/* Ensure memmove works for overlapping regions. */
memmove (rgn+40, rgn, sizeof(string)+1);
if (strcmp(string, rgn+40))
goto Fail;
/* Test memchr by searching region for characters. */
ptr1 = (char *) memchr (string, 'n', 50);
if (ptr1 != string+14)
goto Fail;
ptr1 = (char *) (memchr (string, 'Z', 88));
if (ptr1 != NULL)
goto Fail;
/* Verify that the region has the correct characters. */
i = memcmp ( (char *) (rgn), (char *) (rgn + 40), 39);
if (i)
goto Fail;
i = memcmp ( string, "Here is a string", 17);
if (i <= 0)
goto Fail;
free (rgn);
printf ("Passed Conformance Test 16.1.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 16.1.0.1\n");
return;
Fail1:
printf ("Unable to allocate memory for Conformance Test 16.1.0.1\n");
return;
}

37
Tests/Conformance/C16.4.0.1.CC Executable file → Normal file
View File

@ -1 +1,36 @@
/* Conformance Test 16.4.0.1: Verification of memset library function */ #include <stddef.h> #include <string.h> #include <stdlib.h> main () { char *rgn, *ptr1; rgn = (char *) malloc (1024); if (rgn == NULL) goto Fail1; ptr1 = (char *) memset (rgn, 'a', 1024); if (ptr1 != rgn) goto Fail; for (; rgn != ptr1; rgn++) if (*rgn != 'a') goto Fail; free (rgn); printf ("Passed Conformance Test 16.4.0.1\n"); return; Fail: printf ("Failed Conformance Test 16.4.0.1\n"); return; Fail1: printf ("Unable to allocate memory for Conformance Test 16.4.0.1\n"); return; }
/* Conformance Test 16.4.0.1: Verification of memset library function */
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
main ()
{
char *rgn, *ptr1;
rgn = (char *) malloc (1024);
if (rgn == NULL)
goto Fail1;
ptr1 = (char *) memset (rgn, 'a', 1024);
if (ptr1 != rgn)
goto Fail;
for (; rgn != ptr1; rgn++)
if (*rgn != 'a')
goto Fail;
free (rgn);
printf ("Passed Conformance Test 16.4.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 16.4.0.1\n");
return;
Fail1:
printf ("Unable to allocate memory for Conformance Test 16.4.0.1\n");
return;
}

74
Tests/Conformance/C17.10.0.1.CC Executable file → Normal file
View File

@ -1 +1,73 @@
/* Conformance Test 17.10.0.1: Verification of fputs and puts */ #include <stdio.h> main () { FILE *f1; int i,j; char string [255], *strPtr; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; /* Redirect standard output to a file */ stdout = freopen ("3/tmp2", "w+", stdout); if (stdout == NULL) goto Fail3; /* Write strings to output files. */ j = fputs ("this is the first string\n", f1); if (j) goto Fail; j = puts ("and this is the second string"); if (j) goto Fail; /* Check files' contents. */ rewind (f1); rewind (stdout); strPtr = fgets (string, 100, f1); if (strPtr != string) goto Fail; if (strcmp (string, "this is the first string\n")) goto Fail; strPtr = fgets (string, 100, stdout); if (strPtr != string) goto Fail; if (strcmp (string, "and this is the second string\n")) goto Fail; fclose(stdout); /* reset standard out */ i = fclose (f1); /* close the update file */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.10.0.1\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.10.0.1\n"); return; Fail1: fprintf (stderr, "Unable to open input file for Conformance Test 17.10.0.1\n"); return; Fail2: fprintf (stderr, "Unable to close input file for Conformance Test 17.10.0.1\n"); return; Fail3: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.10.0.1\n"); return; }
/* Conformance Test 17.10.0.1: Verification of fputs and puts */
#include <stdio.h>
main ()
{
FILE *f1;
int i,j;
char string [255], *strPtr;
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
/* Redirect standard output to a file */
stdout = freopen ("3/tmp2", "w+", stdout);
if (stdout == NULL)
goto Fail3;
/* Write strings to output files. */
j = fputs ("this is the first string\n", f1);
if (j)
goto Fail;
j = puts ("and this is the second string");
if (j)
goto Fail;
/* Check files' contents. */
rewind (f1);
rewind (stdout);
strPtr = fgets (string, 100, f1);
if (strPtr != string)
goto Fail;
if (strcmp (string, "this is the first string\n"))
goto Fail;
strPtr = fgets (string, 100, stdout);
if (strPtr != string)
goto Fail;
if (strcmp (string, "and this is the second string\n"))
goto Fail;
fclose(stdout); /* reset standard out */
i = fclose (f1); /* close the update file */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.10.0.1\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.10.0.1\n");
return;
Fail1:
fprintf (stderr, "Unable to open input file for Conformance Test 17.10.0.1\n");
return;
Fail2:
fprintf (stderr, "Unable to close input file for Conformance Test 17.10.0.1\n");
return;
Fail3:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.10.0.1\n");
return;
}

103
Tests/Conformance/C17.11.0.1.CC Executable file → Normal file
View File

@ -1 +1,102 @@
/* Conformance Test 17.11.0.1: Verification of fprintf, printf, sprintf: */ /* d, i format codes */ #include <string.h> #include <stdio.h> main () { FILE *f1; short i1; int i; int i2, i3; long L1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; i1 = 32767; i2 = 0; L1 = -32767; i3 = 8; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%55c", string); if (i != 1) goto Fail3; string [55] = '\0'; if (strcmp (string, " +000032767 000032767 -00032767\ -32767 M")) goto Fail; rewind (stdout); i = fscanf (stdout, "%55c", string); if (i != 1) goto Fail3; string [55] = '\0'; if (strcmp (string, " +000032767 000032767 -00032767\ -32767 M")) goto Fail; if (strcmp (sstring, " +000032767 000032767 -00032767\ -32767 M\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.1\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.1\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.1\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.1\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.1\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.1\n"); return; }
/* Conformance Test 17.11.0.1: Verification of fprintf, printf, sprintf: */
/* d, i format codes */
#include <string.h>
#include <stdio.h>
main ()
{
FILE *f1;
short i1;
int i;
int i2, i3;
long L1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
i1 = 32767;
i2 = 0;
L1 = -32767;
i3 = 8;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n",
i1, i3, i1, i2, L1, i3, L1);
if (i != 56)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%55c", string);
if (i != 1)
goto Fail3;
string [55] = '\0';
if (strcmp (string, " +000032767 000032767 -00032767\
-32767 M"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%55c", string);
if (i != 1)
goto Fail3;
string [55] = '\0';
if (strcmp (string, " +000032767 000032767 -00032767\
-32767 M"))
goto Fail;
if (strcmp (sstring, " +000032767 000032767 -00032767\
-32767 M\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.1\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.1\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.1\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.1\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.1\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.1\n");
return;
}

100
Tests/Conformance/C17.11.0.10.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.10: Verification of fprintf, printf, sprintf: */ /* g,G format codes */ #include <stdio.h> main () { FILE *f1; int i; int i1, i2, i3; float fl1; double d1; extended e1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */ if (stdout == NULL) goto Fail4; fl1 = 9.0; d1 = -123.456e-20; e1 = 9876543210.0; i1 = 15; i2 = 8; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1); if (i != 42) goto Fail; i = printf (" %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1); if (i != 42) goto Fail; i = sprintf (sstring, " %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1); if (i != 42) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%41c", string); if (i != 1) goto Fail3; string [41] = '\0'; if (strcmp (string, " +009. -0001.23456E-18 9876543210 G")) goto Fail; rewind (stdout); i = fscanf (stdout, "%41c", string); if (i != 1) goto Fail3; string [41] = '\0'; if (strcmp (string, " +009. -0001.23456E-18 9876543210 G")) goto Fail; if (strcmp (sstring, " +009. -0001.23456E-18 9876543210 G\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.10\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.10\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.10\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.10\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.10\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.10\n"); return; }
/* Conformance Test 17.11.0.10: Verification of fprintf, printf, sprintf: */
/* g,G format codes */
#include <stdio.h>
main ()
{
FILE *f1;
int i;
int i1, i2, i3;
float fl1;
double d1;
extended e1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */
if (stdout == NULL)
goto Fail4;
fl1 = 9.0;
d1 = -123.456e-20;
e1 = 9876543210.0;
i1 = 15;
i2 = 8;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1);
if (i != 42)
goto Fail;
i = printf (" %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1);
if (i != 42)
goto Fail;
i = sprintf (sstring, " %+0 #5.g %-0*.*G %13.10Lg G\n", fl1, i1, i2, d1, e1);
if (i != 42)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%41c", string);
if (i != 1)
goto Fail3;
string [41] = '\0';
if (strcmp (string, " +009. -0001.23456E-18 9876543210 G"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%41c", string);
if (i != 1)
goto Fail3;
string [41] = '\0';
if (strcmp (string, " +009. -0001.23456E-18 9876543210 G"))
goto Fail;
if (strcmp (sstring, " +009. -0001.23456E-18 9876543210 G\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.10\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.10\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.10\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.10\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.10\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.10\n");
return;
}

106
Tests/Conformance/C17.11.0.11.CC Executable file → Normal file
View File

@ -1 +1,105 @@
/* Conformance Test 17.11.0.11: Verification of fprintf, printf, sprintf: */ /* n and % format codes */ #include <stdio.h> main () { FILE *f1; int i, i1, i2; short sh; long l1; extended e1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */ if (stdout == NULL) goto Fail4; e1 = 123.456e-205; i1 = 6; i2 = 16; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, "%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1, "a string", &l1); if (i != 48) goto Fail; if ((sh != 3) || (l1 != 44)) /* check return values for n format */ goto Fail; i = printf ("%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1, "a string", &l1); if (i != 48) goto Fail; if ((sh != 3) || (l1 != 44)) /* check return values for n format */ goto Fail; i = sprintf (sstring, "%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1, "a string", &l1); if (i != 48) goto Fail; if ((sh != 3) || (l1 != 44)) /* check return values for n format */ goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%47c", string); if (i != 1) goto Fail3; string [47] = '\0'; if (strcmp (string, "% +1.2345599999999999e-203 a string % N")) goto Fail; rewind (stdout); i = fscanf (stdout, "%47c", string); if (i != 1) goto Fail3; string [47] = '\0'; if (strcmp (string, "% +1.2345599999999999e-203 a string % N")) goto Fail; if (strcmp (sstring, "% +1.2345599999999999e-203 a string % N\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.11\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.11\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.11\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.11\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.11\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.11\n"); return; }
/* Conformance Test 17.11.0.11: Verification of fprintf, printf, sprintf: */
/* n and % format codes */
#include <stdio.h>
main ()
{
FILE *f1;
int i, i1, i2;
short sh;
long l1;
extended e1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */
if (stdout == NULL)
goto Fail4;
e1 = 123.456e-205;
i1 = 6;
i2 = 16;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, "%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1,
"a string", &l1);
if (i != 48)
goto Fail;
if ((sh != 3) || (l1 != 44)) /* check return values for n format */
goto Fail;
i = printf ("%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1,
"a string", &l1);
if (i != 48)
goto Fail;
if ((sh != 3) || (l1 != 44)) /* check return values for n format */
goto Fail;
i = sprintf (sstring, "%% %hn %0+*.*le %s %% %ln N\n", &sh, i1, i2, e1,
"a string", &l1);
if (i != 48)
goto Fail;
if ((sh != 3) || (l1 != 44)) /* check return values for n format */
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%47c", string);
if (i != 1)
goto Fail3;
string [47] = '\0';
if (strcmp (string, "% +1.2345599999999999e-203 a string % N"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%47c", string);
if (i != 1)
goto Fail3;
string [47] = '\0';
if (strcmp (string, "% +1.2345599999999999e-203 a string % N"))
goto Fail;
if (strcmp (sstring, "% +1.2345599999999999e-203 a string % N\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.11\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.11\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.11\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.11\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.11\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.11\n");
return;
}

104
Tests/Conformance/C17.11.0.2.CC Executable file → Normal file
View File

@ -1 +1,103 @@
/* Conformance Test 17.11.0.2: Verification of fprintf, sprintf, printf: */ /* u format code */ #include <stdio.h> main () { FILE *f1; int i, i1, i2; unsigned int ui1, ui2; unsigned long ul1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; ui1 = 65535; ui2 = 0; ul1 = 4294967295u; i1 = 12; i2 = 16; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; i = printf (" %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; i = sprintf (sstring, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%44c", string); if (i != 1) goto Fail3; string [44] = '\0'; i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (strcmp (string, " 0000065535 +065535 0000004294967295 A")) goto Fail; rewind (stdout); i = fscanf (stdout, "%44c", string); if (i != 1) goto Fail3; string [44] = '\0'; if (strcmp (string, " 0000065535 +065535 0000004294967295 A")) goto Fail; if (strcmp (sstring, " 0000065535 +065535 0000004294967295 A\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.2\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.2\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.2\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.2\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.2\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.2\n"); return; }
/* Conformance Test 17.11.0.2: Verification of fprintf, sprintf, printf: */
/* u format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i, i1, i2;
unsigned int ui1, ui2;
unsigned long ul1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
ui1 = 65535;
ui2 = 0;
ul1 = 4294967295u;
i1 = 12;
i2 = 16;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = printf (" %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = sprintf (sstring, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%44c", string);
if (i != 1)
goto Fail3;
string [44] = '\0';
i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n",
ui1, (long) ui1, ui2, i1, i2, ul1);
if (strcmp (string, " 0000065535 +065535 0000004294967295 A"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%44c", string);
if (i != 1)
goto Fail3;
string [44] = '\0';
if (strcmp (string, " 0000065535 +065535 0000004294967295 A"))
goto Fail;
if (strcmp (sstring, " 0000065535 +065535 0000004294967295 A\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.2\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.2\n");
return;
Fail1:
fprintf (stderr,
"Unable to open output file for Conformance Test 17.11.0.2\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.2\n");
return;
Fail3:
fprintf (stderr,
"Unable to read output file for Conformance Test 17.11.0.2\n");
return;
Fail4:
fprintf (stderr,
"Unable to redirect stdout for Conformance Test 17.11.0.2\n");
return;
}

100
Tests/Conformance/C17.11.0.3.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.3: Verification of fprintf, printf, sprintf: */ /* o format code */ #include <stdio.h> main () { FILE *f1; int i, i1, i2; unsigned int ui1, ui2; unsigned long ul1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; ui1 = 65535; ui2 = 0; ul1 = 4294967295u; i1 = 6; i2 = 9; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %-+ #10.5ho %#0*.*o %o %-12lo B\n", ui1, i1, i2, ui1, ui2, ul1); if (i != 43) goto Fail; i = printf (" %-+ #10.5ho %#0*.*o %o %-12lo B\n", ui1, i1, i2, ui1, ui2, ul1); if (i != 43) goto Fail; i = sprintf (sstring, " %-+ #10.5ho %#0*.*o %o %-12lo B\n", ui1, i1, i2, ui1, ui2, ul1); if (i != 43) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%42c", string); if (i != 1) goto Fail3; string [42] = '\0'; if (strcmp (string, " 0177777 000177777 0 37777777777 B")) goto Fail; rewind (stdout); i = fscanf (stdout, "%42c", string); if (i != 1) goto Fail3; string [42] = '\0'; if (strcmp (string, " 0177777 000177777 0 37777777777 B")) goto Fail; if (strcmp (sstring, " 0177777 000177777 0 37777777777 B\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.3\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.3\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.3\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.3\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.3\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.3\n"); return; }
/* Conformance Test 17.11.0.3: Verification of fprintf, printf, sprintf: */
/* o format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i, i1, i2;
unsigned int ui1, ui2;
unsigned long ul1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
ui1 = 65535;
ui2 = 0;
ul1 = 4294967295u;
i1 = 6;
i2 = 9;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %-+ #10.5ho %#0*.*o %o %-12lo B\n",
ui1, i1, i2, ui1, ui2, ul1);
if (i != 43)
goto Fail;
i = printf (" %-+ #10.5ho %#0*.*o %o %-12lo B\n",
ui1, i1, i2, ui1, ui2, ul1);
if (i != 43)
goto Fail;
i = sprintf (sstring, " %-+ #10.5ho %#0*.*o %o %-12lo B\n",
ui1, i1, i2, ui1, ui2, ul1);
if (i != 43)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%42c", string);
if (i != 1)
goto Fail3;
string [42] = '\0';
if (strcmp (string, " 0177777 000177777 0 37777777777 B"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%42c", string);
if (i != 1)
goto Fail3;
string [42] = '\0';
if (strcmp (string, " 0177777 000177777 0 37777777777 B"))
goto Fail;
if (strcmp (sstring, " 0177777 000177777 0 37777777777 B\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.3\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.3\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.3\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.3\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.3\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.3\n");
return;
}

100
Tests/Conformance/C17.11.0.4.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.4: Verification of fprintf, printf, sprintf: */ /* x,X format codes */ #include <stdio.h> main () { FILE *f1; int i, i1, i2; unsigned int ui1, ui2; unsigned long ul1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; ui1 = 65535u; ui2 = 0; ul1 = 4294967295u; i1 = 12; i2 = 10; /* Write formatted output as string to the output file. */ i = fprintf (f1, " %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n", ui1, ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; i = printf (" %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n", ui1, ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; i = sprintf (sstring, " %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n", ui1, ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%44c", string); if (i != 1) goto Fail3; string [44] = '\0'; if (strcmp (string, " 0x000000ffff 0X0000FFFF 00ffffffff C")) goto Fail; rewind (stdout); i = fscanf (stdout, "%44c", string); if (i != 1) goto Fail3; string [44] = '\0'; if (strcmp (string, " 0x000000ffff 0X0000FFFF 00ffffffff C")) goto Fail; if (strcmp (sstring, " 0x000000ffff 0X0000FFFF 00ffffffff C\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.4\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.4\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.4\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.4\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.4\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.4\n"); return; }
/* Conformance Test 17.11.0.4: Verification of fprintf, printf, sprintf: */
/* x,X format codes */
#include <stdio.h>
main ()
{
FILE *f1;
int i, i1, i2;
unsigned int ui1, ui2;
unsigned long ul1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
ui1 = 65535u;
ui2 = 0;
ul1 = 4294967295u;
i1 = 12;
i2 = 10;
/* Write formatted output as string to the output file. */
i = fprintf (f1, " %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n",
ui1, ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = printf (" %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n",
ui1, ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
i = sprintf (sstring, " %#+ -10.10x %#+ 09.8X %.0x %+ *.*lx C\n",
ui1, ui1, ui2, i1, i2, ul1);
if (i != 45)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%44c", string);
if (i != 1)
goto Fail3;
string [44] = '\0';
if (strcmp (string, " 0x000000ffff 0X0000FFFF 00ffffffff C"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%44c", string);
if (i != 1)
goto Fail3;
string [44] = '\0';
if (strcmp (string, " 0x000000ffff 0X0000FFFF 00ffffffff C"))
goto Fail;
if (strcmp (sstring, " 0x000000ffff 0X0000FFFF 00ffffffff C\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.4\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.4\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.4\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.4\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.4\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.4\n");
return;
}

98
Tests/Conformance/C17.11.0.5.CC Executable file → Normal file
View File

@ -1 +1,97 @@
/* Conformance Test 17.11.0.5: Verification of fprintf, printf, sprintf: */ /* c format code */ #include <stdio.h> main () { FILE *f1; int i, i1, i2; unsigned int ui1, ui2; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; ui1 = 'a'; ui2 = 'b'; i1 = 3; i2 = 2; /* Write formatted output as string to the output file. */ i = fprintf (f1, " %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n", ui1, ui1, ui2, i1, i2, 'd'); if (i != 30) goto Fail; i = printf (" %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n", ui1, ui1, ui2, i1, i2, 'd'); if (i != 30) goto Fail; i = sprintf (sstring, " %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n", ui1, ui1, ui2, i1, i2, 'd'); if (i != 30) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%29c", string); if (i != 1) goto Fail3; string [29] = '\0'; if (strcmp (string, " a a b d D")) goto Fail; rewind (stdout); i = fscanf (stdout, "%29c", string); if (i != 1) goto Fail3; string [29] = '\0'; if (strcmp (string, " a a b d D")) goto Fail; if (strcmp (sstring, " a a b d D\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.5\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.5\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.5\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.5\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.5\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.5\n"); return; }
/* Conformance Test 17.11.0.5: Verification of fprintf, printf, sprintf: */
/* c format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i, i1, i2;
unsigned int ui1, ui2;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
ui1 = 'a';
ui2 = 'b';
i1 = 3;
i2 = 2;
/* Write formatted output as string to the output file. */
i = fprintf (f1, " %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n",
ui1, ui1, ui2, i1, i2, 'd');
if (i != 30)
goto Fail;
i = printf (" %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n",
ui1, ui1, ui2, i1, i2, 'd');
if (i != 30)
goto Fail;
i = sprintf (sstring, " %#+ -010.10c %05.7hc %.6lc %+ *.*lc D\n",
ui1, ui1, ui2, i1, i2, 'd');
if (i != 30)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%29c", string);
if (i != 1)
goto Fail3;
string [29] = '\0';
if (strcmp (string, " a a b d D"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%29c", string);
if (i != 1)
goto Fail3;
string [29] = '\0';
if (strcmp (string, " a a b d D"))
goto Fail;
if (strcmp (sstring, " a a b d D\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.5\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.5\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.5\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.5\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.5\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.5\n");
return;
}

100
Tests/Conformance/C17.11.0.6.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.6: Verification of fprintf, printf, sprintf: */ /* s format code */ #include <stdio.h> main () { FILE *f1; int i, j, k; char sstring [80]; char string [80], arg1 [] = "first string argument", arg2 [] = "second string argument "; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */ if (stdout == NULL) goto Fail4; j = 15; k = 30; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %#+ -10.10s %015.7hs %*.*s %s E\n", arg1, arg1, j, k, arg2, "very short string"); if (i != 77) goto Fail; i = printf (" %#+ -10.10s %015.7hs %*.*s %s E\n", arg1, arg1, j, k, arg2, "very short string"); if (i != 77) goto Fail; i = sprintf (sstring, " %#+ -10.10s %015.7hs %*.*s %s E\n", arg1, arg1, j, k, arg2, "very short string"); if (i != 77) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%76c", string); if (i != 1) goto Fail3; string [76] = '\0'; if (strcmp (string, " first stri first s second string argument \ very short string E")) goto Fail; rewind (stdout); i = fscanf (stdout, "%76c", string); if (i != 1) goto Fail3; string [76] = '\0'; if (strcmp (string, " first stri first s second string argument \ very short string E")) goto Fail; if (strcmp (sstring, " first stri first s second string argument \ very short string E\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.6\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.6\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.6\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.6\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.6\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.6\n"); return; }
/* Conformance Test 17.11.0.6: Verification of fprintf, printf, sprintf: */
/* s format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i, j, k;
char sstring [80];
char string [80], arg1 [] = "first string argument",
arg2 [] = "second string argument ";
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to a file */
if (stdout == NULL)
goto Fail4;
j = 15;
k = 30;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %#+ -10.10s %015.7hs %*.*s %s E\n",
arg1, arg1, j, k, arg2, "very short string");
if (i != 77)
goto Fail;
i = printf (" %#+ -10.10s %015.7hs %*.*s %s E\n",
arg1, arg1, j, k, arg2, "very short string");
if (i != 77)
goto Fail;
i = sprintf (sstring, " %#+ -10.10s %015.7hs %*.*s %s E\n",
arg1, arg1, j, k, arg2, "very short string");
if (i != 77)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%76c", string);
if (i != 1)
goto Fail3;
string [76] = '\0';
if (strcmp (string, " first stri first s second string argument \
very short string E"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%76c", string);
if (i != 1)
goto Fail3;
string [76] = '\0';
if (strcmp (string, " first stri first s second string argument \
very short string E"))
goto Fail;
if (strcmp (sstring, " first stri first s second string argument \
very short string E\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.6\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.6\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.6\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.6\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.6\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.6\n");
return;
}

100
Tests/Conformance/C17.11.0.7.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.7: Verification of fprintf, printf, sprintf: */ /* p format code */ #include <stdio.h> main () { FILE *f1; int i, j, k; char sstring [80]; char string [80], arg1 [] = "\pfirst string argument", arg2 [] = "\psecond string argument "; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */ if (stdout == NULL) goto Fail4; j = 15; k = 30; /* Write formatted output as string to the output file. */ i = fprintf (f1, " %#+ -10.10b %015.7hb %*.*b %b E\n", arg1, arg1, j, k, arg2, "\pvery short string"); if (i != 77) goto Fail; i = printf (" %#+ -10.10b %015.7hb %*.*b %b E\n", arg1, arg1, j, k, arg2, "\pvery short string"); if (i != 77) goto Fail; i = sprintf (sstring, " %#+ -10.10b %015.7hb %*.*b %b E\n", arg1, arg1, j, k, arg2, "\pvery short string"); if (i != 77) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%76c", string); if (i != 1) goto Fail3; string [76] = '\0'; if (strcmp (string, " first stri first s second string argument \ very short string E")) goto Fail; rewind (stdout); i = fscanf (stdout, "%76c", string); if (i != 1) goto Fail3; string [76] = '\0'; if (strcmp (string, " first stri first s second string argument \ very short string E")) goto Fail; if (strcmp (sstring, " first stri first s second string argument \ very short string E\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.7\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.7\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.7\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.7\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.7\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.7\n"); return; }
/* Conformance Test 17.11.0.7: Verification of fprintf, printf, sprintf: */
/* p format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i, j, k;
char sstring [80];
char string [80], arg1 [] = "\pfirst string argument",
arg2 [] = "\psecond string argument ";
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */
if (stdout == NULL)
goto Fail4;
j = 15;
k = 30;
/* Write formatted output as string to the output file. */
i = fprintf (f1, " %#+ -10.10b %015.7hb %*.*b %b E\n",
arg1, arg1, j, k, arg2, "\pvery short string");
if (i != 77)
goto Fail;
i = printf (" %#+ -10.10b %015.7hb %*.*b %b E\n",
arg1, arg1, j, k, arg2, "\pvery short string");
if (i != 77)
goto Fail;
i = sprintf (sstring, " %#+ -10.10b %015.7hb %*.*b %b E\n",
arg1, arg1, j, k, arg2, "\pvery short string");
if (i != 77)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%76c", string);
if (i != 1)
goto Fail3;
string [76] = '\0';
if (strcmp (string, " first stri first s second string argument \
very short string E"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%76c", string);
if (i != 1)
goto Fail3;
string [76] = '\0';
if (strcmp (string, " first stri first s second string argument \
very short string E"))
goto Fail;
if (strcmp (sstring, " first stri first s second string argument \
very short string E\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.7\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.7\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.7\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.7\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.7\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.7\n");
return;
}

98
Tests/Conformance/C17.11.0.8.CC Executable file → Normal file
View File

@ -1 +1,97 @@
/* Conformance Test 17.11.0.8: Verification of fprintf, printf, sprintf: */ /* f format code */ #include <stdio.h> main () { FILE *f1; int i; int i2, i3; float fl1; double d1; extended e1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */ if (stdout == NULL) goto Fail4; fl1 = 45.0; d1 = 123.456e-2; e1 = 99.999; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1); if (i != 40) goto Fail; i = printf (" %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1); if (i != 40) goto Fail; i = sprintf (sstring, " %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1); if (i != 40) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%39c", string); if (i != 1) goto Fail3; string [39] = '\0'; if (strcmp (string, " +001.2345600 +45 099.999000 T")) goto Fail; rewind (stdout); i = fscanf (stdout, "%39c", string); if (i != 1) goto Fail3; string [39] = '\0'; if (strcmp (string, " +001.2345600 +45 099.999000 T")) goto Fail; if (strcmp (sstring, " +001.2345600 +45 099.999000 T\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.8\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.8\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.8\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.8\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.8\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.8\n"); return; }
/* Conformance Test 17.11.0.8: Verification of fprintf, printf, sprintf: */
/* f format code */
#include <stdio.h>
main ()
{
FILE *f1;
int i;
int i2, i3;
float fl1;
double d1;
extended e1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */
if (stdout == NULL)
goto Fail4;
fl1 = 45.0;
d1 = 123.456e-2;
e1 = 99.999;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1);
if (i != 40)
goto Fail;
i = printf (" %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1);
if (i != 40)
goto Fail;
i = sprintf (sstring, " %# +012.7f %+-8.f %# 011lf T\n", d1, fl1, e1);
if (i != 40)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%39c", string);
if (i != 1)
goto Fail3;
string [39] = '\0';
if (strcmp (string, " +001.2345600 +45 099.999000 T"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%39c", string);
if (i != 1)
goto Fail3;
string [39] = '\0';
if (strcmp (string, " +001.2345600 +45 099.999000 T"))
goto Fail;
if (strcmp (sstring, " +001.2345600 +45 099.999000 T\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.8\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.8\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.8\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.8\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.8\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.8\n");
return;
}

100
Tests/Conformance/C17.11.0.9.CC Executable file → Normal file
View File

@ -1 +1,99 @@
/* Conformance Test 17.11.0.9: Verification of fprintf, printf, sprintf: */ /* e, E format codes */ #include <stdio.h> main () { FILE *f1; int i; int i1, i2, i3; float fl1; double d1; extended e1; char string [80], sstring [80]; f1 = fopen ("3/tmp", "w+"); /* open output file for test */ if (f1 == NULL) goto Fail1; stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */ if (stdout == NULL) goto Fail4; fl1 = 5.0; d1 = -4.7; e1 = 123.456e-205; i1 = 6; i2 = 16; /* Write formatted output as string to the output files and sstring. */ i = fprintf (f1, " %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1); if (i != 54) goto Fail; i = printf (" %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1); if (i != 54) goto Fail; i = sprintf (sstring, " %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1); if (i != 54) goto Fail; /* Check the string written. */ rewind (f1); i = fscanf (f1, "%53c", string); if (i != 1) goto Fail3; string [53] = '\0'; if (strcmp (string, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E")) goto Fail; rewind (stdout); i = fscanf (stdout, "%53c", string); if (i != 1) goto Fail3; string [53] = '\0'; if (strcmp (string, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E")) goto Fail; if (strcmp (sstring, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E\n")) goto Fail; fclose(stdout); /* redirect stdout to screen */ i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.11.0.9\n"); return; Fail: fprintf (stderr, "Failed Conformance Test 17.11.0.9\n"); return; Fail1: fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.9\n"); return; Fail2: fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.9\n"); return; Fail3: fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.9\n"); return; Fail4: fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.9\n"); return; }
/* Conformance Test 17.11.0.9: Verification of fprintf, printf, sprintf: */
/* e, E format codes */
#include <stdio.h>
main ()
{
FILE *f1;
int i;
int i1, i2, i3;
float fl1;
double d1;
extended e1;
char string [80], sstring [80];
f1 = fopen ("3/tmp", "w+"); /* open output file for test */
if (f1 == NULL)
goto Fail1;
stdout = freopen ("3/tmp2", "w+", stdout); /* redirect stdout to file */
if (stdout == NULL)
goto Fail4;
fl1 = 5.0;
d1 = -4.7;
e1 = 123.456e-205;
i1 = 6;
i2 = 16;
/* Write formatted output as string to the output files and sstring. */
i = fprintf (f1, " %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1);
if (i != 54)
goto Fail;
i = printf (" %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1);
if (i != 54)
goto Fail;
i = sprintf (sstring, " %0+*.*le %- 15E %#0 .e E\n", i1, i2, e1, d1, fl1);
if (i != 54)
goto Fail;
/* Check the string written. */
rewind (f1);
i = fscanf (f1, "%53c", string);
if (i != 1)
goto Fail3;
string [53] = '\0';
if (strcmp (string, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E"))
goto Fail;
rewind (stdout);
i = fscanf (stdout, "%53c", string);
if (i != 1)
goto Fail3;
string [53] = '\0';
if (strcmp (string, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E"))
goto Fail;
if (strcmp (sstring, " +1.2345599999999999e-203 -4.700000E+00 5e+00 E\n"))
goto Fail;
fclose(stdout); /* redirect stdout to screen */
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.11.0.9\n");
return;
Fail:
fprintf (stderr, "Failed Conformance Test 17.11.0.9\n");
return;
Fail1:
fprintf (stderr, "Unable to open output file for Conformance Test 17.11.0.9\n");
return;
Fail2:
fprintf (stderr, "Unable to close output file for Conformance Test 17.11.0.9\n");
return;
Fail3:
fprintf (stderr, "Unable to read output file for Conformance Test 17.11.0.9\n");
return;
Fail4:
fprintf (stderr, "Unable to redirect stdout for Conformance Test 17.11.0.9\n");
return;
}

78
Tests/Conformance/C17.13.0.1.CC Executable file → Normal file
View File

@ -1 +1,77 @@
/* Conformance Test 17.13.0.1: Verification of fread and fwrite */ #include <stdio.h> #include <math.h> struct S { int i; float f; char c; }; main () { struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' }; struct S buff [3]; FILE *f = fopen ("3/tmp", "w+b"); int i; /* Write the elements to the file. */ if (f == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f); if (i != 3) goto Fail; /* Read the elements from the file. */ rewind (f); i = fread ((void *) buff, sizeof (struct S), 3, f); if (i != 3) goto Fail; if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3)) goto Fail; if ((fabs(s [0].f - 1.0) > 0.00001) || (fabs(s [1].f - 2.0) > 0.00001) || (fabs(s [2].f - 3.0) > 0.00001)) goto Fail; if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c')) goto Fail; /* Ensure that a count or element_size of 0 causes no chars to be written. */ i = fwrite ((void *) s, sizeof (struct S), 0, f); if (i != 0) goto Fail; i = fwrite ((void *) s, 0, 2, f); if (i != 2) goto Fail; rewind (f); i = fread ((void *) s, sizeof (struct S), 0, f); if (i != 0) goto Fail; i = fread ((void *) s, 0, 2, f); if (i != 0) goto Fail; i = fclose (f); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.13.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.13.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.13.0.1\n"); return; Fail2: printf ("Unable to close output file for Conformance Test 17.13.0.1\n"); return; }
/* Conformance Test 17.13.0.1: Verification of fread and fwrite */
#include <stdio.h>
#include <math.h>
struct S { int i;
float f;
char c; };
main ()
{
struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' };
struct S buff [3];
FILE *f = fopen ("3/tmp", "w+b");
int i;
/* Write the elements to the file. */
if (f == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f);
if (i != 3)
goto Fail;
/* Read the elements from the file. */
rewind (f);
i = fread ((void *) buff, sizeof (struct S), 3, f);
if (i != 3)
goto Fail;
if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3))
goto Fail;
if ((fabs(s [0].f - 1.0) > 0.00001) || (fabs(s [1].f - 2.0) > 0.00001) ||
(fabs(s [2].f - 3.0) > 0.00001))
goto Fail;
if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c'))
goto Fail;
/* Ensure that a count or element_size of 0 causes no chars to be written. */
i = fwrite ((void *) s, sizeof (struct S), 0, f);
if (i != 0)
goto Fail;
i = fwrite ((void *) s, 0, 2, f);
if (i != 2)
goto Fail;
rewind (f);
i = fread ((void *) s, sizeof (struct S), 0, f);
if (i != 0)
goto Fail;
i = fread ((void *) s, 0, 2, f);
if (i != 0)
goto Fail;
i = fclose (f); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.13.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.13.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.13.0.1\n");
return;
Fail2:
printf ("Unable to close output file for Conformance Test 17.13.0.1\n");
return;
}

64
Tests/Conformance/C17.14.0.1.CC Executable file → Normal file
View File

@ -1 +1,63 @@
/* Conformance Test 17.14.0.1: Verification of ferror and clearerr */ #include <stdio.h> struct S { int i; float f; char c; }; main () { struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' }; struct S buff [3]; FILE *f = fopen ("3/tmp", "w+b"); int i; /* Write the elements to the file. */ if (f == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f); if (i != 3) goto Fail; /* Cause an error to occur. */ rewind (f); i = fread ((void *) buff, sizeof (struct S), 5, f); if (i != 3) goto Fail; i = ferror (f); if (i != 0) goto Fail; i = feof (f); if (i == 0) goto Fail; /* clear the error */ clearerr (f); i = feof (f); if (i != 0) goto Fail; i = fclose (f); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.14.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.14.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.14.0.1\n"); return; Fail2: printf ("Unable to close output file for Conformance Test 17.14.0.1\n"); return; }
/* Conformance Test 17.14.0.1: Verification of ferror and clearerr */
#include <stdio.h>
struct S { int i;
float f;
char c; };
main ()
{
struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' };
struct S buff [3];
FILE *f = fopen ("3/tmp", "w+b");
int i;
/* Write the elements to the file. */
if (f == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f);
if (i != 3)
goto Fail;
/* Cause an error to occur. */
rewind (f);
i = fread ((void *) buff, sizeof (struct S), 5, f);
if (i != 3)
goto Fail;
i = ferror (f);
if (i != 0)
goto Fail;
i = feof (f);
if (i == 0)
goto Fail;
/* clear the error */
clearerr (f);
i = feof (f);
if (i != 0)
goto Fail;
i = fclose (f); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.14.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.14.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.14.0.1\n");
return;
Fail2:
printf ("Unable to close output file for Conformance Test 17.14.0.1\n");
return;
}

55
Tests/Conformance/C17.15.0.1.CC Executable file → Normal file
View File

@ -1 +1,54 @@
/* Conformance Test 17.15.0.1: Verification of remove and rename */ #include <stdio.h> struct S { int i; float f; char c; }; main () { struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' }; struct S buff [3]; FILE *f = fopen ("3/tmp", "wb"); int i; /* Write the elements to the file. */ if (f == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f); if (i != 3) goto Fail; i = fclose (f); /* close the file */ if (i == EOF) goto Fail2; /* Rename and then delete the file. */ i = remove ("3/temp"); i = rename ("3/tmp", "3/temp"); if (i) goto Fail; i = remove ("3/temp"); if (i) goto Fail; printf ("Passed Conformance Test 17.15.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.15.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.15.0.1\n"); return; Fail2: printf ("Unable to close output file for Conformance Test 17.15.0.1\n"); return; }
/* Conformance Test 17.15.0.1: Verification of remove and rename */
#include <stdio.h>
struct S { int i;
float f;
char c; };
main ()
{
struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' };
struct S buff [3];
FILE *f = fopen ("3/tmp", "wb");
int i;
/* Write the elements to the file. */
if (f == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f);
if (i != 3)
goto Fail;
i = fclose (f); /* close the file */
if (i == EOF)
goto Fail2;
/* Rename and then delete the file. */
i = remove ("3/temp");
i = rename ("3/tmp", "3/temp");
if (i)
goto Fail;
i = remove ("3/temp");
if (i)
goto Fail;
printf ("Passed Conformance Test 17.15.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.15.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.15.0.1\n");
return;
Fail2:
printf ("Unable to close output file for Conformance Test 17.15.0.1\n");
return;
}

104
Tests/Conformance/C17.16.0.1.CC Executable file → Normal file
View File

@ -1 +1,103 @@
/* Conformance Test 17.16.0.1: Verification of tmpfile function */ #include <stdio.h> struct S { int i; float f; char c; }; main () { struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' }; struct S buff [3]; FILE *f1, *f2, *f3; int i; /* Create 3 temp files and write the elements to the files. */ f1 = tmpfile (); if (f1 == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f1); if (i != 3) goto Fail; f2 = tmpfile (); if (f2 == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f2); if (i != 3) goto Fail; f3 = tmpfile (); if (f3 == NULL) goto Fail1; i = fwrite ((void *) s, sizeof (struct S), 3, f3); if (i != 3) goto Fail; /* Read the elements from the files. */ rewind (f1); i = fread ((void *) buff, sizeof (struct S), 3, f1); if (i != 3) goto Fail; if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3)) goto Fail; if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0)) goto Fail; if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c')) goto Fail; rewind (f2); i = fread ((void *) buff, sizeof (struct S), 3, f2); if (i != 3) goto Fail; if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3)) goto Fail; if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0)) goto Fail; if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c')) goto Fail; rewind (f2); i = fread ((void *) buff, sizeof (struct S), 3, f2); if (i != 3) goto Fail; if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3)) goto Fail; if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0)) goto Fail; if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c')) goto Fail; i = fclose (f1); /* close the files and quit */ if (i == EOF) goto Fail2; i = fclose (f2); if (i == EOF) goto Fail2; i = fclose (f3); if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.16.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.16.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.16.0.1\n"); return; Fail2: printf ("Unable to close output file for Conformance Test 17.16.0.1\n"); return; }
/* Conformance Test 17.16.0.1: Verification of tmpfile function */
#include <stdio.h>
struct S { int i;
float f;
char c; };
main ()
{
struct S s [3] = { 1, 1.0, 'a', 2, 2.0, 'b', 3, 3.0, 'c' };
struct S buff [3];
FILE *f1, *f2, *f3;
int i;
/* Create 3 temp files and write the elements to the files. */
f1 = tmpfile ();
if (f1 == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f1);
if (i != 3)
goto Fail;
f2 = tmpfile ();
if (f2 == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f2);
if (i != 3)
goto Fail;
f3 = tmpfile ();
if (f3 == NULL)
goto Fail1;
i = fwrite ((void *) s, sizeof (struct S), 3, f3);
if (i != 3)
goto Fail;
/* Read the elements from the files. */
rewind (f1);
i = fread ((void *) buff, sizeof (struct S), 3, f1);
if (i != 3)
goto Fail;
if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3))
goto Fail;
if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0))
goto Fail;
if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c'))
goto Fail;
rewind (f2);
i = fread ((void *) buff, sizeof (struct S), 3, f2);
if (i != 3)
goto Fail;
if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3))
goto Fail;
if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0))
goto Fail;
if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c'))
goto Fail;
rewind (f2);
i = fread ((void *) buff, sizeof (struct S), 3, f2);
if (i != 3)
goto Fail;
if ((s [0].i != 1) || (s [1].i != 2) || (s [2].i != 3))
goto Fail;
if ((s [0].f != 1.0) || (s [1].f != 2.0) || (s [2].f != 3.0))
goto Fail;
if ((s [0].c != 'a') || (s [1].c != 'b') || (s [2].c != 'c'))
goto Fail;
i = fclose (f1); /* close the files and quit */
if (i == EOF)
goto Fail2;
i = fclose (f2);
if (i == EOF)
goto Fail2;
i = fclose (f3);
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.16.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.16.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.16.0.1\n");
return;
Fail2:
printf ("Unable to close output file for Conformance Test 17.16.0.1\n");
return;
}

113
Tests/Conformance/C17.5.0.1.CC Executable file → Normal file
View File

@ -1 +1,112 @@
/* Conformance Test 17.5.0.1: Verification of fseek function */ #include <stdio.h> main () { FILE *f1; /* file pointer */ int i, j, k, m; f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */ if (f1 == NULL) goto Fail1; for (i = 0; i < 100; i++) /* write 100 integers to the file */ { j = fprintf (f1, "%2d ", i); if (j == EOF) goto Fail2; } i = fseek (f1, 50, SEEK_END); /* extend file by extra 50 bytes */ if (i) goto Fail; rewind (f1); /* position at beginning of file */ i = 0; while ((j = fgetc (f1)) != EOF) i += 1; if (! (j = feof (f1)) ) goto Fail3; if (i != 450) /* check size of file in bytes */ goto Fail; /* Test seek from beginning of file. */ for (k = 0, i = 0; i < 100; i++) { j = fseek (f1, k, SEEK_SET); if (j) goto Fail; j = fscanf (f1, "%d", &m); if (j == EOF) goto Fail3; if (m != i) goto Fail; k += 4; } /* Test seek from end of file. */ j = fseek (f1, -54, SEEK_END); /* start 54 bytes from end of file */ if (j) goto Fail; for (k = -54, i = 99; i > 0; i--) { j = fscanf (f1, "%d", &m); if (j == EOF) goto Fail3; if (m != i) goto Fail; k -= 4; j = fseek (f1, k, SEEK_END); if (j) goto Fail; } /* Test seek from current position in file. */ j = fseek (f1, 12, SEEK_CUR); if (j) goto Fail; j = fscanf (f1, "%d", &m); if (j == EOF) goto Fail3; if (m != 3) goto Fail; j = fseek (f1, 12, SEEK_CUR); if (j) goto Fail; j = fscanf (f1, "%d", &m); if (j == EOF) goto Fail3; if (m != 7) goto Fail; /* Close the file and quit. */ j = fclose (f1); if (j == EOF) goto Fail4; printf ("Passed Conformance Test 17.5.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.5.0.1\n"); return; Fail1: printf ("Could not open tmp file for Conformance Test 17.5.0.1\n"); return; Fail2: printf ("Could not write to file for Conformance Test 17.5.0.1\n"); return; Fail3: printf ("Error while reading file for Conformance Test 17.5.0.1\n"); return; Fail4: printf ("Could not close file for Conformance Test 17.5.0.1\n"); return; }
/* Conformance Test 17.5.0.1: Verification of fseek function */
#include <stdio.h>
main ()
{
FILE *f1; /* file pointer */
int i, j, k, m;
f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */
if (f1 == NULL)
goto Fail1;
for (i = 0; i < 100; i++) /* write 100 integers to the file */
{
j = fprintf (f1, "%2d ", i);
if (j == EOF)
goto Fail2;
}
i = fseek (f1, 50, SEEK_END); /* extend file by extra 50 bytes */
if (i)
goto Fail;
rewind (f1); /* position at beginning of file */
i = 0;
while ((j = fgetc (f1)) != EOF)
i += 1;
if (! (j = feof (f1)) )
goto Fail3;
if (i != 450) /* check size of file in bytes */
goto Fail;
/* Test seek from beginning of file. */
for (k = 0, i = 0; i < 100; i++)
{
j = fseek (f1, k, SEEK_SET);
if (j)
goto Fail;
j = fscanf (f1, "%d", &m);
if (j == EOF)
goto Fail3;
if (m != i)
goto Fail;
k += 4;
}
/* Test seek from end of file. */
j = fseek (f1, -54, SEEK_END); /* start 54 bytes from end of file */
if (j)
goto Fail;
for (k = -54, i = 99; i > 0; i--)
{
j = fscanf (f1, "%d", &m);
if (j == EOF)
goto Fail3;
if (m != i)
goto Fail;
k -= 4;
j = fseek (f1, k, SEEK_END);
if (j)
goto Fail;
}
/* Test seek from current position in file. */
j = fseek (f1, 12, SEEK_CUR);
if (j)
goto Fail;
j = fscanf (f1, "%d", &m);
if (j == EOF)
goto Fail3;
if (m != 3)
goto Fail;
j = fseek (f1, 12, SEEK_CUR);
if (j)
goto Fail;
j = fscanf (f1, "%d", &m);
if (j == EOF)
goto Fail3;
if (m != 7)
goto Fail;
/* Close the file and quit. */
j = fclose (f1);
if (j == EOF)
goto Fail4;
printf ("Passed Conformance Test 17.5.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.5.0.1\n");
return;
Fail1:
printf ("Could not open tmp file for Conformance Test 17.5.0.1\n");
return;
Fail2:
printf ("Could not write to file for Conformance Test 17.5.0.1\n");
return;
Fail3:
printf ("Error while reading file for Conformance Test 17.5.0.1\n");
return;
Fail4:
printf ("Could not close file for Conformance Test 17.5.0.1\n");
return;
}

133
Tests/Conformance/C17.5.0.2.CC Executable file → Normal file
View File

@ -1 +1,132 @@
/* Conformance Test 17.5.0.2: Verification of fseek, rewind, and ftell */ /* functions for text files */ #include <stdio.h> main () { FILE *f1; /* file pointer */ int i, j, m; long L1; char s [254], ch1; char ch [254] = "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z." "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z." "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z." "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z." "A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V."; f1 = fopen ("14:tmp", "w+"); /* create temporary file to work on */ if (f1 == NULL) goto Fail1; for (i = 0; i < 100; i++) /* write 100 lines to the file */ { j = fprintf (f1, "%s\n", ch); if (j == EOF) goto Fail2; } /* Test seek from beginning of file. */ j = fseek (f1, 0L, SEEK_SET); if (j) goto Fail; for (i = 0; i < 100; i++) { j = fscanf (f1, "%s", s); if (j == EOF) goto Fail3; if (strcmp (s, ch)) goto Fail; } /* Test seek from end of file. */ j = fseek (f1, 0L, SEEK_END); if (j) goto Fail; j = fscanf (f1, "%c", &m); if (j != EOF) goto Fail3; /* Test ftell function. */ L1 = ftell (f1); if (L1 != 25300) goto Fail; rewind (f1); L1 = ftell (f1); if (L1 != 0) goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != 'a') goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != '.') goto Fail; L1 = ftell (f1); if (L1 != 2) goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != 'b') goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != '.') goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != 'c') goto Fail; j = fseek (f1, L1, SEEK_SET); /* verify that ftell-position works */ if (j) goto Fail; ch1 = fgetc (f1); if (ch1 == EOF) goto Fail3; if (ch1 != 'b') goto Fail; /* Close the file and quit. */ j = fclose (f1); if (j == EOF) goto Fail4; printf ("Passed Conformance Test 17.5.0.2\n"); return; Fail: printf ("Failed Conformance Test 17.5.0.2\n"); return; Fail1: printf ("Could not open tmp file for Conformance Test 17.5.0.2\n"); return; Fail2: printf ("Could not write to file for Conformance Test 17.5.0.2\n"); return; Fail3: printf ("Error while reading file for Conformance Test 17.5.0.2\n"); return; Fail4: printf ("Could not close file for Conformance Test 17.5.0.2\n"); return; }
/* Conformance Test 17.5.0.2: Verification of fseek, rewind, and ftell */
/* functions for text files */
#include <stdio.h>
main ()
{
FILE *f1; /* file pointer */
int i, j, m;
long L1;
char s [254], ch1;
char ch [254] = "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z."
"A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.";
f1 = fopen ("14:tmp", "w+"); /* create temporary file to work on */
if (f1 == NULL)
goto Fail1;
for (i = 0; i < 100; i++) /* write 100 lines to the file */
{
j = fprintf (f1, "%s\n", ch);
if (j == EOF)
goto Fail2;
}
/* Test seek from beginning of file. */
j = fseek (f1, 0L, SEEK_SET);
if (j)
goto Fail;
for (i = 0; i < 100; i++) {
j = fscanf (f1, "%s", s);
if (j == EOF)
goto Fail3;
if (strcmp (s, ch))
goto Fail;
}
/* Test seek from end of file. */
j = fseek (f1, 0L, SEEK_END);
if (j)
goto Fail;
j = fscanf (f1, "%c", &m);
if (j != EOF)
goto Fail3;
/* Test ftell function. */
L1 = ftell (f1);
if (L1 != 25300)
goto Fail;
rewind (f1);
L1 = ftell (f1);
if (L1 != 0)
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != 'a')
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != '.')
goto Fail;
L1 = ftell (f1);
if (L1 != 2)
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != 'b')
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != '.')
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != 'c')
goto Fail;
j = fseek (f1, L1, SEEK_SET); /* verify that ftell-position works */
if (j)
goto Fail;
ch1 = fgetc (f1);
if (ch1 == EOF)
goto Fail3;
if (ch1 != 'b')
goto Fail;
/* Close the file and quit. */
j = fclose (f1);
if (j == EOF)
goto Fail4;
printf ("Passed Conformance Test 17.5.0.2\n");
return;
Fail:
printf ("Failed Conformance Test 17.5.0.2\n");
return;
Fail1:
printf ("Could not open tmp file for Conformance Test 17.5.0.2\n");
return;
Fail2:
printf ("Could not write to file for Conformance Test 17.5.0.2\n");
return;
Fail3:
printf ("Error while reading file for Conformance Test 17.5.0.2\n");
return;
Fail4:
printf ("Could not close file for Conformance Test 17.5.0.2\n");
return;
}

109
Tests/Conformance/C17.6.0.1.CC Executable file → Normal file
View File

@ -1 +1,108 @@
/* Conformance Test 17.6.0.1: Verification of fgetc, getc, and ungetc with */ /* a text stream */ #include <stdio.h> main () { FILE *f1; int i, j; char ch; f1 = fopen ("3/tmp", "w+"); /* create text file to work on */ if (f1 == NULL) goto Fail1; for (ch = 'a', i = 0; i < 26; i++) { j = fputc (ch, f1); if ((char) j != ch) goto Fail2; ch++; } j = fputc ('\r', f1); /* text files end with return */ if (j != '\r') goto Fail2; rewind (f1); /* check file contents with fgetc */ for (ch = 'a', i = 0; i < 26; i++) { j = fgetc (f1); if ( (char) j != ch++ ) goto Fail; } i = ungetc ('F', f1); /* test ungetc */ if (i != 'F') goto Fail; i = fgetc (f1); if (i != 'F') goto Fail; i = fgetc (f1); if (i != '\n') goto Fail; i = fgetc (f1); if (! (feof (f1)) ) /* ensure end-of-file reached */ goto Fail; j = ungetc (i, f1); /* not an error to try to push */ if (j != EOF) /* back EOF */ goto Fail; j = fseek (f1, 0L, SEEK_SET); /* test getc with temp file */ if (j) goto Fail3; j = ungetc (i, f1); /* ungetc should return an error */ if (j != EOF) /* after seeking on the file */ goto Fail; /* before reading */ for (ch = 'a', i = 0; i < 26; i++) { j = getc (f1); if ( (char) j != ch++ ) goto Fail; } i = ungetc ('L', f1); /* test ungetc */ if (i != 'L') goto Fail; i = fgetc (f1); if (i != 'L') goto Fail; i = getc (f1); if (i != '\n') goto Fail; i = getc (f1); if (! (feof (f1)) ) /* ensure end-of-file reached */ goto Fail; j = ungetc (i, f1); /* not an error to try to push */ if (j != EOF) /* back EOF */ goto Fail; i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail4; printf ("Passed Conformance Test 17.6.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.6.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.6.0.1\n"); return; Fail2: printf ("Unable to write to temp file for Conformance Test 17.6.0.1\n"); return; Fail3: printf ("Unable to seek to temp file for Conformance Test 17.6.0.1\n"); return; Fail4: printf ("Unable to close temp file for Conformance Test 17.6.0.1\n"); return; }
/* Conformance Test 17.6.0.1: Verification of fgetc, getc, and ungetc with */
/* a text stream */
#include <stdio.h>
main ()
{
FILE *f1;
int i, j;
char ch;
f1 = fopen ("3/tmp", "w+"); /* create text file to work on */
if (f1 == NULL)
goto Fail1;
for (ch = 'a', i = 0; i < 26; i++)
{
j = fputc (ch, f1);
if ((char) j != ch)
goto Fail2;
ch++;
}
j = fputc ('\r', f1); /* text files end with return */
if (j != '\r')
goto Fail2;
rewind (f1); /* check file contents with fgetc */
for (ch = 'a', i = 0; i < 26; i++)
{
j = fgetc (f1);
if ( (char) j != ch++ )
goto Fail;
}
i = ungetc ('F', f1); /* test ungetc */
if (i != 'F')
goto Fail;
i = fgetc (f1);
if (i != 'F')
goto Fail;
i = fgetc (f1);
if (i != '\n')
goto Fail;
i = fgetc (f1);
if (! (feof (f1)) ) /* ensure end-of-file reached */
goto Fail;
j = ungetc (i, f1); /* not an error to try to push */
if (j != EOF) /* back EOF */
goto Fail;
j = fseek (f1, 0L, SEEK_SET); /* test getc with temp file */
if (j)
goto Fail3;
j = ungetc (i, f1); /* ungetc should return an error */
if (j != EOF) /* after seeking on the file */
goto Fail; /* before reading */
for (ch = 'a', i = 0; i < 26; i++)
{
j = getc (f1);
if ( (char) j != ch++ )
goto Fail;
}
i = ungetc ('L', f1); /* test ungetc */
if (i != 'L')
goto Fail;
i = fgetc (f1);
if (i != 'L')
goto Fail;
i = getc (f1);
if (i != '\n')
goto Fail;
i = getc (f1);
if (! (feof (f1)) ) /* ensure end-of-file reached */
goto Fail;
j = ungetc (i, f1); /* not an error to try to push */
if (j != EOF) /* back EOF */
goto Fail;
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail4;
printf ("Passed Conformance Test 17.6.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.6.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.6.0.1\n");
return;
Fail2:
printf ("Unable to write to temp file for Conformance Test 17.6.0.1\n");
return;
Fail3:
printf ("Unable to seek to temp file for Conformance Test 17.6.0.1\n");
return;
Fail4:
printf ("Unable to close temp file for Conformance Test 17.6.0.1\n");
return;
}

78
Tests/Conformance/C17.6.0.2.CC Executable file → Normal file
View File

@ -1 +1,77 @@
/* Conformance Test 17.6.0.2: Verification of fgetc, getc, and ungetc with */ /* a binary stream */ #include <stdio.h> main () { FILE *f1; int i, j; char ch; f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */ if (f1 == NULL) goto Fail1; for (ch = 'a', i = 0; i < 26; i++) { j = fputc (ch, f1); if ((char) j != ch) goto Fail2; ch++; } rewind (f1); /* check file contents with fgetc */ ch = 'a'; while ((i = fgetc (f1)) != EOF) if ( (char) i != ch++ ) goto Fail; if (! (feof (f1)) ) /* ensure end-of-file reached */ goto Fail; j = ungetc (i, f1); /* not an error to try to push */ if (j != EOF) /* back EOF */ goto Fail; j = fseek (f1, 0L, SEEK_SET); /* test getc with temp file */ if (j) goto Fail3; j = ungetc (i, f1); /* ungetc should return an error */ if (j != EOF) /* after seeking on the file */ goto Fail; /* before reading */ ch = 'a'; while ((i = getc (f1)) != EOF) if ( (char) i != ch++ ) goto Fail; if (! (feof (f1)) ) /* ensure end-of-file reached */ goto Fail; j = ungetc (i, f1); /* not an error to try to push */ if (j != EOF) /* back EOF */ goto Fail; i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail4; printf ("Passed Conformance Test 17.6.0.2\n"); return; Fail: printf ("Failed Conformance Test 17.6.0.2\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.6.0.2\n"); return; Fail2: printf ("Unable to write to temp file for Conformance Test 17.6.0.2\n"); return; Fail3: printf ("Unable to seek to temp file for Conformance Test 17.6.0.2\n"); return; Fail4: printf ("Unable to close temp file for Conformance Test 17.6.0.2\n"); return; }
/* Conformance Test 17.6.0.2: Verification of fgetc, getc, and ungetc with */
/* a binary stream */
#include <stdio.h>
main ()
{
FILE *f1;
int i, j;
char ch;
f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */
if (f1 == NULL)
goto Fail1;
for (ch = 'a', i = 0; i < 26; i++)
{
j = fputc (ch, f1);
if ((char) j != ch)
goto Fail2;
ch++;
}
rewind (f1); /* check file contents with fgetc */
ch = 'a';
while ((i = fgetc (f1)) != EOF)
if ( (char) i != ch++ )
goto Fail;
if (! (feof (f1)) ) /* ensure end-of-file reached */
goto Fail;
j = ungetc (i, f1); /* not an error to try to push */
if (j != EOF) /* back EOF */
goto Fail;
j = fseek (f1, 0L, SEEK_SET); /* test getc with temp file */
if (j)
goto Fail3;
j = ungetc (i, f1); /* ungetc should return an error */
if (j != EOF) /* after seeking on the file */
goto Fail; /* before reading */
ch = 'a';
while ((i = getc (f1)) != EOF)
if ( (char) i != ch++ )
goto Fail;
if (! (feof (f1)) ) /* ensure end-of-file reached */
goto Fail;
j = ungetc (i, f1); /* not an error to try to push */
if (j != EOF) /* back EOF */
goto Fail;
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail4;
printf ("Passed Conformance Test 17.6.0.2\n");
return;
Fail:
printf ("Failed Conformance Test 17.6.0.2\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.6.0.2\n");
return;
Fail2:
printf ("Unable to write to temp file for Conformance Test 17.6.0.2\n");
return;
Fail3:
printf ("Unable to seek to temp file for Conformance Test 17.6.0.2\n");
return;
Fail4:
printf ("Unable to close temp file for Conformance Test 17.6.0.2\n");
return;
}

81
Tests/Conformance/C17.7.0.1.CC Executable file → Normal file
View File

@ -1 +1,80 @@
/* Conformance Test 17.7.0.1: Verification of fgets function, text stream */ #include <stdio.h> main () { FILE *f1; int i; char string [80] = ""; /* initialize input string to null string */ char *strPtr; f1 = fopen ("3/tmp", "w+"); /* create text file to work on */ if (f1 == NULL) goto Fail1; i = fputs ("Every good boy deserves favor\n", f1); if (i) goto Fail2; rewind (f1); /* test reading until '\n' seen */ strPtr = fgets (string, 100, f1); if (strPtr == NULL) goto Fail; if (strcmp ("Every good boy deserves favor\n", string)) goto Fail; fgetc(f1); /* force an EOF condition */ strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */ if (strPtr != NULL) /* any other characters */ goto Fail; if (! (feof (f1)) ) goto Fail; if (strcmp ("Every good boy deserves favor\n", string)) goto Fail; rewind (f1); /* test reading until n-1 chars seen */ strPtr = fgets (string, 15, f1); if (strPtr == NULL) goto Fail; if (strcmp ("Every good boy", string)) goto Fail; strPtr = fgets (string, 17, f1); /* ensure fgets moves internal file */ if (strPtr == NULL) /* pointer */ goto Fail; if (strcmp (" deserves favor\n", string)) goto Fail; fgetc(f1); /* force an EOF condition */ strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */ if (strPtr != NULL) /* any other characters */ goto Fail; if (! (feof (f1)) ) goto Fail; if (strcmp (" deserves favor\n", string)) goto Fail; i = fclose (f1); /* close file and quit */ if (i) goto Fail3; printf ("Passed Conformance Test 17.7.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.7.0.1\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.7.0.1\n"); return; Fail2: printf ("Unable to write to temp file for Conformance Test 17.7.0.1\n"); return; Fail3: printf ("Unable to close temp file for Conformance Test 17.7.0.1\n"); return; }
/* Conformance Test 17.7.0.1: Verification of fgets function, text stream */
#include <stdio.h>
main ()
{
FILE *f1;
int i;
char string [80] = ""; /* initialize input string to null string */
char *strPtr;
f1 = fopen ("3/tmp", "w+"); /* create text file to work on */
if (f1 == NULL)
goto Fail1;
i = fputs ("Every good boy deserves favor\n", f1);
if (i)
goto Fail2;
rewind (f1); /* test reading until '\n' seen */
strPtr = fgets (string, 100, f1);
if (strPtr == NULL)
goto Fail;
if (strcmp ("Every good boy deserves favor\n", string))
goto Fail;
fgetc(f1); /* force an EOF condition */
strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */
if (strPtr != NULL) /* any other characters */
goto Fail;
if (! (feof (f1)) )
goto Fail;
if (strcmp ("Every good boy deserves favor\n", string))
goto Fail;
rewind (f1); /* test reading until n-1 chars seen */
strPtr = fgets (string, 15, f1);
if (strPtr == NULL)
goto Fail;
if (strcmp ("Every good boy", string))
goto Fail;
strPtr = fgets (string, 17, f1); /* ensure fgets moves internal file */
if (strPtr == NULL) /* pointer */
goto Fail;
if (strcmp (" deserves favor\n", string))
goto Fail;
fgetc(f1); /* force an EOF condition */
strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */
if (strPtr != NULL) /* any other characters */
goto Fail;
if (! (feof (f1)) )
goto Fail;
if (strcmp (" deserves favor\n", string))
goto Fail;
i = fclose (f1); /* close file and quit */
if (i)
goto Fail3;
printf ("Passed Conformance Test 17.7.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.7.0.1\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.7.0.1\n");
return;
Fail2:
printf ("Unable to write to temp file for Conformance Test 17.7.0.1\n");
return;
Fail3:
printf ("Unable to close temp file for Conformance Test 17.7.0.1\n");
return;
}

81
Tests/Conformance/C17.7.0.2.CC Executable file → Normal file
View File

@ -1 +1,80 @@
/* Conformance Test 17.7.0.2: Verification of fgets function, binary stream */ #include <stdio.h> main () { FILE *f1; int i; char string [80] = ""; /* initialize input string to null string */ char *strPtr; f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */ if (f1 == NULL) goto Fail1; i = fputs ("Every good boy deserves favor\n", f1); if (i) goto Fail2; rewind (f1); /* test reading until '\n' seen */ strPtr = fgets (string, 100, f1); if (strPtr == NULL) goto Fail; if (strcmp ("Every good boy deserves favor\n", string)) goto Fail; fgetc(f1); /* force an EOF condition */ strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */ if (strPtr != NULL) /* any other characters */ goto Fail; if (! (feof (f1)) ) goto Fail; if (strcmp ("Every good boy deserves favor\n", string)) goto Fail; rewind (f1); /* test reading until n-1 chars seen */ strPtr = fgets (string, 15, f1); if (strPtr == NULL) goto Fail; if (strcmp ("Every good boy", string)) goto Fail; strPtr = fgets (string, 17, f1); /* ensure fgets moves internal file */ if (strPtr == NULL) /* pointer */ goto Fail; if (strcmp (" deserves favor\n", string)) goto Fail; fgetc(f1); /* force an EOF condition */ strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */ if (strPtr != NULL) /* any other characters */ goto Fail; if (! (feof (f1)) ) goto Fail; if (strcmp (" deserves favor\n", string)) goto Fail; i = fclose (f1); /* close file and quit */ if (i) goto Fail3; printf ("Passed Conformance Test 17.7.0.2\n"); return; Fail: printf ("Failed Conformance Test 17.7.0.2\n"); return; Fail1: printf ("Unable to open temp file for Conformance Test 17.7.0.2\n"); return; Fail2: printf ("Unable to write to temp file for Conformance Test 17.7.0.2\n"); return; Fail3: printf ("Unable to close temp file for Conformance Test 17.7.0.2\n"); return; }
/* Conformance Test 17.7.0.2: Verification of fgets function, binary stream */
#include <stdio.h>
main ()
{
FILE *f1;
int i;
char string [80] = ""; /* initialize input string to null string */
char *strPtr;
f1 = fopen ("3/tmp", "w+b"); /* create binary file to work on */
if (f1 == NULL)
goto Fail1;
i = fputs ("Every good boy deserves favor\n", f1);
if (i)
goto Fail2;
rewind (f1); /* test reading until '\n' seen */
strPtr = fgets (string, 100, f1);
if (strPtr == NULL)
goto Fail;
if (strcmp ("Every good boy deserves favor\n", string))
goto Fail;
fgetc(f1); /* force an EOF condition */
strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */
if (strPtr != NULL) /* any other characters */
goto Fail;
if (! (feof (f1)) )
goto Fail;
if (strcmp ("Every good boy deserves favor\n", string))
goto Fail;
rewind (f1); /* test reading until n-1 chars seen */
strPtr = fgets (string, 15, f1);
if (strPtr == NULL)
goto Fail;
if (strcmp ("Every good boy", string))
goto Fail;
strPtr = fgets (string, 17, f1); /* ensure fgets moves internal file */
if (strPtr == NULL) /* pointer */
goto Fail;
if (strcmp (" deserves favor\n", string))
goto Fail;
fgetc(f1); /* force an EOF condition */
strPtr = fgets (string, 100, f1); /* test reading with EOF seen before */
if (strPtr != NULL) /* any other characters */
goto Fail;
if (! (feof (f1)) )
goto Fail;
if (strcmp (" deserves favor\n", string))
goto Fail;
i = fclose (f1); /* close file and quit */
if (i)
goto Fail3;
printf ("Passed Conformance Test 17.7.0.2\n");
return;
Fail:
printf ("Failed Conformance Test 17.7.0.2\n");
return;
Fail1:
printf ("Unable to open temp file for Conformance Test 17.7.0.2\n");
return;
Fail2:
printf ("Unable to write to temp file for Conformance Test 17.7.0.2\n");
return;
Fail3:
printf ("Unable to close temp file for Conformance Test 17.7.0.2\n");
return;
}

91
Tests/Conformance/C17.8.0.1.CC Executable file → Normal file
View File

@ -1 +1,90 @@
/* Conformance Test 17.8.0.1: Verification of fscanf, d format code */ #include <stdio.h> main () { FILE *f1; short i1; int i; int i2, i3; long L1; char ch; f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r"); rewind(f1); i1 = 0; /* test format string of no */ i = fscanf (f1, "%*05hd8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (i1 != 0) /* after 5 digits read */ goto Fail; i2 = 15; /* test "plain vanilla" fmt */ i = fscanf (f1, "%d", &i2); /* string; data contains */ if (i != 1) /* a single minus sign */ goto Fail; if (i2 != 0) goto Fail; L1 = 0; /* test format string of */ i = fscanf (f1, "%12ldA", &L1); /* max. field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character A must appear*/ if (L1 != -2147483647) /* after digits read */ goto Fail; L1 = 0; /* test format string of */ i = fscanf (f1, "%6ld%d", &L1, &i2); /* max. field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((L1 != 327677) || (i2 != -22)) /* for integer */ goto Fail; i3 = 4; /* test format string of */ i = fscanf (f1, "%4hd", &i3); /* max. field width of 4, */ if (i != 1) /* short variable expectd.*/ goto Fail; /* * appears in input as */ if (i3 != 123) /* 4th char. */ goto Fail; i = fscanf (f1, "%c", &ch); /* Ensure offending * has */ if (i != 1) /* been left in input. */ goto Fail; if (ch != '*') goto Fail; i = fscanf (f1, "%c", &ch); /* Ensure fscanf returns EOF*/ if (i != 1) /* when EOF encountered. */ goto Fail; if (ch != '\r') goto Fail; fgetc(f1); i = fscanf (f1, "%c", &ch); if (i != EOF) goto Fail; i = fclose (f1); /* close the file and quit */ if (i == EOF) goto Fail2; printf ("Passed Conformance Test 17.8.0.1\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.1\n"); return; Fail1: printf ("Unable to open input file for Conformance Test 17.8.0.1\n"); return; Fail2: printf ("Unable to close input file for Conformance Test 17.8.0.1\n"); return; }
/* Conformance Test 17.8.0.1: Verification of fscanf, d format code */
#include <stdio.h>
main ()
{
FILE *f1;
short i1;
int i;
int i2, i3;
long L1;
char ch;
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r");
rewind(f1);
i1 = 0; /* test format string of no */
i = fscanf (f1, "%*05hd8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (i1 != 0) /* after 5 digits read */
goto Fail;
i2 = 15; /* test "plain vanilla" fmt */
i = fscanf (f1, "%d", &i2); /* string; data contains */
if (i != 1) /* a single minus sign */
goto Fail;
if (i2 != 0)
goto Fail;
L1 = 0; /* test format string of */
i = fscanf (f1, "%12ldA", &L1); /* max. field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character A must appear*/
if (L1 != -2147483647) /* after digits read */
goto Fail;
L1 = 0; /* test format string of */
i = fscanf (f1, "%6ld%d", &L1, &i2); /* max. field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((L1 != 327677) || (i2 != -22)) /* for integer */
goto Fail;
i3 = 4; /* test format string of */
i = fscanf (f1, "%4hd", &i3); /* max. field width of 4, */
if (i != 1) /* short variable expectd.*/
goto Fail; /* * appears in input as */
if (i3 != 123) /* 4th char. */
goto Fail;
i = fscanf (f1, "%c", &ch); /* Ensure offending * has */
if (i != 1) /* been left in input. */
goto Fail;
if (ch != '*')
goto Fail;
i = fscanf (f1, "%c", &ch); /* Ensure fscanf returns EOF*/
if (i != 1) /* when EOF encountered. */
goto Fail;
if (ch != '\r')
goto Fail;
fgetc(f1);
i = fscanf (f1, "%c", &ch);
if (i != EOF)
goto Fail;
i = fclose (f1); /* close the file and quit */
if (i == EOF)
goto Fail2;
printf ("Passed Conformance Test 17.8.0.1\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.1\n");
return;
Fail1:
printf ("Unable to open input file for Conformance Test 17.8.0.1\n");
return;
Fail2:
printf ("Unable to close input file for Conformance Test 17.8.0.1\n");
return;
}

46
Tests/Conformance/C17.8.0.10.CC Executable file → Normal file
View File

@ -1 +1,45 @@
/* Conformance Test 17.8.0.10: Verification of sscanf, u format code */ #include <stdio.h> main () { char string [] = " 327678 D 4294967295m 32767722 "; int i; unsigned short us1; unsigned int ui1; unsigned long ul1; ui1 = 2; /* test format string of no */ i = sscanf (string, "%*05hu8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (ui1 != 2) /* after 5 digits read */ goto Fail; i = sscanf (&string [8], "%u", &ui1); /* test "plain vanilla" fmt */ if (i != 0) /* string; data contains */ goto Fail; /* the character 'D' */ ul1 = 0; /* test fmt string of max */ i = sscanf (&string [11], " D %12ldm", &ul1); /* field width of 12, */ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ goto Fail; ul1 = 0; /* test fmt string of max */ i = sscanf (&string [27], "%6lu%u", &ul1, &ui1); /* field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((ul1 != 327677) || (ui1 != 22)) /* for integer */ goto Fail; printf ("Passed Conformance Test 17.8.0.10\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.10\n"); return; }
/* Conformance Test 17.8.0.10: Verification of sscanf, u format code */
#include <stdio.h>
main ()
{
char string [] = " 327678 D 4294967295m 32767722 ";
int i;
unsigned short us1;
unsigned int ui1;
unsigned long ul1;
ui1 = 2; /* test format string of no */
i = sscanf (string, "%*05hu8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (ui1 != 2) /* after 5 digits read */
goto Fail;
i = sscanf (&string [8], "%u", &ui1); /* test "plain vanilla" fmt */
if (i != 0) /* string; data contains */
goto Fail; /* the character 'D' */
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [11], " D %12ldm", &ul1); /* field width of 12, */
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */
goto Fail;
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [27], "%6lu%u", &ul1, &ui1); /* field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((ul1 != 327677) || (ui1 != 22)) /* for integer */
goto Fail;
printf ("Passed Conformance Test 17.8.0.10\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.10\n");
return;
}

46
Tests/Conformance/C17.8.0.11.CC Executable file → Normal file
View File

@ -1 +1,45 @@
/* Conformance Test 17.8.0.11: Verification of sscanf, o format code */ #include <stdio.h> main () { char string [] = " 777778 D 37777777777m 117777526 "; int i; unsigned short us1; unsigned int ui1; unsigned long ul1; us1 = 2; /* test format string of no */ i = sscanf (string, "%*05ho8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (us1 != 2) /* after 5 digits read */ goto Fail; i = sscanf (&string [9], "%o", &ui1); /* test "plain vanilla" fmt */ if (i != 0) /* string; data contains */ goto Fail; /* the character 'D' */ ul1 = 0; /* test fmt string of max */ i = sscanf (&string [11], "D %12lom", &ul1); /* field width of 12, */ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ goto Fail; ul1 = 0; /* test fmt string of max */ i = sscanf (&string [31], "%7lo%o", &ul1, &ui1); /* field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((ul1 != 327677) || (ui1 != 22)) /* for integer */ goto Fail; printf ("Passed Conformance Test 17.8.0.11\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.11\n"); return; }
/* Conformance Test 17.8.0.11: Verification of sscanf, o format code */
#include <stdio.h>
main ()
{
char string [] = " 777778 D 37777777777m 117777526 ";
int i;
unsigned short us1;
unsigned int ui1;
unsigned long ul1;
us1 = 2; /* test format string of no */
i = sscanf (string, "%*05ho8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (us1 != 2) /* after 5 digits read */
goto Fail;
i = sscanf (&string [9], "%o", &ui1); /* test "plain vanilla" fmt */
if (i != 0) /* string; data contains */
goto Fail; /* the character 'D' */
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [11], "D %12lom", &ul1); /* field width of 12, */
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */
goto Fail;
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [31], "%7lo%o", &ul1, &ui1); /* field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((ul1 != 327677) || (ui1 != 22)) /* for integer */
goto Fail;
printf ("Passed Conformance Test 17.8.0.11\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.11\n");
return;
}

48
Tests/Conformance/C17.8.0.12.CC Executable file → Normal file
View File

@ -1 +1,47 @@
/* Conformance Test 17.8.0.12: Verification of sscanf, x,X format codes */ #include <stdio.h> main () { char string [] = " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10 "; int i; unsigned short us1; unsigned int ui1; unsigned long ul1; us1 = 2; /* test format string of no */ i = sscanf (string, "%*05hx8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (us1 != 2) /* after 5 digits read */ goto Fail; i = sscanf (&string [8], "%X", &ui1); /* test "plain vanilla" fmt */ if (i != 1) /* string; data contains */ goto Fail; /* the characters 0x */ if (ui1 != 0) goto Fail; ul1 = 0; /* test fmt string of max */ i = sscanf (&string [12], " D %12lxm", &ul1); /* field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ goto Fail; ul1 = 0; /* test fmt string of max */ i = sscanf (&string [30], "%6lx%x", &ul1, &ui1); /* field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((ul1 != 0x7FED) || (ui1 != 16)) /* for integer */ goto Fail; printf ("Passed Conformance Test 17.8.0.12\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.12\n"); return; }
/* Conformance Test 17.8.0.12: Verification of sscanf, x,X format codes */
#include <stdio.h>
main ()
{
char string [] = " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10 ";
int i;
unsigned short us1;
unsigned int ui1;
unsigned long ul1;
us1 = 2; /* test format string of no */
i = sscanf (string, "%*05hx8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (us1 != 2) /* after 5 digits read */
goto Fail;
i = sscanf (&string [8], "%X", &ui1); /* test "plain vanilla" fmt */
if (i != 1) /* string; data contains */
goto Fail; /* the characters 0x */
if (ui1 != 0)
goto Fail;
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [12], " D %12lxm", &ul1); /* field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */
goto Fail;
ul1 = 0; /* test fmt string of max */
i = sscanf (&string [30], "%6lx%x", &ul1, &ui1); /* field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((ul1 != 0x7FED) || (ui1 != 16)) /* for integer */
goto Fail;
printf ("Passed Conformance Test 17.8.0.12\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.12\n");
return;
}

33
Tests/Conformance/C17.8.0.13.CC Executable file → Normal file
View File

@ -1 +1,32 @@
/* Conformance Test 17.8.0.13: Verification of sscanf, c format code */ #include <stdio.h> #include <string.h> main () { char sstr [] = "bten chars!andMore"; int i; char ch, string [50]; ch = 'a'; /* no assignment should be made */ i = sscanf (sstr, "%*hc"); /* h ignored */ if (i != 0) goto Fail; if (ch != 'a') goto Fail; i = sscanf (&sstr [1], "%10lc", string); /* test assignment to string*/ if (i != 1) /* l ignored */ goto Fail; if (strncmp (string, "ten chars!", 10)) goto Fail; printf ("Passed Conformance Test 17.8.0.13\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.13\n"); return; }
/* Conformance Test 17.8.0.13: Verification of sscanf, c format code */
#include <stdio.h>
#include <string.h>
main ()
{
char sstr [] = "bten chars!andMore";
int i;
char ch, string [50];
ch = 'a'; /* no assignment should be made */
i = sscanf (sstr, "%*hc"); /* h ignored */
if (i != 0)
goto Fail;
if (ch != 'a')
goto Fail;
i = sscanf (&sstr [1], "%10lc", string); /* test assignment to string*/
if (i != 1) /* l ignored */
goto Fail;
if (strncmp (string, "ten chars!", 10))
goto Fail;
printf ("Passed Conformance Test 17.8.0.13\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.13\n");
return;
}

31
Tests/Conformance/C17.8.0.14.CC Executable file → Normal file
View File

@ -1 +1,30 @@
/* Conformance Test 17.8.0.14: Verification of sscanf, s format code */ #include <stdio.h> main () { char sstr [] = " oneLongWord ten-chars!andMore"; int i, j; char string [50] = "hey, hey!"; i = sscanf (&sstr[0], "%*hs"); /* no assignment made; h ignored */ if (i != 0) goto Fail; if (strcmp (string, "hey, hey!")) goto Fail; i = sscanf (&sstr [14], "%10ls", string); /* test assignment to string*/ if (i != 1) /* l ignored */ goto Fail; if (strcmp (string, "ten-chars!")) goto Fail; printf ("Passed Conformance Test 17.8.0.14\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.14\n"); return; }
/* Conformance Test 17.8.0.14: Verification of sscanf, s format code */
#include <stdio.h>
main ()
{
char sstr [] = " oneLongWord ten-chars!andMore";
int i, j;
char string [50] = "hey, hey!";
i = sscanf (&sstr[0], "%*hs"); /* no assignment made; h ignored */
if (i != 0)
goto Fail;
if (strcmp (string, "hey, hey!"))
goto Fail;
i = sscanf (&sstr [14], "%10ls", string); /* test assignment to string*/
if (i != 1) /* l ignored */
goto Fail;
if (strcmp (string, "ten-chars!"))
goto Fail;
printf ("Passed Conformance Test 17.8.0.14\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.14\n");
return;
}

36
Tests/Conformance/C17.8.0.15.CC Executable file → Normal file
View File

@ -1 +1,35 @@
/* Conformance Test 17.8.0.15: Verification of fscanf, f e E g G format codes */ #include <stdio.h> #include <math.h> main () { char sstr [] = " 23 -3.8E20 - e- +25e- 00002.00008e000049.9 "; float f1, f2, f3, f4; double d1, d2, d3; int i; f1 = f2 = f3 = f4 = 1.0; d1 = d2 = d3 = 1.0; i = sscanf (&sstr[0], "%*07f %e %E %lg %30lG %17lf%e", &f2, &f3, &d1, &d2, &d3, &f4); if (i != 6) goto Fail; if ((fabs(f1 - 1.0) > 0.00001) || (fabs(f2 - (-3.8E20)) > 1e15) || (fabs(f3) > 0.00001) || (fabs(f4 - 9.9) > 0.00001) || (fabs(d1) > 0.00001) || (fabs(d2 - 25.0) > 0.00001) || (fabs(d3 - 2.00008e4) > 0.00001)) goto Fail; printf ("Passed Conformance Test 17.8.0.15\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.15\n"); return; }
/* Conformance Test 17.8.0.15: Verification of fscanf, f e E g G format codes */
#include <stdio.h>
#include <math.h>
main ()
{
char sstr [] = " 23 -3.8E20 - e- +25e- 00002.00008e000049.9 ";
float f1, f2, f3, f4;
double d1, d2, d3;
int i;
f1 = f2 = f3 = f4 = 1.0;
d1 = d2 = d3 = 1.0;
i = sscanf (&sstr[0], "%*07f %e %E %lg %30lG %17lf%e", &f2, &f3, &d1, &d2,
&d3, &f4);
if (i != 6)
goto Fail;
if ((fabs(f1 - 1.0) > 0.00001) ||
(fabs(f2 - (-3.8E20)) > 1e15) ||
(fabs(f3) > 0.00001) ||
(fabs(f4 - 9.9) > 0.00001) ||
(fabs(d1) > 0.00001) ||
(fabs(d2 - 25.0) > 0.00001) ||
(fabs(d3 - 2.00008e4) > 0.00001))
goto Fail;
printf ("Passed Conformance Test 17.8.0.15\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.15\n");
return;
}

44
Tests/Conformance/C17.8.0.16.CC Executable file → Normal file
View File

@ -1 +1,43 @@
/* Conformance Test 17.8.0.16: Verification of sscanf, % and [ format codes */ #include <stdio.h> main () { char sstr [] = "% these are the ^only[ characters" "*aaabbb a fine mess, you see! ddddfffffffff"; int i; char string [2] [50] = { {"hey, hey!"}, {"you, you"} }; i = sscanf (&sstr[0], "%*50h%"); /* no assignment made; * 50 h ignored */ if (i != 0) goto Fail; /* Create set of characters which can appear in the output string. */ i = sscanf (&sstr [1], "%45[thes aronlyc^[] %*[*ab]", &string [0]); if (i != 1) goto Fail; if (strcmp (&string [0], " these are the ^only[ characters")) goto Fail; /* Create set of characters which cannot appear in the output string. */ i = sscanf (&sstr [42], "%[^d] %10[df]", &string [0], &string [1]); if (i != 2) goto Fail; if (strcmp (&string [0], " a fine mess, you see! ")) goto Fail; if (strcmp (&string [1], "ddddffffff")) goto Fail; printf ("Passed Conformance Test 17.8.0.16\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.16\n"); return; }
/* Conformance Test 17.8.0.16: Verification of sscanf, % and [ format codes */
#include <stdio.h>
main ()
{
char sstr [] = "% these are the ^only[ characters"
"*aaabbb a fine mess, you see! ddddfffffffff";
int i;
char string [2] [50] = { {"hey, hey!"}, {"you, you"} };
i = sscanf (&sstr[0], "%*50h%"); /* no assignment made; * 50 h ignored */
if (i != 0)
goto Fail;
/* Create set of characters which can appear in the output string. */
i = sscanf (&sstr [1], "%45[thes aronlyc^[] %*[*ab]", &string [0]);
if (i != 1)
goto Fail;
if (strcmp (&string [0], " these are the ^only[ characters"))
goto Fail;
/* Create set of characters which cannot appear in the output string. */
i = sscanf (&sstr [42], "%[^d] %10[df]", &string [0], &string [1]);
if (i != 2)
goto Fail;
if (strcmp (&string [0], " a fine mess, you see! "))
goto Fail;
if (strcmp (&string [1], "ddddffffff"))
goto Fail;
printf ("Passed Conformance Test 17.8.0.16\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.16\n");
return;
}

92
Tests/Conformance/C17.8.0.17.CC Executable file → Normal file
View File

@ -1 +1,91 @@
/* Conformance Test 17.8.0.17: Verification of scanf, d format code */ #include <stdio.h> main () { short i1; int i; int i2, i3; long L1; char ch; FILE *f1; /* Redirect standard input to a data file. */ f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r"); fclose(f1); stdin = freopen ("3/tmp", "r", stdin); if (stdin == NULL) goto Fail1; i1 = 0; /* test format string of no */ i = scanf ("%*05hd8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (i1 != 0) /* after 5 digits read */ goto Fail; i2 = 15; /* test "plain vanilla" fmt */ i = scanf ("%d", &i2); /* string; data contains */ if (i != 1) /* a single minus sign */ goto Fail; if (i2 != 0) goto Fail; L1 = 0; /* test format string of */ i = scanf ("%12ldA", &L1); /* max. field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character A must appear*/ if (L1 != -2147483647) /* after digits read */ goto Fail; L1 = 0; /* test format string of */ i = scanf ("%6ld%d", &L1, &i2); /* max. field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((L1 != 327677) || (i2 != -22)) /* for integer */ goto Fail; i3 = 4; /* test format string of */ i = scanf ("%4hd", &i3); /* max. field width of 4, */ if (i != 1) /* short variable expectd,*/ goto Fail; /* character * must appear*/ if (i3 != 123) /* after digits read. In */ goto Fail; /* the input, the number */ /* of digits is only 3. */ i = scanf ("%c", &ch); /* Ensure offending * has */ if (i != 1) /* been left in input. */ goto Fail; if (ch != '*') goto Fail; i = scanf ("%c", &ch); /* Ensure scanf returns EOF */ if (i != 1) /* when EOF encountered. */ goto Fail; if (ch != '\n') goto Fail; i = scanf ("%c", &ch); if (i != EOF) goto Fail; stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */ if (stdin == NULL) goto Fail1; printf ("Passed Conformance Test 17.8.0.17\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.17\n"); return; Fail1: printf ("Unable to redirect stdin for Conformance Test 17.8.0.17\n"); return; }
/* Conformance Test 17.8.0.17: Verification of scanf, d format code */
#include <stdio.h>
main ()
{
short i1;
int i;
int i2, i3;
long L1;
char ch;
FILE *f1;
/* Redirect standard input to a data file. */
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r");
fclose(f1);
stdin = freopen ("3/tmp", "r", stdin);
if (stdin == NULL)
goto Fail1;
i1 = 0; /* test format string of no */
i = scanf ("%*05hd8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (i1 != 0) /* after 5 digits read */
goto Fail;
i2 = 15; /* test "plain vanilla" fmt */
i = scanf ("%d", &i2); /* string; data contains */
if (i != 1) /* a single minus sign */
goto Fail;
if (i2 != 0)
goto Fail;
L1 = 0; /* test format string of */
i = scanf ("%12ldA", &L1); /* max. field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character A must appear*/
if (L1 != -2147483647) /* after digits read */
goto Fail;
L1 = 0; /* test format string of */
i = scanf ("%6ld%d", &L1, &i2); /* max. field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((L1 != 327677) || (i2 != -22)) /* for integer */
goto Fail;
i3 = 4; /* test format string of */
i = scanf ("%4hd", &i3); /* max. field width of 4, */
if (i != 1) /* short variable expectd,*/
goto Fail; /* character * must appear*/
if (i3 != 123) /* after digits read. In */
goto Fail; /* the input, the number */
/* of digits is only 3. */
i = scanf ("%c", &ch); /* Ensure offending * has */
if (i != 1) /* been left in input. */
goto Fail;
if (ch != '*')
goto Fail;
i = scanf ("%c", &ch); /* Ensure scanf returns EOF */
if (i != 1) /* when EOF encountered. */
goto Fail;
if (ch != '\n')
goto Fail;
i = scanf ("%c", &ch);
if (i != EOF)
goto Fail;
stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */
if (stdin == NULL)
goto Fail1;
printf ("Passed Conformance Test 17.8.0.17\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.17\n");
return;
Fail1:
printf ("Unable to redirect stdin for Conformance Test 17.8.0.17\n");
return;
}

66
Tests/Conformance/C17.8.0.18.CC Executable file → Normal file
View File

@ -1 +1,65 @@
/* Conformance Test 17.8.0.18: Verification of scanf, u format code */ #include <stdio.h> main () { int i; unsigned short us1; unsigned int ui1; unsigned long ul1; FILE *f1; /* Redirect standard input from a file. */ f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; fprintf(f1, " 327678 D 4294967295m 32767722\r"); fclose(f1); stdin = freopen ("3/tmp", "r", stdin); if (stdin == NULL) goto Fail1; ui1 = 2; /* test format string of no */ i = scanf ("%*05hu8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (ui1 != 2) /* after 5 digits read */ goto Fail; i = scanf ("%u", &ui1); /* test "plain vanilla" fmt */ if (i != 0) /* string; data contains */ goto Fail; /* the character 'D' */ ul1 = 0; /* test format string of */ i = scanf ("D %12ldm", &ul1); /* max. field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ goto Fail; ul1 = 0; /* test format string of */ i = scanf ("%6lu%u", &ul1, &ui1); /* max. field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((ul1 != 327677) || (ui1 != 22)) /* for integer */ goto Fail; stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */ if (stdin == NULL) goto Fail1; printf ("Passed Conformance Test 17.8.0.18\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.18\n"); return; Fail1: printf ("Unable to redirect stdin for Conformance Test 17.8.0.18\n"); return; }
/* Conformance Test 17.8.0.18: Verification of scanf, u format code */
#include <stdio.h>
main ()
{
int i;
unsigned short us1;
unsigned int ui1;
unsigned long ul1;
FILE *f1;
/* Redirect standard input from a file. */
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " 327678 D 4294967295m 32767722\r");
fclose(f1);
stdin = freopen ("3/tmp", "r", stdin);
if (stdin == NULL)
goto Fail1;
ui1 = 2; /* test format string of no */
i = scanf ("%*05hu8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (ui1 != 2) /* after 5 digits read */
goto Fail;
i = scanf ("%u", &ui1); /* test "plain vanilla" fmt */
if (i != 0) /* string; data contains */
goto Fail; /* the character 'D' */
ul1 = 0; /* test format string of */
i = scanf ("D %12ldm", &ul1); /* max. field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */
goto Fail;
ul1 = 0; /* test format string of */
i = scanf ("%6lu%u", &ul1, &ui1); /* max. field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((ul1 != 327677) || (ui1 != 22)) /* for integer */
goto Fail;
stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */
if (stdin == NULL)
goto Fail1;
printf ("Passed Conformance Test 17.8.0.18\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.18\n");
return;
Fail1:
printf ("Unable to redirect stdin for Conformance Test 17.8.0.18\n");
return;
}

66
Tests/Conformance/C17.8.0.19.CC Executable file → Normal file
View File

@ -1 +1,65 @@
/* Conformance Test 17.8.0.19: Verification of scanf, o format code */ #include <stdio.h> main () { int i; unsigned short us1; unsigned int ui1; unsigned long ul1; FILE *f1; /* Redirect standard input from a file. */ f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; fprintf(f1, " 77777 D 37777777777m 117777526"); fclose(f1); stdin = freopen ("3/tmp", "r", stdin); if (stdin == NULL) goto Fail1; us1 = 2; /* test format string of no */ i = scanf ("%*05ho8"); /* assignment, max. field */ if (i != 0) /* width of 5, h ignored, */ goto Fail; /* character 8 must appear*/ if (us1 != 2) /* after 5 digits read */ goto Fail; i = scanf ("%o", &ui1); /* test "plain vanilla" fmt */ if (i != 0) /* string; data contains */ goto Fail; /* the character 'D' */ ul1 = 0; /* test format string of */ i = scanf ("D %12lom", &ul1); /* max. field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ goto Fail; ul1 = 0; /* test format string of */ i = scanf ("%7lo%o", &ul1, &ui1); /* max. field width of 6, */ if (i != 2) /* long variable expected,*/ goto Fail; /* followed by simple fmt */ if ((ul1 != 327677) || (ui1 != 22)) /* for integer */ goto Fail; stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */ if (stdin == NULL) goto Fail1; printf ("Passed Conformance Test 17.8.0.19\n"); return; Fail: printf ("Failed Conformance Test 17.8.0.19\n"); return; Fail1: printf ("Unable to redirect stdin for Conformance Test 17.8.0.19\n"); return; }
/* Conformance Test 17.8.0.19: Verification of scanf, o format code */
#include <stdio.h>
main ()
{
int i;
unsigned short us1;
unsigned int ui1;
unsigned long ul1;
FILE *f1;
/* Redirect standard input from a file. */
f1 = fopen ("3/tmp", "wb+"); /* open input file for test */
if (f1 == NULL)
goto Fail1;
fprintf(f1, " 77777 D 37777777777m 117777526");
fclose(f1);
stdin = freopen ("3/tmp", "r", stdin);
if (stdin == NULL)
goto Fail1;
us1 = 2; /* test format string of no */
i = scanf ("%*05ho8"); /* assignment, max. field */
if (i != 0) /* width of 5, h ignored, */
goto Fail; /* character 8 must appear*/
if (us1 != 2) /* after 5 digits read */
goto Fail;
i = scanf ("%o", &ui1); /* test "plain vanilla" fmt */
if (i != 0) /* string; data contains */
goto Fail; /* the character 'D' */
ul1 = 0; /* test format string of */
i = scanf ("D %12lom", &ul1); /* max. field width of 12,*/
if (i != 1) /* long variable expected,*/
goto Fail; /* character m must appear*/
if (ul1 != 4294967295u) /* after digits read */
goto Fail;
ul1 = 0; /* test format string of */
i = scanf ("%7lo%o", &ul1, &ui1); /* max. field width of 6, */
if (i != 2) /* long variable expected,*/
goto Fail; /* followed by simple fmt */
if ((ul1 != 327677) || (ui1 != 22)) /* for integer */
goto Fail;
stdin = freopen (".CONSOLE", "r", stdin); /* reset stdin and quit */
if (stdin == NULL)
goto Fail1;
printf ("Passed Conformance Test 17.8.0.19\n");
return;
Fail:
printf ("Failed Conformance Test 17.8.0.19\n");
return;
Fail1:
printf ("Unable to redirect stdin for Conformance Test 17.8.0.19\n");
return;
}

Some files were not shown because too many files have changed in this diff Show More