This commit is contained in:
Christian Grothoff 2020-04-23 16:06:21 +02:00
parent 8b99abbe62
commit de61e06eb1
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -110,6 +110,7 @@ mime_matches (const char *accept_pattern,
/** /**
* Check if @a lang matches the @a language_pattern, and if so with * Check if @a lang matches the @a language_pattern, and if so with
* which preference. * which preference.
* See also: https://tools.ietf.org/html/rfc7231#section-5.3.1
* *
* @param language_pattern a language preferences string * @param language_pattern a language preferences string
* like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1" * like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1"
@ -125,15 +126,20 @@ language_matches (const char *language_pattern,
char *sptr; char *sptr;
double r = 0.0; double r = 0.0;
for (char *tok = strtok_r (p, ", ", &sptr); for (char *tok = strtok_r (p, ",", &sptr);
NULL != tok; NULL != tok;
tok = strtok_r (NULL, ", ", &sptr)) tok = strtok_r (NULL, ",", &sptr))
{ {
char *sptr2; char *sptr2;
char *lp = strtok_r (tok, ";", &sptr2); char *lp = strtok_r (tok, ";", &sptr2);
char *qp = strtok_r (NULL, ";", &sptr2); char *qp = strtok_r (NULL, ";", &sptr2);
double q = 1.0; double q = 1.0;
while (isspace ((int) *lp))
lp++;
if (NULL != qp)
while (isspace ((int) *qp))
qp++;
GNUNET_break_op ( (NULL == qp) || GNUNET_break_op ( (NULL == qp) ||
(1 == sscanf (qp, (1 == sscanf (qp,
"q=%lf", "q=%lf",