LCOV - code coverage report
Current view: top level - libc/string - strstr.c (source / functions) Coverage Total Hit
Test: skiboot.info Lines: 0.0 % 11 0
Test Date: 2025-01-24 18:40:10 Functions: 0.0 % 1 0
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /******************************************************************************
       2                 :             :  * Copyright (c) 2004, 2008 IBM Corporation
       3                 :             :  * All rights reserved.
       4                 :             :  * This program and the accompanying materials
       5                 :             :  * are made available under the terms of the BSD License
       6                 :             :  * which accompanies this distribution, and is available at
       7                 :             :  * http://www.opensource.org/licenses/bsd-license.php
       8                 :             :  *
       9                 :             :  * Contributors:
      10                 :             :  *     IBM Corporation - initial implementation
      11                 :             :  *****************************************************************************/
      12                 :             : 
      13                 :             : #include <stddef.h>
      14                 :             : 
      15                 :             : size_t strlen(const char *s);
      16                 :             : int strncmp(const char *s1, const char *s2, size_t n);
      17                 :             : char *strstr(const char *hay, const char *needle);
      18                 :           0 : char *strstr(const char *hay, const char *needle)
      19                 :             : {
      20                 :             :         char *pos;
      21                 :             :         size_t hlen, nlen;
      22                 :             : 
      23                 :           0 :         if (hay == NULL || needle == NULL)
      24                 :           0 :                 return NULL;
      25                 :             :         
      26                 :           0 :         hlen = strlen(hay);
      27                 :           0 :         nlen = strlen(needle);
      28                 :           0 :         if (nlen < 1)
      29                 :           0 :                 return (char *)hay;
      30                 :             : 
      31                 :           0 :         for (pos = (char *)hay; pos < hay + hlen; pos++) {
      32                 :           0 :                 if (strncmp(pos, needle, nlen) == 0) {
      33                 :           0 :                         return pos;
      34                 :             :                 }
      35                 :             :         }
      36                 :             : 
      37                 :           0 :         return NULL;
      38                 :             : }
      39                 :             : 
        

Generated by: LCOV version 2.0-1