🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Guy Harris Wed, 26 Mar 1986 05:04
"regexp.h" does an incorrect comparison of a "char" against 255
#279
Author: Guy Harris
Date: Wed, 26 Mar 1986 05:04
83 lines
2167 bytes
"regexp.h" compares a "char" expression against 255.  On a machine with
8-bit signed "char"s and a correct C compiler, this comparison will always
indicate that the value of the expression is not equal to 255.  What it
intended to do was mask the character with 0377 and then do the comparison.
Here's a context diff of the fix, with two free "lint" fixes courtesy of Doug
Gwyn:

*** /archbeluga/s5r2/usr/include/regexp.h	Sat Nov  5 09:42:54 1983
--- /tmp/regexp.h	Tue Mar 25 20:59:36 1986
***************
*** 220,225
  			*ep++ = c;
  		}
  	}
  }
  
  step(p1, p2)

--- 220,226 -----
  			*ep++ = c;
  		}
  	}
+ 	/*NOTREACHED*/
  }
  
  step(p1, p2)
***************
*** 400,405
  
  		}
  	}
  }
  
  static

--- 401,407 -----
  
  		}
  	}
+ 	/*NOTREACHED*/
  }
  
  static
***************
*** 406,411
  getrnge(str)
  register char *str;
  {
  	low = *str++ & 0377;
  	size = (*str == 255)? 20000: (*str &0377) - low;
  }

--- 408,415 -----
  getrnge(str)
  register char *str;
  {
+ 	register int sizecode;
+ 
  	low = *str++ & 0377;
  	sizecode = *str & 0377;
  	if (sizecode == 255)
***************
*** 407,411
  register char *str;
  {
  	low = *str++ & 0377;
! 	size = (*str == 255)? 20000: (*str &0377) - low;
  }

--- 411,419 -----
  	register int sizecode;
  
  	low = *str++ & 0377;
! 	sizecode = *str & 0377;
! 	if (sizecode == 255)
! 		size = 20000;
! 	else
! 		size = sizecode - low;
  }
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.arpa	(yes, really)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads