LCOV - code coverage report
Current view: top level - lib/missing - string.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 4 4 100.0 %
Date: 2023-04-18 16:19:03 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * lwan - web server
       3             :  * Copyright (c) 2012 L. A. F. Pereira <l@tia.mat.br>
       4             :  *
       5             :  * This program is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU General Public License
       7             :  * as published by the Free Software Foundation; either version 2
       8             :  * of the License, or any later version.
       9             :  *
      10             :  * This program is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :  * GNU General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License
      16             :  * along with this program; if not, write to the Free Software
      17             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
      18             :  * USA.
      19             :  */
      20             : 
      21             : #include_next <string.h>
      22             : 
      23             : #ifndef MISSING_STRING_H
      24             : #define MISSING_STRING_H
      25             : 
      26             : #include <stdbool.h>
      27             : 
      28             : #define strndupa_impl(s, l)                                                    \
      29             :     ({                                                                         \
      30             :         char *strndupa_tmp_s = alloca(l + 1);                                  \
      31             :         strndupa_tmp_s[l] = '\0';                                              \
      32             :         strncpy(strndupa_tmp_s, s, l);                                          \
      33             :     })
      34             : 
      35             : #ifndef strndupa
      36             : #define strndupa(s, l) strndupa_impl((s), strnlen((s), (l)))
      37             : #undef NEED_ALLOCA_H
      38             : #define NEED_ALLOCA_H
      39             : #endif
      40             : 
      41             : #ifndef strdupa
      42             : #define strdupa(s) strndupa((s), strlen(s))
      43             : #undef NEED_ALLOCA_H
      44             : #define NEED_ALLOCA_H
      45             : #endif
      46             : 
      47             : #ifdef NEED_ALLOCA_H
      48             : #undef NEED_ALLOCA_H
      49             : #ifdef LWAN_HAVE_ALLOCA_H
      50             : #include <alloca.h>
      51             : #else
      52             : #include <stdlib.h>
      53             : #endif
      54             : #endif
      55             : 
      56             : #ifndef LWAN_HAVE_MEMPCPY
      57             : void *mempcpy(void *dest, const void *src, size_t len);
      58             : #endif
      59             : 
      60             : #ifndef LWAN_HAVE_MEMRCHR
      61             : void *memrchr(const void *s, int c, size_t n);
      62             : #endif
      63             : 
      64             : #ifndef LWAN_HAVE_STPCPY
      65             : char *stpcpy(char *restrict dst, const char *restrict src);
      66             : char *stpncpy(char *restrict dst, const char *restrict src, size_t sz);
      67             : #endif
      68             : 
      69       24918 : static inline int streq(const char *a, const char *b)
      70             : {
      71       24918 :     return strcmp(a, b) == 0;
      72             : }
      73             : 
      74          34 : static inline void *mempmove(void *dest, const void *src, size_t len)
      75             : {
      76          34 :     return (char *)memmove(dest, src, len) + len;
      77             : }
      78             : 
      79             : bool strcaseequal_neutral(const char *a, const char *b);
      80             : 
      81             : #endif /* MISSING_STRING_H */

Generated by: LCOV version 1.15-2-gb9d6727