diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llcommon/llstreamtools.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llcommon/llstreamtools.cpp')
-rw-r--r-- | linden/indra/llcommon/llstreamtools.cpp | 81 |
1 files changed, 13 insertions, 68 deletions
diff --git a/linden/indra/llcommon/llstreamtools.cpp b/linden/indra/llcommon/llstreamtools.cpp index 669bdd0..b95ee60 100644 --- a/linden/indra/llcommon/llstreamtools.cpp +++ b/linden/indra/llcommon/llstreamtools.cpp | |||
@@ -263,20 +263,14 @@ bool get_word(std::string& output_string, std::istream& input_stream, int n) | |||
263 | // get everything up to and including the next newline | 263 | // get everything up to and including the next newline |
264 | bool get_line(std::string& output_string, std::istream& input_stream) | 264 | bool get_line(std::string& output_string, std::istream& input_stream) |
265 | { | 265 | { |
266 | output_string.clear(); | ||
266 | char c = input_stream.get(); | 267 | char c = input_stream.get(); |
267 | while (input_stream.good()) | 268 | while (input_stream.good()) |
268 | { | 269 | { |
269 | if ('\r' == c) | 270 | output_string += c; |
270 | { | 271 | if ('\n' == c) |
271 | // skip carriage returns | ||
272 | } | ||
273 | else | ||
274 | { | 272 | { |
275 | output_string += c; | 273 | break; |
276 | if ('\n' == c) | ||
277 | { | ||
278 | break; | ||
279 | } | ||
280 | } | 274 | } |
281 | c = input_stream.get(); | 275 | c = input_stream.get(); |
282 | } | 276 | } |
@@ -288,27 +282,21 @@ bool get_line(std::string& output_string, std::istream& input_stream) | |||
288 | // add a newline on the end if bail before actual line ending | 282 | // add a newline on the end if bail before actual line ending |
289 | bool get_line(std::string& output_string, std::istream& input_stream, int n) | 283 | bool get_line(std::string& output_string, std::istream& input_stream, int n) |
290 | { | 284 | { |
285 | output_string.clear(); | ||
291 | int char_count = 0; | 286 | int char_count = 0; |
292 | char c = input_stream.get(); | 287 | char c = input_stream.get(); |
293 | while (input_stream.good() && char_count < n) | 288 | while (input_stream.good() && char_count < n) |
294 | { | 289 | { |
295 | char_count++; | 290 | char_count++; |
296 | output_string += c; | 291 | output_string += c; |
297 | if ('\r' == c) | 292 | if ('\n' == c) |
298 | { | 293 | { |
299 | // skip carriage returns | 294 | break; |
300 | } | 295 | } |
301 | else | 296 | if (char_count >= n) |
302 | { | 297 | { |
303 | if ('\n' == c) | 298 | output_string.append("\n"); |
304 | { | 299 | break; |
305 | break; | ||
306 | } | ||
307 | if (char_count >= n) | ||
308 | { | ||
309 | output_string.append("\n"); | ||
310 | break; | ||
311 | } | ||
312 | } | 300 | } |
313 | c = input_stream.get(); | 301 | c = input_stream.get(); |
314 | } | 302 | } |
@@ -408,49 +396,6 @@ void replace_newlines_with_whitespace(std::string& line) | |||
408 | } | 396 | } |
409 | } | 397 | } |
410 | 398 | ||
411 | // returns 1 for solitary "{" | ||
412 | // returns -1 for solitary "}" | ||
413 | // otherwise returns 0 | ||
414 | int get_brace_count(const std::string& line) | ||
415 | { | ||
416 | int index = 0; | ||
417 | int line_size = line.size(); | ||
418 | char c = 0; | ||
419 | while (index < line_size) | ||
420 | { | ||
421 | c = line[index]; | ||
422 | index++; | ||
423 | if (!isspace(c)) | ||
424 | { | ||
425 | break; | ||
426 | } | ||
427 | } | ||
428 | char brace = c; | ||
429 | // make sure the rest of the line is whitespace | ||
430 | while (index < line_size) | ||
431 | { | ||
432 | c = line[index]; | ||
433 | if (!isspace(c)) | ||
434 | { | ||
435 | break; | ||
436 | } | ||
437 | index++; | ||
438 | } | ||
439 | if ('\n' != c) | ||
440 | { | ||
441 | return 0; | ||
442 | } | ||
443 | if ('{' == brace) | ||
444 | { | ||
445 | return 1; | ||
446 | } | ||
447 | else if ('}' == brace) | ||
448 | { | ||
449 | return -1; | ||
450 | } | ||
451 | return 0; | ||
452 | } | ||
453 | |||
454 | // erases any double-quote characters in 'line' | 399 | // erases any double-quote characters in 'line' |
455 | void remove_double_quotes(std::string& line) | 400 | void remove_double_quotes(std::string& line) |
456 | { | 401 | { |
@@ -498,7 +443,7 @@ void get_keyword_and_value(std::string& keyword, | |||
498 | } | 443 | } |
499 | 444 | ||
500 | // get the keyword | 445 | // get the keyword |
501 | keyword.assign(""); | 446 | keyword.clear(); |
502 | while (line_index < line_size) | 447 | while (line_index < line_size) |
503 | { | 448 | { |
504 | c = line[line_index]; | 449 | c = line[line_index]; |
@@ -510,6 +455,8 @@ void get_keyword_and_value(std::string& keyword, | |||
510 | line_index++; | 455 | line_index++; |
511 | } | 456 | } |
512 | 457 | ||
458 | // get the value | ||
459 | value.clear(); | ||
513 | if (keyword.size() > 0 | 460 | if (keyword.size() > 0 |
514 | && '\r' != line[line_index] | 461 | && '\r' != line[line_index] |
515 | && '\n' != line[line_index]) | 462 | && '\n' != line[line_index]) |
@@ -523,8 +470,6 @@ void get_keyword_and_value(std::string& keyword, | |||
523 | line_index++; | 470 | line_index++; |
524 | } | 471 | } |
525 | 472 | ||
526 | // get the value | ||
527 | value.assign(""); | ||
528 | while (line_index < line_size) | 473 | while (line_index < line_size) |
529 | { | 474 | { |
530 | c = line[line_index]; | 475 | c = line[line_index]; |