[libgda] Removing global variables



commit c302d28f0f2dff24c986dc1342918e9870ce0aa3
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Apr 14 17:50:07 2019 -0500

    Removing global variables

 libgda/gda-data-model-import.c              |  4 +--
 libgda/gda-data-model.c                     |  4 +--
 libgda/gda-init.c                           | 37 ++++------------------------
 libgda/gda-server-operation.c               |  4 +--
 libgda/gda-set.c                            |  2 +-
 libgda/gda-util.c                           |  4 +--
 libgda/libgda-global-variables.h            | 38 -----------------------------
 libgda/meson.build                          |  1 -
 providers/mysql/gda-mysql-recordset.c       |  1 -
 providers/postgres/gda-postgres-recordset.c |  1 -
 10 files changed, 10 insertions(+), 86 deletions(-)
---
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index a36eb446d..9ce58d83f 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -40,8 +40,6 @@
 #include <locale.h>
 #endif
 
-extern gchar *gda_lang_locale;
-
 #include <glib/gi18n-lib.h>
 #include <libgda/gda-decl.h>
 #include <libgda/gda-enums.h>
@@ -1413,7 +1411,7 @@ xml_fetch_next_row (GdaDataModelImport *model)
        const xmlChar *name;
        gint ret;
 
-       const gchar *lang = gda_lang_locale;
+       const gchar *lang = setlocale(LC_ALL, NULL);
 
        GSList *columns = priv->columns;
        GdaColumn *last_column = NULL;
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index c253ab708..c454be53b 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -63,8 +63,6 @@
 #endif
 #include "csv.h"
 
-extern gchar *gda_lang_locale;
-
 static void gda_data_model_default_init (GdaDataModelInterface *iface);
 
 static xmlNodePtr gda_data_model_to_xml_node (GdaDataModel *model, const gint *cols, gint nb_cols, 
@@ -1750,7 +1748,7 @@ add_xml_row (GdaDataModel *model, xmlNodePtr xml_row, GError **error)
        gboolean retval = TRUE;
        gint pos = 0;
 
-       const gchar *lang = gda_lang_locale;
+       const gchar *lang = setlocale(LC_ALL, NULL);
 
        values = g_ptr_array_new ();
        g_ptr_array_set_size (values, gda_data_model_get_n_columns (model));
diff --git a/libgda/gda-init.c b/libgda/gda-init.c
index 764656837..8e903181b 100644
--- a/libgda/gda-init.c
+++ b/libgda/gda-init.c
@@ -43,7 +43,7 @@
  * global variables
  *
  * REM: to use them from another Windows DLL, they have to be declared like:
- *     __declspec(dllimport) extern gchar *gda_numeric_locale;
+ *     __declspec(dllimport) extern gchar *_gda_server_op_dtd;
  *
  * Better yet is to define the IMPORT macro as:
  *
@@ -52,15 +52,12 @@
  *     #else
  *       #define IMPORT
  *     #endif
- *     IMPORT extern gchar *gda_numeric_locale;
+ *     IMPORT extern gchar *_gda_server_op_dtd;
  */
 xmlDtdPtr       _gda_server_op_dtd = NULL;
 xmlDtdPtr              _gda_db_catalog_dtd = NULL;
 
-static gboolean numeric_locale_dyn = FALSE;
-gchar          *gda_numeric_locale = "";
-static gboolean lang_locale_dyn = FALSE;
-gchar          *gda_lang_locale = "";
+static gchar          *gda_lang_locale = "";
 
 /**
  * gda_locale_changed:
@@ -77,35 +74,11 @@ gchar          *gda_lang_locale = "";
 void
 gda_locale_changed (void)
 {
-       /* free previous setting */
-       if (numeric_locale_dyn)
-               g_free (gda_numeric_locale);
-       if (lang_locale_dyn)
-               g_free (gda_lang_locale);
-
-       /* net new settings */
-       gda_numeric_locale = setlocale (LC_NUMERIC, NULL);
-       if (gda_numeric_locale) {
-               numeric_locale_dyn = TRUE;
-               gda_numeric_locale = g_strdup (gda_numeric_locale);
-       }
-       else {
-               numeric_locale_dyn = FALSE;
-               gda_numeric_locale = "";
-       }
 #ifdef HAVE_LC_MESSAGES
-        gda_lang_locale = setlocale (LC_MESSAGES, NULL);
+  gda_lang_locale = setlocale (LC_MESSAGES, NULL);
 #else
-        gda_lang_locale = setlocale (LC_CTYPE, NULL);
+  gda_lang_locale = setlocale (LC_CTYPE, NULL);
 #endif
-       if (gda_lang_locale) {
-               lang_locale_dyn = TRUE;
-               gda_lang_locale = g_strdup (gda_lang_locale);
-       }
-       else {
-               lang_locale_dyn = FALSE;
-               gda_lang_locale = "";
-       }
 }
 
 /**
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index e53ba437f..6152a69f4 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -45,8 +45,6 @@
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
 
-extern gchar *gda_lang_locale;
-
 typedef struct {
        GdaServerOperationType  op_type;
        gboolean                cnc_set;
@@ -803,7 +801,7 @@ load_xml_spec (GdaServerOperation *op, xmlNodePtr specnode, const gchar *root, G
 {
        GdaServerOperationPrivate *priv = gda_server_operation_get_instance_private (op);
        xmlNodePtr node;
-       const gchar *lang = gda_lang_locale;
+       const gchar *lang = setlocale(LC_ALL, NULL);
        GSList *retlist = NULL;
        Node *parent = NULL;
 
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 22850b5cf..e391d3b64 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -1461,7 +1461,7 @@ gda_set_new_from_spec_node (xmlNodePtr xml_spec, GError **error)
        GdaSet *set = NULL;
        GSList *holders = NULL, *sources = NULL;
        GSList *list;
-       const gchar *lang = gda_lang_locale;
+       const gchar *lang = setlocale(LC_ALL, NULL);
 
        xmlNodePtr cur;
        gboolean allok = TRUE;
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index f3f8586f1..d2fd8904f 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -61,8 +61,6 @@
 #include <libgda/sqlite/keywords_hash.h>
 #include "keywords_hash.code" /* this one is dynamically generated */
 
-extern gchar *gda_lang_locale;
-
 /**
  * gda_g_type_to_string:
  * @type: Type to convert from.
@@ -717,7 +715,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
        vnode = node->children;
        if (vnode) {
                xmlChar *this_lang, *isnull;
-               const gchar *lang = gda_lang_locale;
+               const gchar *lang = setlocale(LC_ALL, NULL);
 
                while (vnode) {
                        if (xmlNodeIsText (vnode)) {
diff --git a/libgda/meson.build b/libgda/meson.build
index 6d3a1e926..fc4efea14 100644
--- a/libgda/meson.build
+++ b/libgda/meson.build
@@ -118,7 +118,6 @@ libgda_headers = files([
        'gda-util.h',
        'gda-value.h',
        'gda-xa-transaction.h',
-       'libgda-global-variables.h',
        'gda-data-pivot.h'
 ])
 libgda_headers_all = []
diff --git a/providers/mysql/gda-mysql-recordset.c b/providers/mysql/gda-mysql-recordset.c
index 8a783b803..d7f157186 100644
--- a/providers/mysql/gda-mysql-recordset.c
+++ b/providers/mysql/gda-mysql-recordset.c
@@ -42,7 +42,6 @@
 #include "gda-mysql-provider.h"
 #include "gda-mysql-util.h"
 #include <gda-data-select-private.h>
-#include <libgda/libgda-global-variables.h>
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
diff --git a/providers/postgres/gda-postgres-recordset.c b/providers/postgres/gda-postgres-recordset.c
index 588b1bf98..d40dcc732 100644
--- a/providers/postgres/gda-postgres-recordset.c
+++ b/providers/postgres/gda-postgres-recordset.c
@@ -42,7 +42,6 @@
 #include "gda-postgres-blob-op.h"
 #include "gda-postgres-util.h"
 #include <gda-data-select-private.h>
-#include <libgda/libgda-global-variables.h>
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]