Changeset 380 for trunk/src/lua/lua_path.cc
- Timestamp:
- 05/29/15 17:28:16 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_path.cc
r376 r380 32 32 } 33 33 34 void lua::path::push( nv:: size_tvalue )34 void lua::path::push( nv::uint32 value ) 35 35 { 36 36 m_elements[ m_count ].value = value; … … 50 50 if (m_count == 0) return false; 51 51 if (global) lua_pushglobaltable( L ); 52 for ( inti = 0; i < m_count; ++i )52 for ( uint32 i = 0; i < m_count; ++i ) 53 53 { 54 54 if ( lua_istable( L, -1 ) ) … … 76 76 std::string nv::lua::path::to_string() const 77 77 { 78 std::string result; 79 result.reserve( 64 ); 78 char buffer[64]; 79 char* start = buffer; 80 char* current = buffer; 80 81 bool dot = false; 82 bool oos = false; 81 83 for ( const element& e : m_elements ) 82 84 { 83 if ( dot ) result.append("."); 85 if ( current - start > 48 ) { oos = true; break; } 86 if ( dot ) *current++ = '.'; 84 87 if ( e.length == 0 ) 85 88 { 86 result.append("[" + nv::to_string( e.value ) + "]" ); 89 *current++ = '['; 90 current += uint32_to_buffer( e.value, current ); 91 *current++ = ']'; 87 92 dot = false; 88 93 } 89 94 else 90 95 { 91 result.append( e.str, e.length ); 96 if ( size_t(current - start) + e.length > 60 ) { oos = true; break; } 97 nvmemcpy( current, e.str, e.length ); 98 current += e.length; 92 99 dot = true; 93 100 } 94 101 } 95 return result; 102 if (oos) 103 { 104 *current++ = '.'; 105 *current++ = '.'; 106 *current++ = '.'; 107 } 108 *current++ = '\0'; 109 return std::string( buffer, size_t(current - start - 1) ); 96 110 }
Note: See TracChangeset
for help on using the changeset viewer.