After filtering, the program can't find the user name. So it calls the function again.
This probably happened when they moved an old unix app to Windows.
Let's also assume that whatever this is has multiple instances for some reason; maybe it's something called as part of an update process for system accounting information.
If every process on the machine did this every time it got re-scheduled? Yeah, I can see that.
for (pos = 0; !found; pos++) {
row = get_next_row();
if (strstr(row, "user") {
// this is obviously a header row
continue
}
if (strstr(row, user_name)) {
found = 1;
}
} for (pos = 0; !found; pos++)
This is so cool, I have never thought about this in like a decade of programming. I mean using a bool variable within a for loop.I'd say fair, but...
> indeed try to avoid languages where "for" allows such arbitrary constructs.
... come on. I'd say - go for such languages, they give you if a tiny bit more expressive power than ones who don't let you write such a loop.
That said, if one has an alternative that can express their intention better (like e.g. mapcar, foreach loop, Lisp's dotimes, etc.), one should use it instead.
That said, I rarely if ever have to resort to low-level debugging in such cases. I'm yet to encounter a problem that couldn't be solved by looking at the code and (very occasionally) stepping it through in the debugger. Here, using higher-order constructs in code is actually very helpful - the closer your code gets to expressing your intent, the smaller the set of possible bugs is. For instance, you can't make an off-by-one error in a foreach or a mapcar.
for (pos = 0; !found || pos < limit; pos++)
but there is nothing wrong in using an iterator and break out of the loop, especially if the language or the library gives you iterators.When you are over the iteration limit you want to trigger True && False which is False to break out of the loop where the right side False is the condition when pos > limit
Btw this is covered in Code Complete Second Edition by Microsoft Press on page 378-380
while(!done)
{
try
{
foo();
baz();
done = true;
}
catch(...) {}
}
with baz failing, but the retry present to handle cases where foo fails.As other have said, maybe Raymond Chen will some day do a blog post on this, although, considering that the bug is in DFPCommon.dll, i.e. the "Disk Footprint Utility Library", I doubt it really belongs to the shell and thus he won't know more than we do.