tests: Fix gcc incompatibility
* tests/json/t-json.c: Remove var definitions inside a for statement. -- This useful C99 feature seems to work only in recent gcc versions. We can't use it; see gnupg/doc/HACKING. GnuPG-bug-id: 5088
This commit is contained in:
parent
fd904f87f8
commit
25e2d717f4
@ -209,6 +209,8 @@ get_file (const char *fname)
|
|||||||
int
|
int
|
||||||
test_contains (cjson_t needle, cjson_t hay)
|
test_contains (cjson_t needle, cjson_t hay)
|
||||||
{
|
{
|
||||||
|
cjson_t it;
|
||||||
|
|
||||||
if (verbose == 2)
|
if (verbose == 2)
|
||||||
fprintf (stderr, "%s: -------checking-------- "
|
fprintf (stderr, "%s: -------checking-------- "
|
||||||
"\n%s\n -------against-------- \n%s\n",
|
"\n%s\n -------against-------- \n%s\n",
|
||||||
@ -261,7 +263,9 @@ test_contains (cjson_t needle, cjson_t hay)
|
|||||||
if (test_contains (needle->child, hay->child))
|
if (test_contains (needle->child, hay->child))
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
for (cjson_t hit = hay->child; hit; hit = hit->next)
|
cjson_t hit;
|
||||||
|
|
||||||
|
for (hit = hay->child; hit; hit = hit->next)
|
||||||
{
|
{
|
||||||
found |= !test_contains (needle->child, hit);
|
found |= !test_contains (needle->child, hit);
|
||||||
if (found)
|
if (found)
|
||||||
@ -282,13 +286,16 @@ test_contains (cjson_t needle, cjson_t hay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Walk elements of an array */
|
/* Walk elements of an array */
|
||||||
for (cjson_t it = needle->next; it; it = it->next)
|
for (it = needle->next; it; it = it->next)
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
cjson_t hit;
|
||||||
|
|
||||||
if (!it->string && it->child)
|
if (!it->string && it->child)
|
||||||
{
|
{
|
||||||
/* Try out all other anonymous children on the same level */
|
/* Try out all other anonymous children on the same level */
|
||||||
cjson_t hit = hay;
|
hit = hay;
|
||||||
|
|
||||||
/* Return to the beginning */
|
/* Return to the beginning */
|
||||||
while (hit->prev)
|
while (hit->prev)
|
||||||
{
|
{
|
||||||
@ -310,7 +317,7 @@ test_contains (cjson_t needle, cjson_t hay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Try the children in the haystack */
|
/* Try the children in the haystack */
|
||||||
for (cjson_t hit = hay; hit; hit = hit->next)
|
for (hit = hay; hit; hit = hit->next)
|
||||||
{
|
{
|
||||||
if (hit->string && it->string &&
|
if (hit->string && it->string &&
|
||||||
!strcmp (hit->string, it->string))
|
!strcmp (hit->string, it->string))
|
||||||
@ -463,6 +470,7 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const char *gpgme_json = getenv ("gpgme_json");
|
const char *gpgme_json = getenv ("gpgme_json");
|
||||||
int last_argc = -1;
|
int last_argc = -1;
|
||||||
|
const char **test;
|
||||||
|
|
||||||
if (argc)
|
if (argc)
|
||||||
{ argc--; argv++; }
|
{ argc--; argv++; }
|
||||||
@ -488,7 +496,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
init_gpgme (GPGME_PROTOCOL_SPAWN);
|
init_gpgme (GPGME_PROTOCOL_SPAWN);
|
||||||
|
|
||||||
for (const char **test = tests; *test; test++)
|
for (test = tests; *test; test++)
|
||||||
{
|
{
|
||||||
if (run_test (*test, gpgme_json))
|
if (run_test (*test, gpgme_json))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user