Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Apr 23, 2024
1 parent ef05357 commit 7d5ab1c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions cobc/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
function to keep the depth of the recursion. */

/* #define DEBUG_REPLACE_TRACE */
/* #define DEBUG_REPLACE */
/* #define DEBUG_REPLACE */

#ifdef DEBUG_REPLACE_TRACE
#define DEBUG_REPLACE
Expand Down Expand Up @@ -341,8 +341,6 @@ char * string_of_##kind##_list(const struct cb_##kind##_list *list) \
return text_list_string; \
}

/* string_of_token_list (...) */
STRING_OF_LIST(token)
/* string_of_text_list (...) */
STRING_OF_LIST(text)

Expand Down Expand Up @@ -411,7 +409,7 @@ static void
ppecho_switch_token_queue (WITH_DEPTH struct cb_replacement_state *repls,
struct cb_token_queue *q)
{
#ifdef DEBUG_REPLACE_TRACE
#if 0
fprintf (stderr, "%sppecho_switch_token_queue(%s, %s)\n",
DEPTH, repls->name, string_of_token_list(p));
#endif
Expand Down Expand Up @@ -513,7 +511,7 @@ check_replace (WITH_DEPTH struct cb_replacement_state* repls,
/* remove the text from the current stream */
const char* text;
const char* token;
token_queue_take (MORE_DEPTH repls->token_queue, &text, &token);
token_queue_take (repls->token_queue, &text, &token);

/* pass it to the next stream */
ppecho_switch (MORE_DEPTH repls, text, token);
Expand Down Expand Up @@ -544,7 +542,7 @@ check_replace (WITH_DEPTH struct cb_replacement_state* repls,

/* MATCH */
/* remove the text from the current stream */
token_queue_remove (MORE_DEPTH repls->token_queue, 1);
token_queue_remove (repls->token_queue, 1);

/* perform a partial replacement on the text,
and pass it to the next stream */
Expand Down Expand Up @@ -599,8 +597,8 @@ check_replace_all (WITH_DEPTH
DEPTH, repls->name);
fprintf (stderr, "%s new_text = %s,\n", DEPTH,
string_of_text_list(new_text));
fprintf (stderr, "%s texts = %s,\n", DEPTH,
string_of_token_list(texts));
// fprintf (stderr, "%s texts = %s,\n", DEPTH,
// string_of_token_list(texts));
fprintf (stderr, "%s src = %s,\n", DEPTH,
string_of_text_list(src));
fprintf (stderr, "%s)\n", DEPTH);
Expand Down Expand Up @@ -751,7 +749,7 @@ is_word (WITH_DEPTH const char *s) {

static void
add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,
int prequeue, const char* text, const char* token
int prequeue, const char* text, const char* token
)
{
/* CHECKME: this function takes >35% of the parsing cpu instructions,
Expand Down Expand Up @@ -792,7 +790,7 @@ add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,

} else {

if (repls->token_queue == NULL
if ( token_queue_is_empty (repls->token_queue)
&& is_space_or_nl (text[0]) ) {
ppecho_switch (MORE_DEPTH repls, text, token);
} else {
Expand All @@ -801,8 +799,9 @@ add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,
"%s add_text_to_replace () -> push_text()\n",
DEPTH);
#endif
token_queue_put(MORE_DEPTH repls->token_queue,
1, /* TODO strdup check */
token_queue_put(repls->token_queue,
/* use strdup if we are in the COPY phase */
repls->ppecho == CB_PPECHO_REPLACE ? 1 : 0,
text, token);

do_replace (MORE_DEPTH repls);
Expand Down

0 comments on commit 7d5ab1c

Please sign in to comment.