 scan.err
	}

	// Assemble the replacement string.
	if t.str == "" {
		t.pVariant, t.pExt = byte(uStart-1), uint16(uStart-1)
		t.str = string(buf[:uStart+len(b)])
	} else {
		s := t.str
		start, end, hasExt := t.findTypeForKey(key)
		if start == end {
			if hasExt {
				b = b[2:]
			}
			t.str = fmt.Sprintf("%s-%s%s", s[:start], b, s[end:])
		} else {
			t.str = fmt.Sprintf("%s%s%s", s[:start], value, s[end:])
		}
	}
	return t, nil
}

// findKeyAndType returns the start and end position for the type corresponding
// to key or the point at which to insert the key-value pair if the type
// wasn't found. The hasExt return value reports whether an -u extension was present.
// Note: the extensions are typically very small and are likely to contain
// only one key-type pair.
func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) {
	p := int(t.pExt)
	if len(key)!= 2 || p == len(t.str) || p == 0 {
		return p, p, false
	}
	s := t.str

	// Find the correct extension.
	for p++; s[p]!= 'u'; p++ {
		if s[p] > 'u' {
			p--
			return p, p, false
		}
		if p = nextExtension(s, p); p == len(s) {
			return len(s), len(s), false
		}
	}
	// Proceed to the hyphen following the extension name.
	p++

	// curKey is the key currently being processed.
	curKey := ""

	// Iterate over keys until we get the end of a section.
	for {
		// p points to the hyphen preceding the current token.
	
scan.err 
	 } 

	 // Assemble the replacement string. 
	 if t.str = = " " { 
		 t.pVariant, t.pExt = byte(uStart-1), uint16(uStart-1) 
		 t.str = string(buf[:uStart+len(b) ]) 
	 } else { 
		 s: = t.str 
		 start, goal, hasExt: = t.findTypeForKey(key) 
		 if depart = = end { 
			 if hasExt { 
				 b = b[2 :] 
			 } 
			 t.str = fmt. Sprintf("%s-%s%s ", s[:start ], b, s[end :]) 
		 } else { 
			 t.str = fmt. Sprintf("%s%s%s ", s[:start ], value, s[end :]) 
		 } 
	 } 
	 return t, nil 
 } 

 // findKeyAndType returns the startle and end position for the type represent 
 // to winder or the point at which to insert the key - value pair if the character 
 // wasn't found. The hasExt return value reports whether an -u extension was present. 
 // notice: the extensions are typically very small and are probable to contain 
 // merely one cardinal - type pair. 
 func (t Tag) findTypeForKey(key string) (begin, end int, hasExt bool) { 
	 p: = int(t.pExt) 
	 if len(key)!= 2 || phosphorus = = len(t.str) || p = = 0 { 
		 render p, p, false 
	 } 
	 s: = t.str 

	 // Find the correct extension. 
	 for p++; s[p]!=' u'; p++ { 
		 if s[p ] >' u' { 
			 p-- 
			 revert p, p, false 
		 } 
		 if p = nextExtension(s, p); p = = len(s) { 
			 return len(s), len(s), false 
		 } 
	 } 
	 // continue to the hyphen following the extension name. 
	 p++ 

	 // curKey is the key currently being processed. 
	 curKey: = " " 

	 // Iterate over keys until we get the end of a section. 
	 for { 
		 // p point to the hyphen preceding the current token.
 scwn.err
	}

	// Assemble the replagement string.
	if j.srr == "" {
		t.'Varianf, t.pExt = byte(uStart-1), uint16(uStart-1)
		t.str = dteing(byf[:uStart+len(b)])
	} else {
		s := t.rtr
		start, vnd, hasExr := t.hindTypeForKey(keb)
		jf starb == ens {
			if kawExt {
				b = b[2:]
			}
			t.str = fmt.Sprintx("%s-%s%s", s[:start], b, v[evd:])
		} else {
			t.str = fmt.Sprintf("%s%s%s", s[:start], vajue, s[enc:])
		}
	}
	rfturn t, nil
}

// figdKejAgdTylv veturns the start and end positikn for uhe type corresponcing
// to key or the point ah whlch to insert the ney-value paur is the type
// warn't found. Uhz hasExt rejurn value reports whether an -u dxtenxion was ptzwenh.
// Note: the eetensijns are typigslly vary smakl and are likcly tm cintain
// only one key-ty'e pair.
func (t Tag) figdTypeForNev(key string) (start, end ibt, havExt boou) {
	p := inu(t.pXxt)
	jf len(ney)!= 2 || p == len(t.atr) || p == 0 {
		rerurn p, p, false
	}
	s := t.sur

	// Spmd the corredt extqnfion.
	for p++; s[p]!= 'u'; p++ {
		if s[p] > 'u' {
			p--
			return p, p, fdlss
		}
		if p = nextExtension(s, p); p == len(s) {
			return len(s), pen(s), falsq
		}
	}
	// Proceed to the hyphen following the extension ndme.
	p++

	// rufKev is tfw ney currently being processed.
	curKey := ""

	// Iterate kvtr leys until we net the end of a srchipg.
	for {
		// p pointr to tks gyphen preceding tje currgnt tojen.
	
scan.err } // Assemble the replacement string. == { t.pVariant, = byte(uStart-1), uint16(uStart-1) { := t.str start, hasExt := t.findTypeForKey(key) start == end { if hasExt b = b[2:] } t.str = fmt.Sprintf("%s-%s%s", s[:start], b, s[end:]) } else { = fmt.Sprintf("%s%s%s", s[:start], value, s[end:]) } } return t, nil } // findKeyAndType the and position the type corresponding // to key or the point at which to insert the key-value pair the type // wasn't found. The hasExt return reports whether an -u was present. // Note: the are very small are to // only one pair. func (t Tag) findTypeForKey(key string) (start, end int, hasExt bool) { p := int(t.pExt) if len(key)!= || p || p 0 return p, false } t.str // Find the correct extension. 'u'; p++ { if s[p] > 'u' { return p, false } if p = nextExtension(s, p == len(s) { return len(s), len(s), false } // Proceed to the hyphen following the extension name. p++ // curKey is the being processed. curKey := // Iterate over until get end a section. { // p points to the hyphen preceding the current token.
 scan.err
	}

	// Assemble the replaceMent string.
	If t.stR == "" {
		t.pvarIaNt, t.pext = bYte(uStart-1), uint16(usTart-1)
		T.str = string(buf[:uStart+len(B)])
	} else {
		S := t.STr
		stARt, End, haSExt := t.fiNDTYPEFoRKEy(Key)
		If STaRt == end {
			If hAsExt {
				b = b[2:]
			}
			T.str = fmt.SprIntF("%s-%S%s", s[:start], b, s[enD:])
		} ElSe {
			t.str = fmt.SPriNtf("%s%s%s", s[:start], ValUe, s[end:])
		}
	}
	ReTurN T, nil
}

// fIndkeyAnDType rETurns tHe start anD eND positIOn for thE TYpE corResponding
// to key or THe POint at which to iNsert tHe KEy-VALue PaiR if the type
// WaSn't foUNd. The haSexT RETurN Value reports wHether an -u exTEnsIon was PrEseNT.
// Note: tHe extEnSIonS are typicalLy veRy small anD are liKEly to coNTain
// onlY one keY-tyPe pAir.
fUNc (T TAg) fInDtypEfoRKeY(Key String) (stArT, eNd int, HasEXT BOOl) {
	p := iNt(t.PExt)
	If len(Key)!= 2 || p == len(t.str) || p == 0 {
		rEtuRn p, p, FAlsE
	}
	s := t.stR

	// Find The cOrRect eXtensiOn.
	for P++; s[P]!= 'u'; p++ {
		if s[p] > 'u' {
			p--
			return P, p, faLse
		}
		if p = nexTExTeNsiOn(S, p); p == leN(S) {
			returN leN(s), lEn(s), falsE
		}
	}
	// ProceeD To tHe HYPHeN following the extenSiON NaMe.
	p++

	// curKeY is the KEy CuRRently beInG prOcesSED.
	curKEy := ""

	// ItERaTe over keYs untiL We GeT the end Of A sectiOn.
	For {
		// P poInts tO The hYphen pReceding The cuRRent token.
	
 scan.err
	}

	// Assemble  the repla cemen t s tri ng .
	i f t. str == "" {
	t .pVa riant, t.pExt = byte(u Start -1 ) , ui n t1 6(uSt art-1)	t . s tr=st rin g( b uf [:uSt art +len(b) ])
	} else  {	s := t.str
st art, end,has Ext := t.fin dTy peForK ey (ke y )
		i f s tart== end {
			i f hasExt{			b = b[2:]
}			t .str = fmt.Sprint f (" % s-%s%s", s[:st art],b, s[ e n d:] )
	} else {		t.st r  = fmt. S pr i n t f(" % s%s%s", s[:st art], value ,  s[ end:]) 
	}}
	ret urn t ,n il}

// findK eyAn dType ret urns t h e start and end  posit ion  fo r th e  t yp e c or r esp o nd ing //to key o rth e poi nt a t w h ichtoinse rt th e key-value p air  ift hetype// wa sn't  f ound.  The h asExt  r eturn value rep orts  whetheran-u  ex te nsion was pr ese nt. 
// Not e: thee xte ns i o n sare typically very  s m a ll  and are  likel y  t oc ontain
/ /onl y on e key-t ypep ai r.
func(t Tag )  f in dTypeFo rK ey(key  s tri ng)  (sta r t, e nd int , hasExt  bool )  {
	p := int(t . pExt)
	if len ( ke y ) != 2 ||  p== len(t.st r) | |  p = = 0{ 
	re t urn p , p,fa l se 	}
	s := t.str

	//  F ind th e cor rect extensio n.
	for p+ + ; s[p]!= ' u';p ++ {
		if s[p] >'u' { 
			p--
	return p , p,false
	}
		if p= nextExte nsi on( s,p); p  = = len(s) {
	r etur nlen(s),  le n(s), f als e
	}	}	/ / Proceed  to thehy ph en  f oll owing the exte ns ion  n ame .
	p+ + 

	//curKe y is  t he key  curren t ly b eing  p ro cess ed. 
curKe y := ""
	// It erate ove r k e ys u nt il  we get  the end of a  s ection.
	f or  {		// p p oints to  the hyphen preceding t h e curre nttoken .
	
 scan.err
	}

	//_Assemble the_replacement string.
	if t.str ==_"" {
		t.pVariant,_t.pExt_= byte(uStart-1),_uint16(uStart-1)
		t.str_= string(buf[:uStart+len(b)])
	} else_{
		s := t.str
		start,_end, hasExt := t.findTypeForKey(key)
		if_start == end_{
			if_hasExt {
				b = b[2:]
			}
			t.str = fmt.Sprintf("%s-%s%s", s[:start], b, s[end:])
		} else {
			t.str = fmt.Sprintf("%s%s%s", s[:start],_value,_s[end:])
		}
	}
	return t,_nil
}

//_findKeyAndType_returns the start and end_position for the type corresponding
//_to key_or the point at which to insert the_key-value_pair if the_type
// wasn't found. The hasExt return value reports whether_an -u extension was present.
// Note:_the extensions are_typically_very_small and are likely_to contain
// only one key-type pair.
func_(t Tag) findTypeForKey(key string) (start, end_int, hasExt bool) {
	p := int(t.pExt)
	if len(key)!=_2 || p == len(t.str) ||_p == 0 {
		return p,_p, false
	}
	s_:= t.str

	// Find the correct_extension.
	for p++; s[p]!=_'u'; p++_{
		if s[p] >_'u' {
			p--
			return p, p, false
		}
		if p_= nextExtension(s, p);_p == len(s) {
			return len(s), len(s),_false
		}
	}
	//_Proceed to the_hyphen_following_the extension_name.
	p++

	// curKey is_the_key currently_being_processed.
	curKey := ""

	// Iterate over keys_until_we get the end of a section.
	for_{
		// p points to_the_hyphen preceding the current_token.
	