readDoubleValue improvement

In the JuceCharacterFunctions, readDoubleValue(CharPointerType &text) currently only works correctly if the input string starts with the number that one wants to extract (i.e. the format “0.34 dB” returns 0.34, but the format “Q: 0.123” returns 0). I’d suggest to replace the simple break in lines 255 and 314 in juce_CharacterFunctions.h with if (*text == 0) break; else text++;

Erm… no!

This function’s job is to parse a number string that you give it. If you give it a string that isn’t a number then you can’t expect this function to magically know how to deal with that.

If you want it to skip over some arbitrary leading characters then that’s your job as the caller, because only you know the constraints on what you want to happen in that situation.

Your suggestion would also be a silent breaking change to existing code! There’s going to be a lot of places out there where people rely on this function to fail if it gets given some non-numeric input!

If you give it a string containing no digits at all, it would return 0, just as before. But ok, I’ll adapt my code then.

Yes, it’ll return 0 when it fails to find a number, but it won’t advance the pointer.

Maybe that’s not clear enough from the description, but what makes it useful is the fact that it consumes as many chars as the number contains, and updates the pointer for the caller to see what happened.

I see… I came from String::getDoubleValue so that additional info is lost in that case. Anyway, I think this should be added to that method’s description then, to me it seems counterintuitive that only leading digits are consumed.