Release 970509

Tue May  6 19:12:20 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [loader/task.c] [loader/module.c]
	Fixed command line in LoadModule to already include the length
	indicator (thanks to Andreas Mohr).

	* [windows/dialog.c]
	DlgDirList: fixed behavior with DDL_DRIVES | DDL_EXCLUSIVE (thanks
	to Bruce Milner for this one); correctly update file spec on exit.

	* [windows/winproc.c] [if1632/thunk.c] [include/callback.h]
	Moved emulator-specific code for calling window procedure to
	thunk.c.

Mon Apr 28 10:21:59 1997  Huw D M Davies <h.davies1@physics.oxford.ac.uk>

	* [memory/local.c]
	Better implementation of moveable blocks (first word in block is
	the handle itself) and discarded blocks. Local(Re)Alloc is much
	more like the real thing.

Thu Apr 24 19:50:19 1997  Albrecht Kleine <kleine@ak.sax.de>

	* [objects/metafile.c]
	Added handling of meta record META_DIBCREATEPATTERNBRUSH.

Mon Apr 21 14:03:32 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [multimedia/mmsystem.c] [multimedia/audio.c]
	Fixed leftover problems with masked device IDs.

	* [msdos/int21.c]
	Removed code duplications, fixed Write.

	* [windows/event.c] [windows/dce.c] [windows/nonclient.c]
	  [windows/winpos.c]
	Yet another attempt to make -managed work better.

	* [controls/combo.c]
	UI fix.

Mon Apr 21 13:10:24 1997  Marcus Meissner <msmeissn@immd4.informatik.uni-erlangen.de>

	* [debugger/*]
	All "Loading from ..." lines merged into one so important
	information before the crash doesn't scroll out.

	* [if1632/kernel.spec]
	Added some ordinal stubs used by win95 OLE and friends.

	* [win32/process.c] [if1632/kernel.spec] [loader/module.c]
	MsgWaitForMultipleObjects,GetProcessTimes,RtlImageNtHeaders,
 	LoadLibraryEx32W and GetProcAddress32W added.

	* [objects/bitmap.c]
	XImages use another memory layout for depth 4 (and poss. other
 	depths) then Windows bitmaps. Replaced speedup hack by generic
 	(and better working) code.

	* [objects/dib.c]
	Another ximage!=bitmap memory layout bug. 
	All _XinitImageFuncPtrs except one removed.

Sun Apr 20 17:12:30 1997  Andrew Taylor <andrew@riscan.com>

	* [multimedia/audio.c]
	Fixed some regression bugs.

Sun Apr 20 12:15:09 1997  Andreas Mohr <100.30936@germany.net>

	* [loader/module.c]
	Fixed MODULE_LoadExeHeader() to use the correct offset for
	fast-load area.

Sat Apr 19 16:40:00 1997  Chad Fraleigh <chadf@bookcase.com>

	* [controls/*] [debugger/*] [graphics/win16drv/*] [loader/*] [misc/*]
	  [win32/*]
	Removed <malloc.h> and added <stdlib.h> where needed.
	Changed printf formaters to match argument types (%lx instead of %x).
	Casted some types to make the compiler happy. Mostly pointer<->ulong.

	* [graphics/win16drv/init.c]
	Fixed uninitialized variable.

	* [include/msdos.h]
	Added <sys/types.h> needed for <dirent.h>.

	* [include/sigcontext.h]
	Combined a common NetBSD & FreeBSD #ifdef, and added in OpenBSD.
	Casted EIP_sig/ESP_sig to be unsigned long (declared as 'int' in *BSD).

	* [misc/crtdll.c] [misc/lstr.c]
	Casted last argument in v*printf() to be va_list. This code seems to
	make BIG assumptions about the implementation of va_list.

	* [misc/ver.c]
	Fixed impossible if() expression (unsigned < 0).

	* [misc/winsock.c]
	Removed semicolon on the end of an if() statement.

	* [windows/mdi.c]
	Changed a counter/index to unsigned since it was complaining about
	signed/unsigned comparison and didn't need to be negative.

Wed Apr 16 17:43:19 1997 Georg Beyerle <gbeyerle@awi-potsdam.de>

	* [scheduler/thread.c]
	Minor fix in thread database initialization.

Wed Apr 16 17:28:05 1997  Andreas Mohr <100.30936@germany.net>

	* [files/file.c]
	Fixed FILE_FillInfo() to omit the archive flag when handling a DOS
	directory entry.
diff --git a/windows/dialog.c b/windows/dialog.c
index ca234ad..f59cbd9 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -1565,11 +1565,12 @@
  *
  * Helper function for DlgDirList*
  */
-static INT32 DIALOG_DlgDirList( HWND32 hDlg, LPCSTR spec, INT32 idLBox,
+static INT32 DIALOG_DlgDirList( HWND32 hDlg, LPSTR spec, INT32 idLBox,
                                 INT32 idStatic, UINT32 attrib, BOOL32 combo )
 {
     int drive;
     HWND32 hwnd;
+    LPSTR orig_spec = spec;
 
 #define SENDMSG(msg,wparam,lparam) \
     ((attrib & DDL_POSTMSGS) ? PostMessage32A( hwnd, msg, wparam, lparam ) \
@@ -1586,41 +1587,42 @@
     }
     else drive = DRIVE_GetCurrentDrive();
 
+    /* If the path exists and is a directory, chdir to it */
+    if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
+    else
+    {
+        char *p, *p2;
+        p = spec;
+        if ((p2 = strrchr( p, '\\' ))) p = p2;
+        if ((p2 = strrchr( p, '/' ))) p = p2;
+        if (p != spec)
+        {
+            char sep = *p;
+            *p = 0;
+            if (!DRIVE_Chdir( drive, spec ))
+            {
+                *p = sep;  /* Restore the original spec */
+                return FALSE;
+            }
+            spec = p + 1;
+        }
+    }
+
+    dprintf_dialog( stddeb, "ListBoxDirectory: path=%c:\\%s mask=%s\n",
+                    'A' + drive, DRIVE_GetDosCwd(drive), spec );
+
     if (idLBox && ((hwnd = GetDlgItem32( hDlg, idLBox )) != 0))
     {
-        /* If the path exists and is a directory, chdir to it */
-        if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
-        else
-        {
-            const char *p, *p2;
-            p = spec;
-            if ((p2 = strrchr( p, '\\' ))) p = p2 + 1;
-            if ((p2 = strrchr( p, '/' ))) p = p2 + 1;
-            if (p != spec)
-            {
-                BOOL32 ret = FALSE;
-                char *dir = HeapAlloc( SystemHeap, 0, p - spec );
-                if (dir)
-                {
-                    lstrcpyn32A( dir, spec, p - spec );
-                    ret = DRIVE_Chdir( drive, dir );
-                    HeapFree( SystemHeap, 0, dir );
-                }
-                if (!ret) return FALSE;
-                spec = p;
-            }
-        }
-        
-        dprintf_dialog( stddeb, "ListBoxDirectory: path=%c:\\%s mask=%s\n",
-                        'A' + drive, DRIVE_GetDosCwd(drive), spec );
-        
         SENDMSG( combo ? CB_RESETCONTENT32 : LB_RESETCONTENT32, 0, 0 );
-        if ((attrib & DDL_DIRECTORY) && !(attrib & DDL_EXCLUSIVE))
+        if (attrib & DDL_DIRECTORY)
         {
-            if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
-                         attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
-                         (LPARAM)spec ) == LB_ERR)
-                return FALSE;
+            if (!(attrib & DDL_EXCLUSIVE))
+            {
+                if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
+                             attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
+                             (LPARAM)spec ) == LB_ERR)
+                    return FALSE;
+            }
             if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
                        (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
                          (LPARAM)"*.*" ) == LB_ERR)
@@ -1645,12 +1647,41 @@
         /* Can't use PostMessage() here, because the string is on the stack */
         SetDlgItemText32A( hDlg, idStatic, temp );
     }
+
+    if (orig_spec && (spec != orig_spec))
+    {
+        /* Update the original file spec */
+        char *p = spec;
+        while ((*orig_spec++ = *p++));
+    }
+
     return TRUE;
 #undef SENDMSG
 }
 
 
 /**********************************************************************
+ *	    DIALOG_DlgDirListW
+ *
+ * Helper function for DlgDirList*32W
+ */
+static INT32 DIALOG_DlgDirListW( HWND32 hDlg, LPWSTR spec, INT32 idLBox,
+                                 INT32 idStatic, UINT32 attrib, BOOL32 combo )
+{
+    if (spec)
+    {
+        LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
+        INT32 ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
+                                       attrib, combo );
+        lstrcpyAtoW( spec, specA );
+        HeapFree( GetProcessHeap(), 0, specA );
+        return ret;
+    }
+    return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
+}
+
+
+/**********************************************************************
  *	    DlgDirSelect    (USER.99)
  */
 BOOL16 DlgDirSelect( HWND16 hwnd, LPSTR str, INT16 id )
@@ -1725,7 +1756,7 @@
 /**********************************************************************
  *	    DlgDirList16    (USER.100)
  */
-INT16 DlgDirList16( HWND16 hDlg, LPCSTR spec, INT16 idLBox, INT16 idStatic,
+INT16 DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox, INT16 idStatic,
                     UINT16 attrib )
 {
     return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
@@ -1735,7 +1766,7 @@
 /**********************************************************************
  *	    DlgDirList32A    (USER32.142)
  */
-INT32 DlgDirList32A( HWND32 hDlg, LPCSTR spec, INT32 idLBox, INT32 idStatic,
+INT32 DlgDirList32A( HWND32 hDlg, LPSTR spec, INT32 idLBox, INT32 idStatic,
                      UINT32 attrib )
 {
     return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
@@ -1745,21 +1776,17 @@
 /**********************************************************************
  *	    DlgDirList32W    (USER32.145)
  */
-INT32 DlgDirList32W( HWND32 hDlg, LPCWSTR spec, INT32 idLBox, INT32 idStatic,
+INT32 DlgDirList32W( HWND32 hDlg, LPWSTR spec, INT32 idLBox, INT32 idStatic,
                      UINT32 attrib )
 {
-    INT32 ret;
-    LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
-    ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic, attrib, FALSE );
-    HeapFree( GetProcessHeap(), 0, specA );
-    return ret;
+    return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
 }
 
 
 /**********************************************************************
  *	    DlgDirListComboBox16    (USER.195)
  */
-INT16 DlgDirListComboBox16( HWND16 hDlg, LPCSTR spec, INT16 idCBox,
+INT16 DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
                             INT16 idStatic, UINT16 attrib )
 {
     return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
@@ -1769,7 +1796,7 @@
 /**********************************************************************
  *	    DlgDirListComboBox32A    (USER32.143)
  */
-INT32 DlgDirListComboBox32A( HWND32 hDlg, LPCSTR spec, INT32 idCBox,
+INT32 DlgDirListComboBox32A( HWND32 hDlg, LPSTR spec, INT32 idCBox,
                              INT32 idStatic, UINT32 attrib )
 {
     return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
@@ -1779,12 +1806,8 @@
 /**********************************************************************
  *	    DlgDirListComboBox32W    (USER32.144)
  */
-INT32 DlgDirListComboBox32W( HWND32 hDlg, LPCWSTR spec, INT32 idCBox,
+INT32 DlgDirListComboBox32W( HWND32 hDlg, LPWSTR spec, INT32 idCBox,
                              INT32 idStatic, UINT32 attrib )
 {
-    INT32 ret;
-    LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
-    ret = DIALOG_DlgDirList( hDlg, specA, idCBox, idStatic, attrib, FALSE );
-    HeapFree( GetProcessHeap(), 0, specA );
-    return ret;
+    return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
 }