Skip to content

Commit

Permalink
Fixed reported version number by autogenerating it with CMake (#45)
Browse files Browse the repository at this point in the history
Auto generate version mumber from CMakeList.txt
  • Loading branch information
rien333 authored and fabianishere committed Aug 25, 2017
1 parent f61a755 commit cb8ec36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions include/brainfuck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand All @@ -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') {
Expand All @@ -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;
}
Expand Down

0 comments on commit cb8ec36

Please sign in to comment.