[cvs] bogofilter/src bogotune.c,1.228,1.229
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: David R. <re...@us...> - 2006-03-27 19:22:18
|
Update of /cvsroot/bogofilter/bogofilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331 Modified Files: bogotune.c Log Message: Revise filename patch to remove goto's and labels. Index: bogotune.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/bogotune.c,v retrieving revision 1.228 retrieving revision 1.229 diff -u -d -r1.228 -r1.229 --- bogotune.c 27 Mar 2006 19:17:49 -0000 1.228 +++ bogotune.c 27 Mar 2006 19:21:59 -0000 1.229 @@ -948,9 +948,6 @@ #define OPTIONS ":c:Cd:DeEM:n:qr:s:tT:vVx:" - /* this function uses a few gotos below, to avoid code duplication - * that may lead to inconsistencies if one edit is forgotten. */ - while (1) { int option; @@ -963,6 +960,19 @@ if (option == -1) break; + if (option == 1) { + /* If getopt's RETURN_IN_ORDER behavior */ + switch (lastmode) { + case 'n': + case 's': + option = lastmode; + break; + default: + fprintf(stderr, + "File names may only be given after -n or -s options.\n"); + } + } + switch (option) { case 'c': read_config_file(optarg, false, false, PR_CFG_USER, longopts_bogotune); @@ -988,7 +998,6 @@ break; case 'n': lastmode = 'n'; -hamarg: /* <- case 1 jumps to this label */ filelist_add(ham_files, optarg); break; case 'q': @@ -999,23 +1008,8 @@ break; case 's': lastmode = 's'; -spamarg: /* <- case 1 jumps to this label */ filelist_add(spam_files, optarg); break; - case 1: - /* GNU getopt RETURN_IN_ORDER special - * (requires '-' as first character in optstring) - */ - switch (lastmode) { - case 'n': - goto hamarg; - case 's': - goto spamarg; - } - fprintf(stderr, - "File names may only be given after -n or -s options.\n"); - goto usage; - break; #ifdef TEST case 't': test += 1; @@ -1037,7 +1031,6 @@ set_debug_mask( optarg ); break; default: -usage: /* <- case 1 jumps to this label */ help(); exit(EX_ERROR); } |