Commit Graph

1421 Commits

Author SHA1 Message Date
Karel Zak a31bb9b6a1 cal: clean up man page synopsis syntax
Let's use '[ ]' rather than '< >' to be compatible with our another
man pages. Note that all time addressing on cal(1) command line is
optional.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1542883
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-07 11:19:44 +01:00
Jakub Wilk f04c77f0a3 findmnt.8: remove spurious spaces before "--tree" and "--verbose"
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-02-04 19:31:17 +01:00
Karel Zak b9d9ab7dae cal: add ifdef TEST_CAL
The test program follows CAL_TEST_TIME=<sec> rather than libc time().
It allows to use cal(1) in regression tests in cases where output
depends on the current time.

(We already use the same for example for logger.)

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-02 10:05:15 +01:00
Karel Zak 79d6aa3811 findfs: don't include exitcodes.h
The code uses findfs return codes only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 14:51:55 +01:00
Karel Zak f066c107ce cal: remove extra space after year output
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:17:10 +01:00
Karel Zak 37bd991f77 cal: don't use year header for -1, -3 or -n
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:14:15 +01:00
Karel Zak 8315a2ff15 cal: follow terminal width
* modify number of months in row according to the terminal width
* don't print blank space behind last char on row

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:10:06 +01:00
J William Piggott d7db28c6d6 cal: do not set months_in_row with -3 option
Having the -3 option set months_in_row causes ordinal days
to wrap; it overrides the automatic handling of months_in_row
that falls back to 2 month columns for ordinal days.

Before:
cal -3j 2020
                           2020

            July                         August                      September
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
    182 183 184 185 186 187                   213 214 215   244 245 246 247 248 249 250
188 189 190 191 192 193 194   216 217 218 219 220 221 222   251 252 253 254 255 256 257
195 196 197 198 199 200 201   223 224 225 226 227 228 229   258 259 260 261 262 263 264
202 203 204 205 206 207 208   230 231 232 233 234 235 236   265 266 267 268 269 270 271
209 210 211 212               237 238 239 240 241 242 243   272 273

Patched:
cal -3j 2020
                           2020

          December                      January
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
335 336 337 338 339 340 341                 1   2   3   4
342 343 344 345 346 347 348     5   6   7   8   9  10  11
349 350 351 352 353 354 355    12  13  14  15  16  17  18
356 357 358 359 360 361 362    19  20  21  22  23  24  25
363 364 365                    26  27  28  29  30  31

          February
Sun Mon Tue Wed Thu Fri Sat
                         32
 33  34  35  36  37  38  39
 40  41  42  43  44  45  46
 47  48  49  50  51  52  53
 54  55  56  57  58  59  60

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 2bcf8f7934 cal: honor num_months when only a year argument
I don't know if this was an oversight or an overzealous
interpretation of POSIX. Just in case, I'll address the
POSIX possibility. POSIX description for cal(1) says:

  If only the year operand is given, cal shall produce a
  calendar for all twelve months in the given calendar year.

It also says that cal(1) has no options, so in that context
if an option is given then it should be expected to override
POSIX behavior.

Before patched all of these command displayed a full year:
cal -1 2020
cal -3 2020
cal -n6 2020

Patched the number of months options are honored.

This patch also fixes the -1 option which was a no-op.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 6304358cb7 cal: fix first week calculation
Commit efafeaf set 1 Jan as week 1, but the change
was missed in week_to_day() and in the man page.

Before
cal --week=40 --iso 1752
      October 1752
   Su Mo Tu We Th Fr Sa
41  1  2  3  4  5  6  7
42  8  9 10 11 12 13 14
43 15 16 17 18 19 20 21
44 22 23 24 25 26 27 28
45 29 30 31

Patched
cal --week=40 --iso 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36                 1  2
37  3  4  5  6  7  8  9
38 10 11 12 13 14 15 16
39 17 18 19 20 21 22 23
40 24 25 26 27 28 29 30

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
J William Piggott e572a765f9 cal: fix week calculations for 1752
Before:
cal --week=39 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36        1  2 14 15 16
37 17 18 19 20 21 22 23
38 24 25 26 27 28 29 30

Patched:
cal --week=39 1752
      October 1752
   Su Mo Tu We Th Fr Sa
39  1  2  3  4  5  6  7
40  8  9 10 11 12 13 14
41 15 16 17 18 19 20 21
42 22 23 24 25 26 27 28
43 29 30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
Rafal Luzynski 4e12a62e88 cal: Use ALTMON_* correctly
cal: use ALTMON_* and _NL_ABALTMON_* constants to display
months in a standalone form correctly.  These constants have just
been newly added to glibc.  ALTMON_x has been used in BSD family
since 1990s and has been accepted as the future POSIX extension.
_NL_ABALTMON_* is exclusively a GNU extension but it is expected
to be added to POSIX in future.

More info: https://sourceware.org/bugzilla/show_bug.cgi?id=10871
2018-01-22 11:50:50 +01:00
J William Piggott 1dca3edc36 cal: fix julian calendars for large years
Before:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Patched:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 11:33:20 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
J William Piggott a4b55ad008 cal: update man page
Update cal.1 with the new options --reform and --iso.

Also add information about the calendar systems used and
the difference between the --julian option and the Julian
calendar system.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:43 -05:00
J William Piggott ae51e7b429 cal: add option to set Gregorian reform date
Create the new option: --reform <1752|gregorian|iso|julian>

This adds the capability to display either the proleptic Gregorian or
the Julian calendar systems exclusively.

Also create the option --iso as alias of --reform=gregorian.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:24 -05:00
J William Piggott db9baa8ab7 cal: move REFORMATION_YEAR to control struct
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-15 11:06:36 -05:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Kenyon Ralph deff4975a1
rename.1: fix typo, where -> were 2017-12-23 13:44:34 -08:00
Karel Zak 6ce7eca36c cal: fix multi-byte comment, explain in better way
On Sun, Dec 17, 2017 at 07:47:49PM -0500, J William Piggott wrote
> * it contains multi-byte characters (which is what drew me to reading it).
> * it truncates one very important piece of the formula: ". . . (mod 7)."
> * it explains the values for 'e', but there is no 'e' in the code.
> * it doesn't include a row resolving 'e' in the table, so it is not
>    obvious what it relates to in the code.
> * without citing it as an external reference, the comment language is confusing.

Co-Author: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 12:44:03 +01:00
Karel Zak 7468a8d106 whereis: fix typo in debug message
Reported-by: Matthew White <mehw.is.me@inventati.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:52:57 +01:00
Karel Zak b9c650106b Revert "cal: simplify leap year rule"
It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267.
2017-12-14 13:19:08 +01:00
Karel Zak 3c49b23ad6 cal: explain magic values for day of week calculation
Based on BERNDT E.SCHWERDTFEGER papers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-13 19:09:56 +01:00
Masatake YAMATO 616e75c02c fincore: fix a typo in fincore.1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-13 13:06:54 +01:00
Karel Zak 856d856a98 mcookie: properly initialize hash
This stupid mistake has been introduced by commit 46ae163a8e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:09:13 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Sami Kerola 378d58abb1 rename: use access(3) to check if a file exists
This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:12 +01:00
Sami Kerola bfcd327541 man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:15 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Karel Zak 06a27566e1 lsblk: add hint about perms to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 12:31:58 +01:00
Karel Zak b9bd8dc267 cal: simplify leap year rule
Gregorian rule for leap years has been adopted by reformation in year
1782 (Calendar Act 1750), but all tools (date, SQL servers, etc. etc.)
don't care about it and apply the new rule for all year -- including
years before the reformation.

It's better to be compatible with another tools than try to be perfect :-)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1507271
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 17:34:19 +01:00
J William Piggott 4111bb3ab5 lib/timeutils: add common ISO timestamp masks
* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-10 16:34:55 -05:00
Karel Zak 4707bc83e1 lslocks: add note about OFDLCK
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-03 11:20:41 +01:00
Karel Zak c61e986fd0 lib/signames: remove signame array from header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-23 13:18:57 +02:00
Karel Zak c5910c7f27 Merge branch 'kill-child-feature' of https://github.com/nh2/util-linux
* 'kill-child-feature' of https://github.com/nh2/util-linux:
  unshare: Allow passing <signame> to --kill-child
  unshare: Add --kill-child option.
  signames: Make input char buffers const
  kill: Extract signal names into signames.h/signames.c
2017-10-23 12:58:21 +02:00
Karel Zak beaca64a6c blkid: improve man page wording
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 23:26:45 +02:00
Karel Zak 27fbfef33c blkid: more info about ambivalent results to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 12:01:41 +02:00
Karel Zak 12786a9015 blkid: cleanup man page info about lsblk
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 11:45:41 +02:00
Niklas Hambüchen 6855f6e80b kill: Extract signal names into signames.h/signames.c 2017-10-14 04:46:13 +02:00
Karel Zak 2d4c226dfb logger: keep header generators independent on connection
* avoid memory leaks
* don't use incomplete or header after free()

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 14:21:27 +02:00
Karel Zak 5794087292 fincore: make sure mmap(NULL, ...) [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 12:44:55 +02:00
Karel Zak e92d55e6cb logger: allow to reconnect on initial failed connect too
The current code sets noact flag if unix socked connection failed. This is ugly.
We want to reconnect always in all cases (well, except --socket-error=on).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-11 12:35:24 +02:00
Karel Zak 87ac63c9fa logger: add dummy fallback for OSX
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 14:45:55 +02:00
Karel Zak caf6ac6e59 logger: reconnect on failed send()
The libc syslog() reconnects on failed send(). We need the same thing
as logger(1) is expected as long time running tool. For example
recommended Apache configuration is:

	ErrorLog "| /usr/bin/logger -t apache_error -p local6.debug"

The issue is that connection endpoint (e.g. syslogd) maybe restarted.
The simple way how to test is:

	for i in $(seq 0 3600); do echo "This is message number $i"; sleep 1; done | logger --tcp --server 127.0.0.1 --port 514

and restart your syslog. The current implementation gets SIGPIPE or
write warning message, but it never reconnect.

Addresses: https://github.com/karelzak/util-linux/issues/363
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 13:56:30 +02:00
Karel Zak 774178f727 Merge branch 'patch-1' of https://github.com/aner-perez/util-linux 2017-09-15 14:45:36 +02:00
Karel Zak ae1c9d6008 uuidparse:fix stack-buffer-overflow [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:45 +02:00
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Karel Zak 8b318eb25e logger: make stdin parsing more friendly to static analyzers
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 12:54:54 +02:00
Aner Perez ed21c47aa1 Example for renaming foo? does not work as described
Command for renaming foo? should add 2 zeros to make all the file names have 3 digits as described in the example results.
2017-09-14 11:30:53 -04:00
Karel Zak e12364cdfb lsblk: small man page change in return codes description
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-07 10:03:18 +02:00