summaryrefslogtreecommitdiff
path: root/sfeed_plain.c
AgeCommit message (Collapse)Author
2021-08-03code-style: use a newline before return in main()Hiltjo Posthuma
2021-06-01portability and standards: add BSD-like err() and errx() functionsHiltjo Posthuma
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-01-10optimize converting UNIX timestamp to localtimeHiltjo Posthuma
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;
2020-07-05format tools: don't skip items with a missing/invalid timestamp fieldHiltjo Posthuma
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-04-01util: improve/cleanup parseline()Hiltjo Posthuma
- 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-01-24cleanup some includesHiltjo Posthuma
2019-05-10sfeed_plain: start with timestamp, consistent with sfeed_twtxtHiltjo Posthuma
2018-11-04whitespace and comment fixHiltjo Posthuma
2018-03-11sfeed_plain: don't flush line (was used for tail -f)Hiltjo Posthuma
2018-03-11include <sys/types.h> for types size_t, ssize_t etcHiltjo Posthuma
This makes sure xml.c in particular can be compiled without further feature macros.
2018-02-18sfeed_plain: force flush line to output, useful for tail -fHiltjo Posthuma
2018-02-18sfeed_plain: utf-8 pad nameHiltjo Posthuma
2017-12-24format programs: ignore fields with an invalid timeHiltjo Posthuma
this makes sure tail -f with multiple files ignores the ==> file <== lines too.
2017-06-29sfeed_plain: use setlocale() for glibcHiltjo Posthuma
this is required for mbtowc for glibc (not required in musl or on OpenBSD).
2017-04-27simplify pledge stubHiltjo Posthuma
2016-08-06add USE_PLEDGE, remove pledge dummy functionHiltjo Posthuma
2016-04-10remove basename, just use last part of the path...Hiltjo Posthuma
... as a bonus it also saves an allocation.
2016-03-29add time parsing to sfeed itself, remove time fieldHiltjo Posthuma
- 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.
2016-02-28null-terminate line at newline from getline()Hiltjo Posthuma
2016-02-27various improvementsHiltjo Posthuma
- 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.
2015-10-04portability: dont use HOST_NAME_MAX, just use 256 as maximumHiltjo Posthuma
2015-10-02sfeed_plain: remove some spaces for slightly more screen space :)Hiltjo Posthuma
2015-08-22use HOST_NAME_MAX for hostnameHiltjo Posthuma
2015-08-16code-style + no need to zero static variablesHiltjo Posthuma
2015-08-07util: strtotime: stricter time parsingHiltjo Posthuma
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.
2015-08-05sfeed_plain: save a character before statusHiltjo Posthuma
2015-08-02sfeed_plain: remove control char check, assume input is sanitized for format ↵Hiltjo Posthuma
programs
2015-08-02util: simplify parseline() and check t for strtotime().Hiltjo Posthuma
2015-07-31Various improvementsHiltjo Posthuma
- 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.
2015-07-30check for time() failureHiltjo Posthuma
2015-07-28improve code-style and consistencyHiltjo Posthuma
2015-07-28sfeed_plain: xbasename, free memory after useHiltjo Posthuma
2015-06-21improvementsHiltjo Posthuma
2015-01-03time fixesHiltjo Posthuma
2015-01-02cleanupHiltjo Posthuma
- 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().
2014-11-11code style, use actual column width of charHiltjo Posthuma
2014-11-11move printutf8padded to utilHiltjo Posthuma
2014-06-28handle invalid values of strto*lHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-27small fixesHiltjo Posthuma
reorder static -> public xml functions. Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-05-13cleanup, tested with tccHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-09cleanup, remove javascript hotkeyHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-31small cleanupHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-31new versionHiltjo Posthuma
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>
2013-05-20update sfeed_plain: whoops, argv is unusedHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2013-05-20update sfeed_plain: pad time format, make code more readableHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2012-11-11show formatted time, dont show interpreted time since its not always correctunknown
Signed-off-by: unknown <hiltjo@.(none)>
2012-08-03Add base url of a site parameter for sfeedrcHiltjo Posthuma
This allows to have a feed on a different domain but specify the base url of links if links in the feed are relative. Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2012-08-03New initial repoHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>