Fix bugs and make code tinier

- Fixed bug where stdio eof wasn't being sticky
- Fixed bug where fseeko() wasn't clearing eof state
- Removed assert() usage from libc favoring _unassert() / _npassert()
This commit is contained in:
Justine Tunney 2022-10-09 22:38:28 -07:00
parent 9b7c8db846
commit d5910e2673
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
115 changed files with 510 additions and 290 deletions

View file

@ -56,6 +56,7 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/limits.h"
#include "third_party/regex/tre.inc"
@ -393,7 +394,7 @@ static reg_errcode_t tre_tnfa_run_parallel(const tre_tnfa_t *tnfa,
reach_next_i++;
} else {
assert(reach_pos[trans_i->state_id].pos == pos);
_unassert(reach_pos[trans_i->state_id].pos == pos);
/* Another path has also reached this state. We choose
the winner by examining the tag values for both
paths. */
@ -520,7 +521,7 @@ typedef struct tre_backtrack_struct {
#define BT_STACK_POP() \
do { \
int i; \
assert(stack->prev); \
_unassert(stack->prev); \
pos = stack->item.pos; \
str_byte = stack->item.str_byte; \
state = stack->item.state; \
@ -846,8 +847,8 @@ static void tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
submatches. */
i = 0;
while (i < tnfa->num_submatches && i < nmatch) {
if (pmatch[i].rm_eo == -1) assert(pmatch[i].rm_so == -1);
assert(pmatch[i].rm_so <= pmatch[i].rm_eo);
if (pmatch[i].rm_eo == -1) _unassert(pmatch[i].rm_so == -1);
_unassert(pmatch[i].rm_so <= pmatch[i].rm_eo);
parents = submatch_data[i].parents;
if (parents != NULL)