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

Diff for libplaton/platon/str/strplus.c between version 1.5 and 1.6

version 1.5, 2001/12/08 18:23:53 version 1.6, 2001/12/09 15:06:35
Line 1 
Line 1 
 #include <string.h>  #include <string.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <ctype.h>  #include <ctype.h>
   #include <stdio.h>
   
 #include "strplus.h"  #include "strplus.h"
 #include "strctype.h"  #include "strctype.h"
Line 121  char *str_left_trim(char *s)
Line 122  char *str_left_trim(char *s)
 {  {
         register char *pos;          register char *pos;
   
         for (pos = s; *pos != '\0' && isspace(*pos); pos++)          for (pos = s; *pos != '\0' && isspace(*pos); pos++) ;
                 ;  
   
         if (pos > s)          if (pos > s)
                 memmove((void *) s, (void *) pos, strlen(pos) + 1);                  memmove((void *) s, (void *) pos, strlen(pos) + 1);
Line 134  char *str_right_trim(char *s)
Line 134  char *str_right_trim(char *s)
 {  {
         register char *pos;          register char *pos;
   
         for (pos = s + (strlen(s) - 1); pos >= s && isspace(*pos); pos--)          for (pos = s + (strlen(s) - 1); pos >= s && isspace(*pos); pos--) ;
                 ;  
   
         *(pos + 1) = '\0';          *(pos + 1) = '\0';
   
         return s;          return s;
 }  }
   
   char *str_trim_whitechars(char *s)
   {
           register char *pos, *start;
   
           for (pos = s, start = NULL; ; pos++) {
                   if (isspace(*pos)) {
                           if (start == NULL)
                                   start = pos;
                   }
                   else {
                           if (start != NULL) {
                                   memmove(start + 1, pos, strlen(pos) + 1);
                                   *start = ' ';
   
                                   pos = start + 1;
                                   start = NULL;
                           }
                   }
   
                   if (*pos == '\0')
                           break;
           }
   
           return s;
   }
   
 int strrcmp(const char *s1, const char *s2)  int strrcmp(const char *s1, const char *s2)
 {  {
         register char *x1, *x2;          register char *x1, *x2;
Line 167  int strrcmp(const char *s1, const char *
Line 192  int strrcmp(const char *s1, const char *
 #define TESTSEP1 '_'  #define TESTSEP1 '_'
 #define TESTSEP2 "BB"  #define TESTSEP2 "BB"
   
 int main(void) {  #define TESTSTR2 " \t  AAA\nBBBB__C   D\taDa D \t   \t"
   
   int main(void)
   {
           char *str2 = strdup(TESTSTR2);
   
         printf("strcnt(\"%s\", '%c') = %d\n",          printf("strcnt(\"%s\", '%c') = %d\n",
                         TESTSTR1, TESTSEP1,                          TESTSTR1, TESTSEP1,
Line 181  int main(void) {
Line 210  int main(void) {
                         TESTSTR1, TESTSEP2,                          TESTSTR1, TESTSEP2,
                         strcnt_sepstr(TESTSTR1, TESTSEP2));                          strcnt_sepstr(TESTSTR1, TESTSEP2));
   
           printf("str_trim_whitechars(\"%s\") = \"%s\"\n",
                           TESTSTR2, str_trim_whitechars(str2));
   
           free(str2);
   
         return 0;          return 0;
 }  }
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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