From 975cb4f01b4973a3b2e8dd63bad90e9c6764be93 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 20 Nov 2023 20:52:40 -0500 Subject: [PATCH] Fixed another tiny bug. --- chapter/chapter_4.c | 14 +++++++++++--- chapter/chapter_5.c | 12 +++++++++--- program/example.c | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/chapter/chapter_4.c b/chapter/chapter_4.c index be0e1fd..19f8d14 100644 --- a/chapter/chapter_4.c +++ b/chapter/chapter_4.c @@ -174,8 +174,15 @@ static int syntax_select (char * string, int * length) { // it's best to modify only variable 'length', hence we check with 'string_compare_limit' function. for (select = offset = 0; select != syntax_count; ++select) { // We're looping defined syntax rules: if (syntax_enrange [select] == FALSE) { // Choosing the comparisson: - if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) { // Limiting our string comparisson. - break; // If strings are same, we exit the loop. + if (syntax_derange [select] == FALSE) { + if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) { // Limiting our string comparisson. + break; // If strings are same, we exit the loop. + } + } else { + if ((string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) + && (character_compare_array (string [offset + string_length (syntax_begin [select])], syntax_end [select]) == TRUE)) { + break; + } } } else { // Else, we compare any character. if (character_compare_array (string [offset], syntax_begin [select]) == TRUE) { // With our obviously named function... @@ -209,7 +216,8 @@ static int syntax_select (char * string, int * length) { break; } } else { - if (string_compare (syntax_end [select], "") == TRUE) { // And here's our empty string exception. + if (syntax_end [select] [0] == CHARACTER_NULL) { // And here's our empty string exception. + * length = offset; break; } if (character_compare_array (string [offset], syntax_end [select]) == TRUE) { diff --git a/chapter/chapter_5.c b/chapter/chapter_5.c index a5370c4..93d514a 100644 --- a/chapter/chapter_5.c +++ b/chapter/chapter_5.c @@ -13,11 +13,17 @@ It is distributed in the hope that it will be useful or harmful, it really depen /* static void (* game_action [GAME_ACTION_COUNT]) (game_t * game, player_t * player); */ -static number_t game_is_active (game_t * game) { return (game->active = curses_active); }/* +static number_t game_is_active (game_t * game) { return (game->active = curses_active); } + +/* +So, what are actually getters and setters, and why you should never use them? Lets explain. +@C static number_t game_get_screen_width (game_t * game) { return (game->screen_width); } static number_t game_get_screen_height (game_t * game) { return (game->screen_height); } static number_t game_set_screen_width (game_t * game, number_t width) { return (game->screen_width = width); } -static number_t game_set_screen_height (game_t * game, number_t height) { return (game->screen_height = height); }*/ +static number_t game_set_screen_height (game_t * game, number_t height) { return (game->screen_height = height); } +@ +*/ static void game_configure (game_t * game, player_t * player) { curses_configure (); @@ -46,7 +52,7 @@ void play_game (void) { game_configure (& game, & player); - while (game_is_active (& game) && curses_active) { + while (game_is_active (& game)) { game_synchronize (& game, & player); } } diff --git a/program/example.c b/program/example.c index 3c10dcb..8d2a298 100644 --- a/program/example.c +++ b/program/example.c @@ -32,6 +32,8 @@ static void data_echo (void) { char byte [4] = " "; int i; + char character; + _meme = MEME = meme; for (i = 0; i != data [0]; ++i) {