<commit_before>#include "e.h"

/* local subsystem functions */
static void _e_order_free(E_Order *eo);
static void _e_order_cb_monitor(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
static void _e_order_read(E_Order *eo);
static void _e_order_save(E_Order *eo);
static Eina_Bool _e_order_cb_efreet_cache_update(void *data, int ev_type, void *ev);

static Eina_List *orders = NULL;
static Eina_List *handlers = NULL;

/* externally accessible functions */
EINTERN int
e_order_init(void)
{
   char *menu_file = NULL;
   
   handlers = 
     eina_list_append(handlers, 
                      ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, 
                                              _e_order_cb_efreet_cache_update, 
                                              NULL));
   if (e_config->default_system_menu)
      menu_file = strdup(e_config->default_system_menu);
   if (!menu_file)
      menu_file = strdup("/etc/xdg/menus/applications.menu");
   if (menu_file)
     {
        if (!ecore_file_exists(menu_file))
          {
             char buf[PATH_MAX];
             
             free(menu_file);
             snprintf(buf, sizeof(buf), "/etc/xdg/menus/enlightenment.menu");
             if (ecore_file_exists(buf)) menu_file = strdup(buf);
             else
               {
                  snprintf(buf, sizeof(buf), 
                           "%s/etc/xdg/menus/enlightenment.menu",
                           e_prefix_get());
                  if (ecore_file_exists(buf)) menu_file = strdup(buf);
               }
          }
     }
   efreet_menu_file_set(menu_file);
   if (menu_file) free(menu_file);
   return 1;
}

EINTERN int
e_order_shutdown(void)
{
   orders = eina_list_free(orders);

   E_FREE_LIST(handlers, ecore_event_handler_del);
   return 1;
}

EAPI E_Order *
e_order_new(const char *path)
{<commit_msg>e17: avoid segfault with no xdg menu<commit_after>#include "e.h"

/* local subsystem functions */
static void _e_order_free(E_Order *eo);
static void _e_order_cb_monitor(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
static void _e_order_read(E_Order *eo);
static void _e_order_save(E_Order *eo);
static Eina_Bool _e_order_cb_efreet_cache_update(void *data, int ev_type, void *ev);

static Eina_List *orders = NULL;
static Eina_List *handlers = NULL;

/* externally accessible functions */
EINTERN int
e_order_init(void)
{
   char *menu_file = NULL;
   
   handlers = 
     eina_list_append(handlers, 
                      ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, 
                                              _e_order_cb_efreet_cache_update, 
                                              NULL));
   if (e_config->default_system_menu)
      menu_file = strdup(e_config->default_system_menu);
   if (!menu_file)
      menu_file = strdup("/etc/xdg/menus/applications.menu");
   if (menu_file)
     {
        if (!ecore_file_exists(menu_file))
          {
             char buf[PATH_MAX];
             
             free(menu_file);
             menu_file = NULL;
             snprintf(buf, sizeof(buf), "/etc/xdg/menus/enlightenment.menu");
             if (ecore_file_exists(buf)) menu_file = strdup(buf);
             else
               {
                  snprintf(buf, sizeof(buf), 
                           "%s/etc/xdg/menus/enlightenment.menu",
                           e_prefix_get());
                  if (ecore_file_exists(buf)) menu_file = strdup(buf);
               }
          }
     }
   efreet_menu_file_set(menu_file);
   if (menu_file) free(menu_file);
   return 1;
}

EINTERN int
e_order_shutdown(void)
{
   orders = eina_list_free(orders);

   E_FREE_LIST(handlers, ecore_event_handler_del);
   return 1;
}

EAPI E_Order *
e_order_new(const char *path)
{
{'fraction_non_alphanumeric': 0.09695218076720967, 'fraction_numerical': 0.0015764582238570678, 'mean_word_length': 2.2678111587982834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4507838', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1246, 'n_words': 226}