Move the "foreign" option into configure.ac

This makes it possible to use autoreconf(1) instead of autogen.sh

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Remove autogen.sh

With the latest patch, we can use autoreconf -i to get the job that
autogen.sh did, done. So there's no need to have the latter here
anymore.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Remove an unnecessary pointer to array

Be a little more explicit instead of relying on the compiler to optimize
the variable away.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Fix 1-byte heap overflow in ul_buffer_finalize

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Don't create unnecessary libtool wrapper scripts for tests

This marginally speeds up build, and simplifies debugging/valgrind runs

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Don't use \f in JSON

JSON-c 0.9 does not parse \f, so fall back to \uNNNN for now.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Test escaping of all control characters

... now that \f does not break the test.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use a static exception map

* Make the map static, read-only and preinitialized, to avoid
  thread-safety problems.
* Invert the map, making it non-zero for exceptional characters
  (so that non-exceptional characters don't need to be mentioned)
* Tighten the set of exceptional characters, so that most of ASCII
  goes through the fast path.

This increases the speed of test_perf_* by 7.7-20.6%.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Fix error handling in buffer.c

* Don't lose old msg on realloc() failure
* Don't dereference NULL on failure when
  buffer = (...)
  if (!buffer) { buffer->len = orig_len; ...}
* To avoid the above pattern, use integer return values:
  "buffer" itself will not change in any case.
* Add missing error handling

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Change return type of _ul_str_escape

Use an integer instead of pointer, like in the other cases in buffer.c.
We won't need the return value in the future.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Simplify extending the buffer

Most of the callers know how much the buffer needs extending, so don't
ask them for the total size: new _ul_buffer_reserve_size replaces
_ul_buffer_ensure_size, and the fast path is now inlined.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Use pointers instead of offsets in ul_buffer_t

This avoids various additions and subtractions on the fast path.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Escape values directly into a buffer

Instead of precomputing a buffer length, do only one pass, extending the
buffer as necessary.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Remove escape_buffer entirely

Output the escaped content directly into the destination buffer,
avoiding the memory copy and associated overhead.

This finishes the series, and brings another 6.6-18.0% speed
improvement in test_perf, compared to the previous increase with using
a static exception map.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Fix timestamp formatting

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
t/test_umberlog: Fix a minor indentation issue

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Fix log mask handling

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Switch warn_unused_result attributes

These should not be on ul_*syslog, because there is nothing one can do
to recover; OTOH they should be on ul_*format, because they indicate a
memory leak.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>