<commit_before>/*
 * $Id$
 * Copyright (C) 2008, The Perl Foundation.
 */

#include <stdarg.h>
#include <string.h>
#include "pirmacro.h"
#include "pircompiler.h"
#include "pirmacro.h"
#include "parrot/parrot.h"



/*

=head1 FUNCTIONS

This file contains functions that manage the macro datastructures.
Actual expansion of the macros is completely handled in the lexer (pir.l).

=over 4

=cut

*/

static void check_size(macro_def * const macro, unsigned length);




/*

=item C<macro_def *
new_macro(macro_table * const table, char * const name, int lineno)>

Create a new macro definition node and store it in the macro_table C<table>

=cut

*/
PARROT_MALLOC
PARROT_IGNORABLE_RESULT
macro_def *
new_macro(macro_table * const table, char const * const name, int lineno, int takes_args,
          unsigned initsize)
{
    macro_def *macro   = (macro_def *)mem_sys_allocate(sizeof (macro_def));

    macro->name        = name;
    macro->linedefined = lineno;
    macro->takes_args  = takes_args;

    if (initsize) /* only call allocate function if initsize != zero */
        macro->body    = (char *)mem_sys_allocate_zeroed(sizeof (char) * initsize);

    macro->buffersize  = initsize;
    macro->cursor      = macro->body;
    /* link the macro in the list */
    macro->next        = table->definitions;
    table->definitions = macro;

    return macro;
}

/*

=item C<macro_param *
new_macro_param(char const * const value)

Constructor for a C<macro_param> struct object. Initializes
the C<name> attribute of the C<macro_param> object to C<value>.
A pointer to the newly allocated C<macro_param> object is returned.

=cut

*/
PARROT_MALLOC
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
macro_param *
new_macro_param(char const * const value) {
    macro_param *param = (macro_param *)mem_sys_allocate(sizeof (macro_param));
    param->name        = value;
    param->next        = NULL;
    return param;
}

/*

=item C<void
add_macro_param(macro_def * const macro, char * const name)>

Add a macro parameter by name of C<name> to the macro definition C<macro>.

=cut<commit_msg>[pirc] fix pod error<commit_after>/*
 * $Id$
 * Copyright (C) 2008, The Perl Foundation.
 */

#include <stdarg.h>
#include <string.h>
#include "pirmacro.h"
#include "pircompiler.h"
#include "pirmacro.h"
#include "parrot/parrot.h"



/*

=head1 FUNCTIONS

This file contains functions that manage the macro datastructures.
Actual expansion of the macros is completely handled in the lexer (pir.l).

=over 4

=cut

*/

static void check_size(macro_def * const macro, unsigned length);




/*

=item C<macro_def *
new_macro(macro_table * const table, char * const name, int lineno)>

Create a new macro definition node and store it in the macro_table C<table>

=cut

*/
PARROT_MALLOC
PARROT_IGNORABLE_RESULT
macro_def *
new_macro(macro_table * const table, char const * const name, int lineno, int takes_args,
          unsigned initsize)
{
    macro_def *macro   = (macro_def *)mem_sys_allocate(sizeof (macro_def));

    macro->name        = name;
    macro->linedefined = lineno;
    macro->takes_args  = takes_args;

    if (initsize) /* only call allocate function if initsize != zero */
        macro->body    = (char *)mem_sys_allocate_zeroed(sizeof (char) * initsize);

    macro->buffersize  = initsize;
    macro->cursor      = macro->body;
    /* link the macro in the list */
    macro->next        = table->definitions;
    table->definitions = macro;

    return macro;
}

/*

=item C<macro_param *
new_macro_param(char const * const value)>

Constructor for a C<macro_param> struct object. Initializes
the C<name> attribute of the C<macro_param> object to C<value>.
A pointer to the newly allocated C<macro_param> object is returned.

=cut

*/
PARROT_MALLOC
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
macro_param *
new_macro_param(char const * const value) {
    macro_param *param = (macro_param *)mem_sys_allocate(sizeof (macro_param));
    param->name        = value;
    param->next        = NULL;
    return param;
}

/*

=item C<void
add_macro_param(macro_def * const macro, char * const name)>

Add a macro parameter by name of C<name> to the macro definition C<macro>.

=cut
{'fraction_non_alphanumeric': 0.10414680648236416, 'fraction_numerical': 0.002859866539561487, 'mean_word_length': 3.7051569506726456, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 52, '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': '7434370', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1383, 'n_words': 418}