[svn r145] bug fix trunk
authorrenatofilho
Thu Nov 30 14:27:14 2006 +0000 (2006-11-30)
branchtrunk
changeset 144352ead2e7867
parent 143 f1f98329934e
child 145 af12962f4fd2
[svn r145] bug fix
gmyth/src/gmyth_uri.c
     1.1 --- a/gmyth/src/gmyth_uri.c	Thu Nov 30 13:58:35 2006 +0000
     1.2 +++ b/gmyth/src/gmyth_uri.c	Thu Nov 30 14:27:14 2006 +0000
     1.3 @@ -216,7 +216,7 @@
     1.4  	/*** Protocol ****/
     1.5  	protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM);
     1.6  	if (0 < protoIdx) {
     1.7 -		uri->protocol = g_string_append_len (uri->protocol, value, protoIdx);
     1.8 +        uri->protocol = g_string_new_len (value, protoIdx);
     1.9  		currIdx += protoIdx + strlen( GMYTH_URI_PROTOCOL_DELIM );
    1.10  	}
    1.11  
    1.12 @@ -226,20 +226,20 @@
    1.13  		colonIdx = gmyth_strstr( value+currIdx, GMYTH_URI_COLON_DELIM );
    1.14  
    1.15  		if (0 < colonIdx && colonIdx < atIdx) {
    1.16 -			uri->user = g_string_append_len( uri->user, value+currIdx,  colonIdx );
    1.17 -			uri->password = g_string_append_len( uri->password, value+currIdx+colonIdx+1, atIdx-(colonIdx+1) );
    1.18 +            uri->user = g_string_new_len (value+currIdx, colonIdx);
    1.19 +            uri->password = g_string_new_len (value+currIdx+colonIdx+1, atIdx - (colonIdx+1));
    1.20  		}
    1.21 -		else 
    1.22 -			uri->user = g_string_append_len( uri->user, value+currIdx, atIdx - currIdx );
    1.23 +		else
    1.24 +            uri->user = g_string_new_len (value+currIdx, atIdx - currIdx);
    1.25  		currIdx += atIdx + 1;
    1.26  	}
    1.27  
    1.28  	/*** Host (Port) ****/
    1.29  	shashIdx = gmyth_strstr( value+currIdx, GMYTH_URI_SLASH_DELIM );
    1.30 -	if ( 0 < shashIdx )
    1.31 -		uri->host = g_string_append_len( uri->host, value+currIdx, shashIdx );
    1.32 +	if (0 < shashIdx)
    1.33 +        uri->host = g_string_new_len (value+currIdx, shashIdx);
    1.34  	else if ( gmyth_uri_isabsolute(uri) == TRUE )
    1.35 -		uri->host = g_string_append_len( uri->host, value+currIdx, strlen(value) - currIdx );
    1.36 +        uri->host = g_string_new_len (value+currIdx, strlen (value) - currIdx);
    1.37  	host = g_strdup( gmyth_uri_get_host(uri) );
    1.38  	colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1);
    1.39  	eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1);
    1.40 @@ -253,11 +253,10 @@
    1.41  		uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx);
    1.42  		if (0 < hostLen) {
    1.43  			if (host[0] == '[' && host[hostLen-1] == ']')
    1.44 -				uri->host = g_string_append_len( uri->host, hostStr->str+1,  colonIdx-2 );
    1.45 +                uri->host = g_string_new_len (hostStr->str+1, colonIdx-2);
    1.46  		}
    1.47  		/**** port ****/
    1.48 -		portStr = g_string_new("");
    1.49 -		portStr = g_string_append_len( portStr, hostStr->str+colonIdx+1, hostLen-colonIdx-1 );
    1.50 +		portStr = g_string_new_len (hostStr->str+colonIdx+1, hostLen-colonIdx-1);
    1.51  		uri->port = (gint)g_ascii_strtoull( portStr->str, NULL, 10 );
    1.52  		g_string_free( portStr, TRUE );
    1.53  		g_string_free( hostStr, FALSE );
    1.54 @@ -291,24 +290,23 @@
    1.55  		
    1.56  	} else {
    1.57  		/* First set path simply to the rest of URI */
    1.58 -		g_string_append_len( uri->path, value+currIdx,  uriLen-currIdx );
    1.59 +		uri->path = g_string_new_len (value+currIdx,  uriLen-currIdx );
    1.60  	}
    1.61  		
    1.62  	/**** Path (Query/Fragment) ****/
    1.63  	sharpIdx = gmyth_strstr(value+currIdx, GMYTH_URI_SHARP_DELIM);
    1.64  	if (0 < sharpIdx) {
    1.65  		uri->path = g_string_append_len( uri->path, value+currIdx, sharpIdx);
    1.66 -		uri->fragment = g_string_append_len( uri->fragment, 
    1.67 -			value+currIdx+sharpIdx+1, uriLen-(currIdx+sharpIdx+1));
    1.68 +		uri->fragment = g_string_new_len (value+currIdx+sharpIdx+1, uriLen-(currIdx+sharpIdx+1));
    1.69  	}
    1.70  	
    1.71  	questionIdx = gmyth_strstr( value+currIdx, GMYTH_URI_QUESTION_DELIM );
    1.72  	if ( 0 < questionIdx ) {
    1.73 -		uri->path = g_string_append_len( uri->path, value+currIdx, questionIdx );
    1.74 +		uri->path = g_string_append_len (uri->path, value+currIdx, questionIdx );
    1.75  		queryLen = uriLen-(currIdx+questionIdx+1);
    1.76  		if ( 0 < sharpIdx )
    1.77  			queryLen -= uriLen - (currIdx+sharpIdx+1);
    1.78 -		uri->query = g_string_append_len( uri->query, value+currIdx+questionIdx+1, queryLen );
    1.79 +		uri->query = g_string_new_len (value+currIdx+questionIdx+1, queryLen );
    1.80  	}
    1.81  	gmyth_debug( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "\
    1.82  								"user = %s, password = %s.\n", __FUNCTION__, uri->host->str, uri->port,