Download raw body.
gotwebd: convert newfile/closefile() to push/popfile()
On Sat, Nov 08, 2025 at 07:04:06PM +0100, Omar Polo wrote:
> hello =)
>
> this is a preparatory step to introduce the types {} block like httpd
> has. It is easier to have include support if we have a per-file push
> back buffer, like many other parse.y have.
>
> For the whole picture, please take a look at op/mime.
> This is the first of three steps.
>
> To be clear I'm not introducing support for a generic include, though
> it can be done easily now, but just a `types { include "mime" }'
>
> ok?
The logic around the 'expanding' flag seems incomplete. As far as
I can tell this flag is involved in expansion of macros, correct?
There are START_EXPAND and DONE_EXPAND constants, which in your code
are checked against 'c' but I don't see code anywhere which would set 'c'
to these values. Even when looking at subsequent patches on your branch.
Is this intentional?
Maybe this part of the code does nothing right now? Macro support in
gotwebd.conf is not terribly important, but we do document the feature.
If it works today then it should keep working.
> @@ -791,69 +796,90 @@ lookup(char *s)
> return (STRING);
> }
>
> -#define MAXPUSHBACK 128
> +#define START_EXPAND 1
> +#define DONE_EXPAND 2
>
> -unsigned char *parsebuf;
> -int parseindex;
> -unsigned char pushback_buffer[MAXPUSHBACK];
> -int pushback_index = 0;
> +static int expanding;
>
> int
> +igetc(void)
> +{
> + int c;
> +
> + while (1) {
> + if (file->ungetpos > 0)
> + c = file->ungetbuf[--file->ungetpos];
> + else
> + c = getc(file->stream);
> +
> + if (c == START_EXPAND)
> + expanding = 1;
> + else if (c == DONE_EXPAND)
> + expanding = 0;
> + else
> + break;
> + }
> + return c;
> +}
gotwebd: convert newfile/closefile() to push/popfile()