Page History
- 2007-Nov-07 11:03 ono
- 2005-Dec-31 20:46 cpb
- 2005-Dec-31 16:00 cpb
- 2005-Aug-21 14:22 cpb
- 2005-Aug-21 03:22 cpb
These are more like observations from a latecomer, but better than nothing. CvstracArchitecture is a big picture overview. This talks about the nitty-gritty coding details.
- CVSTrac source uses two spaces for indentation, no tabs
- braces are a modified K&R. Generally, there should be no whitespace between the trailing paren and the leading brace. i.e.
void function(args){ if( condition ){ } }
- In the case of else and else if keywords, also eliminate extra whitespace:
if( condition ){ }else if( condition2 ){ }else{ }
- whithin parens, rules seem to be a bit more variable. For example, if and while statements use internal whitespace:
if( condition ){ while( v[i] ) i++; }
but for loops are a bit different:
for(i=0; i<40; i++){ }
- CVSTrac has a magical preprocessor which extracts HTML strings prefixed inline by '@' characters and basically turns them into cgi_printf() calls. CvstracArchitecture discusses this a bit more.
- variable naming is partially Hungarian style.
- 'z' prefixes NUL-terminated strings
- 'az' prefixes an array of 'z' strings. 'az' strings also appear to be NULL terminated.
- 'p' prefixes a pointer to something
- 'n' occasionally prefixes integers, but usually not.
- commonly used variable names
- tn is a ticket number
- cn is a change/checkin number
- rn is a report number
- CVSTrac doesn't worry about memory management! It's assumed that a CVSTrac instance will live only long enough to serve out a request and then resources will be reclaimed (AKA garbage collection by exit()). As such, you frequently see constructs like:
zPath = mprintf("%s/%s", zDir, zFile);
without a corresponding free(). The only time memory is really a concern happens when a large amount of activity happens in a loop. In such instances, free() or db_query_free() will be used.
- CVSTrac cares about security. This means dynamic memory allocation where possible, really large static buffers with limits on the size of copies, heavy use of the %q format (as found in mprintf() and db_query()), and a lot of heavily used helper functions to manage all this.