Resolve warnings from compiler

This commit is contained in:
Night Kaly 2024-11-09 00:44:11 +00:00
parent 4fb08b462e
commit dccef3d081
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
2 changed files with 5 additions and 8 deletions

View file

@ -23,8 +23,6 @@
#define MAUVE_BG "\033[38;2;203;166;247m" #define MAUVE_BG "\033[38;2;203;166;247m"
#define YELLOW_BG "\033[38;2;249;226;175m" #define YELLOW_BG "\033[38;2;249;226;175m"
enum keys { enum keys {
BACKSPACE = 127, BACKSPACE = 127,
ARROW_LEFT = 1000, ARROW_LEFT = 1000,
@ -93,6 +91,9 @@ typedef struct {
language_t *syntax; language_t *syntax;
} editor_t; } editor_t;
#define HL_NUMBERS (1 << 0)
#define HL_STRINGS (1 << 1)
language_t langs[] = { language_t langs[] = {
{ {
"c", "c",
@ -107,8 +108,5 @@ language_t langs[] = {
#define LANGS_LEN (sizeof(langs) / sizeof(langs[0])) #define LANGS_LEN (sizeof(langs) / sizeof(langs[0]))
#define HL_NUMBERS (1 << 0)
#define HL_STRINGS (1 << 1)
#define CTRL_KEY(k) ((k) & 0x1f) #define CTRL_KEY(k) ((k) & 0x1f)
#define COLOR_LEN 19 #define COLOR_LEN 19

5
vip.c
View file

@ -534,11 +534,11 @@ void save_file(void)
} }
select_syntax(); select_syntax();
} }
int len;
int fd = open(cur_editor->filename, O_RDWR | O_CREAT, 0644); int fd = open(cur_editor->filename, O_RDWR | O_CREAT, 0644);
if (fd != -1) { if (fd != -1) {
int len;
char *buf = export_buffer(&len);
if (ftruncate(fd, len) != -1) { if (ftruncate(fd, len) != -1) {
char *buf = export_buffer(&len);
if (write(fd, buf, len) == len) { if (write(fd, buf, len) == len) {
close(fd); close(fd);
free(buf); free(buf);
@ -576,7 +576,6 @@ void draw_rows(void)
unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff]; unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff];
char *current_color = malloc(COLOR_LEN * 2); char *current_color = malloc(COLOR_LEN * 2);
int current_color_len = 0;
for (int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
if (iscntrl(c[j])) { if (iscntrl(c[j])) {
bprintf("\033[7m^%c\033[m", '@' + c[j]); bprintf("\033[7m^%c\033[m", '@' + c[j]);