Detlef Riekenberg : winspool: Empty string as environment is valid, with tests.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Feb 1 06:59:16 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 366f452b91e9399217e90a3a441aa91e50fd4c61
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=366f452b91e9399217e90a3a441aa91e50fd4c61

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Wed Feb  1 12:32:10 2006 +0100

winspool: Empty string as environment is valid, with tests.

---

 dlls/winspool/info.c       |    9 ++++-----
 dlls/winspool/tests/info.c |   28 +++++++++++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/dlls/winspool/info.c b/dlls/winspool/info.c
index d0f51aa..15f0c48 100644
--- a/dlls/winspool/info.c
+++ b/dlls/winspool/info.c
@@ -204,6 +204,7 @@ static DWORD WINSPOOL_GetOpenedPrinterRe
  *  Success:  PTR to printenv_t
  *
  * NOTES
+ *  An empty string is handled the same way as NULL.
  *  SetLastEror(ERROR_INVALID_ENVIRONMENT) is called on Failure
  *  
  */
@@ -218,7 +219,7 @@ static const  printenv_t * validate_envW
     unsigned int i;
 
     TRACE("testing %s\n", debugstr_w(env));
-    if (env)
+    if (env && env[0])
     {
         for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++)
         {
@@ -3399,9 +3400,7 @@ BOOL WINAPI GetPrinterDriverW(HANDLE hPr
  *   "%winsysdir%" is the Value from GetSystemDirectoryW()
  *
  * FIXME
- *-  pName != NULL not supported
- *-  pEnvironment != NULL not supported
- *-  Current Implementation returns always "%winsysdir%"
+ *-  Only NULL or "" is supported for pName
  *
  */
 BOOL WINAPI GetPrinterDriverDirectoryW(LPWSTR pName, LPWSTR pEnvironment,
@@ -3413,7 +3412,7 @@ BOOL WINAPI GetPrinterDriverDirectoryW(L
 
     TRACE("(%s, %s, %ld, %p, %ld, %p)\n", debugstr_w(pName), 
           debugstr_w(pEnvironment), Level, pDriverDirectory, cbBuf, pcbNeeded);
-    if(pName != NULL) {
+    if(pName != NULL && pName[0]) {
         FIXME("pName unsupported: %s\n", debugstr_w(pName));
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
diff --git a/dlls/winspool/tests/info.c b/dlls/winspool/tests/info.c
index 4b11829..8041f5c 100644
--- a/dlls/winspool/tests/info.c
+++ b/dlls/winspool/tests/info.c
@@ -94,7 +94,7 @@ static LPSTR find_default_printer(VOID)
 }
 
 
-static void test_default_printer(void)
+static void test_GetDefaultPrinter(void)
 {
     BOOL    retval;
     DWORD   exact = DEFAULT_PRINTER_SIZE;
@@ -171,8 +171,9 @@ static void test_default_printer(void)
 	exact, size);
 }
 
-static void test_printer_directory(void)
-{   LPBYTE buffer = NULL;
+static void test_GetPrinterDriverDirectory(void)
+{
+    LPBYTE buffer = NULL;
     DWORD  cbBuf = 0, pcbNeeded = 0;
     BOOL   res;
 
@@ -305,10 +306,23 @@ static void test_printer_directory(void)
         "'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
         res, GetLastError(), lstrlenA((char *)buffer));
 
+    /* A Setup-Programm (PDFCreator_0.8.0) use empty strings */
+    SetLastError(MAGIC_DEAD);
+    res = GetPrinterDriverDirectoryA("", "", 1, buffer, cbBuf*2, &pcbNeeded);
+    ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
+
+    SetLastError(MAGIC_DEAD);
+    res = GetPrinterDriverDirectoryA(NULL, "", 1, buffer, cbBuf*2, &pcbNeeded);
+    ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
+
+    SetLastError(MAGIC_DEAD);
+    res = GetPrinterDriverDirectoryA("", NULL, 1, buffer, cbBuf*2, &pcbNeeded);
+    ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
+
     HeapFree( GetProcessHeap(), 0, buffer);
 }
 
-static void test_openprinter(void)
+static void test_OpenPrinter(void)
 {
     PRINTER_DEFAULTSA defaults;
     HANDLE  hprinter;
@@ -458,7 +472,7 @@ START_TEST(info)
 
     find_default_printer();
 
-    test_default_printer();
-    test_printer_directory();
-    test_openprinter();
+    test_GetDefaultPrinter();
+    test_GetPrinterDriverDirectory();
+    test_OpenPrinter();
 }




More information about the wine-cvs mailing list