[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kdecore
From:       Luís Pedro Coelho <luis () luispedro ! org>
Date:       2004-09-02 15:31:17
Message-ID: 20040902153117.3761F1EFF () office ! kde ! org
[Download RAW message or body]

CVS commit by luis_pedro: 

Make the code simpler to understand, while fixing a small bug:

   if ( !kDebug_data->aAreaName.isEmpty() ) {
       strlcpy( buf, kDebug_data->aAreaName.data(), BUFSIZE );
       strlcat( buf, ": ", BUFSIZE );
       strlcat( buf, data, BUFSIZE );
-      nSize = strlen( buf );
   }
   else
-      nSize = strlcpy( buf, data, BUFSIZE );

The meaning is not the same. strlcpy returns the number of characters which would \
have been copied if the buffer was large enough. Not that it ever matters in \
practice, but it doesn't hurt.


  M +3 -8      kdebug.cpp   1.141


--- kdelibs/kdecore/kdebug.cpp  #1.140:1.141
@@ -250,13 +250,11 @@ static void kDebugBackend( unsigned shor
   const int BUFSIZE = 4096;
   char buf[BUFSIZE];
-  int nSize;
   if ( !kDebug_data->aAreaName.isEmpty() ) {
       strlcpy( buf, kDebug_data->aAreaName.data(), BUFSIZE );
       strlcat( buf, ": ", BUFSIZE );
       strlcat( buf, data, BUFSIZE );
-      nSize = strlen( buf );
   }
   else
-      nSize = strlcpy( buf, data, BUFSIZE );
+      strlcpy( buf, data, BUFSIZE );
 
 
@@ -285,8 +283,5 @@ static void kDebugBackend( unsigned shor
       QFile aOutputFile( kDebug_data->config->readPathEntry(aKey, "kdebug.dbg") );
       aOutputFile.open( IO_WriteOnly | IO_Append | IO_Raw );
-      if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
-          aOutputFile.writeBlock( buf, BUFSIZE-1 );
-      else
-          aOutputFile.writeBlock( buf, nSize );
+      aOutputFile.writeBlock( buf, strlen( buf ) );
       aOutputFile.close();
       break;
@@ -303,5 +298,5 @@ static void kDebugBackend( unsigned shor
   case 2: // Shell
   {
-      write( 2, buf, nSize ); //fputs( buf, stderr );
+      write( 2, buf, strlen( buf ) );  //fputs( buf, stderr );
       break;
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic