An exasperating bug for your amusement.

R

Robbie Hatley

Here's a bug I found in a program of mine, after much
exasperation trying to find out why this wasn't working.
You all might find it educational and/or entertaining.

I had this line of code:

rhdir::LoadFileList(RawFiles, "qgv??-raw.txt");

Basically, it looks for files in the current directory
named "qgv??-raw.txt" (where the question marks are
being used in the context of wildcard characters),
and loads the names of all such files into a
std::list<std::string> object named "RawFiles".
Seems very simple.

And yet, although I had a bunch of files named:

qgv17-raw.txt
qgv32-raw.txt
qgv88-raw.txt

none of them were getting into the list. What went
wrong?

You ain't gonna believe this....

The function LoadFileList() was actually looking for
a file named "qgv~raw.txt", and since there was no
such file, the "RawFiles" list remained empty.

Why?

The answer is: the character sequence ??- is NOT
three characters! It's ONE character, a tilde ~ .
It's one of those blasted "triglyph" thingies left
over from the days when certain characters weren't
actually on keyboards and had to be "faked".

So I backslashed the question marks:

rhdir::LoadFileList(RawFiles, "qgv\?\?-raw.txt");

and the program worked fine. Live and learn.
 
H

Howard

Robbie Hatley said:
Here's a bug I found in a program of mine, after much
exasperation trying to find out why this wasn't working.
You all might find it educational and/or entertaining.

I had this line of code:

rhdir::LoadFileList(RawFiles, "qgv??-raw.txt");

Basically, it looks for files in the current directory
named "qgv??-raw.txt" (where the question marks are
being used in the context of wildcard characters),
and loads the names of all such files into a
std::list<std::string> object named "RawFiles".
Seems very simple.

And yet, although I had a bunch of files named:

qgv17-raw.txt
qgv32-raw.txt
qgv88-raw.txt

none of them were getting into the list. What went
wrong?

You ain't gonna believe this....

The function LoadFileList() was actually looking for
a file named "qgv~raw.txt", and since there was no
such file, the "RawFiles" list remained empty.

Why?

The answer is: the character sequence ??- is NOT
three characters! It's ONE character, a tilde ~ .
It's one of those blasted "triglyph" thingies left
over from the days when certain characters weren't
actually on keyboards and had to be "faked".

So I backslashed the question marks:

rhdir::LoadFileList(RawFiles, "qgv\?\?-raw.txt");

and the program worked fine. Live and learn.

One of my compilers often complains that I've got "invalid triglyphs",
because in my comments when developing I often put ??? at the end of a
comment when I'm not sure of what I've written and want to come back and
revisit that point later. But I found that the compiler has an option to
turn off triglyph recognition entirely. Perhaps yours has that option?

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top