Resolve compiler warnings and udpate CFLAGS

This commit is contained in:
Night Kaly 2024-11-05 00:02:09 +00:00
parent 6f5904ecf6
commit 8573bc1c5c
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
9 changed files with 28 additions and 28 deletions

View file

@ -6,13 +6,13 @@ TARGET = vip
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin 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 SRC != find src -name *.c
INCLUDE = include INCLUDE = include
$(TARGET): $(SRC) config.h $(TARGET): $(SRC) config.h
$(CC) $(SRC) config.h -o $@ $(CFLAGS) -I$(INCLUDE) -I. $(CC) $(SRC) -o $@ $(CFLAGS) -I$(INCLUDE) -I.
dist: dist:
mkdir -p $(TARGET)-$(VERSION) mkdir -p $(TARGET)-$(VERSION)

View file

@ -1,16 +1,16 @@
#ifndef EDITOR_H_ #ifndef EDITOR_H_
#define EDITOR_H_ #define EDITOR_H_
void refresh_screen(); void refresh_screen(void);
void move_cursor(int key); void move_cursor(int key);
void scroll(); void scroll(void);
void insert_char(int c); void insert_char(int c);
void insert_new_line(); void insert_new_line(void);
void shift_new_line(); void shift_new_line(void);
void del_char(); void del_char(void);
void init_editor(); void init_editor(void);
void open_editor(char *filename); void open_editor(char *filename);
char *prompt_editor(char *prompt, void (*callback)(char *, int)); char *prompt_editor(char *prompt, void (*callback)(char *, int));
void find_editor(); void find_editor(void);
#endif #endif

View file

@ -1,9 +1,9 @@
#ifndef IO_H_ #ifndef IO_H_
#define IO_H_ #define IO_H_
int read_key(); int read_key(void);
void save_file(); void save_file(void);
void process_key(); void process_key(void);
void draw_rows(struct abuf *ab); void draw_rows(struct abuf *ab);
#endif #endif

View file

@ -21,6 +21,6 @@ typedef struct language {
int is_separator(int c); int is_separator(int c);
void update_highlight(row *row); void update_highlight(row *row);
char *syntax_to_color(int hl, size_t *len); char *syntax_to_color(int hl, size_t *len);
void select_syntax_highlight(); void select_syntax_highlight(void);
#endif #endif

View file

@ -4,8 +4,8 @@
#define CTRL_KEY(k) ((k) & 0x1f) #define CTRL_KEY(k) ((k) & 0x1f)
void die(const char *s); void die(const char *s);
void reset_term(); void reset_term(void);
void setup_term(); void setup_term(void);
int get_cursor_position(int *rows, int *cols); int get_cursor_position(int *rows, int *cols);
int get_window_size(int *rows, int *cols); int get_window_size(int *rows, int *cols);

View file

@ -12,7 +12,7 @@
extern editor vip; extern editor vip;
void refresh_screen() void refresh_screen(void)
{ {
scroll(); scroll();
@ -68,7 +68,7 @@ void move_cursor(int key)
} }
} }
void scroll() void scroll(void)
{ {
vip.rx = 0; vip.rx = 0;
if (vip.cy < vip.rows) { if (vip.cy < vip.rows) {
@ -97,7 +97,7 @@ void insert_char(int c)
vip.cx++; vip.cx++;
} }
void insert_new_line() void insert_new_line(void)
{ {
if (vip.cx == 0) { if (vip.cx == 0) {
insert_row(vip.cy, "", 0); insert_row(vip.cy, "", 0);
@ -116,14 +116,14 @@ void insert_new_line()
/* /*
* 'o' in vim * 'o' in vim
*/ */
void shift_new_line() void shift_new_line(void)
{ {
insert_row(vip.cy + 1, "", 0); insert_row(vip.cy + 1, "", 0);
vip.cy++; vip.cy++;
vip.cx = 0; vip.cx = 0;
} }
void del_char() void del_char(void)
{ {
if (vip.cy == vip.rows) return; if (vip.cy == vip.rows) return;
if (vip.cx == 0 && vip.cy == 0) 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.cx = 0;
vip.cy = 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_cx = vip.cx;
int tmp_cy = vip.cy; int tmp_cy = vip.cy;

View file

@ -10,7 +10,7 @@
#include "vip.h" #include "vip.h"
#include "bar.h" #include "bar.h"
int read_key() int read_key(void)
{ {
int nread; int nread;
char c; char c;
@ -65,7 +65,7 @@ int read_key()
} }
} }
void save_file() void save_file(void)
{ {
if (vip.filename == NULL) { if (vip.filename == NULL) {
vip.filename = prompt_editor("Save as: %s", 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)); set_status_bar_message("Error saving: %s", strerror(errno));
} }
void process_key() void process_key(void)
{ {
int c = read_key(); int c = read_key();
switch (c) { switch (c) {

View file

@ -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; vip.syntax = NULL;
if (vip.filename == NULL) return; if (vip.filename == NULL) return;

View file

@ -15,7 +15,7 @@ void die(const char *s)
exit(1); exit(1);
} }
void reset_term() void reset_term(void)
{ {
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) { if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &vip.termios) == -1) {
die("tcsetattr"); die("tcsetattr");
@ -26,7 +26,7 @@ void reset_term()
/* /*
* Setup terminal * Setup terminal
*/ */
void setup_term() void setup_term(void)
{ {
write(STDOUT_FILENO, "\x1b[?1049h\x1b[2J", 12); write(STDOUT_FILENO, "\x1b[?1049h\x1b[2J", 12);
if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) { if (tcgetattr(STDIN_FILENO, &vip.termios) == -1) {