Make hard-linking work when a device has an st_dev of 0.
[rsync/rsync.git] / popt / popt.c
index fcf671c..a01b6b9 100644 (file)
@@ -392,7 +392,6 @@ static int execCommand(poptContext con)
     poptItem item = con->doExec;
     const char ** argv;
     int argc = 0;
-    int rc;
 
     if (item == NULL) /*XXX can't happen*/
        return POPT_ERROR_NOARG;
@@ -432,8 +431,9 @@ static int execCommand(poptContext con)
 
     argv[argc] = NULL;
 
+  {
 #ifdef __hpux
-    rc = setresgid(getgid(), getgid(),-1);
+    int rc = setresgid(getgid(), getgid(),-1);
     if (rc) return POPT_ERROR_ERRNO;
     rc = setresuid(getuid(), getuid(),-1);
     if (rc) return POPT_ERROR_ERRNO;
@@ -444,12 +444,12 @@ static int execCommand(poptContext con)
  * XXX from Norbert Warmuth <nwarmuth@privat.circular.de>
  */
 #if defined(HAVE_SETUID)
-    rc = setgid(getgid());
+    int rc = setgid(getgid());
     if (rc) return POPT_ERROR_ERRNO;
     rc = setuid(getuid());
     if (rc) return POPT_ERROR_ERRNO;
 #elif defined (HAVE_SETREUID)
-    rc = setregid(getgid(), getgid());
+    int rc = setregid(getgid(), getgid());
     if (rc) return POPT_ERROR_ERRNO;
     rc = setreuid(getuid(), getuid());
     if (rc) return POPT_ERROR_ERRNO;
@@ -457,6 +457,7 @@ static int execCommand(poptContext con)
     ; /* Can't drop privileges */
 #endif
 #endif
+  }
 
     if (argv[0] == NULL)
        return POPT_ERROR_NOARG;
@@ -471,7 +472,7 @@ if (_popt_debug)
     }
 #endif
 
-    rc = execvp(argv[0], (char *const *)argv);
+    execvp(argv[0], (char *const *)argv);
 
     return POPT_ERROR_ERRNO;
 }
@@ -808,16 +809,20 @@ int poptGetNextOpt(poptContext con)
                    *oe++ = '\0';
                    /* XXX longArg is mapped back to persistent storage. */
                    longArg = origOptString + (oe - localOptString);
-               }
+               } else
+                   oe = NULL;
 
                opt = findOption(con->options, optString, '\0', &cb, &cbData,
                                 singleDash);
                if (!opt && !singleDash)
                    return POPT_ERROR_BADOPT;
+               if (!opt && oe)
+                   oe[-1] = '='; /* restore overwritten '=' */
            }
 
            if (!opt) {
                con->os->nextCharArg = origOptString + 1;
+               longArg = NULL;
            } else {
                if (con->os == con->optionStack &&
                   opt->argInfo & POPT_ARGFLAG_STRIP)
@@ -855,7 +860,7 @@ int poptGetNextOpt(poptContext con)
 
            origOptString++;
            if (*origOptString != '\0')
-               con->os->nextCharArg = origOptString;
+               con->os->nextCharArg = origOptString + (*origOptString == '=');
        }
        /*@=branchstate@*/
 
@@ -965,10 +970,10 @@ int poptGetNextOpt(poptContext con)
                    if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) {
                        *((double *) opt->arg) = aDouble;
                    } else {
-#define _ABS(a)        ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
-                       if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
+#define MY_ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
+                       if ((MY_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
                            return POPT_ERROR_OVERFLOW;
-                       if ((FLT_MIN - _ABS(aDouble)) > DBL_EPSILON)
+                       if ((FLT_MIN - MY_ABS(aDouble)) > DBL_EPSILON)
                            return POPT_ERROR_OVERFLOW;
                        *((float *) opt->arg) = aDouble;
                    }