João Diogo Ferreira : kernel32: Handle GEOCLASS_ALL in EnumSystemGeoID().

Alexandre Julliard julliard at winehq.org
Tue Nov 19 16:35:22 CST 2019


Module: wine
Branch: master
Commit: 2a03c0958b1d15e7684b9437e67bf327098bcfde
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2a03c0958b1d15e7684b9437e67bf327098bcfde

Author: João Diogo Ferreira <devilj at outlook.pt>
Date:   Mon Nov 18 02:27:24 2019 +0000

kernel32: Handle GEOCLASS_ALL in EnumSystemGeoID().

Signed-off-by: João Diogo Craveiro Ferreira <devilj at outlook.pt>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/locale.c       | 25 +++++++++++++++++++------
 dlls/kernel32/tests/locale.c | 13 +++++++++++++
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index e5e32d3cb5..b2a5831a9e 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -4247,16 +4247,28 @@ INT WINAPI GetGeoInfoA(GEOID geoid, GEOTYPE geotype, LPSTR data, int data_len, L
 /******************************************************************************
  *           EnumSystemGeoID    (KERNEL32.@)
  *
- * Call a users function for every location available on the system.
+ * Calls a user's function for every location available on the system.
  *
  * PARAMS
- *  geoclass   [I] Type of information desired (SYSGEOTYPE enum from "winnls.h")
- *  parent     [I] GEOID for the parent
- *  enumproc   [I] Callback function to call for each location
+ *  geoclass   [I] Type of location desired (SYSGEOTYPE enum from "winnls.h")
+ *  parent     [I] GeoID for the parent
+ *  enumproc   [I] Callback function to call for each location (prototype in "winnls.h")
  *
  * RETURNS
  *  Success: TRUE.
  *  Failure: FALSE. Use GetLastError() to determine the cause.
+ *
+ * NOTES
+ *  The enumproc function returns TRUE to continue enumerating
+ *  or FALSE to interrupt the enumeration.
+ *
+ *  On failure, GetLastError() returns one of the following values:
+ *   - ERROR_INVALID_PARAMETER: no callback function was provided.
+ *   - ERROR_INVALID_FLAGS: the location type was invalid.
+ *
+ * TODO
+ *  On Windows 10, this function filters out those locations which
+ *  simultaneously lack ISO and UN codes (e.g. Johnson Atoll).
  */
 BOOL WINAPI EnumSystemGeoID(GEOCLASS geoclass, GEOID parent, GEO_ENUMPROC enumproc)
 {
@@ -4269,7 +4281,7 @@ BOOL WINAPI EnumSystemGeoID(GEOCLASS geoclass, GEOID parent, GEO_ENUMPROC enumpr
         return FALSE;
     }
 
-    if (geoclass != GEOCLASS_NATION && geoclass != GEOCLASS_REGION) {
+    if (geoclass != GEOCLASS_NATION && geoclass != GEOCLASS_REGION && geoclass != GEOCLASS_ALL) {
         SetLastError(ERROR_INVALID_FLAGS);
         return FALSE;
     }
@@ -4277,9 +4289,10 @@ BOOL WINAPI EnumSystemGeoID(GEOCLASS geoclass, GEOID parent, GEO_ENUMPROC enumpr
     for (i = 0; i < ARRAY_SIZE(geoinfodata); i++) {
         const struct geoinfo_t *ptr = &geoinfodata[i];
 
-        if (geoclass == GEOCLASS_NATION && (ptr->kind == LOCATION_REGION))
+        if (geoclass == GEOCLASS_NATION && (ptr->kind != LOCATION_NATION))
             continue;
 
+        /* LOCATION_BOTH counts as region. */
         if (geoclass == GEOCLASS_REGION && (ptr->kind == LOCATION_NATION))
             continue;
 
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index aaaf09cf5c..45cb11d254 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -4981,6 +4981,19 @@ static void test_EnumSystemGeoID(void)
         ret = pEnumSystemGeoID(GEOCLASS_REGION, 0, test_geoid_enumproc2);
         ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count);
     }
+
+    geoidenum_count = 0;
+    ret = pEnumSystemGeoID(GEOCLASS_ALL, 39070, test_geoid_enumproc2);
+    if (ret == 0)
+        win_skip("GEOCLASS_ALL is not supported in EnumSystemGeoID.\n");
+    else
+    {
+        ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count);
+
+        geoidenum_count = 0;
+        ret = pEnumSystemGeoID(GEOCLASS_ALL, 0, test_geoid_enumproc2);
+        ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count);
+    }
 }
 
 struct invariant_entry {




More information about the wine-cvs mailing list