Monday, October 8, 2007

svn_load_dirs.pl woes

I use subversion to manage all software projects. It is a nice utility, much better than the commercial SourceSafe. And it is free. Have not encounter any problems in the past three years.

Today I am trying to upgrade boost from 1.33 to 1.34. There are a lot of changes between the two versions, so it is not possible to manually change them. Furthermore, although WinMerge is nice to show all the differences, it does not understand subversion command. If a file exists in 1.34 but not in 1.33, the correct command is "svn copy" rather than copy.

My installation does not have this magic file svn_load_dirs.pl. I grabbed it from collab: http://svn.collab.net/repos/svn/tags/1.4.2/contrib/client-side/svn_load_dirs.pl.in. I did a copy and paste, and run the command, it gives me an error:

'SVN_BINDIR@' is not recognized as an internal or external command,

Not good. Look further I found the file extension ends with .in. So some work needs to be done to convert it to .pl. Open the file, I found this line:

# Specify the location of the svn command.
my $svn = '@SVN_BINDIR@/svn';

Cool. Changed the line to

my $svn = 'C:\Program Files\Subversion\bin\svn.exe';

and it worked properly.

Thursday, October 4, 2007

Default C/C++ char is signed

Programmer often forgot that the default char type is signed, instead of unsigned. In VC, /J gives the char unsigned. We ran into a problem this week:

if ( character > 126 character < 32) {
sprintf(sTemp, "%02X", character);
os << '#' <<>

In VC 2003, sTemp gives "FFFFFFFFFac" for character 0xac. To correct the issue, convert it to unsigned integer type, such as
sprintf(sTemp, "%02X", (unsigned char)character );

Note that this statement

if ( character > 126 character <>

implies that the character is unsigned type. This variable should be declared as unsigned char at the beginning.