add -u flag, error if variable undefined#77
add -u flag, error if variable undefined#77birchb1024 wants to merge 2 commits intorakitzis:masterfrom
Conversation
|
What is your opinion on this, @rakitzis? Can you please add some tests to |
| return NULL; /* not found */ | ||
| if (look == NULL) { | ||
| if (strict && dashewe) | ||
| rc_error(get_message("Undefined variable '%s'\n", name)); |
There was a problem hiding this comment.
Would you prefer "undefined ?
| return TRUE; | ||
| } | ||
|
|
||
| char* get_message(char *format, char *msg) { |
There was a problem hiding this comment.
Prefer char *-style decl syntax
There was a problem hiding this comment.
This whole helper function actually is unneeded -- and allocating error messages with malloc will leak memory.
Incidentally, trip.rc probably doesn't verify leak-free behavior but at one time I ran rc through valgrind to catch leaks. I wonder if the state of the art of leak detection for C has advanced to the point where we could run a tool in-line for pull requests.
There was a problem hiding this comment.
It's a while since I ran this, but AFAICR trip.rc only succeeds with this flag OFF. Because there are undefined variables being used in there 😃 . Notwithstanding I have been using this branch as my daily drive. I will have a look at this again.
There was a problem hiding this comment.
trip.rc can exercise features selectively. It's not all-or-nothing.
| @@ -1,5 +1,5 @@ | |||
| /* var.c: provide "public" functions for adding and removing variables from the symbol table */ | |||
|
|
|||
| #include <stdio.h> | |||
There was a problem hiding this comment.
Prefer the nalloc helper, do not include stdio or use malloc here. nalloc is scoped to command-lifetime allocations.
|
Seems like a useful feature, but the change could be harmonized with the [admittedly idiosyncratic] coding style. |
|
And yes, it could use some test coverage in trip.rc |
No description provided.