Commit 78d67ff8 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

getopt.c: Pointer comparison fix

* Remove <stdint.h> because MSVC 2005 (and probably 2008) don't have it.
* Fix pointer difference caclulation between `nameend` and `nextchar`.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
parent c80a819b
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
/* Comment out all this code if we are using the GNU C Library, and are not /* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C actually compiling the library itself. This code is part of the GNU C
...@@ -664,8 +663,7 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only) ...@@ -664,8 +663,7 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only)
for (p = longopts, option_index = 0; p->name; p++, option_index++) for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar)) if (!strncmp (p->name, nextchar, nameend - nextchar))
{ {
if ((uint32_t) (nameend - nextchar) if ((size_t) (nameend - nextchar) == strlen (p->name))
== (uint32_t) strlen (p->name))
{ {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
...@@ -853,7 +851,7 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only) ...@@ -853,7 +851,7 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only)
for (p = longopts, option_index = 0; p->name; p++, option_index++) for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar)) if (!strncmp (p->name, nextchar, nameend - nextchar))
{ {
if ((uint32_t) (nameend - nextchar) == strlen (p->name)) if ((size_t) (nameend - nextchar) == strlen (p->name))
{ {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment