diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-01-29 16:17:52 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-01-29 16:17:52 +0100 |
commit | cd47bd564d7fc6177ba2e231d76bf352978409b8 (patch) | |
tree | 7465150c86969e66a90e4b960bb3537485205842 /src/tc-string.c | |
parent | 6c88f3bab0b743487b367712fa1ec27d1f87389e (diff) | |
parent | bfef0924f58eab930bdd826ac0132786abc32220 (diff) |
Update upstream source from tag 'upstream/4.10'
Update to upstream version '4.10'
with Debian dir 3c0b972fcc05149f237318f1a516c1c6bee6ce20
Diffstat (limited to 'src/tc-string.c')
-rw-r--r-- | src/tc-string.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/tc-string.c b/src/tc-string.c index db242a3..77235c2 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -1,11 +1,5 @@ /* long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing */ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifndef __cplusplus # include <assert.h> # include <errno.h> @@ -480,6 +474,35 @@ static void t_time_strto(void) } } +static int t_strmid(void) +{ +#define T(spar,opar,lpar,xpar) do { \ + char *s = HX_strmid((spar), (opar), (lpar)); \ + if (s == nullptr) \ + return EXIT_FAILURE; \ + int ret = strcmp(s, (xpar)); \ + if (ret != 0) { \ + fprintf(stderr, "Faillure: substr %s,%d,%d = %s\n", \ + (spar), static_cast(int, (opar)), static_cast(int, (lpar)), s); \ + free(s); \ + return ret; \ + } \ + free(s); \ + } while (false) + + T("Hello World", -12, 5, ""); + T("bark", -3, -1, "ar"); + T("cake", -3, -3, ""); + T("cake", -3, -4, ""); + T("fun", 0, 0, ""); + T("bark", 0, 1, "b"); + T("bark", 0, 5, "bark"); + T("bark", -4, 1, "b"); + T("bark", -4, 5, "bark"); + return EXIT_SUCCESS; +#undef T +} + int main(int argc, const char **argv) { hxmc_t *tx = NULL; @@ -488,6 +511,9 @@ int main(int argc, const char **argv) if (HX_init() <= 0) abort(); + int ret = t_strmid(); + if (ret != EXIT_SUCCESS) + return EXIT_FAILURE; fp = fopen(file, "r"); if (fp == NULL) { |