<commit_before>/* ****************************************************************************
*
* FILE			paDefaultValues.c
*
* AUTHOR		<NAME>
*
* HISTORY
* $Log: $
*
*/
#include <stdio.h>               /* stderr, stdout, ...                      */
#include <string.h>              /* strncmp, strspn, ...                     */
#include <cstdlib>               /* C++ free()                               */

#include "baStd.h"               /* BA standard header file                  */
#include "logMsg/logMsg.h"       /* LM_ENTRY, LM_EXIT, ...                   */

#include "parseArgs/parseArgs.h" /* PaArgument                               */
#include "paPrivate.h"           /* paBuiltin                                */
#include "paTraceLevels.h"       /* LmtPaDefVal, LmtPaLimits, ...            */
#include "paWarning.h"           /* paWaringInit, paWarningAdd               */
#include "paIterate.h"           /* paIterateInit, paIterateNext             */
#include "paDefaultValues.h"     /* Own interface                            */



/* ****************************************************************************
*
* paDefaultValues - set default values, initially
*/
int paDefaultValues(PaiArgument* paList)
{
    PaiArgument*  aP;
    char          w[512];

    LM_ENTRY();

    paIterateInit();
    while ((aP = paIterateNext(paList)) != NULL)
    {
        long long*  defP;

        if (aP->def == PaNoDef)
            continue;

        aP->from = PafDefault;
        if (aP->type != PaString)
            LM_T(LmtPaDefVal, ("setting default value for '%s' (0x%x)", aP->name, (int) aP->def));
        else
            LM_T(LmtPaDefVal, ("setting default value for '%s' (%s)", aP->name, (char*) aP->def));

        defP = (long long*) &aP->def;

        switch (aP->type)
        {
        case PaInt:     *((int*)               aP->varP) = *defP;                    break;
        case PaIntU:    *((int*)               aP->varP) = *defP;                    break;
        case PaInt64:   *((long int*)          aP->varP) = *defP;                    break;
        case PaIntU64:  *((unsigned long int*) aP->varP) = *defP;                    break;
        case PaChar:    *((char*)              aP->varP) = (char)      *defP;        break;
        case PaCharU:   *((char*)              aP->varP) = (char)      *defP;        break;
        case PaShort:   *((short*)             aP->varP) = (short)     *defP;        break;
        case PaShortU:  *((short*)             aP->varP) = (short)     *defP;        break;
        case PaBoolean: *((bool*)              aP->varP) = (bool)      *defP;        break;
        case PaFloat:   *((float*)             aP->varP) = (float)     *defP;        break;
        case PaDouble:  *((double*)            aP->varP) = (double)    *defP;        break;
                       
        case PaString:
            if (aP->def)
            {
                if (((char*) aP->def)[0] != 0)
                    strcpy((char*) aP->varP, (char*) aP->def);
            }
            else
                ((char*) aP->varP)[0] = 0;
            break;

        default:
            sprintf(w, "type %d unknown for %s",
                    aP->type, aP->name);
            PA_WARNING(PasProgrammingError, w);
            continue;
        }<commit_msg>Fixed an inconsistency complained about by valgrind<commit_after>/* ****************************************************************************
*
* FILE			paDefaultValues.c
*
* AUTHOR		<NAME>
*
* HISTORY
* $Log: $
*
*/
#include <stdio.h>               /* stderr, stdout, ...                      */
#include <string.h>              /* strncmp, strspn, ...                     */
#include <cstdlib>               /* C++ free()                               */

#include "baStd.h"               /* BA standard header file                  */
#include "logMsg/logMsg.h"       /* LM_ENTRY, LM_EXIT, ...                   */

#include "parseArgs/parseArgs.h" /* PaArgument                               */
#include "paPrivate.h"           /* paBuiltin                                */
#include "paTraceLevels.h"       /* LmtPaDefVal, LmtPaLimits, ...            */
#include "paWarning.h"           /* paWaringInit, paWarningAdd               */
#include "paIterate.h"           /* paIterateInit, paIterateNext             */
#include "paDefaultValues.h"     /* Own interface                            */



/* ****************************************************************************
*
* paDefaultValues - set default values, initially
*/
int paDefaultValues(PaiArgument* paList)
{
    PaiArgument*  aP;
    char          w[512];

    LM_ENTRY();

    paIterateInit();
    while ((aP = paIterateNext(paList)) != NULL)
    {
        long long*  defP;

        if (aP->def == PaNoDef)
            continue;

        aP->from = PafDefault;
        if (aP->type != PaString)
            LM_T(LmtPaDefVal, ("setting default value for '%s' (0x%x)", aP->name, (int) aP->def));
        else
            LM_T(LmtPaDefVal, ("setting default value for '%s' (%s)", aP->name, (char*) aP->def));

        defP = (long long*) &aP->def;

        switch (aP->type)
        {
        case PaInt:     *((int*)               aP->varP) = *defP;                    break;
        case PaIntU:    *((int*)               aP->varP) = *defP;                    break;
        case PaInt64:   *((long int*)          aP->varP) = *defP;                    break;
        case PaIntU64:  *((unsigned long int*) aP->varP) = *defP;                    break;
        case PaChar:    *((char*)              aP->varP) = (char)      *defP;        break;
        case PaCharU:   *((char*)              aP->varP) = (char)      *defP;        break;
        case PaShort:   *((short*)             aP->varP) = (short)     *defP;        break;
        case PaShortU:  *((short*)             aP->varP) = (short)     *defP;        break;
        case PaBoolean: *((bool*)              aP->varP) = (bool)      *defP;        break;
        case PaFloat:   *((float*)             aP->varP) = (float)     *defP;        break;
        case PaDouble:  *((double*)            aP->varP) = (double)    *defP;        break;
                       
        case PaString:
            if (aP->def)
            {
                if (((char*) aP->def)[0] != 0)
                {
                    if ((char*) aP->varP != (char*) aP->def)
                        strcpy((char*) aP->varP, (char*) aP->def);
                }
            }
            else
                ((char*) aP->varP)[0] = 0;
            break;

        default:
            sprintf(w, "type %d unknown for %s",
                    aP->type, aP->name);
            PA_WARNING(PasProgrammingError, w);
            continue;
        }
{'fraction_non_alphanumeric': 0.18647328696166937, 'fraction_numerical': 0.0035518721326032263, 'mean_word_length': 1.2823370482944951, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 67, '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': '4493289', 'n_tokens_mistral': 2084, 'n_tokens_neox': 1957, 'n_words': 437}