MSI: remove more types from the parser (RESEND)
Mike McCormack
mike at codeweavers.com
Fri May 27 02:36:05 CDT 2005
The previous patch had a problem with linking.
Mike
ChangeLog:
* remove more types from the parser
-------------- next part --------------
diff -urp dlls/msi.old/insert.c dlls/msi/insert.c
--- dlls/msi.old/insert.c 2005-05-27 15:36:54.000000000 +0900
+++ dlls/msi/insert.c 2005-05-27 15:40:29.000000000 +0900
@@ -44,7 +44,7 @@ typedef struct tagMSIINSERTVIEW
MSIDATABASE *db;
BOOL bIsTemp;
MSIVIEW *sv;
- value_list *vals;
+ column_info *vals;
} MSIINSERTVIEW;
static UINT INSERT_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
@@ -62,7 +62,7 @@ static UINT INSERT_fetch_int( struct tag
* Merge a value_list and a record to create a second record.
* Replace wildcard entries in the valuelist with values from the record
*/
-static MSIRECORD *INSERT_merge_record( UINT fields, value_list *vl, MSIRECORD *rec )
+static MSIRECORD *INSERT_merge_record( UINT fields, column_info *vl, MSIRECORD *rec )
{
MSIRECORD *merged;
DWORD wildcard_count = 1, i;
@@ -255,7 +255,7 @@ MSIVIEWOPS insert_ops =
};
UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
- column_info *columns, value_list *values, BOOL temp )
+ column_info *columns, column_info *values, BOOL temp )
{
MSIINSERTVIEW *iv = NULL;
UINT r;
diff -urp dlls/msi.old/query.h dlls/msi/query.h
--- dlls/msi.old/query.h 2005-05-27 15:36:54.000000000 +0900
+++ dlls/msi/query.h 2005-05-27 15:40:29.000000000 +0900
@@ -68,12 +68,6 @@ typedef struct _column_info
struct _column_info *next;
} column_info;
-typedef struct _string_list
-{
- LPWSTR string;
- struct _string_list *next;
-} string_list;
-
struct complex_expr
{
UINT op;
@@ -95,19 +89,6 @@ struct expr
} u;
};
-typedef struct _value_list
-{
- struct expr *val;
- struct _value_list *next;
-} value_list;
-
-typedef struct _column_assignment
-{
- column_info *col_list;
- value_list *val_list;
-} column_assignment;
-
-
UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
struct list *mem );
@@ -128,7 +109,7 @@ UINT CREATE_CreateView( MSIDATABASE *db,
column_info *col_info, BOOL temp );
UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
- column_info *columns, value_list *values, BOOL temp );
+ column_info *columns, column_info *values, BOOL temp );
UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **, LPWSTR table,
column_info *list, struct expr *expr );
diff -urp dlls/msi.old/sql.y dlls/msi/sql.y
--- dlls/msi.old/sql.y 2005-05-27 15:36:54.000000000 +0900
+++ dlls/msi/sql.y 2005-05-27 16:32:10.000000000 +0900
@@ -32,7 +32,6 @@
#include "query.h"
#include "wine/list.h"
#include "wine/debug.h"
-#include "wine/unicode.h"
#define YYLEX_PARAM info
#define YYPARSE_PARAM info
@@ -61,7 +60,7 @@ static BOOL SQL_MarkPrimaryKeys( column_
static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
static struct expr * EXPR_column( void *info, column_info *column );
-static struct expr * EXPR_ival( void *info, struct sql_str *, int sign );
+static struct expr * EXPR_ival( void *info, int val );
static struct expr * EXPR_sval( void *info, struct sql_str * );
static struct expr * EXPR_wildcard( void *info );
@@ -74,10 +73,10 @@ static struct expr * EXPR_wildcard( void
struct sql_str str;
LPWSTR string;
column_info *column_list;
- value_list *val_list;
MSIVIEW *query;
struct expr *expr;
USHORT column_type;
+ int integer;
}
%token TK_ABORT TK_AFTER TK_AGG_FUNCTION TK_ALL TK_AND TK_AS TK_ASC
@@ -126,12 +125,12 @@ static struct expr * EXPR_wildcard( void
%type <string> table id
%type <column_list> selcollist column column_and_type column_def table_def
-%type <column_list> column_assignment update_assign_list
+%type <column_list> column_assignment update_assign_list constlist
%type <query> query from fromtable selectfrom unorderedsel
%type <query> oneupdate onedelete oneselect onequery onecreate oneinsert
%type <expr> expr val column_val const_val
%type <column_type> column_type data_type data_type_l data_count
-%type <val_list> constlist
+%type <integer> number
%%
@@ -318,13 +317,11 @@ data_type:
;
data_count:
- TK_INTEGER
+ number
{
- SQL_input* sql = (SQL_input*) info;
- int val = SQL_getint(sql);
- if( ( val > 255 ) || ( val < 0 ) )
+ if( ( $1 > 255 ) || ( $1 < 0 ) )
YYABORT;
- $$ = val;
+ $$ = $1;
}
;
@@ -498,25 +495,18 @@ val:
constlist:
const_val
{
- value_list *vals;
-
- vals = parser_alloc( info, sizeof *vals );
- if( !vals )
+ $$ = parser_alloc_column( info, NULL, NULL );
+ if( !$$ )
YYABORT;
- vals->val = $1;
- vals->next = NULL;
- $$ = vals;
+ $$->val = $1;
}
| const_val TK_COMMA constlist
{
- value_list *vals;
-
- vals = parser_alloc( info, sizeof *vals );
- if( !vals )
+ $$ = parser_alloc_column( info, NULL, NULL );
+ if( !$$ )
YYABORT;
- vals->val = $1;
- vals->next = $3;
- $$ = vals;
+ $$->val = $1;
+ $$->next = $3;
}
;
@@ -538,15 +528,15 @@ column_assignment:
;
const_val:
- TK_INTEGER
+ number
{
- $$ = EXPR_ival( info, &$1, 1 );
+ $$ = EXPR_ival( info, $1 );
if( !$$ )
YYABORT;
}
- | TK_MINUS TK_INTEGER
+ | TK_MINUS number
{
- $$ = EXPR_ival( info, &$2, -1 );
+ $$ = EXPR_ival( info, -$2 );
if( !$$ )
YYABORT;
}
@@ -604,6 +594,13 @@ id:
}
;
+number:
+ TK_INTEGER
+ {
+ $$ = SQL_getint( info );
+ }
+ ;
+
%%
static void *parser_alloc( void *info, unsigned int sz )
@@ -684,8 +681,19 @@ INT SQL_getint( void *info )
{
SQL_input* sql = (SQL_input*) info;
LPCWSTR p = &sql->command[sql->n];
+ INT i, r = 0;
+
+ for( i=0; i<sql->len; i++ )
+ {
+ if( '0' > p[i] || '9' < p[i] )
+ {
+ ERR("should only be numbers here!\n");
+ break;
+ }
+ r = (p[i]-'0') + r*10;
+ }
- return atoiW( p );
+ return r;
}
int SQL_error( const char *str )
@@ -727,13 +735,13 @@ static struct expr * EXPR_column( void *
return e;
}
-static struct expr * EXPR_ival( void *info, struct sql_str *str, int sign )
+static struct expr * EXPR_ival( void *info, int val )
{
struct expr *e = parser_alloc( info, sizeof *e );
if( e )
{
e->type = EXPR_IVAL;
- e->u.ival = atoiW( str->data ) * sign;
+ e->u.ival = val;
}
return e;
}
More information about the wine-patches
mailing list