Revision control

Copy as Markdown

Other Tools

--- ../../../ipc/chromium/src/third_party/libevent/WIN32-Code/getopt_long.c 2024-07-23 20:57:30.389625432 -0400
+++ getopt.c 2024-07-23 22:01:31.747785483 -0400
@@ -1,9 +1,8 @@
-
/*
* Copyright (c) 1987, 1993, 1994, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
@@ -29,31 +28,28 @@
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "getopt.h"
-extern int opterr; /* if error message should be printed */
-extern int optind; /* index into parent argv vector */
-extern int optopt; /* character checked for validity */
-extern int optreset; /* reset getopt */
-extern char *optarg; /* argument associated with option */
+int opterr; /* if error message should be printed */
+int optind; /* index into parent argv vector */
+int optopt; /* character checked for validity */
+int optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
-#define __P(x) x
#define _DIAGASSERT(x) assert(x)
-static char * __progname __P((char *));
-int getopt_internal __P((int, char * const *, const char *));
+static char * __progname(char *);
+int getopt_internal (int, char**, const char *);
-static char *
-__progname(nargv0)
- char * nargv0;
+static char * __progname(char * nargv0)
{
char * tmp;
_DIAGASSERT(nargv0 != NULL);
tmp = strrchr(nargv0, '/');
if (tmp)
tmp++;
@@ -66,20 +62,17 @@
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int
-getopt_internal(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
+getopt_internal(int nargc, char** nargv, const char* ostr)
{
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(ostr != NULL);
if (optreset || !*place) { /* update scanning pointer */
@@ -126,48 +119,39 @@
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}
-#if 0
/*
* getopt --
* Parse argc/argv argument vector.
*/
int
-getopt2(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
+getopt(int nargc, char** nargv, const char* ostr)
{
int retval;
if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) {
retval = -1;
++optind;
}
return(retval);
}
-#endif
+
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
-getopt_long(nargc, nargv, options, long_options, index)
- int nargc;
- char ** nargv;
- const char * options;
- const struct option * long_options;
- int * index;
+getopt_long(int nargc, char** nargv, const char* options, const struct option* long_options, int* index)
{
int retval;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
_DIAGASSERT(long_options != NULL);
/* index may be NULL */