Quality software

I don’t normally write about programming stuff here (it scares my relatives) but this is too good to ignore.  I’m managing a project and there’s this one bit of legacy code:

// write the message to a buffer
char buffer[N];
sprintf(buffer, "%s: %snr",header,value);

// remove the carriage return
int len = strlen(buffer);
buffer[len-2] = 0;

For the C#-challenged, what it’s doing is adding a carriage return/linefeed pair and then stripping it right back out.

I’m going to send this along to The Daily WTF and see if they like it.