From d969ee2ca6b5c9738821ff9261974b03bd885ed5 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 12 Jun 2019 21:37:18 +0100 Subject: [PATCH] wmail: use continues rather than if-else chain to improve readability. --- wmail/src/config.c | 123 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 21 deletions(-) diff --git a/wmail/src/config.c b/wmail/src/config.c index e81476a..d128c80 100644 --- a/wmail/src/config.c +++ b/wmail/src/config.c @@ -270,65 +270,146 @@ void ReadConfigFile( bool resetConfigStrings ) if( !Tokenize( buf, &id, &value )) continue; - if( !strncasecmp( id, "Window.Display", 14 )) { + if( !strncasecmp( id, "Window.Display", 14 )) + { if( !( config.givenOptions & CL_DISPLAY )) ReadString( value, line, &config.display ); - } else if( !strncasecmp( id, "Window.NonShaped", 16 )) { + continue; + } + + if( !strncasecmp( id, "Window.NonShaped", 16 )) + { if( !( config.givenOptions & CL_NOSHAPE )) ReadBool( value, line, &config.noshape ); - } else if( !strncasecmp( id, "Window.Button.Command", 21 )) { + continue; + } + + if( !strncasecmp( id, "Window.Button.Command", 21 )) + { if( !( config.givenOptions & CL_RUNCMD )) ReadString( value, line, &config.runCmd ); - } else if( !strncasecmp( id, "Mail.MailBox", 12 )) { + continue; + } + + if( !strncasecmp( id, "Mail.MailBox", 12 )) + { if( !( config.givenOptions & CL_MAILBOX )) ReadString( value, line, &config.mailBox ); - } else if( !strncasecmp( id, "Mail.ChecksumFile", 17 )) // no corresponding cmdline option + continue; + } + + if( !strncasecmp( id, "Mail.ChecksumFile", 17 )) + { + /* + * No corresponding command-line option. + */ ReadString( value, line, &config.checksumFileName ); - else if( !strncasecmp( id, "Mail.CheckIntervall", 19 )) { + continue; + } + + if( !strncasecmp( id, "Mail.CheckIntervall", 19 )) + { if( !( config.givenOptions & CL_CHECKINTERVAL )) ReadInt( value, line, &config.checkInterval ); - } else if( !strncasecmp( id, "Mail.ShowOnlyNew", 16 )) { + continue; + } + + if( !strncasecmp( id, "Mail.ShowOnlyNew", 16 )) + { if( !( config.givenOptions & CL_NEWMAILONLY )) ReadBool( value, line, &config.newMailsOnly ); - } else if( !strncasecmp( id, "Ticker.Mode", 11 )) { + continue; + } + + if( !strncasecmp( id, "Ticker.Mode", 11 )) + { if( !( config.givenOptions & CL_TICKERMODE )) ReadEnum( value, line, (int *)&config.tickerMode, tickerEnum ); - } else if( !strncasecmp( id, "Ticker.Frames", 13 )) { + continue; + } + + if( !strncasecmp( id, "Ticker.Frames", 13 )) + { if( !( config.givenOptions & CL_FPS )) ReadInt( value, line, &config.fps ); - } else if( !strncasecmp( id, "Colors.Symbols", 14 )) { + continue; + } + + if( !strncasecmp( id, "Colors.Symbols", 14 )) + { if( !( config.givenOptions & CL_SYMBOLCOLOR )) ReadString( value, line, &config.symbolColor ); - } else if( !strncasecmp( id, "Colors.Font", 11 )) { + continue; + } + + if( !strncasecmp( id, "Colors.Font", 11 )) + { if( !( config.givenOptions & CL_FONTCOLOR )) ReadString( value, line, &config.fontColor ); - } else if( !strncasecmp( id, "Colors.Backlight", 16 )) { + continue; + } + + if( !strncasecmp( id, "Colors.Backlight", 16 )) + { if( !( config.givenOptions & CL_BACKCOLOR )) ReadString( value, line, &config.backColor ); - } else if( !strncasecmp( id, "Colors.OffLight", 15 )) { + continue; + } + + if( !strncasecmp( id, "Colors.OffLight", 15 )) + { if( !( config.givenOptions & CL_OFFLIGHTCOLOR )) ReadString( value, line, &config.offlightColor ); - } else if( !strncasecmp( id, "Colors.NonShapedFrame", 21 )) { + continue; + } + + if( !strncasecmp( id, "Colors.NonShapedFrame", 21 )) + { if( !( config.givenOptions & CL_NOSHAPE )) ReadString( value, line, &config.backgroundColor ); - } else if( !strncasecmp( id, "Ticker.X11Font", 14 )) { + continue; + } + + if( !strncasecmp( id, "Ticker.X11Font", 14 )) + { if( !( config.givenOptions & CL_USEX11FONT )) ReadString( value, line, &config.useX11Font ); - } else if( !strncasecmp( id, "Mail.SkipSender", 15 )) { // no corresponding cmdline options + continue; + } + + if( !strncasecmp( id, "Mail.SkipSender", 15 )) + { + /* + * No corresponding command-line option. + */ char *skip; if( ReadString( value, line, &skip )) AddSenderToSkipList( skip ); - } else if( !strncasecmp( id, "Mail.OnNew.Command", 18 )) { + continue; + } + + if( !strncasecmp( id, "Mail.OnNew.Command", 18 )) + { if( !( config.givenOptions & CL_CMDONMAIL )) ReadString( value, line, &config.cmdOnMail ); - } else if( !strncasecmp( id, "Mail.UseStatusField", 19 )) { + continue; + } + + if( !strncasecmp( id, "Mail.UseStatusField", 19 )) + { if( !( config.givenOptions & CL_CONSIDERSTATUSFIELD )) ReadBool( value, line, &config.considerStatusField ); - } else if( !strncasecmp( id, "Mail.ReadStatus", 15 )) { + continue; + } + + if( !strncasecmp( id, "Mail.ReadStatus", 15 )) + { if( !( config.givenOptions & CL_READSTATUS )) ReadString( value, line, &config.readStatus ); - } else - WARNING( "cfg-file(%i): unrecognized: \"%s\"\n", line, buf ); + continue; + } + + WARNING( "cfg-file(%i): unrecognized: \"%s\"\n", line, buf ); } fclose( f );