Fixed some of (easy) newly detected Coverity bugs. Those are mostly
innocent ones (performance) and not new (detected because of new release
of Coverity).
Setting line buffering does not appear to work correctly on Powershell nor
cmd.exe and instead behaves like full buffering (lines do not appear
util flush).
Use inline ANSI escape sequences instead of modifiers.
This allows more convenient formatting without the need to use multiple
calls (possibly interleaving).
ANSI escape sequences are nowadays supported also in Windows terminals
(PS, cmd).
The parsing was done early before dynamic modules that export own
parameters were loaded.
Now, the parsing is done in 2 steps -- first scan only for already known
parameters (output buffer settings is needed for preinit), ignore
"help".
The second step is to do the full parse (in main), when there are all
modules loaded (latter in common_preinit()).
Fixes#237.
The regression was introduced by 1dc89920.
- show usage with "help"
- print error if setvbuf fails (but do not return an error - there may
be some platform problem but the setting is done always, so it would
unconditionally prevent UltraGrid from running)
- if usage error (or help) occurs, exit UltraGrid
setvbuf() should be called on a stream prior to any operation with the
stream. Previously it was to late -- it was even after configuration
summary was printed to stdout.
The value 0 is mentioned in man setvbuf(3) and indeed glibc
implements setlinebuf as:
_IO_setvbuf (stream, NULL, 1, 0);
However, except the mention in manual page, this extension doesn't seem
to be anywhere mentioned (not clear if valid with _IOFBF) and it is not
widespread except glibc, since [1] forbids that. Also using _IOLBF+0
behaves in the same way as _IOLBF+BUFSIZ (buffers BUFSIZ bytes).
[1] https://www.ibm.com/docs/en/i/7.1?topic=functions-setvbuf-control-buffering
Set output buffering to "line" for stdout and "no" for stderr. This is
the case usually but not always (eg. MSYS, GUI console) so make this
explicit to be deterministic.
Some macros are quite common so it is perhaps more wise to use a
separate header.
Also moved ref_count_init_once and ref_count_terminate last to misc.h.
Unless MALLOC_TRACE environment variable is set, no hook is installed
and the calls have no effect. On the other hand, if we compile it
unconditionally, it can be used without need to recompile UltraGrid.
mtrace(), however, doesn't seem to be much helpful (compared to eg.
valgrind).
This looks to be more reasonable - user may not know that s/he actually
wants to set it. The thing is that this may be needed only for stdout -
user than doesn't detect that some output is missing.
Skip repeating registration of the same parameter.
This allows registration of the param from within more modules (eg.
common file included in multiple plugins). Warning is issued if already
registered param has a different description.
- allow also comma as a delimiter (WLOG - comma cannot be part of
current set of options)
- print token, that is not understood
- hint that "bps" must be in bits-per-second (% 8 = 0)