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 libcfg+/src/platon/str/strdyn.c between version 1.19 and 1.20

version 1.19, 2002/08/16 20:31:43 version 1.20, 2002/08/27 13:12:33
Line 10 
Line 10 
 #include "strplus.h"  #include "strplus.h"
 #include "strdyn.h"  #include "strdyn.h"
   
 #ifndef FUNCTION  
 #  define FUNCTION_NAME(_unused, _name) _unused##_name  
 #  define FUNCTION(_name) FUNCTION_NAME(, ## _name)  
 #endif  
   
   
         void          void
 FUNCTION(strdyn_free)(ar)  PLATON_FUNC(strdyn_free)(ar)
         char **ar;          char **ar;
 {  {
         register int i;          register int i;
Line 29  FUNCTION(strdyn_free)(ar)
Line 23  FUNCTION(strdyn_free)(ar)
 }  }
   
         void          void
 FUNCTION(strdyn_safe_free)(ar)  PLATON_FUNC(strdyn_safe_free)(ar)
         char **ar;          char **ar;
 {  {
         if (ar == NULL)          if (ar == NULL)
                 return;                  return;
   
         FUNCTION(strdyn_free)(ar);          PLATON_FUNC(strdyn_free)(ar);
   
         return;          return;
 }  }
   
         int          int
 FUNCTION(strdyn_get_size)(ar)  PLATON_FUNC(strdyn_get_size)(ar)
         char **ar;          char **ar;
 {  {
         register int i;          register int i;
Line 53  FUNCTION(strdyn_get_size)(ar)
Line 47  FUNCTION(strdyn_get_size)(ar)
 }  }
   
         char **          char **
 FUNCTION(strdyn_create)(void)  PLATON_FUNC(strdyn_create)(void)
 {  {
         register char **ar;          register char **ar;
   
Line 66  FUNCTION(strdyn_create)(void)
Line 60  FUNCTION(strdyn_create)(void)
 }  }
   
 char **  char **
 FUNCTION(strdyn_create_va)(  PLATON_FUNC(strdyn_create_va)(
                 char *s1,                  char *s1,
                 ...)                  ...)
 {  {
         register char **ar;          register char **ar;
   
         if ((ar = FUNCTION(strdyn_create)()) == NULL)          if ((ar = PLATON_FUNC(strdyn_create)()) == NULL)
                 return NULL;                  return NULL;
   
         if (s1 != NULL) {          if (s1 != NULL) {
                 register char *s;                  register char *s;
                 va_list ap;                  va_list ap;
   
                 if ((ar = FUNCTION(strdyn_add)(ar, s1)) == NULL)                  if ((ar = PLATON_FUNC(strdyn_add)(ar, s1)) == NULL)
                         return NULL;                          return NULL;
   
                 va_start(ap, s1);                  va_start(ap, s1);
   
                 while ((s = va_arg(ap, char *)) != NULL)                  while ((s = va_arg(ap, char *)) != NULL)
                         if ((ar = FUNCTION(strdyn_add)(ar, s)) == NULL)                          if ((ar = PLATON_FUNC(strdyn_add)(ar, s)) == NULL)
                                 return NULL;                                  return NULL;
   
                 va_end(ap);                  va_end(ap);
Line 95  FUNCTION(strdyn_create_va)(
Line 89  FUNCTION(strdyn_create_va)(
 }  }
   
         char **          char **
 FUNCTION(strdyn_create_ar)(ar)  PLATON_FUNC(strdyn_create_ar)(ar)
         char **ar;          char **ar;
 {  {
         register int i;          register int i;
         register char **new_ar;          register char **new_ar;
   
         if ((new_ar = (char**) malloc((FUNCTION(strdyn_get_size)(ar) + 1)          if ((new_ar = (char**) malloc((PLATON_FUNC(strdyn_get_size)(ar) + 1)
                                         * sizeof(char*))) == NULL)                                          * sizeof(char*))) == NULL)
                         return NULL;                          return NULL;
   
Line 114  FUNCTION(strdyn_create_ar)(ar)
Line 108  FUNCTION(strdyn_create_ar)(ar)
 }  }
   
 char **  char **
 FUNCTION(strdyn_safe_create_ar)(ar)  PLATON_FUNC(strdyn_safe_create_ar)(ar)
         char **ar;          char **ar;
 {  {
         if (ar == NULL)          if (ar == NULL)
                 return NULL;                  return NULL;
   
         return FUNCTION(strdyn_create_ar)(ar);          return PLATON_FUNC(strdyn_create_ar)(ar);
 }  }
   
 char **  char **
 FUNCTION(strdyn_add)(ar, s)  PLATON_FUNC(strdyn_add)(ar, s)
         char       **ar;          char       **ar;
         const char *s;          const char *s;
 {  {
         register int count;          register int count;
   
         if (ar == NULL)          if (ar == NULL)
                 if ((ar = FUNCTION(strdyn_create)()) == NULL)                  if ((ar = PLATON_FUNC(strdyn_create)()) == NULL)
                         return NULL;                          return NULL;
   
         count = FUNCTION(strdyn_get_size)(ar);          count = PLATON_FUNC(strdyn_get_size)(ar);
   
         if ((ar = (char **) realloc(ar, (count + 2) * sizeof(char *))) == NULL)          if ((ar = (char **) realloc(ar, (count + 2) * sizeof(char *))) == NULL)
                 return NULL;                  return NULL;
Line 146  FUNCTION(strdyn_add)(ar, s)
Line 140  FUNCTION(strdyn_add)(ar, s)
 }  }
   
 char **  char **
 FUNCTION(strdyn_add_va)(  PLATON_FUNC(strdyn_add_va)(
                 char **ar,                  char **ar,
                 ...)                  ...)
 {  {
Line 154  FUNCTION(strdyn_add_va)(
Line 148  FUNCTION(strdyn_add_va)(
         va_list ap;          va_list ap;
   
         if (ar == NULL)          if (ar == NULL)
                 if ((ar = FUNCTION(strdyn_create)()) == NULL)                  if ((ar = PLATON_FUNC(strdyn_create)()) == NULL)
                         return NULL;                          return NULL;
   
         va_start(ap, ar);          va_start(ap, ar);
   
         while ((s = va_arg(ap, char *)) != NULL)          while ((s = va_arg(ap, char *)) != NULL)
                 if ((ar = FUNCTION(strdyn_add)(ar, s)) == NULL)                  if ((ar = PLATON_FUNC(strdyn_add)(ar, s)) == NULL)
                         return NULL;                          return NULL;
   
         va_end(ap);          va_end(ap);
Line 169  FUNCTION(strdyn_add_va)(
Line 163  FUNCTION(strdyn_add_va)(
 }  }
   
 char **  char **
 FUNCTION(strdyn_add_ar)(ar, s_ar)  PLATON_FUNC(strdyn_add_ar)(ar, s_ar)
         char         **ar;          char         **ar;
         char * const *s_ar;          char * const *s_ar;
 {  {
         register int k;          register int k;
   
         for (k = 0; s_ar[k] != NULL; k++)          for (k = 0; s_ar[k] != NULL; k++)
                 if ((ar = FUNCTION(strdyn_add)(ar, s_ar[k])) == NULL)                  if ((ar = PLATON_FUNC(strdyn_add)(ar, s_ar[k])) == NULL)
                         return NULL;                          return NULL;
   
         return ar;          return ar;
 }  }
   
 char **  char **
 FUNCTION(strdyn_remove_idx)(ar, idx)  PLATON_FUNC(strdyn_remove_idx)(ar, idx)
         char **ar;          char **ar;
         int  idx;          int  idx;
 {  {
Line 204  FUNCTION(strdyn_remove_idx)(ar, idx)
Line 198  FUNCTION(strdyn_remove_idx)(ar, idx)
 }  }
   
 char **  char **
 FUNCTION(strdyn_remove_str)(ar, s)  PLATON_FUNC(strdyn_remove_str)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
         register int idx;          register int idx;
   
         idx = FUNCTION(strdyn_search)(ar, s);          idx = PLATON_FUNC(strdyn_search)(ar, s);
   
         if (idx < 0)          if (idx < 0)
                 return ar;                  return ar;
   
         return FUNCTION(strdyn_remove_idx)(ar, idx);          return PLATON_FUNC(strdyn_remove_idx)(ar, idx);
 }  }
   
 char **  char **
 FUNCTION(strdyn_remove_str_all)(ar, s)  PLATON_FUNC(strdyn_remove_str_all)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
Line 229  FUNCTION(strdyn_remove_str_all)(ar, s)
Line 223  FUNCTION(strdyn_remove_str_all)(ar, s)
                 if (new_ar != NULL)                  if (new_ar != NULL)
                         ar = new_ar;                          ar = new_ar;
   
                 if ((new_ar = FUNCTION(strdyn_remove_str)(ar, s)) == NULL)                  if ((new_ar = PLATON_FUNC(strdyn_remove_str)(ar, s)) == NULL)
                         return NULL;                          return NULL;
         }          }
   
Line 237  FUNCTION(strdyn_remove_str_all)(ar, s)
Line 231  FUNCTION(strdyn_remove_str_all)(ar, s)
 }  }
   
 char **  char **
 FUNCTION(strdyn_remove_empty)(ar)  PLATON_FUNC(strdyn_remove_empty)(ar)
         char **ar;          char **ar;
 {  {
         register int i, j;          register int i, j;
Line 261  FUNCTION(strdyn_remove_empty)(ar)
Line 255  FUNCTION(strdyn_remove_empty)(ar)
 }  }
   
 char **  char **
 FUNCTION(strdyn_remove_all)(ar)  PLATON_FUNC(strdyn_remove_all)(ar)
         char **ar;          char **ar;
 {  {
         register int i;          register int i;
Line 278  FUNCTION(strdyn_remove_all)(ar)
Line 272  FUNCTION(strdyn_remove_all)(ar)
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode_chr)(str, sep)  PLATON_FUNC(strdyn_explode_chr)(str, sep)
         char *str;          char *str;
         int sep;          int sep;
 {  {
Line 287  FUNCTION(strdyn_explode_chr)(str, sep)
Line 281  FUNCTION(strdyn_explode_chr)(str, sep)
         sep_str[0] = (char) sep;          sep_str[0] = (char) sep;
         sep_str[1] = '\0';          sep_str[1] = '\0';
   
         return FUNCTION(strdyn_explode_str)(str, sep_str);          return PLATON_FUNC(strdyn_explode_str)(str, sep_str);
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode2_chr)(str, sep)  PLATON_FUNC(strdyn_explode2_chr)(str, sep)
         char *str;          char *str;
         int sep;          int sep;
 {  {
   
         return FUNCTION(strdyn_remove_empty)(FUNCTION(strdyn_explode_chr)(str, sep));          return PLATON_FUNC(strdyn_remove_empty)(PLATON_FUNC(strdyn_explode_chr)(str, sep));
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode_str)(str, sep)  PLATON_FUNC(strdyn_explode_str)(str, sep)
         char *str;          char *str;
         char *sep;          char *sep;
 {  {
Line 311  FUNCTION(strdyn_explode_str)(str, sep)
Line 305  FUNCTION(strdyn_explode_str)(str, sep)
         if (str == NULL || sep == NULL)          if (str == NULL || sep == NULL)
                 return NULL;                  return NULL;
   
         ar_size = FUNCTION(strcnt_sepstr)(str, sep);          ar_size = PLATON_FUNC(strcnt_sepstr)(str, sep);
   
         if ((ar = (char**) malloc((ar_size + 2) * sizeof(char*))) == NULL)          if ((ar = (char**) malloc((ar_size + 2) * sizeof(char*))) == NULL)
                 return NULL;                  return NULL;
Line 339  FUNCTION(strdyn_explode_str)(str, sep)
Line 333  FUNCTION(strdyn_explode_str)(str, sep)
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode2_str)(str, sep)  PLATON_FUNC(strdyn_explode2_str)(str, sep)
         char *str;          char *str;
         char *sep;          char *sep;
 {  {
         return FUNCTION(strdyn_remove_empty)(FUNCTION(strdyn_explode_str)(str, sep));          return PLATON_FUNC(strdyn_remove_empty)(PLATON_FUNC(strdyn_explode_str)(str, sep));
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode_ar)(str, sep)  PLATON_FUNC(strdyn_explode_ar)(str, sep)
         char *str;          char *str;
         char **sep;          char **sep;
 {  {
Line 356  FUNCTION(strdyn_explode_ar)(str, sep)
Line 350  FUNCTION(strdyn_explode_ar)(str, sep)
   
         char **ar, **ar1;          char **ar, **ar1;
   
         if ((ar1 = FUNCTION(strdyn_explode_str)(str, sep[0])) == NULL)          if ((ar1 = PLATON_FUNC(strdyn_explode_str)(str, sep[0])) == NULL)
                 return NULL;                  return NULL;
   
         if (sep[1] != NULL) {          if (sep[1] != NULL) {
                 char **ar2;                  char **ar2;
                 register int i;                  register int i;
   
                 if ((ar = FUNCTION(strdyn_create)()) == NULL) {                  if ((ar = PLATON_FUNC(strdyn_create)()) == NULL) {
                         FUNCTION(strdyn_free)(ar1);                          PLATON_FUNC(strdyn_free)(ar1);
                         return NULL;                          return NULL;
                 }                  }
   
                 for (i = 0; i < strdyn_count(ar1); i++) {                  for (i = 0; i < strdyn_count(ar1); i++) {
                         if ((ar2 = FUNCTION(strdyn_explode_ar)(ar1[i], sep + 1)) == NULL) {                          if ((ar2 = PLATON_FUNC(strdyn_explode_ar)(ar1[i], sep + 1)) == NULL) {
                                 FUNCTION(strdyn_free)(ar1);                                  PLATON_FUNC(strdyn_free)(ar1);
                                 FUNCTION(strdyn_free)(ar);                                  PLATON_FUNC(strdyn_free)(ar);
                                 return NULL;                                  return NULL;
                         }                          }
   
                         if ((ar = FUNCTION(strdyn_add_ar)(ar, ar2)) == NULL) {                          if ((ar = PLATON_FUNC(strdyn_add_ar)(ar, ar2)) == NULL) {
                                 FUNCTION(strdyn_free)(ar1);                                  PLATON_FUNC(strdyn_free)(ar1);
                                 FUNCTION(strdyn_free)(ar);                                  PLATON_FUNC(strdyn_free)(ar);
                                 FUNCTION(strdyn_free)(ar2);                                  PLATON_FUNC(strdyn_free)(ar2);
                                 return NULL;                                  return NULL;
                         }                          }
   
                         FUNCTION(strdyn_free)(ar2);                          PLATON_FUNC(strdyn_free)(ar2);
                 }                  }
   
                 FUNCTION(strdyn_free)(ar1);                  PLATON_FUNC(strdyn_free)(ar1);
         }          }
         else          else
                 ar = ar1;                  ar = ar1;
Line 394  FUNCTION(strdyn_explode_ar)(str, sep)
Line 388  FUNCTION(strdyn_explode_ar)(str, sep)
 }  }
   
 char **  char **
 FUNCTION(strdyn_explode2_ar)(str, sep)  PLATON_FUNC(strdyn_explode2_ar)(str, sep)
         char *str;          char *str;
         char **sep;          char **sep;
 {  {
         return FUNCTION(strdyn_remove_empty)(FUNCTION(strdyn_explode_ar)(str, sep));          return PLATON_FUNC(strdyn_remove_empty)(PLATON_FUNC(strdyn_explode_ar)(str, sep));
 }  }
   
 char *  char *
 FUNCTION(strdyn_implode_chr)(ar, sep)  PLATON_FUNC(strdyn_implode_chr)(ar, sep)
         char **ar;          char **ar;
         int sep;          int sep;
 {  {
Line 411  FUNCTION(strdyn_implode_chr)(ar, sep)
Line 405  FUNCTION(strdyn_implode_chr)(ar, sep)
         sep_str[0] = (char) sep;          sep_str[0] = (char) sep;
         sep_str[1] = '\0';          sep_str[1] = '\0';
   
         return FUNCTION(strdyn_implode_str)(ar, sep_str);          return PLATON_FUNC(strdyn_implode_str)(ar, sep_str);
 }  }
   
 char *  char *
 FUNCTION(strdyn_implode2_chr)(ar, sep)  PLATON_FUNC(strdyn_implode2_chr)(ar, sep)
         char **ar;          char **ar;
         int sep;          int sep;
 {  {
         register char **new_ar;          register char **new_ar;
         register char *s;          register char *s;
   
         new_ar = FUNCTION(strdyn_remove_empty)(strdyn_duplicate(ar));          new_ar = PLATON_FUNC(strdyn_remove_empty)(strdyn_duplicate(ar));
   
         s = FUNCTION(strdyn_implode_chr)(new_ar, sep);          s = PLATON_FUNC(strdyn_implode_chr)(new_ar, sep);
   
         FUNCTION(strdyn_free)(new_ar);          PLATON_FUNC(strdyn_free)(new_ar);
   
         return s;          return s;
 }  }
   
 char *  char *
 FUNCTION(strdyn_implode_str)(ar, sep)  PLATON_FUNC(strdyn_implode_str)(ar, sep)
         char **ar;          char **ar;
         char *sep;          char *sep;
 {  {
Line 462  FUNCTION(strdyn_implode_str)(ar, sep)
Line 456  FUNCTION(strdyn_implode_str)(ar, sep)
 }  }
   
 char *  char *
 FUNCTION(strdyn_implode2_str)(ar, str)  PLATON_FUNC(strdyn_implode2_str)(ar, str)
         char **ar;          char **ar;
         char *str;          char *str;
 {  {
         register char **new_ar;          register char **new_ar;
         register char *s;          register char *s;
   
         new_ar = FUNCTION(strdyn_remove_empty)(strdyn_duplicate(ar));          new_ar = PLATON_FUNC(strdyn_remove_empty)(strdyn_duplicate(ar));
   
         s = FUNCTION(strdyn_implode_str)(new_ar, str);          s = PLATON_FUNC(strdyn_implode_str)(new_ar, str);
   
         FUNCTION(strdyn_free)(new_ar);          PLATON_FUNC(strdyn_free)(new_ar);
   
         return s;          return s;
 }  }
   
 char **  char **
 FUNCTION(strdyn_conjunct)(ar1, ar2)  PLATON_FUNC(strdyn_conjunct)(ar1, ar2)
         char **ar1;          char **ar1;
         char **ar2;          char **ar2;
 {  {
         register int i;          register int i;
         register char **ar;          register char **ar;
   
         if ((ar = FUNCTION(strdyn_create)()) == NULL)          if ((ar = PLATON_FUNC(strdyn_create)()) == NULL)
                 return NULL;                  return NULL;
   
         for (i = 0; ar2[i] != NULL; i++) {          for (i = 0; ar2[i] != NULL; i++) {
                 if (! FUNCTION(strdyn_compare)(ar1, ar2[i])) {                  if (! PLATON_FUNC(strdyn_compare)(ar1, ar2[i])) {
                         if ((ar = FUNCTION(strdyn_add)(ar, ar2[i])) == NULL)                          if ((ar = PLATON_FUNC(strdyn_add)(ar, ar2[i])) == NULL)
                                 return NULL;                                  return NULL;
                 }                  }
         }          }
Line 500  FUNCTION(strdyn_conjunct)(ar1, ar2)
Line 494  FUNCTION(strdyn_conjunct)(ar1, ar2)
 }  }
   
 char **  char **
 FUNCTION(strdyn_consolide)(ar1, ar2)  PLATON_FUNC(strdyn_consolide)(ar1, ar2)
         char **ar1;          char **ar1;
         char **ar2;          char **ar2;
 {  {
         register int i;          register int i;
         register char **ar;          register char **ar;
   
         if ((ar = FUNCTION(strdyn_create)()) == NULL)          if ((ar = PLATON_FUNC(strdyn_create)()) == NULL)
                 return NULL;                  return NULL;
   
         for (i = 0; ar1[i] != NULL; i++) {          for (i = 0; ar1[i] != NULL; i++) {
                 if (FUNCTION(strdyn_compare)(ar, ar1[i])) {                  if (PLATON_FUNC(strdyn_compare)(ar, ar1[i])) {
                         if ((ar = FUNCTION(strdyn_add)(ar, ar1[i])) == NULL)                          if ((ar = PLATON_FUNC(strdyn_add)(ar, ar1[i])) == NULL)
                                 return NULL;                                  return NULL;
                 }                  }
         }          }
   
         for (i = 0; ar2[i] != NULL; i++) {          for (i = 0; ar2[i] != NULL; i++) {
                 if (FUNCTION(strdyn_compare)(ar, ar2[i])) {                  if (PLATON_FUNC(strdyn_compare)(ar, ar2[i])) {
                         if ((ar = FUNCTION(strdyn_add)(ar, ar2[i])) == NULL)                          if ((ar = PLATON_FUNC(strdyn_add)(ar, ar2[i])) == NULL)
                                 return NULL;                                  return NULL;
                 }                  }
         }          }
Line 528  FUNCTION(strdyn_consolide)(ar1, ar2)
Line 522  FUNCTION(strdyn_consolide)(ar1, ar2)
 }  }
   
 int  int
 FUNCTION(strdyn_search)(ar, s)  PLATON_FUNC(strdyn_search)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
Line 542  FUNCTION(strdyn_search)(ar, s)
Line 536  FUNCTION(strdyn_search)(ar, s)
 }  }
   
 int  int
 FUNCTION(strdyn_casesearch)(ar, s)  PLATON_FUNC(strdyn_casesearch)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
Line 556  FUNCTION(strdyn_casesearch)(ar, s)
Line 550  FUNCTION(strdyn_casesearch)(ar, s)
 }  }
   
 int  int
 FUNCTION(strdyn_compare)(ar, s)  PLATON_FUNC(strdyn_compare)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
         return FUNCTION(strdyn_search)(ar, s) < 0 ? -1 : 0;          return PLATON_FUNC(strdyn_search)(ar, s) < 0 ? -1 : 0;
 }  }
   
 int  int
 FUNCTION(strdyn_casecompare)(ar, s)  PLATON_FUNC(strdyn_casecompare)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
         return FUNCTION(strdyn_casesearch)(ar, s) < 0 ? -1 : 0;          return PLATON_FUNC(strdyn_casesearch)(ar, s) < 0 ? -1 : 0;
         return FUNCTION(strdyn_casesearch)(ar, s) < 0 ? -1 : 0;          return PLATON_FUNC(strdyn_casesearch)(ar, s) < 0 ? -1 : 0;
 }  }
   
 int  int
 FUNCTION(strdyn_compare_all)(ar, s)  PLATON_FUNC(strdyn_compare_all)(ar, s)
         char **ar;          char **ar;
         char *s;          char *s;
 {  {
Line 587  FUNCTION(strdyn_compare_all)(ar, s)
Line 581  FUNCTION(strdyn_compare_all)(ar, s)
 }  }
   
 char *  char *
 FUNCTION(strdyn_str2)(s, ar, idx)  PLATON_FUNC(strdyn_str2)(s, ar, idx)
         char *s;          char *s;
         char **ar;          char **ar;
         int  *idx;          int  *idx;

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

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