Commit Graph

168 Commits

Author SHA1 Message Date
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
Karel Zak 2ec8187eed cal: fix gettext warning
/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>
2013-10-11 12:53:56 +02:00
Pádraig Brady 233ad1fa9b cal: improve the help text and man page
* 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>
2013-10-11 10:44:21 +02:00
Benno Schulenberg 119ed9bfcd textual: tag a translator comment and put it in proper place
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:38:39 +02:00
Sami Kerola 1beb933efd cal: set statically defined data read-only
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-05 10:47:51 +02:00
Karel Zak add1924d5b cal: fix -y output for UTF8
... 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>
2013-06-17 18:09:49 +02:00
Sami Kerola 536dd3250e cal: fix few type mismatches
Sloppiness from commit e44fe47121.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-06-07 12:24:51 +02:00
Karel Zak d4be073d19 cal: improve coding style
- use static for all global variables
 - use REFORMATION_YEAR macro
 - make if() lines more readable
 - etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-28 15:33:05 +02:00
Karel Zak 201b39f001 cal: simplify colormode parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-28 15:27:22 +02:00
Sami Kerola e44fe47121 cal: remove arbitrary limit of maxium year being 9999
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>
2013-05-26 20:46:59 +01:00
Sami Kerola 91ac9ef5db cal: use Claus Tøndering's day of the week algorithm
Reference: http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#T.C3.B8ndering.27s_algorithm
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:20 +01:00
Sami Kerola d68f076f1c cal: simplify day_in_week() calculation
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>
2013-05-26 09:59:20 +01:00
Sami Kerola 8ea0caa2fb cal: mark all functions static
Proposed-by: Dave Reisner <dreisner@archlinux.org>
Reference: http://marc.info/?l=util-linux-ng&m=136717012419551&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:20 +01:00
Sami Kerola 224687082e 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>
2013-05-26 09:59:19 +01:00
Sami Kerola 201d43fd12 cal: add --color to usage()
And clean up the usage() function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:19 +01:00
Sami Kerola 7b353df28d cal: support --color[={auto,always,never}]
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>
2013-05-26 09:59:19 +01:00
Sami Kerola b283141c90 cal: de-duplicate julian specific functions
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>
2013-05-26 09:59:19 +01:00
Sami Kerola 7c0726d7e6 cal: remove unnecessary initializations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:18 +01:00
Sami Kerola e8c58289d9 cal: simplify calendar reformat calculations
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>
2013-05-26 09:59:18 +01:00
Sami Kerola 5f845cb765 cal: clean up use of constants
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>
2013-05-26 09:59:18 +01:00
Sami Kerola 3b66dfd6bb cal: convert function like definitions to functions
Reviewed-by: Thomas Bächler <thomas@archlinux.org>
Reviewed-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:18 +01:00
Sami Kerola 4aefe5e88e cal: fix preprocessor directive indendation
And code within the blocks selected by preprocessor to be live code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-26 09:59:18 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Karel Zak e66ba1bfaf cal: don't mix ncurses output functions and printf()
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>
2013-01-17 18:48:16 +01:00
Karel Zak db41a4298f misc-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:44:37 +02:00
James Le Cuirot 69cabd7204 cal: Fix building under uClibc.
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>
2012-04-16 11:13:13 +01:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Sami Kerola fbc333fec0 build-sys: check HAVE_ definitions with #ifdef [smatch scan]
Fix to `warning: undefined preprocessor identifier' messages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:46 +01:00
Karel Zak 2985e3833b cal: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:12:45 +02:00
Karel Zak 3e0b9e21af cal: indent usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 12:16:38 +02:00
Benno Schulenberg 19d646f417 cal.c: fix typo ("fistt day") in help text, seize chance to improve it
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-08 11:58:42 +02:00
Sami Kerola 33c1735400 cal: clean up few coding style issues
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:44:12 +02:00
Sami Kerola 21ba9798fb cal: fix compiler warnings
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:43:14 +02:00
Sami Kerola 022df321b1 cal: argument checking, long options and argument checking
Check numeric user inputs with strtol_on_err. Add long options
with nice looking usage.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:38:47 +02:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
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>
2011-02-14 17:45:24 +01:00
Karel Zak 2a6fd10e02 cal: follow HAVE_LANGINFO
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-15 16:48:03 +01:00
Karel Zak 37d6897f94 cal: use EXIT_* and program_invocation_short_name
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-07 10:35:32 +02:00
Pádraig Brady 104b92f848 cal: factor out and update multibyte alignment code
* include/mbsalign.h: New module interface
* lib/mbsalign.c: Updated implementation synced from coreutils
* include/Makefile.am: Add mbsalign.h
* misc-utils/Makefile.am: Make cal dependent on mbsalign module
* misc-utils/cal.c: Call mbsalign()

[kzak@redhat.com: - use min() macro from c.h]

Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16 15:16:11 +01:00
Karel Zak aebb9522b7 cal: fix first day of the week calculation on BE systems
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>
2010-02-11 16:29:05 +01:00
Karel Zak 1728253821 cal: use c.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:32:28 +02:00
Guillem Jover 76fb73ef98 cal: remove obsolete <localeinfo.h> include
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>
2009-10-09 15:17:53 +02:00
Peter Breitenlohner f06602a42a cal: fix broken computation for Sep 1752
Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
2009-07-20 15:33:50 +02:00
Peter Breitenlohner 32dec5ac25 cal: fix (harmless) typo
Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
2009-07-20 15:33:44 +02:00
Tom Prince a88057d9a3 cal: uClibc has langinfo.h but not _NL_TIME_WEEK_1STDAY.
Signed-off-by: Tom Prince <cougar@hermes>
2009-05-19 14:25:43 +02:00
Rajeev V. Pillai a43145e157 cal: Highlight today even when month or year specified
* misc-utils/cal.c: Unconditionally call time()
and highlight today where possible.

Signed-off-by: Rajeev V. Pillai <rajeevvp@gmail.com>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
2009-05-07 10:59:29 +02:00
Karel Zak dcb54fafb1 cal: remove gcc-ism from nl_langinfo() call
> 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>
2009-03-10 13:36:56 +01:00
Pádraig Brady 0a9bead039 cal: determine the first day of week from the locale
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>
2009-03-10 13:01:39 +01:00
Karel Zak 310170b83b cal: use HAVE_LIB{NCURSES,NCURSESW} instead HAVE_NCURSES
The HAVE_NCURSES is obsolete macro. The autotool generates HAVE_LIBxxx macros.

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-04-16 23:12:40 +02:00
Pádraig Brady ff87defc0d cal: fix weekday alignment for certain locales
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>
2008-01-17 02:21:53 +01:00
Karel Zak 14563c194e cal: replace errs.h with libc err.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-16 12:31:17 +02:00
Pádraig Brady d7a92b8994 cal: add support for highlighting an arbitrary date
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>
2007-10-11 14:19:39 +02:00
Jim Meyering 8c6c72bfe3 cal: avoid -Wformat warnings
Avoid this warning from gcc -Wformat:
"format not a string literal and no format arguments".

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-10-03 23:09:50 +02:00
Mike Frysinger 8b7f16fc37 build-sys: nls/locale handling in util-linux-ng general
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>
2007-09-19 23:15:21 +02:00
Karel Zak 7e7f73cf9d cal: add test code
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>
2007-07-10 23:20:42 +02:00
Karel Zak a256ea01ff cal: widechar code cleanup
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>
2007-06-12 17:46:16 +02:00
Karel Zak f406193831 cal: ifdef cleanup, non-curses/tempcap code fixes
This patche:
  - removes extra #ifdef-s,
  - fixes \n usage when compiled without curses/termcap

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-06-12 16:45:32 +02:00
Karel Zak 94b269193b cal: fix a segfault and -3m highlighting
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>
2007-06-12 16:08:58 +02:00
Karel Zak 06b04b23cd build-sys: fix ifdef ENABLE_WIDECHAR usage
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>
2007-01-30 13:49:50 +01:00
Karel Zak baf39af15b Imported from util-linux-2.13-pre2 tarball. 2006-12-07 00:26:58 +01:00