author | Michael Krelin <hacker@klever.net> | 2008-06-27 21:00:41 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-06-27 21:00:41 (UTC) |
commit | 362678728b8232c9490e14ba14ff323d9a92d6be (patch) (unidiff) | |
tree | 105675f96fff87916b2fdea8b51ad9fe98c5531d /lib/util.cc | |
parent | a344edbdddeac51524001faa10d06f85cfdb041c (diff) | |
download | libopkele-362678728b8232c9490e14ba14ff323d9a92d6be.zip libopkele-362678728b8232c9490e14ba14ff323d9a92d6be.tar.gz libopkele-362678728b8232c9490e14ba14ff323d9a92d6be.tar.bz2 |
made gcc 4.3 a bit happier
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/util.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/util.cc b/lib/util.cc index b702291..d979502 100644 --- a/lib/util.cc +++ b/lib/util.cc | |||
@@ -198,33 +198,33 @@ namespace opkele { | |||
198 | for(string::const_iterator i=str.begin(),ie=str.end(); | 198 | for(string::const_iterator i=str.begin(),ie=str.end(); |
199 | i!=ie;++i) { | 199 | i!=ie;++i) { |
200 | switch(*i) { | 200 | switch(*i) { |
201 | case '+': | 201 | case '+': |
202 | *(ii++) = ' '; break; | 202 | *(ii++) = ' '; break; |
203 | case '%': | 203 | case '%': |
204 | ++i; | 204 | ++i; |
205 | static char tmp[3] = {0,0,0}; | 205 | static char tmp[3] = {0,0,0}; |
206 | if(i==ie) | 206 | if(i==ie) |
207 | throw failed_conversion(OPKELE_CP_ "trailing percent in the url-encoded string"); | 207 | throw failed_conversion(OPKELE_CP_ "trailing percent in the url-encoded string"); |
208 | tmp[0] = *(i++); | 208 | tmp[0] = *(i++); |
209 | if(i==ie) | 209 | if(i==ie) |
210 | throw failed_conversion(OPKELE_CP_ "not enough hexadecimals after the percent sign in url-encoded string"); | 210 | throw failed_conversion(OPKELE_CP_ "not enough hexadecimals after the percent sign in url-encoded string"); |
211 | tmp[1] = *i; | 211 | tmp[1] = *i; |
212 | if(!(isxdigit(tmp[0]) && isxdigit(tmp[1]))) | 212 | if(!(isxdigit(tmp[0]) && isxdigit(tmp[1]))) |
213 | throw failed_conversion(OPKELE_CP_ "non-hex follows percent in url-encoded string"); | 213 | throw failed_conversion(OPKELE_CP_ "non-hex follows percent in url-encoded string"); |
214 | *(ii++) = strtol(tmp,0,16); | 214 | *(ii++) = (char)strtol(tmp,0,16); |
215 | break; | 215 | break; |
216 | default: | 216 | default: |
217 | *(ii++) = *i; break; | 217 | *(ii++) = *i; break; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | return rv; | 220 | return rv; |
221 | } | 221 | } |
222 | 222 | ||
223 | string attr_escape(const string& str) { | 223 | string attr_escape(const string& str) { |
224 | static const char *unsafechars = "<>&\n\"'"; | 224 | static const char *unsafechars = "<>&\n\"'"; |
225 | string rv; | 225 | string rv; |
226 | string::size_type p=0; | 226 | string::size_type p=0; |
227 | while(true) { | 227 | while(true) { |
228 | string::size_type us = str.find_first_of(unsafechars,p); | 228 | string::size_type us = str.find_first_of(unsafechars,p); |
229 | if(us==string::npos) { | 229 | if(us==string::npos) { |
230 | if(p!=str.length()) | 230 | if(p!=str.length()) |
@@ -335,36 +335,36 @@ namespace opkele { | |||
335 | if(unsafe==string::npos) { | 335 | if(unsafe==string::npos) { |
336 | pseg.append(uri,n,ul-n-1); n = ul-1; | 336 | pseg.append(uri,n,ul-n-1); n = ul-1; |
337 | }else{ | 337 | }else{ |
338 | pseg.append(uri,n,unsafe-n); | 338 | pseg.append(uri,n,unsafe-n); |
339 | n = unsafe; | 339 | n = unsafe; |
340 | } | 340 | } |
341 | char c = uri[n++]; | 341 | char c = uri[n++]; |
342 | if(c=='%') { | 342 | if(c=='%') { |
343 | if((n+1)>=ul) | 343 | if((n+1)>=ul) |
344 | throw bad_input(OPKELE_CP_ "Unexpected end of URI encountered while parsing percent-encoded character"); | 344 | throw bad_input(OPKELE_CP_ "Unexpected end of URI encountered while parsing percent-encoded character"); |
345 | tmp[0] = uri[n++]; | 345 | tmp[0] = uri[n++]; |
346 | tmp[1] = uri[n++]; | 346 | tmp[1] = uri[n++]; |
347 | if(!( isxdigit(tmp[0]) && isxdigit(tmp[1]) )) | 347 | if(!( isxdigit(tmp[0]) && isxdigit(tmp[1]) )) |
348 | throw bad_input(OPKELE_CP_ "Invalid percent-encoded character in URI being normalized"); | 348 | throw bad_input(OPKELE_CP_ "Invalid percent-encoded character in URI being normalized"); |
349 | int cc = strtol(tmp,0,16); | 349 | int cc = strtol(tmp,0,16); |
350 | if( isalpha(cc) || isdigit(cc) || strchr("._~-",cc) ) | 350 | if( isalpha(cc) || isdigit(cc) || strchr("._~-",cc) ) |
351 | pseg += cc; | 351 | pseg += (char)cc; |
352 | else{ | 352 | else{ |
353 | pseg += '%'; | 353 | pseg += '%'; |
354 | pseg += toupper(tmp[0]); pseg += toupper(tmp[1]); | 354 | pseg += (char)toupper(tmp[0]); pseg += (char)toupper(tmp[1]); |
355 | } | 355 | } |
356 | }else if(qf) { | 356 | }else if(qf) { |
357 | rv += pseg; rv += c; | 357 | rv += pseg; rv += c; |
358 | pseg.clear(); | 358 | pseg.clear(); |
359 | }else if(n>=ul || strchr("?/#",c)) { | 359 | }else if(n>=ul || strchr("?/#",c)) { |
360 | if(pseg.empty() || pseg==".") { | 360 | if(pseg.empty() || pseg==".") { |
361 | }else if(pseg=="..") { | 361 | }else if(pseg=="..") { |
362 | if(psegs.size()>1) { | 362 | if(psegs.size()>1) { |
363 | rv.resize(psegs.top()); psegs.pop(); | 363 | rv.resize(psegs.top()); psegs.pop(); |
364 | } | 364 | } |
365 | }else{ | 365 | }else{ |
366 | psegs.push(rv.length()); | 366 | psegs.push(rv.length()); |
367 | if(c!='/') { | 367 | if(c!='/') { |
368 | pseg += c; | 368 | pseg += c; |
369 | qf = true; | 369 | qf = true; |
370 | } | 370 | } |