Changeset 5290 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Oct 6, 2005, 11:41:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_buffer.cc
r5254 r5290 134 134 void ShellBuffer::addBufferLine(const char* line, va_list arguments) 135 135 { 136 vsprintf(this->bufferArray, line, arguments);137 138 136 char* inputEnd; 139 137 char* newLineBegin; 140 138 char* newLineEnd; 141 139 142 // check if we have something left in the buffers 140 // copy the output to the bufferArray 141 vsprintf(this->bufferArray, line, arguments); 142 143 // check if we have something left in the buffers 144 // if so, append the new String to this one. 143 145 if (unlikely(this->keepBuffer)) 144 146 { 145 147 strcat(this->keepBufferArray, this->bufferArray); 146 inputEnd = this->keepBufferArray + strlen(this-> keepBufferArray);148 inputEnd = this->keepBufferArray + strlen(this->bufferArray); 147 149 newLineBegin = this->keepBufferArray; 148 150 this->keepBuffer = false; … … 154 156 } 155 157 156 157 while (newLineBegin < inputEnd 158 // adding all the new Lines 159 while (newLineBegin < inputEnd) 158 160 { 159 161 newLineEnd = strchr(newLineBegin, '\n'); 160 if ( newLineEnd != NULL && *newLineEnd == '\n')162 if (likely(newLineEnd != NULL && *newLineEnd == '\n')) 161 163 *newLineEnd = '\0'; 162 164 else 163 165 { 164 // newLineEnd = newLineBegin + strlen(newLineBegin);165 166 unsigned int len = strlen(newLineBegin); 166 strncpy(this->keepBufferArray, newLineBegin, len); 167 char* copyBuffer = new char[len+1]; 168 strcpy(copyBuffer, newLineBegin); 169 strncpy(this->keepBufferArray, copyBuffer, len); 170 delete[] copyBuffer; 167 171 this->keepBufferArray[len] = '\0'; 168 172 this->keepBuffer = true;
Note: See TracChangeset
for help on using the changeset viewer.