diff options
Diffstat (limited to 'cmdbuf.c')
| -rw-r--r-- | cmdbuf.c | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -358,7 +358,7 @@ static void cmd_lshift(void) s = ns; } - cmd_offset = (int) (s - cmdbuf); + cmd_offset = (int) ptr_diff(s, cmdbuf); save_cp = cp; cmd_home(); cmd_repaint(save_cp); @@ -387,7 +387,7 @@ static void cmd_rshift(void) cols += width; } - cmd_offset = (int) (s - cmdbuf); + cmd_offset = (int) ptr_diff(s, cmdbuf); save_cp = cp; cmd_home(); cmd_repaint(save_cp); @@ -479,7 +479,7 @@ static int cmd_erase(void) */ s = cp; cmd_left(); - clen = (int) (s - cp); + clen = (int) ptr_diff(s, cp); /* * Remove the char from the buffer (shift the buffer left). @@ -993,10 +993,12 @@ static int cmd_istr(constant char *str) */ static void set_tk_original(constant char *word) { + size_t len = ptr_diff(cp, word); if (tk_original != NULL) free(tk_original); - tk_original = (char *) ecalloc(ptr_diff(cp,word)+1, sizeof(char)); - strncpy(tk_original, word, ptr_diff(cp,word)); + tk_original = (char *) ecalloc(len+1, sizeof(char)); + strncpy(tk_original, word, len); + tk_original[len] = '\0'; } #if TAB_COMPLETE_FILENAME @@ -1418,15 +1420,18 @@ public LINENUM cmd_int(mutable long *frac) { if (ckd_mul(&n, n, 10) || ckd_add(&n, n, *p - '0')) { - error("Integer is too big", NULL_PARG); + error(LM(Integer_is_too_big), NULL_PARG); return (0); } } - *frac = 0; - if (*p++ == '.') + if (frac != NULL) { - /* {{ Just ignore error in fractional part. }} */ - (void) getfraction(&p, frac); + *frac = 0; + if (*p++ == '.') + { + /* {{ Just ignore error in fractional part. }} */ + (void) getfraction(&p, frac); + } } return (n); } @@ -1481,7 +1486,7 @@ static char * histfile_find(lbool must_exist) name = dirfile(lgetenv("XDG_STATE_HOME"), &LESSHISTFILE[1], must_exist); if (name == NULL) { - char *dir = dirfile(home, ".local/state", 1); + char *dir = dirfile(home, ".local/state", TRUE); if (dir != NULL) { name = dirfile(dir, &LESSHISTFILE[1], must_exist); @@ -1606,7 +1611,7 @@ static void addhist_init(void *uparam, struct mlist *ml, constant char *string) { (void) uparam; if (ml != NULL) - cmd_addhist(ml, string, 0); + cmd_addhist(ml, string, FALSE); else if (string != NULL) restore_mark(string); } @@ -1721,8 +1726,8 @@ static void make_file_private(FILE *f) #if HAVE_FCHMOD lbool do_chmod = TRUE; #if HAVE_STAT - struct stat statbuf; - int r = fstat(fileno(f), &statbuf); + less_stat_t statbuf; + int r = less_fstat(fileno(f), &statbuf); if (r < 0 || !S_ISREG(statbuf.st_mode)) /* Don't chmod if not a regular file. */ do_chmod = FALSE; |
