Improvement

Using states for each "SERP-type" increases speed when processing catenated SERPs almost 6-fold.

/*
make sqlite from s.e.r.p.

ddg 001,
google 002,
qwant 003, SNI
startpage 004,
github 005,
google news 006, pub date as date
mojeek 007,
f-droid 010,
bing 011, SNI
yandex 013,
tailsx 014,
google scholar 015,
ecosia 016,
wiby.me 017,
marginalia 018,
yahoo 019, cache url as desc
youtube 020,
wikipedia 021,
pubmed 022, SNI
brave 023 SNI?
*/

int fileno (FILE *);
#define jmp (yy_start) = 1 + 2 *
int mode;
int w,x,y,z;
int utf8,tag;
int datelen,querylen,urllen,desclen;
int bing,bing_url,bing_desc;
int ddg_url,ddg_desc,ddg_info;
int google_url,google_desc,google_desc2;
int mojeek_url,mojeek_desc,mojeek_info;
int yandex,yandex_url,yandex_desc;
int tailsx,tailsx_url,tailsx_desc,tailsx_info;
int google_news; /* DELETE */
int startpage;
int yahoo,yahoo_url,yahoo_bingj;
int google_scholar_url;
int ecosia,ecosia_desc;
int wikipedia_url;
int pubmed_url;
int youtube1,youtube2,youtube_itag,youtube_url,youtube_desc;
int brave;
int qwant,qwant_json;
int f_droid;
int github;
int setenv (const char *, const char *, int);
char desc[255];
char url[255];
int puts(const char *);
int printf(const char *__restrict, ...);
int dprintf(int, const char *__restrict, ...);
int CDp8iULPuCinsert(int xyz)
{
fwrite("INSERT or IGNORE INTO t1 VALUES(",1,32,stdout);
printf("%03d,'",xyz);
fwrite(getenv("query"),1,querylen,stdout);
fwrite("','",1,3,yyout);
fwrite(getenv("date"),1,datelen,yyout);
fwrite("','",1,3,yyout);
return 0;
}
%s YANDEX_DESC BING_URL BING_DESC1 BING_DESC2
%s QWANT_DESC GITHUB_DESC GOOGLE_DESC
%s MODE1 MODE2 MODE3 MODE4 MODE5 MODE6 MODE7 MODE9
%s MODE10 MODE11 MODE12 MODE13 MODE14 MODE15 MODE16
%s MODE17 MODE18 MODE19 MODE20 MODE21 MODE22 MODE23
%option nounput noinput noyywrap
%%
"class=\"startpage-html startpage-html--" startpage++;
"<title>Yandex</title>" yandex++;
"policyref=\"https://policies.yahoo.com/w3c/p3p.xml\"" yahoo++;
^[Ss]erver:[ ]Qwant\r qwant++;

TWVGHkppk6Q6cODqP7Kqdate:\"[^\"]+ {
y=0;for(x=26;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];
if(yytext[yyleng])yytext[yyleng]=0;y++;};
setenv("date",yytext,1);
datelen=y;
}
TWVGHkppk6Q6cODqP7Kqquery:\"[^\"]+ {
y=0;for(x=27;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];
if(yytext[yyleng])yytext[yyleng]=0;y++;};
setenv("query",yytext,1);
querylen=y;
}
TWVGHkppk6Q6cODqP7Kqmode:\"[^\"]+ {
y=0;for(x=26;x<yyleng;x++){if(yytext[x])yytext[y]=yytext[x];
if(yytext[yyleng])yytext[yyleng]=0;y++;};
mode=atoi(yytext);
switch(mode){
case 1: jmp MODE1;break;
case 2: jmp MODE2;break;
case 3: jmp MODE3;break;
case 4: jmp MODE4;break;
case 5: jmp MODE5;break;
case 6: jmp MODE6;break;
case 7: jmp MODE7;break;
case 10: jmp MODE10;break;
case 11: jmp MODE11;break;
case 12: jmp MODE12;break;
case 13: jmp MODE13;break;
case 14: jmp MODE14;break;
case 15: jmp MODE15;break;
case 16: jmp MODE16;break;
case 17: jmp MODE17;break;
case 18: jmp MODE18;break;
case 19: jmp MODE19;break;
case 20: jmp MODE20;break;
case 21: jmp MODE21;break;
case 22: jmp MODE22;break;
case 23: jmp MODE23;break;
default: break;
}
}
^HTTP\/1.[01][ ]200[ ]O[Kk]\r {
bing_desc=0;
ddg_info=0;
tag=0;
tailsx_info=0;
yahoo=0;
yahoo_bingj=0;
bing=0;
bing_url=0;
brave=0;
ddg_url=0;
desclen=0;
ecosia=0;
ecosia_desc=0;
google_scholar_url=0;
mojeek_desc=0;
mojeek_info=0;
mojeek_url=0;
pubmed_url=0;
qwant=0;
startpage=0;
tailsx=0;
tailsx_desc=0;
tailsx_url=0;
w=0;
wikipedia_url=0;
x=0;
yahoo=0;
yahoo_url=0;
youtube_itag=0;
z=0;
}
/* insert code for SERP-type here */

.|\n
%%
int main(){
fwrite("PRAGMA foreign_keys=OFF;\n",1,25,stdout);
fwrite("BEGIN TRANSACTION;\n",1,19,stdout);
fwrite("CREATE TABLE IF NOT EXISTS t1(site INTEGER,query TEXT,gmt TEXT,url TEXT PRIMARY KEY,desc TEXT);\n",1,96,stdout);
yylex();
fwrite("COMMIT;\n",1,8,stdout);
exit(0);
}