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

Diff for libplaton/platon/str/strplus.c between version 1.7 and 1.8

version 1.7, 2001/12/16 20:44:37 version 1.8, 2001/12/20 00:29:26
Line 1 
Line 1 
   #include <stdio.h>
 #include <string.h>  #include <string.h>
 #include <stdlib.h>  
 #include <ctype.h>  #include <ctype.h>
 #include <stdio.h>  #include <stdlib.h>
   
 #include "strplus.h"  #include "strplus.h"
 #include "strctype.h"  #include "strctype.h"
Line 27  char *stristr(const char *s1, const char
Line 27  char *stristr(const char *s1, const char
         a_s1 = strdup(s1);          a_s1 = strdup(s1);
         a_s2 = strdup(s2);          a_s2 = strdup(s2);
   
         if (a_s1 == NULL || a_s2 == NULL) {          if (a_s1 == NULL) {
                 free(a_s1);                  free(a_s1);
                   return NULL;
           }
   
           if (a_s2 == NULL) {
                 free(a_s2);                  free(a_s2);
                 return NULL;                  return NULL;
         }          }
Line 44  char *stristr(const char *s1, const char
Line 48  char *stristr(const char *s1, const char
   
 #endif  #endif
   
   #if 0 /* Funny, isn't it? */
   
 char *str_white_str(char *s, int *size)  char *str_white_str(char *s, int *size)
 {  {
         register int elems;          register int elems;
Line 68  char *str_white_str(char *s, int *size)
Line 74  char *str_white_str(char *s, int *size)
   
 }  }
   
   #endif
   
   char *str_white_str(char *str, char *substr, int *size)
   {
           register int slen, plen, ssize;
           register char *pptr, *sptr, *start;
   
           ssize = 0;
           slen = strlen(str);
           plen = strlen(substr);
   
           for (start = str, pptr = substr; slen >= plen; start++, slen--) {
                   /* Find start of pattern in string. */
                   while (*start != *substr) {
                           start++;
                           slen--;
                           /* If pattern longer than string. */
                           if (slen < plen)
                                   return NULL;
                   }
   
                   sptr = start;
                   pptr = substr;
   
                   while (*sptr == *pptr) {
                           sptr++;
                           pptr++;
                           ssize++;
   
                           while (isspace(*sptr)) {
                                   ++sptr;
   
                                   if (isspace(*pptr)) {
                                           ++ssize;
                                           ++pptr;
                                   }
                                   else
                                           ++ssize;
                           }
   
                           /* If end of pattern then pattern was found. */
                           if (*pptr == '\0') {
                                   if (size != NULL)
                                           *size = ssize;
                                   return start;
                           }
                   }
           }
   
           return NULL;
   }
   
   
 int strcnt(const char *str, const char c)  int strcnt(const char *str, const char c)
 {  {
         register int i = 0;          register int i = 0;
Line 116  char *strdel(char *s)
Line 175  char *strdel(char *s)
 {  {
         register int i;          register int i;
   
           /* XXX: memmove() will be probably faster here */
         for (i = 0; s[i] != '\0'; i++)          for (i = 0; s[i] != '\0'; i++)
                 s[i] = s[i + 1];                  s[i] = s[i + 1];
   

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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