Change semantics of pz:extendrecs
[pazpar2-moved-to-github.git] / src / client.c
index 25f6505..2002c69 100644 (file)
@@ -777,7 +777,7 @@ int client_fetch_more(struct client *cl)
     struct session_database *sdb = client_get_database(cl);
     const char *str;
     int extend_recs = 0;
-    int number;
+    int number = cl->hits - cl->record_offset;
 
     str = session_setting_oneval(sdb, PZ_EXTENDRECS);
     if (!str || !*str)
@@ -791,10 +791,8 @@ int client_fetch_more(struct client *cl)
         return 0;
     yaz_log(YLOG_LOG, "cl=%s Trying to fetch more", client_get_id(cl));
 
-    if (extend_recs > cl->hits)
-        extend_recs = cl->hits;
-
-    number = extend_recs - cl->record_offset;
+    if (number > extend_recs)
+        number = extend_recs;
     if (number > 0)
     {
         ZOOM_resultset set = cl->resultset;
@@ -1396,7 +1394,8 @@ int client_parse_query(struct client *cl, const char *query,
     facet_limits_destroy(cl->facet_limits);
     cl->facet_limits = facet_limits_dup(facet_limits);
 
-    yaz_log(YLOG_LOG, "Client %s: CCL query: %s limit: %s", client_get_id(cl), wrbuf_cstr(w_ccl), wrbuf_cstr(w_pqf));
+    yaz_log(YLOG_LOG, "Client %s: CCL query: %s limit: %s",
+            client_get_id(cl), wrbuf_cstr(w_ccl), wrbuf_cstr(w_pqf));
     cn = ccl_find_str(ccl_map, wrbuf_cstr(w_ccl), &cerror, &cpos);
     ccl_qual_rm(&ccl_map);
     if (!cn)
@@ -1436,7 +1435,8 @@ int client_parse_query(struct client *cl, const char *query,
     if (!cl->pquery || strcmp(cl->pquery, wrbuf_cstr(w_pqf)))
     {
         if (cl->pquery)
-            session_log(se, YLOG_LOG, "Client %s: Re-search due query/limit change: %s to %s", 
+            session_log(se, YLOG_LOG, "Client %s: "
+                        "Re-search due query/limit change: %s to %s", 
                         client_get_id(cl), cl->pquery, wrbuf_cstr(w_pqf));
         xfree(cl->pquery);
         cl->pquery = xstrdup(wrbuf_cstr(w_pqf));
@@ -1703,7 +1703,7 @@ struct suggestions* client_suggestions_create(const char* suggestions_string)
                               &suggestions->num, 1, '\\', 0);
     /* Set up misspelled array */
     suggestions->misspelled = (char **)
-        nmem_malloc(nmem, suggestions->num * sizeof(**suggestions->misspelled));
+        nmem_malloc(nmem, suggestions->num * sizeof(*suggestions->misspelled));
     /* replace = with \0 .. for each item */
     for (i = 0; i < suggestions->num; i++)
     {