<commit_before>/* GTK - The GIMP Toolkit
 * Copyright 1998-2002 <NAME>, Red Hat, Inc., and others.
 * Copyright (C) 2003 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <string.h>

#include "gtkmodules.h"
#include "gtksettings.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtkmodulesprivate.h"
#include "gtkintl.h"

#include <gmodule.h>

typedef struct _GtkModuleInfo GtkModuleInfo;
struct _GtkModuleInfo
{
  GModule                 *module;
  gint                     ref_count;
  GtkModuleInitFunc        init_func;
  GtkModuleDisplayInitFunc display_init_func;
  GSList                  *names;
};

static GSList *gtk_modules = NULL;

static gboolean default_display_opened = FALSE;

/* Saved argc, argv for delayed module initialization
 */
static gint    gtk_argc = 0;
static gchar **gtk_argv = NULL;

static gchar **
get_module_path (void)
{
  const gchar *module_path_env;
  const gchar *exe_prefix;
  const gchar *home_dir;
  gchar *home_gtk_dir = NULL;
  gchar *module_path;
  gchar *default_dir;
  static gchar **result = NULL;

  if (result)
    return result;

  home_dir = g_get_home_dir();
  if (home_dir)
    home_gtk_dir = g_build_filename (home_dir, ".gtk-3.0", NULL);

  module_path_env = g_getenv ("GTK_PATH");
  exe_prefix = g_getenv ("GTK_EXE_PREFIX");

  if (exe_prefix)
    default_dir = g_build_filename (exe_prefix, "lib", "gtk-3.0", NULL);
  else
    default_dir = g_build_filename (_gtk_get_libdir (), "gtk-3.0", NULL);

  if (module_path_env && home_gtk_dir)
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				module_path_env, home_gtk_dir, default_dir, NULL);
  else if (module_path_env)
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				module_path_env, default_dir, NULL);
  else if (home_gtk_dir)
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				home_gtk_dir, default_dir, NULL);
  else
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				default_dir, NULL);

  g_free (home_gtk_dir);
  g_free (default_dir);

  result = pango_split_file_list (module_path);
  g_free (module_path);
<commit_msg>Don't load binary modules from the home directory by default<commit_after>/* GTK - The GIMP Toolkit
 * Copyright 1998-2002 <NAME>, Red Hat, Inc., and others.
 * Copyright (C) 2003 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <string.h>

#include "gtkmodules.h"
#include "gtksettings.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtkmodulesprivate.h"
#include "gtkintl.h"

#include <gmodule.h>

typedef struct _GtkModuleInfo GtkModuleInfo;
struct _GtkModuleInfo
{
  GModule                 *module;
  gint                     ref_count;
  GtkModuleInitFunc        init_func;
  GtkModuleDisplayInitFunc display_init_func;
  GSList                  *names;
};

static GSList *gtk_modules = NULL;

static gboolean default_display_opened = FALSE;

/* Saved argc, argv for delayed module initialization
 */
static gint    gtk_argc = 0;
static gchar **gtk_argv = NULL;

static gchar **
get_module_path (void)
{
  const gchar *module_path_env;
  const gchar *exe_prefix;
  gchar *module_path;
  gchar *default_dir;
  static gchar **result = NULL;

  if (result)
    return result;

  module_path_env = g_getenv ("GTK_PATH");
  exe_prefix = g_getenv ("GTK_EXE_PREFIX");

  if (exe_prefix)
    default_dir = g_build_filename (exe_prefix, "lib", "gtk-3.0", NULL);
  else
    default_dir = g_build_filename (_gtk_get_libdir (), "gtk-3.0", NULL);

  if (module_path_env)
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				module_path_env, default_dir, NULL);
  else
    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
				default_dir, NULL);

  g_free (default_dir);

  result = pango_split_file_list (module_path);
  g_free (module_path);

{'fraction_non_alphanumeric': 0.09012029185564978, 'fraction_numerical': 0.007493591007690791, 'mean_word_length': 3.90048309178744, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2079701', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1656, 'n_words': 524}