Squashed commit of the following:
commit 74b0e7aa54
Author: Dylan Lom <dylanlom@gmail.com>
Date: Tue Jan 26 13:01:39 2021 +1100
Fix bug with link elements
Link tags in the header were using "vals=" instead of "href="...
* I think this is actually a pretty good use-case for a macro, the
overhead of the function (in terms of readability and stack stuff i
guess) seems overkill for what it was doing.
* examples/header.shmd can now be successfully parsed
* However, some clean-up is probably required before this should be
merged.
* Add a command to examples/header.shmd to make sure that the body is
still parsed correctly after the header.
It converts a str_list into a html tag based on the rules set out in
issue #2.
Fix issue with header_split function where quotes weren't being skipped
(e.g. they were included in the output).
Fix issue with header_split function where the last word wasn't being
included.
* Return number of trimmed char's from `str_trimr`, instead of modified
string.
* Re-order util.h based on #include convention (function name length,
then alphabetical). Re-order util.c to match
* Add `ecalloc` function which calls die if calloc returns NULL
* Add `str_malloc` macro-function which calls calloc with size as
sizeof(char)
* Add `str_ealloc` macro-function which calls ecalloc with size as
sizeof(char)
This makes it clearer the it is a pipe being read, not a file and
distinguishes it from fp, which is being used elsewhere to mean the
source of incoming shmd (e.g. stdin).
The shmd program now interprets the $(...) command substitution on it's
own. This means that basic.shmd now compiles correctly!
`execute_command` has been renamed to `command_execute` to match the
naming of `command_substitute`. It also now strips up to one trailing
newline from the command's output.
I feel quite dumb realising I could've just made this a shell
one-liner... although from a bit of playing I couldn't actually get echo
"$(cat)" to execute command substitution from the input properly.
Still can't compile examples/basic.shmd as the backquotes (`) are being
interpreted by the shell, the same would be true of anything in
paranethesis, which would be executed in a subshell.
Quotes aren't as damaging as I thought they would be (no errors), but
double quotes outside of commands are swallowed, see additions to
examples/basic.shmd
I'd also like to do some environment stuff at a later date, so eh maybe
I'll keep doing it in C... I've been enjoying it more than I would've a
shell script also.
* Local #includes last, includes ordered by line length, then
alphabetically
* Snake case for variables
* Use more descriptive name, `str_concat`, for `concat` function