<commit_before># Copyright (C) 2004-2009, Parrot Foundation.
# $Id$

=head1 TITLE

pcre.pir - user interface to Perl-Compatible Regular Expression library

=head1 SYNOPSIS

    load_bytecode 'pcre.pbc'

    .local pmc func, lib
    func = get_hll_global ['PCRE'], 'init'
    lib = func()

    func = get_hll_global ['PCRE'], 'compile'
    ( regex, error, errptr )= func( pat, options )

    func = get_hll_global ['PCRE'], 'match'
    ( ok, result )= func( regex, string, start, options )

    func = get_hll_global ['PCRE'], 'dollar'
    match = func( string, ok, result, i )

=head1 DESCRIPTION

This is the user interface to PCRE. Use this to initialize the library,
compile regexes, match against strings, and return the results.
All functions are found in the 'PCRE' namespace.

The NCI interface is contained in libpcre.pir.

=cut


.namespace ['PCRE']


=over 4

=item sub init()

Initialize the pcre library. The library handle is returned as a PMC
and is additionally stored as global 'PCRE', 'lib'.

=cut

.include "sysinfo.pasm"

.sub init
    .local pmc libpcre
    .local pmc pcre_function
    .local string osname
    .local int loaded

    osname = sysinfo .SYSINFO_PARROT_OS

    if 'MSWin32' == osname goto LIB_WIN32
    if 'cygwin'  == osname goto LIB_CYGWIN

LIB_DEFAULT:
    loadlib libpcre, 'libpcre'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
    branch LIB_FAILED

LIB_WIN32:
    # Usually it's pcre.dll
    loadlib libpcre, 'pcre'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
    # But maybe you have GnuWin32 pcre3.dll?
    loadlib libpcre, 'pcre3'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
    branch LIB_FAILED<commit_msg>[lib] try harder to load libpcre in the default platform case<commit_after># Copyright (C) 2004-2009, Parrot Foundation.
# $Id$

=head1 TITLE

pcre.pir - user interface to Perl-Compatible Regular Expression library

=head1 SYNOPSIS

    load_bytecode 'pcre.pbc'

    .local pmc func, lib
    func = get_hll_global ['PCRE'], 'init'
    lib = func()

    func = get_hll_global ['PCRE'], 'compile'
    ( regex, error, errptr )= func( pat, options )

    func = get_hll_global ['PCRE'], 'match'
    ( ok, result )= func( regex, string, start, options )

    func = get_hll_global ['PCRE'], 'dollar'
    match = func( string, ok, result, i )

=head1 DESCRIPTION

This is the user interface to PCRE. Use this to initialize the library,
compile regexes, match against strings, and return the results.
All functions are found in the 'PCRE' namespace.

The NCI interface is contained in libpcre.pir.

=cut


.namespace ['PCRE']


=over 4

=item sub init()

Initialize the pcre library. The library handle is returned as a PMC
and is additionally stored as global 'PCRE', 'lib'.

=cut

.include "sysinfo.pasm"

.sub init
    .local pmc libpcre
    .local pmc pcre_function
    .local string osname
    .local int loaded

    osname = sysinfo .SYSINFO_PARROT_OS

    if 'MSWin32' == osname goto LIB_WIN32
    if 'cygwin'  == osname goto LIB_CYGWIN

LIB_DEFAULT:
# Plain name
    loadlib libpcre, 'libpcre'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
# Shared object name
    loadlib libpcre, 'libpcre.so'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
# soname of recent version
    loadlib libpcre, 'libpcre.so.3'
    loaded = defined libpcre
    if loaded goto LIB_LOADED

    branch LIB_FAILED

LIB_WIN32:
    # Usually it's pcre.dll
    loadlib libpcre, 'pcre'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
    # But maybe you have GnuWin32 pcre3.dll?
    loadlib libpcre, 'pcre3'
    loaded = defined libpcre
    if loaded goto LIB_LOADED
    branch LIB_FAILED
{'fraction_non_alphanumeric': 0.08455284552845528, 'fraction_numerical': 0.012195121951219513, 'mean_word_length': 3.2572087658592848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3199179', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1239, 'n_words': 446}