Commit 4239e5fe authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: put declarations always first, so it will compile on Haiku

No related merge requests found
Showing with 32 additions and 22 deletions
+32 -22
...@@ -1987,6 +1987,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, ...@@ -1987,6 +1987,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
/* If we must set the filename, and it changed, adjust things. */ /* If we must set the filename, and it changed, adjust things. */
if (!nonamechange && strcmp(openfile->filename, realname) != 0) { if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
char *newname;
char *oldname = openfile->syntax ? openfile->syntax->name : ""; char *oldname = openfile->syntax ? openfile->syntax->name : "";
filestruct *line = openfile->fileage; filestruct *line = openfile->fileage;
#endif #endif
...@@ -1997,7 +1998,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, ...@@ -1997,7 +1998,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
color_update(); color_update();
color_init(); color_init();
char *newname = openfile->syntax ? openfile->syntax->name : ""; newname = openfile->syntax ? openfile->syntax->name : "";
/* If the syntax changed, discard and recompute the multidata. */ /* If the syntax changed, discard and recompute the multidata. */
if (strcmp(oldname, newname) != 0) { if (strcmp(oldname, newname) != 0) {
...@@ -2457,14 +2458,15 @@ char **username_tab_completion(const char *buf, size_t *num_matches, ...@@ -2457,14 +2458,15 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len) size_t buf_len)
{ {
char **matches = NULL; char **matches = NULL;
#ifdef HAVE_PWD_H
const struct passwd *userdata;
#endif
assert(buf != NULL && num_matches != NULL && buf_len > 0); assert(buf != NULL && num_matches != NULL && buf_len > 0);
*num_matches = 0; *num_matches = 0;
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
const struct passwd *userdata;
while ((userdata = getpwent()) != NULL) { while ((userdata = getpwent()) != NULL) {
if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) { if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) {
/* Cool, found a match. Add it to the list. This makes a /* Cool, found a match. Add it to the list. This makes a
......
...@@ -899,9 +899,10 @@ void pick_up_name(const char *kind, char *ptr, char **storage) ...@@ -899,9 +899,10 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
if (!strcmp(ptr, "\"\"")) if (!strcmp(ptr, "\"\""))
*storage = NULL; *storage = NULL;
else if (*ptr == '"') { else if (*ptr == '"') {
*storage = mallocstrcpy(NULL, ++ptr); char *p, *q;
char* q = *storage;
char* p = *storage; p = q = *storage = mallocstrcpy(NULL, ++ptr);
/* Snip out the backslashes of escaped characters. */ /* Snip out the backslashes of escaped characters. */
while (*p != '"') { while (*p != '"') {
if (*p == '\0') { if (*p == '\0') {
......
...@@ -653,12 +653,14 @@ void undo_cut(undo *u) ...@@ -653,12 +653,14 @@ void undo_cut(undo *u)
/* Redo a cut, or undo an uncut. */ /* Redo a cut, or undo an uncut. */
void redo_cut(undo *u) void redo_cut(undo *u)
{ {
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
/* If we cut the magicline, we may as well not crash. :/ */ /* If we cut the magicline, we may as well not crash. :/ */
if (!u->cutbuffer) if (!u->cutbuffer)
return; return;
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom; cutbuffer = NULL;
cutbuffer = cutbottom = NULL; cutbottom = NULL;
goto_line_posx(u->lineno, u->begin); goto_line_posx(u->lineno, u->begin);
...@@ -678,7 +680,9 @@ void do_undo(void) ...@@ -678,7 +680,9 @@ void do_undo(void)
{ {
undo *u = openfile->current_undo; undo *u = openfile->current_undo;
filestruct *f, *t = NULL; filestruct *f, *t = NULL;
filestruct *oldcutbuffer, *oldcutbottom;
char *data, *undidmsg = NULL; char *data, *undidmsg = NULL;
size_t from_x, to_x;
if (!u) { if (!u) {
statusbar(_("Nothing in undo buffer!")); statusbar(_("Nothing in undo buffer!"));
...@@ -767,8 +771,8 @@ void do_undo(void) ...@@ -767,8 +771,8 @@ void do_undo(void)
break; break;
} }
undidmsg = _("line break"); undidmsg = _("line break");
size_t from_x = (u->begin == 0) ? 0 : u->mark_begin_x; from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
size_t to_x = (u->begin == 0) ? u->mark_begin_x : u->begin; to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
f->data = charealloc(f->data, strlen(f->data) + f->data = charealloc(f->data, strlen(f->data) +
strlen(&u->strdata[from_x]) + 1); strlen(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]); strcat(f->data, &u->strdata[from_x]);
...@@ -787,7 +791,8 @@ void do_undo(void) ...@@ -787,7 +791,8 @@ void do_undo(void)
#endif #endif
case INSERT: case INSERT:
undidmsg = _("text insert"); undidmsg = _("text insert");
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom; oldcutbuffer = cutbuffer;
oldcutbottom = cutbottom;
cutbuffer = NULL; cutbuffer = NULL;
cutbottom = NULL; cutbottom = NULL;
openfile->mark_begin = fsfromline(u->mark_begin_lineno); openfile->mark_begin = fsfromline(u->mark_begin_lineno);
...@@ -832,7 +837,7 @@ void do_undo(void) ...@@ -832,7 +837,7 @@ void do_undo(void)
/* Redo the last thing(s) we undid. */ /* Redo the last thing(s) we undid. */
void do_redo(void) void do_redo(void)
{ {
filestruct *f; filestruct *f, *shoveline;
char *data, *redidmsg = NULL; char *data, *redidmsg = NULL;
undo *u = openfile->undotop; undo *u = openfile->undotop;
...@@ -883,7 +888,7 @@ void do_redo(void) ...@@ -883,7 +888,7 @@ void do_redo(void)
break; break;
case ENTER: case ENTER:
redidmsg = _("line break"); redidmsg = _("line break");
filestruct *shoveline = make_new_node(f); shoveline = make_new_node(f);
shoveline->data = mallocstrcpy(NULL, u->strdata); shoveline->data = mallocstrcpy(NULL, u->strdata);
data = mallocstrncpy(NULL, f->data, u->begin + 1); data = mallocstrncpy(NULL, f->data, u->begin + 1);
data[u->begin] = '\0'; data[u->begin] = '\0';
...@@ -1406,11 +1411,12 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf ...@@ -1406,11 +1411,12 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
* bottom-->top, then swap the mark points. */ * bottom-->top, then swap the mark points. */
if ((u->lineno == u->mark_begin_lineno && u->begin < u->mark_begin_x) if ((u->lineno == u->mark_begin_lineno && u->begin < u->mark_begin_x)
|| u->lineno < u->mark_begin_lineno) { || u->lineno < u->mark_begin_lineno) {
ssize_t line = u->lineno;
size_t x_loc = u->begin; size_t x_loc = u->begin;
u->begin = u->mark_begin_x; u->begin = u->mark_begin_x;
u->mark_begin_x = x_loc; u->mark_begin_x = x_loc;
ssize_t line = u->lineno;
u->lineno = u->mark_begin_lineno; u->lineno = u->mark_begin_lineno;
u->mark_begin_lineno = line; u->mark_begin_lineno = line;
} else } else
...@@ -1487,6 +1493,9 @@ bool do_wrap(filestruct *line) ...@@ -1487,6 +1493,9 @@ bool do_wrap(filestruct *line)
size_t next_line_len = 0; size_t next_line_len = 0;
/* The length of next_line. */ /* The length of next_line. */
size_t old_x = openfile->current_x;
filestruct * oldLine = openfile->current;
/* There are three steps. First, we decide where to wrap. Then, we /* There are three steps. First, we decide where to wrap. Then, we
* create the new wrap line. Finally, we clean up. */ * create the new wrap line. Finally, we clean up. */
...@@ -1529,8 +1538,6 @@ bool do_wrap(filestruct *line) ...@@ -1529,8 +1538,6 @@ bool do_wrap(filestruct *line)
add_undo(SPLIT_BEGIN); add_undo(SPLIT_BEGIN);
#endif #endif
size_t old_x = openfile->current_x;
filestruct * oldLine = openfile->current;
openfile->current = line; openfile->current = line;
/* Step 2, making the new wrap line. It will consist of indentation /* Step 2, making the new wrap line. It will consist of indentation
......
...@@ -2385,6 +2385,12 @@ void edit_draw(filestruct *fileptr, const char *converted, ...@@ -2385,6 +2385,12 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* The place in converted from where painting starts. */ /* The place in converted from where painting starts. */
regmatch_t match; regmatch_t match;
/* The match positions of a single-line regex. */ /* The match positions of a single-line regex. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr that matches 'start'. */
const filestruct *end_line = fileptr;
/* The line that matches 'end'. */
regmatch_t startmatch, endmatch;
/* The match positions of the start and end regexes. */
/* Two notes about regexec(). A return value of zero means /* Two notes about regexec(). A return value of zero means
* that there is a match. Also, rm_eo is the first * that there is a match. Also, rm_eo is the first
...@@ -2440,12 +2446,6 @@ void edit_draw(filestruct *fileptr, const char *converted, ...@@ -2440,12 +2446,6 @@ void edit_draw(filestruct *fileptr, const char *converted,
} }
/* Second case: varnish is a multiline expression. */ /* Second case: varnish is a multiline expression. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr that matches 'start'. */
const filestruct *end_line = fileptr;
/* The line that matches 'end'. */
regmatch_t startmatch, endmatch;
/* The match positions of the start and end regexes. */
/* Assume nothing gets painted until proven otherwise below. */ /* Assume nothing gets painted until proven otherwise below. */
fileptr->multidata[varnish->id] = CNONE; fileptr->multidata[varnish->id] = CNONE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment