From d7f5f66277d335b596873151a252beb3fbc40537 Mon Sep 17 00:00:00 2001 From: Jimmy Zhuo Date: Tue, 6 Aug 2013 10:51:11 +0800 Subject: [PATCH] avoids to output some linenoise error info by default --- 3rdparty/linenoise/linenoise.c | 41 +++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/3rdparty/linenoise/linenoise.c b/3rdparty/linenoise/linenoise.c index cd16395f09..c5f4630d32 100644 --- a/3rdparty/linenoise/linenoise.c +++ b/3rdparty/linenoise/linenoise.c @@ -96,6 +96,7 @@ #include #include #endif + #include #include #include @@ -103,10 +104,11 @@ #include #include #include "linenoise.h" + #ifdef WIN32 - #include - #define snprintf _snprintf - #define __NOTUSED(V) ((void) V) +#include +#define snprintf _snprintf +#define __NOTUSED(V) ((void) V) #endif #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 @@ -275,23 +277,12 @@ static int win32read(char *c) { return -1; /* Makes compiler happy */ } -#ifdef __STRICT_ANSI__ -char *strdup(const char *s) { - size_t l = strlen(s)+1; - char *p = malloc(l); - - memcpy(p,s,l); - return p; -} -#endif /* __STRICT_ANSI__ */ - - /* ======================= Clear Screen API for Windows ====================== */ /* see http://support.microsoft.com/kb/99261 */ /* Standard error macro for reporting API errors */ - #define PERR(bSuccess, api) if(!(bSuccess)) \ +#define PERR(bSuccess, api) if(!(bSuccess)) \ printf("%s:Error %d from %s on line %d\n", __FILE__, GetLastError(), api, __LINE__); void cls( HANDLE hConsole ) @@ -306,29 +297,49 @@ char *strdup(const char *s) { /* get the number of character cells in the current buffer */ bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); +#ifdef LN_DEBUG PERR( bSuccess, "GetConsoleScreenBufferInfo" ); +#endif dwConSize = csbi.dwSize.X * csbi.dwSize.Y; /* fill the entire screen with blanks */ bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten ); +#ifdef LN_DEBUG PERR( bSuccess, "FillConsoleOutputCharacter" ); +#endif /* get the current text attribute */ bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi ); +#ifdef LN_DEBUG PERR( bSuccess, "ConsoleScreenBufferInfo" ); +#endif /* now set the buffer's attributes accordingly */ bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten ); +#ifdef LN_DEBUG PERR( bSuccess, "FillConsoleOutputAttribute" ); +#endif /* put the cursor at (0, 0) */ bSuccess = SetConsoleCursorPosition( hConsole, coordScreen ); +#ifdef LN_DEBUG PERR( bSuccess, "SetConsoleCursorPosition" ); +#endif return; } +#ifdef __STRICT_ANSI__ +char *strdup(const char *s) { + size_t l = strlen(s)+1; + char *p = malloc(l); + + memcpy(p,s,l); + return p; +} +#endif /* __STRICT_ANSI__ */ + #endif /* WIN32 */ /* ======================= Low level terminal handling ====================== */