I'm reading through some legacy code trying to figure out what it's doing. I've run into some
goto
statements and don't know exactly what they are doing.
Here is an example of the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
88 DO_SOMETHING:
89 if (value == 0)
90 goto EOJ;
91
92 if (value == 10)
93 goto EOJ;
94
95 DO_SOMETHING_ELSE:
96 if (someOtherValue == 0)
97 goto SOMEWHERE;
98
99 EOJ:
100 if (somethingHappened == 1)
101 doSomething();
102
103 else
104 doSomethingElse();
|
This, of course, isn't the actual code but it will suffice for what I'm asking.
So, suppose it is the case that
value == 0
at line 89. The next execution after the
goto
would be on line 100. After the contents of EOJ are satisfied what happens? Do we go back up to line 92 or do we continue to line 105?
That is, once a
goto
has "gone to" does it come back afterward (like you would expect if you called a function) or does it continue until it hits a
return
?
Any help would be appreciated.
Caveat: I don't like
goto
statements and would never use them. I'm in a situation where they are in existing code (which I'm trying to update) so I need to understand how they work.