[net.sources.mac] bugs in DeSmet C

paul@greipa.UUCP (Paul A. Vixie) (07/27/85)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	BUG_NO.A
#	BUG_YES.A
#	bug_no.c
#	bug_yes.c
# This archive created: Fri Jul 26 20:36:27 1985
export PATH; PATH=/bin:$PATH
if test -f 'BUG_NO.A'
then
	echo shar: will not over-write existing file "'BUG_NO.A'"
else
cat << \SHAR_EOF > 'BUG_NO.A'
 CSEG 
 PUBLIC fopen_
 PUBLIC fseek_
 PUBLIC lseek_
 PUBLIC _lread_
 PUBLIC _lwrite_
 DSEG 
arr_ DC.B 'instr1',0,0,0,0
 DC.B   1
 DC.B   2
 DC.B  10
 DC.B  20
 DC.B  30
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 'instr2',0,0,0,0
 DC.B   3
 DC.B   4
 DC.B  40
 DC.B  50
 DC.B  60
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 'instr3',0,0,0,0
 DC.B   5
 DC.B   6
 DC.B  70
 DC.B  80
 DC.B  90
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0,0,0,0,0,0,0,0,0,0
 DC.B   0
 DC.B   0
 DC.B   0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 DC.B 0
 CSEG 
 PUBLIC main_
 PUBLIC printf_
 DSEG 
__9 DC.B 'a=%s, b=%d, c=%d',10,0
 CSEG 

main_
 LINK A6,#-4
 LEA arr_,A0
 MOVE.L A0,-4(A6)
_L1
 MOVE.L -4(A6),A1
 TST.B (A1)
 BEQ _L2
 MOVE.B 11(A1),D1
 EXT.W D1
 MOVE.W D1,-(A7)
 MOVE.B 10(A1),D2
 EXT.W D2
 MOVE.W D2,-(A7)
 MOVE.L -4(A6),-(A7)
 PEA __9
 JSR printf_
 ADDA.W #12,A7
_L3
 ADD.L #22,-4(A6)
 BRA _L1
_L2
 UNLK A6
 RTS
 END
SHAR_EOF
fi # end of overwriting check
if test -f 'BUG_YES.A'
then
	echo shar: will not over-write existing file "'BUG_YES.A'"
else
cat << \SHAR_EOF > 'BUG_YES.A'
 CSEG 
 PUBLIC fopen_
 PUBLIC fseek_
 PUBLIC lseek_
 PUBLIC _lread_
 PUBLIC _lwrite_
 DSEG 
arr_ DC.B 'instr1',0,0,0,0
 DC.B   1
 DC.B   2
 DC.B  10
 DC.B  20
 DC.B  30
 DC.B 0,0,0,0,0,0,0,0
 DC.B 'instr2',0,0,0,0
 DC.B   3
 DC.B   4
 DC.B  40
 DC.B  50
 DC.B  60
 DC.B 0,0,0,0,0,0,0
 DC.B 'instr3',0,0,0,0
 DC.B   5
 DC.B   6
 DC.B  70
 DC.B  80
 DC.B  90
 DC.B 0,0,0,0,0,0,0
 DC.B 0,0,0,0,0,0,0,0,0,0
 DC.B   0
 DC.B   0
 DC.B   0
 DC.B 0,0,0,0,0,0,0,0,0
 CSEG 
 PUBLIC main_
 PUBLIC printf_
 DSEG 
__9 DC.B 'a=%s, b=%d, c=%d',10,0
 CSEG 

main_
 LINK A6,#-4
 LEA arr_,A0
 MOVE.L A0,-4(A6)
_L1
 MOVE.L -4(A6),A1
 TST.B (A1)
 BEQ _L2
 MOVE.B 11(A1),D1
 EXT.W D1
 MOVE.W D1,-(A7)
 MOVE.B 10(A1),D2
 EXT.W D2
 MOVE.W D2,-(A7)
 MOVE.L -4(A6),-(A7)
 PEA __9
 JSR printf_
 ADDA.W #12,A7
_L3
 ADD.L #22,-4(A6)
 BRA _L1
_L2
 UNLK A6
 RTS
 END
SHAR_EOF
fi # end of overwriting check
if test -f 'bug_no.c'
then
	echo shar: will not over-write existing file "'bug_no.c'"
else
cat << \SHAR_EOF > 'bug_no.c'

#include <stdio.h>

static struct s {char a[10], b, c, d1,d2,d3,d4,d5,d6,d7,d8,d9,d10;}
arr[] = {
	{"instr1", 1, 2, 10,20,30},
	{"instr2", 3, 4, 40,50,60},
	{"instr3", 5, 6, 70,80,90},
	{"", 0, 0, 0}};

main() {
	struct s *p;

	for (p = arr;  p->a[0];  p++)
		printf("a=%s, b=%d, c=%d\n", p->a,p->b,p->c);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'bug_yes.c'
then
	echo shar: will not over-write existing file "'bug_yes.c'"
else
cat << \SHAR_EOF > 'bug_yes.c'

#include <stdio.h>

static struct s {char a[10], b, c, d[10];} arr[] = {
	{"instr1", 1, 2, {10,20,30}},
	{"instr2", 3, 4, {40,50,60}},
	{"instr3", 5, 6, {70,80,90}},
	{"", 0, 0, {0}}};

main() {
	struct s *p;

	for (p = arr;  p->a[0];  p++)
		printf("a=%s, b=%d, c=%d\n", p->a,p->b,p->c);
}
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
-- 

	Paul Vixie
	{decwrl dual pyramid}!greipa!paul