Skip to content

Commit

Permalink
nodateqkw
Browse files Browse the repository at this point in the history
  • Loading branch information
freakout42 committed Jul 11, 2024
1 parent 3659ffd commit 652e80a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 147 deletions.
10 changes: 1 addition & 9 deletions runform/colquery/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,9 @@ if (type==0 || type==STRING) fprintf (out,
"*hallo suche nach Zeichenkette\n"
"~meier aehnlich\n");

#ifndef DB
if (type==0 || type==DATE) fprintf (out,
"10.03.94 Datum\n"
"29/94 Kalenderwoche\n"
"12.94 Monat\n"
"VI/94 Quartal\n");
#endif
"12.94 Monat\n");

fprintf (out,
"10,12,15 Liste verschiedener Werte\n"
Expand All @@ -116,11 +112,7 @@ fprintf (out,
"10-17&!12 UND-Bedingung: 10 bis 17 ohne 12\n"
"(10-17&!12)37 Klammern fuer komplexe Abfragen\n"

#ifdef DB
"[land==5] beliebige DB-Abfrage\n"
#else
"[land='DE'] beliebige SQL-Abfrage\n"
#endif
"================================================================\n");
}

Expand Down
66 changes: 8 additions & 58 deletions runform/colquery/cql.l
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ ye19 ([5-9][0-9])
ye20 ([0-4][0-9])
year ([0-9][0-9])
lyear ((19|20)[0-9][0-9])
week (([0-4][0-9])|(5[0-3]))
sweek ([0-9])
quart ([Ii]{1,3}|IV|iv)
ddmys {lday}{lmon}{ye19}
ddmys2 {lday}{lmon}{ye20}
ddmysl {lday}{lmon}{lyear}
Expand All @@ -40,19 +37,6 @@ my20 {mon}\.{ye20}
ly20 {lmon}\.{ye20}
ml {mon}\.{lyear}
ll {lmon}\.{lyear}
k19 {week}\/{ye19}
k20 {week}\/{ye20}
k {week}\/{lyear}
sk19 {sweek}\/{ye19}
sk20 {sweek}\/{ye20}
sk {sweek}\/{lyear}
q19 {quart}\/{ye19}
q20 {quart}\/{ye20}
q {quart}\/{lyear}
hour ([0-2]?[0-9])
min ([0-5][0-9])
t ({ddmy}|{dlmy}|{ddly}|{dlly}){w}{hour}:{min}
tl ({ddml}|{dlml}|{ddll}|{dlll}){w}{hour}:{min}
%{
#undef input
#undef unput
Expand All @@ -71,6 +55,7 @@ extern int cqtype;
static char tmp[1024];
/*static char *p;*/

/*
static char *rom2d (roman)
unsigned char *roman;
{
Expand All @@ -86,6 +71,7 @@ else dec[0] = '2';
dec[1] = '\0';
return dec;
}
*/
%}
%%
{if (cqtype==DATE) BEGIN DATET;}
Expand All @@ -102,54 +88,24 @@ return dec;
cqlval.item = (char*) yytext;
return(COMPARE);
}
{my19} {sprintf (tmp, "'19%s0%.1s'", yytext+2, yytext);
{my19} {sprintf (tmp, "19%s0%.1s", yytext+2, yytext);
cqlval.item = tmp;
return(MDATE);}
{my20} {sprintf (tmp, "'20%.2s0%.1s'", yytext+2, yytext);
{my20} {sprintf (tmp, "20%.2s0%.1s", yytext+2, yytext);
cqlval.item = tmp;
return(MDATE);}
{ly19} {sprintf (tmp, "'19%s%.2s'", yytext+3, yytext);
{ly19} {sprintf (tmp, "19%s%.2s", yytext+3, yytext);
cqlval.item = tmp;
return(MDATE);}
{ly20} {sprintf (tmp, "'20%.2s%.2s'", yytext+3, yytext);
{ly20} {sprintf (tmp, "20%.2s%.2s", yytext+3, yytext);
cqlval.item = tmp;
return(MDATE);}
{ml} {sprintf (tmp, "'%s0%.1s'", yytext+2, yytext);
{ml} {sprintf (tmp, "%s0%.1s", yytext+2, yytext);
cqlval.item = tmp;
return(MDATE);}
{ll} {sprintf (tmp, "'%s%.2s'", yytext+3, yytext);
{ll} {sprintf (tmp, "%s%.2s", yytext+3, yytext);
cqlval.item = tmp;
return(MDATE);}
{k19} {sprintf (tmp, "'19%s%.2s'", yytext+3, yytext);
cqlval.item = tmp;
return(KWDATE);}
{k20} {sprintf (tmp, "'20%.2s%.2s'", yytext+3, yytext);
cqlval.item = tmp;
return(KWDATE);}
{k} {sprintf (tmp, "'%s%.2s'", yytext+3, yytext);
cqlval.item = tmp;
return(KWDATE);}
{sk19} {sprintf (tmp, "'19%s0%.1s'", yytext+2, yytext);
cqlval.item = tmp;
return(KWDATE);}
{sk20} {sprintf (tmp, "'20%s0%.1s'", yytext+2, yytext);
cqlval.item = tmp;
return(KWDATE);}
{sk} {sprintf (tmp, "'%s0%.1s'", yytext+2, yytext);
cqlval.item = tmp;
return(KWDATE);}
{q19} {sprintf (tmp, "'19%s%s'",
yytext+strlen((char*)yytext)-2, rom2d(yytext));
cqlval.item = tmp;
return(QDATE);}
{q20} {sprintf (tmp, "'20%s%s'",
yytext+strlen((char*)yytext)-2, rom2d(yytext));
cqlval.item = tmp;
return(QDATE);}
{q} {sprintf (tmp, "'%s%s'",
yytext+strlen((char*)yytext)-4, rom2d(yytext));
cqlval.item = tmp;
return(QDATE);}
<DATET>{ddmys} {
sprintf (tmp, "TO_DATE('%c%c.%c%c.19%c%c','DD.MM.RR')",
*(yytext+0), *(yytext+1),
Expand Down Expand Up @@ -215,12 +171,6 @@ return dec;
cqlval.item = tmp;
return(DATE);
}
{t} {sprintf (tmp, "TO_CHAR(TO_DATE('%s','DD.MM.RR HH24:MI'),'YYYYMMDDHH24MI')", yytext);
cqlval.item = tmp;
return(TIME);}
{tl} {sprintf (tmp, "TO_CHAR(TO_DATE('%s','DD.MM.YYYY HH24:MI'),'YYYYMMDDHH24MI')", yytext);
cqlval.item = tmp;
return(TIME);}
{n} {if (cqnonumbers)
{sprintf (tmp, "'%s'", yytext); cqlval.item = tmp;}
else
Expand Down
76 changes: 4 additions & 72 deletions runform/colquery/cqy.y
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
int oper;
char *item;
}
%type <item> list const constm constk constq constd constt
%type <item> list const constm constd
svalue value comp pexpr expr query match qstr
%token <oper> OR
%token <oper> AND
Expand All @@ -14,8 +14,6 @@
%token <item> SQLNULL
%token <item> NUMBER
%token <item> MDATE
%token <item> KWDATE
%token <item> QDATE
%token <item> DATE
%token <item> TIME
%token <item> STRING
Expand Down Expand Up @@ -106,45 +104,13 @@ svalue : constm
}
| comp constm
{
sprintf (tmp, "TO_CHAR(%s,'YYYYMM') %s %s", cqcolumn, $1, $2);
sprintf (tmp, "{fn YEAR(%s)} * 100 + {fn MONTH(%s)} %s %s", cqcolumn, cqcolumn, $1, $2);
$$ = cqstr (tmp);
}
| constm BETWEEN constm
{
sprintf (tmp, "TO_CHAR(%s,'YYYYMM') BETWEEN %s AND %s",
cqcolumn, $1, $3);
$$ = cqstr (tmp);
}
| constk
{
sprintf (tmp, "TO_CHAR(%s,'YYYYIW') = %s", cqcolumn, $1);
$$ = cqstr (tmp);
}
| comp constk
{
sprintf (tmp, "TO_CHAR(%s,'YYYYIW') %s %s", cqcolumn, $1, $2);
$$ = cqstr (tmp);
}
| constk BETWEEN constk
{
sprintf (tmp, "TO_CHAR(%s,'YYYYIW') BETWEEN %s AND %s",
cqcolumn, $1, $3);
$$ = cqstr (tmp);
}
| constq
{
sprintf (tmp, "TO_CHAR(%s,'YYYYQ') = %s", cqcolumn, $1);
$$ = cqstr (tmp);
}
| comp constq
{
sprintf (tmp, "TO_CHAR(%s,'YYYYQ') %s %s", cqcolumn, $1, $2);
$$ = cqstr (tmp);
}
| constq BETWEEN constq
{
sprintf (tmp, "TO_CHAR(%s,'YYYYQ') BETWEEN %s AND %s",
cqcolumn, $1, $3);
sprintf (tmp, "{fn YEAR(%s)} * 100 + {fn MONTH(%s)} BETWEEN %s AND %s",
cqcolumn, cqcolumn, $1, $3);
$$ = cqstr (tmp);
}
| constd
Expand All @@ -162,22 +128,6 @@ svalue : constm
sprintf (tmp, "%s BETWEEN %s AND %s + .99999", cqcolumn, $1, $3);
$$ = cqstr (tmp);
}
| constt
{
sprintf (tmp, "TO_CHAR(%s,'YYYYMMDDHH24MI') = %s", cqcolumn, $1);
$$ = cqstr (tmp);
}
| comp constt
{
sprintf (tmp, "TO_CHAR(%s,'YYYYMMDDHH24MI') %s %s",cqcolumn,$1,$2);
$$ = cqstr (tmp);
}
| constt BETWEEN constt
{
sprintf (tmp, "TO_CHAR(%s,'YYYYMMDDHH24MI') BETWEEN %s AND %s",
cqcolumn, $1, $3);
$$ = cqstr (tmp);
}
| comp const
{
sprintf (tmp, "%s %s %s", cqcolumn, $1, $2);
Expand Down Expand Up @@ -251,30 +201,12 @@ constm : MDATE
cqtype(DATE);
}
;
constk : KWDATE
{
$$ = cqstr ($1);
cqtype(DATE);
}
;
constq : QDATE
{
$$ = cqstr ($1);
cqtype(DATE);
}
;
constd : DATE
{
$$ = cqstr ($1);
cqtype(DATE);
}
;
constt : TIME
{
$$ = cqstr ($1);
cqtype(DATE);
}
;
qstr : STRING
{
sprintf (tmp, "'%s'", $1);
Expand Down
1 change: 1 addition & 0 deletions runform/form.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Form: public Record {
int numpage;
int curblock;
int curfield;
int lastcmd;
int lastkey;
int dirty;
int rmode;
Expand Down
21 changes: 14 additions & 7 deletions runform/function.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#include "runform.h"

int Function::dispatch() {
switch(f.mapkey(LK)) {
f.lastcmd = f.mapkey(LK);
switch(f.lastcmd) {
case -1: LK = enter_the_form(); break;
#ifdef NOTYETIMPLEMENTED
case KEF_HELP: /* fhelp() */
case KEF_BACKDEL: /* fbackdel() */
case KEF_COPY: /* fhelp() */
case KEF_PASTE: /* fpaste() */
case KEF_LIST: /* flist() */
case KEF_COPYREC: /* fcopyrec() */
case KEF_NAVI0: /* fmenu() */
case KEF_HOME: /* fhome() */
case KEF_END: /* fend() */
case KEF_PRESETR: /* fpresetr() */
case KEF_NXTSETR: /* fnxtsetr() */
case KEF_REFRESH: LK = 0 /* frefresh() */; break;
case KEF_NXTFLD: LK = fmove(0, 1); break;
case KEF_PREFLD: LK = fmove(0, -1); break;
case KEF_REFRESH: /* frefresh() */
case KEF_NAVI0: /* fmenu() */
#endif
case KEF_NAVI1: LK = fmove(0, NFIELD1+1); break;
case KEF_NAVI2: LK = fmove(0, NFIELD1+2); break;
case KEF_NAVI3: LK = fmove(0, NFIELD1+3); break;
Expand All @@ -26,7 +27,8 @@ switch(f.mapkey(LK)) {
case KEF_NAVI7: LK = fmove(0, NFIELD1+7); break;
case KEF_NAVI8: LK = fmove(0, NFIELD1+8); break;
case KEF_NAVI9: LK = fmove(0, NFIELD1+9); break;
case KEF_NAVI10: LK = 0 /* fcommit() */ ; break;
case KEF_NXTFLD: LK = fmove(0, 1); break;
case KEF_PREFLD: LK = fmove(0, -1); break;
case KEF_NXTREC: LK = fmover(1); break;
case KEF_PREREC: LK = fmover(-1); break;
case KEF_INSERT:
Expand All @@ -42,6 +44,7 @@ switch(f.mapkey(LK)) {
default: LK = 0; MSG(MSG_NOREC); break;
} break;
case KEF_QUERY: LK = enter_query(); break;
case KEF_NAVI10:
case KEF_COMMIT:
switch(f.rmode) {
case MOD_UPDATE: LK = enter_query(); break;
Expand All @@ -58,7 +61,11 @@ switch(f.mapkey(LK)) {
} break;
case KEF_RIGHT: LK = fedit(0); break;
case KEF_LEFT: LK = fedit(-1); break;
default: LK = fedit(-1000 - LK);
default:
if (isprintable(LK))
LK = fedit(-1000 - LK);
else LK = 0;
break;
}
return notrunning;
}
Expand Down
4 changes: 3 additions & 1 deletion runform/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ writef(0, 34, 0, 9, "%s", f.l[f.curfield].name);
writef(0, 44, 0, 9, "%4d/%4d", CB.currentrecord, CB.q->rows);
writef(0, 54, COL_HEADER,6,"%s",rmodes[f.rmode]);
writef(0, 61, COL_HEADER,3,"%s",(char*)(insertmode ? "Ins" : "Rep"));
writes(0, 67, "runform-");
//ites(0, 67, "runform-");
writef(0, 70, 0, 4, "%4d", f.lastcmd);
writes(0, 75, (char*)VERSION);
refr();
for (i=0; i<f.numfield; i++) f.l[i].show(i == f.curfield);
Expand All @@ -65,6 +66,7 @@ if (f.y.ysiz > 0) {
if (pnt) pntst = pnt; else pntst = empty;
if (strlen(pntst) > LINE0SIZE-12) i = strlen(pntst) - LINE0SIZE + 12; else i = 0;
writef(0, 0, 0, LINE0SIZE, "MAX-%03d %s %s", ern, f.y.msg(ern), pntst+i);
writef(0, 76, 0, 4, "%04d", f.lastcmd);
wmov(0,0);
refr();
return getkb();
Expand Down

0 comments on commit 652e80a

Please sign in to comment.