test/harness/testcaseparser.c
changeset 6 faab25d520dd
parent 5 f600b0d1fc5d
child 7 721e468c10f3
     1.1 --- a/test/harness/testcaseparser.c	Fri Jan 27 10:30:16 2012 +0000
     1.2 +++ b/test/harness/testcaseparser.c	Fri Jan 27 16:18:02 2012 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  #include <stdlib.h>
     1.5  #include <stdio.h>
     1.6  #include <string.h>
     1.7 -#include <ctype.h>
     1.8 +#include <glib.h>
     1.9  #include <bl/bl.h>
    1.10  #include "testcaseparser.h"
    1.11  
    1.12 @@ -13,9 +13,9 @@
    1.13      char *s=parser->contents;
    1.14      if (!parser->flag)
    1.15      {
    1.16 -	parser->flag=string_new(NULL);
    1.17 +	parser->flag=g_string_new(NULL);
    1.18  	while(*s>' ' && *s<='~')
    1.19 -	    string_append_c(parser->flag,*s++);
    1.20 +	    g_string_append_c(parser->flag,*s++);
    1.21      }
    1.22      return parser->flag->str;
    1.23  }
    1.24 @@ -23,7 +23,7 @@
    1.25  /*
    1.26   * Test if the parser has reached the end of the input file
    1.27   */
    1.28 -boolean testcase_parser_at_eof(TestcaseParser *parser)
    1.29 +gboolean testcase_parser_at_eof(TestcaseParser *parser)
    1.30  {
    1.31      return !parser->contents[parser->pos];
    1.32  }
    1.33 @@ -34,15 +34,15 @@
    1.34   * Callers can call testcase_parser_at_eof() when testcase_parser_get_next_tag()
    1.35   * to distinguish EOF and text which isn't a valid tag.
    1.36   */
    1.37 -boolean testcase_parser_get_next_tag(TestcaseParser *parser,const char **tag,
    1.38 +gboolean testcase_parser_get_next_tag(TestcaseParser *parser,const char **tag,
    1.39    const char **text)
    1.40  {
    1.41      size_t n;
    1.42      char *eol,*endp;
    1.43 -    String *string;
    1.44 -    mem_free(parser->tag);
    1.45 +    GString *string;
    1.46 +    g_free(parser->tag);
    1.47      parser->tag=NULL;
    1.48 -    mem_free(parser->tag_text);
    1.49 +    g_free(parser->tag_text);
    1.50      parser->tag_text=NULL;
    1.51      (void)testcase_parser_get_flag(parser);
    1.52      if (strncmp(parser->contents+parser->pos,parser->flag->str,
    1.53 @@ -54,15 +54,15 @@
    1.54      endp=eol-parser->flag->len;
    1.55      if (strncmp(endp,parser->flag->str,parser->flag->len))
    1.56  	return FALSE;
    1.57 -    while(endp>parser->contents && isspace(endp[-1]))
    1.58 +    while(endp>parser->contents && g_ascii_isspace(endp[-1]))
    1.59  	endp--;
    1.60      parser->pos+=parser->flag->len;
    1.61 -    while(isspace(parser->contents[parser->pos]))
    1.62 +    while(g_ascii_isspace(parser->contents[parser->pos]))
    1.63  	parser->pos++;
    1.64 -    parser->tag=str_ndup(parser->contents+parser->pos,
    1.65 +    parser->tag=g_strndup(parser->contents+parser->pos,
    1.66        endp-(parser->contents+parser->pos));
    1.67      parser->pos=eol-parser->contents+1;
    1.68 -    string=string_new(NULL);
    1.69 +    string=g_string_new(NULL);
    1.70      while (!testcase_parser_at_eof(parser) &&
    1.71        strncmp(parser->contents+parser->pos,parser->flag->str,parser->flag->len))
    1.72      {
    1.73 @@ -71,12 +71,12 @@
    1.74  	    n=eol-(parser->contents+parser->pos)+1;
    1.75  	else
    1.76  	    n=strlen(parser->contents+parser->pos);
    1.77 -	string_append_len(string,parser->contents+parser->pos,n);
    1.78 +	g_string_append_len(string,parser->contents+parser->pos,n);
    1.79  	parser->pos+=n;
    1.80      }
    1.81 -    parser->tag_text=string_free(string,FALSE);
    1.82 +    parser->tag_text=g_string_free(string,FALSE);
    1.83      if (!parser->tag_text)
    1.84 -	parser->tag_text=str_dup("");
    1.85 +	parser->tag_text=g_strdup("");
    1.86      if (tag)
    1.87  	*tag=parser->tag;
    1.88      if (text)
    1.89 @@ -90,13 +90,13 @@
    1.90  TestcaseParser *testcase_parser_new_from_file(const char *filename)
    1.91  {
    1.92      TestcaseParser *parser;
    1.93 -    parser=mem_new0(TestcaseParser,1);
    1.94 +    parser=g_new0(TestcaseParser,1);
    1.95      if (!file_get_contents_text(filename,&parser->contents,NULL))
    1.96      {
    1.97 -	mem_free(parser);
    1.98 +	g_free(parser);
    1.99  	return NULL;
   1.100      }
   1.101 -    parser->filename=str_dup(filename);
   1.102 +    parser->filename=g_strdup(filename);
   1.103      return parser;
   1.104  }
   1.105  
   1.106 @@ -105,11 +105,11 @@
   1.107   */
   1.108  void testcase_parser_free(TestcaseParser *parser)
   1.109  {
   1.110 -    mem_free(parser->filename);
   1.111 -    mem_free(parser->contents);
   1.112 +    g_free(parser->filename);
   1.113 +    g_free(parser->contents);
   1.114      if (parser->flag)
   1.115 -	string_free(parser->flag,TRUE);
   1.116 -    mem_free(parser->tag);
   1.117 -    mem_free(parser->tag_text);
   1.118 -    mem_free(parser);
   1.119 +	g_string_free(parser->flag,TRUE);
   1.120 +    g_free(parser->tag);
   1.121 +    g_free(parser->tag_text);
   1.122 +    g_free(parser);
   1.123  }