Introduced 4 macros to minimise boilerplate command line processing code.
Nicely cuts around 130 lines of code, spread over the core and several tools.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2422 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c
index 3c7c616..29772a2 100644
--- a/memcheck/mac_needs.c
+++ b/memcheck/mac_needs.c
@@ -56,37 +56,19 @@
 
 Bool MAC_(process_common_cmd_line_option)(Char* arg)
 {
-   if      (VG_CLO_STREQ(arg, "--partial-loads-ok=yes"))
-      MAC_(clo_partial_loads_ok) = True;
-   else if (VG_CLO_STREQ(arg, "--partial-loads-ok=no"))
-      MAC_(clo_partial_loads_ok) = False;
-
-   else if (VG_CLO_STREQN(15, arg, "--freelist-vol=")) {
-      MAC_(clo_freelist_vol) = (Int)VG_(atoll)(&arg[15]);
-      if (MAC_(clo_freelist_vol) < 0) MAC_(clo_freelist_vol) = 0;
-   }
-
-   else if (VG_CLO_STREQ(arg, "--leak-check=yes"))
-      MAC_(clo_leak_check) = True;
-   else if (VG_CLO_STREQ(arg, "--leak-check=no"))
-      MAC_(clo_leak_check) = False;
-
+        VG_BOOL_CLO("--leak-check",            MAC_(clo_leak_check))
+   else VG_BOOL_CLO("--partial-loads-ok",      MAC_(clo_partial_loads_ok))
+   else VG_BOOL_CLO("--show-reachable",        MAC_(clo_show_reachable))
+   else VG_BOOL_CLO("--workaround-gcc296-bugs",MAC_(clo_workaround_gcc296_bugs))
+   
+   else VG_BNUM_CLO("--freelist-vol",  MAC_(clo_freelist_vol), 0, 1000000000)
+   
    else if (VG_CLO_STREQ(arg, "--leak-resolution=low"))
       MAC_(clo_leak_resolution) = Vg_LowRes;
    else if (VG_CLO_STREQ(arg, "--leak-resolution=med"))
       MAC_(clo_leak_resolution) = Vg_MedRes;
    else if (VG_CLO_STREQ(arg, "--leak-resolution=high"))
       MAC_(clo_leak_resolution) = Vg_HighRes;
-   
-   else if (VG_CLO_STREQ(arg, "--show-reachable=yes"))
-      MAC_(clo_show_reachable) = True;
-   else if (VG_CLO_STREQ(arg, "--show-reachable=no"))
-      MAC_(clo_show_reachable) = False;
-
-   else if (VG_CLO_STREQ(arg, "--workaround-gcc296-bugs=yes"))
-      MAC_(clo_workaround_gcc296_bugs) = True;
-   else if (VG_CLO_STREQ(arg, "--workaround-gcc296-bugs=no"))
-      MAC_(clo_workaround_gcc296_bugs) = False;
 
    else
       return VG_(replacement_malloc_process_cmd_line_option)(arg);
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index 6d800de..4497b32 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -1601,16 +1601,8 @@
 
 Bool SK_(process_cmd_line_option)(Char* arg)
 {
-   if (VG_CLO_STREQ(arg, "--avoid-strlen-errors=yes"))
-      MC_(clo_avoid_strlen_errors) = True;
-   else if (VG_CLO_STREQ(arg, "--avoid-strlen-errors=no"))
-      MC_(clo_avoid_strlen_errors) = False;
-
-   else if (VG_CLO_STREQ(arg, "--cleanup=yes"))
-      MC_(clo_cleanup) = True;
-   else if (VG_CLO_STREQ(arg, "--cleanup=no"))
-      MC_(clo_cleanup) = False;
-
+        VG_BOOL_CLO("--avoid-strlen-errors", MC_(clo_avoid_strlen_errors))
+   else VG_BOOL_CLO("--cleanup",             MC_(clo_cleanup))
    else
       return MAC_(process_common_cmd_line_option)(arg);