static int tokque_print_one(struct FSQLF_queue *tq, FILE *fout, struct FSQLF_out_buffer *bout) { if (FSQLF_queue_empty(tq)) { return 0; // queue was empty, so printing was not possible } else if (tq->length == 1) { struct FSQLF_token *tok; tok = (struct FSQLF_token *) FSQLF_queue_peek_n(tq, 0); struct fsqlf_kw_conf prev = {{0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0}; FSQLF_print(fout, bout, tok->indent, tok->text, tok->kw_setting, &prev); return 1; // success - printing was made } else { assert(tq->length >= 2); struct FSQLF_token *tok, *prev; prev = (struct FSQLF_token *) FSQLF_queue_peek_n(tq, 0); tok = (struct FSQLF_token *) FSQLF_queue_peek_n(tq, 1); FSQLF_print(fout, bout, tok->indent, tok->text, tok->kw_setting, prev->kw_setting); if (prev->token_class == FSQLF_TOKEN_CLASS_TXT) { free(prev->kw_setting); } FSQLF_queue_drop_head(tq); FSQLF_clear_token(tok); return 1; // success - printing was made } }
void FSQLF_delete_token(struct FSQLF_token **tok) { FSQLF_clear_token(*tok); free((*tok)); (*tok) = NULL; }