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.1 and 1.2

version 1.1, 2001/10/05 13:42:11 version 1.2, 2001/10/10 13:53:35
Line 3 
Line 3 
   
 #include "strplus.h"  #include "strplus.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){  char *strdel(char *s) {
         register int k=-1;          register int i;
         while(++k,s[k]!='\0')s[k]=s[k+1];  
         return(s);          for (i = 0; s[i] != '\0'; i++)
                   s[i] = s[i + 1];
   
           return s;
 }  }
   
   
 char*strlwr(char*s){  char *strlwr(char *s) {
         register int i=0;          register int i;
         while(s[i]!='\0'){  
                 if(s[i]>='A'&&s[i]<='Z')s[i]+=('a'-'A');          for (i = 0; s[i] != '\0'; i++)
                 i++;                  if (s[i] >= 'A' && s[i] <= 'Z')
         }                          s[i] += 'a' - 'A';
         return(s);  
           return s;
 }  }
   
 char*strupr(char*s){  char *strupr(char *s) {
         register int i=0;          register int i;
         while(s[i]!='\0'){  
                 if(s[i]>='a'&&s[i]<='z')s[i]-=('a'-'A');          for (i = 0; s[i] != '\0'; i++)
                 i++;                  if (s[i] >= 'a' && s[i] <= 'z')
         }                          s[i] -= 'a' - 'A';
         return(s);  
           return s;
 }  }
   
 char*strrmlf(char*s){  char *strrmlf(char *s) {
         while(strchr(s,'\n')!=NULL)strdel(strchr(s,'\n'));          while (strchr(s, '\n') != NULL)
         return(s);                  strdel(strchr(s, '\n'));
   
           return s;
 }  }
   
 char*strrmcr(char*s){  char *strrmcr(char *s) {
         while(strchr(s,'\r')!=NULL)strdel(strchr(s,'\r'));          while (strchr(s, '\r') != NULL)
         return(s);                  strdel(strchr(s, '\r'));
   
           return s;
 }  }
   
 int strrcmp(const char*s1,const char*s2){  int strrcmp(const char *s1, const char *s2) {
         register char*x1=strchr(s1,'\0'),*x2=strchr(s2,'\0');          register char *x1, *x2;
         while(x1>s1&&x2>s2){  
           x1 = strchr(s1,'\0');
           x2 = strchr(s2,'\0');
   
           while (x1 > s1 && x2 > s2) {
                 x1--;                  x1--;
                 x2--;                  x2--;
                 if(strcmp(x1,x2))return(strcmp(x1,x2));                  if (strcmp(x1,x2))
                           return strcmp(x1,x2);
         }          }
         return(strlen(s1)-strlen(s2));  
           return strlen(s1) - strlen(s2);
 }  }
   
 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;
         a_s1=strdup(s1);  
         a_s2=strdup(s2);          a_s1 = strdup(s1);
         if(a_s1==NULL||a_s2==NULL){          a_s2 = strdup(s2);
   
           if (a_s1 == NULL || a_s2 == NULL) {
                 free(a_s1);                  free(a_s1);
                 free(a_s2);                  free(a_s2);
                 return(NULL);                  return NULL;
         }          }
   
         ret=strstr(strlwr(a_s1),strlwr(a_s2));          if ((ret = strstr(strlwr(a_s1), strlwr(a_s2))) != NULL)
         if(ret!=NULL)ret=(char*)s1+(ret-a_s1);                  ret = (char *) s1 + (ret - a_s1);
   
         free(a_s1);          free(a_s1);
         free(a_s2);          free(a_s2);
         return(ret);  
           return ret;
 }  }
   
 int strcnt(const char *s, const char c) {  int strcnt(const char *s, const char c) {
Line 81  int strcnt(const char *s, const char c)
Line 100  int strcnt(const char *s, const char c)
         return i;          return i;
 }  }
   
   #if defined(SELF) || defined(SELFTEST)
   
   #define TESTSTR1 "___AAA_BBBB__C_DaDaD____"
   #define TESTSEP1 '_'
   
   int main(void) {
   
           printf("strcnt(\"%s\", '%c') = %d\n",
                                                           TESTSTR1, TESTSEP1, strcnt(TESTSTR1, TESTSEP1));
           return 0;
   }
   
   #endif
   

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

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