Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
It seems that people are crazy enough to assume that "cal 16" is the
year 2016, rather than 16 (2000 years ago).
This patch makes it more clear as the output is 0016.
Addresses: https://github.com/karelzak/util-linux/issues/320
Signed-off-by: Karel Zak <kzak@redhat.com>
This fixes a minor issue where cal -n 3 would mirror the spanning
behaviour of cal -3 with Gregorian calendars, instead of starting with
the current month.
Signed-off-by: Deiz <silverwraithii@gmail.com>
This allows Sunday based week 54 be highlighted, and deny week 54 for
Monday based weeks when year has only 52 weeks.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Jan 1 is always First week, and year always has 53 weeks. The week 53
may be cut short, e.g., it may and often has fewer than 7 days. Every
year 28 year intervals US week numbering continues all the way to 54th
week, such as 1972, 2000, and 2028.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1249486
Reported-by: Michal Toth
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[kzak@redhat.com: - add month_in_row to avoid extra meaning of num_month=-3,
- add header_year
- add long option for -Y
- define conflicts between -Y, -y and -n
- remove ctl.yflag]
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/cal.c:811:16: runtime error: signed integer overflow:
2147483645 + 536870911 cannot be represented in type 'int'
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Most of them catched on 32bit gcc and icc.
disk-utils/fsck.cramfs.c: printf format type
lib/boottime.c: unused variables
misc-utils/cal.c: set but never used
sys-utils/losetup.c: set but never used
sys-utils/lscpu-dmi.c: defined but not used
sys-utils/switch_root.c: comparison between signed and unsigned
tests/helpers/test_sysinfo.c: printf format type
Replace all puts, fputs and printf calls by my_putstring() because
we don't want to mix different output channels (buffers).
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
[kzak@redhat.com: - move paths to pathnames.h,
- use static path buffer]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This is done to keep things simple, when considering tests, for both 64
and 32 bit architectures. Setting the upper limit of a year value to to
2^31-1 (2147483646) should be enough for anyone.
Reported-by: Mike Frysinger <vapier@gentoo.org>
Reference: http://www.spinics.net/lists/util-linux-ng/msg08662.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
While prototypes such as 'function(int, int, char, int);' are legal they
do not help when trying to understand how the function is expected to be
used. Adding variable names gives at least a hint when looking the
prototypes.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Runtime configuration is set at the time of command line option parsing,
and other initialization. Later the configuration is read-only. This
should make code a little bit more understandable.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The long option --week still has the optional argument as --week=<wnum>
This was suggested on the mailing list by Padraig Brady and I do agree with that.
Actually, the whole idea of --week=<wnum> came from him.
Signed-off-by: Tommi Kyntola <kynde@iki.fi>
Because many years have two sections of week 52 or 53, the week that
this argument points to is the one that starts during that year (when available).
The week number in argument is also highlighted in addition to possibly visible
current/defined date highlighting.
Signed-off-by: Tommi Kyntola <kynde@iki.fi>
Added week numbers both in ISO-6801 and North America numbering.
The mode is determined by first day of the week, Monday
for ISO and Sunday for North America mode.
ISO week numbers are defined as the first Thursday being part of week 1.
The North America numbering is defined, at least by gcal, as first Sunday
being in the first week.
Signed-off-by: Tommi Kyntola <kynde@iki.fi>
/usr/bin/xgettext: Non-ASCII comment at or before misc-utils/cal.c:473.
Please specify the source encoding through --from-code.
Signed-off-by: Karel Zak <kzak@redhat.com>
* misc-utils/cal.c: Add a little doc string, and mention that the
current month is implicit if not specified. Also remove mention
of "current" from two option descriptions as a specific date may
have been specified.
* misc-utils/cal.1: Likewise.
[kzak@redhat.com: - use fputs and USAGE_SEPARATOR]
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
... in the yearly() function is a static buffer where is not space for
multibyte headers. The patch also clean ups function where we
initialize headers.
Signed-off-by: Karel Zak <kzak@redhat.com>
The change limits year to be unsigned long. In case a year + month name
exceed a column width two lines are used for them.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The day_in_week() can be made easier to read, and should return invalid
weekday at the time of missing 11 days at September 1752.
Reported-by: Thomas Bächler <thomas@archlinux.org>
References: http://www.spinics.net/lists/util-linux-ng/msg07910.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
Similar with dmesg commit 9bc2b51a06.
CC: Pádraig Brady <P@draigBrady.com>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The cost is a little bit more complex functions, while the benefit is
couple data flows fewer to mind about.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The only September 1752 offset calculation that is necessary is whether
Sun or Mon is the first day of the week.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit also adds few new symbolic names, such as DAYS_IN_WEEK. While
these definitions may look a little too trivial to have I am sure they
ease understanding what is going on in code where they are used.
Reviewed-by: Thomas Bächler <thomas@archlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fedora 18 (ncurses-libs-5.9-7.20121017, glibc-2.16-28):
$ cal | cat
Actual results:
January 2013 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8
9 10 11 1213 14 15 16 17 18 1920 21 22 23 24 25 2627 28 29 30 31
Not sure where is the problem, but it's too fragile to mix two
output methods in one code.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=896447
Signed-off-by: Karel Zak <kzak@redhat.com>
Commit fbc333fec0 broke building under uClibc because HAVE_DECL macros are set to 0, not undefined.
Signed-off-by: James Le Cuirot <chewi@aura-online.co.uk>
Solaris lacks err, errx, warn and warnx. This also means the err.h header
doesn't exist. Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
This reverts commit dcb54fafb1,
"cal: remove gcc-ism from nl_langinfo() call".
The code:
int wfd = (int)(intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY);
does not work on big-endian machines. The original solution based on
union is better.
Note that the "type punning" is not gcc-ism any more, it's allowed
by C99 (6.5.2.3).
Reported-by: Joseph Jezak <josejx@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The fact that the system does not have <langinfo.h> does not imply that
it has <localeinfo.h> (which is an ancient header from Linux libc4).
Signed-off-by: Guillem Jover <guillem@hadrons.org>
> On Tue, Mar 10, 2009 at 01:15:14PM +0100, Samuel Thibault wrote:
> That will only work with the gcc compiler, which allows to read a
> union field what you wrote in another. Shouldn't
> (int)(intptr_t)nl_langinfo() be just fine?
Signed-off-by: Karel Zak <kzak@redhat.com>
Previously it defaulted to Sunday rather than using
the value from the locale. Lauri Nurmi <lanurmi@iki.fi>
provided the detailed argument for this change while
Samuel Thibault <samuel.thibault@ens-lyon.org> provided
the information on how to read the first day of the week
from the locale correctly.
[kzak@redhat.com: - fix "cast from pointer to integer",
nl_langinfo(_NL_TIME_WEEK_1STDAY) call)]
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
For example this had too much padding: LANG=zh_CN.utf8 cal -j
while this had too little padding: LANG=hu_HU.utf8 cal
This had invalid chars: LANG=li_BE.utf8 cal
This had too few chars: LANG=si_LK.utf8 cal
Note some locales may display with slightly worse alignment
(fa_IR.utf8 for example), but that is only because the terminal
is not merging the combining characters. This happens on
gnome-terminal-2.18.3-1.fc8 at least.
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This is done by calling cal with the extra day parameter like:
cal 14 9 1752
Note the tests were updated to use the new syntax.
Note also that this patch changes the -y option
to always print a full year, even if a month or
the -[13] options are specified.
This matches the cal operation from bsdmainutils on debian
and also allows one to print a full year while
highlighting a particular date.
Signed-off-by: Pádraig Brady <P@draigBrady.com>
On Monday 03 September 2007, Karel Zak wrote:
> http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/590/focus=592
>
> I agree that we need a better support for compilation without
> locales, but from my point of view NLS != all locales stuff. The NLS
> support is subset only.
thinking about the input from everyone, i'd propose the attached ...
Only pull in locale.h as needed and move it to the common nls.h.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This patch allows to override the time() and define a different time by
TEST_TIME env. variable. The code has to be compiled with -DTEST_CAL.
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch make widechar code (cal headers initialization) more
robust. That's possible to format wide char strings by swprintf() and
non-widechar version by sprintf(). This is better than the old
solution with wcscat().
Signed-off-by: Karel Zak <kzak@redhat.com>
Fixes a segfault for certain values of $TERM
Fixes alignment issues when the highlighted day (today)
is in the last week of the month.
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
There has been unexpected mix of HAVE_WIDECHAR and ENABLE_WIDECHAR macros. The
ENABLE_WIDECHAR is old version and has to be replaced everywhere otherwise we
will see bugs with multibyte stuff.
Signed-off-by: Karel Zak <kzak@redhat.com>