Whether Gain is right or not, this line should be comparing *quote against '\0', not against NULL (you are likely to get compiler warnings from some compilers otherwise)