Age | Commit message (Collapse) | Author |
|
Separate the common pattern to get the time to compare new items in format
tools to the new util function: getcomparetime().
Some changes and notes:
- Change it so it is OK to set this value to 0 or negative (in the future).
- sfeed_curses: truncating newmaxsecs to an int would limit the value too much.
- Just use strtotime() and parse the value to time_t. This is a signed long
(32-bit, until 2038) or signed long long (64-bit) on most platforms.
- sfeed_curses gets the comparison time on reload aswell and it needs errno =
0, because it uses die(). time() is not guaranteed to set an errno if it fails.
- Rename environment variable to $SFEED_NEW_AGE.
|
|
By introducing the new environment variable $SFEED_NEW_MAX_SECS in all
sfeed_* utilities marking feeds as new based on comparing their age, it
is now possible to override this age limit.
This allows, for example, to be notified about new feeds within the last
hour with
SFEED_NEW_MAX_SECS=3600 sfeed_plain ~/.sfeed/feeds/*
while creating a beautiful web report for last week's news by
SFEED_NEW_MAX_SECS=604800 sfeed_html ~/.sfeed/feeds/*
|
|
This reverts commit db1dcafd03997127f2cbc82376e2cc8df9b77356.
This is needed. Tested on an (old) Slackware 11 install.
|
|
This include is not needed. It was intended for ssize_t but this is already
defined by stdio.h for getline().
|
|
This will detect write errors sooner.
|
|
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
|
|
Use errx, time(NULL) does not set errno. For sfeed_curses reset errno so it
doesn't print a random error if it failed.
POSIX recommends checking against (time_t)-1 on failure.
Note that some implementation, like the OpenBSD man page says time() cannot
fail.
|
|
|
|
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.
|
|
Make a huge difference (cuts the time in half to process the same amount of
lines) on atleast glibc 2.30 on Void Linux. Seems to make no difference on
OpenBSD.
- This removes atleast one heap allocation per line (checked with valgrind).
This is because glibc will strdup() the environment variable $TZ and free it
each time, which is pointless here and wasteful.
- localtime_r does not require to set the variables like tzname.
In glibc-2.30/time/tzset.c in __tz_convert is the following code and comment:
/* Update internal database according to current TZ setting.
POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname.
This is a good idea since this allows at least a bit more parallelism. */
tzset_internal (tp == &_tmbuf && use_localtime);
This makes it always tzset() and inspect the environment $TZ etc. While with
localtime_r it will only initialize it once:
static void tzset_internal (int always) {
[...]
if (is_initialized && !always)
return;
|
|
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?
|
|
- 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.
|
|
|
|
|
|
|
|
|
|
This makes sure xml.c in particular can be compiled without further
feature macros.
|
|
|
|
|
|
this makes sure tail -f with multiple files ignores the ==> file <== lines too.
|
|
this is required for mbtowc for glibc (not required in musl or on OpenBSD).
|
|
|
|
|
|
... as a bonus it also saves an allocation.
|
|
- less overhead (we only need GMT time) so no setenv("TZ", ...) tzset() crap.
- timezone format (for example %z in strptime) is non-standard,
this will add some lines of code and some complexity to our code though, but
the trade-off is worth it imho.
|
|
|
|
- pledge tools and add define to enable it on platforms that support it, currently
only OpenBSD 5.9+
- separate getline and parseline functionality.
- use murmur3 hash instead of jenkins1: faster and less collisions.
- make some error messages a bit more clear, for example with path truncation.
- some small cleanups, move printutf8pad to util.
|
|
|
|
|
|
|
|
|
|
as input: an empty string or non-digit characters are digits are considered an
error now. Still, for the format tools output the formatted time string as
time_t 0 on a parse error.
|
|
|
|
programs
|
|
|
|
- Only escape characters in "content" field, these can contain newlines.
- Trim newlines and tabs, etc from the title, id and author fields.
- Make decodefield, xmlencode functions easier to "chain" without allocatting
new buffers.
- Move printutf8pad from util (only used by sfeed_plain) to sfeed_plain.
- Update README, still need to update the man-page and improve the documentation
in general.
- Code cleanup.
|
|
|
|
|
|
|
|
|
|
|
|
- dont free at end (not needed in our case).
- use 0 and 1 instead of EXIT_SUCCESS, EXIT_FAILURE.
- use err (from err.h) instead of custom die().
|
|
|
|
|
|
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
reorder static -> public xml functions.
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
lots of things changed, but cleanup todo. changelog and consistent stream of small updates will come in the future.
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
|