diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d3f9d6c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lisp-interpreter"] + path = lisp-interpreter + url = https://github.com/justinmeiners/lisp-interpreter.git diff --git a/Makefile b/Makefile deleted file mode 100644 index 4b99214..0000000 --- a/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -## -# TEST -# -# @file -# @version 0.1 - -BELUGA_OUTPUT=bin - -BUILD_FLAGS=-Wall -Wextra -pedantic - -build: main.c src/* - if [ ! -d $(BELUGA_OUTPUT) ]; then mkdir $(BELUGA_OUTPUT); fi - $(CC) main.c -o $(BELUGA_OUTPUT)/beluga src/* $(BUILD_FLAGS) - -DEBUG_FLAGS=-Wall -Wextra -pedantic -Werror -fsanitize=address -g - -debug: main.c src/* - if [ ! -d $(BELUGA_OUTPUT) ]; then mkdir $(BELUGA_OUTPUT); fi - $(CC) main.c -o $(BELUGA_OUTPUT)/beluga src/* $(DEBUG_FLAGS) - -doc: - if [ ! -d doc/ ]; then mkdir doc; fi - doxygen - -clean: - rm -r $(BELUGA_OUTPUT) - rm -rf doc/ - rm -rf tmp/ - -all: build doc - -# end diff --git a/lisp-interpreter b/lisp-interpreter new file mode 160000 index 0000000..366bfb9 --- /dev/null +++ b/lisp-interpreter @@ -0,0 +1 @@ +Subproject commit 366bfb9bdbf0b268bf299cc25178da0d6e626c59 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..5018014 --- /dev/null +++ b/meson.build @@ -0,0 +1,56 @@ +project('editor', 'c', + version : '1.0.0', + default_options : [ + 'warning_level=2', + 'c_std=c99' + ] +) + +# Check if we're using Clang and add Clang-specific options +cc = meson.get_compiler('c') +if cc.get_id() == 'clang' + add_project_arguments([ + '-Wextra', + '-Wpedantic', + '-Wno-unused-parameter', + '-fcolor-diagnostics' # Colored output + ], language : 'c') + + # Add debug options for debug builds + if get_option('buildtype') == 'debug' + add_project_arguments([ + '-fsanitize=address', # AddressSanitizer + '-fsanitize=undefined', # UndefinedBehaviorSanitizer + '-g3', # Full debug info + '-O0' # No optimization + ], language : 'c') + + add_project_link_arguments([ + '-fsanitize=address', + '-fsanitize=undefined' + ], language : 'c') + endif +endif + +# Include directory +inc_dir = include_directories('include') + +# Source files +src_files = files( + 'main.c', + 'src/append_buffer.c', + 'src/editor_op.c', + 'src/file_io.c', + 'src/init.c', + 'src/input.c', + 'src/output.c', + 'src/row_op.c', + 'src/terminal.c' +) + +# Executable +executable('editor', + src_files, + include_directories : inc_dir, + install : true +) diff --git a/src/file_io.c b/src/file_io.c index 0bde548..057848b 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -8,6 +8,11 @@ #include #include +extern char *strdup(const char *); +extern ssize_t getline(char **restrict lineptr, size_t *restrict n, + FILE *restrict stream); +extern int ftruncate(int fd, off_t length); + char *editorRowsToString(struct editorConfig *E, int *buffer_len) { int tot_len = 0; int j;