and add it to those regexes that can use it. Changes to
parse_colors(), parse_rcfile(), nanorc.sample, and nanorc.5.
(Brand Huntsman, minor tweaks by DLR)
+ - Add various type changes to avoid problems on systems where
+ int and ssize_t are different sizes. Make filestruct->lineno
+ a ssize_t (so that we can avoid negative line numbers at the
+ "Go To Line" prompt), current_y a ssize_t (in order to hold
+ the maximum difference between two filestruct->lineno's),
+ totlines a size_t, and change related variables to match.
+ (DLR, initial problem with parse_line_column() found by Mike
+ Frysinger)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
char *ans = mallocstrcpy(NULL, "");
/* The last answer the user typed on the statusbar. */
filestruct *edittop_save = edittop;
- int current_y_save = current_y;
+ ssize_t current_y_save = current_y;
bool at_edittop = FALSE;
/* Whether we're at the top of the edit window. */
filestruct *current; /* Current buffer pointer */
size_t current_x = 0; /* Current x-coordinate in the edit
window */
-int current_y = 0; /* Current y-coordinate in the edit
+ssize_t current_y = 0; /* Current y-coordinate in the edit
window */
filestruct *fileage = NULL; /* Our file buffer */
filestruct *edittop = NULL; /* Pointer to the top of the edit
#endif
char *answer = NULL; /* Answer str to many questions */
-int totlines = 0; /* Total number of lines in the file */
+size_t totlines = 0; /* Total number of lines in the file */
size_t totsize = 0; /* Total number of characters in the
file */
size_t placewewant = 0; /* The column we'd like the cursor
void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
{
filestruct *top_save;
- int part_totlines;
- size_t part_totsize;
+ size_t part_totlines, part_totsize;
bool at_edittop;
assert(file_top != NULL && file_bot != NULL);
{
int alt_spell_status, lineno_save = current->lineno;
size_t current_x_save = current_x, pww_save = placewewant;
- int current_y_save = current_y;
+ ssize_t current_y_save = current_y;
pid_t pid_spell;
char *ptr;
static int arglen = 3;
* FALSE if (current, current_x) is. */
filestruct *top, *bot;
size_t top_x, bot_x;
- int mbb_lineno_save = 0;
+ ssize_t mbb_lineno_save = 0;
/* We're going to close the current file, and open the output of
* the alternate spell command. The line that mark_beginbuf
* points to will be freed, so we save the line number and
/* Number of lines in the paragraph we search for. */
filestruct *current_save;
/* The line at the beginning of the paragraph we search for. */
- size_t current_y_save;
+ ssize_t current_y_save;
/* The y-coordinate at the beginning of the paragraph we search
* for. */
/* We save these global variables to be restored if the user
* unjustifies. Note that we don't need to save totlines. */
size_t current_x_save = current_x, pww_save = placewewant;
- int current_y_save = current_y;
+ ssize_t current_y_save = current_y;
unsigned long flags_save = flags;
size_t totsize_save = totsize;
filestruct *edittop_save = edittop, *current_save = current;
int main(int argc, char **argv)
{
int optchr;
- int startline = 1;
+ ssize_t startline = 1;
/* Line to try and start at. */
ssize_t startcol = 1;
/* Column to try and start at. */
/* Read all the files after the first one on the command line into
* new buffers. */
{
- int i = optind + 1, iline = 1;
- ssize_t icol = 1;
+ int i = optind + 1;
+ ssize_t iline = 1, icol = 1;
for (; i < argc; i++) {
/* If there's a +LINE or +LINE,COLUMN flag here, it is
char *data;
struct filestruct *next; /* Next node. */
struct filestruct *prev; /* Previous node. */
- int lineno; /* The line number. */
+ ssize_t lineno; /* The line number. */
} filestruct;
#ifdef ENABLE_MULTIBUFFER
size_t current_x; /* Current file's x-coordinate
* position. */
size_t placewewant; /* Current file's place we want. */
- int totlines; /* Current file's total number of
+ size_t totlines; /* Current file's total number of
* lines. */
size_t totsize; /* Current file's total size. */
unsigned long flags; /* Current file's flags: modification
#endif
extern int editwinrows;
extern size_t current_x;
-extern int current_y;
-extern int totlines;
+extern ssize_t current_y;
+extern size_t totlines;
extern size_t placewewant;
#ifndef NANO_SMALL
extern size_t mark_beginx;
interactive, bool save_pos);
void do_gotolinecolumn_void(void);
#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER)
-void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww);
+void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t
+ pos_pww);
#endif
#ifndef NANO_SMALL
#ifdef HAVE_REGEX_H
int digits(size_t n);
void get_homedir(void);
bool parse_num(const char *str, ssize_t *val);
-bool parse_line_column(const char *str, int *line, ssize_t *column);
+bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void align(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
#endif
-void get_totals(const filestruct *begin, const filestruct *end, int
+void get_totals(const filestruct *begin, const filestruct *end, size_t
*lines, size_t *size);
/* Public functions in winio.c. */
};
static bool errors = FALSE;
-static int lineno = 0;
+static size_t lineno = 0;
static char *nanorc = NULL;
#ifdef ENABLE_COLOR
static syntaxtype *endsyntax = NULL;
fprintf(stderr, "\n");
if (lineno > 0) {
errors = TRUE;
- fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
+ fprintf(stderr, _("Error in %s on line %lu: "), nanorc,
+ (unsigned long)lineno);
}
va_start(ap, msg);
/* The length of the match we found. */
size_t current_x_find = 0;
/* The location of the match we found. */
- int current_y_find = current_y;
+ ssize_t current_y_find = current_y;
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because strstrwrapper()
}
#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER)
-void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww)
+void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t
+ pos_pww)
{
/* Since do_gotolinecolumn() resets the x-coordinate but not the
* y-coordinate, set the coordinates up this way. */
/* Read an int and a ssize_t, separated by a comma, from str, and store
* them in *line and *column (if they're not both NULL). On error, we
* return FALSE. Otherwise, we return TRUE. */
-bool parse_line_column(const char *str, int *line, ssize_t *column)
+bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{
bool retval = TRUE;
const char *comma;
/* Calculate the number of lines and the number of characters between
* begin and end, and return them in lines and size, respectively. */
-void get_totals(const filestruct *begin, const filestruct *end, int
+void get_totals(const filestruct *begin, const filestruct *end, size_t
*lines, size_t *size)
{
const filestruct *f;
const filestruct *foo = edittop;
#ifdef DEBUG
- fprintf(stderr, "edit_refresh(): edittop->lineno = %d\n", edittop->lineno);
+ fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)edittop->lineno);
#endif
while (nlines < editwinrows) {
int bytepct = (totsize == 0) ? 0 : 100 * i / totsize;
statusbar(
- _("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
- current->lineno, totlines, linepct, (unsigned long)xpt,
- (unsigned long)cur_len, colpct, (unsigned long)i,
- (unsigned long)totsize, bytepct);
+ _("line %ld/%lu (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
+ (long)current->lineno, (unsigned long)totlines, linepct,
+ (unsigned long)xpt, (unsigned long)cur_len, colpct,
+ (unsigned long)i, (unsigned long)totsize, bytepct);
disable_cursorpos = FALSE;
}
fprintf(stderr, "Dumping a buffer to stderr...\n");
while (inptr != NULL) {
- fprintf(stderr, "(%d) %s\n", inptr->lineno, inptr->data);
+ fprintf(stderr, "(%ld) %s\n", (long)inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
const filestruct *fileptr = filebot;
while (fileptr != NULL) {
- fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
+ fprintf(stderr, "(%ld) %s\n", (long)fileptr->lineno,
+ fileptr->data);
fileptr = fileptr->prev;
}
}