]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
indent(1): improve CHECK_SIZE_ macros
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>
Sun, 3 Jun 2018 18:19:41 +0000 (18:19 +0000)
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>
Sun, 3 Jun 2018 18:19:41 +0000 (18:19 +0000)
commit9de29bfb5a3a756a306a37d11462c6656f1953c8
tree3758acfad0885100023e5a7ec24cccb6dc6fae99
parent1479f36d8e1c14c9f2da7f839b0c98cf8715a8f5
indent(1): improve CHECK_SIZE_ macros

Rewrite the macros so that they take a parameter. Consumers use it to signal
how much room in the buffer they need; this lets them do that once when
required space is known instead of doing the check once every loop step.

Also take the parameter value into consideration when resizing the buffer;
the requested space may be larger than the constant 400 bytes that the
previous version used - now it's the sum of those two values.

On the consumer side, don't copy strings byte by byte - use memcpy().

Deduplicate code that copied base 2, base 8 and base 16 literals.

Don't advance the e_token pointer once the token has been copied into
s_token. This allows easy calculation of the token's length.
usr.bin/indent/indent.c
usr.bin/indent/indent_globs.h
usr.bin/indent/lexi.c
usr.bin/indent/pr_comment.c