Bug 1909675 - Update niwcompat. r=dandarnell

Differential Revision: https://phabricator.services.mozilla.com/D217755

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Lemley 2024-07-31 17:44:58 +00:00
Родитель 763f0aacb7
Коммит a6ca0cde78
5 изменённых файлов: 955 добавлений и 760 удалений

13
third_party/README.niwcompat поставляемый
Просмотреть файл

@ -1,5 +1,14 @@
Directory ./niwcompat contains dirent.h from vcpkg and an empty getopt.h.
to compile RNP with Clang-cl for Windows.
Directory ./niwcompat contains files needed to compile RNP with Clang-cl for Windows.
dirent.h
https://github.com/tronkko/dirent 39c1f1bc98ef3326237d03006f35d7dd44620e43
getopt
Copied from ipc/chromium/src/third_party/libevent/WIN32-Code 17630c12ac58fd6623fb5d6816eccd9b17933729
getopt_long.c -> getopt.c
Applied patch in ../patches/getopt/getopt.diff to fix warnings
niwcompat = wincompat where "win" is spelled backwards

1541
third_party/niwcompat/dirent.h поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

33
third_party/niwcompat/getopt.c поставляемый
Просмотреть файл

@ -39,15 +39,12 @@ 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;
@ -70,10 +67,7 @@ __progname(nargv0)
* 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 */
@ -135,10 +129,7 @@ getopt_internal(nargc, nargv, ostr)
* Parse argc/argv argument vector.
*/
int
getopt(nargc, nargv, ostr)
int nargc;
char * const *nargv;
const char *ostr;
getopt(int nargc, char** nargv, const char* ostr)
{
int retval;
@ -155,12 +146,7 @@ getopt(nargc, nargv, ostr)
* 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;
@ -171,7 +157,8 @@ getopt_long(nargc, nargv, options, long_options, index)
if ((retval = getopt_internal(nargc, nargv, options)) == -2) {
char *current_argv = nargv[optind++] + 2, *has_equal;
int i, current_argv_len, match = -1;
int i, match = -1;
size_t current_argv_len;
if (*current_argv == '\0') {
return(-1);
@ -182,11 +169,11 @@ getopt_long(nargc, nargv, options, long_options, index)
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
for (i = 0; long_options[i].name; i++) {
if (strncmp(current_argv, long_options[i].name, current_argv_len))
continue;
if (strlen(long_options[i].name) == (unsigned)current_argv_len) {
if (strlen(long_options[i].name) == current_argv_len) {
match = i;
break;
}

2
third_party/niwcompat/getopt.h поставляемый
Просмотреть файл

@ -23,7 +23,7 @@ struct option
#define required_argument 1
#define optional_argument 2
int getopt(int, char * const*, const char*);
int getopt(int, char**, const char*);
int getopt_long(int, char**, const char*, const struct option*, int*);
#ifdef __cplusplus

126
third_party/patches/getopt/getopt.diff поставляемый Normal file
Просмотреть файл

@ -0,0 +1,126 @@
--- ../../../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 */