C style guide

Mark Brader msb at sq.sq.com
Sun Dec 17 22:08:31 AEST 1989


The revised Indian Hill style guide recently posted here is excellent
in many respects, but the example function copy() in section 14 contains
no fewer than four bugs, of which three are in the same line.  Here's a
patch which I have tested and which fixes all of them.  Finding them
without reading the patch is left as an exercise for the reader.

Patch follows:


*** ihill.old	Sun Dec 17 12:55:21 1989
--- ihill	Sun Dec 17 12:57:38 1989
***************
*** 1478,1490 ****
  .\"
  {
! 	char *retval = dest;
  
! 	while (*dest++ = *++src && maxsize-- > 0)
! 		;		/* VOID */
  
! 	if (maxsize == 0)
! 		retval = NULL;
! 
! 	return (retval);
  }
  .Ee
--- 1478,1488 ----
  .\"
  {
! 	char *p = dest;
  
! 	while (maxsize-- > 0)
! 		if ((*p++ = *src++) == '\\\\0')
! 			return dest;
  
! 	return (char *) NULL;
  }
  .Ee


-- 
Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb at sq.com
	"I'm a little worried about the bug-eater," she said.  "We're embedded
	in bugs, have you noticed?"		-- Niven, "The Integral Trees"

This article is in the public domain.



More information about the Comp.lang.c mailing list