PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_5_2/TSRM - tsrm_strtok_r.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 21
Code covered: 100.0 % Executed lines: 21
Legend: not executed executed

       1                 : #include <stdio.h>
       2                 : 
       3                 : #include "tsrm_config_common.h"
       4                 : #include "tsrm_strtok_r.h"
       5                 : 
       6                 : static inline int in_character_class(char ch, const char *delim)
       7         1780717 : {
       8         5151721 :         while (*delim) {
       9         1780717 :                 if (*delim == ch) {
      10          190430 :                         return 1;
      11                 :                 }
      12         1590287 :                 delim++;
      13                 :         }
      14         1590287 :         return 0;
      15                 : }
      16                 : 
      17                 : char *tsrm_strtok_r(char *s, const char *delim, char **last)
      18          217509 : {
      19                 :         char *token;
      20                 : 
      21          217509 :         if (s == NULL) {
      22          190323 :                 s = *last;
      23                 :         }
      24                 : 
      25          462307 :         while (*s && in_character_class(*s, delim)) {
      26           27289 :                 s++;
      27                 :         }
      28          217509 :         if (!*s) {
      29           27186 :                 return NULL;
      30                 :         }
      31                 : 
      32          190323 :         token = s;
      33                 : 
      34         1780610 :         while (*s && !in_character_class(*s, delim)) {
      35         1399964 :                 s++;
      36                 :         }
      37          190323 :         if (!*s) {
      38           27182 :                 *last = s;
      39                 :         } else {
      40          163141 :                 *s = '\0';
      41          163141 :                 *last = s + 1;
      42                 :         }
      43          190323 :         return token;
      44                 : }
      45                 : 
      46                 : #if 0
      47                 : 
      48                 : main()
      49                 : {
      50                 :         char foo[] = "/foo/bar//\\barbara";
      51                 :         char *last;
      52                 :         char *token;
      53                 : 
      54                 :         token = tsrm_strtok_r(foo, "/\\", &last);
      55                 :         while (token) {
      56                 :                 printf ("Token = '%s'\n", token);
      57                 :                 token = tsrm_strtok_r(NULL, "/\\", &last);
      58                 :         }
      59                 :         
      60                 :         return 0;
      61                 : }
      62                 : 
      63                 : #endif

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:00 +0000 (5 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.