* 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.
}
#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) {
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));
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)) {
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
}
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);
* 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. */
/* 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) {
* 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) {
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
}
#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;
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
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);
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;
}
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;
}
#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++;
maxrows += editwinrows - n;
#ifdef DEBUG
- fprintf(stderr, "compute_maxrows(): maxrows = %i\n", maxrows);
+ fprintf(stderr, "compute_maxrows(): maxrows = %d\n", maxrows);
#endif
}
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
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
}
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;