37 tok/s from Qwen3-Next-80B (48 GB) on a 32 GB laptop, 24 without drafts vs 2.8 for llama.cpp; reading 62 vs 16 tok/s. Faster than llama.cpp on all 13 models compared in Q4_K_M. LLMs bigger than your RAM, pure C, CPU or GPU.
C avx2ccpu-inferenceggufinference-enginelinuxllmlocal-llmmixture-of-expertsmoenvmequantizationqwen3simdspeculative-decodingvulkan
Release 2026-10-08 (2): the weather of a region, cities by their Italian names, each model's own layout translations
camauribfb1d2614d09
diff --git a/ChangeLog.md b/ChangeLog.mdindex 918b485..4f7719e 100644--- a/ChangeLog.md+++ b/ChangeLog.md@@ -2,6 +2,15 @@> Curated, user-facing summary of completed work, newest first.+## [2026-10-08] - Cities by their Italian names; each model's own layouts++- **Roma, Torino, Londra, Parigi are cities to the flights and weather services.** The tables name cities in English, and an Italian name went astray: "Roma" was the airport of Roma in Queensland (0 aircraft within 50 km of it, for a question about Rome), Torino, Londra and Parigi nothing at all. The Italian names of the cities most asked for, Italy's and abroad, now lead to theirs, each in its country (Siracusa stays in Sicily); an airport found by a city's name has to be within 100 km of the largest city so called ("Florence" is Peretola, not Florence Regional in South Carolina). Asked again: Roma, 17 aircraft within 50 km of Ciampino. `test_geo` checks them.+- **Each model translates the services' layouts for itself, and is not asked again after it failed.** A layout (the text a service's answer is shown in) was translated once and kept for every model, so Qwen3.5-0.8B's poor translation ("misurato dal punto") came with every other model's answers once it had written it first; and a translation that failed was asked for again at the next question, two or three minutes a reply for Qwen3-4B. Now the file carries the model's name, and a failure is kept beside it: Qwen3-4B 291 s for its first weather question, 42 s for the next. Layouts translated before are translated again, once, by each model.++## [2026-10-08] - The weather of a region++- **A region is a place the weather service knows.** Asked for "Liguria", the geocoding it uses has no such place, only a peak of that name in Antarctica, and that is what it took: -26 °C in Liguria, found by Qwen3-0.6B asking for Liguria's warnings. A region is now taken as its largest city with the region kept for the warnings (Liguria: Genova, and MeteoAlarm's warnings for Liguria): an Italian one by its Italian or English name before the geocoding (so "Molise" is Campobasso, not the hamlet of 150 people called so), any other only where the geocoding knows no town of that name ("Washington" stays the capital). Of the geocoding's answers, a place people live in now always comes before a peak, a range or a lake, and anything in Antarctica after everything else. `test_geo` checks the regions.+## [2026-10-08] - Every model's fast profile, measured- **Every lever that trades a little accuracy for speed was tried on every model of the catalog, alone and in every combination**: `--head 4`, `--attention fast`, and `--bits 4` where the experts are in planes. A lever is in a model's `fast` profile when it adds 2% or more: Qwen3-0.6B `--head 4 --attention fast` (+14.3%), Qwen3-4B the same (+6.8%), Qwen3.5-0.8B `--attention fast` (+2.0%), Qwen3.5-2B and 9B `--head 4` (+10.2%, +5.1%), Qwen3-30B-A3B all three (+10.0%), Qwen3.6-35B-A3B, Qwen3-Next-80B-A3B and Qwen3-Coder-Next `--head 4 --bits 4` (+6.5%, +8.6%, +10.5%). The agreement with llama.cpp of each is in the README. Gemma 4 has none: sixteen-bit keys, heads not six-bit, experts not in planes. Oracles of llama.cpp for the four Gemma 4 models were made for it (micro-batches of 8).diff --git a/src/chat/layout.c b/src/chat/layout.cindex 005533c..56ba057 100644--- a/src/chat/layout.c+++ b/src/chat/layout.c@@ -20,6 +20,7 @@#define META "dev.prabanta.janas/layout"static char lang[16] = "en";+static char model[128] = "";static int (*translator)(const char *, const char *, const char *, char **);void layout_set_lang(const char *l)@@ -27,6 +28,11 @@ void layout_set_lang(const char *l)snprintf(lang, sizeof lang, "%s", l && *l ? l : "en");}+void layout_set_model(const char *key)+{+ snprintf(model, sizeof model, "%s", key ? key : "");+}+const char *layout_lang(void){return lang;@@ -406,14 +412,27 @@ static char *translated(const char *name, const char *en)char dir[1024], path[1200];if (dir_of(dir, sizeof dir) != 0)return NULL;- snprintf(path, sizeof path, "%s/%s.%s.%016llx.txt", dir, name, lang,- (unsigned long long)glossary_mark(lang, name, mark(en)));+ /* the model's own: Qwen3.5-0.8B's "misurato dal punto" was shown with+ every model's answers once it had written it first (8 Oct 2026) */+ unsigned long long mk = glossary_mark(lang, name, mark(en));+ char failed[1200];+ snprintf(path, sizeof path, "%s/%s.%s.%s%s%016llx.txt", dir, name, lang,+ model, model[0] ? "." : "", mk);+ snprintf(failed, sizeof failed, "%s/%s.%s.%s%s%016llx.fail", dir, name,+ lang, model, model[0] ? "." : "", mk);char *have = read_file(path);char why[200];if (have && janas_tpl_same_shape(en, strlen(en), have, strlen(have), why,sizeof why))return have;free(have);+ /* failed before with this model and this layout: English, at once -+ asking again cost Qwen3-4B two or three minutes a reply */+ FILE *ff = fopen(failed, "rb");+ if (ff) {+ fclose(ff);+ return NULL;+ }struct coded c;if (!translator || encode(en, &c) != 0)return NULL;@@ -467,8 +486,13 @@ static char *translated(const char *name, const char *en)if (!out) {fprintf(stderr,"janas-chat: the layout %s in %s is not usable (%s): "- "English is used\n",+ "English is used, and this model is not asked again\n",name, lang, why);+ FILE *f = fopen(failed, "wb");+ if (f) {+ fprintf(f, "%s\n", why);+ fclose(f);+ }return NULL;}FILE *f = fopen(path, "wb");diff --git a/src/chat/layout.h b/src/chat/layout.hindex 61c80b6..e8e5ae9 100644--- a/src/chat/layout.h+++ b/src/chat/layout.h@@ -16,6 +16,10 @@/* The user's language ("it"; "en" or NULL: English, no translation). */void layout_set_lang(const char *lang);+/* The model the layouts are translated by: each model keeps its own, and+ its failures, so that a small model's poor translation is never shown+ with another model's answers and a failed one is not asked for again. */+void layout_set_model(const char *key);const char *layout_lang(void);/* How a layout is translated: system and user messages to the model, itsdiff --git a/src/chat/main.c b/src/chat/main.cindex 7e1f6b3..8cf2de1 100644--- a/src/chat/main.c+++ b/src/chat/main.c@@ -1702,8 +1702,8 @@ int main(int argc, char **argv)struct janas_llm_params probe = mp;static char probe_mtp[4096], probe_draft[4096];if (!probe.mtp_path && !probe.draft_path && !no_mtp &&- !(probe.draft_path = chat_model_draft(&cm, probe_draft,- sizeof(probe_draft))))+ !(probe.draft_path =+ chat_model_draft(&cm, probe_draft, sizeof(probe_draft))))probe.mtp_path =chat_model_mtp(&cm, probe_mtp, sizeof(probe_mtp));chat_tune_run(cm.path, &probe, &cp, gpu, dims, tpath);@@ -1777,6 +1777,7 @@ int main(int argc, char **argv)aside_chat = c;user_lang();layout_set_translator(translate);+ layout_set_model(cm.key);if (mcp) {mcpc_defer(!all_tools);mcpc_start(mcp_config);diff --git a/src/services/common/geo.c b/src/services/common/geo.cindex f4cb43f..0a90b53 100644--- a/src/services/common/geo.c+++ b/src/services/common/geo.c@@ -98,6 +98,90 @@ static void norm(const char *s, char *out, size_t cap)out[n] = 0;}+/*+ * The tables name cities in English; people here name them in Italian.+ * Without this "Roma" was the airport of Roma in Queensland (its city's+ * name in the tables), and Torino, Londra or Parigi nothing at all (8 Oct+ * 2026): the Italian names of the cities most asked for, Italy's and+ * abroad, and those of the tables' that differ.+ */+static const struct {+ const char *it, *en, *cc;+} CITY_IT[] = {+ {"roma", "Rome", "IT"},+ {"milano", "Milan", "IT"},+ {"napoli", "Naples", "IT"},+ {"torino", "Turin", "IT"},+ {"firenze", "Florence", "IT"},+ {"venezia", "Venice", "IT"},+ {"genova", "Genoa", "IT"},+ {"padova", "Padua", "IT"},+ {"mantova", "Mantua", "IT"},+ {"londra", "London", "GB"},+ {"parigi", "Paris", "FR"},+ {"berlino", "Berlin", "DE"},+ {"monaco di baviera", "Munich", "DE"},+ {"lisbona", "Lisbon", "PT"},+ {"atene", "Athens", "GR"},+ {"bruxelles", "Brussels", "BE"},+ {"ginevra", "Geneva", "CH"},+ {"zurigo", "Zürich", "CH"},+ {"barcellona", "Barcelona", "ES"},+ {"siviglia", "Sevilla", "ES"},+ {"varsavia", "Warsaw", "PL"},+ {"praga", "Prague", "CZ"},+ {"copenaghen", "Copenhagen", "DK"},+ {"stoccolma", "Stockholm", "SE"},+ {"edimburgo", "Edinburgh", "GB"},+ {"il cairo", "Cairo", "EG"},+ {"algeri", "Algiers", "DZ"},+ {"tunisi", "Tunis", "TN"},+ {"belgrado", "Belgrade", "RS"},+ {"lubiana", "Ljubljana", "SI"},+ {"zagabria", "Zagreb", "HR"},+ {"marsiglia", "Marseille", "FR"},+ {"nizza", "Nice", "FR"},+ {"lione", "Lyon", "FR"},+ {"tolosa", "Toulouse", "FR"},+ {"francoforte", "Frankfurt am Main", "DE"},+ {"colonia", "Köln", "DE"},+ {"amburgo", "Hamburg", "DE"},+ {"dublino", "Dublin", "IE"},+ {"bucarest", "Bucharest", "RO"},+ {"cracovia", "Krakow", "PL"},+ {"anversa", "Antwerp", "BE"},+ {"l'aia", "The Hague", "NL"},+ {"salisburgo", "Salzburg", "AT"},+ {"lussemburgo", "Luxembourg", "LU"},+};++/* The CITY_IT entry of an Italian name, or -1. */+static int city_it(const char *name)+{+ char w[128];+ norm(name, w, sizeof w);+ for (size_t i = 0; i < N_OF(CITY_IT); i++)+ if (strcmp(w, CITY_IT[i].it) == 0)+ return (int)i;+ return -1;+}++/* The most populous city called name (English or as the tables write+ it), in the country cc when given. */+static const struct geo_city *city_named(const char *name, const char *cc)+{+ const struct geo_city *best = NULL;+ for (size_t i = 0; i < N_OF(geo_cities); i++) {+ const struct geo_city *c = &geo_cities[i];+ if ((strcasecmp(c->ascii, name) == 0 ||+ strcasecmp(c->name, name) == 0) &&+ (!cc || strcmp(geo_country_iso2(c->country), cc) == 0) &&+ (!best || c->pop > best->pop))+ best = c;+ }+ return best;+}+const struct geo_airport *geo_airport_find(const char *what){size_t n = strlen(what);@@ -107,17 +191,33 @@ const struct geo_airport *geo_airport_find(const char *what)(n == 4 && a->icao[0] && strcasecmp(a->icao, what) == 0))return a;}+ /* an Italian name of a city: the airport nearest to it, in its country+ ("Firenze" is Peretola's, not Florence's in Alabama) */+ int it = city_it(what);+ if (it >= 0) {+ const struct geo_city *c = city_named(CITY_IT[it].en, CITY_IT[it].cc);+ double km;+ const struct geo_airport *a =+ c ? geo_airport_near(DEG(c->lat), DEG(c->lon), &km) : NULL;+ return a && km < 50 ? a : NULL;+ }char w[128], t[256];norm(what, w, sizeof w);if (!w[0])return NULL;+ /* the largest city of that name, if any: an airport found by its city+ or name has to be within 100 km of it ("Florence" is Peretola's, not+ Florence Regional's in South Carolina, which the name matches) */+ const struct geo_city *c = city_named(what, NULL);+#define NEAR_C(a) \+ (!c || geo_km(DEG(c->lat), DEG(c->lon), DEG((a)->lat), DEG((a)->lon)) < 100)/* by city, then by name: of the airports of a city, the one whose namestarts with the city's wins */const struct geo_airport *by_city = NULL;for (size_t i = 0; i < N_OF(geo_airports); i++) {const struct geo_airport *a = &geo_airports[i];norm(a->city, t, sizeof t);- if (strcmp(t, w) == 0) {+ if (strcmp(t, w) == 0 && NEAR_C(a)) {norm(a->name, t, sizeof t);if (!by_city || strncmp(t, w, strlen(w)) == 0)by_city = a;@@ -129,12 +229,12 @@ const struct geo_airport *geo_airport_find(const char *what)if (strlen(w) >= 4)for (size_t i = 0; i < N_OF(geo_airports); i++) {norm(geo_airports[i].name, t, sizeof t);- if (strstr(t, w))+ if (strstr(t, w) && NEAR_C(&geo_airports[i]))return &geo_airports[i];}+#undef NEAR_C/* a city's name: its nearest airport, within 50 km ("Turin" is CaselleTorinese's airport for OurAirports) */- const struct geo_city *c = geo_city_find(what);if (c) {double km;const struct geo_airport *a =@@ -147,13 +247,46 @@ const struct geo_airport *geo_airport_find(const char *what)const struct geo_city *geo_city_find(const char *name){+ int it = city_it(name);+ return it >= 0 ? city_named(CITY_IT[it].en, CITY_IT[it].cc)+ : city_named(name, NULL);+}++/* Italy's regions whose English name is not the Italian one */+static const struct {+ const char *it, *en;+} REGION_IT[] = {+ {"sicilia", "sicily"},+ {"sardegna", "sardinia"},+ {"toscana", "tuscany"},+ {"lombardia", "lombardy"},+ {"piemonte", "piedmont"},+ {"puglia", "apulia"},+ {"marche", "the marches"},+ {"basilicata", "basilicate"},+ {"valle d'aosta", "aosta valley"},+ {"val d'aosta", "aosta valley"},+ {"friuli", "friuli venezia giulia"},+};++const struct geo_city *geo_region_city(const char *name)+{+ char w[128], t[128];+ norm(name, w, sizeof w);+ const char *q = w;+ for (size_t i = 0; i < N_OF(REGION_IT); i++)+ if (strcmp(q, REGION_IT[i].it) == 0)+ q = REGION_IT[i].en;const struct geo_city *best = NULL;- for (size_t i = 0; i < N_OF(geo_cities); i++) {- const struct geo_city *c = &geo_cities[i];- if ((strcasecmp(c->ascii, name) == 0 ||- strcasecmp(c->name, name) == 0) &&- (!best || c->pop > best->pop))- best = c;+ for (size_t r = 0; r < N_OF(geo_regions); r++) {+ norm(geo_regions[r].name, t, sizeof t);+ if (strcmp(t, q) != 0)+ continue;+ for (size_t i = 0; i < N_OF(geo_cities); i++) {+ const struct geo_city *c = &geo_cities[i];+ if (c->region == r && (!best || c->pop > best->pop))+ best = c;+ }}return best;}diff --git a/src/services/common/geo.h b/src/services/common/geo.hindex 275773e..e409e98 100644--- a/src/services/common/geo.h+++ b/src/services/common/geo.h@@ -66,6 +66,10 @@ const struct geo_airport *geo_airport_find(const char *what);/* A city by name (its ASCII name, case ignored; the most populous of thoseof that name); NULL when none. */const struct geo_city *geo_city_find(const char *name);+/* A first-level region by its English name or, for Italy's, its Italian+ one ("Liguria", "Sicilia", "Lombardy"): its most populous city of the+ tables, or NULL. Of two regions so called, the one of the larger city. */+const struct geo_city *geo_region_city(const char *name);/* The nearest city (within 5 degrees of latitude; one under 10,000people only within 3 km), and its distance; NULL when none. */const struct geo_city *geo_city_near(double lat, double lon, double *km);diff --git a/src/services/flights/tools.c b/src/services/flights/tools.cindex 9798df7..f5d41f2 100644--- a/src/services/flights/tools.c+++ b/src/services/flights/tools.c@@ -799,7 +799,7 @@ static int flights_between(const struct janas_json *args, struct janas_buf *b)char m[300];snprintf(m, sizeof m,"Airport not known: %.100s. Give an IATA or ICAO code (TRN, "- "LICT) or a city's name in English.",+ "LICT) or a city's name in Italian or English.",!f ? (from ? from : "(none)") : to);janas_mcps_text_result(b, m, strlen(m), 1);return 0;@@ -1166,11 +1166,12 @@ static int flights_nearby(const struct janas_json *args, struct janas_buf *b)geo_country_name(c->country));} else {char m[300];- snprintf(m, sizeof m,- "Place not known: %.100s. Give an airport code (TRN, "- "LIMF), a city's name in English, or a latitude and "- "longitude.",- place);+ snprintf(+ m, sizeof m,+ "Place not known: %.100s. Give an airport code (TRN, "+ "LIMF), a city's name in Italian or English, or a latitude and "+ "longitude.",+ place);janas_mcps_text_result(b, m, strlen(m), 1);return 0;}diff --git a/src/services/weather/README.md b/src/services/weather/README.mdindex d3d3bc7..f8509a9 100644--- a/src/services/weather/README.md+++ b/src/services/weather/README.md@@ -9,7 +9,7 @@ The weather now and in the next days, the sea and its waves, and the weather war- **`weather_sea`** - the state of the sea, now and up to 8 days ahead: waves with their name on the Douglas scale (calm, smooth, slight, moderate, rough...), wind waves and swell, the water's temperature and the wind. For a whole sea by its name in English or Italian ("Tyrrhenian Sea", "Tirreno", "Adriatico", "mar Ligure"), at up to nine points across it with a summary on top, or for the sea off a coastal place.- **`weather_alerts`** - the warnings in force for a place, from the national weather services gathered by MeteoAlarm (wind, thunderstorms, heat, snow; yellow, orange, red), the place's region first and the expired and green ones left out; and in Italy the Civil Protection's official levels for the zone of alert the place is in, for floods, landslides and thunderstorms, today and tomorrow.-A place is a name in Italian or English ("Trapani", "Firenze", "Florence"), with its region or country when several share it ("Trapani, Sicilia"), an airport's code (`TRN`, `LICT`), or a latitude and longitude. A point is put into words (the town it is in or near, or the sea it is over: "the Tyrrhenian Sea, between Lazio, Italy and Sicily, Italy; 191 km SSW of Anzio"). Times are given in the place's local time.+A place is a name in Italian or English ("Trapani", "Firenze", "Florence"), with its region or country when several share it ("Trapani, Sicilia"), a region (an Italian one by its Italian or English name, "Liguria", "Sicilia", "Lombardy"; any other by its English name where no town is called so), which stands for its largest city and keeps the region for the warnings, an airport's code (`TRN`, `LICT`), or a latitude and longitude. A point is put into words (the town it is in or near, or the sea it is over: "the Tyrrhenian Sea, between Lazio, Italy and Sicily, Italy; 191 km SSW of Anzio"). Times are given in the place's local time.## When no place is nameddiff --git a/src/services/weather/place.c b/src/services/weather/place.cindex 41df270..4f3ec0c 100644--- a/src/services/weather/place.c+++ b/src/services/weather/place.c@@ -47,14 +47,15 @@ static void url_put(struct janas_buf *b, const char *s, size_t n)* region and province, and with rename its name too.*/static int find_named(const char *query, double near_lat, double near_lon,- struct wx_place *p, char *err, size_t err_len);+ struct wx_place *p, int *inhabited, char *err,+ size_t err_len);static void localize(struct wx_place *p, const char *city, int rename){struct wx_place q;char err[256];if (!city || !*city ||- find_named(city, p->lat, p->lon, &q, err, sizeof err) != 0 ||+ find_named(city, p->lat, p->lon, &q, NULL, err, sizeof err) != 0 ||geo_km(p->lat, p->lon, q.lat, q.lon) > 30 ||(p->cc[0] && strcasecmp(p->cc, q.cc) != 0))return;@@ -102,6 +103,8 @@ void wx_place_at(double lat, double lon, struct wx_place *p)localize(p, c->name, km < 3);}+static void from_city(const struct geo_city *c, struct wx_place *p);+static int from_tables(const char *q, struct wx_place *p){size_t n = strlen(q);@@ -131,6 +134,25 @@ static int from_tables(const char *q, struct wx_place *p)const struct geo_city *c = geo_city_find(q);if (!c)return 0;+ from_city(c, p);+ return 1;+}++/* A region, as its most populous city, the region kept for the warnings:+ "Liguria" is no place the geocoding knows - it gave a peak of that name+ in Antarctica, -26 degrees in Liguria (8 Oct 2026). */+static int from_region(const char *q, struct wx_place *p)+{+ const struct geo_city *c = geo_region_city(q);+ if (!c)+ return 0;+ from_city(c, p);+ localize(p, c->name, 1);+ return 1;+}++static void from_city(const struct geo_city *c, struct wx_place *p)+{memset(p, 0, sizeof *p);copy(p->name, sizeof p->name, c->name);p->lat = DEG(c->lat);@@ -141,7 +163,6 @@ static int from_tables(const char *q, struct wx_place *p)copy(p->cc, sizeof p->cc, geo_country_iso2(c->country));if (c->region != 0xFFFF)copy(p->region, sizeof p->region, geo_region_name(c->region));- return 1;}/* "38.02, 12.51" */@@ -173,9 +194,13 @@ static int contains(const char *hay, const char *needle)}/* GeoNames' feature code as a weight: a capital, a region's, a- province's or county's, a municipality's seat, a place. */+ province's or county's, a municipality's seat, a place; anything that+ is not a place people live in (a peak, a range, a lake) after every+ place, so that no peak stands for a town. */static double rank_weight(const char *code){+ if (code && strncmp(code, "PPL", 3) != 0)+ return 1e-3;static const struct {const char *code;double w;@@ -193,7 +218,8 @@ static double rank_weight(const char *code)"Venice" Venezia (51,000 people in its old town, a regional capital),not Dayton in Ohio, which the geocoding gives first. */static int find_named(const char *query, double near_lat, double near_lon,- struct wx_place *p, char *err, size_t err_len)+ struct wx_place *p, int *inhabited, char *err,+ size_t err_len){/* "Trapani, Sicilia": the name, and what its region or country musthold */@@ -252,10 +278,12 @@ static int find_named(const char *query, double near_lat, double near_lon,continue;}double pop = janas_json_num(janas_json_get(r, "population"), 0);- /* + 1: places of no known population still count */+ /* + 1: places of no known population still count; Antarctica's+ after every other */double score =(pop + 1) *- rank_weight(janas_json_str(janas_json_get(r, "feature_code")));+ rank_weight(janas_json_str(janas_json_get(r, "feature_code"))) *+ (same_name(cc, "AQ") ? 1e-6 : 1);if (!best || score > best_score) {best = r;best_score = score;@@ -279,6 +307,11 @@ static int find_named(const char *query, double near_lat, double near_lon,p->lat = janas_json_num(janas_json_get(best, "latitude"), 0);p->lon = janas_json_num(janas_json_get(best, "longitude"), 0);p->elevation = janas_json_num(janas_json_get(best, "elevation"), NAN);+ if (inhabited) {+ const char *fc =+ janas_json_str(janas_json_get(best, "feature_code"));+ *inhabited = !fc || strncmp(fc, "PPL", 3) == 0;+ }ok = 1;}janas_json_free(d);@@ -286,8 +319,11 @@ static int find_named(const char *query, double near_lat, double near_lon,if (ok)return 0;/* the geocoding did not answer, or knew nothing: the tables */- if (from_tables(name, p))+ if (from_tables(name, p)) {+ if (inhabited)+ *inhabited = 1;return 0;+ }if (why[0])snprintf(err, err_len, "no place called \"%s\" found (%s)", query, why);else@@ -314,5 +350,16 @@ int wx_place_find(const char *query, struct wx_place *p, char *err,if (a && (strcmp(a->iata, query) == 0 || strcmp(a->icao, query) == 0) &&from_tables(query, p))return 0;- return find_named(query, NAN, NAN, p, err, err_len);+ /* an Italian region before the geocoding, any other only where the+ geocoding knows no place people live in by that name: "Washington"+ is the capital, not the state's largest city */+ const struct geo_city *rc = geo_region_city(query);+ if (rc && strcmp(geo_country_iso2(rc->country), "IT") == 0 &&+ from_region(query, p))+ return 0;+ int inhabited = 0;+ int r = find_named(query, NAN, NAN, p, &inhabited, err, err_len);+ if ((r != 0 || !inhabited) && rc && from_region(query, p))+ return 0;+ return r;}diff --git a/tests/test_geo.c b/tests/test_geo.cindex c73db5a..eb69440 100644--- a/tests/test_geo.c+++ b/tests/test_geo.c@@ -87,6 +87,45 @@ int main(void)const struct geo_city *c = geo_city_find("Turin");CHECK(c && strcmp(geo_country_name(c->country), "Italy") == 0,"Turin is not in Italy");+ /* a region by its name, as its largest city: Liguria was a peak in+ Antarctica to the weather service's geocoding (8 Oct 2026) */+ static const char *const reg[][2] = {+ {"Liguria", "Genoa"}, {"Sicilia", "Palermo"},+ {"Sicily", "Palermo"}, {"lombardia", "Milan"},+ {"Valle d'Aosta", "Aosta"}, {"Marche", "Ancona"},+ {"Puglia", "Bari"}, {"Bavaria", "Munich"}};+ for (size_t i = 0; i < sizeof reg / sizeof *reg; i++) {+ c = geo_region_city(reg[i][0]);+ CHECK(c && strcmp(c->ascii, reg[i][1]) == 0, "region %s: %s", reg[i][0],+ c ? c->ascii : "none");+ }+ /* the largest city, not the seat: Basilicata's is Matera */+ c = geo_region_city("Basilicata");+ CHECK(c && strcmp(geo_region_name(c->region), "Basilicate") == 0,+ "Basilicata: %s", c ? geo_region_name(c->region) : "none");+ CHECK(!geo_region_city("Nowhereland"), "Nowhereland is a region");+ /* cities by their Italian names: "Roma" was Roma in Queensland's+ airport, Torino nothing (8 Oct 2026) */+ static const char *const cit[][3] = {{"Roma", "Rome", "IT"},+ {"Torino", "Turin", "IT"},+ {"Siracusa", "Siracusa", "IT"},+ {"Londra", "London", "GB"},+ {"Parigi", "Paris", "FR"}};+ for (size_t i = 0; i < sizeof cit / sizeof *cit; i++) {+ c = geo_city_find(cit[i][0]);+ CHECK(c && strcmp(c->ascii, cit[i][1]) == 0 &&+ strcmp(geo_country_iso2(c->country), cit[i][2]) == 0,+ "city %s: %s", cit[i][0], c ? c->ascii : "none");+ }+ a = geo_airport_find("Roma");+ CHECK(a && strcmp(geo_country_iso2(a->country), "IT") == 0,+ "Roma's airport: %s", a ? a->iata : "none");+ a = geo_airport_find("Firenze");+ CHECK(a && strcmp(a->iata, "FLR") == 0, "Firenze's airport: %s",+ a ? a->iata : "none");+ a = geo_airport_find("Florence");+ CHECK(a && strcmp(a->iata, "FLR") == 0, "Florence's airport: %s",+ a ? a->iata : "none");c = geo_city_find("livorno");CHECK(c && strcmp(geo_region_name(c->region), "Tuscany") == 0,"Livorno is not in Tuscany");