From 8573bc1c5c79ba98a7ce04a3b16d4dd57f14a7b8 Mon Sep 17 00:00:00 2001 From: night0721 Date: Tue, 5 Nov 2024 00:02:09 +0000 Subject: [PATCH] Resolve compiler warnings and udpate CFLAGS --- Makefile | 4 ++-- include/editor.h | 14 +++++++------- include/io.h | 6 +++--- include/syntax.h | 2 +- include/term.h | 4 ++-- src/editor.c | 14 +++++++------- src/io.c | 6 +++--- src/syntax.c | 2 +- src/term.c | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 473192c..5f33e25 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ TARGET = vip PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin -CFLAGS = -O3 -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall +CFLAGS = -Os -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE SRC != find src -name *.c INCLUDE = include $(TARGET): $(SRC) config.h - $(CC) $(SRC) config.h -o $@ $(CFLAGS) -I$(INCLUDE) -I. + $(CC) $(SRC) -o $@ $(CFLAGS) -I$(INCLUDE) -I. dist: mkdir -p $(TARGET)-$(VERSION) diff --git a/include/editor.h b/include/editor.h index b68215c..60e861d 100644 --- a/include/editor.h +++ b/include/editor.h @@ -1,16 +1,16 @@ #ifndef EDITOR_H_ #define EDITOR_H_ -void refresh_screen(); +void refresh_screen(void); void move_cursor(int key); -void scroll(); +void scroll(void); void insert_char(int c); -void insert_new_line(); -void shift_new_line(); -void del_char(); -void init_editor(); +void insert_new_line(void); +void shift_new_line(void); +void del_char(void); +void init_editor(void); void open_editor(char *filename); char *prompt_editor(char *prompt, void (*callback)(char *, int)); -void find_editor(); +void find_editor(void); #endif diff --git a/include/io.h b/include/io.h index 6899136..15d0c31 100644 --- a/include/io.h +++ b/include/io.h @@ -1,9 +1,9 @@ #ifndef IO_H_ #define IO_H_ -int read_key(); -void save_file(); -void process_key(); +int read_key(void); +void save_file(void); +void process_key(void); void draw_rows(struct abuf *ab); #endif diff --git a/include/syntax.h b/include/syntax.h index 9e42d04..db6026f 100644 --- a/include/syntax.h +++ b/include/syntax.h @@ -21,6 +21,6 @@ typedef struct language { int is_separator(int c); void update_highlight(row *row); char *syntax_to_color(int hl, size_t *len); -void select_syntax_highlight(); +void select_syntax_highlight(void); #endif diff --git a/include/term.h b/include/term.h index 9affe20..c4ea7d7 100644 --- a/include/term.h +++ b/include/term.h @@ -4,8 +4,8 @@ #define CTRL_KEY(k) ((k) & 0x1f) void die(const char *s); -void reset_term(); -void setup_term(); +void reset_term(void); +void setup_term(void); int get_cursor_position(int *rows, int *cols); int get_window_size(int *rows, int *cols); diff --git a/src/editor.c b/src/editor.c index 2350b51..dab4672 100644 --- a/src/editor.c +++ b/src/editor.c @@ -12,7 +12,7 @@ extern editor vip; -void refresh_screen() +void refresh_screen(void) { scroll(); @@ -68,7 +68,7 @@ void move_cursor(int key) } } -void scroll() +void scroll(void) { vip.rx = 0; if (vip.cy < vip.rows) { @@ -97,7 +97,7 @@ void insert_char(int c) vip.cx++; } -void insert_new_line() +void insert_new_line(void) { if (vip.cx == 0) { insert_row(vip.cy, "", 0); @@ -116,14 +116,14 @@ void insert_new_line() /* * 'o' in vim */ -void shift_new_line() +void shift_new_line(void) { insert_row(vip.cy + 1, "", 0); vip.cy++; vip.cx = 0; } -void del_char() +void del_char(void) { if (vip.cy == vip.rows) return; if (vip.cx == 0 && vip.cy == 0) return; @@ -140,7 +140,7 @@ void del_char() } } -void init_editor() +void init_editor(void) { vip.cx = 0; vip.cy = 0; @@ -280,7 +280,7 @@ void find_callback(char *query, int key) } } -void find_editor() +void find_editor(void) { int tmp_cx = vip.cx; int tmp_cy = vip.cy; diff --git a/src/io.c b/src/io.c index c9b337d..ee65050 100644 --- a/src/io.c +++ b/src/io.c @@ -10,7 +10,7 @@ #include "vip.h" #include "bar.h" -int read_key() +int read_key(void) { int nread; char c; @@ -65,7 +65,7 @@ int read_key() } } -void save_file() +void save_file(void) { if (vip.filename == NULL) { vip.filename = prompt_editor("Save as: %s", NULL); @@ -94,7 +94,7 @@ void save_file() set_status_bar_message("Error saving: %s", strerror(errno)); } -void process_key() +void process_key(void) { int c = read_key(); switch (c) { diff --git a/src/syntax.c b/src/syntax.c index 02cb594..642ea21 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -185,7 +185,7 @@ char *syntax_to_color(int hl, size_t *len) } } -void select_syntax_highlight() +void select_syntax_highlight(void) { vip.syntax = NULL; if (vip.filename == NULL) return; diff --git a/src/term.c b/src/term.c index 94f7869..48f8e30 100644 --- a/src/term.c +++ b/src/term.c @@ -15,7 +15,7 @@ void die(const char *s) exit(1); } -void reset_term() +void reset_term(void) { if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) { die("tcsetattr"); @@ -26,7 +26,7 @@ void reset_term() /* * Setup terminal */ -void setup_term() +void setup_term(void) { write(STDOUT_FILENO, "\x1b[?1049h\x1b[2J", 12); if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) {