Download raw body.
gotd.conf varset
On 2023/11/04 11:48:16 +0100, Stefan Sperling <stsp@stsp.name> wrote:
> This makes it possible to set variables in gotd.conf.
> We already have symset() but it was not reachable.
> Code obtained from gotwebd/parse.y. ok?
ok op@
> diff /home/stsp/src/got
> commit - ac4f092c7c8e090ee733c90b8b0f0274872c8662
> path + /home/stsp/src/got
> blob - cc7231514a823861b662e419be141a4492c833fd
> file + gotd/parse.y
> --- gotd/parse.y
> +++ gotd/parse.y
> @@ -127,10 +127,29 @@ typedef struct {
>
> grammar :
> | grammar '\n'
> + | grammar varset '\n'
> | grammar main '\n'
> | grammar repository '\n'
> ;
>
> +varset : STRING '=' STRING {
> + char *s = $1;
> + while (*s++) {
> + if (isspace((unsigned char)*s)) {
> + yyerror("macro name cannot contain "
> + "whitespace");
> + free($1);
> + free($3);
> + YYERROR;
> + }
> + }
> + if (symset($1, $3, 0) == -1)
> + fatal("cannot store variable");
> + free($1);
> + free($3);
> + }
> + ;
> +
> timeout : NUMBER {
> if ($1 < 0) {
> yyerror("invalid timeout: %lld", $1);
gotd.conf varset