DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using programming tools

Using cb

When developing software, it is easy to forget to format the code so it is both easy to read and the program logic is apparent. Running a program through cb (C program beautifier) corrects this problem. For example, some of the code in testcase.c is less than beautiful:

 57 int main(argc, argv) int argc; char *argv[]; { char	buf[BUFFERSIZE], match;
 58 /* Check command line arguments. */ 
 59 if (argc < 2) match = ' ';
 60 /* No command line argument, match all words. */
 61 else   match = *++argv[1];	/* Match the char after the first - */
While this code fragment uses legal C syntax that is readily understood by the compiler, it is hard for a human to understand. When the code is run through cb with the -s option specified, the reformatted code is easier to follow and understand:
 73 int	main(argc, argv)
 74 int	argc;
 75 char	*argv[];
 76 {
 77 	char	buf[BUFFERSIZE], match;
 78 	/* Check command line arguments. */
 79 	if (argc < 2)
 80 		match = ' ';
 81 		/* No command line argument, match all words. */
 82 	else
 83 		match = *++argv[1];	/* Match the char after the first - */
For more information, see cb(CP).
Next topic: Using cscope
Previous topic: Analyzing the code

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003