summaryrefslogtreecommitdiff
path: root/src/mongo/shell/linenoise.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-06-10 18:41:42 -0400
committerAndrew Morrow <acm@mongodb.com>2015-06-10 22:37:55 -0400
commit1360f243ee7fa662c0ded25a9bc479aa47388446 (patch)
tree4e612c60d4e45386800e147e5d67366c61284d71 /src/mongo/shell/linenoise.cpp
parentd7d1fdb75966c684e9a42150e6e9b69c4a10ee08 (diff)
downloadmongo-1360f243ee7fa662c0ded25a9bc479aa47388446.tar.gz
SERVER-17308 Replace boost::scoped_array<T> with std::unique_ptr<T[]>
Diffstat (limited to 'src/mongo/shell/linenoise.cpp')
-rw-r--r--src/mongo/shell/linenoise.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mongo/shell/linenoise.cpp b/src/mongo/shell/linenoise.cpp
index 753f1154f27..43b42b9f028 100644
--- a/src/mongo/shell/linenoise.cpp
+++ b/src/mongo/shell/linenoise.cpp
@@ -119,12 +119,11 @@
#include "mk_wcwidth.h"
#include <string>
#include <vector>
-#include <boost/smart_ptr/scoped_array.hpp>
using std::string;
using std::vector;
-using boost::scoped_array;
+using std::unique_ptr;
using linenoise_utf8::UChar8;
using linenoise_utf8::UChar32;
@@ -1652,7 +1651,7 @@ int InputBuffer::incrementalHistorySearch( PromptBase& pi, int startChar ) {
if ( historyIndex == historyLen - 1 ) {
free( history[historyLen - 1] );
bufferSize = sizeof( UChar32 ) * len + 1;
- scoped_array< UChar8 > tempBuffer( new UChar8[ bufferSize ] );
+ unique_ptr< UChar8 []> tempBuffer( new UChar8[ bufferSize ] );
copyString32to8( tempBuffer.get(), buf32, bufferSize );
history[ historyLen - 1 ] = reinterpret_cast< UChar8 * >( strdup( reinterpret_cast< const char * >( tempBuffer.get() ) ) );
}
@@ -1759,7 +1758,7 @@ int InputBuffer::incrementalHistorySearch( PromptBase& pi, int startChar ) {
enableRawMode(); // Back from Linux shell, re-enter raw mode
{
bufferSize = historyLineLength + 1;
- scoped_array< UChar32 > tempUnicode( new UChar32[ bufferSize ] );
+ unique_ptr< UChar32 []> tempUnicode( new UChar32[ bufferSize ] );
copyString8to32( tempUnicode.get(), history[ historyIndex ], bufferSize, ucharCount, errorCode );
dynamicRefresh( dp, tempUnicode.get(), historyLineLength, historyLinePosition );
}
@@ -1770,7 +1769,7 @@ int InputBuffer::incrementalHistorySearch( PromptBase& pi, int startChar ) {
// these characters update the search string, and hence the selected input line
case ctrlChar( 'H' ): // backspace/ctrl-H, delete char to left of cursor
if ( dp.searchTextLen > 0 ) {
- scoped_array<UChar32> tempUnicode( new UChar32[ dp.searchTextLen ] );
+ unique_ptr<UChar32[]> tempUnicode( new UChar32[ dp.searchTextLen ] );
--dp.searchTextLen;
dp.searchText[ dp.searchTextLen ] = 0;
copyString32( tempUnicode.get(), dp.searchText.get(), dp.searchTextLen + 1 );
@@ -1786,7 +1785,7 @@ int InputBuffer::incrementalHistorySearch( PromptBase& pi, int startChar ) {
default:
if ( !isControlChar( c ) && c <= 0x0010FFFF ) { // not an action character
- scoped_array< UChar32 > tempUnicode( new UChar32[ dp.searchTextLen + 2 ] );
+ unique_ptr< UChar32 []> tempUnicode( new UChar32[ dp.searchTextLen + 2 ] );
copyString32( tempUnicode.get(), dp.searchText.get(), dp.searchTextLen + 2 );
tempUnicode[ dp.searchTextLen ] = c;
tempUnicode[ dp.searchTextLen + 1 ] = 0;
@@ -1889,7 +1888,7 @@ int InputBuffer::getInputLine( PromptBase& pi ) {
// The latest history entry is always our current buffer
if ( len > 0 ) {
size_t bufferSize = sizeof( UChar32 ) * len + 1;
- scoped_array< char > tempBuffer( new char[ bufferSize ] );
+ unique_ptr< char []> tempBuffer( new char[ bufferSize ] );
copyString32to8( reinterpret_cast< UChar8 * >( tempBuffer.get() ), buf32, bufferSize );
linenoiseHistoryAdd( tempBuffer.get() );
}
@@ -2193,7 +2192,7 @@ int InputBuffer::getInputLine( PromptBase& pi ) {
if ( historyIndex == historyLen - 1 ) {
free( history[historyLen - 1] );
size_t tempBufferSize = sizeof( UChar32 ) * len + 1;
- scoped_array< UChar8 > tempBuffer( new UChar8[ tempBufferSize ] );
+ unique_ptr< UChar8 []> tempBuffer( new UChar8[ tempBufferSize ] );
copyString32to8( tempBuffer.get(), buf32, tempBufferSize );
history[historyLen - 1] = reinterpret_cast< UChar8 * >( strdup( reinterpret_cast< const char * >( tempBuffer.get() ) ) );
}
@@ -2385,7 +2384,7 @@ int InputBuffer::getInputLine( PromptBase& pi ) {
if ( historyIndex == historyLen - 1 ) {
free( history[historyLen - 1] );
size_t tempBufferSize = sizeof( UChar32 ) * len + 1;
- scoped_array< UChar8 > tempBuffer( new UChar8[ tempBufferSize ] );
+ unique_ptr< UChar8 []> tempBuffer( new UChar8[ tempBufferSize ] );
copyString32to8( tempBuffer.get(), buf32, tempBufferSize );
history[historyLen - 1] = reinterpret_cast< UChar8 * >( strdup( reinterpret_cast< const char * >( tempBuffer.get() ) ) );
}
@@ -2466,7 +2465,7 @@ void linenoisePreloadBuffer( const char* preloadText ) {
return;
}
int bufferSize = strlen( preloadText ) + 1;
- scoped_array< char > tempBuffer( new char[ bufferSize ] );
+ unique_ptr< char []> tempBuffer( new char[ bufferSize ] );
strncpy( &tempBuffer[0], preloadText, bufferSize );
// remove characters that won't display correctly
@@ -2535,7 +2534,7 @@ char* linenoise( const char* prompt ) {
if ( write32( 1, pi.promptText.get(), pi.promptChars ) == -1 ) return 0;
fflush( stdout );
if ( preloadedBufferContents.empty() ) {
- scoped_array<char> buf8( new char[ LINENOISE_MAX_LINE ] );
+ unique_ptr<char[]> buf8( new char[ LINENOISE_MAX_LINE ] );
if ( fgets( buf8.get(), LINENOISE_MAX_LINE, stdin ) == NULL ) {
return NULL;
}
@@ -2568,13 +2567,13 @@ char* linenoise( const char* prompt ) {
return NULL;
}
size_t bufferSize = sizeof( UChar32 ) * ib.length() + 1;
- scoped_array<UChar8> buf8( new UChar8[ bufferSize ] );
+ unique_ptr<UChar8[]> buf8( new UChar8[ bufferSize ] );
copyString32to8( buf8.get(), buf32, bufferSize );
return strdup( reinterpret_cast<char*>( buf8.get() ) ); // caller must free buffer
}
}
else { // input not from a terminal, we should work with piped input, i.e. redirected stdin
- scoped_array<char> buf8( new char[ LINENOISE_MAX_LINE ] );
+ unique_ptr<char[]> buf8( new char[ LINENOISE_MAX_LINE ] );
if ( fgets( buf8.get(), LINENOISE_MAX_LINE, stdin ) == NULL ) {
return NULL;
}