2015-05-31 A week or two ago, I discovered a strange program behavior. I had two files: edtut.pdf, which contains a beginner's tutorial to ed(1), and EdTut.pdf, which contains an advanced text. After I had skimmed through the beginner's text, I wanted to take a look at the advanced text. Therefore I typed: ESC-k-w-~-Enter. (I.e. I switched to the control mode of my shell's vi readline, selected the previous commandline, went one word forward to the first ar- gument (which was the filename), toggled the case of the first letter and executed. What I expected to happen: xpdf opens with the advanced text. What actually did happen: xpdf opens with the beginner's text. What should have happen: xpdf fails with file not found. My expectation was wrong, because I haven't seen that the `T' was capitalized as well. I would have realized my fault quickly if xpdf would have complained that no such file exists. However, it presented my the ``wrong'' file, which irritated my greatly. I tried it multiple times (because I was so irritated), until I took the other way and typed ``xpdf E''. Then xpdf opened with the correct file (of course) and I was sure, at least, that it weren't two copies of the same file. It became quickly clear, that xpdf does some magic with letter cases. Until today, I found no time to take a deeper look. Now, I took the source code of xpdf-3.03 and started digging. This is the full shell history of this digging session: tar xzf xpdf-3.03.tar.gz cd xpdf-3.03 ls sloccount . grep -r '\
getCString(), "rb"))) { 95 fileName2 = fileName->copy(); 96 fileName2->lowerCase(); 97 if (!(file = fopen(fileName2->getCString(), "rb"))) { 98 fileName2->upperCase(); 99 if (!(file = fopen(fileName2->getCString(), "rb"))) { 100 error(errIO, -1, "Couldn't open file '{0:t}'", fileName); 101 delete fileName2; 102 errCode = errOpenFile; 103 return; 104 } 105 } 106 delete fileName2; 107 } The ``safety check'' for other lowercasing code that might be relevant brought me to the CHANGES file that contains the follow- ing entry for version 0.7 of 1997-05-28: If file open fails, try lower-casing and upper-casing the file name. ... quite an interesting code reading trip this was. :-) http://marmaro.de/lue/ markus schnalke