Commit Graph

15 Commits

Author SHA1 Message Date
Hiltjo Posthuma ebc33326e1 Revert "rm sys/types.h include and improve portability"
This reverts commit db1dcafd03.

This is needed. Tested on an (old) Slackware 11 install.
2022-03-27 14:57:05 +02:00
Hiltjo Posthuma db1dcafd03 rm sys/types.h include and improve portability
This include is not needed. It was intended for ssize_t but this is already
defined by stdio.h for getline().
2022-03-25 23:18:58 +01:00
Hiltjo Posthuma 665ce267d9 check write errors on the output stream after each feed
This will detect write errors sooner.
2022-03-20 17:49:13 +01:00
Hiltjo Posthuma fad48ffa27 stricter error checking in file streams (input, output)
This also makes the programs exit with a non-zero status when a read or write
error occurs.

This makes checking the exit status more reliable in scripts.

A simple example to simulate a disk with no space left:

	curl -s 'https://codemadness.org/atom.xml' | sfeed > f
	/mnt/test: write failed, file system is full
	echo $?
	0

Which now produces:

	curl -s 'https://codemadness.org/atom.xml' | sfeed > f
	/mnt/test: write failed, file system is full
	write error: <stdout>
	echo $?
	1

Tested with a small mfs on OpenBSD, fstab entry:

	swap /mnt/test mfs rw,nodev,nosuid,-s=1M 0 0
2022-03-15 14:46:46 +01:00
Hiltjo Posthuma 7199cd10a9 code-style: use a newline before return in main() 2021-08-03 20:43:54 +02:00
Hiltjo Posthuma 7c78c67806 code-style: change gmtime to the reentrant/thread-safe gmtime_r
No functional or performance difference (intended) because these programs are
not threaded.
2021-07-19 12:50:44 +02:00
Hiltjo Posthuma 55ac2338fc portability and standards: add BSD-like err() and errx() functions
These are BSD functions.
- HaikuOS now compiles without having to use libbsd.
- Tested on SerenityOS (for fun), which doesn't have these functions (yet).
  With a small change to support wcwidth() sfeed works on SerenityOS.
2021-06-01 18:21:08 +02:00
Hiltjo Posthuma 276d5789fd format tools: don't skip items with a missing/invalid timestamp field
Handle it appropriately in the context of each format tool. Output the item but
keep it blanked.

NOTE: maybe in sfeed_twtxt it should use the current time instead?
2020-07-05 15:57:02 +02:00
Hiltjo Posthuma 7c99000c20 util: improve/cleanup parseline()
- remove a check that has no use/can never happen.
- remove the return value as it's unused and the input size is known.
- fix an old comment that doesn't reflect what the function does anymore.
2020-04-01 18:49:24 +02:00
Hiltjo Posthuma eabed01f85 sfeed_twtxt: fix error message if gmtime() fails, "localtime" -> "gmtime" 2020-03-15 15:00:15 +01:00
Hiltjo Posthuma d4c8c60b38 cleanup some includes 2020-01-24 02:14:57 +01:00
Hiltjo Posthuma 28b37c1c8c whitespace and comment fix 2018-11-04 18:25:24 +01:00
Hiltjo Posthuma 663b4a4e04 sfeed_twtxt: slightly nicer output 2018-08-23 13:59:37 +02:00
Hiltjo Posthuma b7f7a502a0 sfeed_twtxt: dont use the author and mention style, use a regular link
Thanks trqx for pointing it out!
2018-08-22 16:54:23 +02:00
Hiltjo Posthuma 6446070da5 add sfeed_twtxt format program: format to a twtxt feed 2018-08-22 16:24:42 +02:00