Sha256: 7be4fce8449f91b22b49cd3dff736d5e51b454ce1b712e90aaf725cfaba769fe

Contents?: true

Size: 1023 Bytes

Versions: 22

Compression:

Stored size: 1023 Bytes

Contents

#ifndef ext_help_h
#define ext_help_h

/* not all Ruby implementations support frozen objects (Rubinius does not) */
#if defined(OBJ_FROZEN)
#  define assert_frozen(f) assert(OBJ_FROZEN(f) && "unfrozen object")
#else
#  define assert_frozen(f) do {} while (0)
#endif /* !defined(OBJ_FROZEN) */

static inline int str_cstr_eq(VALUE val, const char *ptr, long len)
{
  return (RSTRING_LEN(val) == len && !memcmp(ptr, RSTRING_PTR(val), len));
}

#define STR_CSTR_EQ(val, const_str) \
  str_cstr_eq(val, const_str, sizeof(const_str) - 1)

/* strcasecmp isn't locale independent */
static int str_cstr_case_eq(VALUE val, const char *ptr, long len)
{
  if (RSTRING_LEN(val) == len) {
    const char *v = RSTRING_PTR(val);

    for (; len--; ++ptr, ++v) {
      if ((*ptr == *v) || (*v >= 'A' && *v <= 'Z' && (*v | 0x20) == *ptr))
        continue;
      return 0;
    }
    return 1;
  }
  return 0;
}

#define STR_CSTR_CASE_EQ(val, const_str) \
  str_cstr_case_eq(val, const_str, sizeof(const_str) - 1)

#endif /* ext_help_h */

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
pitchfork-0.16.0 ext/pitchfork_http/ext_help.h
pitchfork-0.15.0 ext/pitchfork_http/ext_help.h
pitchfork-0.14.0 ext/pitchfork_http/ext_help.h
pitchfork-0.13.0 ext/pitchfork_http/ext_help.h
unicorn-maintained-6.2.0 ext/unicorn_http/ext_help.h
pitchfork-0.12.0 ext/pitchfork_http/ext_help.h
pitchfork-0.11.1 ext/pitchfork_http/ext_help.h
pitchfork-0.11.0 ext/pitchfork_http/ext_help.h
pitchfork-0.10.0 ext/pitchfork_http/ext_help.h
pitchfork-0.9.0 ext/pitchfork_http/ext_help.h
pitchfork-0.8.0 ext/pitchfork_http/ext_help.h
pitchfork-0.7.0 ext/pitchfork_http/ext_help.h
pitchfork-0.6.0 ext/pitchfork_http/ext_help.h
pitchfork-0.5.0 ext/pitchfork_http/ext_help.h
pitchfork-0.4.1 ext/pitchfork_http/ext_help.h
pitchfork-0.4.0 ext/pitchfork_http/ext_help.h
pitchfork-0.3.0 ext/pitchfork_http/ext_help.h
pitchfork-0.2.0 ext/pitchfork_http/ext_help.h
pitchfork-0.1.2 ext/pitchfork_http/ext_help.h
pitchfork-0.1.1 ext/pitchfork_http/ext_help.h