summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorSami Kerola2013-04-28 16:35:26 +0200
committerSami Kerola2013-05-26 10:59:19 +0200
commit224687082e6c519c8f24b471ca51c7679a75dc00 (patch)
treeef2b0b155127c24e11a227be95ca20dc2e925e15 /misc-utils
parenttests: add cal day color corner cases (diff)
downloadkernel-qcow2-util-linux-224687082e6c519c8f24b471ca51c7679a75dc00.tar.gz
kernel-qcow2-util-linux-224687082e6c519c8f24b471ca51c7679a75dc00.tar.xz
kernel-qcow2-util-linux-224687082e6c519c8f24b471ca51c7679a75dc00.zip
cal: stop trimming whitespaces
Remove trailing spaces from output it is trivial cal | sed 's/ *$//' but padding them back is difficult. CC: Pádraig Brady <P@draigbrady.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/cal.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 9988c7b9e..ec8922e4a 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -246,7 +246,6 @@ void yearly(int, int, int);
void do_monthly(int, int, int, struct fmt_st*);
void monthly(int, int, int);
void monthly3(int, int, int);
-void trim_trailing_spaces(char *);
static void __attribute__ ((__noreturn__)) usage(FILE * out);
void headers_init(int);
@@ -496,7 +495,6 @@ do_monthly(int day, int month, int year, struct fmt_st *out) {
p = ascii_day(p, xd);
}
*p = '\0';
- trim_trailing_spaces(lineout);
snprintf(out->s[row+2], FMT_ST_CHARS, "%s", lineout);
if (has_hl)
Hrow = out->s[row+2];
@@ -561,7 +559,7 @@ monthly3(int day, int month, int year) {
w2 += (out_curm.s[i] == Hrow ? Slen : 0);
w3 += (out_next.s[i] == Hrow ? Slen : 0);
#endif
- snprintf(lineout, sizeof(lineout), "%-*s %-*s %-*s\n",
+ snprintf(lineout, sizeof(lineout), "%-*s %-*s %-*s\n",
w1, out_prev.s[i],
w2, out_curm.s[i],
w3, out_next.s[i]);
@@ -620,7 +618,6 @@ yearly(int day, int year, int julian) {
p += sprintf(p, " ");
}
*p = '\0';
- trim_trailing_spaces(lineout);
my_putstring(lineout);
my_putstring("\n");
}
@@ -746,20 +743,6 @@ ascii_day(char *p, int day) {
return p;
}
-void
-trim_trailing_spaces(char *s)
-{
- char *p;
-
- for (p = s; *p; ++p)
- continue;
- while (p > s && isspace(*--p))
- continue;
- if (p > s)
- ++p;
- *p = '\0';
-}
-
/*
* Center string, handling multibyte characters appropriately.
* In addition if the string is too large for the width it's truncated.