X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Flookups%2Flsearch.c;h=b236d8b72e7c31b339d8c57cca942e52db02dbaa;hp=3883d4ba0e4e9a8083b06aa010e5ac5247374a26;hb=refs%2Ftags%2Fexim-4_90_RC1;hpb=3386088d5af4d4c61faa12ae29560e2c5bd43304 diff --git a/src/src/lookups/lsearch.c b/src/src/lookups/lsearch.c index 3883d4ba0..b236d8b72 100644 --- a/src/src/lookups/lsearch.c +++ b/src/src/lookups/lsearch.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2015 */ +/* Copyright (c) University of Cambridge 1995 - 2017 */ /* See the file NOTICE for conditions of use and distribution. */ #include "../exim.h" @@ -101,11 +101,10 @@ for (last_was_eol = TRUE; Ufgets(buffer, sizeof(buffer), f) != NULL; last_was_eol = this_is_eol) { - int ptr, size; int p = Ustrlen(buffer); int linekeylength; BOOL this_is_comment; - uschar *yield; + gstring * yield; uschar *s = buffer; /* Check whether this the final segment of a line. If it follows an @@ -240,7 +239,7 @@ for (last_was_eol = TRUE; /* Reset dynamic store, if we need to, and revert to the search pool */ - if (reset_point != NULL) + if (reset_point) { store_reset(reset_point); store_pool = old_pool; @@ -254,11 +253,9 @@ for (last_was_eol = TRUE; Initialize, and copy the first segment of data. */ this_is_comment = FALSE; - size = 100; - ptr = 0; - yield = store_get(size); + yield = string_get(100); if (*s != 0) - yield = string_cat(yield, &size, &ptr, s, Ustrlen(s)); + yield = string_cat(yield, s); /* Now handle continuations */ @@ -294,18 +291,17 @@ for (last_was_eol = TRUE; /* Join a physical or logical line continuation onto the result string. */ - yield = string_cat(yield, &size, &ptr, s, Ustrlen(s)); + yield = string_cat(yield, s); } - yield[ptr] = 0; - store_reset(yield + ptr + 1); - *result = yield; + store_reset(yield->s + yield->ptr + 1); + *result = string_from_gstring(yield); return OK; } /* Reset dynamic store, if we need to */ -if (reset_point != NULL) +if (reset_point) { store_reset(reset_point); store_pool = old_pool; @@ -323,7 +319,7 @@ return FAIL; static int lsearch_find(void *handle, uschar *filename, const uschar *keystring, int length, - uschar **result, uschar **errmsg, BOOL *do_cache) + uschar **result, uschar **errmsg, uint *do_cache) { do_cache = do_cache; /* Keep picky compilers happy */ return internal_lsearch_find(handle, filename, keystring, length, result, @@ -340,7 +336,7 @@ return internal_lsearch_find(handle, filename, keystring, length, result, static int wildlsearch_find(void *handle, uschar *filename, const uschar *keystring, int length, - uschar **result, uschar **errmsg, BOOL *do_cache) + uschar **result, uschar **errmsg, uint *do_cache) { do_cache = do_cache; /* Keep picky compilers happy */ return internal_lsearch_find(handle, filename, keystring, length, result, @@ -357,7 +353,7 @@ return internal_lsearch_find(handle, filename, keystring, length, result, static int nwildlsearch_find(void *handle, uschar *filename, const uschar *keystring, int length, - uschar **result, uschar **errmsg, BOOL *do_cache) + uschar **result, uschar **errmsg, uint *do_cache) { do_cache = do_cache; /* Keep picky compilers happy */ return internal_lsearch_find(handle, filename, keystring, length, result, @@ -375,7 +371,7 @@ return internal_lsearch_find(handle, filename, keystring, length, result, static int iplsearch_find(void *handle, uschar *filename, const uschar *keystring, int length, - uschar **result, uschar **errmsg, BOOL *do_cache) + uschar **result, uschar **errmsg, uint *do_cache) { do_cache = do_cache; /* Keep picky compilers happy */ if ((length == 1 && keystring[0] == '*') ||