X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-var-store.c;h=26c1ee4d34e6cd0d5b13b4f2f89c78e1d5b865c8;hb=82217038368a953179398d9ecc7b80169a1b9ddc;hp=092de58cafa0ed89f827d61a617c9008a442e86a;hpb=9e0e4996fad6563f0a1ce628b80db5c23ef8279e;p=pspp-builds.git diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 092de58c..26c1ee4d 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2006 Free Software Foundation + Copyright (C) 2006, 2009 Free Software Foundation 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 @@ -435,7 +435,7 @@ psppire_var_store_clear (PsppireSheetModel *model, glong row, glong col) switch (col) { case PSPPIRE_VAR_STORE_COL_LABEL: - var_set_label (pv, 0); + var_set_label (pv, NULL); return TRUE; break; } @@ -468,13 +468,7 @@ psppire_var_store_set_string (PsppireSheetModel *model, case PSPPIRE_VAR_STORE_COL_NAME: { gboolean ok; - char *s = recode_string (psppire_dict_encoding (var_store->dict), - UTF8, - text, -1); - - ok = psppire_dict_rename_var (var_store->dict, pv, s); - - free (s); + ok = psppire_dict_rename_var (var_store->dict, pv, text); return ok; } case PSPPIRE_VAR_STORE_COL_COLUMNS: @@ -484,10 +478,19 @@ psppire_var_store_set_string (PsppireSheetModel *model, break; case PSPPIRE_VAR_STORE_COL_WIDTH: { - int width = atoi (text); - if ( ! text) return FALSE; + const int width = atoi (text); + if ( ! text) + return FALSE; + + if (width < 0) + return FALSE; + if ( var_is_alpha (pv)) + { + if ( width > MAX_STRING ) + return FALSE; var_set_width (pv, width); + } else { bool for_input @@ -531,11 +534,7 @@ psppire_var_store_set_string (PsppireSheetModel *model, break; case PSPPIRE_VAR_STORE_COL_LABEL: { - gchar *s = recode_string (psppire_dict_encoding (var_store->dict), - UTF8, - text, -1); - var_set_label (pv, s); - free (s); + var_set_label (pv, text); return TRUE; } break; @@ -574,6 +573,7 @@ text_for_column (PsppireVarStore *vs, N_("Custom"), N_("String") }; + enum {VT_NUMERIC, VT_COMMA, VT_DOT, VT_SCIENTIFIC, VT_DATE, VT_DOLLAR, VT_CUSTOM, VT_STRING}; @@ -582,8 +582,7 @@ text_for_column (PsppireVarStore *vs, switch (c) { case PSPPIRE_VAR_STORE_COL_NAME: - return recode_string (UTF8, psppire_dict_encoding (dict), - var_get_name (pv), -1); + return xstrdup (var_get_name (pv)); break; case PSPPIRE_VAR_STORE_COL_TYPE: { @@ -670,8 +669,12 @@ text_for_column (PsppireVarStore *vs, } break; case PSPPIRE_VAR_STORE_COL_LABEL: - return recode_string (UTF8, psppire_dict_encoding (dict), - var_get_label (pv), -1); + { + const char *label = var_get_label (pv); + if (label) + return xstrdup (label); + return NULL; + } break; case PSPPIRE_VAR_STORE_COL_MISSING: @@ -685,27 +688,18 @@ text_for_column (PsppireVarStore *vs, return g_locale_to_utf8 (gettext (none), -1, 0, 0, err); else { - gchar *ss; - GString *gstr = g_string_sized_new (10); const struct val_labs *vls = var_get_value_labels (pv); - struct val_labs_iterator *ip = 0; - struct val_lab *vl = val_labs_first_sorted (vls, &ip); + const struct val_lab **labels = val_labs_sorted (vls); + const struct val_lab *vl = labels[0]; + free (labels); g_assert (vl); { - gchar *const vstr = value_to_text (vl->value, *write_spec); + gchar *const vstr = value_to_text (vl->value, dict, *write_spec); - g_string_printf (gstr, "{%s,\"%s\"}_", vstr, vl->label); - g_free (vstr); + return g_strdup_printf ( "{%s,\"%s\"}_", vstr, val_lab_get_label (vl)); } - - val_labs_done (&ip); - - ss = recode_string (UTF8, psppire_dict_encoding (dict), - gstr->str, gstr->len); - g_string_free (gstr, TRUE); - return ss; } } break;