<commit_before>#!/bin/sh

# Validate the header of a ROM passed through stdin (update the logo and the
# header checksum) and enable the GBC and/or the SGB enhancements.
# Output the ROM with the updated header on stdout.
#
# Used in the Makefile when generating the menu files.

while getopts "cs" opt; do
    case $opt in
    c)  color=1;;
    s)  super=1;;
    esac
done

# need to do some magic to make this portable to OS X and Linux
AWK="awk"
which gawk > /dev/null
if [[ $? == 0 ]]; then
    AWK="gawk"
fi

OD="od"
which god > /dev/null
if [[ $? == 0 ]]; then
    OD="god"
fi

$OD -v -Ad -tu1 -w1 | $AWK -vcolor=$color -vsuper=$super '
BEGIN {
    split( \
        " 206 237 102 102 204  13   0  11   3 115   0 131   0  12   0  13" \
        "  0   8  17  31 136 137   0  14 220 204 110 230 221 221 217 153" \
        " 187 187 103  99 110  14 236 204 221 220 153 159 187 185  51  62",
        logo)
}

$2 == "" {next}

{ out = $2 }

# 0x104 to 0x133 - Update the logo
$1 >= 260 && $1 <= 307 {
    out = logo[$1-259]
}

# 0x144: Update the GBC flag
color && $1 == 323 {
    if (out < 128)<commit_msg>Fix awk command when locale is wrong<commit_after>#!/bin/sh

# Validate the header of a ROM passed through stdin (update the logo and the
# header checksum) and enable the GBC and/or the SGB enhancements.
# Output the ROM with the updated header on stdout.
#
# Used in the Makefile when generating the menu files.

while getopts "cs" opt; do
    case $opt in
    c)  color=1;;
    s)  super=1;;
    esac
done

# need to do some magic to make this portable to OS X and Linux
AWK="awk"
which gawk > /dev/null
if [[ $? == 0 ]]; then
    AWK="gawk"
fi

OD="od"
which god > /dev/null
if [[ $? == 0 ]]; then
    OD="god"
fi

$OD -v -Ad -tu1 -w1 | LC_ALL=C $AWK -vcolor=$color -vsuper=$super '
BEGIN {
    split( \
        " 206 237 102 102 204  13   0  11   3 115   0 131   0  12   0  13" \
        "  0   8  17  31 136 137   0  14 220 204 110 230 221 221 217 153" \
        " 187 187 103  99 110  14 236 204 221 220 153 159 187 185  51  62",
        logo)
}

$2 == "" {next}

{ out = $2 }

# 0x104 to 0x133 - Update the logo
$1 >= 260 && $1 <= 307 {
    out = logo[$1-259]
}

# 0x144: Update the GBC flag
color && $1 == 323 {
    if (out < 128)
{'fraction_non_alphanumeric': 0.11976847729296528, 'fraction_numerical': 0.13891362422083706, 'mean_word_length': 2.228448275862069, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '605151', 'n_tokens_mistral': 1093, 'n_tokens_neox': 832, 'n_words': 356}