wmail: white-space fixes.

This commit is contained in:
Jeremy Sowden 2019-06-07 09:52:10 +01:00 committed by Carlos R. Mafra
parent b78df8ed42
commit 71c126d20e
2 changed files with 50 additions and 43 deletions

View file

@ -393,7 +393,8 @@ static bool ReadString( const char *from, unsigned int line, char **to )
case 'r': *to_c = '\r'; break;
case 't': *to_c = '\t'; break;
case '"': *to_c = '"'; break;
default: {
default:
{
int value, i;
for( i = 0, value = 0; i < 3; ++i ) {
if( c+i == NULL || *(c+i) < '0' || *(c+i) > '9' )
@ -401,7 +402,8 @@ static bool ReadString( const char *from, unsigned int line, char **to )
value = value * 10 + *(c+i) - '0';
}
if( value == 0 )
WARNING( "cfg-file(%i): '\\0' in string or unknown escape sequence found\n", line );
WARNING( "cfg-file(%i): '\\0' in string or unknown escape sequence found\n",
line );
else {
*to_c = (char)value;
c += i-1;
@ -464,15 +466,18 @@ static bool ReadInt( const char *from, unsigned int line, int *to )
return false;
}
}
} else for( ; *from != '\0' && !IsWhiteSpace( from ); ++from ) {
} else
for( ; *from != '\0' && !IsWhiteSpace( from ); ++from ) {
if( value > (INT_MAX - 9) / 10 ) {
WARNING( "cfg-file(%i): decimal-number too large: \">%i\"\n", line, INT_MAX );
WARNING( "cfg-file(%i): decimal-number too large: \">%i\"\n",
line, INT_MAX );
return false;
}
if( *from >= '0' && *from <= '9' )
value = value * 10 + *from - '0';
else {
WARNING( "cfg-file(%i): invalid decimal-digit: \"%c\"\n", line, *from );
WARNING( "cfg-file(%i): invalid decimal-digit: \"%c\"\n",
line, *from );
return false;
}
}

View file

@ -230,7 +230,7 @@ int main( int argc, char **argv )
config.checksumFileName = MakePathName( usersHome, WMAIL_CHECKSUM_FILE );
}
if ( config.checksumFileName == NULL)
if( config.checksumFileName == NULL )
{
WARNING( "Cannot allocate checksum file-name.\n");
exit( EXIT_FAILURE );
@ -493,13 +493,15 @@ static void DetermineState( void )
static void ReadChecksumFile( void )
{
FILE *f = fopen( config.checksumFileName, "rb" );
if( f != NULL ) while( !feof( f )) {
if( f != NULL )
while( !feof( f )) {
unsigned long checksum;
if( fread( &checksum, sizeof(long), 1, f ) != 1 )
continue;
MarkName( checksum );
} else
}
else
return;
fclose( f );
@ -549,7 +551,7 @@ static void ExitHandler( int sig )
static void TimedOut( void )
{
if (caughtSig) {
if( caughtSig ) {
ClearAllNames();
ResetConfigStrings();
exit( EXIT_SUCCESS );
@ -567,7 +569,7 @@ static void CheckTimeOut( bool force )
unsigned long nowMs = now.tv_sec * 1000L + now.tv_usec / 1000L;
if (!force && nowMs - lastTimeOut < 1000L / config.fps)
if( !force && nowMs - lastTimeOut < 1000L / config.fps )
return;
lastTimeOut = nowMs;
@ -660,7 +662,7 @@ static void CheckMaildir( void )
char *fullName = MakePathName( config.mailBox, dirEnt->d_name );
struct stat fileStat;
if ( fullName == NULL )
if( fullName == NULL )
{
WARNING( "Cannot allocate file/path\n" );
break;
@ -708,7 +710,7 @@ static int TraverseDirectory( const char *name, bool isNewMail )
unsigned long checksum = 0;
name_t *name;
if ( fullName == NULL )
if( fullName == NULL )
{
WARNING( "Cannot allocate file/path\n" );
break;
@ -972,7 +974,7 @@ static char *ParseFromField( char *buf )
continue;
} // else do the default action
default:
if( fullName[0] != '\0' || !isspace ( *c ))
if( fullName[0] != '\0' || !isspace( *c ))
fullName[ fullNameLen++ ] = *c;
}
continue;
@ -1050,12 +1052,12 @@ static char *ParseFromField( char *buf )
}
}
if (*comment) {
if( *comment ) {
//WARNING("Comment seen: %s\nIn: %s\nFullname: %s\nAddress: %s\n", comment, buf, fullName, addressName);
// Comment seen: if there's an address, append to
// fullname. If no address, copy fullname to address
// and comment to fullname.
if (*addressName) {
if( *addressName ) {
strcat(fullName, "(");
strcat(fullName, comment);
strcat(fullName, ")");
@ -1116,7 +1118,7 @@ static void InsertName( char *name, unsigned long checksum, flag_t flag )
name_t *item;
TRACE( "insertName: %X, \"%s\"\n", checksum, name );
if (( item = malloc( sizeof( name_t ))) == NULL )
if(( item = malloc( sizeof( name_t ))) == NULL )
{
free( name );
return;
@ -1359,7 +1361,7 @@ static void UpdateConfiguration( void )
PreparePixmaps( true );
DASetTimeout (1000 / config.fps);
DASetTimeout( 1000 / config.fps );
}
static void CleanupNames( void )