Txtzyme icon indicating copy to clipboard operation
Txtzyme copied to clipboard

loop brace code a bit obscure

Open sf105 opened this issue 12 years ago • 1 comments

This code

case '{':
  count = x; 
  loop = buf;
  while ((ch = *buf++) && ch != '}') {}
case '}':
  if (count) {
    count--;
    buf = loop;
  }
  break;

depends on the '{' case falling through to the '}' case at the end. I just blew a day porting to another process where I didn't notice this. How about

case '{':
  count = x; 
  loop = buf;
  while ((ch = *buf) && ch != '}') { buf++; }
  break;

Not quite as efficient but much safer?

sf105 avatar Mar 28 '13 15:03 sf105

Sorry about the day.

I'm happy to accept a pull request.

WardCunningham avatar Mar 28 '13 17:03 WardCunningham