]> git.sur5r.net Git - i3/i3lock/commitdiff
Merge pull request #135 from grandchild/fix_optind_overwrite
authorIngo Bürk <admin@airblader.de>
Sun, 13 Aug 2017 15:26:38 +0000 (17:26 +0200)
committerGitHub <noreply@github.com>
Sun, 13 Aug 2017 15:26:38 +0000 (17:26 +0200)
Fix shadowing of getopt optind

1  2 
i3lock.c

diff --combined i3lock.c
index 208e4acba4ae5533d37b7bf7d5371ccef248923c,af678aa7abdd46cf23219f71f9554d5afad172ae..945be9fa1cc4c5a8fb794c733a5a4edb2909fe8f
+++ b/i3lock.c
@@@ -819,7 -819,7 +819,7 @@@ int main(int argc, char *argv[]) 
  #endif
      int curs_choice = CURS_NONE;
      int o;
-     int optind = 0;
+     int longoptind = 0;
      struct option longopts[] = {
          {"version", no_argument, NULL, 'v'},
          {"nofork", no_argument, NULL, 'n'},
          errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
  
      char *optstring = "hvnbdc:p:ui:teI:f";
-     while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
+     while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) {
          switch (o) {
              case 'v':
                  errx(EXIT_SUCCESS, "version " VERSION " © 2010 Michael Stapelberg");
                  ignore_empty_password = true;
                  break;
              case 0:
-                 if (strcmp(longopts[optind].name, "debug") == 0)
+                 if (strcmp(longopts[longoptind].name, "debug") == 0)
                      debug_mode = true;
                  break;
              case 'f':
          errx(EXIT_FAILURE, "Could not load keymap");
  
      const char *locale = getenv("LC_ALL");
 -    if (!locale)
 +    if (!locale || !*locale)
          locale = getenv("LC_CTYPE");
 -    if (!locale)
 +    if (!locale || !*locale)
          locale = getenv("LANG");
 -    if (!locale) {
 +    if (!locale || !*locale) {
          if (debug_mode)
              fprintf(stderr, "Can't detect your locale, fallback to C\n");
          locale = "C";