Portability fix from Joachim Schmitz. Closes bug #546.