New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add this_file, this_counter, GNUremake #116
base: remake-4-3
Are you sure you want to change the base?
Conversation
* Reinstate inadvertently deleted @node line * Add test for GNUremake
Hey, long time not chat :)
In the function table a function with a max of 0 args can't be specified since max=0 means no maximum. A workaround could be change the syntax, like Without any args In the next few days I'll have a closer look. /Thomas Edit: Remove "there's no check for max # of arguments", the first paragraph was after I did some changing, not true for the unmodfied commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rocky
Addition to the above: I did some more investigation and the lookup_function
method doesn't handle functions without an argument well. It expects at least a space after the function name.
In src/function.c
, lookup_function
, changing
if (e == s || !STOP_SET(*e, MAP_NUL|MAP_SPACE))
to something like
if (e == s || !STOP_SET(*e, MAP_NUL|MAP_SPACE|stopchar_map[(int)')']))
does make it work, if using variable_buffer_output
instead of xstrdup
in the func_this_*
methods.
I do wonder if and under what parameters the original patch works.
func_this_file (char *o UNUSED, char **argv UNUSED, const char *funcname UNUSED) | ||
{ | ||
if (reading_file) { | ||
return xstrdup(reading_file->filenm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using o = variable_buffer_output
and return o
instead of xstrdup
and the internal function(s) do work if adding a pseudo argument, like $(this_file fluffy)
.
Then it's down to the handling of no-arg functions.
if (!argc && !entry_p->alloc_fn) | ||
if (!argc | ||
/// the functions named this_* by <basile@starynkevitch.net> take no arguments... | ||
&& strncmp(entry_p->name, "this", sizeof("this")-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my untrained eye sizeof()
for a string doesn't seem like a good idea, why not use strlen
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a constant string, sizeof
is computed at compile time.
But strlen
might be computed at runtime. I know that some versions of GCC + GNU libc are able to compute strlen
at compile time (on Linux/x86-64 at least).
@boretom Many thanks for investigating what's up, finding and fixing (at least some of) the problems and the review. Also, all the best for 2021! |
After the dust settles, we should look into adding a few more tests. It shouldn't be that onerous. (In fact, this is something I think even I could do.) Thanks again. |
269a076
to
3048790
Compare
@bstarynk this addresses the build failure and has a test for GNUremakefile
However I don't see that the
this_
functions work.For example for this Makefile
I get:
If the
this
functions work for you, maybe you can give an example simiilar to the above?