diff --git a/CMakeLists.txt b/CMakeLists.txt index fbe7dd0..1c8aafa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,10 @@ if(ENABLE_DEBUG) add_definitions("-DBRAINFUCK_EXTENSION_DEBUG") endif() +configure_file ( + "${PROJECT_SOURCE_DIR}/include/brainfuck.h" + "${PROJECT_SOURCE_DIR}/include/brainfuck.h" +) include_directories(include/) add_definitions("-Wall -Wextra -O2 -std=c89") add_library(libbrainfuck STATIC src/brainfuck.c) diff --git a/include/brainfuck.h b/include/brainfuck.h index caaf4ee..bb57d67 100644 --- a/include/brainfuck.h +++ b/include/brainfuck.h @@ -16,7 +16,9 @@ #ifndef BRAINFUCK_H #define BRAINFUCK_H -#define BRAINFUCK_VERSION "2.6.6" +#define BRAINFUCK_VERSION_MAJOR @brainfuck_VERSION_MAJOR@ +#define BRAINFUCK_VERSION_MINOR @brainfuck_VERSION_MINOR@ +#define BRAINFUCK_VERSION_PATCH @brainfuck_VERSION_PATCH@ #define BRAINFUCK_TAPE_SIZE 30000 /* 1: EOF leaves cell unchanged; 0: EOF == 0; 1: EOF == 1 */ #define BRAINFUCK_EOF_BEHAVIOR 1 @@ -42,7 +44,7 @@ */ typedef struct BrainfuckInstruction { /** - * The difference between the value of the byte at the currect pointer and + * The difference between the value of the byte at the currect pointer and * the value we want. */ int difference; diff --git a/src/main.c b/src/main.c index a431c83..9625b32 100644 --- a/src/main.c +++ b/src/main.c @@ -47,8 +47,8 @@ void print_usage(char *name) { * Print the version information. */ void print_version() { - fprintf(stderr, "brainfuck %s (%s, %s)\n", BRAINFUCK_VERSION, __DATE__, - __TIME__); + fprintf(stderr, "brainfuck %d.%d.%d (%s, %s)\n", BRAINFUCK_VERSION_MAJOR, + BRAINFUCK_VERSION_MINOR, BRAINFUCK_VERSION_PATCH, __DATE__, __TIME__); fprintf(stderr, "Copyright (c) 2016 Fabian Mastenbroek.\n"); fprintf(stderr, "Distributed under the Apache License Version 2.0.\n"); } @@ -105,8 +105,8 @@ int run_string(char *code) { * Run the brainfuck interpreter in interactive mode. */ void run_interactive_console() { - printf("brainfuck %s (%s, %s)\n", BRAINFUCK_VERSION, __DATE__, - __TIME__); + printf("brainfuck %d.%d.%d (%s, %s)\n", BRAINFUCK_VERSION_MAJOR, + BRAINFUCK_VERSION_MINOR, BRAINFUCK_VERSION_PATCH, __DATE__, __TIME__); #ifdef BRAINFUCK_EXTENSION_DEBUG printf("Use # to inspect tape\n"); #endif @@ -117,7 +117,7 @@ void run_interactive_console() { initialize_readline(); while(1) { - line = readline(">> "); + line = readline(">> "); if (line) { /* Empty string crashes on some OSs/versions of editline */ if (line[0] == '\0') { @@ -127,11 +127,11 @@ void run_interactive_console() { char* expansion; int result; - + result = history_expand(line, &expansion); if (result >= 0 && result != 2 ) { add_history(expansion); } free(expansion); - } else { + } else { /* EOF */ break; }