tidy up zend_extensions.c so that the logic makes good sense and the output is sane