Oh I was stupid. Never mind.
So how about this, leave the two functions, but defined a separated global string:
`const char * VALID_FORMAT_SPECIFIER_IN_FILENAME="diuoxX";` and use `strchr` instead of comparing with 'd'