Algorithm-LUHN_XS

 view release on metacpan or  search on metacpan

LUHN_XS.xs  view on Meta::CPAN


/* you may be asking...why? */
/* well, windows and older versions of MacOS don't have strndup, so... */
unsigned char * _al_substr(unsigned const char* src, const int offset, const int len) {
    unsigned char * sub = (unsigned char*)malloc(len+1);
    memcpy(sub, src + offset, len);
    sub[len] = 0;
    return sub;
}

/* not thread safe, don't use this module with perl threads */
int _al_init_vc(SV* hash_ref) {
  HV* hash;
  HE* hash_entry;
  int num_keys, i;
  SV* sv_key;
  SV* sv_val;
  for (i=0;i<256;++i) {
      _al_vc[i]=-1;
  }
  hash = (HV*)SvRV(hash_ref);

README  view on Meta::CPAN


        If you do not provide LIST, this function returns the current valid
        character map.

        Note that the check_digit_rff() and is_valid_rff() functions do not
        support the valid_chars() function. Both only support numeric
        inputs, and map them to their literal values.

CAVEATS
    This module, because of how valid_chars() stores data in the XS portion,
    is NOT thread safe.

    The _fast and _rff versions of is_valid() and check_digit() don't have
    the same return values for failure as the original Algorithm::LUHN
    module. Specifically:

    *   is_valid_fast() and is_valid_rff() return 0 on failure, but
        is_valid() returns the empty string.

    *   check_digit_fast() and check_digit_rff() return -1 on failure, but
        check_digit() returns undef.

README.md  view on Meta::CPAN

    If you do not provide LIST,
    this function returns the current valid character map.

    Note that the check\_digit\_rff() and is\_valid\_rff() functions do not support
    the valid\_chars() function.  Both only support numeric inputs, and map them
    to their literal values.

# CAVEATS

This module, because of how valid\_chars() stores data in the XS portion,
is NOT thread safe.

The \_fast and \_rff versions of is\_valid() and check\_digit() don't have the 
same return values for failure as the original Algorithm::LUHN module.
Specifically: 

- is\_valid\_fast() and is\_valid\_rff() return 0 on failure, but
        is\_valid() returns the empty string.
- check\_digit\_fast() and check\_digit\_rff() return -1 on failure, but
        check\_digit() returns undef.

lib/Algorithm/LUHN_XS.pm  view on Meta::CPAN


=back

=cut

__END__

=head1 CAVEATS

This module, because of how valid_chars() stores data in the XS portion,
is NOT thread safe.

The _fast and _rff versions of is_valid() and check_digit() don't have the 
same return values for failure as the original Algorithm::LUHN module.
Specifically: 

=over 4

=item * is_valid_fast() and is_valid_rff() return 0 on failure, but
        is_valid() returns the empty string.



( run in 1.480 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )