Replace fprintf(stderr,...) in code by a macro FDPRINTF

This commit is contained in:
Abs62 2011-06-20 00:29:11 +04:00
parent 36e509a2ab
commit 7de7fcc8df
11 changed files with 45 additions and 42 deletions

10
bgl.cc
View file

@ -192,8 +192,8 @@ namespace
if ( result < 0 )
{
fprintf( stderr, "Failed to decode utf8 of headword %s, skipping it.\n",
word.c_str() );
FDPRINTF( stderr, "Failed to decode utf8 of headword %s, skipping it.\n",
word.c_str() );
return;
}
@ -956,8 +956,8 @@ sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name
if ( compress( &compressedData.front(), &compressedSize,
(unsigned char const *) data, size ) != Z_OK )
{
fprintf( stderr, "Failed to compress the body of resource %s, dropping it.\n",
filename.c_str() );
FDPRINTF( stderr, "Failed to compress the body of resource %s, dropping it.\n",
filename.c_str() );
return;
}
@ -1010,7 +1010,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
if ( !b.read( sourceCharset, targetCharset ) )
{
fprintf( stderr, "Failed to start reading from %s, skipping it\n", i->c_str() );
FDPRINTF( stderr, "Failed to start reading from %s, skipping it\n", i->c_str() );
continue;
}

View file

@ -273,7 +273,7 @@ bool Babylon::read(std::string &source_charset, std::string &target_charset)
if ( isUtf8File )
{
//fprintf( stderr, "%s: utf8 file.\n", m_title.c_str() );
//FDPRINTF( stderr, "%s: utf8 file.\n", m_title.c_str() );
m_defaultCharset = "UTF-8";
m_sourceCharset = "UTF-8";
m_targetCharset = "UTF-8";
@ -381,7 +381,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 2 )
{
fprintf( stderr, "Hidden displayed headword is too large %s\n", headword.c_str() );
FDPRINTF( stderr, "Hidden displayed headword is too large %s\n", headword.c_str() );
pos += len - a;
break;
}
@ -396,7 +396,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 2 )
{
fprintf( stderr, "Displayed headword's length is too large for headword %s\n", headword.c_str() );
FDPRINTF( stderr, "Displayed headword's length is too large for headword %s\n", headword.c_str() );
pos += len - a;
break;
}
@ -416,7 +416,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 3 )
{
fprintf( stderr, "2-byte sized displayed headword for %s is too large\n", headword.c_str() );
FDPRINTF( stderr, "2-byte sized displayed headword for %s is too large\n", headword.c_str() );
pos += len - a;
break;
}
@ -434,7 +434,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 3 )
{
fprintf( stderr, "1-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
FDPRINTF( stderr, "1-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
pos += len - a;
break;
}
@ -456,7 +456,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 4)
{
fprintf( stderr, "2-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
FDPRINTF( stderr, "2-byte-sized transcription's length is too large for headword %s\n", headword.c_str() );
pos += len - a;
break;
}
@ -478,7 +478,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler )
if ( length > len - a - 2 )
{
fprintf( stderr, "Hidden transcription is too large %s\n", headword.c_str() );
FDPRINTF( stderr, "Hidden transcription is too large %s\n", headword.c_str() );
pos += len - a;
break;
}

View file

@ -845,7 +845,7 @@ static uint32_t buildBtreeNode( IndexedWords::const_iterator & nextIndex,
&compressedData.front(), &compressedSize, workMem )
!= LZO_E_OK )
{
fprintf( stderr, "Failed to compress btree node.\n" );
FDPRINTF( stderr, "Failed to compress btree node.\n" );
abort();
}
@ -858,7 +858,7 @@ static uint32_t buildBtreeNode( IndexedWords::const_iterator & nextIndex,
if ( compress( &compressedData.front(), &compressedSize,
&uncompressedData.front(), uncompressedData.size() ) != Z_OK )
{
fprintf( stderr, "Failed to compress btree node.\n" );
FDPRINTF( stderr, "Failed to compress btree node.\n" );
abort();
}

View file

@ -436,7 +436,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "Dictd dictionary reading failed: %s, error: %s\n",
FDPRINTF( stderr, "Dictd dictionary reading failed: %s, error: %s\n",
i->c_str(), e.what() );
}
}

View file

@ -3,8 +3,10 @@
#ifdef NO_CONSOLE
#define DPRINTF(...)
#define FDPRINTF(...)
#else
#define DPRINTF(...) { printf(__VA_ARGS__); }
#define FDPRINTF(...) { fprintf(__VA_ARGS__); }
#endif
#endif // __DPRINTF_HH_INCLUDED__

10
dsl.cc
View file

@ -1462,7 +1462,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
if ( !abrvScanner.readNextLine( curString, curOffset ) || curString.empty() )
{
fprintf( stderr, "Warning: premature end of file %s\n", abrvFileName.c_str() );
FDPRINTF( stderr, "Warning: premature end of file %s\n", abrvFileName.c_str() );
eof = true;
break;
}
@ -1514,7 +1514,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "Error reading abrv file %s: %s. Skipping it.\n",
FDPRINTF( stderr, "Error reading abrv file %s: %s. Skipping it.\n",
abrvFileName.c_str(), e.what() );
}
}
@ -1548,7 +1548,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
{
if ( !isDslWs( curString[ x ] ) )
{
fprintf( stderr, "Warning: garbage string in %s at offset 0x%X\n", i->c_str(), curOffset );
FDPRINTF( stderr, "Warning: garbage string in %s at offset 0x%X\n", i->c_str(), curOffset );
break;
}
}
@ -1572,7 +1572,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
{
if ( ! ( hasString = scanner.readNextLine( curString, curOffset ) ) )
{
fprintf( stderr, "Warning: premature end of file %s\n", i->c_str() );
FDPRINTF( stderr, "Warning: premature end of file %s\n", i->c_str() );
break;
}
@ -1796,7 +1796,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "DSL dictionary reading failed: %s:%u, error: %s\n",
FDPRINTF( stderr, "DSL dictionary reading failed: %s:%u, error: %s\n",
i->c_str(), atLine, e.what() );
}
}

View file

@ -6,6 +6,7 @@
#include "langcoder.hh"
#include <wctype.h>
#include <stdio.h>
#include "dprintf.hh"
namespace Dsl {
namespace Details {
@ -379,7 +380,7 @@ ArticleDom::ArticleDom( wstring const & str ):
stack.pop_back();
if ( stack.size() )
fprintf( stderr, "Warning: %u tags were unclosed.\n", stack.size() );
FDPRINTF( stderr, "Warning: %u tags were unclosed.\n", stack.size() );
}
void ArticleDom::closeTag( wstring const & name,
@ -452,7 +453,7 @@ void ArticleDom::closeTag( wstring const & name,
else
if ( warn )
{
fprintf( stderr, "Warning: no corresponding opening tag for closing tag \"/%ls\" found.\n",
FDPRINTF( stderr, "Warning: no corresponding opening tag for closing tag \"/%ls\" found.\n",
name.c_str() );
}
}
@ -620,7 +621,7 @@ DslScanner::DslScanner( string const & fileName ) throw( Ex, Iconv::Ex ):
if ( !needExactEncoding )
{
// We don't need that!
fprintf( stderr, "Warning: encoding was specified in a Unicode file, ignoring.\n" );
FDPRINTF( stderr, "Warning: encoding was specified in a Unicode file, ignoring.\n" );
}
else
if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"Latin" ) ) )
@ -837,7 +838,7 @@ void processUnsortedParts( wstring & str, bool strip )
if ( refCount < 0 )
{
fprintf( stderr, "Warning: an unmatched closing brace was encountered.\n" );
FDPRINTF( stderr, "Warning: an unmatched closing brace was encountered.\n" );
refCount = 0;
// But we remove that thing either way
str.erase( x, 1 );
@ -866,7 +867,7 @@ void processUnsortedParts( wstring & str, bool strip )
if ( strip && refCount )
{
fprintf( stderr, "Warning: unclosed brace(s) encountered.\n" );
FDPRINTF( stderr, "Warning: unclosed brace(s) encountered.\n" );
str.erase( startPos );
}
}

6
lsa.cc
View file

@ -459,14 +459,14 @@ sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name
if ( result <= 0 )
{
fprintf( stderr, "Warning: failed to read Vorbis data (code = %ld)\n", result );
FDPRINTF( stderr, "Warning: failed to read Vorbis data (code = %ld)\n", result );
memset( ptr, 0, left );
break;
}
if ( result > left )
{
fprintf( stderr, "Warning: Vorbis decode returned more data than requested.\n" );
FDPRINTF( stderr, "Warning: Vorbis decode returned more data than requested.\n" );
result = left;
}
@ -599,7 +599,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "Lingo's LSA reading failed: %s, error: %s\n",
FDPRINTF( stderr, "Lingo's LSA reading failed: %s, error: %s\n",
i->c_str(), e.what() );
}
}

View file

@ -322,7 +322,7 @@ void StardictDictionary::loadArticle( uint32_t address,
else
if ( !size )
{
fprintf( stderr, "Warning: short entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: short entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -336,7 +336,7 @@ void StardictDictionary::loadArticle( uint32_t address,
if ( size < entrySize )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -357,7 +357,7 @@ void StardictDictionary::loadArticle( uint32_t address,
{
if ( size < sizeof( uint32_t ) )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -371,7 +371,7 @@ void StardictDictionary::loadArticle( uint32_t address,
if ( size < entrySize )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -382,7 +382,7 @@ void StardictDictionary::loadArticle( uint32_t address,
}
else
{
fprintf( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n",
FDPRINTF( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n",
type, headword.c_str() );
break;
}
@ -400,7 +400,7 @@ void StardictDictionary::loadArticle( uint32_t address,
if ( size < len + 2 )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -415,7 +415,7 @@ void StardictDictionary::loadArticle( uint32_t address,
// An entry which havs its size before contents
if ( size < sizeof( uint32_t ) + 1 )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -427,7 +427,7 @@ void StardictDictionary::loadArticle( uint32_t address,
if ( size < sizeof( uint32_t ) + 1 + entrySize )
{
fprintf( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
FDPRINTF( stderr, "Warning: malformed entry for the word %s encountered.\n", headword.c_str() );
break;
}
@ -438,7 +438,7 @@ void StardictDictionary::loadArticle( uint32_t address,
}
else
{
fprintf( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n",
FDPRINTF( stderr, "Warning: non-alpha entry type 0x%x for the word %s encountered.\n",
(unsigned)*ptr, headword.c_str() );
break;
}
@ -928,7 +928,7 @@ static void handleIdxSynFile( string const & fileName,
sizeof( uint32_t ) * 2 ) >
&image.back() )
{
fprintf( stderr, "Warning: sudden end of file %s\n", fileName.c_str() );
FDPRINTF( stderr, "Warning: sudden end of file %s\n", fileName.c_str() );
break;
}
@ -1156,7 +1156,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "Stardict's dictionary reading failed: %s, error: %s\n",
FDPRINTF( stderr, "Stardict's dictionary reading failed: %s, error: %s\n",
i->c_str(), e.what() );
}
}

View file

@ -802,7 +802,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
catch( std::exception & e )
{
fprintf( stderr, "Xdxf dictionary reading failed: %s, error: %s\n",
FDPRINTF( stderr, "Xdxf dictionary reading failed: %s, error: %s\n",
i->c_str(), e.what() );
}
}

View file

@ -51,8 +51,8 @@ string convert( string const & in )
if ( !dd.setContent( QByteArray( ( "<div class=\"sdct_x\">" + inConverted + "</div>" ).c_str() ), false, &errorStr, &errorLine, &errorColumn ) )
{
fprintf( stderr, "Xdxf2html error, xml parse failed: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
fprintf( stderr, "The input was: %s\n", in.c_str() );
FDPRINTF( stderr, "Xdxf2html error, xml parse failed: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
FDPRINTF( stderr, "The input was: %s\n", in.c_str() );
return in;
}