* move some system-initialization to mu_util_init_system;
set G_SLICE env far to always-malloc on FreeBSD, as g_slice does not work correctly there.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** This program is free software; you can redistribute it and/or modify
|
||||||
@ -22,12 +22,14 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <locale.h> /* for setlocale() */
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -66,6 +68,28 @@ mu_util_dir_expand (const char *path)
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mu_util_init_system (void)
|
||||||
|
{
|
||||||
|
/* without setlocale, non-ascii cmdline params (like search
|
||||||
|
* terms) won't work */
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
/* on FreeBSD, it seems g_slice_new and friends lead to
|
||||||
|
* segfaults. So we shut if off */
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
if (!g_setenv ("G_SLICE", "always-malloc", TRUE)) {
|
||||||
|
g_critical ("cannot set G_SLICE");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
MU_LOG_FILE("setting G_SLICE to always-malloc");
|
||||||
|
#endif /*__FreeBSD__*/
|
||||||
|
|
||||||
|
g_type_init ();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable)
|
mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable)
|
||||||
|
|||||||
@ -24,6 +24,14 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* do system-specific initialization. should be called before anything
|
||||||
|
* else. Initializes the locale and Gtype
|
||||||
|
*
|
||||||
|
* @return TRUE if is succeeds, FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean mu_util_init_system (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the expanded path; ie. perform shell expansion on the path
|
* get the expanded path; ie. perform shell expansion on the path
|
||||||
*
|
*
|
||||||
|
|||||||
13
src/mu.cc
13
src/mu.cc
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
b** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** This program is free software; you can redistribute it and/or modify it
|
||||||
** under the terms of the GNU General Public License as published by the
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -20,10 +20,9 @@ b** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
|
||||||
#include <stdio.h> /* for fileno() */
|
#include <stdio.h> /* for fileno() */
|
||||||
#include <locale.h> /* for setlocale() */
|
|
||||||
|
|
||||||
|
#include "mu-util.h"
|
||||||
#include "mu-config.h"
|
#include "mu-config.h"
|
||||||
#include "mu-cmd.h"
|
#include "mu-cmd.h"
|
||||||
#include "mu-log.h"
|
#include "mu-log.h"
|
||||||
@ -48,18 +47,14 @@ init_log (MuConfigOptions *opts)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
MuConfigOptions config;
|
MuConfigOptions config;
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
|
|
||||||
/* without setlocale, non-ascii cmdline params (like search
|
if (!mu_util_init_system())
|
||||||
* terms) won't work */
|
return 1;
|
||||||
setlocale (LC_ALL, "");
|
|
||||||
|
|
||||||
g_type_init ();
|
|
||||||
|
|
||||||
if (!mu_config_init (&config, &argc, &argv))
|
if (!mu_config_init (&config, &argc, &argv))
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user