used the following commands: find . -type f -name "*.h" | xargs sed -i 's/\s*$//g' find . -type f -name "*.cpp" | xargs sed -i 's/\s*$//g'
Showing the changes to src/core/util_string.cpp (1 of 90 files). Show all
Unified · Split
| @@ -218,30 +218,30 @@ string rtrim( const string & val ) · 217 unmodified lines | |||
| 218 | // name: extract_args() | 218 | // name: extract_args() |
| 219 | // desc: extract argument from format filename:arg1:arg2:etc | 219 | // desc: extract argument from format filename:arg1:arg2:etc |
| 220 | //----------------------------------------------------------------------------- | 220 | //----------------------------------------------------------------------------- |
| 221 | t_CKBOOL extract_args( const string & token, | 221 | t_CKBOOL extract_args( const string & token, |
| 222 | string & filename, vector<string> & args ) | 222 | string & filename, vector<string> & args ) |
| 223 | { | 223 | { |
| 224 | // clear vector | 224 | // clear vector |
| 225 | args.clear(); | 225 | args.clear(); |
| 226 | // clear filename | 226 | // clear filename |
| 227 | filename = ""; | 227 | filename = ""; |
| 228 | 228 | ||
| 229 | // last : found pos | 229 | // last : found pos |
| 230 | t_CKINT prev_pos = 0; | 230 | t_CKINT prev_pos = 0; |
| 231 | // curr : pos | 231 | // curr : pos |
| 232 | t_CKINT i = 0; | 232 | t_CKINT i = 0; |
| 233 | 233 | ||
| 234 | string tmp; | 234 | string tmp; |
| 235 | 235 | ||
| 236 | // copy and trim | 236 | // copy and trim |
| 237 | string s = trim( token ); | 237 | string s = trim( token ); |
| 238 | 238 | ||
| 239 | // ignore second character as arg separator if its : on Windows | 239 | // ignore second character as arg separator if its : on Windows |
| 240 | t_CKBOOL ignoreSecond = FALSE; | 240 | t_CKBOOL ignoreSecond = FALSE; |
| 241 | #ifdef __PLATFORM_WIN32__ | 241 | #ifdef __PLATFORM_WIN32__ |
| 242 | ignoreSecond = TRUE; | 242 | ignoreSecond = TRUE; |
| 243 | #endif // __PLATFORM_WIN32__ | 243 | #endif // __PLATFORM_WIN32__ |
| 244 | 244 | ||
| 245 | // detect | 245 | // detect |
| 246 | t_CKBOOL scan = FALSE; | 246 | t_CKBOOL scan = FALSE; |
| 247 | t_CKBOOL ret = TRUE; | 247 | t_CKBOOL ret = TRUE; |
| @@ -253,14 +253,14 @@ t_CKBOOL extract_args( const string & token, · 5 unmodified lines | |||
| 253 | scan = TRUE; | 253 | scan = TRUE; |
| 254 | break; | 254 | break; |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | // mad... | 257 | // mad... |
| 258 | if( scan ) | 258 | if( scan ) |
| 259 | { | 259 | { |
| 260 | mask = new char[s.length()]; | 260 | mask = new char[s.length()]; |
| 261 | // zero | 261 | // zero |
| 262 | memset(mask, 0, s.length()*sizeof(char)); | 262 | memset(mask, 0, s.length()*sizeof(char)); |
| 263 | 263 | ||
| 264 | // loop through | 264 | // loop through |
| 265 | for( i = 0; i < s.length(); i++ ) | 265 | for( i = 0; i < s.length(); i++ ) |
| 266 | { | 266 | { |
| @@ -271,7 +271,7 @@ t_CKBOOL extract_args( const string & token, · 4 unmodified lines | |||
| 271 | // mask[i] = 1; | 271 | // mask[i] = 1; |
| 272 | // break; // added 1.3.1.1 | 272 | // break; // added 1.3.1.1 |
| 273 | // } | 273 | // } |
| 274 | 274 | ||
| 275 | // 1.3.2.0: spencer and ge fixed this, requiring \ to escape : | 275 | // 1.3.2.0: spencer and ge fixed this, requiring \ to escape : |
| 276 | if( s[i] == '\\' && (i+1) < s.length() ) | 276 | if( s[i] == '\\' && (i+1) < s.length() ) |
| 277 | { | 277 | { |
| @@ -318,15 +318,15 @@ t_CKBOOL extract_args( const string & token, · 40 unmodified lines | |||
| 318 | ret = FALSE; | 318 | ret = FALSE; |
| 319 | goto done; | 319 | goto done; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | // copy | 322 | // copy |
| 323 | if( filename == "" ) | 323 | if( filename == "" ) |
| 324 | filename = tmp; | 324 | filename = tmp; |
| 325 | else | 325 | else |
| 326 | args.push_back( tmp ); | 326 | args.push_back( tmp ); |
| 327 | 327 | ||
| 328 | tmp = ""; | 328 | tmp = ""; |
| 329 | 329 | ||
| 330 | // update | 330 | // update |
| 331 | prev_pos = i + 1; | 331 | prev_pos = i + 1; |
| 332 | } | 332 | } |
| @@ -334,11 +334,11 @@ t_CKBOOL extract_args( const string & token, · 1 unmodified line | |||
| 334 | { | 334 | { |
| 335 | tmp.append(1, s[i]); | 335 | tmp.append(1, s[i]); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | // reset | 338 | // reset |
| 339 | ignoreNext = FALSE; | 339 | ignoreNext = FALSE; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | // get the remainder, if any | 342 | // get the remainder, if any |
| 343 | if( tmp.length() ) | 343 | if( tmp.length() ) |
| 344 | { | 344 | { |
| @@ -348,7 +348,7 @@ t_CKBOOL extract_args( const string & token, · 3 unmodified lines | |||
| 348 | else | 348 | else |
| 349 | args.push_back( tmp ); | 349 | args.push_back( tmp ); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | // testing code - spencer 1.3.2.0 | 352 | // testing code - spencer 1.3.2.0 |
| 353 | // CK_FPRINTF_STDERR( "INPUT: %s\n", token.c_str() ); | 353 | // CK_FPRINTF_STDERR( "INPUT: %s\n", token.c_str() ); |
| 354 | // CK_FPRINTF_STDERR( "FILENAME: %s\n", filename.c_str() ); | 354 | // CK_FPRINTF_STDERR( "FILENAME: %s\n", filename.c_str() ); |
| @@ -467,21 +467,21 @@ std::string globTildePath( const std::string & path ) · 112 unmodified lines | |||
| 467 | std::string get_full_path( const std::string & fp ) | 467 | std::string get_full_path( const std::string & fp ) |
| 468 | { | 468 | { |
| 469 | #ifndef __PLATFORM_WIN32__ | 469 | #ifndef __PLATFORM_WIN32__ |
| 470 | 470 | ||
| 471 | char buf[PATH_MAX]; | 471 | char buf[PATH_MAX]; |
| 472 | char * result = realpath(fp.c_str(), buf); | 472 | char * result = realpath(fp.c_str(), buf); |
| 473 | 473 | ||
| 474 | // try with .ck extension | 474 | // try with .ck extension |
| 475 | if(result == NULL && !str_endsin(fp.c_str(), ".ck")) | 475 | if(result == NULL && !str_endsin(fp.c_str(), ".ck")) |
| 476 | result = realpath((fp + ".ck").c_str(), buf); | 476 | result = realpath((fp + ".ck").c_str(), buf); |
| 477 | 477 | ||
| 478 | if(result == NULL) | 478 | if(result == NULL) |
| 479 | return fp; | 479 | return fp; |
| 480 | else | 480 | else |
| 481 | return buf; | 481 | return buf; |
| 482 | 482 | ||
| 483 | #else // | 483 | #else // |
| 484 | 484 | ||
| 485 | char buf[MAX_PATH]; | 485 | char buf[MAX_PATH]; |
| 486 | DWORD result = GetFullPathName(fp.c_str(), MAX_PATH, buf, NULL); | 486 | DWORD result = GetFullPathName(fp.c_str(), MAX_PATH, buf, NULL); |
| 487 | 487 | ||
| @@ -528,13 +528,13 @@ std::string expand_filepath( std::string & fp, t_CKBOOL ensurePathExists ) · 40 unmodified lines | |||
| 528 | std::string extract_filepath_dir(std::string &filepath) | 528 | std::string extract_filepath_dir(std::string &filepath) |
| 529 | { | 529 | { |
| 530 | char path_separator = '/'; | 530 | char path_separator = '/'; |
| 531 | 531 | ||
| 532 | //#ifdef __WINDOWS_DS__ | 532 | //#ifdef __WINDOWS_DS__ |
| 533 | // path_separator = '\\'; | 533 | // path_separator = '\\'; |
| 534 | //#else | 534 | //#else |
| 535 | // path_separator = '/'; | 535 | // path_separator = '/'; |
| 536 | //#endif | 536 | //#endif |
| 537 | 537 | ||
| 538 | // if the last character is a slash, skip it | 538 | // if the last character is a slash, skip it |
| 539 | t_CKINT i = filepath.rfind(path_separator); | 539 | t_CKINT i = filepath.rfind(path_separator); |
| 540 | // if not separator found, return empty string | 540 | // if not separator found, return empty string |
| @@ -543,7 +543,7 @@ std::string extract_filepath_dir(std::string &filepath) · 2 unmodified lines | |||
| 543 | // skip any/all extra trailing slashes | 543 | // skip any/all extra trailing slashes |
| 544 | while( i > 0 && filepath[i-1] == path_separator ) | 544 | while( i > 0 && filepath[i-1] == path_separator ) |
| 545 | i--; | 545 | i--; |
| 546 | 546 | ||
| 547 | // change spencer 2014-7-17: include trailing slash | 547 | // change spencer 2014-7-17: include trailing slash |
| 548 | return std::string(filepath, 0, i+1); | 548 | return std::string(filepath, 0, i+1); |
| 549 | } | 549 | } |
| @@ -570,7 +570,7 @@ string dir_go_up( const string & dir, t_CKINT numUp ) · 20 unmodified lines | |||
| 570 | // skip any trailing slashes | 570 | // skip any trailing slashes |
| 571 | while( pos > 0 && dir[pos-1] == path_separator ) | 571 | while( pos > 0 && dir[pos-1] == path_separator ) |
| 572 | pos--; | 572 | pos--; |
| 573 | 573 | ||
| 574 | // loop | 574 | // loop |
| 575 | while( numUp > 0 ) | 575 | while( numUp > 0 ) |
| 576 | { | 576 | { |
| @@ -614,13 +614,13 @@ void parse_path_list( std::string & str, std::list<std::string> & lst ) · 37 unmodified lines | |||
| 614 | const char separator = ':'; | 614 | const char separator = ':'; |
| 615 | #endif | 615 | #endif |
| 616 | std::string::size_type i = 0, last = 0; | 616 | std::string::size_type i = 0, last = 0; |
| 617 | while( last < str.size() && | 617 | while( last < str.size() && |
| 618 | ( i = str.find( separator, last ) ) != std::string::npos ) | 618 | ( i = str.find( separator, last ) ) != std::string::npos ) |
| 619 | { | 619 | { |
| 620 | lst.push_back( str.substr( last, i - last ) ); | 620 | lst.push_back( str.substr( last, i - last ) ); |
| 621 | last = i + 1; | 621 | last = i + 1; |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | lst.push_back( str.substr( last, str.size() - last ) ); | 624 | lst.push_back( str.substr( last, str.size() - last ) ); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| @@ -660,7 +660,7 @@ t_CKBOOL str_endsin( const char * str, const char * end ) · 33 unmodified lines | |||
| 660 | { | 660 | { |
| 661 | size_t len = strlen(str); | 661 | size_t len = strlen(str); |
| 662 | size_t endlen = strlen(end); | 662 | size_t endlen = strlen(end); |
| 663 | 663 | ||
| 664 | return strncmp(str+(len-endlen), end, endlen) == 0; | 664 | return strncmp(str+(len-endlen), end, endlen) == 0; |
| 665 | } | 665 | } |
| 666 | 666 | ||