make tests easier to read

This commit is contained in:
prx 2022-08-17 21:34:37 +02:00
parent 26ca6c422d
commit 883bfed7a7
1 changed files with 8 additions and 6 deletions

14
vger.c
View File

@ -508,20 +508,22 @@ get_query(char *path, char *query, size_t querysiz)
void
split_request(const char *request, char *hostname, char *path, char *query)
{
regex_t greg = {0}; /* compiled gemini regex */
regex_t greg = {0}; /* compiled gemini regex */
regmatch_t *match = {0}; /* matches founds */
size_t nmatch = 4; /* number of substrings to look for */
char buf[BUFSIZ] = {'\0'}; /* to handle error messages */
int ret = 0;
size_t nmatch = 4; /* number of substrings to look for */
char buf[BUFSIZ] = {'\0'}; /* to handle error messages */
int ret = 0;
if ((ret = regcomp(&greg, gemini_regex, REG_EXTENDED)) != 0) {
ret = regcomp(&greg, gemini_regex, REG_EXTENDED);
if (ret != 0) {
regerror(ret, &greg, buf, sizeof(buf));
regfree(&greg);
status(50, "Internal server error");
stop(EXIT_FAILURE, "%s", buf);
}
if ((ret = regexec(&greg, request, nmatch, match, 0)) != 0) {
ret = regexec(&greg, request, nmatch, match, 0);
if (ret != 0) {
regerror(ret, &greg, buf, sizeof(buf));
regfree(&greg);
status(59, "Malformed request");