Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, October 17, 2026

Diff for libcfg+/src/platon/str/strplus.c between version 1.2 and 1.3

version 1.2, 2001/10/10 13:53:35 version 1.3, 2001/10/10 17:59:53
Line 2 
Line 2 
 #include<stdlib.h>  #include<stdlib.h>
   
 #include "strplus.h"  #include "strplus.h"
   #include "strctype.h"
   
 char *strestr(const char *s1, const char *s2) {  char *strestr(const char *s1, const char *s2) {
         return strstr(s1,s2) == NULL ? NULL : strendstr(s1,s2);          return strstr(s1,s2) == NULL ? NULL : strendstr(s1,s2);
 }  }
   
 char *strdel(char *s) {  int strcnt(const char *s, const char c) {
         register int i;          register int i = 0;
   
         for (i = 0; s[i] != '\0'; i++)  
                 s[i] = s[i + 1];  
   
         return s;  
 }  
   
   
 char *strlwr(char *s) {  
         register int i;  
   
         for (i = 0; s[i] != '\0'; i++)          if (s != NULL)
                 if (s[i] >= 'A' && s[i] <= 'Z')                  while (*s != '\0')
                         s[i] += 'a' - 'A';                          if (*s++ == c)
                                   i++;
   
         return s;          return i;
 }  }
   
 char *strupr(char *s) {  char *strdel(char *s) {
         register int i;          register int i;
   
         for (i = 0; s[i] != '\0'; i++)          for (i = 0; s[i] != '\0'; i++)
                 if (s[i] >= 'a' && s[i] <= 'z')                  s[i] = s[i + 1];
                         s[i] -= 'a' - 'A';  
   
         return s;          return s;
 }  }
Line 67  int strrcmp(const char *s1, const char *
Line 58  int strrcmp(const char *s1, const char *
         return strlen(s1) - strlen(s2);          return strlen(s1) - strlen(s2);
 }  }
   
   #if ! defined(SELF) && ! defined(SELFTEST)
   
   /*
    * Functions strtolower() and strtoupper(), used by function below,
    * are defined in strctype.c so when we are building self-testing
    * binary, skip this section.
    */
   
 char *stristr(const char *s1, const char *s2) {  char *stristr(const char *s1, const char *s2) {
         char *a_s1, *a_s2;          char *a_s1, *a_s2;
         register char *ret;          register char *ret;
Line 80  char *stristr(const char *s1, const char
Line 79  char *stristr(const char *s1, const char
                 return NULL;                  return NULL;
         }          }
   
         if ((ret = strstr(strlwr(a_s1), strlwr(a_s2))) != NULL)          if ((ret = strstr(strtolower(a_s1), strtoupper(a_s2))) != NULL)
                 ret = (char *) s1 + (ret - a_s1);                  ret = (char *) s1 + (ret - a_s1);
   
         free(a_s1);          free(a_s1);
Line 89  char *stristr(const char *s1, const char
Line 88  char *stristr(const char *s1, const char
         return ret;          return ret;
 }  }
   
 int strcnt(const char *s, const char c) {  #endif
         register int i = 0;  
   
         if (s != NULL)  
                 while (*s != '\0')  
                         if (*s++ == c)  
                                 i++;  
   
         return i;  
 }  
   
 #if defined(SELF) || defined(SELFTEST)  #if defined(SELF) || defined(SELFTEST)
   
Line 109  int main(void) {
Line 99  int main(void) {
   
         printf("strcnt(\"%s\", '%c') = %d\n",          printf("strcnt(\"%s\", '%c') = %d\n",
                                                         TESTSTR1, TESTSEP1, strcnt(TESTSTR1, TESTSEP1));                                                          TESTSTR1, TESTSEP1, strcnt(TESTSTR1, TESTSEP1));
   
         return 0;          return 0;
 }  }
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top