projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unexpand: fix "a b"\n" input case
[oweals/busybox.git]
/
coreutils
/
expand.c
diff --git
a/coreutils/expand.c
b/coreutils/expand.c
index 60ac9f56834fafb34de09b488507ff7eb9c5c378..cfb1e25d9216eebbd72593d18433233aa53afe00 100644
(file)
--- a/
coreutils/expand.c
+++ b/
coreutils/expand.c
@@
-81,12
+81,13
@@
static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
while (*ptr) {
unsigned n;
while (*ptr) {
unsigned n;
- unsigned len;
+ unsigned len
= 0
;
while (*ptr == ' ') {
while (*ptr == ' ') {
- column++;
ptr++;
ptr++;
+ len++;
}
}
+ column += len;
if (*ptr == '\t') {
column += tab_size - (column % tab_size);
ptr++;
if (*ptr == '\t') {
column += tab_size - (column % tab_size);
ptr++;
@@
-94,16
+95,18
@@
static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
}
n = column / tab_size;
}
n = column / tab_size;
- column = column % tab_size;
- while (n--)
- putchar('\t');
+ if (n) {
+ len = column = column % tab_size;
+ while (n--)
+ putchar('\t');
+ }
if ((opt & OPT_INITIAL) && ptr != line) {
if ((opt & OPT_INITIAL) && ptr != line) {
- printf("%*s%s",
colum
n, "", ptr);
+ printf("%*s%s",
le
n, "", ptr);
break;
}
n = strcspn(ptr, "\t ");
break;
}
n = strcspn(ptr, "\t ");
- printf("%*s%.*s",
colum
n, "", n, ptr);
+ printf("%*s%.*s",
le
n, "", n, ptr);
# if ENABLE_FEATURE_ASSUME_UNICODE
{
char c;
# if ENABLE_FEATURE_ASSUME_UNICODE
{
char c;