if s is not empty when all input is complete, then unmatched parentheses remain

if(!empty(&s))

*pvalid = FALSE;