diff options
-rw-r--r-- | editors/vi.c | 38 | ||||
-rw-r--r-- | networking/interface.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 26 |
3 files changed, 32 insertions, 34 deletions
diff --git a/editors/vi.c b/editors/vi.c index 7f1d27f..7f5f2dc 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -662,7 +662,7 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present c = c - 'a'; q = mark[(unsigned char) c]; if (q != NULL) { // is mark valid - *addr = count_lines(text, q); // count lines + *addr = count_lines(text, q); } } } @@ -1673,12 +1673,16 @@ static char *char_insert(char *p, char c) // insert the char c at 'p' } if (autoindent && c == '\n') { // auto indent the new line char *q; - + size_t len; q = prev_line(p); // use prev line as template - for (; isblank(*q); q++) { - uintptr_t bias = stupid_insert(p, *q); // insert the char - p += bias + 1; + len = strspn(q, " \t"); // space or tab + if (len) { + uintptr_t bias; + bias = text_hole_make(p, len); + p += bias; q += bias; + memcpy(p, q, len); + p += len; } } #endif @@ -2042,7 +2046,7 @@ static uintptr_t string_insert(char *p, const char *s) // insert the string at ' i = strlen(s); bias = text_hole_make(p, i); p += bias; - strncpy(p, s, i); + memcpy(p, s, i); #if ENABLE_FEATURE_VI_YANKMARK { int cnt; @@ -2060,21 +2064,13 @@ static uintptr_t string_insert(char *p, const char *s) // insert the string at ' #if ENABLE_FEATURE_VI_YANKMARK static char *text_yank(char *p, char *q, int dest) // copy text into a register { - char *t; - int cnt; - - if (q < p) { // they are backwards- reverse them - t = q; - q = p; - p = t; + int cnt = q - p; + if (cnt < 0) { // they are backwards- reverse them + p = q; + cnt = -cnt; } - cnt = q - p + 1; - t = reg[dest]; - free(t); // if already a yank register, free it - t = xmalloc(cnt + 1); // get a new register - memset(t, '\0', cnt + 1); // clear new text[] - strncpy(t, p, cnt); // copy text[] into bufer - reg[dest] = t; + free(reg[dest]); // if already a yank register, free it + reg[dest] = xstrndup(p, cnt + 1); return p; } @@ -3115,7 +3111,7 @@ static void do_cmd(int c) case 'P': // P- Put register before case 'p': // p- put register after p = reg[YDreg]; - if (p == 0) { + if (p == NULL) { status_line_bold("Nothing in register %c", what_reg()); break; } diff --git a/networking/interface.c b/networking/interface.c index b09148b..00174d4 100644 --- a/networking/interface.c +++ b/networking/interface.c @@ -990,7 +990,7 @@ static void ife_print6(struct interface *ptr) fclose(f); } #else -static void ife_print6(struct interface *ptr) {} +#define ife_print6(a) ((void)0) #endif diff --git a/networking/wget.c b/networking/wget.c index d782cc4..3f80d61 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -54,14 +54,14 @@ enum { STALLTIME = 5 /* Seconds when xfer considered "stalled" */ }; -static unsigned int getttywidth(void) +static unsigned int get_tty2_width(void) { unsigned width; - get_terminal_width_height(0, &width, NULL); + get_terminal_width_height(2, &width, NULL); return width; } -static void progressmeter(int flag) +static void progress_meter(int flag) { /* We can be called from signal handler */ int save_errno = errno; @@ -70,7 +70,7 @@ static void progressmeter(int flag) unsigned ratio; int barlength, i; - if (flag == -1) { /* first call to progressmeter */ + if (flag == -1) { /* first call to progress_meter */ start_sec = monotonic_sec(); lastupdate_sec = start_sec; lastsize = 0; @@ -86,7 +86,7 @@ static void progressmeter(int flag) fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio); - barlength = getttywidth() - 49; + barlength = get_tty2_width() - 49; if (barlength > 0) { /* god bless gcc for variable arrays :) */ i = barlength * ratio / 100; @@ -138,13 +138,13 @@ static void progressmeter(int flag) } if (flag == 0) { - /* last call to progressmeter */ + /* last call to progress_meter */ alarm(0); transferred = 0; fputc('\n', stderr); } else { - if (flag == -1) { /* first call to progressmeter */ - signal_SA_RESTART_empty_mask(SIGALRM, progressmeter); + if (flag == -1) { /* first call to progress_meter */ + signal_SA_RESTART_empty_mask(SIGALRM, progress_meter); } alarm(1); } @@ -188,7 +188,7 @@ static void progressmeter(int flag) */ #else /* FEATURE_WGET_STATUSBAR */ -static ALWAYS_INLINE void progressmeter(int flag UNUSED_PARAM) { } +static ALWAYS_INLINE void progress_meter(int flag UNUSED_PARAM) { } #endif @@ -202,6 +202,7 @@ static size_t safe_fread(void *ptr, size_t nmemb, FILE *stream) do { clearerr(stream); + errno = 0; ret = fread(p, 1, nmemb, stream); p += ret; nmemb -= ret; @@ -218,6 +219,7 @@ static char *safe_fgets(char *s, int size, FILE *stream) do { clearerr(stream); + errno = 0; ret = fgets(s, size, stream); } while (ret == NULL && ferror(stream) && errno == EINTR); @@ -765,7 +767,7 @@ However, in real world it was observed that some web servers * Retrieve file */ - /* Do it before progressmeter (want to have nice error message) */ + /* Do it before progress_meter (want to have nice error message) */ if (output_fd < 0) { int o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; /* compat with wget: -O FILE can overwrite */ @@ -775,7 +777,7 @@ However, in real world it was observed that some web servers } if (!(opt & WGET_OPT_QUIET)) - progressmeter(-1); + progress_meter(-1); if (chunked) goto get_clen; @@ -817,7 +819,7 @@ However, in real world it was observed that some web servers } if (!(opt & WGET_OPT_QUIET)) - progressmeter(0); + progress_meter(0); if ((use_proxy == 0) && target.is_ftp) { fclose(dfp); |