@@ -119,6 +119,40 @@ int URI_FUNC(CompareRange)(
119119
120120
121121
122+ UriBool  URI_FUNC (CopyRange )(URI_TYPE (TextRange ) *  destRange ,
123+ 		const  URI_TYPE (TextRange ) *  sourceRange , UriMemoryManager  *  memory ) {
124+ 	const  int  lenInChars  =  (int )(sourceRange -> afterLast  -  sourceRange -> first );
125+ 	const  int  lenInBytes  =  lenInChars  *  sizeof (URI_CHAR );
126+ 	URI_CHAR  *  dup  =  memory -> malloc (memory , lenInBytes );
127+ 	if  (dup  ==  NULL ) {
128+ 		return  URI_FALSE ;
129+ 	}
130+ 	memcpy (dup , sourceRange -> first , lenInBytes );
131+ 	destRange -> first  =  dup ;
132+ 	destRange -> afterLast  =  dup  +  lenInChars ;
133+ 
134+ 	return  URI_TRUE ;
135+ }
136+ 
137+ 
138+ 
139+ UriBool  URI_FUNC (CopyRangeAsNeeded )(URI_TYPE (TextRange ) *  destRange ,
140+ 		const  URI_TYPE (TextRange ) *  sourceRange , UriBool  useSafe , UriMemoryManager  *  memory ) {
141+ 	if  (sourceRange -> first  ==  NULL ) {
142+ 		destRange -> first  =  NULL ;
143+ 		destRange -> afterLast  =  NULL ;
144+ 	} else  if  (sourceRange -> first  ==  sourceRange -> afterLast  &&  useSafe ) {
145+ 		destRange -> first  =  URI_FUNC (SafeToPointTo );
146+ 		destRange -> afterLast  =  URI_FUNC (SafeToPointTo );
147+ 	} else  {
148+ 		return  URI_FUNC (CopyRange )(destRange , sourceRange , memory );
149+ 	}
150+ 
151+ 	return  URI_TRUE ;
152+ }
153+ 
154+ 
155+ 
122156UriBool  URI_FUNC (RemoveDotSegmentsEx )(URI_TYPE (Uri ) *  uri ,
123157		UriBool  relative , UriBool  pathOwned , UriMemoryManager  *  memory ) {
124158	URI_TYPE (PathSegment ) *  walker ;
@@ -189,7 +223,7 @@ UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri,
189223
190224						if  (prev  ==  NULL ) {
191225							/* Last and first */ 
192- 							if  (URI_FUNC (IsHostSet )(uri )) {
226+ 							if  (URI_FUNC (HasHost )(uri )) {
193227								/* Replace "." with empty segment to represent trailing slash */ 
194228								walker -> text .first  =  URI_FUNC (SafeToPointTo );
195229								walker -> text .afterLast  =  URI_FUNC (SafeToPointTo );
@@ -463,7 +497,7 @@ URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase) {
463497
464498
465499/* Checks if a URI has the host component set. */ 
466- UriBool  URI_FUNC (IsHostSet )(const  URI_TYPE (Uri ) *  uri ) {
500+ UriBool  URI_FUNC (HasHost )(const  URI_TYPE (Uri ) *  uri ) {
467501	return  (uri  !=  NULL )
468502			&&  ((uri -> hostText .first  !=  NULL )
469503				||  (uri -> hostData .ip4  !=  NULL )
@@ -601,7 +635,7 @@ void URI_FUNC(FixEmptyTrailSegment)(URI_TYPE(Uri) * uri,
601635		UriMemoryManager  *  memory ) {
602636	/* Fix path if only one empty segment */ 
603637	if  (!uri -> absolutePath 
604- 			&&  !URI_FUNC (IsHostSet )(uri )
638+ 			&&  !URI_FUNC (HasHost )(uri )
605639			&&  (uri -> pathHead  !=  NULL )
606640			&&  (uri -> pathHead -> next  ==  NULL )
607641			&&  (uri -> pathHead -> text .first  ==  uri -> pathHead -> text .afterLast )) {
0 commit comments