Release 970804

Sun Aug  3 14:03:43 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [documentation/Makefile.in]
	Create links for files included from wine.texinfo.

	* [wine.man]
	Moved to documentation dir.

	* [if1632/builtin.c]
	Made SYSTEM.DLL always loaded by default.

	* [loader/signal.c] [if1632/signal.c]
	Split signal.c in generic/emulator-specific parts.

	* [misc/system.c] [if1632/thunk.c]
	Implemented system timer functions.
	Fixed InquireSystem parameters.

	* [msdos/ioports.c]
	Defined inb/outb functions to avoid including asm/io.h.
	Use the right instruction for word and dword direct access.

	* [multimedia/mmsystem.c]
	Fixed CallTo16 usage.

Sat Aug 2 13:05:23 1997  Andreas Mohr <100.30936@germany.net>

	* [controls/edit.c]
	When text is inserted into a newly created editline, the caret
	is placed after the text. Should be placed before the text. Fixed.

	* [files/file.c]
	Removed O_TRUNC flag from OF_WRITE mode in _lopen32().
	According to doc _lopen() never truncates files.

	* [if1632/user.spec] [misc/comm.c]
	Added stub for EnableCommNotification().

	* [misc/ver.c]
	Fixed problem with VerQueryValue*() running over end of name table
	in rare cases.

	* [msdos/int21.c]
	Enhanced ioctlGetDeviceInfo() to correctly return the current drive.

	* [multimedia/joystick.c] [windows/message.c]
	Added joystick support !!!
	Needs Linux >= 2.1.45 or joystick-0.8.0.tar.gz.

Fri Aug  1 18:02:09 1997  Morten Welinder  <terra@diku.dk>

	* [if1632/user32.spec]
	Define DrawAnimatedRects32.

	* [graphics/painting.c]
	(DrawAnimatedRects32): Create stub.

	* [misc/registry.c]
	Cope with NULL class in RegQueryInfoKey32A.

	* [if1632/user32.spec]
	Add GetMenuItemInfo32[AW].

	* [controls/menu.c]
	(InsertMenu32A): Upgrade flags to 8 hex-digits.
	(MENUEX_ParseResource): First shot at implementation.
	(LoadMenuIndirect32A): Handle extended menus.
	(GetMenuItemInfo32[AW]): First shot at implementation.

	* [include/windows.h]
	Define MFT_*, MFS_*, MIIM_* macros.  Define MENUITEMINFO[AW]
 	structures and pointers.

	* [Makefile.in]
	(etags): Add TAGS as target.

	* [if1632/comctl32.spec]
	Use Windows 95's ordinals.  Add a few missing stubs.

Thu Jul 31 14:01:13 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [objects/color.c]
	Fix for 16 color mode of XFree.

	* [if1632/kernel32.spec][win32/ordinals.c]
	Moved/added some ordinal only exported functions from kernel32.dll
	(mostly thunking preparation stuff).

Wed Jul 30 09:16:38 1997  John Harvey <john@division.co.uk>

	* [graphics/win16drv/init.c] [include/win16drv.h]
        Escape(SETABORTPROC) returns success to keep pbrush.exe happy.
        Escape(NEXTBAND) implemented to make HP PCL printer driver work in
 	word.  Stub for PATBLT added to start work on printing more than
 	text.

Mon Jul 28 13:14:28 1997  Victor Schneider <vischne@ibm.net>

	* [libtest/expand.c]
	New Winelib test program.

Wed Jul 23 09:37:13 1997  Adrian Harvey <adrian@select.com.au>

	* [tools/build.c] [tools/build-spec.txt] [if1632/kernel.spec]
	  [if1632/user.spec]
	Added ability to set filename wine considers the built-in DLLs 
	to be in  to something other than name.DLL with new "file" key
	in .spec files.
	Made kernel filename KRNL386.EXE (some programs use this name 
	explicitly - ChemOffice install now starts up).
	Made user filename USER.EXE (just to be tidy).

Sun Jul 20 23:51:02 1997  David A. Cuthbert <dacut@henry.ece.cmu.edu>

	* [controls/menu.c] [misc/tweak.c] [include/tweak.h]
	Fixed MENU_KeyLeft and MENU_KeyRight to handle multiple-column
	menus.  Misc menu drawing issues for Win95 tweaks fixed.  Misc
	warnings fixed.

	* [loader/module.c]
	Spaces are now permitted in file/path names on the command line.
	If multiple matches can be made, the preferred match is the
	path/file with fewer spaces.

Tue Jul 29 02:21:15 1997  Bruce Milner <Bruce.Milner@genetics.utah.edu>

	* [misc/compobj.c]
	Added CLSIDFromString and StringFromCLSID.
diff --git a/loader/module.c b/loader/module.c
index a3522c6..bd12830 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -1162,8 +1162,9 @@
 					0xFF00, hModule, FALSE, FALSE, FALSE)
 					);
 		oldstack = IF1632_Saved16_ss_sp;
-		IF1632_Saved16_ss_sp = MAKELONG( 0xFF00 - sizeof(*stack16Top),
-                                                 pModule->self_loading_sel );
+		IF1632_Saved16_ss_sp =
+                    PTR_SEG_OFF_TO_SEGPTR( pModule->self_loading_sel,
+                                           0xff00 - sizeof(*stack16Top) );
                 stack16Top = CURRENT_STACK16;
                 stack16Top->saved_ss_sp = 0;
                 stack16Top->ebp = 0;
@@ -1458,10 +1459,11 @@
 {
     LOADPARAMS params;
     HGLOBAL16 cmdShowHandle, cmdLineHandle;
-    HINSTANCE16 handle;
+    HINSTANCE16 handle = 2;
     WORD *cmdShowPtr;
     char *p, *cmdline, filename[256];
     static int use_load_module = 1;
+    int  spacelimit = 0, exhausted = 0;
 
     if (!lpCmdLine)
         return 2;  /* File not found */
@@ -1473,115 +1475,148 @@
         return 8;  /* Out of memory */
     }
 
-      /* Store nCmdShow */
+    /* Keep trying to load a file by trying different filenames; e.g.,
+       for the cmdline "abcd efg hij", try "abcd" with args "efg hij",
+       then "abcd efg" with arg "hij", and finally "abcd efg hij" with
+       no args */
 
-    cmdShowPtr = (WORD *)GlobalLock16( cmdShowHandle );
-    cmdShowPtr[0] = 2;
-    cmdShowPtr[1] = nCmdShow;
+    while(!exhausted && handle == 2) {
+	int spacecount = 0;
 
-      /* Build the filename and command-line */
+	/* Store nCmdShow */
 
-    cmdline = (char *)GlobalLock16( cmdLineHandle );
-    lstrcpyn32A(filename, lpCmdLine, sizeof(filename) - 4 /* for extension */);
-    for (p = filename; *p && (*p != ' ') && (*p != '\t'); p++);
-    if (*p) lstrcpyn32A( cmdline + 1, p + 1, 127 );
-    else cmdline[1] = '\0';
-    cmdline[0] = strlen( cmdline + 1 ) + 1;
-    *p = '\0';
+	cmdShowPtr = (WORD *)GlobalLock16( cmdShowHandle );
+	cmdShowPtr[0] = 2;
+	cmdShowPtr[1] = nCmdShow;
 
-      /* Now load the executable file */
+	/* Build the filename and command-line */
 
-    if (use_load_module)
-    {
+	cmdline = (char *)GlobalLock16( cmdLineHandle );
+	lstrcpyn32A(filename, lpCmdLine,
+		    sizeof(filename) - 4 /* for extension */);
+
+	/* Keep grabbing characters until end-of-string, tab, or until the
+	   number of spaces is greater than the spacelimit */
+
+	for (p = filename; ; p++) {
+	    if(*p == ' ') {
+		++spacecount;
+		if(spacecount > spacelimit) {
+		    ++spacelimit;
+		    break;
+		}
+	    }
+
+	    if(*p == '\0' || *p == '\t') {
+		exhausted = 1;
+		break;
+	    }
+	}
+
+	if (*p)
+	    lstrcpyn32A( cmdline + 1, p + 1, 127 );
+	else
+	    cmdline[1] = '\0';
+
+	cmdline[0] = strlen( cmdline + 1 ) + 1;
+	*p = '\0';
+
+	/* Now load the executable file */
+
+	if (use_load_module)
+	{
 #ifdef WINELIB
-        /* WINELIB: Use LoadModule() only for the program itself */
-        use_load_module = 0;
-	params.hEnvironment = (HGLOBAL16)GetDOSEnvironment();
+	    /* WINELIB: Use LoadModule() only for the program itself */
+	    use_load_module = 0;
+	    params.hEnvironment = (HGLOBAL16)GetDOSEnvironment();
 #else
-	params.hEnvironment = (HGLOBAL16)SELECTOROF( GetDOSEnvironment() );
+	    params.hEnvironment = (HGLOBAL16)SELECTOROF( GetDOSEnvironment() );
 #endif  /* WINELIB */
-	params.cmdLine  = (SEGPTR)WIN16_GlobalLock16( cmdLineHandle );
-	params.showCmd  = (SEGPTR)WIN16_GlobalLock16( cmdShowHandle );
-	params.reserved = 0;
-	handle = LoadModule16( filename, &params );
-	if (handle == 2)  /* file not found */
-	{
-	    /* Check that the original file name did not have a suffix */
-	    p = strrchr(filename, '.');
-	    /* if there is a '.', check if either \ OR / follow */
-	    if (!p || strchr(p, '/') || strchr(p, '\\'))
-            {
-                p = filename + strlen(filename);
-                strcpy( p, ".exe" );
-                handle = LoadModule16( filename, &params );
-                *p = '\0';  /* Remove extension */
-            }
+	    params.cmdLine  = (SEGPTR)WIN16_GlobalLock16( cmdLineHandle );
+	    params.showCmd  = (SEGPTR)WIN16_GlobalLock16( cmdShowHandle );
+	    params.reserved = 0;
+	    handle = LoadModule16( filename, &params );
+	    if (handle == 2)  /* file not found */
+	    {
+		/* Check that the original file name did not have a suffix */
+		p = strrchr(filename, '.');
+		/* if there is a '.', check if either \ OR / follow */
+		if (!p || strchr(p, '/') || strchr(p, '\\'))
+		{
+		    p = filename + strlen(filename);
+		    strcpy( p, ".exe" );
+		    handle = LoadModule16( filename, &params );
+		    *p = '\0';  /* Remove extension */
+		}
+	    }
 	}
-    }
-    else handle = 2;
+	else
+	    handle = 2; /* file not found */
 
-    if (handle < 32)
-    {
-        /* Try to start it as a unix program */
-        if (!fork())
+	if (handle < 32)
 	{
-            /* Child process */
-            DOS_FULL_NAME full_name;
-            const char *unixfilename = NULL;
-            const char *argv[256], **argptr;
-            int iconic = (nCmdShow == SW_SHOWMINIMIZED ||
-                          nCmdShow == SW_SHOWMINNOACTIVE);
+	    /* Try to start it as a unix program */
+	    if (!fork())
+	    {
+		/* Child process */
+		DOS_FULL_NAME full_name;
+		const char *unixfilename = NULL;
+		const char *argv[256], **argptr;
+		int iconic = (nCmdShow == SW_SHOWMINIMIZED ||
+			      nCmdShow == SW_SHOWMINNOACTIVE);
 
-            /* get unixfilename */
-            if (strchr(filename, '/') ||
-                strchr(filename, ':') ||
-                strchr(filename, '\\'))
-            {
-                if (DOSFS_GetFullName( filename, TRUE, &full_name ))
-                    unixfilename = full_name.long_name;
-            }
-            else unixfilename = filename;
+		/* get unixfilename */
+		if (strchr(filename, '/') ||
+		    strchr(filename, ':') ||
+		    strchr(filename, '\\'))
+		{
+		    if (DOSFS_GetFullName( filename, TRUE, &full_name ))
+			unixfilename = full_name.long_name;
+		}
+		else unixfilename = filename;
 
-            if (unixfilename)
-            {
-                /* build argv */
-                argptr = argv;
-                if (iconic) *argptr++ = "-iconic";
-                *argptr++ = unixfilename;
-                p = cmdline;
-                while (1)
-                {
-                    while (*p && (*p == ' ' || *p == '\t')) *p++ = '\0';
-                    if (!*p) break;
-                    *argptr++ = p;
-                    while (*p && *p != ' ' && *p != '\t') p++;
-                }
-                *argptr++ = 0;
+		if (unixfilename)
+		{
+		    /* build argv */
+		    argptr = argv;
+		    if (iconic) *argptr++ = "-iconic";
+		    *argptr++ = unixfilename;
+		    p = cmdline;
+		    while (1)
+		    {
+			while (*p && (*p == ' ' || *p == '\t')) *p++ = '\0';
+			if (!*p) break;
+			*argptr++ = p;
+			while (*p && *p != ' ' && *p != '\t') p++;
+		    }
+		    *argptr++ = 0;
 
-                /* Execute */
-                execvp(argv[0], (char**)argv);
-            }
+		    /* Execute */
+		    execvp(argv[0], (char**)argv);
+		}
 
-	    /* Failed ! */
+		/* Failed ! */
 
-            if (__winelib)
-            {
-                /* build argv */
-                argptr = argv;
-                *argptr++ = "wine";
-                if (iconic) *argptr++ = "-iconic";
-                *argptr++ = lpCmdLine;
-                *argptr++ = 0;
+		if (__winelib)
+		{
+		    /* build argv */
+		    argptr = argv;
+		    *argptr++ = "wine";
+		    if (iconic) *argptr++ = "-iconic";
+		    *argptr++ = lpCmdLine;
+		    *argptr++ = 0;
 
-                /* Execute */
-                execvp(argv[0] , (char**)argv);
+		    /* Execute */
+		    execvp(argv[0] , (char**)argv);
 
-                /* Failed ! */
-                fprintf(stderr, "WinExec: can't exec 'wine %s'\n", lpCmdLine);
-            }
-	    exit(1);
+		    /* Failed ! */
+		    fprintf(stderr, "WinExec: can't exec 'wine %s'\n",
+			    lpCmdLine);
+		}
+		exit(1);
+	    }
 	}
-    }
+    } /* while (!exhausted && handle < 32) */
 
     GlobalFree16( cmdShowHandle );
     GlobalFree16( cmdLineHandle );
@@ -1590,6 +1625,35 @@
 
 
 /***********************************************************************
+ *           WIN32_GetProcAddress16   (KERNEL32.36)
+ * Get procaddress in 16bit module from win32... (kernel32 undoc. ordinal func)
+ */
+FARPROC16 WIN32_GetProcAddress16( HMODULE16 hModule, LPSTR name )
+{
+    WORD	ordinal;
+    FARPROC16	ret;
+
+    if (!hModule) {
+    	fprintf(stderr,"WIN32_GetProcAddress16: hModule may not be 0!\n");
+	return (FARPROC16)0;
+    }
+    hModule = GetExePtr(hModule);
+    if (HIWORD(name)) {
+        ordinal = MODULE_GetOrdinal( hModule, name );
+        dprintf_module( stddeb, "WIN32_GetProcAddress16: %04x '%s'\n",
+                        hModule, name );
+    } else {
+        ordinal = LOWORD(name);
+        dprintf_module( stddeb, "GetProcAddress: %04x %04x\n",
+                        hModule, ordinal );
+    }
+    if (!ordinal) return (FARPROC16)0;
+    ret = MODULE_GetEntryPoint( hModule, ordinal );
+    dprintf_module(stddeb,"WIN32_GetProcAddress16: returning %08x\n",(UINT32)ret);
+    return ret;
+}
+
+/***********************************************************************
  *           GetProcAddress16   (KERNEL.50)
  */
 FARPROC16 GetProcAddress16( HMODULE16 hModule, SEGPTR name )