MSI: get rid of some redundant parser types

Mike McCormack mike at codeweavers.com
Fri May 27 00:18:37 CDT 2005


ChangeLog:
* get rid of some redundant parser types
-------------- next part --------------
Index: dlls/msi/create.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/create.c,v
retrieving revision 1.11
diff -u -p -r1.11 create.c
--- dlls/msi/create.c	23 May 2005 12:08:17 -0000	1.11
+++ dlls/msi/create.c	27 May 2005 05:19:47 -0000
@@ -40,11 +40,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
 typedef struct tagMSICREATEVIEW
 {
-    MSIVIEW          view;
-    MSIDATABASE     *db;
-    LPWSTR           name;
-    BOOL             bIsTemp;
-    create_col_info *col_info;
+    MSIVIEW      view;
+    MSIDATABASE *db;
+    LPWSTR       name;
+    BOOL         bIsTemp;
+    column_info *col_info;
 } MSICREATEVIEW;
 
 static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
@@ -59,7 +59,7 @@ static UINT CREATE_fetch_int( struct tag
 static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
 {
     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
-    create_col_info *col;
+    column_info *col;
     UINT r, nField, row, table_val, column_val;
     static const WCHAR szTables[] =  { '_','T','a','b','l','e','s',0 };
     static const WCHAR szColumns[] = { '_','C','o','l','u','m','n','s',0 };
@@ -122,8 +122,8 @@ static UINT CREATE_execute( struct tagMS
         if( r )
             goto err;
 
-        column_val = msi_addstringW( cv->db->strings, 0, col->colname, -1, 1 );
-        TRACE("New string %s -> %d\n", debugstr_w( col->colname ), column_val );
+        column_val = msi_addstringW( cv->db->strings, 0, col->column, -1, 1 );
+        TRACE("New string %s -> %d\n", debugstr_w( col->column ), column_val );
         if( column_val < 0 )
             break;
 
@@ -226,7 +226,7 @@ MSIVIEWOPS create_ops =
 };
 
 UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
-                        create_col_info *col_info, BOOL temp )
+                        column_info *col_info, BOOL temp )
 {
     MSICREATEVIEW *cv = NULL;
 
Index: dlls/msi/insert.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/insert.c,v
retrieving revision 1.11
diff -u -p -r1.11 insert.c
--- dlls/msi/insert.c	23 May 2005 12:08:17 -0000	1.11
+++ dlls/msi/insert.c	27 May 2005 05:19:47 -0000
@@ -255,7 +255,7 @@ MSIVIEWOPS insert_ops =
 };
 
 UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
-                        string_list *columns, value_list *values, BOOL temp )
+                        column_info *columns, value_list *values, BOOL temp )
 {
     MSIINSERTVIEW *iv = NULL;
     UINT r;
Index: dlls/msi/order.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/order.c,v
retrieving revision 1.10
diff -u -p -r1.10 order.c
--- dlls/msi/order.c	23 May 2005 10:27:00 -0000	1.10
+++ dlls/msi/order.c	27 May 2005 05:19:47 -0000
@@ -302,11 +302,11 @@ static UINT ORDER_AddColumn( MSIORDERVIE
 }
 
 UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
-                       string_list *columns )
+                       column_info *columns )
 {
     MSIORDERVIEW *ov = NULL;
     UINT count = 0, r;
-    string_list *x;
+    column_info *x;
 
     TRACE("%p\n", ov );
 
@@ -332,7 +332,7 @@ UINT ORDER_CreateView( MSIDATABASE *db, 
     *view = (MSIVIEW*) ov;
 
     for( x = columns; x ; x = x->next )
-        ORDER_AddColumn( ov, x->string );
+        ORDER_AddColumn( ov, x->column );
 
     return ERROR_SUCCESS;
 }
Index: dlls/msi/query.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/query.h,v
retrieving revision 1.16
diff -u -p -r1.16 query.h
--- dlls/msi/query.h	23 May 2005 12:08:17 -0000	1.16
+++ dlls/msi/query.h	27 May 2005 05:19:48 -0000
@@ -59,6 +59,15 @@ struct sql_str {
     INT len;
 };
 
+typedef struct _column_info
+{
+    LPCWSTR table;
+    LPCWSTR column;
+    UINT   type;
+    struct expr *val;
+    struct _column_info *next;
+} column_info;
+
 typedef struct _string_list
 {
     LPWSTR string;
@@ -80,19 +89,12 @@ struct expr
         struct complex_expr expr;
         INT   ival;
         UINT  uval;
-        LPWSTR sval;
-        LPWSTR column;
+        LPCWSTR sval;
+        LPCWSTR column;
         UINT col_number;
     } u;
 };
 
-typedef struct _create_col_info
-{
-    LPWSTR colname;
-    UINT   type;
-    struct _create_col_info *next;
-} create_col_info;
-
 typedef struct _value_list
 {
     struct expr *val;
@@ -101,7 +103,7 @@ typedef struct _value_list
 
 typedef struct _column_assignment
 {
-    string_list *col_list;
+    column_info *col_list;
     value_list *val_list;
 } column_assignment;
 
@@ -112,24 +114,24 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCW
 UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view );
 
 UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
-                        string_list *columns );
+                        column_info *columns );
 
 UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table );
 
 UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
-                       string_list *columns );
+                       column_info *columns );
 
 UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
                        struct expr *cond );
 
 UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
-                        create_col_info *col_info, BOOL temp );
+                        column_info *col_info, BOOL temp );
 
 UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
-                        string_list *columns, value_list *values, BOOL temp );
+                        column_info *columns, value_list *values, BOOL temp );
 
 UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **, LPWSTR table,
-                        column_assignment *list, struct expr *expr );
+                        column_info *list, struct expr *expr );
 
 UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table );
 
Index: dlls/msi/select.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/select.c,v
retrieving revision 1.8
diff -u -p -r1.8 select.c
--- dlls/msi/select.c	8 Feb 2005 13:44:25 -0000	1.8
+++ dlls/msi/select.c	27 May 2005 05:19:48 -0000
@@ -210,7 +210,7 @@ MSIVIEWOPS select_ops =
     SELECT_delete
 };
 
-static UINT SELECT_AddColumn( MSISELECTVIEW *sv, LPWSTR name )
+static UINT SELECT_AddColumn( MSISELECTVIEW *sv, LPCWSTR name )
 {
     UINT r, n=0;
     MSIVIEW *table;
@@ -245,7 +245,7 @@ static UINT SELECT_AddColumn( MSISELECTV
 }
 
 UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
-                        string_list *columns )
+                        column_info *columns )
 {
     MSISELECTVIEW *sv = NULL;
     UINT count = 0, r;
@@ -273,7 +273,7 @@ UINT SELECT_CreateView( MSIDATABASE *db,
 
     while( columns )
     {
-        r = SELECT_AddColumn( sv, columns->string );
+        r = SELECT_AddColumn( sv, columns->column );
         if( r )
             break;
         columns = columns->next;
Index: dlls/msi/sql.y
===================================================================
RCS file: /home/wine/wine/dlls/msi/sql.y,v
retrieving revision 1.28
diff -u -p -r1.28 sql.y
--- dlls/msi/sql.y	24 May 2005 09:49:01 -0000	1.28
+++ dlls/msi/sql.y	27 May 2005 05:19:48 -0000
@@ -55,11 +55,12 @@ static INT SQL_getint( void *info );
 static int SQL_lex( void *SQL_lval, SQL_input *info );
 
 static void *parser_alloc( void *info, unsigned int sz );
+static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column );
 
-static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys);
+static BOOL SQL_MarkPrimaryKeys( column_info *cols, column_info *keys);
 
 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
-static struct expr * EXPR_column( void *info, LPWSTR column );
+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_sval( void *info, struct sql_str * );
 static struct expr * EXPR_wildcard( void *info );
@@ -72,13 +73,11 @@ static struct expr * EXPR_wildcard( void
 {
     struct sql_str str;
     LPWSTR string;
-    string_list *column_list;
+    column_info *column_list;
     value_list *val_list;
     MSIVIEW *query;
     struct expr *expr;
     USHORT column_type;
-    create_col_info *column_info;
-    column_assignment update_col_info;
 }
 
 %token TK_ABORT TK_AFTER TK_AGG_FUNCTION TK_ALL TK_AND TK_AS TK_ASC
@@ -125,15 +124,14 @@ static struct expr * EXPR_wildcard( void
 %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
           COLUMN AGG_FUNCTION.
 
-%type <string> column table id
-%type <column_list> selcollist
-%type <query> query from fromtable unorderedsel selectfrom
+%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 <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 <column_info> column_def table_def
 %type <val_list> constlist
-%type <update_col_info> column_assignment update_assign_list
 
 %%
 
@@ -210,7 +208,7 @@ oneupdate:
             SQL_input* sql = (SQL_input*) info;
             MSIVIEW *update = NULL; 
 
-            UPDATE_CreateView( sql->db, &update, $2, &$4, $6 );
+            UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
             if( !update )
                 YYABORT;
             $$ = update;
@@ -241,33 +239,27 @@ table_def:
     ;
 
 column_def:
-    column_def TK_COMMA column column_type
+    column_def TK_COMMA column_and_type
         {
-            create_col_info *ci;
+            column_info *ci;
 
             for( ci = $1; ci->next; ci = ci->next )
                 ;
 
-            ci->next = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ );
-            if( !ci->next )
-            {
-                /* FIXME: free $1 */
-                YYABORT;
-            }
-            ci->next->colname = $3;
-            ci->next->type = $4;
-            ci->next->next = NULL;
-
+            ci->next = $3;
             $$ = $1;
         }
-  | column column_type
+  | column_and_type
         {
-            $$ = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ );
-            if( ! $$ )
-                YYABORT;
-            $$->colname = $1;
+            $$ = $1;
+        }
+    ;
+
+column_and_type:
+    column column_type
+        {
+            $$ = $1;
             $$->type = $2;
-            $$->next = NULL;
         }
     ;
 
@@ -386,30 +378,9 @@ selectfrom:
 
 selcollist:
     column 
-        { 
-            string_list *list;
-
-            list = HeapAlloc( GetProcessHeap(), 0, sizeof *list );
-            if( !list )
-                YYABORT;
-            list->string = $1;
-            list->next = NULL;
-
-            $$ = list;
-            TRACE("Collist %s\n",debugstr_w($$->string));
-        }
   | column TK_COMMA selcollist
         { 
-            string_list *list;
-
-            list = HeapAlloc( GetProcessHeap(), 0, sizeof *list );
-            if( !list )
-                YYABORT;
-            list->string = $1;
-            list->next = $3;
-
-            $$ = list;
-            TRACE("From table: %s\n",debugstr_w($$->string));
+            $1->next = $3;
         }
   | TK_STAR
         {
@@ -553,25 +524,16 @@ update_assign_list:
     column_assignment
   | column_assignment TK_COMMA update_assign_list
         {
-            $1.col_list->next = $3.col_list;
-            $1.val_list->next = $3.val_list;
             $$ = $1;
+            $$->next = $3;
         }
     ;
 
 column_assignment:
     column TK_EQ const_val
         {
-            $$.col_list = HeapAlloc( GetProcessHeap(), 0, sizeof *$$.col_list );
-            if( !$$.col_list )
-                YYABORT;
-            $$.col_list->string = $1;
-            $$.col_list->next = NULL;
-            $$.val_list = HeapAlloc( GetProcessHeap(), 0, sizeof *$$.val_list );
-            if( !$$.val_list )
-                YYABORT;
-            $$.val_list->val = $3;
-            $$.val_list->next = 0;
+            $$ = $1;
+            $$->val = $3;
         }
     ;
 
@@ -614,11 +576,15 @@ column_val:
 column:
     table TK_DOT id
         {
-            $$ = $3;  /* FIXME */
+            $$ = parser_alloc_column( info, $1, $3 );
+            if( !$$ )
+                YYABORT;
         }
   | id
         {
-            $$ = $1;
+            $$ = parser_alloc_column( info, NULL, $1 );
+            if( !$$ )
+                YYABORT;
         }
     ;
 
@@ -650,6 +616,23 @@ static void *parser_alloc( void *info, u
     return &mem[1];
 }
 
+static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
+{
+    column_info *col;
+
+    col = parser_alloc( info, sizeof (*col) );
+    if( col )
+    {
+        col->table = table;
+        col->column = column;
+        col->val = NULL;
+        col->type = 0;
+        col->next = NULL;
+    }
+
+    return col;
+}
+
 int SQL_lex( void *SQL_lval, SQL_input *sql )
 {
     int token;
@@ -733,13 +716,13 @@ static struct expr * EXPR_complex( void 
     return e;
 }
 
-static struct expr * EXPR_column( void *info, LPWSTR column )
+static struct expr * EXPR_column( void *info, column_info *column )
 {
     struct expr *e = parser_alloc( info, sizeof *e );
     if( e )
     {
         e->type = EXPR_COLUMN;
-        e->u.sval = column;
+        e->u.sval = column->column;
     }
     return e;
 }
@@ -766,19 +749,20 @@ static struct expr * EXPR_sval( void *in
     return e;
 }
 
-static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys)
+static BOOL SQL_MarkPrimaryKeys( column_info *cols,
+                                 column_info *keys )
 {
-    string_list *k;
+    column_info *k;
     BOOL found = TRUE;
 
     for( k = keys; k && found; k = k->next )
     {
-        create_col_info *c;
+        column_info *c;
 
         found = FALSE;
         for( c = cols; c && !found; c = c->next )
         {
-             if( lstrcmpW( k->string, c->colname ) )
+             if( lstrcmpW( k->column, c->column ) )
                  continue;
              c->type |= MSITYPE_KEY;
              found = TRUE;
Index: dlls/msi/update.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/update.c,v
retrieving revision 1.6
diff -u -p -r1.6 update.c
--- dlls/msi/update.c	23 May 2005 12:08:17 -0000	1.6
+++ dlls/msi/update.c	27 May 2005 05:19:48 -0000
@@ -43,7 +43,7 @@ typedef struct tagMSIUPDATEVIEW
     MSIVIEW          view;
     MSIDATABASE     *db;
     MSIVIEW         *wv;
-    value_list      *vals;
+    column_info     *vals;
 } MSIUPDATEVIEW;
 
 static UINT UPDATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
@@ -193,7 +193,7 @@ static MSIVIEWOPS update_ops =
 };
 
 UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
-                        column_assignment *list, struct expr *expr )
+                        column_info *columns, struct expr *expr )
 {
     MSIUPDATEVIEW *uv = NULL;
     UINT r;
@@ -215,7 +215,7 @@ UINT UPDATE_CreateView( MSIDATABASE *db,
     }
     
     /* then select the columns we want */
-    r = SELECT_CreateView( db, &sv, wv, list->col_list );
+    r = SELECT_CreateView( db, &sv, wv, columns );
     if( r != ERROR_SUCCESS )
     {
         if( tv )
@@ -231,7 +231,7 @@ UINT UPDATE_CreateView( MSIDATABASE *db,
     uv->view.ops = &update_ops;
     msiobj_addref( &db->hdr );
     uv->db = db;
-    uv->vals = list->val_list;
+    uv->vals = columns;
     uv->wv = sv;
     *view = (MSIVIEW*) uv;
 


More information about the wine-patches mailing list