<commit_before>#include "config.h"

#ifdef ENABLE_DEBUG

#include <stdarg.h>

#include <glib.h>

#include <telepathy-glib/debug.h>

#include "debug.h"

static SIPDebugFlags flags = 0;

static const GDebugKey keys[] = {
  { "media-channel", SIP_DEBUG_MEDIA },
  { "connection",    SIP_DEBUG_CONNECTION },
  { "im",            SIP_DEBUG_IM },
  { 0, },
};

void sip_debug_set_flags_from_env ()
{
  guint nkeys;
  const gchar *flags_string;

  for (nkeys = 0; keys[nkeys].value; nkeys++);

  flags_string = g_getenv ("SOFIASIP_DEBUG");

  if (flags_string)
    {
      tp_debug_set_flags_from_env ("SOFIASIP_DEBUG");
      sip_debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
    }
}

void sip_debug_set_flags (SIPDebugFlags new_flags)
{
  flags |= new_flags;
}

gboolean sip_debug_flag_is_set (SIPDebugFlags flag)
{
  return flag & flags;
}

void sip_debug (SIPDebugFlags flag,
                const gchar *format,
                ...)
{
  if (flag & flags)
    {
      va_list args;
      va_start (args, format);
      g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
      va_end (args);
    }
}

#endif /* ENABLE_DEBUG */
<commit_msg>Size of the keys array is known at compile time, use it<commit_after>#include "config.h"

#ifdef ENABLE_DEBUG

#include <stdarg.h>

#include <glib.h>

#include <telepathy-glib/debug.h>

#include "debug.h"

static SIPDebugFlags flags = 0;

static const GDebugKey keys[] = {
  { "media-channel", SIP_DEBUG_MEDIA },
  { "connection",    SIP_DEBUG_CONNECTION },
  { "im",            SIP_DEBUG_IM },
};

void sip_debug_set_flags_from_env ()
{
  const gchar *flags_string;

  flags_string = g_getenv ("SOFIASIP_DEBUG");

  if (flags_string)
    {
      tp_debug_set_flags_from_env ("SOFIASIP_DEBUG");
      sip_debug_set_flags (g_parse_debug_string (flags_string,
                                                 keys,
                                                 G_N_ELEMENTS(keys)));
    }
}

void sip_debug_set_flags (SIPDebugFlags new_flags)
{
  flags |= new_flags;
}

gboolean sip_debug_flag_is_set (SIPDebugFlags flag)
{
  return flag & flags;
}

void sip_debug (SIPDebugFlags flag,
                const gchar *format,
                ...)
{
  if (flag & flags)
    {
      va_list args;
      va_start (args, format);
      g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
      va_end (args);
    }
}

#endif /* ENABLE_DEBUG */

{'fraction_non_alphanumeric': 0.11439267886855241, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 2.7874015748031495, 'pattern_counts': {'":': 0, '<': 9, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1716116', 'n_tokens_mistral': 892, 'n_tokens_neox': 881, 'n_words': 179}