Fix parameter initialization and assignment

This commit is contained in:
Quentin Rameau 2015-11-30 00:39:52 +01:00
parent 75e3fe5b95
commit 6e019362c5
1 changed files with 34 additions and 30 deletions

64
surf.c
View File

@ -31,14 +31,18 @@
#define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
#define SETB(p, s) [p] = (Parameter){ { .b = s }, } #define SETB(p, s) [p] = { { .b = s }, }
#define SETI(p, s) [p] = (Parameter){ { .i = s }, } #define SETI(p, s) [p] = { { .i = s }, }
#define SETV(p, s) [p] = (Parameter){ { .v = s }, } #define SETV(p, s) [p] = { { .v = s }, }
#define SETF(p, s) [p] = (Parameter){ { .f = s }, } #define SETF(p, s) [p] = { { .f = s }, }
#define FSETB(p, s) [p] = (Parameter){ { .b = s }, 1 } #define FSETB(p, s) [p] = { { .b = s }, 1 }
#define FSETI(p, s) [p] = (Parameter){ { .i = s }, 1 } #define FSETI(p, s) [p] = { { .i = s }, 1 }
#define FSETV(p, s) [p] = (Parameter){ { .v = s }, 1 } #define FSETV(p, s) [p] = { { .v = s }, 1 }
#define FSETF(p, s) [p] = (Parameter){ { .f = s }, 1 } #define FSETF(p, s) [p] = { { .f = s }, 1 }
#define CSETB(p, s) [p] = (Parameter){ { .b = s }, 1 }
#define CSETI(p, s) [p] = (Parameter){ { .i = s }, 1 }
#define CSETV(p, s) [p] = (Parameter){ { .v = s }, 1 }
#define CSETF(p, s) [p] = (Parameter){ { .f = s }, 1 }
enum { AtomFind, AtomGo, AtomUri, AtomLast }; enum { AtomFind, AtomGo, AtomUri, AtomLast };
@ -1599,76 +1603,76 @@ main(int argc, char *argv[])
/* command line args */ /* command line args */
ARGBEGIN { ARGBEGIN {
case 'a': case 'a':
defconfig FSETV(CookiePolicies, EARGF(usage())); defconfig CSETV(CookiePolicies, EARGF(usage()));
break; break;
case 'b': case 'b':
defconfig FSETB(ScrollBars, 0); defconfig CSETB(ScrollBars, 0);
break; break;
case 'B': case 'B':
defconfig FSETB(ScrollBars, 1); defconfig CSETB(ScrollBars, 1);
break; break;
case 'c': case 'c':
cookiefile = EARGF(usage()); cookiefile = EARGF(usage());
break; break;
case 'd': case 'd':
defconfig FSETB(DiskCache, 0); defconfig CSETB(DiskCache, 0);
break; break;
case 'D': case 'D':
defconfig FSETB(DiskCache, 1); defconfig CSETB(DiskCache, 1);
break; break;
case 'e': case 'e':
embed = strtol(EARGF(usage()), NULL, 0); embed = strtol(EARGF(usage()), NULL, 0);
break; break;
case 'f': case 'f':
defconfig FSETB(RunInFullscreen, 0); defconfig CSETB(RunInFullscreen, 0);
break; break;
case 'F': case 'F':
defconfig FSETB(RunInFullscreen, 1); defconfig CSETB(RunInFullscreen, 1);
break; break;
case 'g': case 'g':
defconfig FSETB(Geolocation, 0); defconfig CSETB(Geolocation, 0);
break; break;
case 'G': case 'G':
defconfig FSETB(Geolocation, 1); defconfig CSETB(Geolocation, 1);
break; break;
case 'i': case 'i':
defconfig FSETB(LoadImages, 0); defconfig CSETB(LoadImages, 0);
break; break;
case 'I': case 'I':
defconfig FSETB(LoadImages, 1); defconfig CSETB(LoadImages, 1);
break; break;
case 'k': case 'k':
defconfig FSETB(KioskMode, 0); defconfig CSETB(KioskMode, 0);
break; break;
case 'K': case 'K':
defconfig FSETB(KioskMode, 1); defconfig CSETB(KioskMode, 1);
break; break;
case 'm': case 'm':
defconfig FSETB(Style, 0); defconfig CSETB(Style, 0);
break; break;
case 'M': case 'M':
defconfig FSETB(Style, 1); defconfig CSETB(Style, 1);
break; break;
case 'n': case 'n':
defconfig FSETB(Inspector, 0); defconfig CSETB(Inspector, 0);
break; break;
case 'N': case 'N':
defconfig FSETB(Inspector, 1); defconfig CSETB(Inspector, 1);
break; break;
case 'p': case 'p':
defconfig FSETB(Plugins, 0); defconfig CSETB(Plugins, 0);
break; break;
case 'P': case 'P':
defconfig FSETB(Plugins, 1); defconfig CSETB(Plugins, 1);
break; break;
case 'r': case 'r':
scriptfile = EARGF(usage()); scriptfile = EARGF(usage());
break; break;
case 's': case 's':
defconfig FSETB(JavaScript, 0); defconfig CSETB(JavaScript, 0);
break; break;
case 'S': case 'S':
defconfig FSETB(JavaScript, 1); defconfig CSETB(JavaScript, 1);
break; break;
case 't': case 't':
stylefile = EARGF(usage()); stylefile = EARGF(usage());
@ -1683,7 +1687,7 @@ main(int argc, char *argv[])
showxid = 1; showxid = 1;
break; break;
case 'z': case 'z':
defconfig FSETF(ZoomLevel, strtof(EARGF(usage()), NULL)); defconfig CSETF(ZoomLevel, strtof(EARGF(usage()), NULL));
break; break;
default: default:
usage(); usage();