Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove warnings and wrong type casts #33

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/cjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ extern char *win32_mkdtemp();
extern void _out(const char *fmt, ...);
extern void _err(const char *fmt, ...);

// from kilo.c
extern void initEditor(void);
extern void editorRefreshScreen(void);
extern void editorSetStatusMessage(const char *fmt, ...);
extern void editorSetCompilerCallback(int (*cb)(void *, char *, int, char **));
extern void editorSetCheckCallback(int (*cb)(void *, char *, char **));
extern void editorSetCompilerContext(void *ctx);
extern void editorProcessKeypress(int fd);
extern int enableRawMode(int fd);
extern void disableRawMode(int fd);
extern int enableGetCharMode(int fd);
extern void disableGetCharMode(int fd);
extern void editorInsertRow(int at, const char *s, size_t len);


static void error_callback(void *ctx, const char *msg);

#ifdef REPL_SUPPORTED
Expand Down Expand Up @@ -215,7 +230,7 @@ static int cjit_check_buffer(void *tcs, char *code, char **err_msg)
res = cjit_compile_and_run(TCC, code, 0, NULL, 0, err_msg);
if (res != 0) {
if(*err_msg) {
if (strlen(err_msg) > ERR_MAX -1) {
if (strlen(*err_msg) > ERR_MAX -1) {
(*err_msg)[ERR_MAX - 1] = 0;
}
char *p = strchr(*err_msg, '\n');
Expand Down
15 changes: 5 additions & 10 deletions src/kilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct editorSyntax {
typedef struct erow {
int idx; /* Row index in the file, zero-based. */
int size; /* Size of the row, excluding the null term. */
int rsize; /* Size of the rendered row. */
unsigned rsize; /* Size of the rendered row. */
char *chars; /* Row content. */
char *render; /* Row content "rendered" for screen (for TABs). */
unsigned char *hl; /* Syntax highlight type for each character in render.*/
Expand All @@ -110,7 +110,7 @@ struct editorConfig {
time_t statusmsg_time;
struct editorSyntax *syntax; /* Current syntax highlight, or NULL. */
int (*compiler_cb)(void *, const char *, int, char **);
int (*check_cb)(void *, const char *, char *);
int (*check_cb)(void *, const char *, char **);
void *compiler_cb_ctx;
int keep_scratchpad;
int exiting;
Expand Down Expand Up @@ -430,7 +430,7 @@ int is_separator(int c) {
* that starts at this row or at one before, and does not end at the end
* of the row but spawns to the next row. */
int editorRowHasOpenComment(erow *row) {
if ((!row->rsize < 3) || (sizeof(row->hl) < row->rsize - 1))
if ((!(row->rsize < 3)) || (sizeof(row->hl) < row->rsize - 1))
return 0;
if (row->hl) {
if ((row->hl[row->size - 1] == HL_MLCOMMENT)) {
Expand Down Expand Up @@ -730,7 +730,6 @@ void editorDelRow(int at) {

/* Clear the entire buffer */
void editorReset(void) {
int j;
while (E.numrows > 0)
editorDelRow(E.numrows-1);
E.dirty = 0;
Expand Down Expand Up @@ -1122,9 +1121,8 @@ void editorRefreshScreen(void) {
abFree(&ab);
/* Check for errors on new line */
if (E.check_cb) {
int err_line = 0;
char *err_msg = NULL;
unsigned buflen;
int buflen;
char *buf = editorRowsToString(&buflen);
int ret;
buf[buflen] = (char)0;
Expand Down Expand Up @@ -1366,7 +1364,6 @@ void editorMoveCursor(int key) {
void editorProcessKeypress(int fd) {
/* When the file is modified, requires Ctrl-q to be pressed N times
* before actually quitting. */
static int quit_times = KILO_QUIT_TIMES;
int c = editorReadKey(fd);
switch(c) {
case ENTER: /* Enter */
Expand Down Expand Up @@ -1443,8 +1440,6 @@ void editorProcessKeypress(int fd) {
editorInsertChar(c);
break;
}

quit_times = KILO_QUIT_TIMES; /* Reset it to the original value. */
}

int editorFileWasModified(void) {
Expand Down Expand Up @@ -1492,7 +1487,7 @@ void editorSetCompilerCallback(int (*cb)(void *ctx, const char *code, int argc,
E.compiler_cb = cb;
}

void editorSetCheckCallback(int (*cb)(void *ctx, const char *code)) {
void editorSetCheckCallback(int (*cb)(void *ctx, const char *code, char **err_msg)) {
E.check_cb = cb;
}

Expand Down