[PATCH] kernel32: Handle GEOCLASS_ALL in EnumSystemGeoID().

João Diogo Ferreira devilj at outlook.pt
Sun Nov 17 20:27:24 CST 2019


Signed-off-by: João Diogo Craveiro Ferreira <devilj at outlook.pt>
---
 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 0f91728e84..db8bd8c883 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -4206,16 +4206,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)
 {
@@ -4228,7 +4240,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;
     }
@@ -4236,9 +4248,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 81e74531ea..458cd0b5ef 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -4891,6 +4891,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 {
-- 
2.24.0



More information about the wine-devel mailing list