<commit_before>#include "QueryString.h"

void *QSValuesCopy(strarg_t const qs, strarg_t const fields[], count_t const count) {
	str_t **const values = calloc(count, sizeof(str_t *));
	if(!values) return NULL;
	strarg_t pos = qs;
	for(;;) {
		if('\0' == pos[0]) break;
		if('?' == pos[0] || '&' == pos[0]) ++pos;

		size_t flen = 0, sep = 0;
		for(;;) {
			char const x = pos[flen];
			if('\0' == x) break;
			if('=' == x) { ++sep; break; }
			if('&' == x) break;
			++flen;
		}
		size_t vlen = 0;
		if(sep) for(;;) {
			char const x = pos[flen+sep+vlen];
			if('\0' == x) break;
			if('&' == x) break;
			++vlen;
		}

		for(index_t i = 0; i < count; ++i) {
			if(!substr(fields[i], pos, flen)) continue;
			if(values[i]) continue;
			if(vlen > 0) {
				// TODO: Decode.
				values[i] = strndup(pos+flen+sep, vlen);<commit_msg>Query string ?x= isn't the same as ?x (empty string vs default "true")<commit_after>#include "QueryString.h"

void *QSValuesCopy(strarg_t const qs, strarg_t const fields[], count_t const count) {
	str_t **const values = calloc(count, sizeof(str_t *));
	if(!values) return NULL;
	strarg_t pos = qs;
	for(;;) {
		if('\0' == pos[0]) break;
		if('?' == pos[0] || '&' == pos[0]) ++pos;

		size_t flen = 0, sep = 0;
		for(;;) {
			char const x = pos[flen];
			if('\0' == x) break;
			if('=' == x) { ++sep; break; }
			if('&' == x) break;
			++flen;
		}
		size_t vlen = 0;
		if(sep) for(;;) {
			char const x = pos[flen+sep+vlen];
			if('\0' == x) break;
			if('&' == x) break;
			++vlen;
		}

		for(index_t i = 0; i < count; ++i) {
			if(!substr(fields[i], pos, flen)) continue;
			if(values[i]) continue;
			if(sep) {
				// TODO: Decode.
				values[i] = strndup(pos+flen+sep, vlen);
{'fraction_non_alphanumeric': 0.22593896713615025, 'fraction_numerical': 0.01232394366197183, 'mean_word_length': 3.251870324189526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2189405', 'n_tokens_mistral': 831, 'n_tokens_neox': 744, 'n_words': 184}