Back to index

glibc  2.9
Defines | Typedefs | Functions
test-strcspn.c File Reference
#include "test-string.h"
#include "test-strpbrk.c"

Go to the source code of this file.

Defines

#define STRPBRK_RESULT(s, pos)   (pos)
#define RES_TYPE   size_t
#define TEST_MAIN

Typedefs

typedef size_t(* proto_t )(const char *, const char *)

Functions

size_t simple_strcspn (const char *, const char *)
size_t stupid_strcspn (const char *, const char *)

Define Documentation

#define RES_TYPE   size_t

Definition at line 22 of file test-strcspn.c.

#define STRPBRK_RESULT (   s,
  pos 
)    (pos)

Definition at line 21 of file test-strcspn.c.

#define TEST_MAIN

Definition at line 23 of file test-strcspn.c.


Typedef Documentation

typedef size_t(* proto_t)(const char *, const char *)

Definition at line 26 of file test-strcspn.c.


Function Documentation

size_t simple_strcspn ( const char *  s,
const char *  rej 
)

Definition at line 35 of file test-strcspn.c.

{
  const char *r, *str = s;
  char c;

  while ((c = *s++) != '\0')
    for (r = rej; *r != '\0'; ++r)
      if (*r == c)
       return s - str - 1;
  return s - str - 1;
}
size_t stupid_strcspn ( const char *  s,
const char *  rej 
)

Definition at line 48 of file test-strcspn.c.

{
  size_t ns = strlen (s), nrej = strlen (rej);
  size_t i, j;

  for (i = 0; i < ns; ++i)
    for (j = 0; j < nrej; ++j)
      if (s[i] == rej[j])
       return i;
  return i;
}

Here is the call graph for this function: