diff options
author | Ron Yorston <rmy@pobox.com> | 2021-02-05 11:24:06 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-02-05 11:24:06 +0000 |
commit | 32e19e7ae8b0d76d69871ba234e8f0af31baff4e (patch) | |
tree | 6fdc833a444e0dd6fd359b21a8d463856917a387 /editors | |
parent | 4fb71406b884c6ac0a9a4d2acf7a32b544611f70 (diff) | |
parent | cad3fc743aa7c7744e4fcf044371f0fda50fa51f (diff) | |
download | busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.tar.gz busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.tar.bz2 busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 18 | ||||
-rw-r--r-- | editors/ed.c | 2 | ||||
-rw-r--r-- | editors/vi.c | 17 |
3 files changed, 26 insertions, 11 deletions
diff --git a/editors/awk.c b/editors/awk.c index 4799091ec..41a57ea0c 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2174,7 +2174,10 @@ static int fmt_num(char *b, int size, const char *format, double n, int int_as_i | |||
2174 | } | 2174 | } |
2175 | 2175 | ||
2176 | /* formatted output into an allocated buffer, return ptr to buffer */ | 2176 | /* formatted output into an allocated buffer, return ptr to buffer */ |
2177 | static char *awk_printf(node *n) | 2177 | #if !ENABLE_FEATURE_AWK_GNU_EXTENSIONS |
2178 | # define awk_printf(a, b) awk_printf(a) | ||
2179 | #endif | ||
2180 | static char *awk_printf(node *n, int *len) | ||
2178 | { | 2181 | { |
2179 | char *b = NULL; | 2182 | char *b = NULL; |
2180 | char *fmt, *s, *f; | 2183 | char *fmt, *s, *f; |
@@ -2228,6 +2231,10 @@ static char *awk_printf(node *n) | |||
2228 | nvfree(v); | 2231 | nvfree(v); |
2229 | b = xrealloc(b, i + 1); | 2232 | b = xrealloc(b, i + 1); |
2230 | b[i] = '\0'; | 2233 | b[i] = '\0'; |
2234 | #if ENABLE_FEATURE_AWK_GNU_EXTENSIONS | ||
2235 | if (len) | ||
2236 | *len = i; | ||
2237 | #endif | ||
2231 | return b; | 2238 | return b; |
2232 | } | 2239 | } |
2233 | 2240 | ||
@@ -2685,6 +2692,7 @@ static var *evaluate(node *op, var *res) | |||
2685 | case XC( OC_PRINT ): | 2692 | case XC( OC_PRINT ): |
2686 | case XC( OC_PRINTF ): { | 2693 | case XC( OC_PRINTF ): { |
2687 | FILE *F = stdout; | 2694 | FILE *F = stdout; |
2695 | IF_FEATURE_AWK_GNU_EXTENSIONS(int len;) | ||
2688 | 2696 | ||
2689 | if (op->r.n) { | 2697 | if (op->r.n) { |
2690 | rstream *rsm = newfile(R.s); | 2698 | rstream *rsm = newfile(R.s); |
@@ -2722,8 +2730,12 @@ static var *evaluate(node *op, var *res) | |||
2722 | fputs(getvar_s(intvar[ORS]), F); | 2730 | fputs(getvar_s(intvar[ORS]), F); |
2723 | 2731 | ||
2724 | } else { /* OC_PRINTF */ | 2732 | } else { /* OC_PRINTF */ |
2725 | char *s = awk_printf(op1); | 2733 | char *s = awk_printf(op1, &len); |
2734 | #if ENABLE_FEATURE_AWK_GNU_EXTENSIONS | ||
2735 | fwrite(s, len, 1, F); | ||
2736 | #else | ||
2726 | fputs(s, F); | 2737 | fputs(s, F); |
2738 | #endif | ||
2727 | free(s); | 2739 | free(s); |
2728 | } | 2740 | } |
2729 | fflush(F); | 2741 | fflush(F); |
@@ -2997,7 +3009,7 @@ static var *evaluate(node *op, var *res) | |||
2997 | break; | 3009 | break; |
2998 | 3010 | ||
2999 | case XC( OC_SPRINTF ): | 3011 | case XC( OC_SPRINTF ): |
3000 | setvar_p(res, awk_printf(op1)); | 3012 | setvar_p(res, awk_printf(op1, NULL)); |
3001 | break; | 3013 | break; |
3002 | 3014 | ||
3003 | case XC( OC_UNARY ): { | 3015 | case XC( OC_UNARY ): { |
diff --git a/editors/ed.c b/editors/ed.c index d3ae8da92..c50faeefa 100644 --- a/editors/ed.c +++ b/editors/ed.c | |||
@@ -553,7 +553,7 @@ static int printLines(int num1, int num2, int expandFlag) | |||
553 | fputc_printable(ch | PRINTABLE_META, stdout); | 553 | fputc_printable(ch | PRINTABLE_META, stdout); |
554 | } | 554 | } |
555 | 555 | ||
556 | fputs("$\n", stdout); | 556 | fputs_stdout("$\n"); |
557 | 557 | ||
558 | setCurNum(num1++); | 558 | setCurNum(num1++); |
559 | lp = lp->next; | 559 | lp = lp->next; |
diff --git a/editors/vi.c b/editors/vi.c index bfe05d613..8181a5384 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -524,7 +524,7 @@ static void show_help(void) | |||
524 | 524 | ||
525 | static void write1(const char *out) | 525 | static void write1(const char *out) |
526 | { | 526 | { |
527 | fputs(out, stdout); | 527 | fputs_stdout(out); |
528 | } | 528 | } |
529 | 529 | ||
530 | #if ENABLE_FEATURE_VI_WIN_RESIZE | 530 | #if ENABLE_FEATURE_VI_WIN_RESIZE |
@@ -3113,12 +3113,15 @@ static int find_range(char **start, char **stop, char c) | |||
3113 | do_cmd(c); // execute movement cmd | 3113 | do_cmd(c); // execute movement cmd |
3114 | dot_end(); // find NL | 3114 | dot_end(); // find NL |
3115 | q = dot; | 3115 | q = dot; |
3116 | } else { | 3116 | } else /* if (c == ' ' || c == 'l') */ { |
3117 | // nothing -- this causes any other values of c to | 3117 | // forward motion by character |
3118 | // represent the one-character range under the | 3118 | int tmpcnt = (cmdcnt ?: 1); |
3119 | // cursor. this is correct for ' ' and 'l', but | 3119 | do_cmd(c); // execute movement cmd |
3120 | // perhaps no others. | 3120 | // exclude last char unless range isn't what we expected |
3121 | // | 3121 | // this indicates we've hit EOL |
3122 | if (tmpcnt == dot - p) | ||
3123 | dot--; | ||
3124 | q = dot; | ||
3122 | } | 3125 | } |
3123 | if (q < p) { | 3126 | if (q < p) { |
3124 | t = q; | 3127 | t = q; |