Sync with trunk (48463)
authorJérôme Gardou <jerome.gardou@reactos.org>
Thu, 5 Aug 2010 21:03:35 +0000 (21:03 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Thu, 5 Aug 2010 21:03:35 +0000 (21:03 +0000)
svn path=/branches/reactos-yarotows/; revision=48464

17 files changed:
dll/win32/gdi32/objects/bitmap.c
dll/win32/gdi32/objects/text.c
dll/win32/kernel32/file/dir.c
dll/win32/kernel32/misc/lang.c
dll/win32/kernel32/misc/lcformat.c
dll/win32/shell32/iconcache.c
dll/win32/ws2_32/misc/ns.c
drivers/filesystems/fastfat/create.c
lib/sdk/crt/misc/assert.c
media/doc/README.WINE
ntoskrnl/fsrtl/name.c
ntoskrnl/io/pnpmgr/plugplay.c
subsystems/win32/win32k/eng/xlate.c
subsystems/win32/win32k/include/text.h
subsystems/win32/win32k/misc/copy.c
subsystems/win32/win32k/ntuser/callback.c
subsystems/win32/win32k/objects/freetype.c

index 1070838..8d93036 100644 (file)
@@ -869,17 +869,12 @@ StretchDIBits(HDC hdc,
     }
   }
 #endif
-  if ( iUsage ) // Save time, we only look at non RGB.
-  {
-     pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage,
-                                      &ConvertedInfoSize, FALSE);
-     if (!pConvertedInfo)
-     {
+    pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage,
+                                  &ConvertedInfoSize, FALSE);
+    if (!pConvertedInfo)
+    {
         return 0;
-     }
-  }
-  else
-     pConvertedInfo = (PBITMAPINFO)lpBitsInfo;
+    }
 
   cjBmpScanSize = DIB_BitmapBitsSize((LPBITMAPINFO)pConvertedInfo);
 
index e524571..d64e012 100644 (file)
@@ -192,6 +192,13 @@ GetTextExtentExPointW(
        LPSIZE  lpSize
        )
 {
+
+  if(nMaxExtent < -1)
+  {
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
+  }
+
   return NtGdiGetTextExtentExW (
     hdc, (LPWSTR)lpszStr, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)alpDx, lpSize, 0 );
 }
@@ -216,6 +223,12 @@ GetTextExtentExPointA(
   LPWSTR lpszStrW;
   BOOL rc = 0;
 
+  if(nMaxExtent < -1)
+  {
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
+  }
+
   Status = HEAP_strdupA2W ( &lpszStrW, lpszStr );
   if (!NT_SUCCESS (Status))
     SetLastError (RtlNtStatusToDosError(Status));
index 848d4f8..913243a 100644 (file)
@@ -972,7 +972,7 @@ ContainsPath(LPCWSTR name)
 {
     if (RtlDetermineDosPathNameType_U(name) != RtlPathTypeRelative) return TRUE;
     if (name[0] != '.') return FALSE;
-    if (name[1] == '/' || name[1] == '\\') return TRUE;
+    if (name[1] == '/' || name[1] == '\\' || name[1] == '\0') return TRUE;
     return (name[1] == '.' && (name[2] == '/' || name[2] == '\\'));
 }
 
index 6ebbf9d..78cf47f 100644 (file)
@@ -158,142 +158,6 @@ ConvertDefaultLocale(LCID lcid)
 }
 
 
-/**************************************************************************
- *              EnumDateFormatsExA    (KERNEL32.@)
- *
- * FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
- * LOCALE_NOUSEROVERRIDE here as well?
- */
-BOOL
-WINAPI
-EnumDateFormatsExA(
-    DATEFMT_ENUMPROCEXA lpDateFmtEnumProcEx,
-    LCID                Locale,
-    DWORD               dwFlags)
-{
-    CALID cal_id;
-    char szBuf[256];
-
-    if (!lpDateFmtEnumProcEx)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return FALSE;
-    }
-
-    if (!GetLocaleInfoW(Locale,
-                        LOCALE_ICALENDARTYPE|LOCALE_RETURN_NUMBER,
-                        (LPWSTR)&cal_id,
-                        sizeof(cal_id)/sizeof(WCHAR)))
-    {
-        return FALSE;
-    }
-
-    switch (dwFlags & ~LOCALE_USE_CP_ACP)
-    {
-        case 0:
-        case DATE_SHORTDATE:
-            if (GetLocaleInfoA(Locale,
-                LOCALE_SSHORTDATE | (dwFlags & LOCALE_USE_CP_ACP),
-                szBuf, 256))
-            {
-                lpDateFmtEnumProcEx(szBuf, cal_id);
-            }
-            break;
-
-        case DATE_LONGDATE:
-            if (GetLocaleInfoA(Locale,
-                LOCALE_SLONGDATE | (dwFlags & LOCALE_USE_CP_ACP),
-                szBuf, 256))
-            {
-                lpDateFmtEnumProcEx(szBuf, cal_id);
-            }
-            break;
-
-        case DATE_YEARMONTH:
-            if (GetLocaleInfoA(Locale,
-                LOCALE_SYEARMONTH | (dwFlags & LOCALE_USE_CP_ACP),
-                szBuf, 256))
-            {
-                lpDateFmtEnumProcEx(szBuf, cal_id);
-            }
-            break;
-
-        default:
-            SetLastError(ERROR_INVALID_FLAGS);
-            return FALSE;
-    }
-    return TRUE;
-}
-
-
-/**************************************************************************
- *              EnumDateFormatsExW    (KERNEL32.@)
- */
-BOOL
-WINAPI
-EnumDateFormatsExW(
-    DATEFMT_ENUMPROCEXW lpDateFmtEnumProcEx,
-    LCID                Locale,
-    DWORD               dwFlags)
-{
-    CALID cal_id;
-    WCHAR wbuf[256]; // FIXME
-
-    if (!lpDateFmtEnumProcEx)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return FALSE;
-    }
-
-    if (!GetLocaleInfoW(Locale,
-                        LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,
-                        (LPWSTR)&cal_id,
-                        sizeof(cal_id)/sizeof(WCHAR)))
-    {
-        return FALSE;
-    }
-
-    switch (dwFlags & ~LOCALE_USE_CP_ACP)
-    {
-        case 0:
-        case DATE_SHORTDATE:
-            if (GetLocaleInfoW(Locale,
-                               LOCALE_SSHORTDATE | (dwFlags & LOCALE_USE_CP_ACP),
-                               wbuf,
-                               256))
-            {
-                lpDateFmtEnumProcEx(wbuf, cal_id);
-            }
-            break;
-
-        case DATE_LONGDATE:
-            if (GetLocaleInfoW(Locale,
-                               LOCALE_SLONGDATE | (dwFlags & LOCALE_USE_CP_ACP),
-                               wbuf,
-                               256))
-            {
-                lpDateFmtEnumProcEx(wbuf, cal_id);
-            }
-            break;
-
-        case DATE_YEARMONTH:
-            if (GetLocaleInfoW(Locale,
-                               LOCALE_SYEARMONTH | (dwFlags & LOCALE_USE_CP_ACP),
-                               wbuf,
-                               256))
-            {
-                lpDateFmtEnumProcEx(wbuf, cal_id);
-            }
-            break;
-
-        default:
-            SetLastError(ERROR_INVALID_FLAGS);
-            return FALSE;
-    }
-    return TRUE;
-}
-
-
 static BOOL NLS_RegEnumValue(HANDLE hKey, UINT ulIndex,
                              LPWSTR szValueName, ULONG valueNameSize,
                              LPWSTR szValueData, ULONG valueDataSize)
index 57cca52..1813a5c 100644 (file)
@@ -3,8 +3,9 @@
  *
  * Copyright 1995 Martin von Loewis
  * Copyright 1998 David Lee Lambert
- * Copyright 2000 Julio César Gázquez
+ * Copyright 2000 Julio César Gázquez
  * Copyright 2003 Jon Griffiths
+ * Copyright 2005 Dmitry Timoshkov
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,7 +19,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
 /*
 
 #include "wine/config.h"
 #include "wine/unicode.h"
-#define NDEBUG
-#include <debug.h>
+#include <wine/debug.h>
 
-#define TRACE DPRINT
-#define WARN DPRINT1
-#define ERR DPRINT1
-#define FIXME DPRINT1
+WINE_DEFAULT_DEBUG_CHANNEL(nls);
 
 #define DATE_DATEVARSONLY 0x0100  /* only date stuff: yMdg */
 #define TIME_TIMEVARSONLY 0x0200  /* only time stuff: hHmst */
@@ -52,7 +49,7 @@
  *
  * Our cache takes the form of a singly linked list, whose node is below:
  */
-#define NLS_NUM_CACHED_STRINGS 45
+#define NLS_NUM_CACHED_STRINGS 57
 
 typedef struct _NLS_FORMAT_NODE
 {
@@ -72,14 +69,15 @@ typedef struct _NLS_FORMAT_NODE
 #define GetLongDate(fmt)  fmt->lppszStrings[1]
 #define GetShortDate(fmt) fmt->lppszStrings[2]
 #define GetTime(fmt)      fmt->lppszStrings[3]
-#define GetAM(fmt)        fmt->lppszStrings[42]
-#define GetPM(fmt)        fmt->lppszStrings[43]
-#define GetYearMonth(fmt) fmt->lppszStrings[44]
+#define GetAM(fmt)        fmt->lppszStrings[54]
+#define GetPM(fmt)        fmt->lppszStrings[55]
+#define GetYearMonth(fmt) fmt->lppszStrings[56]
 
-#define GetLongDay(fmt,day)    fmt->lppszStrings[4 + day]
-#define GetShortDay(fmt,day)   fmt->lppszStrings[11 + day]
-#define GetLongMonth(fmt,mth)  fmt->lppszStrings[18 + mth]
-#define GetShortMonth(fmt,mth) fmt->lppszStrings[30 + mth]
+#define GetLongDay(fmt,day)       fmt->lppszStrings[4 + day]
+#define GetShortDay(fmt,day)      fmt->lppszStrings[11 + day]
+#define GetLongMonth(fmt,mth)     fmt->lppszStrings[18 + mth]
+#define GetGenitiveMonth(fmt,mth) fmt->lppszStrings[30 + mth]
+#define GetShortMonth(fmt,mth)    fmt->lppszStrings[42 + mth]
 
 /* Write access to the cache is protected by this critical section */
 static RTL_CRITICAL_SECTION NLS_FormatsCS;
@@ -92,53 +90,6 @@ static RTL_CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug =
 };
 static RTL_CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 };
 
-/**************************************************************************
- * NLS_isSystemLocale <internal>
- *
- * Return TRUE, if locale is system-type
- */
-BOOL NLS_isSystemLocale(LCID lcid)
-{
-    if(lcid == LOCALE_SYSTEM_DEFAULT ||
-       lcid == LOCALE_NEUTRAL ||
-       lcid == LOCALE_USER_DEFAULT)
-    {
-        return TRUE;
-    }
-    return FALSE;
-}
-
-/**************************************************************************
- * NLS_getDefaultLocale <internal>
- *
- * Return default system or user locale
- */
-LCID NLS_getDefaultLocale(LCID lcid)
-{
-    LCID lcidTmp;
-
-    DPRINT("Called NLS_getDefaultLocale(0x%04lx)\n", lcid);
-
-    switch(lcid)
-    {
-        case LOCALE_SYSTEM_DEFAULT:
-            NtQueryDefaultLocale(FALSE, &lcidTmp);
-            return lcidTmp;
-        break;
-
-        case LOCALE_USER_DEFAULT:
-        case LOCALE_NEUTRAL:
-            NtQueryDefaultLocale(TRUE, &lcidTmp);
-            return lcidTmp;
-        break;
-
-        default:
-            DPRINT1("FIXME: unknown system lcid\n");
-    }
-
-    return lcid;
-}
-
 /**************************************************************************
  * NLS_GetLocaleNumber <internal>
  *
@@ -184,10 +135,10 @@ static WCHAR* NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
 }
 
 #define GET_LOCALE_NUMBER(num, type) num = NLS_GetLocaleNumber(lcid, type|dwFlags); \
-  TRACE( #type ": %ld (%08lx)\n", (DWORD)num, (DWORD)num)
+  TRACE( #type ": %d (%08x)\n", (DWORD)num, (DWORD)num)
 
 #define GET_LOCALE_STRING(str, type) str = NLS_GetLocaleString(lcid, type|dwFlags); \
-  TRACE( #type ": '%S'\n", (str))
+  TRACE( #type ": %s\n", debugstr_w(str))
 
 /**************************************************************************
  * NLS_GetFormats <internal>
@@ -197,7 +148,7 @@ static WCHAR* NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
 static const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
 {
   /* GetLocaleInfo() identifiers for cached formatting strings */
-  static const USHORT NLS_LocaleIndices[] = {
+  static const LCTYPE NLS_LocaleIndices[] = {
     LOCALE_SNEGATIVESIGN,
     LOCALE_SLONGDATE,   LOCALE_SSHORTDATE,
     LOCALE_STIMEFORMAT,
@@ -210,6 +161,18 @@ static const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
     LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6,
     LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9,
     LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12,
+    LOCALE_SMONTHNAME1  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME2  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME3  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME4  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME5  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME6  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME7  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME8  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME9  | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME10 | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME11 | LOCALE_RETURN_GENITIVE_NAMES,
+    LOCALE_SMONTHNAME12 | LOCALE_RETURN_GENITIVE_NAMES,
     LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2, LOCALE_SABBREVMONTHNAME3,
     LOCALE_SABBREVMONTHNAME4, LOCALE_SABBREVMONTHNAME5, LOCALE_SABBREVMONTHNAME6,
     LOCALE_SABBREVMONTHNAME7, LOCALE_SABBREVMONTHNAME8, LOCALE_SABBREVMONTHNAME9,
@@ -222,7 +185,7 @@ static const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
 
   dwFlags &= LOCALE_NOUSEROVERRIDE;
 
-  TRACE("(0x%04lx,0x%08lx)\n", lcid, dwFlags);
+  TRACE("(0x%04x,0x%08x)\n", lcid, dwFlags);
 
   /* See if we have already cached the locales number format */
   while (node && (node->lcid != lcid || node->dwFlags != dwFlags) && node->next)
@@ -296,6 +259,16 @@ static const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
     {
       GET_LOCALE_STRING(new_node->lppszStrings[i], NLS_LocaleIndices[i]);
     }
+    /* Save some memory if month genitive name is the same or not present */
+    for (i = 0; i < 12; i++)
+    {
+      if (strcmpW(GetLongMonth(new_node, i), GetGenitiveMonth(new_node, i)) == 0)
+      {
+        HeapFree(GetProcessHeap(), 0, GetGenitiveMonth(new_node, i));
+        GetGenitiveMonth(new_node, i) = NULL;
+      }
+    }
+
     new_node->szShortAM[0] = GetAM(new_node)[0]; new_node->szShortAM[1] = '\0';
     new_node->szShortPM[0] = GetPM(new_node)[0]; new_node->szShortPM[1] = '\0';
 
@@ -360,7 +333,7 @@ BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
   case LANG_MARATHI:
   case LANG_PUNJABI:
   case LANG_SANSKRIT:
-    TRACE("lcid 0x%08lx: langid 0x%4x is Unicode Only\n", lcid, PRIMARYLANGID(lcid));
+    TRACE("lcid 0x%08x: langid 0x%4x is Unicode Only\n", lcid, PRIMARYLANGID(lcid));
     return TRUE;
   default:
     return FALSE;
@@ -399,14 +372,11 @@ static INT NLS_GetDateTimeFormatW(LCID lcid, DWORD dwFlags,
   INT cchWritten = 0;
   INT lastFormatPos = 0;
   BOOL bSkipping = FALSE; /* Skipping text around marker? */
+  BOOL d_dd_formatted = FALSE; /* previous formatted part was for d or dd */
 
   /* Verify our arguments */
   if ((cchOut && !lpStr) || !(node = NLS_GetFormats(lcid, dwFlags)))
-  {
-NLS_GetDateTimeFormatW_InvalidParameter:
-    SetLastError(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
+    goto invalid_parameter;
 
   if (dwFlags & ~(DATE_DATEVARSONLY|TIME_TIMEVARSONLY))
   {
@@ -414,15 +384,13 @@ NLS_GetDateTimeFormatW_InvalidParameter:
         ((dwFlags & DATE_DATEVARSONLY && dwFlags & ~DATE_FORMAT_FLAGS) ||
          (dwFlags & TIME_TIMEVARSONLY && dwFlags & ~TIME_FORMAT_FLAGS)))
     {
-NLS_GetDateTimeFormatW_InvalidFlags:
-      SetLastError(ERROR_INVALID_FLAGS);
-      return 0;
+      goto invalid_flags;
     }
 
     if (dwFlags & DATE_DATEVARSONLY)
     {
       if ((dwFlags & (DATE_LTRREADING|DATE_RTLREADING)) == (DATE_LTRREADING|DATE_RTLREADING))
-        goto NLS_GetDateTimeFormatW_InvalidFlags;
+        goto invalid_flags;
       else if (dwFlags & (DATE_LTRREADING|DATE_RTLREADING))
         FIXME("Unsupported flags: DATE_LTRREADING/DATE_RTLREADING\n");
 
@@ -434,10 +402,10 @@ NLS_GetDateTimeFormatW_InvalidFlags:
       case DATE_LONGDATE:
       case DATE_YEARMONTH:
         if (lpFormat)
-          goto NLS_GetDateTimeFormatW_InvalidFlags;
+          goto invalid_flags;
         break;
       default:
-        goto NLS_GetDateTimeFormatW_InvalidFlags;
+        goto invalid_flags;
       }
     }
   }
@@ -476,7 +444,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
       st.wDay = lpTime->wDay;
 
       if (st.wDay > 31 || st.wMonth > 12 || !SystemTimeToFileTime(&st, &ftTmp))
-        goto NLS_GetDateTimeFormatW_InvalidParameter;
+        goto invalid_parameter;
 
       FileTimeToSystemTime(&ftTmp, &st);
       lpTime = &st;
@@ -486,7 +454,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
     {
       /* Verify the time */
       if (lpTime->wHour > 24 || lpTime->wMinute > 59 || lpTime->wSecond > 59)
-        goto NLS_GetDateTimeFormatW_InvalidParameter;
+        goto invalid_parameter;
     }
   }
 
@@ -511,7 +479,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
         if (!cchOut)
           cchWritten++;   /* Count size only */
         else if (cchWritten >= cchOut)
-          goto NLS_GetDateTimeFormatW_Overrun;
+          goto overrun;
         else if (!bSkipping)
         {
           lpStr[cchWritten] = *lpFormat;
@@ -523,7 +491,6 @@ NLS_GetDateTimeFormatW_InvalidFlags:
     else if ((dwFlags & DATE_DATEVARSONLY && IsDateFmtChar(*lpFormat)) ||
              (dwFlags & TIME_TIMEVARSONLY && IsTimeFmtChar(*lpFormat)))
     {
-      char  buffA[32];
       WCHAR buff[32], fmtChar;
       LPCWSTR szAdd = NULL;
       DWORD dwVal = 0;
@@ -539,6 +506,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
       }
       buff[0] = '\0';
 
+      if (fmtChar != 'M') d_dd_formatted = FALSE;
       switch(fmtChar)
       {
       case 'd':
@@ -550,12 +518,59 @@ NLS_GetDateTimeFormatW_InvalidFlags:
         {
           dwVal = lpTime->wDay;
           szAdd = buff;
+          d_dd_formatted = TRUE;
         }
         break;
 
       case 'M':
         if (count >= 4)
+        {
+          LPCWSTR genitive = GetGenitiveMonth(node, lpTime->wMonth - 1);
+          if (genitive)
+          {
+            if (d_dd_formatted)
+            {
+              szAdd = genitive;
+              break;
+            }
+            else
+            {
+              LPCWSTR format = lpFormat;
+              /* Look forward now, if next format pattern is for day genitive
+                 name should be used */
+              while (*format)
+              {
+                /* Skip parts within markers */
+                if (IsLiteralMarker(*format))
+                {
+                  ++format;
+                  while (*format)
+                  {
+                    if (IsLiteralMarker(*format))
+                    {
+                      ++format;
+                      if (!IsLiteralMarker(*format)) break;
+                    }
+                  }
+                }
+                if (*format != ' ') break;
+                ++format;
+              }
+              /* Only numeric day form matters */
+              if (*format && *format == 'd')
+              {
+                INT dcount = 1;
+                while (*++format == 'd') dcount++;
+                if (dcount < 3)
+                {
+                  szAdd = genitive;
+                  break;
+                }
+              }
+            }
+          }
           szAdd = GetLongMonth(node, lpTime->wMonth - 1);
+        }
         else if (count == 3)
           szAdd = GetShortMonth(node, lpTime->wMonth - 1);
         else
@@ -657,9 +672,9 @@ NLS_GetDateTimeFormatW_InvalidFlags:
 
       if (szAdd == buff && buff[0] == '\0')
       {
+        static const WCHAR fmtW[] = {'%','.','*','d',0};
         /* We have a numeric value to add */
-        sprintf(buffA, "%.*ld", count, dwVal);
-        MultiByteToWideChar(CP_ACP, 0, buffA, -1, buff, sizeof(buff)/sizeof(WCHAR));
+        snprintfW(buff, sizeof(buff)/sizeof(WCHAR), fmtW, count, dwVal);
       }
 
       dwLen = szAdd ? strlenW(szAdd) : 0;
@@ -671,7 +686,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
         else
         {
           memcpy(lpStr + cchWritten, szAdd, (cchOut - cchWritten) * sizeof(WCHAR));
-          goto NLS_GetDateTimeFormatW_Overrun;
+          goto overrun;
         }
       }
       cchWritten += dwLen;
@@ -683,7 +698,7 @@ NLS_GetDateTimeFormatW_InvalidFlags:
       if (!cchOut)
         cchWritten++;   /* Count size only */
       else if (cchWritten >= cchOut)
-        goto NLS_GetDateTimeFormatW_Overrun;
+        goto overrun;
       else if (!bSkipping || *lpFormat == ' ')
       {
         lpStr[cchWritten] = *lpFormat;
@@ -697,19 +712,27 @@ NLS_GetDateTimeFormatW_InvalidFlags:
   if (cchOut)
   {
    if (cchWritten >= cchOut)
-     goto NLS_GetDateTimeFormatW_Overrun;
+     goto overrun;
    else
      lpStr[cchWritten] = '\0';
   }
   cchWritten++; /* Include terminating NUL */
 
-  TRACE("returning length=%d, ouput='%S'\n", cchWritten, lpStr);
+  TRACE("returning length=%d, ouput=%s\n", cchWritten, debugstr_w(lpStr));
   return cchWritten;
 
-NLS_GetDateTimeFormatW_Overrun:
+overrun:
   TRACE("returning 0, (ERROR_INSUFFICIENT_BUFFER)\n");
   SetLastError(ERROR_INSUFFICIENT_BUFFER);
   return 0;
+
+invalid_parameter:
+  SetLastError(ERROR_INVALID_PARAMETER);
+  return 0;
+
+invalid_flags:
+  SetLastError(ERROR_INVALID_FLAGS);
+  return 0;
 }
 
 /******************************************************************************
@@ -725,12 +748,11 @@ static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags,
   WCHAR szFormat[128], szOut[128];
   INT iRet;
 
-  TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
-        lpFormat, lpStr, cchOut);
+  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
+        debugstr_a(lpFormat), lpStr, cchOut);
 
   if (NLS_IsUnicodeOnlyLcid(lcid))
   {
-GetDateTimeFormatA_InvalidParameter:
     SetLastError(ERROR_INVALID_PARAMETER);
     return 0;
   }
@@ -739,7 +761,11 @@ GetDateTimeFormatA_InvalidParameter:
   {
     const NLS_FORMAT_NODE *node = NLS_GetFormats(lcid, dwFlags);
     if (!node)
-      goto GetDateTimeFormatA_InvalidParameter;
+    {
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return 0;
+    }
+
     cp = node->dwCodePage;
   }
 
@@ -810,8 +836,8 @@ GetDateTimeFormatA_InvalidParameter:
 INT WINAPI GetDateFormatA( LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
                            LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
 {
-  TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
-        lpFormat, lpDateStr, cchOut);
+  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
+        debugstr_a(lpFormat), lpDateStr, cchOut);
 
   return NLS_GetDateTimeFormatA(lcid, dwFlags | DATE_DATEVARSONLY, lpTime,
                                 lpFormat, lpDateStr, cchOut);
@@ -826,8 +852,8 @@ INT WINAPI GetDateFormatA( LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
 INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
                           LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
 {
-  TRACE("(0x%04lx,0x%08lx,%p,%S,%p,%d)\n", lcid, dwFlags, lpTime,
-        lpFormat, lpDateStr, cchOut);
+  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
+        debugstr_w(lpFormat), lpDateStr, cchOut);
 
   return NLS_GetDateTimeFormatW(lcid, dwFlags|DATE_DATEVARSONLY, lpTime,
                                 lpFormat, lpDateStr, cchOut);
@@ -877,8 +903,8 @@ INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
 INT WINAPI GetTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
                           LPCSTR lpFormat, LPSTR lpTimeStr, INT cchOut)
 {
-  TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
-        lpFormat, lpTimeStr, cchOut);
+  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
+        debugstr_a(lpFormat), lpTimeStr, cchOut);
 
   return NLS_GetDateTimeFormatA(lcid, dwFlags|TIME_TIMEVARSONLY, lpTime,
                                 lpFormat, lpTimeStr, cchOut);
@@ -892,8 +918,8 @@ INT WINAPI GetTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
 INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
                           LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
 {
-  TRACE("(0x%04lx,0x%08lx,%p,%S,%p,%d)\n",lcid, dwFlags, lpTime,
-        lpFormat, lpTimeStr, cchOut);
+  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
+        debugstr_w(lpFormat), lpTimeStr, cchOut);
 
   return NLS_GetDateTimeFormatW(lcid, dwFlags|TIME_TIMEVARSONLY, lpTime,
                                 lpFormat, lpTimeStr, cchOut);
@@ -936,12 +962,11 @@ INT WINAPI GetNumberFormatA(LCID lcid, DWORD dwFlags,
   const NUMBERFMTW *pfmt = NULL;
   INT iRet;
 
-  TRACE("(0x%04lx,0x%08lx,%s,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
+  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
         lpFormat, lpNumberStr, cchOut);
 
   if (NLS_IsUnicodeOnlyLcid(lcid))
   {
-GetNumberFormatA_InvalidParameter:
     SetLastError(ERROR_INVALID_PARAMETER);
     return 0;
   }
@@ -950,7 +975,11 @@ GetNumberFormatA_InvalidParameter:
   {
     const NLS_FORMAT_NODE *node = NLS_GetFormats(lcid, dwFlags);
     if (!node)
-      goto GetNumberFormatA_InvalidParameter;
+    {
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return 0;
+    }
+
     cp = node->dwCodePage;
   }
 
@@ -1013,28 +1042,16 @@ INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags,
   WCHAR szNegBuff[8];
   const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc;
   DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0;
-  DWORD dwLeadingZeros = 0;
   INT iRet;
 
-  TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
+  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
         lpFormat, lpNumberStr, cchOut);
 
-  if(NLS_isSystemLocale(lcid))
-  {
-      lcid = NLS_getDefaultLocale(lcid);
-  }
-  else if(!IsValidLocale(lcid, LCID_INSTALLED))
-  {
-      SetLastError(ERROR_INVALID_PARAMETER);
-      return 0;
-  }
-
   if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
+      !IsValidLocale(lcid, 0) ||
       (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
   {
-GetNumberFormatW_Error:
-    SetLastError(lpFormat && dwFlags ? ERROR_INVALID_FLAGS : ERROR_INVALID_PARAMETER);
-    return 0;
+    goto error;
   }
 
   if (!lpFormat)
@@ -1042,7 +1059,7 @@ GetNumberFormatW_Error:
     const NLS_FORMAT_NODE *node = NLS_GetFormats(lcid, dwFlags);
 
     if (!node)
-      goto GetNumberFormatW_Error;
+      goto error;
     lpFormat = &node->fmt;
     lpszNegStart = lpszNeg = GetNegative(node);
   }
@@ -1064,11 +1081,7 @@ GetNumberFormatW_Error:
   /* Check the number for validity */
   while (*szSrc)
   {
-    if (*szSrc == '0' && !(dwState & NF_DIGITS))
-    {
-      dwLeadingZeros++;
-    }
-    else if ((*szSrc >= '1' && *szSrc <= '9') || (*szSrc == '0' && (dwState & NF_DIGITS)))
+    if (*szSrc >= '0' && *szSrc <= '9')
     {
       dwState |= NF_DIGITS;
       if (dwState & NF_ISREAL)
@@ -1077,23 +1090,23 @@ GetNumberFormatW_Error:
     else if (*szSrc == '-')
     {
       if (dwState)
-        goto GetNumberFormatW_Error; /* '-' not first character */
+        goto error; /* '-' not first character */
       dwState |= NF_ISNEGATIVE;
     }
     else if (*szSrc == '.')
     {
       if (dwState & NF_ISREAL)
-        goto GetNumberFormatW_Error; /* More than one '.' */
+        goto error; /* More than one '.' */
       dwState |= NF_ISREAL;
     }
     else
-      goto GetNumberFormatW_Error; /* Invalid char */
+      goto error; /* Invalid char */
     szSrc++;
   }
   szSrc--; /* Point to last character */
 
   if (!(dwState & NF_DIGITS))
-    goto GetNumberFormatW_Error; /* No digits */
+    goto error; /* No digits */
 
   /* Add any trailing negative sign */
   if (dwState & NF_ISNEGATIVE)
@@ -1181,7 +1194,7 @@ GetNumberFormatW_Error:
   dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
 
   /* Write the remaining whole number digits, including grouping chars */
-  while (szSrc >= (lpszValue + dwLeadingZeros) && *szSrc >= '0' && *szSrc <= '9')
+  while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
   {
     if (dwState & NF_ROUND)
     {
@@ -1199,7 +1212,7 @@ GetNumberFormatW_Error:
 
     dwState |= NF_DIGITS_OUT;
     dwCurrentGroupCount++;
-    if (szSrc >= (lpszValue + dwLeadingZeros) && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
+    if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
     {
       LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
 
@@ -1251,6 +1264,10 @@ GetNumberFormatW_Error:
     }
   }
   return iRet;
+
+error:
+  SetLastError(lpFormat && dwFlags ? ERROR_INVALID_FLAGS : ERROR_INVALID_PARAMETER);
+  return 0;
 }
 
 /**************************************************************************
@@ -1290,12 +1307,11 @@ INT WINAPI GetCurrencyFormatA(LCID lcid, DWORD dwFlags,
   const CURRENCYFMTW *pfmt = NULL;
   INT iRet;
 
-  TRACE("(0x%04lx,0x%08lx,%s,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
+  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
         lpFormat, lpCurrencyStr, cchOut);
 
   if (NLS_IsUnicodeOnlyLcid(lcid))
   {
-GetCurrencyFormatA_InvalidParameter:
     SetLastError(ERROR_INVALID_PARAMETER);
     return 0;
   }
@@ -1304,7 +1320,11 @@ GetCurrencyFormatA_InvalidParameter:
   {
     const NLS_FORMAT_NODE *node = NLS_GetFormats(lcid, dwFlags);
     if (!node)
-      goto GetCurrencyFormatA_InvalidParameter;
+    {
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return 0;
+    }
+
     cp = node->dwCodePage;
   }
 
@@ -1395,32 +1415,16 @@ INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags,
   DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0, dwFmt;
   INT iRet;
 
-  DPRINT1("GetCurrencyFormatW(0x%04lx,0x%08lx,%S,%p,%p,%d)\n",
-          lcid,
-          dwFlags,
-          lpszValue,
-          lpFormat,
-          lpCurrencyStr,
-          cchOut);
-
-  if(NLS_isSystemLocale(lcid))
-  {
-    lcid = NLS_getDefaultLocale(lcid);
-  }
-  else if(!IsValidLocale(lcid, LCID_INSTALLED))
-  {
-    SetLastError(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
+  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
+        lpFormat, lpCurrencyStr, cchOut);
 
   if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
+      !IsValidLocale(lcid, 0) ||
       (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
       !lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
       lpFormat->PositiveOrder > 3)))
   {
-GetCurrencyFormatW_Error:
-    SetLastError(lpFormat && dwFlags ? ERROR_INVALID_FLAGS : ERROR_INVALID_PARAMETER);
-    return 0;
+    goto error;
   }
 
   if (!lpFormat)
@@ -1428,7 +1432,8 @@ GetCurrencyFormatW_Error:
     const NLS_FORMAT_NODE *node = NLS_GetFormats(lcid, dwFlags);
 
     if (!node)
-      goto GetCurrencyFormatW_Error;
+      goto error;
+
     lpFormat = &node->cyfmt;
     lpszNegStart = lpszNeg = GetNegative(node);
   }
@@ -1461,23 +1466,23 @@ GetCurrencyFormatW_Error:
     else if (*szSrc == '-')
     {
       if (dwState)
-        goto GetCurrencyFormatW_Error; /* '-' not first character */
+        goto error; /* '-' not first character */
       dwState |= NF_ISNEGATIVE;
     }
     else if (*szSrc == '.')
     {
       if (dwState & NF_ISREAL)
-        goto GetCurrencyFormatW_Error; /* More than one '.' */
+        goto error; /* More than one '.' */
       dwState |= NF_ISREAL;
     }
     else
-      goto GetCurrencyFormatW_Error; /* Invalid char */
+      goto error; /* Invalid char */
     szSrc++;
   }
   szSrc--; /* Point to last character */
 
   if (!(dwState & NF_DIGITS))
-    goto GetCurrencyFormatW_Error; /* No digits */
+    goto error; /* No digits */
 
   if (dwState & NF_ISNEGATIVE)
     dwFmt = NLS_NegCyFormats[lpFormat->NegativeOrder];
@@ -1652,6 +1657,10 @@ GetCurrencyFormatW_Error:
     }
   }
   return iRet;
+
+error:
+  SetLastError(lpFormat && dwFlags ? ERROR_INVALID_FLAGS : ERROR_INVALID_PARAMETER);
+  return 0;
 }
 
 /* FIXME: Everything below here needs to move somewhere else along with the
@@ -1659,41 +1668,133 @@ GetCurrencyFormatW_Error:
  *        alternate calendars is determined.
  */
 
+/**************************************************************************
+ *              EnumDateFormatsExA    (KERNEL32.@)
+ *
+ * FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
+ * LOCALE_NOUSEROVERRIDE here as well?
+ */
+BOOL WINAPI EnumDateFormatsExA(DATEFMT_ENUMPROCEXA proc, LCID lcid, DWORD flags)
+{
+    CALID cal_id;
+    char buf[256];
+
+    if (!proc)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (!GetLocaleInfoW(lcid, LOCALE_ICALENDARTYPE|LOCALE_RETURN_NUMBER, (LPWSTR)&cal_id, sizeof(cal_id)/sizeof(WCHAR)))
+        return FALSE;
+
+    switch (flags & ~LOCALE_USE_CP_ACP)
+    {
+    case 0:
+    case DATE_SHORTDATE:
+        if (GetLocaleInfoA(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    case DATE_LONGDATE:
+        if (GetLocaleInfoA(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    case DATE_YEARMONTH:
+        if (GetLocaleInfoA(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    default:
+        FIXME("Unknown date format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+    return TRUE;
+}
+
+/**************************************************************************
+ *              EnumDateFormatsExW    (KERNEL32.@)
+ */
+BOOL WINAPI EnumDateFormatsExW(DATEFMT_ENUMPROCEXW proc, LCID lcid, DWORD flags)
+{
+    CALID cal_id;
+    WCHAR buf[256];
+
+    if (!proc)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    if (!GetLocaleInfoW(lcid, LOCALE_ICALENDARTYPE|LOCALE_RETURN_NUMBER, (LPWSTR)&cal_id, sizeof(cal_id)/sizeof(WCHAR)))
+        return FALSE;
+
+    switch (flags & ~LOCALE_USE_CP_ACP)
+    {
+    case 0:
+    case DATE_SHORTDATE:
+        if (GetLocaleInfoW(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    case DATE_LONGDATE:
+        if (GetLocaleInfoW(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    case DATE_YEARMONTH:
+        if (GetLocaleInfoW(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf, cal_id);
+        break;
+
+    default:
+        FIXME("Unknown date format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+    return TRUE;
+}
+
 /**************************************************************************
  *              EnumDateFormatsA       (KERNEL32.@)
+ *
+ * FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
+ * LOCALE_NOUSEROVERRIDE here as well?
  */
-BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale,  DWORD dwFlags)
+BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 {
     char buf[256];
 
-    if (!lpDateFmtEnumProc)
+    if (!proc)
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
 
-    switch (dwFlags & ~LOCALE_USE_CP_ACP)
+    switch (flags & ~LOCALE_USE_CP_ACP)
     {
-        case 0:
-        case DATE_SHORTDATE:
-            if (GetLocaleInfoA(Locale, LOCALE_SSHORTDATE | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case 0:
+    case DATE_SHORTDATE:
+        if (GetLocaleInfoA(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        case DATE_LONGDATE:
-            if (GetLocaleInfoA(Locale, LOCALE_SLONGDATE | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case DATE_LONGDATE:
+        if (GetLocaleInfoA(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        case DATE_YEARMONTH:
-            if (GetLocaleInfoA(Locale, LOCALE_SYEARMONTH | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case DATE_YEARMONTH:
+        if (GetLocaleInfoA(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        default:
-            FIXME("Unknown date format (%d)\n", dwFlags);
-            SetLastError(ERROR_INVALID_PARAMETER);
-            return FALSE;
+    default:
+        FIXME("Unknown date format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
     }
     return TRUE;
 }
@@ -1701,180 +1802,99 @@ BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale,
 /**************************************************************************
  *              EnumDateFormatsW       (KERNEL32.@)
  */
-BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
+BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
 {
     WCHAR buf[256];
 
-    if (!lpDateFmtEnumProc)
+    if (!proc)
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
 
-    switch (dwFlags & ~LOCALE_USE_CP_ACP)
+    switch (flags & ~LOCALE_USE_CP_ACP)
     {
-        case 0:
-        case DATE_SHORTDATE:
-            if (GetLocaleInfoW(Locale, LOCALE_SSHORTDATE | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case 0:
+    case DATE_SHORTDATE:
+        if (GetLocaleInfoW(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        case DATE_LONGDATE:
-            if (GetLocaleInfoW(Locale, LOCALE_SLONGDATE | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case DATE_LONGDATE:
+        if (GetLocaleInfoW(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        case DATE_YEARMONTH:
-            if (GetLocaleInfoW(Locale, LOCALE_SYEARMONTH | (dwFlags & LOCALE_USE_CP_ACP), buf, 256))
-            lpDateFmtEnumProc(buf);
+    case DATE_YEARMONTH:
+        if (GetLocaleInfoW(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
         break;
 
-        default:
-            FIXME("Unknown date format (%d)\n", dwFlags);
-            SetLastError(ERROR_INVALID_PARAMETER);
-            return FALSE;
+    default:
+        FIXME("Unknown date format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
     }
     return TRUE;
 }
 
 /**************************************************************************
  *              EnumTimeFormatsA       (KERNEL32.@)
+ *
+ * FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
+ * LOCALE_NOUSEROVERRIDE here as well?
  */
-BOOL WINAPI EnumTimeFormatsA( TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags )
+BOOL WINAPI EnumTimeFormatsA(TIMEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 {
-  LCID Loc = GetUserDefaultLCID();
-  if(!lpTimeFmtEnumProc)
+    char buf[256];
+
+    if (!proc)
     {
-      SetLastError(ERROR_INVALID_PARAMETER);
-      return FALSE;
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
     }
-  if(dwFlags)
+
+    switch (flags & ~LOCALE_USE_CP_ACP)
     {
-      FIXME("Unknown time format (%ld)\n", dwFlags);
-    }
+    case 0:
+        if (GetLocaleInfoA(lcid, LOCALE_STIMEFORMAT | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
+        break;
 
-  switch( Loc )
- {
-   case 0x00000407:  /* (Loc,"de_DE") */
-   {
-    if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H.mm'Uhr'")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x0000040c:  /* (Loc,"fr_FR") */
-   case 0x00000c0c:  /* (Loc,"fr_CA") */
-   {
-    if(!(*lpTimeFmtEnumProc)("H:mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH'h'mm")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x00000809:  /* (Loc,"en_UK") */
-   case 0x00000c09:  /* (Loc,"en_AU") */
-   case 0x00001409:  /* (Loc,"en_NZ") */
-   case 0x00001809:  /* (Loc,"en_IE") */
-   {
-    if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x00001c09:  /* (Loc,"en_ZA") */
-   case 0x00002809:  /* (Loc,"en_BZ") */
-   case 0x00002c09:  /* (Loc,"en_TT") */
-   {
-    if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
-    return TRUE;
-   }
-
-   default:  /* default to US style "en_US" */
-   {
-    if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
+    default:
+        FIXME("Unknown time format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
     return TRUE;
-   }
- }
 }
 
 /**************************************************************************
  *              EnumTimeFormatsW       (KERNEL32.@)
  */
-BOOL WINAPI EnumTimeFormatsW( TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags )
+BOOL WINAPI EnumTimeFormatsW(TIMEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
 {
-  LCID Loc = GetUserDefaultLCID();
-  if(!lpTimeFmtEnumProc)
+    WCHAR buf[256];
+
+    if (!proc)
     {
-      SetLastError(ERROR_INVALID_PARAMETER);
-      return FALSE;
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
     }
-  if(dwFlags)
+
+    switch (flags & ~LOCALE_USE_CP_ACP)
     {
-      FIXME("Unknown time format (%ld)\n", dwFlags);
-    }
+    case 0:
+        if (GetLocaleInfoW(lcid, LOCALE_STIMEFORMAT | (flags & LOCALE_USE_CP_ACP), buf, 256))
+            proc(buf);
+        break;
 
-  switch( Loc )
- {
-   case 0x00000407:  /* (Loc,"de_DE") */
-   {
-    if(!(*lpTimeFmtEnumProc)(L"HH.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H.mm'Uhr'")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x0000040c:  /* (Loc,"fr_FR") */
-   case 0x00000c0c:  /* (Loc,"fr_CA") */
-   {
-    if(!(*lpTimeFmtEnumProc)(L"H:mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH.mm")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH'h'mm")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x00000809:  /* (Loc,"en_UK") */
-   case 0x00000c09:  /* (Loc,"en_AU") */
-   case 0x00001409:  /* (Loc,"en_NZ") */
-   case 0x00001809:  /* (Loc,"en_IE") */
-   {
-    if(!(*lpTimeFmtEnumProc)(L"h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H:mm:ss")) return TRUE;
-    return TRUE;
-   }
-
-   case 0x00001c09:  /* (Loc,"en_ZA") */
-   case 0x00002809:  /* (Loc,"en_BZ") */
-   case 0x00002c09:  /* (Loc,"en_TT") */
-   {
-    if(!(*lpTimeFmtEnumProc)(L"h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"hh:mm:ss tt")) return TRUE;
-    return TRUE;
-   }
-
-   default:  /* default to US style "en_US" */
-   {
-    if(!(*lpTimeFmtEnumProc)(L"h:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"hh:mm:ss tt")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"H:mm:ss")) return TRUE;
-    if(!(*lpTimeFmtEnumProc)(L"HH:mm:ss")) return TRUE;
+    default:
+        FIXME("Unknown time format (%d)\n", flags);
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
     return TRUE;
-   }
- }
 }
 
 /******************************************************************************
@@ -1940,7 +1960,7 @@ static BOOL NLS_EnumCalendarInfoAW(void *calinfoproc, LCID locale,
       if (opt == NULL)
       {
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-        goto NLS_EnumCalendarInfoAW_Cleanup;
+        goto cleanup;
       }
       if (GetLocaleInfoW(locale, LOCALE_IOPTIONALCALENDAR, opt, optSz))
         iter = opt;
@@ -1967,14 +1987,14 @@ static BOOL NLS_EnumCalendarInfoAW(void *calinfoproc, LCID locale,
           if (bufSz >= newSz)
           {
             ERR("Buffer resizing disorder: was %d, requested %d.\n", bufSz, newSz);
-            goto NLS_EnumCalendarInfoAW_Cleanup;
+            goto cleanup;
           }
           bufSz = newSz;
           WARN("Buffer too small; resizing to %d bytes.\n", bufSz);
           buf = HeapReAlloc(GetProcessHeap(), 0, buf, bufSz);
           if (buf == NULL)
-            goto NLS_EnumCalendarInfoAW_Cleanup;
-        } else goto NLS_EnumCalendarInfoAW_Cleanup;
+            goto cleanup;
+        } else goto cleanup;
       }
     } while (!ret);
 
@@ -2008,7 +2028,7 @@ static BOOL NLS_EnumCalendarInfoAW(void *calinfoproc, LCID locale,
     }
   }
 
-NLS_EnumCalendarInfoAW_Cleanup:
+cleanup:
   HeapFree(GetProcessHeap(), 0, opt);
   HeapFree(GetProcessHeap(), 0, buf);
   return ret;
@@ -2016,12 +2036,14 @@ NLS_EnumCalendarInfoAW_Cleanup:
 
 /******************************************************************************
  *             EnumCalendarInfoA       [KERNEL32.@]
+ *
+ * See EnumCalendarInfoAW.
  */
 BOOL WINAPI EnumCalendarInfoA( CALINFO_ENUMPROCA calinfoproc,LCID locale,
                                CALID calendar,CALTYPE caltype )
 {
-    FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);
-    return NLS_EnumCalendarInfoAW(calinfoproc, locale, calendar, caltype, FALSE, FALSE);
+  TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
+  return NLS_EnumCalendarInfoAW(calinfoproc, locale, calendar, caltype, FALSE, FALSE);
 }
 
 /******************************************************************************
index bc3ea24..41883ac 100644 (file)
@@ -171,25 +171,40 @@ static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large)
          goto fail;
        }
 
-       /* Copy the source xor bitmap to the target and clear out part of it by using
-          the shortcut mask */
+       /* Copy the source color bitmap to the target */
        if (! BitBlt(TargetDC, 0, 0, SourceBitmapInfo.bmWidth, SourceBitmapInfo.bmHeight,
-                    SourceDC, 0, 0, SRCCOPY) ||
-           ! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
-                    ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                    ShortcutDC, 0, 0, SRCAND))
+                    SourceDC, 0, 0, SRCCOPY)) goto fail;
+
+       /* Check if we can use alpha blending */
+       if (ShortcutBitmapInfo.bmBitsPixel == 32)
        {
-         goto fail;
+               /* Use alpha blending to make sure the target alpha channel stays valid */
+               if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
+               if (!GdiAlphaBlend(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
+                               ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
+                               ShortcutDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
+                               (BLENDFUNCTION){AC_SRC_OVER, 0, 255, AC_SRC_ALPHA})) goto fail;
        }
-
-       if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
-
-       /* Now put in the shortcut xor mask */
-       if (! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
-                    ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                    ShortcutDC, 0, 0, SRCINVERT))
+       else
        {
-         goto fail;
+               /* Copy the source xor bitmap to the target and clear out part of it by using
+                  the shortcut mask */
+               if (! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
+                            ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
+                        ShortcutDC, 0, 0, SRCAND))
+               {
+                       goto fail;
+               }
+
+               if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
+
+               /* Now put in the shortcut xor mask */
+               if (! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
+                            ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
+                        ShortcutDC, 0, 0, SRCINVERT))
+               {
+                       goto fail;
+               }
        }
 
        /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set
@@ -387,14 +402,14 @@ BOOL SIC_Initialize(void)
     if (sic_hdpa)
     {
         TRACE("Icon cache already initialized\n");
-        return TRUE;
+         return TRUE;
     }
 
-    sic_hdpa = DPA_Create(16);
-    if (!sic_hdpa)
-    {
+       sic_hdpa = DPA_Create(16);
+       if (!sic_hdpa)
+       {
         return FALSE;
-    }
+       }
 
     hDC = CreateICW(L"DISPLAY", NULL, NULL, NULL);
     if (!hDC)
@@ -439,7 +454,7 @@ BOOL SIC_Initialize(void)
                                         100);
     if (ShellSmallIconList)
     {
-         /* Load the document icon, which is used as the default if an icon isn't found. */
+        /* Load the document icon, which is used as the default if an icon isn't found. */
         hSm = (HICON)LoadImageW(shell32_hInstance,
                                 MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT),
                                 IMAGE_ICON,
@@ -459,7 +474,7 @@ BOOL SIC_Initialize(void)
     }
 
     if (ShellBigIconList)
-    {
+        {
         hLg = (HICON)LoadImageW(shell32_hInstance,
                                 MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT),
                                 IMAGE_ICON,
@@ -470,7 +485,7 @@ BOOL SIC_Initialize(void)
         {
             ERR("Failed to load IDI_SHELL_DOCUMENT icon2!\n");
             DestroyIcon(hSm);
-            return FALSE;
+          return FALSE;
         }
     }
     else
@@ -482,9 +497,9 @@ BOOL SIC_Initialize(void)
     SIC_IconAppend(swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0);
     SIC_IconAppend(swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0);
 
-    TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
+       TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
 
-    return TRUE;
+       return TRUE;
 }
 /*************************************************************************
  * SIC_Destroy
@@ -550,7 +565,7 @@ static int SIC_LoadOverlayIcon(int icon_idx)
                LPWSTR p = wcschr(buffer, ',');
 
                if (p)
-                   *p++ = 0;
+               *p++ = 0;
 
                iconPath = buffer;
                iconIdx = _wtoi(p);
index 04e5b4b..b98c628 100644 (file)
@@ -1172,11 +1172,11 @@ getservbyname(IN  CONST CHAR FAR* name,
     PCHAR SystemDirectory = ServiceDBData; /* Reuse this stack space */
     PCHAR ServicesFileLocation = "\\drivers\\etc\\services";
     PCHAR ThisLine = 0, NextLine = 0, ServiceName = 0, PortNumberStr = 0,
-    ProtocolStr = 0, Comment = 0;
+    ProtocolStr = 0, Comment = 0, EndValid;
     PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS] = { 0 };
     UINT i,SizeNeeded = 0,
     SystemDirSize = sizeof(ServiceDBData) - 1;
-    DWORD ReadSize = 0, ValidData = 0;
+    DWORD ReadSize = 0;
     PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
 
     if( !p )
@@ -1215,43 +1215,56 @@ getservbyname(IN  CONST CHAR FAR* name,
         WSASetLastError( WSANO_RECOVERY );
         return NULL;
     }
-
+    
     /* Scan the services file ...
-     *
-     * We will read up to BUFSIZ bytes per pass, until the buffer does not
-     * contain a full line, then we will try to read more.
-     *
-     * We fall from the loop if the buffer does not have a line terminator.
-     */
-
+    *
+    * We will be share the buffer on the lines. If the line does not fit in
+    * the buffer, then moving it to the beginning of the buffer and read
+    * the remnants of line from file.
+    */
+    
     /* Initial Read */
-    while(!Found &&
-          ReadFile(ServicesFile,
-                   ServiceDBData + ValidData,
-                   sizeof( ServiceDBData ) - ValidData,
-                   &ReadSize,
-                   NULL))
+    ReadFile(ServicesFile,
+                   ServiceDBData,
+                   sizeof( ServiceDBData ) - 1,
+                   &ReadSize, NULL );
+    ThisLine = NextLine = ServiceDBData;
+    EndValid = ServiceDBData + ReadSize;
+    ServiceDBData[sizeof(ServiceDBData) - 1] = '\0';
+    
+    while(ReadSize)
     {
-        ValidData += ReadSize;
-        ReadSize = 0;
-        NextLine = ThisLine = ServiceDBData;
-
-        /* Find the beginning of the next line */
-        while(NextLine < ServiceDBData + ValidData &&
-              *NextLine != '\r' && *NextLine != '\n' )
+        for(; *NextLine != '\r' && *NextLine != '\n'; NextLine++)
         {
-            NextLine++;
-        }
-
-        /* Zero and skip, so we can treat what we have as a string */
-        if( NextLine > ServiceDBData + ValidData )
-            break;
-
-        *NextLine = 0; NextLine++;
+            if(NextLine == EndValid)
+            {
+                int LineLen = NextLine - ThisLine;
+                
+                if(ThisLine == ServiceDBData)
+                {
+                    WS_DbgPrint(MIN_TRACE,("Line too long"));
+                    WSASetLastError( WSANO_RECOVERY );
+                    return NULL;
+                }
 
+                memmove(ServiceDBData, ThisLine, LineLen);
+           
+                ReadFile(ServicesFile, ServiceDBData + LineLen,
+                         sizeof( ServiceDBData )-1 - LineLen,
+                         &ReadSize, NULL );
+                               
+                EndValid = ServiceDBData + LineLen + ReadSize;
+                NextLine = ServiceDBData + LineLen;
+                ThisLine = ServiceDBData;
+                
+                if(!ReadSize) break;
+            }
+        }
+        
+        *NextLine = '\0';
         Comment = strchr( ThisLine, '#' );
-        if( Comment ) *Comment = 0; /* Terminate at comment start */
-
+        if( Comment ) *Comment = '\0'; /* Terminate at comment start */
+        
         if(DecodeServEntFromString(ThisLine,
                                    &ServiceName,
                                    &PortNumberStr,
@@ -1268,22 +1281,8 @@ getservbyname(IN  CONST CHAR FAR* name,
                 (NextLine - ThisLine);
             break;
         }
-
-        /* Get rid of everything we read so far */
-        while( NextLine <= ServiceDBData + ValidData &&
-               isspace( *NextLine ) )
-        {
-            NextLine++;
-        }
-
-        WS_DbgPrint(MAX_TRACE,("About to move %d chars\n",
-                    ServiceDBData + ValidData - NextLine));
-
-        memmove(ServiceDBData,
-                NextLine,
-                ServiceDBData + ValidData - NextLine );
-        ValidData -= NextLine - ServiceDBData;
-        WS_DbgPrint(MAX_TRACE,("Valid bytes: %d\n", ValidData));
+        NextLine++;
+        ThisLine = NextLine;
     }
 
     /* This we'll do no matter what */
index a9d4b25..07b6dc0 100644 (file)
@@ -522,7 +522,7 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
                        return(STATUS_OBJECT_NAME_INVALID);
                }
        }
-        if (FileObject->RelatedFileObject && PathNameU.Length > sizeof(WCHAR) && PathNameU.Buffer[0] == L'\\')
+        if (FileObject->RelatedFileObject && PathNameU.Length >= sizeof(WCHAR) && PathNameU.Buffer[0] == L'\\')
         {
             return(STATUS_OBJECT_NAME_INVALID);
         }
index cfef258..38c6940 100644 (file)
@@ -5,15 +5,68 @@
 #include <stdlib.h>
 #include <signal.h>
 
+static const char formatstr[] = 
+    "Assertion failed!\n\n"
+    "Program: %s\n"
+    "File: %s\n"
+    "Line: %ld\n\n"
+    "Expression: %s\n"
+    "Press Retry to debug the application\n";
+
 
 /*
  * @implemented
  */
-void _assert(const char *msg, const char *file, unsigned line)
+void _assert(const char *exp, const char *file, unsigned line)
 {
-  /* Assertion failed at foo.c line 45: x<y */
-  fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, msg);
-  FIXME("Assertion failed at %s line %d: %s\n", file, line, msg);
-  raise(SIGABRT);
-  for(;;); /* eliminate warning by mingw */
+    int (WINAPI *pMessageBoxA)(HWND, LPCTSTR, LPCTSTR, UINT);
+    HMODULE hmodUser32;
+    char achProgram[40];
+    char *pszBuffer;
+    int len;
+    int iResult;
+
+    /* Assertion failed at foo.c line 45: x<y */
+    fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, exp);
+    FIXME("Assertion failed at %s line %d: %s\n", file, line, exp);
+
+    /* Get MessageBoxA function pointer */
+    hmodUser32 = LoadLibrary("user32.dll");
+    pMessageBoxA = GetProcAddress(hmodUser32, "MessageBoxA");
+    if (!pMessageBoxA)
+    {
+        abort();
+    }
+
+    /* Get the file name of the module */
+    len = GetModuleFileNameA(NULL, achProgram, 40);
+    
+    /* Calculate full length of the message */
+    len += sizeof(formatstr) + len + strlen(exp) + strlen(file);
+
+    /* Allocate a buffer */
+    pszBuffer = malloc(len + 1);
+
+    /* Format a message */
+    _snprintf(pszBuffer, len, formatstr, achProgram, file, line, exp);
+
+    /* Display a message box */
+    iResult = pMessageBoxA(NULL, 
+                          pszBuffer, 
+                          "ReactOS C Runtime Library",
+                          MB_ABORTRETRYIGNORE | MB_ICONERROR);
+
+    free(pszBuffer);
+
+    /* Does the user want to abort? */
+    if (iResult == IDABORT)
+    {
+        abort();
+    }
+
+    /* Does the user want to debug? */
+    if (iResult == IDRETRY)
+    {
+        __debugbreak();
+    }
 }
index 686fd0c..62f4d2e 100644 (file)
@@ -218,7 +218,7 @@ gdi32 -
 kernel32 -
   reactos/dll/win32/kernel32/misc/errormsg.c    # Out of sync
   reactos/dll/win32/kernel32/misc/profile.c     # Out of sync
-  reactos/dll/win32/kernel32/misc/lcformat.c    # Out of sync
+  reactos/dll/win32/kernel32/misc/lcformat.c    # Synced to Wine-1_3
   reactos/dll/win32/kernel32/misc/lzexpand.c    # Synced to Wine-1_1_23
 
 msvcrt -
index 881a667..1405b9f 100644 (file)
@@ -28,59 +28,58 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
 
     while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR))
     {
-               if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) ||
-                       (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) ||
-                       (Expression->Buffer[k] == DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0')))
-               {
-                       i++;
-                       k++;
-               }
-               else if (Expression->Buffer[k] == L'*')
-               {
-                       if (k < Expression->Length / sizeof(WCHAR))
-                       {
-                               if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' &&
+      if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) ||
+          (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) ||
+          (Expression->Buffer[k] == DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0')))
+      {
+        i++;
+        k++;
+      }
+      else if (Expression->Buffer[k] == L'*')
+      {
+        if (k < (Expression->Length / sizeof(WCHAR) - 1))
+        {
+          if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' &&
               Expression->Buffer[k+1] != DOS_DOT && Expression->Buffer[k+1] != DOS_QM &&
-                                       Expression->Buffer[k+1] != DOS_STAR)
-                               {
-                                       while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] &&
-                                                  i <= Name->Length / sizeof(WCHAR)) i++;
-                               }
-                               else
-                               {
-                                       if (!(Expression->Buffer[k+1] != DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0')))
-                                       {
-                                               i++;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               i = Name->Length / sizeof(WCHAR);
-                       }
-                       k++;
-               }
-               else if (Expression->Buffer[k] == DOS_STAR)
-               {
-                       j = i;
-                       while (j <= Name->Length / sizeof(WCHAR))
-                       {
-                               if (Name->Buffer[j] == L'.')
-                               {
-                                       i = j;
-                               }
-                               j++;
-                       }
-                       k++;
-               }
-               else
-               {
-                       i++;
-                       k = 0;
-               }
+              Expression->Buffer[k+1] != DOS_STAR)
+          {
+            while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] &&
+                   i < Name->Length / sizeof(WCHAR)) i++;
+          }
+          else
+          {
+            if (!(Expression->Buffer[k+1] != DOS_DOT && (Name->Buffer[i] == L'.' || Name->Buffer[i] == L'0')))
+            {
+              i++;
+            }
+          }
+        }
+        else
+        {
+          i = Name->Length / sizeof(WCHAR);
+        }
+        k++;
+      }
+      else if (Expression->Buffer[k] == DOS_STAR)
+      {
+        j = i;
+        while (j < Name->Length / sizeof(WCHAR))
+        {
+          if (Name->Buffer[j] == L'.')
+          {
+            i = j;
+          }
+          j++;
+        }
+        k++;
+      }
+      else
+      {
+        i = Name->Length / sizeof(WCHAR);
+      }
     }
 
-    return (k == Expression->Length / sizeof(WCHAR));
+    return (k == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR));
 }
 
 /* PUBLIC FUNCTIONS **********************************************************/
index 492d4a1..9c01544 100644 (file)
@@ -98,7 +98,7 @@ IopRemovePlugPlayEvent(VOID)
     /* Remove a pnp event entry from the tail of the queue */
     if (!IsListEmpty(&IopPnpEventQueueHead))
     {
-        ExFreePool(RemoveTailList(&IopPnpEventQueueHead));
+        ExFreePool(CONTAINING_RECORD(RemoveTailList(&IopPnpEventQueueHead), PNP_EVENT_ENTRY, ListEntry));
     }
 
     /* Signal the next pnp event in the queue */
index 90ed314..0dc9ac0 100644 (file)
@@ -65,10 +65,10 @@ EXLATEOBJ_iXlateRGBtoBGR(PEXLATEOBJ pxlo, ULONG iColor)
     ULONG iNewColor;
 
     /* Copy green */
-    iNewColor = iColor & 0x00ff00;
+    iNewColor = iColor & 0xff00ff00;
 
     /* Mask red and blue */
-    iColor &= 0xff00ff;
+    iColor &= 0x00ff00ff;
 
     /* Shift and copy red and blue */
     iNewColor |= iColor >> 16;
index 8c76484..a9a0577 100644 (file)
@@ -96,7 +96,7 @@ INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristi
 ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL);
 INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI,UINT,OUTLINETEXTMETRICW *);
 BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS);
-BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,int,int,LPINT,LPINT,LPSIZE);
+BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,INT,ULONG,LPINT,LPINT,LPSIZE);
 BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL);
 DWORD FASTCALL IntGetFontLanguageInfo(PDC);
 INT FASTCALL ftGdiGetTextCharsetInfo(PDC,PFONTSIGNATURE,DWORD);
index a40a5be..6a50d55 100644 (file)
@@ -5,7 +5,7 @@ NTSTATUS _MmCopyFromCaller( PVOID Target, PVOID Source, UINT Bytes ) {
 
     _SEH2_TRY
     {
-        /* ProbeForRead(Source,Bytes,1); */
+        ProbeForRead(Source,Bytes,1);
         RtlCopyMemory(Target,Source,Bytes);
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
index eb4db06..0bcbaf2 100644 (file)
@@ -267,7 +267,16 @@ co_IntLoadSysMenuTemplate()
    if (NT_SUCCESS(Status))
    {
       /* Simulate old behaviour: copy into our local buffer */
-      Result = *(LRESULT*)ResultPointer;
+      _SEH2_TRY
+      {
+        ProbeForRead(ResultPointer, sizeof(LRESULT), 1);
+        Result = *(LRESULT*)ResultPointer;
+      }
+      _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+      {
+        Result = 0;
+      }
+      _SEH2_END
    }
 
    UserEnterCo();
index c567b92..20ad506 100644 (file)
@@ -2119,8 +2119,8 @@ FASTCALL
 TextIntGetTextExtentPoint(PDC dc,
                           PTEXTOBJ TextObj,
                           LPCWSTR String,
-                          int Count,
-                          int MaxExtent,
+                          INT Count,
+                          ULONG MaxExtent,
                           LPINT Fit,
                           LPINT Dx,
                           LPSIZE Size)