A bunch of type fixes, mostly in debugging messages --

line numbers are long, x positions unsigned long.
Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4950 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-06-09 15:08:59 +00:00
parent ed0086bde5
commit acda255b47
5 changed files with 34 additions and 30 deletions

View File

@ -2,6 +2,8 @@
* src/*.c: Cosmetic tweaks of comments and whitespace.
* src/help.c, src/rcfile.c, src/winio.c: Elide a function call by
not comparing with an empty string but checking for the final \0.
* src/files.c, src/nano.c, src/text.c, src/winio.c: Type fixes in
debugging stuff -- line numbers are long, x positions unsigned long.
2014-06-09 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (do_input): Remove two superfluous false conditions.

View File

@ -210,7 +210,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
}
#ifdef DEBUG
fprintf(stderr, "In write_lockfile(), write successful (wrote %d bytes)\n", wroteamt);
fprintf(stderr, "In write_lockfile(), write successful (wrote %lu bytes)\n", (unsigned long)wroteamt);
#endif
if (fclose(filestream) == EOF) {
@ -3100,8 +3100,8 @@ void save_poshistory(void)
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4);
sprintf(statusstr, "%s %d %d\n", posptr->filename, (int) posptr->lineno,
(int) posptr->xno);
sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno,
(long)posptr->xno);
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
history_error(N_("Error writing %s: %s"), poshist,
strerror(errno));

View File

@ -1758,7 +1758,7 @@ int do_mouse(void)
sameline = (mouse_y == openfile->current_y);
#ifdef DEBUG
fprintf(stderr, "mouse_y = %d, current_y = %d\n", mouse_y, openfile->current_y);
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
#endif
if (ISSET(SOFTWRAP)) {
@ -1779,12 +1779,14 @@ int do_mouse(void)
openfile->current = openfile->current->prev;
openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS);
#ifdef DEBUG
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %d\n", mouse_x, openfile->current_x);
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %lu\n",
mouse_x, (unsigned long)openfile->current_x);
#endif
} else {
openfile->current_x = actual_x(openfile->current->data, mouse_x);
#ifdef DEBUG
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %d\n", mouse_x, openfile->current_x);
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %lu\n",
mouse_x, (unsigned long)openfile->current_x);
#endif
}
@ -1859,7 +1861,7 @@ void precalc_multicolorinfo(void)
int startx = 0;
int nostart = 0;
#ifdef DEBUG
fprintf(stderr, "working on lineno %lu... ", (unsigned long) fileptr->lineno);
fprintf(stderr, "working on lineno %ld... ", (long)fileptr->lineno);
#endif
alloc_multidata_if_needed(fileptr);
@ -1876,7 +1878,7 @@ void precalc_multicolorinfo(void)
* encompassed, which should speed up rendering later. */
startx += startmatch.rm_eo;
#ifdef DEBUG
fprintf(stderr, "start found at pos %d... ", startx);
fprintf(stderr, "start found at pos %lu... ", (unsigned long)startx);
#endif
/* Look first on this line for an end. */
@ -1893,7 +1895,7 @@ void precalc_multicolorinfo(void)
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
#ifdef DEBUG
fprintf(stderr, "\nadvancing to line %lu to find end... ", (unsigned long) endptr->lineno);
fprintf(stderr, "\nadvancing to line %ld to find end... ", (long)endptr->lineno);
#endif
/* Check for keyboard input, again. */
if ((cur_check = time(NULL)) - last_check > 1) {
@ -1919,24 +1921,24 @@ void precalc_multicolorinfo(void)
* the lines in between and the end properly. */
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
#ifdef DEBUG
fprintf(stderr, "marking line %lu as CENDAFTER\n", (unsigned long) fileptr->lineno);
fprintf(stderr, "marking line %ld as CENDAFTER\n", (long)fileptr->lineno);
#endif
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
alloc_multidata_if_needed(fileptr);
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
#ifdef DEBUG
fprintf(stderr, "marking intermediary line %lu as CWHOLELINE\n", (unsigned long) fileptr->lineno);
fprintf(stderr, "marking intermediary line %ld as CWHOLELINE\n", (long)fileptr->lineno);
#endif
}
alloc_multidata_if_needed(endptr);
fileptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
#ifdef DEBUG
fprintf(stderr, "marking line %lu as CBEGINBEFORE\n", (unsigned long) fileptr->lineno);
fprintf(stderr, "marking line %ld as CBEGINBEFORE\n", (long)fileptr->lineno);
#endif
/* Skip to the end point of the match. */
startx = endmatch.rm_eo;
#ifdef DEBUG
fprintf(stderr, "jumping to line %lu pos %d to continue\n", (unsigned long) fileptr->lineno, startx);
fprintf(stderr, "jumping to line %ld pos %lu to continue\n", (long)fileptr->lineno, (unsigned long)startx);
#endif
}
if (nostart && startx == 0) {

View File

@ -444,7 +444,7 @@ void do_undo(void)
filestruct *f = fsfromline(u->mark_begin_lineno);
if (!f) {
statusbar(_("Internal error: can't match line %d. Please save your work."), u->mark_begin_lineno);
statusbar(_("Internal error: can't match line %ld. Please save your work."), (long)u->mark_begin_lineno);
return;
}
#ifdef DEBUG
@ -975,8 +975,8 @@ void add_undo(undo_type current_action)
}
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n",
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, current_action);
fprintf(stderr, "left add_undo...\n");
#endif
fs->last_action = current_action;
@ -995,10 +995,10 @@ void update_undo(undo_type action)
return;
#ifdef DEBUG
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
action, fs->last_action, (unsigned long) openfile->current->lineno);
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %ld",
action, fs->last_action, (long)openfile->current->lineno);
if (fs->current_undo)
fprintf(stderr, "fs->current_undo->lineno = %lu\n", (unsigned long) fs->current_undo->lineno);
fprintf(stderr, "fs->current_undo->lineno = %ld\n", (long)fs->current_undo->lineno);
else
fprintf(stderr, "\n");
#endif
@ -1018,8 +1018,8 @@ void update_undo(undo_type action)
switch (u->type) {
case ADD: {
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin);
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin);
#endif
char *char_buf = charalloc(mb_cur_max());
size_t char_buf_len = parse_mbchar(&fs->current->data[u->mark_begin_x], char_buf, NULL);
@ -1050,7 +1050,7 @@ void update_undo(undo_type action)
return;
}
#ifdef DEBUG
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %d\n", u->strdata, u->begin);
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin);
#endif
break;
}
@ -3035,7 +3035,7 @@ void do_linter(void)
while ((bytesread = read(lint_fd[0], read_buff_ptr,
pipe_buff_size)) > 0) {
#ifdef DEBUG
fprintf(stderr, "text.c:do_linter:%d bytes (%s)\n", bytesread, read_buff_ptr);
fprintf(stderr, "text.c:do_linter:%ld bytes (%s)\n", (long)bytesread, read_buff_ptr);
#endif
read_buff_read += bytesread;
read_buff_size += pipe_buff_size;
@ -3092,7 +3092,7 @@ void do_linter(void)
}
#ifdef DEBUG
fprintf(stderr, "text.c:do_lint:Successful parse! %d:%d:%s\n", tmplineno, tmpcolno, message);
fprintf(stderr, "text.c:do_lint:Successful parse! %ld:%ld:%s\n", (long)tmplineno, (long)tmpcolno, message);
#endif
/* Nice. We have a lint message we can use. */
parsesuccess++;

View File

@ -2976,7 +2976,7 @@ void compute_maxrows(void)
maxrows += editwinrows - n;
#ifdef DEBUG
fprintf(stderr, "compute_maxrows(): maxrows = %i\n", maxrows);
fprintf(stderr, "compute_maxrows(): maxrows = %d\n", maxrows);
#endif
}
@ -3109,8 +3109,8 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
openfile->edittop->lineno || openfile->current->lineno >=
openfile->edittop->lineno + maxrows) {
#ifdef DEBUG
fprintf(stderr, "edit_redraw(): line %d was offscreen, oldcurrent = %d edittop = %d",
openfile->current->lineno, old_current->lineno, openfile->edittop->lineno);
fprintf(stderr, "edit_redraw(): line %ld was offscreen, oldcurrent = %ld edittop = %ld",
(long)openfile->current->lineno, (long)old_current->lineno, (long)openfile->edittop->lineno);
#endif
#ifndef NANO_TINY
@ -3204,9 +3204,9 @@ void edit_refresh(void)
if (openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno +
maxrows) {
#ifdef DEBUG
fprintf(stderr, "edit_refresh(): line = %d, edittop %d + maxrows %d\n", openfile->current->lineno, openfile->edittop->lineno, maxrows);
fprintf(stderr, "edit_refresh(): line = %ld, edittop %ld + maxrows %d\n",
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows);
#endif
/* Put the top line of the edit window in range of the current
@ -3267,7 +3267,7 @@ void edit_update(update_type location)
}
openfile->edittop = foo;
#ifdef DEBUG
fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
fprintf(stderr, "edit_udpate(), setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
#endif
compute_maxrows();
edit_refresh_needed = TRUE;