Opened 11 years ago

Closed 11 years ago

#3986 closed Enhancement (worksforme)

Bug or Enhancement? : Code Question 'wildmat.c:DoMatch'

Reported by: Astara Owned by:
Priority: Low Milestone: None Set
Component: Transmission Version: 2.20
Severity: Minor Keywords:


There is code in this routine:

   for (last = 0400, matched = FALSE; *++p && *p != ']'; last = *p) {
		/* This next line requires a good C compiler. */
		if (*p == '-' ? *text <= *++p && *text >= last : *text == *p) 
			matched = TRUE;
		matched = (*p=='-') ?  text <= *++p && *text >= last
				    :  *text == *p;

That I had some questions on, and a suggestion for improvement for clarity:

1) why does it require a good C compiler? ;-) 2) the 'matched' condition is set in the loop, but it isn't tested as part of the loop's exit test. Should it be?

3) instead of the 'if (long test) then match=true', how about:

		matched = (*p=='-') ?  text <= *++p && *text >= last
				    :  *text == *p;

Inspection or a truth table show them to be identical.

Change History (1)

comment:1 Changed 11 years ago by jordan

  • Resolution set to worksforme
  • Status changed from new to closed

I've got no idea. That is Rich Salz's classic implementation of wildmat.c from the late 80s / early 90s and you would have to ask him for more information. :)

For more information, see the comments at the top of wildmat.c.

Note: See TracTickets for help on using tickets.