<commit_before>/* Fixes for issues described on http://phpsadness.com/.
 *
 * Most of the macros in this file are simple function replacements, so
 * although the behaviour of a function may change, the calls need not be
 * modified.
 */
#ifndef PHPHAPPINESS_H
#define PHPHAPPINESS_H

// Issue 48 (http://phpsadness.com/sad/48):
// Function naming is inconsistent with "to" and "2". Now you can use either.

#define stream_copy_2_stream stream_copy_to_stream
#define str2lower strtolower
#define str2time strtotime
#define str2upper strtoupper
#define unix2jd unixtojd

#define bintohex bin2hex
#define degtorad deg2rad
#define radtoreg rad2deg
#define hextobin hex2bin
#define iptolong ip2long
#define longtoip long2ip
#define nltobr nl2br

// Issue 43 (http://phpsadness.com/sad/43):
// The array_fill() function doesn't allow length 0

#define array_fill(s, n, v) (!n ? array() : array_fill(s, n, v))

// Issue 39 (http://phpsadness.com/sad/39):
// Declaring a function called __lambda_func() completely breaks
// create_function()

#define __lambda_func ___lambda_func

// Issue 35 (http://phpsadness.com/sad/35):
// The explode() function won't split with empty string

#define explode(d, s) (strlen(d) ? explode(d, s) : str_split(s))

//                         Needle / Haystack problems

// Issue 9 (http://phpsadness.com/sad/9):
// Order of arguments (array/string search)

// Let's just make everything haystack / needle for consistency.
// TODO: Use __VA_ARGS__ and nested macros for third, optional argument.

#define array_key_exists(haystack, needle) array_key_exists(needle, haystack)
#define in_array(haystack, needle) in_array(haystack, needle, true)
#define array_search(haystack, needle) array_search(haystack, needle, true)

#endif
<commit_msg>Array operations support optional parameters<commit_after>/* Fixes for issues described on http://phpsadness.com/.
 *
 * Most of the macros in this file are simple function replacements, so
 * although the behaviour of a function may change, the calls need not be
 * modified.
 */
#ifndef PHPHAPPINESS_H
#define PHPHAPPINESS_H

// Issue 48 (http://phpsadness.com/sad/48):
// Function naming is inconsistent with "to" and "2". Now you can use either.

#define stream_copy_2_stream stream_copy_to_stream
#define str2lower strtolower
#define str2time strtotime
#define str2upper strtoupper
#define unix2jd unixtojd

#define bintohex bin2hex
#define degtorad deg2rad
#define radtoreg rad2deg
#define hextobin hex2bin
#define iptolong ip2long
#define longtoip long2ip
#define nltobr nl2br

// Issue 43 (http://phpsadness.com/sad/43):
// The array_fill() function doesn't allow length 0

#define array_fill(s, n, v) (!n ? array() : array_fill(s, n, v))

// Issue 39 (http://phpsadness.com/sad/39):
// Declaring a function called __lambda_func() completely breaks
// create_function()

#define __lambda_func ___lambda_func

// Issue 35 (http://phpsadness.com/sad/35):
// The explode() function won't split with empty string

#define explode(d, s) (strlen(d) ? explode(d, s) : str_split(s))

//                         Needle / Haystack problems

// Issue 9 (http://phpsadness.com/sad/9):
// Order of arguments (array/string search)

// Let's just make everything haystack / needle for consistency.

#define array_key_exists(haystack, needle, ...) \
    array_key_exists(needle, haystack, ##__VA_ARGS__)

#define in_array(haystack, needle, ...) \
    in_array(haystack, needle, ##__VA_ARGS__)

#define array_search(haystack, needle, ...) \
    array_search(needle, haystack, ##__VA_ARGS__)

#endif

{'fraction_non_alphanumeric': 0.11114237478897017, 'fraction_numerical': 0.018007878446820485, 'mean_word_length': 4.3059701492537314, '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': '4960317', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1168, 'n_words': 369}