const-ify strings in struct location

This commit is contained in:
Omar Polo 2021-01-27 15:53:30 +00:00
parent 0cd6675437
commit fe5967cd02
2 changed files with 10 additions and 7 deletions

8
gmid.h
View File

@ -64,10 +64,10 @@
#define LOGD(c, fmt, ...) logs(LOG_DEBUG, c, fmt, __VA_ARGS__)
struct location {
char *match;
char *lang;
char *default_mime;
char *index;
const char *match;
const char *lang;
const char *default_mime;
const char *index;
int auto_index; /* 0 auto, -1 off, 1 on */
};

View File

@ -129,15 +129,18 @@ locopts : /* empty */
;
locopt : TDEFAULT TTYPE TSTRING {
free(loc->default_mime);
if (loc->default_mime != NULL)
yyerror("`default type' specified more than once");
loc->default_mime = $3;
}
| TLANG TSTRING {
free(loc->lang);
if (loc->lang != NULL)
yyerror("`lang' specified more than once");
loc->lang = $2;
}
| TINDEX TSTRING {
free(loc->index);
if (loc->index != NULL)
yyerror("`index' specified more than once");
loc->index = $2;
}
| TAUTO TINDEX TBOOL { loc->auto_index = $3 ? 1 : -1; }