views:

174

answers:

1

I have a piece of code in front of me that iterates through a long list of urls and something is going wrong when those urls include a certain type of document. I don't want to see every iteration, so I've set up a conditional breakpoint.

The trouble is that I'm not a C++ programmer so I'm slightly having to fish around to work out how to do what I want and I may be doing something obviously wrong.

My current condition is thus:

(strstr( url, "xlsx") == 0x00000000)

This should mean every time the url ( which is a UNICODE_char* ) doesn't contain the literal "xlsx" strstr will return a null pointer which should match the condition, as I understand it. I actually want it the other way round in the long term, but as there are only a couple of "xlsx" urls and I want to check it is working I have it this way up for now.

Well, my condition is not being met or at least the breakpoint is not being triggered.

Assuming that I was doing something wrong I copied the same value as a watch expression and set an unconditional breakpoint on the line before. The result looks like this as I step past my coinditional breakpoint:

Name                                 | Value
================================================
(strstr( url, "xlsx") == 0x00000000) | true

So apparently my condition can be true as far as the watch window is concerned but not trigger the conditional breakpoint.

In order to experiment further I tried flipping the condition over so it was

(strstr( url, "xlsx") != 0x00000000)

As far as the conditional breakpoint is concerned this is also false, which seems a bit funny as that would mean it neither equalled nor didn't equal the null pointer value.

Is this some unusual property of null values in C++? Is there something really obvious I'm missing or some quirk of the language that is causing me to totally miss the boat on this one?

+1  A: 

If your url is a unicode string, have you tried using wcsstr?

Paul Baker
Nope, I haven't at all - as I say not a C++ programmer so although I've got a pretty good range of languages at my disposal and I can follow the code through I don't really know the library. Now I come to try it, though, the outcome appears to be the same.
glenatron