naemon/macros.c: removing double check for variable

we already check a few lines before if input_buffer is or not
valid.

as a plus, if a fail during strdup() occurs we return ERROR

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
naemon/macros.c: using continue to avoid uneede `else'

if we are not `inside a macro' we just copy the current string
to output buffer and keep it going.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
naemon/macros.c: avoid to call grab_macro_value_r() if escaped $ found

bringing comparsion of macro with "" a little up. this way we
avoid to call grab_macro_value_r() with a parameter that we
know it is not a macro.

in other words, if strcmp(temp_buffer,"") is false, we know
that macro contains $$ so we just concatenate it to the output
buffer and keep rocking on.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
naemon/macros.c: grab_macro_value_r() returns only OK or ERROR

grab_macro_value_r() and it's inner functions only return OK
or ERROR(macro could not be found).

in the last case we just copy the macro as is to the output
buffer as the previous version has being doing since remote
ages.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
t-tap/test_macros.c: added tests for escaped $ and invalid macros

added two extra tests to validate if $$ is being escaped to $
and if an invalid macro is copied as is to the output buffer

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
naemon/macros.c: solved undefined behaviour on incomplete macro

if a macro is defined as `$ something' the previous version of
process_macros_r() returned `$ something$', and that behaviour
is not what we supposedly want.

with the patch below we verify if we reached the end of string
before add a new $ sign, making process_macros_r() leave
string untouched in case of an incomplete macro has been
provided.

also added a test case to assure we are treating this correctly.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
Merge branch 'ricardomaraschini-macros'