Sounds silly, but I found the following construct handy:
int margin_t, margin_r, margin_b, margin_l;
switch (sscanf (optarg, \"%d %d %d %d\",
&margin_t, &margin_r,
&margin_b, &margin_l))
{
case 0: err;
case 1: margin_r = margin_t;
case 2: margin_b = margin_t;
case 3: margin_l = margin_r;
}