[comp.sys.atari.st] Fix for Sozobon C case-without-switch bug

agrusow@exunido.uucp (Michael Vishchers) (06/26/89)

This is a followup to my article about the Sozobon C case-without-switch bug.

I received an answer from Tony Andrews saying that this bug will not be in
the new version. For all those who do not want to wait, but get rid of the
bombs NOW, here is a bug fix I received from
Andreas Schwab <schwab@joan.irb.informatik.uni-dortmund.de>

I have not tested it, but it seems okay.

Ah yes, if you do not have patch, you must make the modifications by hand.

Isn't it great to have a good Compiler with sources ? 

Good luck.

diff -c fun.c.old fun.c
*** fun.c.old	Mon Jun 26 12:53:39 1989
--- fun.c	Mon Jun 26 12:53:03 1989
***************
*** 34,40
  struct swittbl {
  	NODEP	caselist;
  	int	deflbl;
! } *curswit;
  
  int curbrk, curcont;
  int funtopl, funbotl, funretl, funstrl;

--- 34,40 -----
  struct swittbl {
  	NODEP	caselist;
  	int	deflbl;
! } *curswit = NULL;			/* Initialisierung noetig */
  
  int curbrk, curcont;
  int funtopl, funbotl, funretl, funstrl;
***************
*** 616,621
  	case K_DEFAULT:
  		if (debugs)
  			printf("DEFAULT ");
  		if (curswit->deflbl >= 0)
  			error("multiple 'default'");
  		curswit->deflbl = l1;

--- 616,623 -----
  	case K_DEFAULT:
  		if (debugs)
  			printf("DEFAULT ");
+ 		if (curswit == NULL)	/* Innerhalb 'switch'? */
+ 			error("'default' without 'switch'");
  		if (curswit->deflbl >= 0)
  			error("multiple 'default'");
  		curswit->deflbl = l1;
***************
*** 703,708
  	np->c_casel = lbl;
  	sprintf(np->n_name, "%d:%d", val, lbl);
  
  	last = NULL;
  	for (p = curswit->caselist; p; last=p, p=p->n_next)
  		if (p->c_casev == val) {

--- 705,712 -----
  	np->c_casel = lbl;
  	sprintf(np->n_name, "%d:%d", val, lbl);
  
+ 	if (curswit == NULL)		/* Innerhalb 'switch'? */
+ 		error("'case' without 'switch'");
  	last = NULL;
  	for (p = curswit->caselist; p; last=p, p=p->n_next)
  		if (p->c_casev == val) {
------------------------------------------------------------------------

 ______________________________________________________________________
/ Michael Vishchers                           | History repeats itself.\
| michaelV@owl.ls5.informatik.uni-dortmund.de | Has to.                |
| michaelV%owl.ls5@UNIDO.uucp                 | No one listens.        |
| (I think)                                   |        (steve turner)  |
\______________________________________________________________________/
/ Home address:: Frohnhauser Str. 233    D-4300 Essen 1    West-Germany\
________________________________________________________________________