🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #359

Re: indirect goto

#359
From: Peter Hartzler
Date: Fri, 10 Apr 1992 02:32
29 lines
1571 bytes
amichail@descartes.waterloo.edu (Amir Michail) writes:

>switch(d){
>case 1 : goto l1;
>case 2 : goto l2;
>case 3 : goto l3;
>}
>The only problem is, d could have many values in my program,
>perhaps 10000 or so.
>Is there any other way I could do this?

If your values of d are contiguous, you could use d to index into an array
of pointers, as in goto VectTabl[d];, where VectTabl would be your array of
locally scoped addresses - void *VectTabl[]  = {l0, l1, l2, ... , ln};

>Also, I have another question about trapping segmentation violations.

>Suppose, I have an array A of size 10.  Then
>the statement a = A[2000] will cause a segmentation violation.  The
>point is I wish to trap it and perform some action, then return
>to the code and continue processing.  However, I keep getting
>repeated segmentation violations as 'a = A[2000]' is executed over and
>over again.  I tried putting an index i, i.e. a = A[i], then changing
>i back to 0 in my error handler routine.  However, this does not
>fix the problem.  Any clue on how to do this?

Is i in scope in your error routine? i.e., global or passed by reference.
-- 
Peter Hartzler (peterh@ukelele.UUCP)
Technical Details
Message-ID: <1992Apr10.023240.4276@ukelele.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!xrxedds!ihost!ukelele!peterh
References: <1992Apr7.015758.15792@descartes.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!xrxedds!ihost!ukelele!peterh
From: peterh@ukelele.UUCP (Peter Hartzler)
Newsgroups: comp.unix.programmer
Subject: Re: indirect goto
Message-ID: <1992Apr10.023240.4276@ukelele.UUCP>
Date: 10 Apr 92 02:32:40 GMT
References: <1992Apr7.015758.15792@descartes.waterloo.edu>
Distribution: dc
Organization: GAU Technologies, Fairfax County, VA
Lines: 29