Beispiel #1
0
char * GetLeafName ( const char ** tree_str){
   Mystring string;
   char * ret;

   string = new_mystring(10);

   while(isspace (*(*tree_str))) {
      *(*tree_str)++;
   }

   const char ** tree_str_old = tree_str;
   while ( *(*tree_str) != '\0' ){
      if ( ! isspace(*(*tree_str)) ){
         switch( *(*tree_str) ){
         case '(': case ')': case ';': case ':': case ',':
	        ret = cstring_of_mystring(string);
	        free_mystring(string);
	        return ret;
         default:
            append_char_to_mystring ( *(*tree_str),string);
         }
      }
      *(*tree_str)++;
   }
   fprintf (stderr,"Read past end of tree string trying to read leaf name. %s\n",*tree_str_old);
   exit(EXIT_FAILURE);
   return NULL;
}
Beispiel #2
0
   int main (int argc, char * argv[]){
      Mystring a;
      char *b;
      int i,nstr;

      assert(argc>1);
      for ( nstr=1 ; nstr<argc ; nstr++){
	 a = new_mystring(10);
	 for ( i=0 ; i<strlen(argv[nstr]) ; i++){
	    append_char_to_mystring(argv[nstr][i],a);
	 }
	 b = cstring_of_mystring (a);
	 free_mystring(a);
	 printf ("String %d is \"%s\"\n",nstr,b);
	 free(b);
      }
      return EXIT_SUCCESS;
   }