Browse Source

Fixed another tiny bug.

master^2
Ognjen Milan Robovic 5 months ago
parent
commit
975cb4f01b
3 changed files with 22 additions and 6 deletions
  1. +11
    -3
      chapter/chapter_4.c
  2. +9
    -3
      chapter/chapter_5.c
  3. +2
    -0
      program/example.c

+ 11
- 3
chapter/chapter_4.c View File

@@ -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) {


+ 9
- 3
chapter/chapter_5.c View File

@@ -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);
}
}


+ 2
- 0
program/example.c View File

@@ -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) {


Loading…
Cancel
Save