Back to index

glibc  2.9
Defines | Functions | Variables
bug-envz1.c File Reference
#include <stdio.h>
#include <envz.h>
#include <stdlib.h>
#include <string.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define nstrs   (sizeof (strs) / sizeof (strs[0]))
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Variables

struct {
const char * s
int in_result
strs []

Define Documentation

#define nstrs   (sizeof (strs) / sizeof (strs[0]))

Definition at line 25 of file bug-envz1.c.

#define TEST_FUNCTION   do_test ()

Definition at line 75 of file bug-envz1.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 29 of file bug-envz1.c.

{

  size_t size = 0;
  char *str = malloc (100);
  if (str == NULL)
    {
      puts ("out of memory");
      return 1;
    }

  char **argz = &str;

  for (int i = 0; i < nstrs; ++i)
    argz_add_sep (argz, &size, strs[i].s, '\0');

  printf ("calling envz_strip with size=%zu\n", size);
  envz_strip (argz, &size);

  int result = 0;
  printf ("new size=%zu\n", size);
  for (int i = 0; i < nstrs; ++i)
    if (strs[i].in_result)
      {
        char name[2];
        name[0] = strs[i].s[0];
        name[1] = '\0';

        char *e = envz_entry (*argz, size, name);
        if (e == NULL)
          {
            printf ("entry '%s' not found\n", name);
            result = 1;
          }
        else if (strcmp (e, strs[i].s) != 0)
          {
            printf ("entry '%s' does not match: is '%s', expected '%s'\n",
                    name, e, strs[i].s);
            result = 1;
          }
      }

  free (*argz);
  return result;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } strs[] [static]