Commit Graph

127 Commits

Author SHA1 Message Date
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Ruediger Meier 12f17a23df misc: fix typos using codespell
# command used was:
 $ ~/src/codespell/codespell \
   -w -D /home/rudi/src/codespell/build/lib/codespell_lib/data/dictionary.txt \
   $(git ls-files | grep -v "^po/\|\.xz$\|\.gz$\|\.bz2$\|\.img$\|^Documentation/releases/")

 BTW some manually grammer fixes:
   s/uses/used/
   s/begin/beginning/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-01 00:01:43 +01:00
Karel Zak c880563200 cal: support abbreviated month names
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-07 16:10:28 +02:00
Karel Zak 535fd6d2b6 cal: support alone month name parameter
For example 'cal August' to print August for the current year.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-07 16:02:36 +02:00
Karel Zak c49fb9cacd cal: remove err message from monthname_to_number()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-10-07 15:24:32 +02:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Karel Zak 58149472ad cal: cleanup non-ncurses build 2016-06-09 11:39:24 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak cd28d6a405 cal: support timestamps
For example

	$ cal '2 weeks ago'

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-31 18:27:20 +02:00
Karel Zak 731441ac5b cal: allow to specify month by name
For example:

	$ cal August 2016

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-31 13:53:58 +02:00
Karel Zak e671a62ef8 cal: use %04d for year
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>
2016-05-18 14:43:20 +02:00
Sami Kerola a3e1c47acc cal: remove libtermcap arguments to my_tgetstr()
Missed in commit b4566a8a8d.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-03-09 11:44:05 +01:00
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +01:00
Sami Kerola b4566a8a8d build-sys: remove libtermcap support
It is unlikely anyone is going to build this project on system where
libtermcap is available.  Fedora project obsoleted libtermcap 2007-12-12 in
favour of ncurses.  Debian made same move 2005.

Reference: https://fedoraproject.org/wiki/Deprecated_packages
Reference: https://www.debian.org/doc/manuals/debian-faq/ch-compat.en.html#s-termcap
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-01-26 11:45:14 +01:00
Deiz ccf3dd50ce cal: Add --span option
This allows the date spanning behaviour of -3 to be used with other
month ranges.

Signed-off-by: Deiz <silverwraithii@gmail.com>
2015-10-09 20:39:02 -04:00
Deiz d4cb626da2 cal: Track date span independently from months_in_row
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>
2015-10-09 20:35:17 -04:00
Sami Kerola 03f8bc1f32 cal: check biggest week number correctly when highlighting
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>
2015-08-31 10:15:12 +02:00
Sami Kerola e1abe57e18 cal: replace magic constants with symbolical values
This makes it easier to know what the values in guestion represent.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-31 10:15:11 +02:00
Sami Kerola efafeaf684 cal: correct gregorian week numbering
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>
2015-08-31 10:15:09 +02:00
Sami Kerola c5ad7b59ac cal: fix January 1753 week number printout
Earlier output was clearly broken.

$ cal -w 1 1753
      January 1753
   Su Mo Tu We Th Fr Sa
51     1  2  3  4  5  6
52  7  8  9 10 11 12 13
52 14 15 16 17 18 19 20
52 21 22 23 24 25 26 27
52 28 29 30 31

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-18 11:41:48 +02:00
Max Klinger 7800509b21 cal: add -Y and -n <num>
[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>
2015-04-07 15:18:38 +02:00
Karel Zak 2a4b073e8b cal: care about setuprterm() result
References: https://bugzilla.suse.com/show_bug.cgi?id=903440
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-12 11:50:07 +01:00
Karel Zak 5d51dc2a7f colors: cleanup man pages, add hint to usage()
cfdisk, fdisk, calm dmesg and hexdump

Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:40:06 +01:00
Ruediger Meier a79735f69a cal: use int64_t instead of long
Followup 26f3a386, bigyear test was broken on ppc.

CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-02-10 11:18:51 +01:00
Sami Kerola 26f3a38673 cal: fix signed integer overflow [AddressSanitizer]
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>
2014-12-19 09:10:48 +00:00
Sami Kerola 34a7e101cc cal: remove unnused structure and definition
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:25:14 +01:00
Ruediger Meier 60cb2c3720 build: fix some compiler warnings
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
2014-05-30 01:18:09 +02:00
Ruediger Meier 07ac4aa9d4 cal: all output must use my_putstring
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>
2014-05-27 16:12:56 +02:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[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>
2014-03-11 09:38:09 +01:00
Sami Kerola 0c6dc4b99f cal: remove unnecessary static variables
Not in use since commit 95f4adde86.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-02-10 19:09:37 +01:00
Sami Kerola 4a7424a5ef cal: limit year to 32 bit value
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>
2014-02-06 16:55:22 +01:00
Sami Kerola 95f4adde86 cal: use month contents structure for --year printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:55 +01:00
Sami Kerola f60117b53e cal: use month contents structure for --three printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola 852c8d2110 cal: add month contents structure
This changes determination of calendar month content completely, as well
as outputing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola efce94ec1c cal: determine how many header lines are needed at initialization
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola ffc5635798 cal: make user request to be part of read-only control struct
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola 71ff238e49 cal: determine output width at beginning of run and reuse result
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola 44df9bd4bf cal: simplify ascii_weeknum() function
Either the week is or isn't highlighted, there is no need to over
complicate printing of that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola ff90b006eb cal: make day_in_week() use same variable names as other functions
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:54 +01:00
Sami Kerola 0106c9e26c cal: add input variable names to function prototypes
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>
2013-12-06 10:58:54 +01:00
Sami Kerola 76c4bbcc6e cal: rename ascii_wnum() to ascii_weeknum()
Week is not long word, so it does not need to be enshorted and made more
difficult to understand.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-06 10:58:52 +01:00
Sami Kerola b549058bd5 cal: use control structure for run time configuration
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>
2013-12-06 10:58:52 +01:00
Karel Zak c1732e6234 cal: fix coding style
- mostly space around operators
 - split yearly(), move weeknum stuff to append_wnum()

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-22 11:54:42 +02:00
Tommi Kyntola af7c483e62 cal: remove optional from short arg -w
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>
2013-10-22 10:39:08 +02:00
Tommi Kyntola aae4f87e68 cal: added argument option for -w|--week to display that week
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>
2013-10-22 10:32:32 +02:00
Tommi Kyntola c36c4a4e4d cal: added -w|--week for showing week numbers
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>
2013-10-22 10:27:03 +02:00
Karel Zak a814f0bb76 cal: fix compiler warning on systems without term libs
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-15 15:44:40 +02:00
Karel Zak 7bd3336f9a cal: fix warning when compiled --without-ncurses
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-15 13:29:19 +02:00