cmd: Fix compilation on systems that don't support nameless unions.

Francois Gouget fgouget at free.fr
Mon Mar 12 04:35:13 CDT 2007


---

There's no good reason to use unnamed unions in Wine-specific 
structures. In fact calling them something like 'u' is a nice reminder 
that what is being accessed is in a union which means one must first 
check the structure's type to be sure we're using the right union field.

 programs/cmd/builtins.c |   10 +++++-----
 programs/cmd/wcmd.h     |    2 +-
 programs/cmd/wcmdmain.c |    4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index d8c3967..cae82b3 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -632,9 +632,9 @@ void WCMD_pushd (char *command) {
       curdir -> next    = pushd_directories;
       curdir -> strings = thisdir;
       if (pushd_directories == NULL) {
-        curdir -> stackdepth = 1;
+        curdir -> u.stackdepth = 1;
       } else {
-        curdir -> stackdepth = pushd_directories -> stackdepth + 1;
+        curdir -> u.stackdepth = pushd_directories -> u.stackdepth + 1;
       }
       pushd_directories = curdir;
     }
@@ -916,7 +916,7 @@ void WCMD_setlocal (const char *s) {
 
     /* Save the current drive letter */
     GetCurrentDirectory (MAX_PATH, cwd);
-    env_copy->cwd = cwd[0];
+    env_copy->u.cwd = cwd[0];
   }
   else
     LocalFree (env_copy);
@@ -990,10 +990,10 @@ void WCMD_endlocal (void) {
   }
 
   /* Restore current drive letter */
-  if (IsCharAlpha(temp->cwd)) {
+  if (IsCharAlpha(temp->u.cwd)) {
     char envvar[4];
     char cwd[MAX_PATH];
-    sprintf(envvar, "=%c:", temp->cwd);
+    sprintf(envvar, "=%c:", temp->u.cwd);
     if (GetEnvironmentVariable(envvar, cwd, MAX_PATH)) {
       WINE_TRACE("Resetting cwd to %s\n", cwd);
       SetCurrentDirectory(cwd);
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index d43e1cd..2915644 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -104,7 +104,7 @@ struct env_stack
   union {
     int    stackdepth;       /* Only used for pushd and popd */
     char   cwd;              /* Only used for set/endlocal   */
-  };
+  } u;
   WCHAR *strings;
 };
 
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 1dcf1e5..544e02e 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1028,8 +1028,8 @@ void WCMD_show_prompt (void) {
 	  break;
 	case '+':
 	  if (pushd_directories) {
-	    memset(q, '+', pushd_directories->stackdepth);
-	    q = q + pushd_directories->stackdepth;
+	    memset(q, '+', pushd_directories->u.stackdepth);
+	    q = q + pushd_directories->u.stackdepth;
 	  }
 	  break;
       }
-- 
1.4.4.4



More information about the wine-patches mailing list