Add SQL quote escaping, Documentation fix

This commit is contained in:
whydoubt 2004-08-27 02:05:22 +00:00
parent e33c909174
commit 2e5179fb63
3 changed files with 33 additions and 6 deletions

View File

@ -1,3 +1,7 @@
Thu Aug 26 21:06:35 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* src/libmdb/write.c: Documentation fix
* src/sql/lexer.l: Add SQL quote escaping
Tue Aug 24 21:04:17 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* include/mdbsql.h:
* src/sql/mdbsql.c: Tidy up a few SQL-related functions

View File

@ -329,7 +329,7 @@ mdb_crack_row3(MdbTableDef *table, int row_start, int row_end, MdbField *fields)
}
/**
* mdb_crack_row:
* @mdb: Database handle
* @table: Table that the row belongs to
* @row_start: offset to start of row on current page
* @row_end: offset to end of row on current page
* @fields: pointer to MdbField array to be popluated by mdb_crack_row

View File

@ -43,14 +43,37 @@ null { return NUL; }
(>=) { return GTEQ; }
like { return LIKE; }
[ \t\r] ;
\"[A-z][A-z0-9 _#@]*\" {
yylval.name = strdup(&yytext[1]);
yylval.name[strlen(yylval.name)-1]='\0';
return IDENT;
\"[^"]*\"\" {
yyless(yyleng-1);
yymore();
}
\"[^"]*\" {
int ip, op, ilen;
ilen = strlen(yytext);
yylval.name = malloc(ilen-1);
for (ip=1, op=0; ip<ilen-1; ip++, op++) {
if (yytext[ip] != '"') {
yylval.name[op] = yytext[ip];
} else if (yytext[ip+1] == '"') {
yylval.name[op] = yytext[ip++];
}
}
yylval.name[op]='\0';
return IDENT;
}
[A-z][A-z0-9_#@]* { yylval.name = strdup(yytext); return NAME; }
'[A-z0-9 !@#$%^&*()-_+={}[\];:",.<>/?`~|\\]*' { yylval.name = strdup(yytext); return STRING; }
'[^']*'' {
yyless(yyleng-1);
yymore();
}
'[^']*' {
yylval.name = strdup(yytext);
return STRING;
}
(-*[0-9]+|([0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?) {
yylval.name = strdup(yytext); return NUMBER;
}