/*******************************************************************************
- **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
+ **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
** 10 20 30 40 50 60 70 80
**
** library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
/**
* GtkPaned:resize:
*
- * The "resize" child property determines whether the child expands and
+ * The "resize" child property determines whether the child expands and
* shrinks along with the paned widget.
- *
- * Since: 2.4
+ *
+ * Since: 2.4
*/
gtk_container_class_install_child_property (container_class,
CHILD_PROP_RESIZE,
/**
* GtkPaned:shrink:
*
- * The "shrink" child property determines whether the child can be made
+ * The "shrink" child property determines whether the child can be made
* smaller than its requisition.
- *
- * Since: 2.4
+ *
+ * Since: 2.4
*/
gtk_container_class_install_child_property (container_class,
CHILD_PROP_SHRINK,
/**
* gtk_xpaned_get_position_x:
* @paned: a #GtkXPaned widget
- *
+ *
* Obtains the x-position of the divider.
- *
+ *
* Return value: x-position of the divider
**/
gint
/**
* gtk_xpaned_get_position_y:
* @paned: a #GtkXPaned widget
- *
+ *
* Obtains the y-position of the divider.
- *
+ *
* Return value: y-position of the divider
**/
gint
* @paned: a #GtkXPaned widget
* @xposition: pixel x-position of divider, a negative values
* of a component mean that the position is unset.
- *
+ *
* Sets the x-position of the divider between the four panes.
**/
void
* @paned: a #GtkXPaned widget
* @yposition: pixel y-position of divider, a negative values
* of a component mean that the position is unset.
- *
+ *
* Sets the y-position of the divider between the four panes.
**/
void
/**
* gtk_xpaned_get_top_left_child:
* @xpaned: a #GtkXPaned widget
- *
+ *
* Obtains the top-left child of the xpaned widget.
- *
+ *
* Return value: top-left child, or %NULL if it is not set.
*
* Since: 2.4
/**
* gtk_xpaned_get_top_right_child:
* @xpaned: a #GtkXPaned widget
- *
+ *
* Obtains the top-right child of the xpaned widget.
- *
+ *
* Return value: top-right child, or %NULL if it is not set.
*
* Since: 2.4
/**
* gtk_xpaned_get_bottom_left_child:
* @xpaned: a #GtkXPaned widget
- *
+ *
* Obtains the bottom-left child of the xpaned widget.
- *
+ *
* Return value: bottom-left child, or %NULL if it is not set.
*
* Since: 2.4
/**
* gtk_xpaned_get_bottom_right_child:
* @xpaned: a #GtkXPaned widget
- *
+ *
* Obtains the bottom-right child of the xpaned widget.
- *
+ *
* Return value: bottom-right child, or %NULL if it is not set.
*
* Since: 2.4
/*******************************************************************************
-**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
+**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
** 10 20 30 40 50 60 70 80
**
** library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
assert (last_col < A->size1);
gsl_matrix_swap_rows (A, A->size1 - 1, last_col);
gsl_matrix_swap_columns (A, A->size1 - 1 , last_col);
-
+
B = gsl_matrix_alloc (A->size1, A->size2);
for (k = 0; k < (A->size1 - 1); k++)
{
* Vol.30, pp.1-15, 1988.
*/
-
+
#include <config.h>
#define ME_PRECISION 8
-static inline double
+static inline double
pnorm(double x, double mu, double sigma, int lower_tail, int log_p)
{
assert (lower_tail == 1);
assert (log_p == 0);
assert (sigma == 1.0);
-
+
return gsl_cdf_gaussian_P (x - mu, sigma);
}
}
/* df must be > 1 ; there must be at least two values */
- /* ^^
+ /* ^^
JMD: The comment says 1 but the code says 2.
Which is correct?
*/
assert (df >= 2);
assert (rr >= 1);
assert (cc >= 2);
-
+
R_Q_P01_boundaries (p, 0, ML_POSINF);
void attribute_del_value (struct attribute *, size_t index);
size_t attribute_get_n_values (const struct attribute *);
-struct attrset
+struct attrset
{
struct hmap map;
};
}
/* Creates and returns a new casereader whose cases are produced
- by reading from SUBREADER and executing the actions of MAP.
+ by reading from SUBREADER and executing the actions of MAP.
The casereader will have as many `union value's as MAP. When
the new casereader is destroyed, MAP will be destroyed too.
when the returned casereader is destroyed. */
struct casereader *
case_map_create_input_translator (struct case_map *map,
- struct casereader *subreader)
+ struct casereader *subreader)
{
return casereader_create_translator (subreader,
case_map_get_proto (map),
when the returned casewriter is destroyed. */
struct casewriter *
case_map_create_output_translator (struct case_map *map,
- struct casewriter *subwriter)
+ struct casewriter *subwriter)
{
return casewriter_create_translator (subwriter,
case_map_get_proto (map),
const union value *va = case_data (ca, *vap);
const union value *vb = case_data (cb, *vbp);
assert (var_get_width (*vap) == var_get_width (*vbp));
- cmp = value_compare_3way (va, vb, var_get_width (*vap));
+ cmp = value_compare_3way (va, vb, var_get_width (*vap));
}
return cmp;
}
const struct variable *const *vars,
size_t var_cnt)
{
- if (var_cnt > 0)
+ if (var_cnt > 0)
{
struct subcase *sc = xmalloc (sizeof *sc);
subcase_init_vars (sc, vars, var_cnt);
return casegrouper_create_func (reader, casegrouper_vars_same_group,
- casegrouper_vars_destroy, sc);
+ casegrouper_vars_destroy, sc);
}
else
return casegrouper_create_func (reader, NULL, NULL, NULL);
casegrouper_create_subcase (struct casereader *reader,
const struct subcase *sc)
{
- if (subcase_get_n_fields (sc) > 0)
+ if (subcase_get_n_fields (sc) > 0)
{
struct subcase *sc_copy = xmalloc (sizeof *sc);
subcase_clone (sc_copy, sc);
return casegrouper_create_func (reader, casegrouper_vars_same_group,
- casegrouper_vars_destroy, sc_copy);
+ casegrouper_vars_destroy, sc_copy);
}
else
return casegrouper_create_func (reader, NULL, NULL, NULL);
casegrouper_vars_destroy (void *sc_)
{
struct subcase *sc = sc_;
- if (sc != NULL)
+ if (sc != NULL)
{
subcase_destroy (sc);
- free (sc);
+ free (sc);
}
}
if ( NULL == next_case)
goto end;
-
+
dir = value_compare_3way (case_data (next_case, cdr->key),
current_value, key_width);
case_unref (next_case);
cdr->direction = dir;
goto end;
}
-
+
return false;
end:
else
{
c = case_unshare_and_resize (input, cdr->proto);
- case_data_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1)->f = cdr->prev_cc;
+ case_data_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1)->f = cdr->prev_cc;
}
return c;
-/* Returns a new casereader which is based upon INPUT, but which contains a maximum
+/* Returns a new casereader which is based upon INPUT, but which contains a maximum
of one case for each distinct value of KEY.
If WEIGHT is non-null, then the new casereader's values for this variable
will be the sum of all values matching KEY.
{
struct casereader *reader = CONST_CAST (struct casereader *, reader_);
struct casereader *clone;
- if ( reader == NULL )
+ if ( reader == NULL )
return NULL;
if (reader->class->clone == NULL)
struct dictionary;
char *data_in (struct substring input, const char *input_encoding,
- enum fmt_type,
+ enum fmt_type,
union value *output, int width, const char *output_encoding);
bool data_in_msg (struct substring input, const char *input_encoding,
calling dict_set_attributes for D will also destroy D's
attribute set. */
struct attrset *
-dict_get_attributes (const struct dictionary *d)
+dict_get_attributes (const struct dictionary *d)
{
return CONST_CAST (struct attrset *, &d->attributes);
}
/* Returns true if D has at least one attribute in its attribute
set, false if D's attribute set is empty. */
bool
-dict_has_attributes (const struct dictionary *d)
+dict_has_attributes (const struct dictionary *d)
{
return attrset_count (&d->attributes) > 0;
}
return NULL;
}
lock->open_cnt++;
-
+
free_key (key);
free (key);
struct file_identity *identity = xmalloc (sizeof *identity);
const char *file_name = fh_get_file_name (fh);
-
+
#if !(defined _WIN32 || defined __WIN32__)
struct stat s;
if (lstat (file_name, &s) == 0)
size_t bufsize;
size_t pathlen = 255;
char *cname = NULL;
- do
+ do
{
bufsize = pathlen;
cname = xrealloc (cname, bufsize);
struct stat temp;
if (( (stat (file, &temp) == 0 ) && ( ! S_ISDIR (temp.st_mode) )))
return file;
-
+
free (file);
}
free (ss);
return fp;
}
-#else
+#else
return fopen (fn, mode);
-#endif
+#endif
}
/* Counterpart to fn_open that closes file F with name FN; returns 0
int maxrow;
};
-struct state_data
+struct state_data
{
/* The libxml reader for this instance */
xmlTextReaderPtr xtr;
int stop_col;
int start_row;
int stop_row;
-
+
struct sheet_detail *sheets;
const xmlChar *target_sheet;
struct gnumeric_reader *gr = (struct gnumeric_reader *) s;
assert (n < s->n_sheets);
- return gr->sheets[n].name;
+ return gr->sheets[n].name;
}
{
int ret;
struct gnumeric_reader *gr = (struct gnumeric_reader *) s;
-
+
assert (n < s->n_sheets);
- while (
+ while (
(gr->sheets[n].stop_col == -1)
- &&
+ &&
(1 == (ret = xmlTextReaderRead (gr->msd.xtr)))
)
{
if (r->first_case && ! r->used_first_case )
case_unref (r->first_case);
- if (r->proto)
+ if (r->proto)
caseproto_unref (r->proto);
gnumeric_unref (&r->spreadsheet);
v,
var_get_width (var),
"UTF-8");
-
+
if (m)
{
char buf [FMT_STRING_LEN_MAX + 1];
char *cell = create_cell_ref (col, row);
-
- msg (MW, _("Cannot convert the value in the spreadsheet cell %s to format (%s): %s"),
+
+ msg (MW, _("Cannot convert the value in the spreadsheet cell %s to format (%s): %s"),
cell, fmt_to_string (fmt, buf), m);
free (cell);
}
UNUSED xmlParserSeverities sev, xmlTextReaderLocatorPtr loc)
{
struct gnumeric_reader *r = ctx;
-
+
msg (MW, _("There was a problem whilst reading the %s file `%s' (near line %d): `%s'"),
"Gnumeric",
r->spreadsheet.file_name,
static struct gnumeric_reader *
gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_errors)
-{
+{
int ret = -1;
struct state_data *sd;
{
sd = &r->rsd;
}
-
- if (show_errors)
+
+ if (show_errors)
xmlTextReaderSetErrorHandler (xtr, gnumeric_error_handler, r);
r->target_sheet = NULL;
if ( XML_CHAR_ENCODING_UTF8 != xce)
{
- /* I have been told that ALL gnumeric files are UTF8 encoded. If that is correct, this
+ /* I have been told that ALL gnumeric files are UTF8 encoded. If that is correct, this
can never happen. */
msg (MW, _("The gnumeric file `%s' is encoded as %s instead of the usual UTF-8 encoding. "
"Any non-ascii characters will be incorrectly imported."),
process_node (r, &r->rsd);
- if ( r->rsd.row > r->start_row )
+ if ( r->rsd.row > r->start_row )
{
xmlChar *attr =
xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType"));
-
+
r->vtype = _xmlchar_to_int (attr);
-
+
xmlFree (attr);
break;
}
continue;
var = dict_get_var (r->dict, x++);
-
+
convert_xml_string_to_value (r->first_case, var,
- var_spec[i].first_value,
+ var_spec[i].first_value,
var_spec[i].first_type,
r->rsd.col + i - 1,
r->rsd.row - 1);
}
free (var_spec);
-
+
return casereader_create_sequential
(NULL,
const int idx = r->rsd.col - r->start_col;
const struct variable *var = dict_get_var (r->dict, idx);
- convert_xml_string_to_value (c, var, value, r->vtype,
+ convert_xml_string_to_value (c, var, value, r->vtype,
r->rsd.col, r->rsd.row);
xmlFree (value);
return -1;
}
-TCHAR *
+TCHAR *
convert_to_filename_encoding (const char *s, size_t len, const char *current_encoding)
{
const char *enc = current_encoding;
#define Topen open
#define Tstat stat
-TCHAR *
+TCHAR *
convert_to_filename_encoding (const char *s, size_t len UNUSED, const char *current_encoding UNUSED)
{
- /* Non-windows systems don't care about the encoding.
+ /* Non-windows systems don't care about the encoding.
The string is copied here, to be consistent with the w32 case. */
return xstrdup (s);
}
char *tmp_name_verbatim;
const char *file_name_verbatim;
};
-
+
static struct ll_list all_files = LL_INITIALIZER (all_files);
static void free_replace_file (struct replace_file *);
fd = Topen (Tfile_name, O_WRONLY);
if (fd < 0)
{
- saved_errno = errno;
+ saved_errno = errno;
msg (ME, _("Opening %s for writing: %s."),
file_name, strerror (saved_errno));
free (Tfile_name);
*fp = fdopen (fd, mode);
if (*fp == NULL)
{
- saved_errno = errno;
+ saved_errno = errno;
msg (ME, _("Opening stream for %s: %s."),
file_name, strerror (saved_errno));
close (fd);
int target_sheet_index;
xmlChar *target_sheet_name;
-
+
/* State data for the meta data */
struct state_data msd;
if ( 0 == xmlStrcmp (r->target_sheet_name, msd->current_sheet_name))
return true;
}
-
+
if (r->target_sheet_index == msd->current_sheet + 1)
return true;
assert (n < s->n_sheets);
- while (
+ while (
(r->n_allocated_sheets <= n)
|| or->state != STATE_SPREADSHEET
)
{
struct ods_reader *r = (struct ods_reader *) s;
struct state_data *or = &r->msd;
-
+
assert (n < s->n_sheets);
- while (
+ while (
(r->n_allocated_sheets <= n)
- || (r->sheets[n].stop_row == -1)
+ || (r->sheets[n].stop_row == -1)
|| or->state != STATE_SPREADSHEET
)
{
break;
case STATE_SPREADSHEET:
if (0 == xmlStrcasecmp (name, _xml("table:table"))
- &&
+ &&
(XML_READER_TYPE_ELEMENT == r->node_type))
{
xmlFree (r->current_sheet_name);
}
break;
case STATE_TABLE:
- if (0 == xmlStrcasecmp (name, _xml("table:table-row")) &&
+ if (0 == xmlStrcasecmp (name, _xml("table:table-row")) &&
(XML_READER_TYPE_ELEMENT == r->node_type))
{
xmlChar *value =
xmlTextReaderGetAttribute (r->xtr,
_xml ("table:number-rows-repeated"));
-
+
int row_span = value ? _xmlchar_to_int (value) : 1;
r->row += row_span;
r->col = 0;
-
+
if (! xmlTextReaderIsEmptyElement (r->xtr))
r->state = STATE_ROW;
xmlFree (value);
}
- else if (0 == xmlStrcasecmp (name, _xml("table:table")) &&
+ else if (0 == xmlStrcasecmp (name, _xml("table:table")) &&
(XML_READER_TYPE_END_ELEMENT == r->node_type))
{
r->state = STATE_SPREADSHEET;
break;
case STATE_ROW:
if ( (0 == xmlStrcasecmp (name, _xml ("table:table-cell")))
- &&
+ &&
(XML_READER_TYPE_ELEMENT == r->node_type))
{
xmlChar *value =
xmlTextReaderGetAttribute (r->xtr,
_xml ("table:number-columns-repeated"));
-
+
r->col_span = value ? _xmlchar_to_int (value) : 1;
r->col += r->col_span;
if (or->sheets[r->current_sheet].start_row == -1)
or->sheets[r->current_sheet].start_row = r->row - 1;
- if (
+ if (
(or->sheets[r->current_sheet].start_col == -1)
||
(or->sheets[r->current_sheet].start_col >= r->col - 1)
xmlFree (name);
}
-/*
- A struct containing the parameters of a cell's value
+/*
+ A struct containing the parameters of a cell's value
parsed from the xml
*/
struct xml_value
char buf [FMT_STRING_LEN_MAX + 1];
char *cell = create_cell_ref (col, row);
- msg (MW, _("Cannot convert the value in the spreadsheet cell %s to format (%s): %s"),
+ msg (MW, _("Cannot convert the value in the spreadsheet cell %s to format (%s): %s"),
cell, fmt_to_string (fmt, buf), m);
free (cell);
}
int s = _xmlchar_to_int (attr);
xmlFreeTextReader (mxtr);
xmlFree (name);
- xmlFree (attr);
+ xmlFree (attr);
return s;
}
- xmlFree (attr);
+ xmlFree (attr);
}
- xmlFree (name);
+ xmlFree (name);
}
xmlFreeTextReader (mxtr);
UNUSED xmlParserSeverities sev, xmlTextReaderLocatorPtr loc)
{
struct ods_reader *r = ctx;
-
+
msg (MW, _("There was a problem whilst reading the %s file `%s' (near line %d): `%s'"),
"ODF",
r->spreadsheet.file_name,
r->spreadsheet.type = SPREADSHEET_ODS;
- if (report_errors)
+ if (report_errors)
xmlTextReaderSetErrorHandler (xtr, ods_error_handler, r);
return xtr;
{
int sheet_count;
struct ods_reader *r = xzalloc (sizeof *r);
- xmlTextReaderPtr xtr;
+ xmlTextReaderPtr xtr;
struct zip_reader *zr;
ds_init_empty (&r->zip_errs);
}
struct casereader *
-ods_make_reader (struct spreadsheet *spreadsheet,
+ods_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_options *opts)
{
intf ret = 0;
r->target_sheet_index = opts->sheet_index;
/* Advance to the start of the cells for the target sheet */
- while ( ! reading_target_sheet (r, &r->rsd)
+ while ( ! reading_target_sheet (r, &r->rsd)
|| r->rsd.state != STATE_ROW || r->rsd.row <= r->start_row )
{
if (1 != (ret = xmlTextReaderRead (r->rsd.xtr)))
if (r->stop_col != -1 && idx > r->stop_col - r->start_col)
continue;
- if (r->rsd.state == STATE_CELL_CONTENT
+ if (r->rsd.state == STATE_CELL_CONTENT
&&
XML_READER_TYPE_TEXT == r->rsd.node_type)
{
/* xrealloc (unlike realloc) doesn't initialise its memory to 0 */
memset (var_spec + n_var_specs,
- 0,
+ 0,
(idx - n_var_specs + 1) * sizeof (*var_spec));
n_var_specs = idx + 1;
}
{
var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1));
memset (var_spec + n_var_specs,
- 0,
+ 0,
(idx - n_var_specs + 1) * sizeof (*var_spec));
var_spec [idx].name = NULL;
&ods_file_casereader_class, r);
error:
-
+
for ( i = 0 ; i < n_var_specs ; ++i )
{
free (var_spec[i].firstval.type);
/* Advance to the start of a row. (If there is one) */
- while (r->rsd.state != STATE_ROW
+ while (r->rsd.state != STATE_ROW
&& 1 == xmlTextReaderRead (r->rsd.xtr)
)
{
}
- if ( ! reading_target_sheet (r, &r->rsd)
+ if ( ! reading_target_sheet (r, &r->rsd)
|| r->rsd.state < STATE_TABLE
|| (r->stop_row != -1 && r->rsd.row > r->stop_row + 1)
)
c = case_create (r->proto);
case_set_missing (c);
-
+
while (1 == xmlTextReaderRead (r->rsd.xtr))
{
process_node (r, &r->rsd);
val_string = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value"));
}
- if (r->rsd.state == STATE_CELL_CONTENT &&
+ if (r->rsd.state == STATE_CELL_CONTENT &&
r->rsd.node_type == XML_READER_TYPE_TEXT)
{
int col;
struct xml_value *xmv = xzalloc (sizeof *xmv);
xmv->text = xmlTextReaderValue (r->rsd.xtr);
- xmv->value = val_string;
+ xmv->value = val_string;
val_string = NULL;
xmv->type = type;
type = NULL;
xmlFree (type);
xmlFree (val_string);
-
+
return c;
}
#endif
struct spreadsheet *ods_probe (const char *filename, bool report_errors);
-struct casereader * ods_make_reader (struct spreadsheet *spreadsheet,
+struct casereader * ods_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_options *opts);
void ods_unref (struct spreadsheet *s);
short_names_assign (dict);
- if (dict_get_weight (dict) != NULL)
+ if (dict_get_weight (dict) != NULL)
{
buf_write (w, "6", 1);
write_string (w, var_get_short_name (dict_get_weight (dict), 0));
}
-
+
buf_write (w, "4", 1);
write_int (w, dict_get_var_cnt (dict));
int width = 0;
int length ;
- /* If there are no data then make a finger in the air
+ /* If there are no data then make a finger in the air
guess at the contents */
if ( n_tuples > 0 )
length = PQgetlength (qres, 0, i);
- else
+ else
length = PSQL_DEFAULT_WIDTH;
switch (type)
/* Sets the maximum number of messages to show of the given SEVERITY before
aborting to MAX. (The value for MSG_S_WARNING is interpreted as maximum
- number of warnings and errors combined.) In addition, in the case of
+ number of warnings and errors combined.) In addition, in the case of
warnings the special value of zero indicates that no warnings are to be
- issued.
+ issued.
*/
void
settings_set_max_messages (enum msg_severity severity, int max)
return the_settings.output_routing[type] | SETTINGS_DEVICE_UNFILTERED;
}
-enum settings_value_style
+enum settings_value_style
settings_get_value_style (void)
{
return the_settings.value_output_style;
static const bool GNM_READING_SUPPORTED = false;
#endif
-void
+void
spreadsheet_ref (struct spreadsheet *s)
{
s->ref_cnt++;
}
-void
+void
spreadsheet_unref (struct spreadsheet *s)
{
switch (s->type)
}
-struct casereader *
+struct casereader *
spreadsheet_make_reader (struct spreadsheet *s,
const struct spreadsheet_read_options *opts)
{
return NULL;
}
-const char *
+const char *
spreadsheet_get_sheet_name (struct spreadsheet *s, int n)
{
if (ODF_READING_SUPPORTED)
}
-char *
+char *
spreadsheet_get_sheet_range (struct spreadsheet *s, int n)
{
if (ODF_READING_SUPPORTED)
while (i > lower + base - 1)
{
lower += base;
- base *= RADIX;
+ base *= RADIX;
assert (base > 0);
exp++;
}
text_warn (r, text, _("Error parsing attribute value %s[%d]."),
key, index);
break;
- }
+ }
length = strlen (value);
- if (length >= 2 && value[0] == '\'' && value[length - 1] == '\'')
+ if (length >= 2 && value[0] == '\'' && value[length - 1] == '\'')
{
value[length - 1] = '\0';
- attribute_add_value (attr, value + 1);
+ attribute_add_value (attr, value + 1);
}
- else
+ else
{
text_warn (r, text,
_("Attribute value %s[%d] is not quoted: %s."),
key, index, value);
- attribute_add_value (attr, value);
+ attribute_add_value (attr, value);
}
/* Was this the last value for this attribute? */
{
if (!text_read_short_name (r, dict, text, ss_cstr ("="), var))
return false;
-
+
*value = text_get_token (text, ss_buffer ("\t\0", 2), NULL);
if (*value == NULL)
return false;
text_warn (struct sfm_reader *r, struct text_record *text,
const char *format, ...)
{
- if (text->n_warnings++ < MAX_TEXT_WARNINGS)
+ if (text->n_warnings++ < MAX_TEXT_WARNINGS)
{
va_list args;
{
if (text->pos >= text->buffer.length)
return false;
-
- if (text->buffer.string[text->pos] == c)
+
+ if (text->buffer.string[text->pos] == c)
{
text->pos++;
return true;
struct attrset_iterator i;
for (attr = attrset_first (attrs, &i); attr != NULL;
- attr = attrset_next (attrs, &i))
+ attr = attrset_next (attrs, &i))
{
size_t n_values = attribute_get_n_values (attr);
size_t j;
ds_put_cstr (string, attribute_get_name (attr));
ds_put_byte (string, '(');
- for (j = 0; j < n_values; j++)
+ for (j = 0; j < n_values; j++)
ds_put_format (string, "'%s'\n", attribute_get_value (attr, j));
ds_put_byte (string, ')');
}
size_t i;
for (i = 0; i < n_vars; i++)
- {
+ {
struct variable *v = dict_get_var (d, i);
struct attrset attrs;
if (val_labs_count (a) != val_labs_count (b))
return false;
-
+
if (a == NULL || b == NULL)
return true;
{
struct variable *ov = var_clone (v);
var_set_value_labels_quiet (v, vls);
- dict_var_changed (v, VAR_TRAIT_LABEL, ov);
+ dict_var_changed (v, VAR_TRAIT_LABEL, ov);
}
case SETTINGS_VAL_STYLE_VALUES:
append_value (v, value, str);
break;
-
+
case SETTINGS_VAL_STYLE_LABELS:
if (name == NULL)
append_value (v, value, str);
all if it hasn't been saved to or read from a system or
portable file. */
size_t
-var_get_short_name_cnt (const struct variable *var)
+var_get_short_name_cnt (const struct variable *var)
{
return var->short_name_cnt;
}
assert (short_name == NULL || id_is_plausible (short_name, false));
/* Clear old short name numbered IDX, if any. */
- if (idx < var->short_name_cnt)
+ if (idx < var->short_name_cnt)
{
free (var->short_names[idx]);
- var->short_names[idx] = NULL;
+ var->short_names[idx] = NULL;
}
/* Install new short name for IDX. */
- if (short_name != NULL)
+ if (short_name != NULL)
{
if (idx >= var->short_name_cnt)
{
V, or calling var_set_attributes() on V, will also destroy its
attribute set. */
struct attrset *
-var_get_attributes (const struct variable *v)
+var_get_attributes (const struct variable *v)
{
return CONST_CAST (struct attrset *, &v->attributes);
}
/* Replaces variable V's attributes set by a copy of ATTRS. */
static void
-var_set_attributes_quiet (struct variable *v, const struct attrset *attrs)
+var_set_attributes_quiet (struct variable *v, const struct attrset *attrs)
{
attrset_destroy (&v->attributes);
attrset_clone (&v->attributes, attrs);
/* Replaces variable V's attributes set by a copy of ATTRS. */
void
-var_set_attributes (struct variable *v, const struct attrset *attrs)
+var_set_attributes (struct variable *v, const struct attrset *attrs)
{
struct variable *ov = var_clone (v);
var_set_attributes_quiet (v, attrs);
/*
Returns zero, if W is a missing value for WV or if it is less than zero.
Typically used to force a numerical value into a valid weight.
-
- As a side effect, this function will emit a warning if the value
+
+ As a side effect, this function will emit a warning if the value
WARN_ON_INVALID points to a bool which is TRUE. That bool will be then
set to FALSE.
*/
{
if (w < 0.0 || (wv && var_is_num_missing (wv, w, MV_ANY)))
w = 0.0;
-
+
if (w == 0.0 && warn_on_invalid != NULL && *warn_on_invalid)
{
*warn_on_invalid = false;
command->name, "FILE TYPE");
break;
case S_INPUT_PROGRAM | S_FILE_TYPE:
- msg (SE, _("%s is allowed only inside %s or inside %s."), command->name,
+ msg (SE, _("%s is allowed only inside %s or inside %s."), command->name,
"INPUT PROGRAM", "FILE TYPE");
break;
lex_match (lexer, T_LPAREN);
if (!lex_force_int (lexer))
goto error;
-
+
int records = lex_integer (lexer);
if (records < 0)
{
{
char *tok = NULL;
struct spreadsheet_read_options opts;
-
+
opts.sheet_name = NULL;
opts.sheet_index = -1;
opts.cell_range = NULL;
if (s)
tok = strdup (s);
-
+
if (lex_match_id (lexer, "TXT"))
{
free (tok);
free (tok);
return parse_get_psql (lexer, ds);
}
- else if (lex_match_id (lexer, "GNM") ||
+ else if (lex_match_id (lexer, "GNM") ||
lex_match_id (lexer, "ODS"))
{
char *filename = NULL;
}
static bool
-parse_spreadsheet (struct lexer *lexer, char **filename,
+parse_spreadsheet (struct lexer *lexer, char **filename,
struct spreadsheet_read_options *opts)
{
opts->sheet_index = 1;
}
-static void
+static void
destroy_spreadsheet_read_info (struct spreadsheet_read_options *opts)
{
free (opts->cell_range);
return CMD_FAILURE;
}
}
-
+
/* Verify arguments. */
if (cmd.first > cmd.last)
var_set_write_format (t, var_get_write_format (s));
}
- if (var_has_attributes (s))
+ if (var_has_attributes (s))
var_set_attributes (t, var_get_attributes (s));
}
struct dictionary *dict = dataset_dict (ds);
const char *dict_encoding = dict_get_encoding (dict);
- do
+ do
{
struct variable **vars;
struct attrset **sets;
static bool
add_attribute (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
const char *value;
size_t index, i;
for (i = 0; i < n; i++)
{
struct attribute *attr = attrset_lookup (sets[i], name);
- if (attr == NULL)
+ if (attr == NULL)
{
attr = attribute_create (name);
- attrset_add (sets[i], attr);
+ attrset_add (sets[i], attr);
}
attribute_set_value (attr, index ? index - 1 : 0, value);
}
static bool
delete_attribute (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
size_t index, i;
char *name;
if (name == NULL)
return false;
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
{
struct attrset *set = sets[i];
if (index == 0)
else
{
struct attribute *attr = attrset_lookup (set, name);
- if (attr != NULL)
+ if (attr != NULL)
{
attribute_del_value (attr, index - 1);
if (attribute_get_n_values (attr) == 0)
- attrset_delete (set, name);
+ attrset_delete (set, name);
}
}
}
static enum cmd_result
parse_attributes (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
enum { UNKNOWN, ADD, DELETE } command = UNKNOWN;
- do
+ do
{
if (lex_match_phrase (lexer, "ATTRIBUTE="))
command = ADD;
if (proc_make_temporary_transformations_permanent (ds))
msg (SE, _("%s may not be used after %s. "
- "Temporary transformations will be made permanent."),
+ "Temporary transformations will be made permanent."),
"DELETE VARIABLES", "TEMPORARY");
if (!parse_variables (lexer, dataset_dict (ds), &vars, &var_cnt, PV_NONE))
tab_text_format (t, 1, i + 1, 0, "%.*s", print->w, s);
free (s);
-
+
val_lab = var_lookup_value_label (v, case_data (c, v));
if (val_lab)
tab_text (t, 2, i + 1, TAB_LEFT, val_lab);
#define _(msgid) gettext (msgid)
/* Information to include in displaying a dictionary. */
-enum
+enum
{
DF_DICT_INDEX = 1 << 0,
DF_FORMATS = 1 << 1,
fh_unref (h);
pool_destroy (pool);
free (encoding);
-
+
return CMD_SUCCESS;
}
display_vectors (dataset_dict(ds), sorted);
return CMD_SUCCESS;
}
- else if (lex_match_id (lexer, "SCRATCH"))
+ else if (lex_match_id (lexer, "SCRATCH"))
{
dict_get_vars (dataset_dict (ds), &vl, &n, DC_ORDINARY);
flags = 0;
}
- else
+ else
{
- struct subcommand
+ struct subcommand
{
const char *name;
int flags;
};
- static const struct subcommand subcommands[] =
+ static const struct subcommand subcommands[] =
{
{"@ATTRIBUTES", DF_ATTRIBUTES | DF_AT_ATTRIBUTES},
{"ATTRIBUTES", DF_ATTRIBUTES},
dict_get_vars (dict, &vl, &n, 0);
}
- if (n > 0)
+ if (n > 0)
{
sort (vl, n, sizeof *vl,
(sorted
tab_headers (t, 0, 0, 1, 0);
tab_hline (t, TAL_2, 0, nc - 1, 1);
tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
- if (flags & ~DF_DICT_INDEX)
+ if (flags & ~DF_DICT_INDEX)
tab_text (t, 1, 0, TAB_LEFT | TAT_TITLE,
(flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS)
? _("Description") : _("Label")));
}
\f
static bool
-is_at_name (const char *name)
+is_at_name (const char *name)
{
return name[0] == '@' || (name[0] == '$' && name[1] == '@');
}
static size_t
-count_attributes (const struct attrset *set, int flags)
+count_attributes (const struct attrset *set, int flags)
{
struct attrset_iterator i;
struct attribute *attr;
size_t n_attrs;
-
+
n_attrs = 0;
for (attr = attrset_first (set, &i); attr != NULL;
- attr = attrset_next (set, &i))
+ attr = attrset_next (set, &i))
if (flags & DF_AT_ATTRIBUTES || !is_at_name (attribute_get_name (attr)))
n_attrs += attribute_get_n_values (attr);
return n_attrs;
}
static void
-display_data_file_attributes (struct attrset *set, int flags)
+display_data_file_attributes (struct attrset *set, int flags)
{
if (count_attributes (set, flags))
table_item_submit (table_item_create (describe_attributes (set, flags),
}
/* Print/write format, or print and write formats. */
- if (flags & DF_FORMATS)
+ if (flags & DF_FORMATS)
{
const struct fmt_spec *print = var_get_print_format (v);
const struct fmt_spec *write = var_get_write_format (v);
else
break;
}
-
+
if (!lex_force_match (lexer, T_SLASH))
goto done;
}
else
lex_error_expecting (lexer, token_type_to_name (type), NULL_SENTINEL);
-
+
return false;
}
}
}
if (*nnames == 0)
goto fail;
-
+
return true;
fail:
*iact = NULL;
return false;
}
-
+
assert (v);
if ( *iact == NULL)
item = find_arc_item (spec, value, hash);
if ( (item == NULL)
- &&
+ &&
( arc->blank_valid
|| val_type_from_width (spec->width) == VAL_NUMERIC
|| ! value_is_blank (value, width, dict))
value_init (&to_val, 0);
items[j]->to = direction == ASCENDING ? j + 1 : n_items - j;
-
+
to_val.f = items[j]->to;
/* Add value labels to the destination variable which indicate
}
else
recoded_value = c_xasprintf ("%.*g", DBL_DIG + 1, from->f);
-
+
/* Remove trailing whitespace */
len = strlen (recoded_value);
while (len > 0 && recoded_value[len - 1] == ' ')
for (i = 0; i < arc->n_specs; i++)
{
struct arc_spec *spec = &arc->specs[i];
-
+
if (--spec->items->refcnt == 0)
{
hmap_destroy (&spec->items->ht);
hmap_destroy (&arc->global_items->ht);
free (arc->global_items);
}
-
+
free (arc->specs);
free (arc);
}
{
const char *name;
const char *description;
-
+
int arity;
bool cumulative;
double (*pre) (void);
rowsq += pow2 (case_hits);
}
casereader_destroy (input);
-
+
{
double c_l = 0;
double c_l2 = 0;
ch.q *= ct->n_vars - 1;
ch.q /= ct->n_vars * c_l - rowsq;
-
+
ch.df = ct->n_vars - 1;
}
tab_hline (table, TAL_2, 0, tab_nc (table) -1, column_headers);
tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1);
- tab_double (table, 1, column_headers,
+ tab_double (table, 1, column_headers,
0, ch->cc, NULL, RC_WEIGHT);
- tab_double (table, 1, column_headers + 1,
+ tab_double (table, 1, column_headers + 1,
0, ch->q, NULL, RC_OTHER);
- tab_double (table, 1, column_headers + 2,
+ tab_double (table, 1, column_headers + 2,
0, ch->df, NULL, RC_INTEGER);
- tab_double (table, 1, column_headers + 3,
- 0, gsl_cdf_chisq_Q (ch->q, ch->df),
+ tab_double (table, 1, column_headers + 3,
+ 0, gsl_cdf_chisq_Q (ch->q, ch->df),
NULL, RC_PVALUE);
tab_submit (table);
case 3:
x = gsl_matrix_get (ns, r, 0);
break;
- default:
+ default:
NOT_REACHED ();
};
-
+
tab_double (t, c, r + heading_rows, 0, x, NULL, RC_OTHER);
}
}
/* Row Headers */
for (r = 0 ; r < corr->n_vars1 ; ++r)
{
- tab_text (t, 0, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE,
+ tab_text (t, 0, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE,
var_to_string (corr->vars[r]));
tab_text (t, 1, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE, _("Pearson Correlation"));
- tab_text (t, 1, 2 + r * rows_per_variable, TAB_LEFT | TAT_TITLE,
+ tab_text (t, 1, 2 + r * rows_per_variable, TAB_LEFT | TAT_TITLE,
(opts->tails == 2) ? _("Sig. (2-tailed)") : _("Sig. (1-tailed)"));
if (opts->statistics & STATS_XPROD)
{
const struct variable *v = corr->n_vars_total > corr->n_vars1 ?
corr->vars[corr->n_vars1 + c] : corr->vars[c];
- tab_text (t, heading_columns + c, 0, TAB_LEFT | TAT_TITLE, var_to_string (v));
+ tab_text (t, heading_columns + c, 0, TAB_LEFT | TAT_TITLE, var_to_string (v));
}
for (r = 0 ; r < corr->n_vars1 ; ++r)
const int row = r * rows_per_variable + heading_rows;
for (c = 0 ; c < matrix_cols ; ++c)
{
- unsigned char flags = 0;
- const int col_index = corr->n_vars_total > corr->n_vars1 ?
- corr->n_vars1 + c :
+ unsigned char flags = 0;
+ const int col_index = corr->n_vars_total > corr->n_vars1 ?
+ corr->n_vars1 + c :
c;
double pearson = gsl_matrix_get (cm, r, col_index);
double w = gsl_matrix_get (samples, r, col_index);
if ( opts->sig && col_index != r && sig < 0.05)
flags = TAB_EMPH;
-
+
tab_double (t, c + heading_columns, row, flags, pearson, NULL, RC_OTHER);
if (opts->statistics & STATS_XPROD)
covariance_accumulate_pass2 (cov, c);
}
casereader_destroy (rc);
-
+
cov_matrix = covariance_calculate (cov);
if (! cov_matrix)
{
msg (SE, _("The data for the chosen variables are all missing or empty."));
goto error;
}
-
+
samples_matrix = covariance_moments (cov, MOMENT_NONE);
var_matrix = covariance_moments (cov, MOMENT_VARIANCE);
mean_matrix = covariance_moments (cov, MOMENT_MEAN);
corr_matrix = correlation_from_covariance (cov_matrix, var_matrix);
- if ( opts->statistics & STATS_DESCRIPTIVES)
+ if ( opts->statistics & STATS_DESCRIPTIVES)
output_descriptives (corr, mean_matrix, var_matrix, samples_matrix);
output_correlation (corr, opts, corr_matrix,
opts.statistics = STATS_ALL;
lex_get (lexer);
}
- else
+ else
{
lex_error (lexer, NULL);
goto error;
corr = xrealloc (corr, sizeof (*corr) * (n_corrs + 1));
corr[n_corrs].n_vars_total = corr[n_corrs].n_vars1 = 0;
-
- if ( ! parse_variables_const (lexer, dict, &corr[n_corrs].vars,
+
+ if ( ! parse_variables_const (lexer, dict, &corr[n_corrs].vars,
&corr[n_corrs].n_vars_total,
PV_NUMERIC))
{
}
nx *= by_nvar[n_by];
n_by++;
-
+
if (!lex_match (lexer, T_BY))
{
if (n_by < 2)
}
}
if (proc->barchart)
- chart_item_submit
+ chart_item_submit
(barchart_create (pt->vars, pt->n_vars, _("Count"), false, pt->entries, pt->n_entries));
}
+ sum_rici * sum_rici
- pt->total * sum_riciri_ci)
/ (pt->total * (pow2 (pt->total) - sum_rici) * (pow2 (pt->total) - sum_rici)));
-
+
ase[8] = sqrt (pt->total * (((sum_fii * (pt->total - sum_fii))
/ pow2 (pow2 (pt->total) - sum_rici))
+ ((2. * (pt->total - sum_fii)
/*
PSPP - a program for statistical analysis.
Copyright (C) 2012, 2013, 2016 Free Software Foundation, Inc.
-
+
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 Free Software Foundation, either version 3 of the License, or
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-static void
+static void
append_value_name (const struct variable *var, const union value *val, struct string *str)
{
var_append_value_name (var, val, str);
enum pc_alg pc_alg;
double *ptiles;
size_t n_percentiles;
-
+
bool npplot;
bool histogramplot;
bool boxplot;
struct extremity *minima;
struct extremity *maxima;
- /*
+ /*
Minimum should alway equal mimima[0].val.
Likewise, maximum should alway equal maxima[0].val.
This redundancy exists as an optimisation effort.
const struct variable *ivar = iact->vars[ivar_idx];
const int width = var_get_width (ivar);
const union value *val = case_data (c, ivar);
-
+
if (prev_val[ivar_idx])
if (! value_equal (prev_val[ivar_idx], val, width))
{
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
prev_val[ivar_idx] = val;
}
return diff_idx;
}
else
ds_put_format (&title, _("Boxplot of %s"), var_to_string (cmd->dep_vars[v]));
-
+
for (grp = 0; grp < n_cats; ++grp)
{
const struct exploratory_stats *es =
if ( y_max < es[v].maximum)
y_max = es[v].maximum;
}
-
+
boxplot = boxplot_create (y_min, y_max, ds_cstr (&title));
ds_destroy (&title);
ds_destroy (&label);
}
-
+
boxplot_submit (boxplot);
}
}
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
struct exploratory_stats *es =
categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp);
- boxplot_add_box (boxplot, es[v].box_whisker,
+ boxplot_add_box (boxplot, es[v].box_whisker,
var_to_string (cmd->dep_vars[v]));
es[v].box_whisker = NULL;
}
categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp);
struct string label;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if ( iact->n_vars > 0)
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
ds_put_cstr (&label, "; ");
-
+
}
ds_put_cstr (&label, ")");
}
-
+
np = es[v].np;
reader = casewriter_make_reader (np->writer);
np->writer = NULL;
struct chart_item *sl;
struct string label;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if (iact->n_vars > 0)
interaction_to_string (iact, &label);
ds_put_cstr (&label, ")");
}
-
+
sl = spreadlevel_plot_create (ds_cstr (&label), cmd->sl_power);
for (grp = 0; grp < n_cats; ++grp)
if (sl == NULL)
msg (MW, _("Not creating spreadlevel chart for %s"), ds_cstr (&label));
- else
+ else
chart_item_submit (sl);
ds_destroy (&label);
if (es[v].histogram == NULL)
continue;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if ( iact->n_vars > 0)
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
ds_put_cstr (&label, "; ");
-
+
}
ds_put_cstr (&label, ")");
}
ds_cstr (&label), n, mean,
sqrt (var), false));
-
+
ds_destroy (&label);
}
}
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE | TAB_LEFT,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
);
}
- tab_text (t, heading_columns - 1,
+ tab_text (t, heading_columns - 1,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
gettext (ptile_alg_desc [cmd->pc_alg]));
for (p = 0; p < cmd->n_percentiles; ++p)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat,
0,
percentile_calculate (es->percentiles[p], cmd->pc_alg),
NULL, RC_OTHER);
-
+
if (cmd->ptiles[p] == 25.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[0],
}
else if (cmd->ptiles[p] == 50.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[1],
}
else if (cmd->ptiles[p] == 75.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[2],
}
- tab_text (t, heading_columns - 1,
+ tab_text (t, heading_columns - 1,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
TAT_TITLE | TAB_LEFT,
_("Tukey's Hinges"));
-
+
}
free (prev_vals);
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE | TAB_LEFT,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
_("%g%% Confidence Interval for Mean"),
cmd->conf * 100.0
);
-
+
tab_text (t,
1 + iact->n_vars + 1,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
TAB_LEFT,
_("Median")
);
-
+
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 4,
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 7,
- 0,
+ 0,
es->minima[0].val,
NULL, RC_OTHER);
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 8,
- 0,
+ 0,
es->maxima[0].val,
NULL, RC_OTHER);
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 9,
- 0,
+ 0,
es->maxima[0].val - es->minima[0].val,
NULL, RC_OTHER);
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 10,
0,
- percentile_calculate (es->quartiles[2], cmd->pc_alg) -
+ percentile_calculate (es->quartiles[2], cmd->pc_alg) -
percentile_calculate (es->quartiles[0], cmd->pc_alg),
NULL, RC_OTHER);
tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
- if ( cmd->id_var )
+ if ( cmd->id_var )
tab_text (t, heading_columns, 0, TAB_CENTER | TAT_TITLE,
var_to_string (cmd->id_var));
else
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
heading_rows + v * rows_per_var + i * rows_per_cat
);
}
-
+
tab_text (t,
heading_columns - 2,
heading_rows + v * rows_per_var + i * rows_per_cat,
&es->maxima[e].identity,
cmd->id_var,
NULL);
- else
+ else
tab_double (t,
heading_columns,
heading_rows + v * rows_per_var + i * rows_per_cat + e,
0,
es->maxima[e].val,
var_get_print_format (cmd->dep_vars[v]), RC_OTHER);
-
+
tab_double (t,
heading_columns - 1,
TAB_CENTER | TAT_TITLE, _("Valid"));
tab_joint_text (t,
- heading_columns + 2, 1,
+ heading_columns + 2, 1,
heading_columns + 3, 1,
TAB_CENTER | TAT_TITLE, _("Missing"));
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx, heading_rows + n_cats * v + i,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, i);
-
-
+
+
total = es[v].missing + es[v].non_missing;
- tab_double (t,
+ tab_double (t,
heading_columns + 0,
heading_rows + n_cats * v + i,
0,
NULL, RC_WEIGHT);
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 1,
heading_rows + n_cats * v + i,
0,
);
- tab_double (t,
+ tab_double (t,
heading_columns + 2,
heading_rows + n_cats * v + i,
0,
es[v].missing,
NULL, RC_WEIGHT);
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 3,
heading_rows + n_cats * v + i,
0,
"%g%%",
100.0 * es[v].missing / total
);
- tab_double (t,
+ tab_double (t,
heading_columns + 4,
heading_rows + n_cats * v + i,
0,
NULL, RC_WEIGHT);
/* This can only be 100% can't it? */
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 5,
heading_rows + n_cats * v + i,
0,
{
const struct variable *v = NULL;
struct interaction *iact = NULL;
-
+
if ( lex_match_variable (lexer, ex->dict, &v))
{
iact = interaction_create (v);
}
lex_match (lexer, T_COMMA);
}
-
+
return iact;
}
create_n (const void *aux1, void *aux2 UNUSED)
{
int v;
-
+
const struct examine *examine = aux1;
struct exploratory_stats *es = pool_calloc (examine->pool, examine->n_dep_vars, sizeof (*es));
struct subcase ordering;
struct ccase *outcase ;
const struct variable *var = examine->dep_vars[v];
const double x = case_data (c, var)->f;
-
+
if (var_is_value_missing (var, case_data (c, var), examine->dep_excl))
{
es[v].missing += weight;
case_data_idx (c, examine->id_idx), examine->id_width);
case_data_rw_idx (outcase, EX_WT)->f = weight;
-
+
es[v].cc += weight;
if (es[v].cmin > weight)
const double val = case_data_idx (c, EX_VAL)->f;
double wt = case_data_idx (c, EX_WT)->f;
wt = var_force_valid_weight (examine->wv, wt, &warn);
-
+
moments_pass_two (es[v].mom, val, wt);
if (es[v].histogram)
{
struct extremity *max;
- if (x >= examine->calc_extremes)
+ if (x >= examine->calc_extremes)
break;
max = &es[v].maxima[x];
{
struct order_stats *os;
- es[v].box_whisker = box_whisker_create (es[v].hinges,
+ es[v].box_whisker = box_whisker_create (es[v].hinges,
EX_ID, examine->id_var);
os = &es[v].box_whisker->parent;
struct order_stats *os;
moments_calculate (es[v].mom, &n, &mean, &var, NULL, NULL);
-
+
es[v].np = np_create (n, mean, var);
os = &es[v].np->parent;
static void
cleanup_exploratory_stats (struct examine *cmd)
-{
+{
int i;
for (i = 0; i < cmd->n_iacts; ++i)
{
payload.update = update_n;
payload.calculate = calculate_n;
payload.destroy = NULL;
-
+
cmd->wv = dict_get_weight (cmd->dict);
cmd->cats
- = categoricals_create (cmd->iacts, cmd->n_iacts,
+ = categoricals_create (cmd->iacts, cmd->n_iacts,
cmd->wv, cmd->dep_excl, cmd->fctr_excl);
categoricals_set_payload (cmd->cats, &payload, cmd, NULL);
examine.id_width = 0;
examine.id_var = NULL;
examine.boxplot_mode = BP_GROUPS;
-
+
examine.ex_proto = caseproto_create ();
examine.pool = pool_create ();
if (iact)
{
examine.n_iacts++;
- iacts_mem =
+ iacts_mem =
pool_nrealloc (examine.pool, iacts_mem,
examine.n_iacts,
sizeof (*iacts_mem));
-
+
iacts_mem[examine.n_iacts - 1] = iact;
}
}
while (lex_is_number (lexer))
{
double p = lex_number (lexer);
-
+
if ( p <= 0 || p >= 100.0)
{
lex_error (lexer,
examine.npplot = true;
examine.boxplot = true;
}
- else
+ else
{
lex_error (lexer, NULL);
goto error;
}
lex_match (lexer, T_COMMA);
- }
+ }
}
else if (lex_match_id (lexer, "CINTERVAL"))
{
if ( !lex_force_num (lexer))
goto error;
-
+
examine.conf = lex_number (lexer);
lex_get (lexer);
}
struct casegrouper *grouper;
struct casereader *group;
bool ok;
-
+
grouper = casegrouper_create_splits (proc_open (ds), examine.dict);
while (casegrouper_get_next_group (grouper, &group))
run_examine (&examine, group);
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_matrix.h>
-#include <gsl/gsl_eigen.h>
-#include <gsl/gsl_blas.h>
+#include <gsl/gsl_eigen.h>
+#include <gsl/gsl_blas.h>
#include <gsl/gsl_sort_vector.h>
#include <gsl/gsl_cdf.h>
PRINT_EXTRACTION = 0x0100,
PRINT_INITIAL = 0x0200,
PRINT_KMO = 0x0400,
- PRINT_REPR = 0x0800,
+ PRINT_REPR = 0x0800,
PRINT_FSCORE = 0x1000
};
/* return diag (C'C) ^ {-0.5} */
static gsl_matrix *
-diag_rcp_sqrt (const gsl_matrix *C)
+diag_rcp_sqrt (const gsl_matrix *C)
{
int j;
gsl_matrix *d = gsl_matrix_calloc (C->size1, C->size2);
/* return diag ((C'C)^-1) ^ {-0.5} */
static gsl_matrix *
-diag_rcp_inv_sqrt (const gsl_matrix *CCinv)
+diag_rcp_inv_sqrt (const gsl_matrix *CCinv)
{
int j;
gsl_matrix *r = gsl_matrix_calloc (CCinv->size1, CCinv->size2);
-struct cmd_factor
+struct cmd_factor
{
size_t n_vars;
const struct variable **vars;
assert (m->size1 == m->size2);
a = gsl_matrix_alloc (m->size1, m->size2);
-
+
for (i = 0; i < m->size1; ++i)
{
for (j = 0; j < m->size2; ++j)
assert (m->size1 == m->size2);
assert (n < m->size1);
-
+
for (i = 0; i < m->size1; ++i)
{
if (i == n ) continue;
#endif
-static int
+static int
n_extracted_factors (const struct cmd_factor *factor, struct idata *idata)
{
int i;
-
+
/* If there is a cached value, then return that. */
if ( idata->n_extractions != 0)
return idata->n_extractions;
idata->n_extractions = factor->n_factors;
goto finish;
}
-
+
/* Use the MIN_EIGEN setting. */
for (i = 0 ; i < idata->eval->size; ++i)
{
{
/* Copy of the subject */
gsl_matrix *m;
-
+
gsl_matrix *inverse;
gsl_permutation *perm;
static struct smr_workspace *ws_create (const gsl_matrix *input)
{
struct smr_workspace *ws = xmalloc (sizeof (*ws));
-
+
ws->m = gsl_matrix_alloc (input->size1, input->size2);
ws->inverse = gsl_matrix_calloc (input->size1 - 1, input->size2 - 1);
ws->perm = gsl_permutation_alloc (input->size1 - 1);
}
-/*
+/*
Return the square of the regression coefficient for VAR regressed against all other variables.
*/
static double
squared_multiple_correlation (const gsl_matrix *corr, int var, struct smr_workspace *ws)
{
- /* For an explanation of what this is doing, see
+ /* For an explanation of what this is doing, see
http://www.visualstatistics.net/Visual%20Statistics%20Multimedia/multiple_regression_analysis.htm
*/
gsl_matrix_swap_rows (ws->m, 0, var);
gsl_matrix_swap_columns (ws->m, 0, var);
- rxx = gsl_matrix_submatrix (ws->m, 1, 1, ws->m->size1 - 1, ws->m->size1 - 1);
+ rxx = gsl_matrix_submatrix (ws->m, 1, 1, ws->m->size1 - 1, ws->m->size1 - 1);
gsl_linalg_LU_decomp (&rxx.matrix, ws->perm, &signum);
ws->eval = gsl_vector_alloc (n);
ws->evec = gsl_matrix_alloc (n, n);
ws->r = gsl_matrix_alloc (n, n);
-
+
return ws;
}
}
-/*
+/*
Indirectly sort the rows of matrix INPUT, storing the sort order in PERM.
The sort criteria are as follows:
-
+
Rows are sorted on the first column, until the absolute value of an
element in a subsequent column is greater than that of the first
column. Thereafter, rows will be sorted on the second column,
}
}
- while (column_n < m && row_n < n)
+ while (column_n < m && row_n < n)
{
gsl_vector_const_view columni = gsl_matrix_const_column (mat, column_n);
gsl_sort_vector_index (p, &columni.vector);
{
gsl_vector_view row = gsl_matrix_row (mat, p->data[n - 1 - i]);
size_t maxindex = gsl_vector_max_index (&row.vector);
-
+
if ( maxindex > column_n )
break;
gsl_permutation_free (p);
gsl_matrix_free (mat);
-
+
assert ( 0 == gsl_permutation_valid (perm));
/* We want the biggest value to be first */
- gsl_permutation_reverse (perm);
+ gsl_permutation_reverse (perm);
}
}
-static double
+static double
initial_sv (const gsl_matrix *fm)
{
int j, k;
{
double jv = gsl_matrix_get (normalised, p, j);
double kv = gsl_matrix_get (normalised, p, k);
-
+
double u = jv * jv - kv * kv;
double v = 2 * jv * kv;
a += u;
gsl_matrix_free (h_sqrt);
gsl_matrix_free (normalised);
- if (cf->rotation == ROT_PROMAX)
+ if (cf->rotation == ROT_PROMAX)
{
/* general purpose m by m matrix, where m is the number of factors */
- gsl_matrix *mm1 = gsl_matrix_calloc (unrot->size2, unrot->size2);
+ gsl_matrix *mm1 = gsl_matrix_calloc (unrot->size2, unrot->size2);
gsl_matrix *mm2 = gsl_matrix_calloc (unrot->size2, unrot->size2);
/* general purpose m by p matrix, where p is the number of variables */
/* Vector of length p containing (indexed by i)
\Sum^m_j {\lambda^2_{ij}} */
- gsl_vector *rssq = gsl_vector_calloc (unrot->size1);
+ gsl_vector *rssq = gsl_vector_calloc (unrot->size1);
for (i = 0; i < P->size1; ++i)
{
{
sum += gsl_matrix_get (result, i, j)
* gsl_matrix_get (result, i, j);
-
+
}
-
+
gsl_vector_set (rssq, i, sqrt (sum));
}
gsl_linalg_matmult_mod (mm1, GSL_LINALG_MOD_NONE,
C, GSL_LINALG_MOD_TRANSPOSE,
factor_correlation_matrix);
-
+
gsl_linalg_matmult_mod (pattern_matrix, GSL_LINALG_MOD_NONE,
factor_correlation_matrix, GSL_LINALG_MOD_NONE,
pm1);
WS is a pointer to a structure which must have been initialised with factor_matrix_workspace_init.
*/
static void
-iterate_factor_matrix (const gsl_matrix *r, gsl_vector *communalities, gsl_matrix *factors,
+iterate_factor_matrix (const gsl_matrix *r, gsl_vector *communalities, gsl_matrix *factors,
struct factor_matrix_workspace *ws)
{
size_t i;
if ( factor.rotation == ROT_NONE )
factor.print &= ~PRINT_ROTATION;
- if ( ! run_factor (ds, &factor))
+ if ( ! run_factor (ds, &factor))
goto error;
free (factor.vars);
struct tab_table *t = tab_create (nc, nr);
- /*
+ /*
if ( factor->extraction == EXTRACTION_PC )
tab_title (t, _("Component Matrix"));
- else
+ else
tab_title (t, _("Factor Matrix"));
*/
for (i = 0 ; i < fcm->size1; ++i)
{
for (j = 0 ; j < fcm->size2; ++j)
- tab_double (t, heading_columns + i, heading_rows +j, 0,
+ tab_double (t, heading_columns + i, heading_rows +j, 0,
gsl_matrix_get (fcm, i, j), NULL, RC_OTHER);
}
var_matrix = covariance_moments (cov, MOMENT_VARIANCE);
mean_matrix = covariance_moments (cov, MOMENT_MEAN);
idata->n = covariance_moments (cov, MOMENT_NONE);
-
+
if ( factor->method == METHOD_CORR)
{
idata->corr = correlation_from_covariance (idata->cov, var_matrix);
-
+
analysis_matrix = idata->corr;
}
else
tab_text (t, 1, 3, TAT_TITLE, _("Sig."));
- /* The literature doesn't say what to do for the value of W when
+ /* The literature doesn't say what to do for the value of W when
missing values are involved. The best thing I can think of
is to take the mean average. */
w = 0;
tab_double (t, 2, 1, 0, xsq, NULL, RC_OTHER);
tab_double (t, 2, 2, 0, df, NULL, RC_INTEGER);
tab_double (t, 2, 3, 0, gsl_cdf_chisq_Q (xsq, df), NULL, RC_PVALUE);
-
+
tab_submit (t);
}
{
gsl_matrix *am = matrix_dup (analysis_matrix);
gsl_eigen_symmv_workspace *workspace = gsl_eigen_symmv_alloc (factor->n_vars);
-
+
gsl_eigen_symmv (am, idata->eval, idata->evec, workspace);
gsl_eigen_symmv_free (workspace);
if (idata->n_extractions > factor->n_vars)
{
- msg (MW,
- _("The %s criteria result in more factors than variables, which is not meaningful. No analysis will be performed."),
+ msg (MW,
+ _("The %s criteria result in more factors than variables, which is not meaningful. No analysis will be performed."),
"FACTOR");
goto finish;
}
-
+
{
gsl_matrix *rotated_factors = NULL;
gsl_matrix *pattern_matrix = NULL;
gsl_vector_memcpy (diff, idata->msr);
iterate_factor_matrix (analysis_matrix, idata->msr, factor_matrix, fmw);
-
+
gsl_vector_sub (diff, idata->msr);
gsl_vector_minmax (diff, &min, &max);
-
+
if ( fabs (min) < factor->econverge && fabs (max) < factor->econverge)
break;
}
pattern_matrix = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2);
fcm = gsl_matrix_calloc (factor_matrix->size2, factor_matrix->size2);
}
-
+
rotate (factor, factor_matrix, extracted_communalities, rotated_factors, rotated_loadings, pattern_matrix, fcm);
}
-
+
show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues, rotated_loadings);
factor_matrix_workspace_free (fmw);
/*
PSPP - a program for statistical analysis.
Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2014, 2015 Free Software Foundation, Inc.
-
+
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 Free Software Foundation, either version 3 of the License, or
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
FRQ_PERCENT
};
-enum sortprops
+enum sortprops
{
FRQ_AFREQ,
FRQ_DFREQ,
static void calc_stats (const struct var_freqs *vf, double d[FRQ_ST_count]);
-static void do_piechart(const struct frq_chart *pie,
+static void do_piechart(const struct frq_chart *pie,
const struct variable *var,
const struct freq_tab *frq_tab);
const struct variable **var,
const struct freq_tab *frq_tab);
-static void dump_statistics (const struct frq_proc *frq,
+static void dump_statistics (const struct frq_proc *frq,
const struct var_freqs *vf,
const struct variable *wv);
frq.vars = NULL;
frq.n_vars = 0;
-
- frq.stats = BIT_INDEX (FRQ_ST_MEAN)
- | BIT_INDEX (FRQ_ST_STDDEV)
+
+ frq.stats = BIT_INDEX (FRQ_ST_MEAN)
+ | BIT_INDEX (FRQ_ST_STDDEV)
| BIT_INDEX (FRQ_ST_MINIMUM)
| BIT_INDEX (FRQ_ST_MAXIMUM);
if (lex_match_id (lexer, "STATISTICS"))
{
- frq.stats = BIT_INDEX (FRQ_ST_MEAN)
- | BIT_INDEX (FRQ_ST_STDDEV)
+ frq.stats = BIT_INDEX (FRQ_ST_MEAN)
+ | BIT_INDEX (FRQ_ST_STDDEV)
| BIT_INDEX (FRQ_ST_MINIMUM)
| BIT_INDEX (FRQ_ST_MAXIMUM);
-
+
frq.n_stats = 4;
if (lex_match (lexer, T_EQUALS))
{
if (lex_match_id (lexer, "DEFAULT"))
{
- frq.stats = BIT_INDEX (FRQ_ST_MEAN)
- | BIT_INDEX (FRQ_ST_STDDEV)
+ frq.stats = BIT_INDEX (FRQ_ST_MEAN)
+ | BIT_INDEX (FRQ_ST_STDDEV)
| BIT_INDEX (FRQ_ST_MINIMUM)
| BIT_INDEX (FRQ_ST_MAXIMUM);
if (lex_force_num (lexer))
{
frq.percentiles =
- xrealloc (frq.percentiles,
+ xrealloc (frq.percentiles,
(frq.n_percentiles + 1)
* sizeof (*frq.percentiles));
frq.percentiles[frq.n_percentiles].p = lex_number (lexer) / 100.0;
for (i = 0; i < n + 1; ++i)
{
frq.percentiles =
- xrealloc (frq.percentiles,
+ xrealloc (frq.percentiles,
(frq.n_percentiles + 1)
* sizeof (*frq.percentiles));
frq.percentiles[frq.n_percentiles].p =
if (frq.stats & BIT_INDEX (FRQ_ST_MEDIAN))
{
frq.percentiles =
- xrealloc (frq.percentiles,
+ xrealloc (frq.percentiles,
(frq.n_percentiles + 1)
* sizeof (*frq.percentiles));
-
+
frq.percentiles[frq.n_percentiles].p = 0.50;
frq.percentiles[frq.n_percentiles].show = true;
msg (SE, _("%s for histogram must be greater than or equal to %s, "
"but %s was specified as %.15g and %s as %.15g. "
"%s and %s will be ignored."),
- "MAX", "MIN",
- "MIN", hist->x_min,
+ "MAX", "MIN",
+ "MIN", hist->x_min,
"MAX", hist->x_max,
"MIN", "MAX");
hist->x_min = hist->x_max = SYSMIS;
}
frq.percentiles =
- xrealloc (frq.percentiles,
+ xrealloc (frq.percentiles,
(frq.n_percentiles + 2)
* sizeof (*frq.percentiles));
-
+
frq.percentiles[frq.n_percentiles].p = 0.25;
frq.percentiles[frq.n_percentiles].show = false;
frq.percentiles[frq.n_percentiles + 1].p = 0.75;
frq.percentiles[frq.n_percentiles + 1].show = false;
-
+
frq.n_percentiles+=2;
}
{
msg (SE, _("%s for pie chart must be greater than or equal to %s, "
"but %s was specified as %.15g and %s as %.15g. "
- "%s and %s will be ignored."),
- "MAX", "MIN",
+ "%s and %s will be ignored."),
+ "MAX", "MIN",
"MIN", pie->x_min,
"MAX", pie->x_max,
"MIN", "MAX");
int i,o;
double previous_p = -1;
qsort (frq.percentiles, frq.n_percentiles,
- sizeof (*frq.percentiles),
+ sizeof (*frq.percentiles),
ptile_3way);
frq.n_show_percentiles = 0;
int n_slices = 0;
int i;
struct freq *slices = xnmalloc (frq_tab->n_valid + frq_tab->n_missing, sizeof *slices);
-
+
for (i = 0; i < frq_tab->n_valid; i++)
{
const struct freq *f = &frq_tab->valid[i];
if (f->count < catchart->x_min)
continue;
-
+
slices[n_slices] = *f;
-
+
n_slices++;
}
{
const struct freq *f = &frq_tab->missing[i];
slices[n_slices].count += f->count;
-
+
if (i == 0)
slices[n_slices].values[0] = f->values[0];
}
-
+
if (frq_tab->n_missing > 0)
n_slices++;
}
int n_slices = 0;
int i;
struct freq **slices = xnmalloc (frq_tab->n_valid + frq_tab->n_missing, sizeof *slices);
-
+
for (i = 0; i < frq_tab->n_valid; i++)
{
struct freq *f = &frq_tab->valid[i];
if (f->count < catchart->x_min)
continue;
-
+
slices[n_slices] = f;
-
+
n_slices++;
}
}
slices[n_slices]->count += f->count;
-
+
}
}
struct freq **slices = pick_cat_counts_ptr (bar, frq_tab, &n_slices);
chart_item_submit (barchart_create (var, 1,
- (bar->y_scale == FRQ_FREQ) ? _("Count") : _("Percent"),
+ (bar->y_scale == FRQ_FREQ) ? _("Count") : _("Percent"),
(bar->y_scale == FRQ_PERCENT),
slices, n_slices));
free (slices);
const struct dictionary *dict;
};
-static void show_ranks_box (const struct one_sample_test *ost,
+static void show_ranks_box (const struct one_sample_test *ost,
const struct friedman *fr);
static void show_sig_box (const struct one_sample_test *ost,
if (a->x < b->x)
return -1;
-
+
return (a->x > b->x);
}
if (a->posn < b->posn)
return -1;
-
+
return (a->posn > b->posn);
}
struct friedman_test *ft = UP_CAST (ost, struct friedman_test, parent);
bool warn = true;
- double sigma_t = 0.0;
+ double sigma_t = 0.0;
struct datum *row = xcalloc (ost->n_vars, sizeof *row);
double rsq;
struct friedman fr;
show_sig_box (const struct one_sample_test *ost, const struct friedman *fr)
{
const struct friedman_test *ft = UP_CAST (ost, const struct friedman_test, parent);
-
+
int row = 0;
const struct variable *weight = dict_get_weight (fr->dict);
const struct fmt_spec *wfmt = weight ? var_get_print_format (weight) : &F_8_0;
tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1);
row = 0;
- tab_double (table, 1, column_headers + row++,
+ tab_double (table, 1, column_headers + row++,
0, fr->cc, NULL, RC_WEIGHT);
if (ft->kendalls_w)
- tab_double (table, 1, column_headers + row++,
+ tab_double (table, 1, column_headers + row++,
0, fr->w, NULL, RC_OTHER);
- tab_double (table, 1, column_headers + row++,
+ tab_double (table, 1, column_headers + row++,
0, fr->chi_sq, NULL, RC_OTHER);
- tab_double (table, 1, column_headers + row++,
+ tab_double (table, 1, column_headers + row++,
0, ost->n_vars - 1, NULL, RC_INTEGER);
- tab_double (table, 1, column_headers + row++,
- 0, gsl_cdf_chisq_Q (fr->chi_sq, ost->n_vars - 1),
+ tab_double (table, 1, column_headers + row++,
+ 0, gsl_cdf_chisq_Q (fr->chi_sq, ost->n_vars - 1),
NULL, RC_PVALUE);
tab_submit (table);
struct categoricals *cats;
- /*
+ /*
Sums of squares due to different variables. Element 0 is the SSE
for the entire model. For i > 0, element i is the SS due to
variable i.
lex_error (lexer, NULL);
goto error;
}
-
+
glm.alpha = lex_number (lexer);
lex_get (lexer);
if ( ! lex_force_match (lexer, T_RPAREN))
size_t j;
size_t n = 0;
size_t m = 0;
-
+
for (i = 0; i < cov->size1; i++)
{
if (not_dropped (i, dropped_f))
- {
+ {
m = 0;
for (j = 0; j < cov->size2; j++)
{
gsl_matrix_set (submatrix, n, m,
gsl_matrix_get (cov, i, j));
m++;
- }
+ }
}
n++;
}
}
-/*
+/*
Type 1 sums of squares.
Populate SSQ with the Type 1 sums of squares according to COV
*/
{
gsl_matrix *model_cov = NULL;
gsl_matrix *submodel_cov = NULL;
-
+
n_dropped_submodel = n_dropped_model;
for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++)
{
for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++)
{
- const struct interaction * x =
+ const struct interaction * x =
categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars);
if ( x == cmd->interactions [k])
free (submodel_dropped);
}
-/*
+/*
Type 2 sums of squares.
Populate SSQ with the Type 2 sums of squares according to COV
*/
size_t n_dropped_submodel = 0;
for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++)
{
- const struct interaction * x =
+ const struct interaction * x =
categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars);
model_dropped[i] = false;
free (submodel_dropped);
}
-/*
+/*
Type 3 sums of squares.
Populate SSQ with the Type 2 sums of squares according to COV
*/
for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++)
{
- const struct interaction * x =
+ const struct interaction * x =
categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars);
model_dropped[i] = false;
cmd->factor_vars, cmd->n_factor_vars,
cmd->exclude,
NULL, NULL);
-
+
ws.cats = categoricals_create (cmd->interactions, cmd->n_interactions,
cmd->wv, cmd->exclude, MV_ANY);
taint_destroy (taint);
}
-static const char *roman[] =
+static const char *roman[] =
{
"", /* The Romans had no concept of zero */
"I",
/* TRANSLATORS: The parameter is a roman numeral */
tab_text_format (t, 1, 0, TAB_CENTER | TAT_TITLE,
- _("Type %s Sum of Squares"),
+ _("Type %s Sum of Squares"),
roman[cmd->ss_type]);
tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df"));
tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
ssq_effects += ssq;
- if (! cmd->intercept)
+ if (! cmd->intercept)
{
df++;
ssq += intercept_ssq;
tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Total"));
tab_double (t, 1, r, 0, ws->total_ssq + intercept_ssq, NULL, RC_OTHER);
tab_double (t, 2, r, 0, n_total, NULL, RC_WEIGHT);
-
+
r++;
}
return false;
}
- lex_error (lexer, "Nested variables are not yet implemented"); return false;
+ lex_error (lexer, "Nested variables are not yet implemented"); return false;
return true;
}
/*
PSPP - a program for statistical analysis.
Copyright (C) 2012, 2013, 2015 Free Software Foundation, Inc.
-
+
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 Free Software Foundation, either version 3 of the License, or
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
enum bar_type bar_type;
const struct variable *by_var[2];
size_t n_by_vars;
-
+
struct subcase ordering; /* Ordering for aggregation */
int agr; /* Index into ag_func */
-
+
/* A caseproto that contains the plot data */
struct caseproto *gr_proto;
};
}
return true;
-
+
error:
lex_error (lexer, NULL);
return false;
{
struct histogram *histogram;
struct ccase *c;
-
+
if (cmd->es[0].cc <= 0)
{
casereader_destroy (input);
return;
}
-
+
{
/* Sturges Rule */
double bin_width = fabs (cmd->es[0].minimum - cmd->es[0].maximum)
struct string label;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[0]));
moments_calculate (cmd->es[0].mom, &n, &mean, &var, NULL, NULL);
ds_cstr (&label), n, mean,
sqrt (var), cmd->normal));
- statistic_destroy (&histogram->parent);
+ statistic_destroy (&histogram->parent);
ds_destroy (&label);
}
}
static void
cleanup_exploratory_stats (struct graph *cmd)
-{
+{
int v;
for (v = 0; v < cmd->n_dep_vars; ++v)
struct casereader *group;
double ccc = 0.0;
- if ( cmd->missing_pw == false)
+ if ( cmd->missing_pw == false)
input = casereader_create_filter_missing (input,
cmd->dep_vars,
cmd->n_dep_vars,
const double x = (cmd->n_dep_vars > 0) ? case_data (c, cmd->dep_vars[0])->f : SYSMIS;
cc += weight;
-
+
freqs[n_freqs - 1]->count
= ag_func[cmd->agr].calc (freqs[n_freqs - 1]->count, x, weight);
}
ag_func[cmd->agr].description,
var_get_name (cmd->dep_vars[0]));
else
- ds_put_cstr (&label,
+ ds_put_cstr (&label,
ag_func[cmd->agr].description);
-
+
chart_item_submit (barchart_create (cmd->by_var, cmd->n_by_vars,
ds_cstr (&label), false,
freqs, n_freqs));
for (int i = 0; i < n_freqs; ++i)
free (freqs[i]);
-
+
free (freqs);
}
struct graph graph;
graph.missing_pw = false;
-
+
graph.pool = pool_create ();
graph.dep_excl = MV_ANY;
graph.fctr_excl = MV_ANY;
-
+
graph.dict = dataset_dict (ds);
-
+
graph.dep_vars = NULL;
graph.chart_type = CT_NONE;
graph.scatter_type = ST_BIVARIATE;
graph.gr_proto = caseproto_create ();
subcase_init_empty (&graph.ordering);
-
+
while (lex_token (lexer) != T_ENDCMD)
{
lex_match (lexer, T_SLASH);
{
if (!lex_force_match_id (lexer, "NORMAL"))
goto error;
-
+
if (!lex_force_match (lexer, T_RPAREN))
goto error;
}
graph.chart_type = CT_BAR;
graph.bar_type = CBT_SIMPLE;
-
- if (lex_match (lexer, T_LPAREN))
+
+ if (lex_match (lexer, T_LPAREN))
{
if (lex_match_id (lexer, "SIMPLE"))
{
/* This is the default anyway */
}
- else if (lex_match_id (lexer, "GROUPED"))
+ else if (lex_match_id (lexer, "GROUPED"))
{
- graph.bar_type = CBT_GROUPED;
+ graph.bar_type = CBT_GROUPED;
goto error;
}
- else if (lex_match_id (lexer, "STACKED"))
+ else if (lex_match_id (lexer, "STACKED"))
{
- graph.bar_type = CBT_STACKED;
+ graph.bar_type = CBT_STACKED;
lex_error (lexer, _("%s is not yet implemented."), "STACKED");
goto error;
}
- else if (lex_match_id (lexer, "RANGE"))
+ else if (lex_match_id (lexer, "RANGE"))
{
- graph.bar_type = CBT_RANGE;
+ graph.bar_type = CBT_RANGE;
lex_error (lexer, _("%s is not yet implemented."), "RANGE");
goto error;
}
if (!lex_force_match (lexer, T_RPAREN))
goto error;
}
-
+
if (!lex_force_match (lexer, T_EQUALS))
goto error;
goto error;
}
graph.chart_type = CT_SCATTERPLOT;
- if (lex_match (lexer, T_LPAREN))
+ if (lex_match (lexer, T_LPAREN))
{
if (lex_match_id (lexer, "BIVARIATE"))
{
/* This is the default anyway */
}
- else if (lex_match_id (lexer, "OVERLAY"))
+ else if (lex_match_id (lexer, "OVERLAY"))
{
lex_error (lexer, _("%s is not yet implemented."),"OVERLAY");
goto error;
}
- else if (lex_match_id (lexer, "MATRIX"))
+ else if (lex_match_id (lexer, "MATRIX"))
{
lex_error (lexer, _("%s is not yet implemented."),"MATRIX");
goto error;
}
- else if (lex_match_id (lexer, "XYZ"))
+ else if (lex_match_id (lexer, "XYZ"))
{
lex_error(lexer, _("%s is not yet implemented."),"XYZ");
goto error;
&graph.dep_vars, &graph.n_dep_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
goto error;
-
+
if (graph.scatter_type == ST_BIVARIATE && graph.n_dep_vars != 1)
{
lex_error(lexer, _("Only one variable is allowed."));
lex_error (lexer, _("Only one variable is allowed."));
goto error;
}
-
+
if (lex_match (lexer, T_BY))
{
const struct variable *v = NULL;
struct casegrouper *grouper;
struct casereader *group;
bool ok;
-
+
grouper = casegrouper_create_splits (proc_open (ds), graph.dict);
while (casegrouper_get_next_group (grouper, &group))
{
const struct n_sample_test *nst = aux;
const union value *bigger = NULL;
const union value *smaller = NULL;
-
+
if (0 > value_compare_3way (&nst->val1, &nst->val2, var_get_width (nst->indep_var)))
{
bigger = &nst->val2;
smaller = &nst->val2;
bigger = &nst->val1;
}
-
+
if (0 < value_compare_3way (smaller, case_data (c, nst->indep_var), var_get_width (nst->indep_var)))
return false;
{
/* The total of the caseweights in the group */
double cc;
-
+
/* A casereader containing the group data.
This casereader contains just two values:
0: The raw value of the data
{
double x1 = case_data_idx (c1, 0)->f;
double cc1 = case_data_idx (c1, 1)->f;
-
+
if (x0 > x1)
{
/* Do nothing */
typedef double func_f (double e_l);
-/*
- These 3 functions are used repeatedly in the calculation of the
+/*
+ These 3 functions are used repeatedly in the calculation of the
variance of the JT statistic.
- Having them explicitly defined makes the variance calculation
+ Having them explicitly defined makes the variance calculation
a lot simpler.
*/
-static double
+static double
ff1 (double e)
{
return e * (e - 1) * (2*e + 5);
}
-static double
+static double
ff2 (double e)
{
return e * (e - 1) * (e - 2);
}
-static double
+static double
ff3 (double e)
{
return e * (e - 1) ;
}
-static func_f *mff[3] =
+static func_f *mff[3] =
{
ff1, ff2, ff3
};
*/
static
void variance_calculation (struct casereader *ir, const struct variable *var,
- const struct dictionary *dict,
+ const struct dictionary *dict,
func_f **f, double *result, size_t n)
{
int i;
r = sort_execute_1var (r, var);
r = casereader_create_distinct (r, var, dict_get_weight (dict));
-
+
for (; (c = casereader_read (r)); case_unref (c))
{
double w = case_data_idx (c, w_idx)->f;
bool warn = true;
const struct dictionary *dict = dataset_dict (ds);
const struct n_sample_test *nst = UP_CAST (test, const struct n_sample_test, parent);
-
+
struct caseproto *proto = caseproto_create ();
proto = caseproto_add_width (proto, 0);
proto = caseproto_add_width (proto, 0);
/* If the independent variable is missing, then we ignore the case */
- input = casereader_create_filter_missing (input,
+ input = casereader_create_filter_missing (input,
&nst->indep_var, 1,
exclude,
NULL, NULL);
input = casereader_create_filter_weight (input, dict, &warn, NULL);
/* Remove all those cases which are outside the range (val1, val2) */
- input = casereader_create_filter_func (input, include_func_bi, NULL,
+ input = casereader_create_filter_func (input, include_func_bi, NULL,
CONST_CAST (struct n_sample_test *, nst), NULL);
/* Sort the data by the independent variable */
/* Get a few values into e_sum - we'll be needing these later */
variance_calculation (vreader, nst->vars[v], dict, mff, e_sum, 3);
-
+
grouper =
casegrouper_create_vars (vreader, &nst->indep_var, 1);
jt.obs = 0;
jt.levels = 0;
jt.n = 0;
- for (; casegrouper_get_next_group (grouper, &group);
+ for (; casegrouper_get_next_group (grouper, &group);
casereader_destroy (group) )
{
struct casewriter *writer = autopaging_writer_create (proto);
{
double std_jt;
- tab_text (table, 0, i + row_headers, TAT_TITLE,
+ tab_text (table, 0, i + row_headers, TAT_TITLE,
var_to_string (nst->vars[i]) );
- tab_double (table, 1, i + row_headers, TAT_TITLE,
+ tab_double (table, 1, i + row_headers, TAT_TITLE,
jt[0].levels, NULL, RC_INTEGER);
-
- tab_double (table, 2, i + row_headers, TAT_TITLE,
+
+ tab_double (table, 2, i + row_headers, TAT_TITLE,
jt[0].n, NULL, RC_WEIGHT);
- tab_double (table, 3, i + row_headers, TAT_TITLE,
+ tab_double (table, 3, i + row_headers, TAT_TITLE,
jt[0].obs, NULL, RC_OTHER);
- tab_double (table, 4, i + row_headers, TAT_TITLE,
+ tab_double (table, 4, i + row_headers, TAT_TITLE,
jt[0].mean, NULL, RC_OTHER);
- tab_double (table, 5, i + row_headers, TAT_TITLE,
+ tab_double (table, 5, i + row_headers, TAT_TITLE,
jt[0].stddev, NULL, RC_OTHER);
std_jt = (jt[0].obs - jt[0].mean) / jt[0].stddev;
- tab_double (table, 6, i + row_headers, TAT_TITLE,
+ tab_double (table, 6, i + row_headers, TAT_TITLE,
std_jt, NULL, RC_OTHER);
- tab_double (table, 7, i + row_headers, TAT_TITLE,
+ tab_double (table, 7, i + row_headers, TAT_TITLE,
2.0 * ((std_jt > 0) ? gsl_cdf_ugaussian_Q (std_jt) : gsl_cdf_ugaussian_P (std_jt)), NULL, RC_PVALUE);
}
-
+
tab_submit (table);
}
if (0 == value_compare_3way (group, &re->group, width))
return re;
}
-
+
return re;
}
struct kw *kw = xcalloc (nst->n_vars, sizeof *kw);
/* If the independent variable is missing, then we ignore the case */
- input = casereader_create_filter_missing (input,
+ input = casereader_create_filter_missing (input,
&nst->indep_var, 1,
exclude,
NULL, NULL);
input = casereader_create_filter_weight (input, dict, &warn, NULL);
/* Remove all those cases which are outside the range (val1, val2) */
- input = casereader_create_filter_func (input, include_func, NULL,
+ input = casereader_create_filter_func (input, include_func, NULL,
CONST_CAST (struct n_sample_test *, nst), NULL);
proto = casereader_get_proto (input);
exclude,
NULL, NULL);
- rr = casereader_create_append_rank (r,
+ rr = casereader_create_append_rank (r,
nst->vars[i],
dict_get_weight (dict),
&rerr,
{
const union value *group = case_data (c, nst->indep_var);
const size_t group_var_width = var_get_width (nst->indep_var);
- struct rank_entry *rank = find_rank_entry (&kw[i].map, group, group_var_width);
+ struct rank_entry *rank = find_rank_entry (&kw[i].map, group, group_var_width);
if ( NULL == rank)
{
total_n_groups ++;
}
kw[i].h *= 12 / (n * ( n + 1));
- kw[i].h -= 3 * (n + 1) ;
+ kw[i].h -= 3 * (n + 1) ;
kw[i].h /= 1 - tiebreaker/ (pow3 (n) - n);
}
}
casereader_destroy (input);
-
+
show_ranks_box (nst, kw, total_n_groups);
show_sig_box (nst, kw);
tab_box (table, TAL_2, TAL_2, -1, -1,
0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
- tab_text (table, 1, 0, TAT_TITLE,
+ tab_text (table, 1, 0, TAT_TITLE,
var_to_string (nst->indep_var)
);
if (i > 0)
tab_hline (table, TAL_1, 0, tab_nc (table) -1, row);
-
+
tab_text (table, 0, row,
TAT_TITLE, var_to_string (nst->vars[i]));
struct string str;
ds_init_empty (&str);
-
+
var_append_value_name (nst->indep_var, &re->group, &str);
-
+
tab_text (table, 1, row, TAB_LEFT, ds_cstr (&str));
tab_double (table, 2, row, TAB_LEFT, re->n, NULL, RC_INTEGER);
tab_double (table, 3, row, TAB_LEFT, re->sum_of_ranks / re->n, NULL, RC_OTHER);
-
+
tot += re->n;
row++;
ds_destroy (&str);
for (i = 0 ; i < nst->n_vars; ++i)
{
const double df = hmap_count (&kw[i].map) - 1;
- tab_text (table, column_headers + 1 + i, 0, TAT_TITLE,
+ tab_text (table, column_headers + 1 + i, 0, TAT_TITLE,
var_to_string (nst->vars[i])
);
}
-static const theoreticalfp theoreticalf[4] =
+static const theoreticalfp theoreticalf[4] =
{
theoretical_normal,
theoretical_uniform,
theoretical_exponential
};
-/*
+/*
Return the assymptotic approximation to the significance of Z
*/
static double
{
if (z < 0.27)
return 1;
-
+
if (z >= 3.1)
return 0;
{
const struct variable *var = ost->vars[v];
const union value *val = case_data (c, var);
-
+
if (var_is_value_missing (var, val, exclude))
continue;
case KS_EXPONENTIAL:
if (kst->p[0] != SYSMIS)
ks[v].mu = ks[v].sigma = kst->p[0];
- else
+ else
ks[v].mu = ks[v].sigma = ks[v].sum / ks[v].obs_cc;
break;
default:
cc += weight;
empirical = cc / ks[v].obs_cc;
-
+
theoretical = theoreticalf[kst->dist] (&ks[v], val->f);
-
+
d = empirical - theoretical;
dp = prev_empirical - theoretical;
if (d > 0)
- maximize (&ks[v].diff_pos, d);
+ maximize (&ks[v].diff_pos, d);
else
minimize (&ks[v].diff_neg, d);
if (dp > 0)
- maximize (&ks[v].diff_pos, dp);
+ maximize (&ks[v].diff_pos, dp);
else
minimize (&ks[v].diff_neg, dp);
case KS_NORMAL:
tab_text (table, 0, 2,
TAT_TITLE | TAB_LEFT , _("Normal Parameters"));
-
+
tab_text (table, 1, 2,
TAT_TITLE | TAB_LEFT , _("Mean"));
tab_text (table, 1, 3,
case KS_UNIFORM:
tab_text (table, 0, 2,
TAT_TITLE | TAB_LEFT , _("Uniform Parameters"));
-
+
tab_text (table, 1, 2,
TAT_TITLE | TAB_LEFT , _("Minimum"));
tab_text (table, 1, 3,
case KS_POISSON:
tab_text (table, 0, 2,
TAT_TITLE | TAB_LEFT , _("Poisson Parameters"));
-
+
tab_text (table, 1, 2,
TAT_TITLE | TAB_LEFT , _("Lambda"));
break;
case KS_EXPONENTIAL:
tab_text (table, 0, 2,
TAT_TITLE | TAB_LEFT , _("Exponential Parameters"));
-
+
tab_text (table, 1, 2,
TAT_TITLE | TAB_LEFT , _("Scale"));
break;
double z = 0;
const int col = 2 + i;
tab_text (table, col, 0,
- TAT_TITLE | TAB_CENTER ,
+ TAT_TITLE | TAB_CENTER ,
var_to_string (kst->parent.vars[i]));
switch (kst->dist)
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/*
- References:
+/*
+ References:
1. "Coding Logistic Regression with Newton-Raphson", James McCaffrey
http://msdn.microsoft.com/en-us/magazine/jj618304.aspx
2. "SPSS Statistical Algorithms" Chapter LOGISTIC REGRESSION Algorithms
- The Newton Raphson method finds successive approximations to $\bf b$ where
+ The Newton Raphson method finds successive approximations to $\bf b$ where
approximation ${\bf b}_t$ is (hopefully) better than the previous ${\bf b}_{t-1}$.
$ {\bf b}_t = {\bf b}_{t -1} + ({\bf X}^T{\bf W}_{t-1}{\bf X})^{-1}{\bf X}^T({\bf y} - {\bf \pi}_{t-1})$
where:
- $\bf X$ is the $n \times p$ design matrix, $n$ being the number of cases,
+ $\bf X$ is the $n \times p$ design matrix, $n$ being the number of cases,
$p$ the number of parameters, \par
$\bf W$ is the diagonal matrix whose diagonal elements are
$\hat{\pi}_0(1 - \hat{\pi}_0), \, \hat{\pi}_1(1 - \hat{\pi}_2)\dots \hat{\pi}_{n-1}(1 - \hat{\pi}_{n-1})$
#include <config.h>
-#include <gsl/gsl_blas.h>
+#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_cdf.h>
*/
struct lr_result
{
- /* Used to indicate if a pass should flag a warning when
+ /* Used to indicate if a pass should flag a warning when
invalid (ie negative or missing) weight values are encountered */
bool warn_bad_weight;
/* The estimates of the predictor coefficients */
gsl_vector *beta_hat;
- /* The predicted classifications:
+ /* The predicted classifications:
True Negative, True Positive, False Negative, False Positive */
double tn, tp, fn, fp;
};
static void output_depvarmap (const struct lr_spec *cmd, const struct lr_result *);
-static void output_variables (const struct lr_spec *cmd,
+static void output_variables (const struct lr_spec *cmd,
const struct lr_result *);
static void output_model_summary (const struct lr_result *,
/* Return the value of case C corresponding to the INDEX'th entry in the
model */
static double
-predictor_value (const struct ccase *c,
- const struct variable **x, size_t n_x,
+predictor_value (const struct ccase *c,
+ const struct variable **x, size_t n_x,
const struct categoricals *cats,
size_t index)
{
/* Values of the scalar predictor variables */
- if (index < n_x)
+ if (index < n_x)
return case_data (c, x[index])->f;
/* Coded values of categorical predictor variables (or interactions) */
Return the probability beta_hat (that is the estimator logit(y) )
corresponding to the coefficient estimator for case C
*/
-static double
-pi_hat (const struct lr_spec *cmd,
+static double
+pi_hat (const struct lr_spec *cmd,
const struct lr_result *res,
const struct variable **x, size_t n_x,
const struct ccase *c)
pi += gsl_vector_get (res->beta_hat, res->beta_hat->size - 1);
n_coeffs--;
}
-
+
for (v0 = 0; v0 < n_coeffs; ++v0)
{
- pi += gsl_vector_get (res->beta_hat, v0) *
+ pi += gsl_vector_get (res->beta_hat, v0) *
predictor_value (c, x, n_x, res->cats, v0);
}
/*
Calculates the Hessian matrix X' V X,
where: X is the n by N_X matrix comprising the n cases in INPUT
- V is a diagonal matrix { (pi_hat_0)(1 - pi_hat_0), (pi_hat_1)(1 - pi_hat_1), ... (pi_hat_{N-1})(1 - pi_hat_{N-1})}
+ V is a diagonal matrix { (pi_hat_0)(1 - pi_hat_0), (pi_hat_1)(1 - pi_hat_1), ... (pi_hat_{N-1})(1 - pi_hat_{N-1})}
(the partial derivative of the predicted values)
If ALL predicted values derivatives are close to zero or one, then CONVERGED
will be set to true.
*/
static void
-hessian (const struct lr_spec *cmd,
+hessian (const struct lr_spec *cmd,
struct lr_result *res,
struct casereader *input,
const struct variable **x, size_t n_x,
/* Calculates the value X' (y - pi)
- where X is the design model,
+ where X is the design model,
y is the vector of observed independent variables
pi is the vector of estimates for y
*freq += weight;
}
-static void
+static void
frq_destroy (const void *aux1 UNUSED, void *aux2 UNUSED, void *user_data UNUSED)
{
free (user_data);
\f
-/*
+/*
Makes an initial pass though the data, doing the following:
* Checks that the dependent variable is dichotomous,
{
missing = true;
}
- else
+ else
for (v = 0; v < cmd->n_indep_vars; ++v)
{
const union value *val = case_data (c, cmd->indep_vars[v]);
And perform other auxilliary initialisation. */
if (! initial_pass (cmd, &work, input))
goto error;
-
+
for (i = 0; i < cmd->n_cat_predictors; ++i)
{
if (1 >= categoricals_n_count (work.cats, i))
{
struct string str;
ds_init_empty (&str);
-
+
interaction_to_string (cmd->cat_predictors[i], &str);
msg (ME, _("Category %s does not have at least two distinct values. Logistic regression will not be run."),
double min, max;
gsl_vector *v ;
-
+
hessian (cmd, &work, input,
cmd->predictor_vars, cmd->n_predictor_vars,
&converged);
- if ( ! converged)
+ if ( ! converged)
msg (MW, _("Estimation terminated at iteration number %d because maximum iterations has been reached"), i );
casereader_destroy (input);
gsl_matrix_free (work.hessian);
- gsl_vector_free (work.beta_hat);
+ gsl_vector_free (work.beta_hat);
categoricals_destroy (work.cats);
return true;
error:
casereader_destroy (input);
gsl_matrix_free (work.hessian);
- gsl_vector_free (work.beta_hat);
+ gsl_vector_free (work.beta_hat);
categoricals_destroy (work.cats);
return false;
{
if (vn->var == var)
break;
-
+
fprintf (stderr, "Warning: Hash table collision\n");
}
-
+
return vn;
}
sizeof (*lr.cat_predictors) * ++lr.n_cat_predictors);
lr.cat_predictors[lr.n_cat_predictors - 1] = 0;
}
- while (parse_design_interaction (lexer, lr.dict,
+ while (parse_design_interaction (lexer, lr.dict,
lr.cat_predictors + lr.n_cat_predictors - 1));
lr.n_cat_predictors--;
}
goto error;
}
cp = lex_number (lexer);
-
+
if (cp < 0 || cp > 1.0)
{
msg (ME, _("Cut point value must be in the range [0,1]"));
}
lr.ilogit_cut_point = - log (1/cp - 1);
-
- /* Copy the predictor variables from the temporary location into the
+
+ /* Copy the predictor variables from the temporary location into the
final one, dropping any categorical variables which appear there.
FIXME: This is O(NxM).
*/
{
vn = xmalloc (sizeof *vn);
vn->var = ivar;
-
+
hmap_insert (&allvars, &vn->node, hash);
}
free (vn);
}
hmap_destroy (&allvars);
- }
+ }
/* logistical regression for each split group */
/* Show the Variables in the Equation box */
static void
-output_variables (const struct lr_spec *cmd,
+output_variables (const struct lr_spec *cmd,
const struct lr_result *res)
{
int row = 0;
tab_text (t, 8, row, TAB_CENTER | TAT_TITLE, _("Lower"));
tab_text (t, 9, row, TAB_CENTER | TAT_TITLE, _("Upper"));
}
-
+
for (row = heading_rows ; row < nr; ++row)
{
const int idx = row - heading_rows - idx_correction;
if (idx < cmd->n_predictor_vars)
{
- tab_text (t, 1, row, TAB_LEFT | TAT_TITLE,
+ tab_text (t, 1, row, TAB_LEFT | TAT_TITLE,
var_to_string (cmd->predictor_vars[idx]));
}
else if (i < cmd->n_cat_predictors)
/* Calculate the Wald statistic,
which is \beta' C^-1 \beta .
where \beta is the vector of the coefficient estimates comprising this
- categorial variable. and C is the corresponding submatrix of the
+ categorial variable. and C is the corresponding submatrix of the
hessian matrix.
*/
gsl_matrix_const_view mv =
struct string str;
const struct ccase *c = categoricals_get_case_by_category_real (res->cats, v, cat);
const double *freq = categoricals_get_user_data_by_category_real (res->cats, v, cat);
-
+
int x;
ds_init_empty (&str);
if (x < cat_predictors->n_vars - 1)
ds_put_cstr (&str, " ");
}
-
+
tab_text (t, 1, heading_rows + r, 0, ds_cstr (&str));
ds_destroy (&str);
tab_double (t, 2, heading_rows + r, 0, *freq, NULL, RC_WEIGHT);
}
-static void
+static void
output_classification_table (const struct lr_spec *cmd, const struct lr_result *res)
{
const struct fmt_spec *wfmt =
tab_joint_text (t, heading_columns, 0, nc - 1, 0,
TAB_CENTER | TAT_TITLE, _("Predicted"));
- tab_joint_text (t, heading_columns, 1, heading_columns + 1, 1,
+ tab_joint_text (t, heading_columns, 1, heading_columns + 1, 1,
0, var_to_string (cmd->dep_var) );
tab_joint_text (t, 1, 2, 2, 2,
tab_double (t, heading_columns + 2, 3, 0, 100 * res->tn / (res->tn + res->fp), NULL, RC_OTHER);
tab_double (t, heading_columns + 2, 4, 0, 100 * res->tp / (res->tp + res->fn), NULL, RC_OTHER);
- tab_double (t, heading_columns + 2, 5, 0,
+ tab_double (t, heading_columns + 2, 5, 0,
100 * (res->tp + res->tn) / (res->tp + res->tn + res->fp + res->fn), NULL, RC_OTHER);
double u; /* The Mann-Whitney U statistic */
double w; /* The Wilcoxon Rank Sum W statistic */
- double z;
+ double z;
};
static void show_ranks_box (const struct n_sample_test *nst, const struct mw *mw);
return false;
}
-
+
void
mann_whitney_execute (const struct dataset *ds,
struct ccase *c;
const struct variable *var = nst->vars[i];
- struct casereader *reader =
+ struct casereader *reader =
casereader_create_filter_func (casereader_clone (input),
belongs_to_test,
NULL,
denominator -= tiebreaker;
denominator *= mwv->n[0] * mwv->n[1];
denominator /= n * (n - 1);
-
+
mwv->z /= sqrt (denominator);
}
}
tab_text (table, 3, 0, TAT_TITLE | TAB_CENTER, _("Z"));
tab_text (table, 4, 0, TAT_TITLE | TAB_CENTER, _("Asymp. Sig. (2-tailed)"));
- if (exact)
+ if (exact)
{
tab_text (table, 5, 0, TAT_TITLE | TAB_CENTER, _("Exact Sig. (2-tailed)"));
tab_text (table, 6, 0, TAT_TITLE | TAB_CENTER, _("Point Probability"));
#include "libpspp/str.h"
#include "output/tab.h"
#include "libpspp/message.h"
-
+
#include "gl/minmax.h"
#include "gl/xalloc.h"
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
struct ccase *c;
-
+
struct casereader *r = input;
struct mcnemar *mc = xcalloc (t2s->n_pairs, sizeof *mc);
ds_init_empty (&val0str);
ds_init_empty (&val1str);
-
+
var_append_value_name ((*vp)[0], ¶m->val0, &val0str);
var_append_value_name ((*vp)[1], ¶m->val1, &val1str);
return *f;
}
-enum
+enum
{
MEANS_MEAN = 0,
MEANS_N,
if (lex_match (lexer, T_BY))
{
table->n_layers++;
- table->layers =
- pool_realloc (cmd->pool, table->layers,
+ table->layers =
+ pool_realloc (cmd->pool, table->layers,
sizeof (*table->layers) * table->n_layers);
- if (!parse_variables_const_pool
+ if (!parse_variables_const_pool
(lexer, cmd->pool, cmd->dict,
&table->layers[table->n_layers - 1].factor_vars,
&table->layers[table->n_layers - 1].n_factor_vars,
/* There is always at least one layer.
However the final layer is the total, and not
- normally considered by the user as a
+ normally considered by the user as a
layer.
*/
table->n_layers++;
- table->layers =
- pool_realloc (cmd->pool, table->layers,
+ table->layers =
+ pool_realloc (cmd->pool, table->layers,
sizeof (*table->layers) * table->n_layers);
table->layers[table->n_layers - 1].factor_vars = NULL;
table->layers[table->n_layers - 1].n_factor_vars = 0;
means.n_tables ++;
means.table = pool_realloc (means.pool, means.table, means.n_tables * sizeof (*means.table));
- if (! parse_means_table_syntax (lexer, &means,
+ if (! parse_means_table_syntax (lexer, &means,
&means.table[means.n_tables - 1]))
{
goto error;
else if (lex_match_id (lexer, "DEPENDENT"))
/*
Use the command "/MISSING=DEPENDENT" to
- include user-missing values for the categorical variables,
+ include user-missing values for the categorical variables,
while excluding them for the dependent variables.
Cases are dropped only when user-missing values
values for categorical variables are treated according to
their face value.
- Cases are ALWAYS dropped when System Missing values appear
+ Cases are ALWAYS dropped when System Missing values appear
in the categorical variables.
*/
{
means.cells =
pool_realloc (means.pool, means.cells,
(means.n_cells += 3) * sizeof (*means.cells));
-
+
means.cells[means.n_cells - 2 - 1] = MEANS_MEAN;
means.cells[means.n_cells - 1 - 1] = MEANS_N;
means.cells[means.n_cells - 0 - 1] = MEANS_STDDEV;
means.cells =
pool_realloc (means.pool, means.cells,
++means.n_cells * sizeof (*means.cells));
-
+
means.cells[means.n_cells - 1] = k;
break;
}
for (l = 0; l < table->n_layers; ++l)
{
interaction_destroy (table->interactions[l]);
- }
+ }
}
-
+
pool_destroy (means.pool);
return CMD_FAILURE;
}
};
-static void
+static void
destroy_n (const void *aux1 UNUSED, void *aux2, void *user_data)
{
struct mtable *table = aux2;
struct per_var_data *pp = &pvd[v];
pp->cell_stats = pool_calloc (means->pool, means->n_cells, sizeof *pp->cell_stats);
-
+
for (i = 0; i < means->n_cells; ++i)
{
payload.update = update_n;
payload.calculate = calculate_n;
payload.destroy = destroy_n;
-
+
for (t = 0; t < cmd->n_tables; ++t)
{
struct mtable *table = &cmd->table[t];
TAB_LEFT | TAT_TITLE, ds_cstr (&str));
- n_total = table->summary[row].missing +
+ n_total = table->summary[row].missing +
table->summary[row].non_missing;
tab_double (t, 1, row + heading_rows,
0, table->summary[row].non_missing, NULL, RC_INTEGER);
tab_text_format (t, 2, row + heading_rows,
- 0, _("%g%%"),
+ 0, _("%g%%"),
table->summary[row].non_missing / (double) n_total * 100.0);
tab_text_format (t, 4, row + heading_rows,
- 0, _("%g%%"),
+ 0, _("%g%%"),
table->summary[row].missing / (double) n_total * 100.0);
tab_double (t, 5, row + heading_rows,
- 0, table->summary[row].missing +
+ 0, table->summary[row].missing +
table->summary[row].non_missing, NULL, RC_INTEGER);
tab_text_format (t, 6, row + heading_rows,
- 0, _("%g%%"),
+ 0, _("%g%%"),
n_total / (double) n_total * 100.0);
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
struct val_node **sorted_array;
double n;
double median;
- double chisq;
+ double chisq;
};
-static int
+static int
val_node_cmp_3way (const void *a_, const void *b_, const void *aux)
{
const struct variable *indep_var = aux;
return value_compare_3way (&(*a)->val, &(*b)->val, var_get_width (indep_var));
}
-static void
+static void
show_frequencies (const struct n_sample_test *nst, const struct results *results, int n_vals, const struct dictionary *);
-static void
+static void
show_test_statistics (const struct n_sample_test *nst, const struct results *results, int, const struct dictionary *);
static struct val_node *
-find_value (const struct hmap *map, const union value *val,
+find_value (const struct hmap *map, const union value *val,
const struct variable *var)
{
struct val_node *foo = NULL;
ptl = percentile_create (0.5, cc);
os = &ptl->parent;
-
+
order_stats_accumulate (&os, 1,
rr,
wvar,
}
results[v].median = median;
-
+
for (; (c = casereader_read (r)) != NULL; case_unref (c))
{
int width = var_get_width (nst->indep_var);
vn = xzalloc (sizeof *vn);
value_clone (&vn->val, indep_val, width);
-
+
hmap_insert (&map, &vn->node, value_hash (indep_val, width, 0));
}
else
n_vals = x;
hmap_destroy (&map);
- sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array),
+ sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array),
val_node_cmp_3way, nst->indep_var);
}
-static void
+static void
show_frequencies (const struct n_sample_test *nst, const struct results *results, int n_vals, const struct dictionary *dict)
{
const struct variable *weight = dict_get_weight (dict);
const int column_headers = 2;
const int nc = row_headers + n_vals;
const int nr = column_headers + nst->n_vars * 2;
-
+
struct tab_table *table = tab_create (nc, nr);
tab_set_format (table, RC_WEIGHT, wfmt);
tab_text (table, row_headers + i, 1,
TAT_TITLE | TAB_LEFT, ds_cstr (&label));
-
+
ds_destroy (&label);
}
}
-static void
+static void
show_test_statistics (const struct n_sample_test *nst,
const struct results *results,
int n_vals,
const int column_headers = 1;
const int nc = row_headers + 5;
const int nr = column_headers + nst->n_vars;
-
+
struct tab_table *table = tab_create (nc, nr);
tab_set_format (table, RC_WEIGHT, wfmt);
tab_double (table, row_headers + 4, column_headers + v,
0, gsl_cdf_chisq_Q (rs->chisq, df), NULL, RC_PVALUE);
}
-
+
tab_submit (table);
}
}
}
- sort (npar_specs.vv, npar_specs.n_vars, sizeof (*npar_specs.vv),
+ sort (npar_specs.vv, npar_specs.n_vars, sizeof (*npar_specs.vv),
compare_var_ptrs_by_name, NULL);
if ( cmd.statistics )
lex_error (lexer, _("Expecting %s, %s, %s or a number."), "MEAN", "MEDIAN", "MODE");
return 0;
}
-
+
if (! lex_force_match (lexer, T_RPAREN))
return 2;
-
+
if (! lex_force_match (lexer, T_EQUALS))
return 2;
-
+
if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
&tp->vars, &tp->n_vars,
PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC))
npar_friedman (struct lexer *lexer, struct dataset *ds,
struct npar_specs *specs)
{
- struct friedman_test *ft = pool_alloc (specs->pool, sizeof (*ft));
+ struct friedman_test *ft = pool_alloc (specs->pool, sizeof (*ft));
struct one_sample_test *ost = &ft->parent;
struct npar_test *nt = &ost->parent;
npar_kendall (struct lexer *lexer, struct dataset *ds,
struct npar_specs *specs)
{
- struct friedman_test *kt = pool_alloc (specs->pool, sizeof (*kt));
+ struct friedman_test *kt = pool_alloc (specs->pool, sizeof (*kt));
struct one_sample_test *ost = &kt->parent;
struct npar_test *nt = &ost->parent;
npar_cochran (struct lexer *lexer, struct dataset *ds,
struct npar_specs *specs)
{
- struct one_sample_test *ft = pool_alloc (specs->pool, sizeof (*ft));
+ struct one_sample_test *ft = pool_alloc (specs->pool, sizeof (*ft));
struct npar_test *nt = &ft->parent;
nt->execute = cochran_execute;
size_t hash = hash_pointer (var, 0);
struct hmapx_node *node;
const struct variable *v = NULL;
-
+
HMAPX_FOR_EACH_WITH_HASH (v, node, hash, var_map)
{
if ( v == var)
}
}
-static void
+static void
n_sample_insert_variables (const struct npar_test *test,
struct hmapx *var_map)
{
struct coeff_node
{
- struct ll ll;
- double coeff;
+ struct ll ll;
+ double coeff;
};
struct contrasts_node
{
- struct ll ll;
+ struct ll ll;
struct ll_list coefficient_list;
};
double n_j, var_j;
double nom,denom;
- moments1_calculate (mom_i, &n_i, NULL, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, NULL, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, NULL, &var_j, 0, 0);
-
+
if ( n_i <= 1.0 || n_j <= 1.0)
return SYSMIS;
double n_j, mean_j, var_j;
double m;
- moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
m = sqrt ((var_i/n_i + var_j/n_j) / 2.0);
}
-static double
+static double
multiple_comparison_sig (double std_err,
const struct per_var_ws *pvw,
const struct descriptive_data *dd_i, const struct descriptive_data *dd_j,
return ph->p1f (ts, k - 1, df);
}
-static double
+static double
mc_half_range (const struct oneway_spec *cmd, const struct per_var_ws *pvw, double std_err, const struct descriptive_data *dd_i, const struct descriptive_data *dd_j, const struct posthoc *ph)
{
int k = pvw->n_groups;
double n_i, mean_i, var_i;
double n_j, mean_j, var_j;
- moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
ts = (mean_i - mean_j) / std_err;
double n_i, mean_i, var_i;
double n_j, mean_j, var_j;
- moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
return (mean_i - mean_j) / std_err;
double n_i, mean_i, var_i;
double n_j, mean_j, var_j;
- moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
t = (mean_i - mean_j) / std_err;
double n_i, mean_i, var_i;
double n_j, mean_j, var_j;
- moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
+ moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
thing = var_i / n_i + var_j / n_j;
-static const struct posthoc ph_tests [] =
+static const struct posthoc ph_tests [] =
{
{ "LSD", N_("LSD"), df_common, lsd_test_stat, lsd_1tailsig, lsd_pinv},
{ "TUKEY", N_("Tukey HSD"), df_common, tukey_test_stat, tukey_1tailsig, tukey_pinv},
struct coeff_node *cn = NULL;
struct coeff_node *cnx = NULL;
struct ll_list *cl = &coeff_list->coefficient_list;
-
+
ll_for_each_safe (cn, cnx, struct coeff_node, ll, cl)
{
free (cn);
}
-
+
free (coeff_list);
}
int
cmd_oneway (struct lexer *lexer, struct dataset *ds)
{
- const struct dictionary *dict = dataset_dict (ds);
+ const struct dictionary *dict = dataset_dict (ds);
struct oneway_spec oneway ;
oneway.n_vars = 0;
oneway.vars = NULL;
ll_init (&oneway.contrast_list);
-
+
if ( lex_match (lexer, T_SLASH))
{
if (!lex_force_match_id (lexer, "VARIABLES"))
goto error;
}
}
-
+
if ( ll_count (coefficient_list) <= 0)
goto error;
return dd;
}
-static void
+static void
killit (const void *aux1 UNUSED, void *aux2 UNUSED, void *user_data)
{
struct descriptive_data *dd = user_data;
}
-static void
+static void
updateit (const void *aux1, void *aux2, void *user_data,
const struct ccase *c, double weight)
{
ws.vws[v].cat = categoricals_create (&ws.vws[v].iact, 1, cmd->wv,
cmd->exclude, cmd->exclude);
- categoricals_set_payload (ws.vws[v].cat, &payload,
+ categoricals_set_payload (ws.vws[v].cat, &payload,
CONST_CAST (struct variable *, cmd->vars[v]),
ws.dd_total[v]);
ws.vws[v].cov = covariance_2pass_create (1, &cmd->vars[v],
- ws.vws[v].cat,
+ ws.vws[v].cat,
cmd->wv, cmd->exclude);
ws.vws[v].nl = levene_create (var_get_width (cmd->indep_var), NULL);
}
if ( ! ok)
{
- msg (MW,
+ msg (MW,
_("Dependent variable %s has no non-missing values. No analysis for this variable will be done."),
var_get_name (cmd->vars[v]));
continue;
/* Degrees of freedom */
tab_double (t, 3, i * 3 + 1, 0, df1, NULL, RC_INTEGER);
- tab_double (t, 3, i * 3 + 2, 0, df2, NULL, RC_INTEGER);
- tab_double (t, 3, i * 3 + 3, 0, n - 1, NULL, RC_INTEGER);
+ tab_double (t, 3, i * 3 + 2, 0, df2, NULL, RC_INTEGER);
+ tab_double (t, 3, i * 3 + 3, 0, n - 1, NULL, RC_INTEGER);
/* Mean Squares */
tab_double (t, 4, i * 3 + 1, TAB_RIGHT, msa, NULL, RC_OTHER);
double n, mean, variance;
const struct descriptive_data *dd = categoricals_get_user_data_by_category (cats, ci);
struct coeff_node *cn = ll_data (coeffi, struct coeff_node, ll);
- const double coef = cn->coeff;
+ const double coef = cn->coeff;
double winv ;
moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL);
int j;
struct descriptive_data *dd_i = categoricals_get_user_data_by_category (cat, i);
const struct ccase *gcc = categoricals_get_case_by_category (cat, i);
-
+
ds_init_empty (&vstr);
var_append_value_name (cmd->indep_var, case_data (gcc, cmd->indep_var), &vstr);
std_err = sqrt (std_err);
tab_double (t, 4, r + rx, 0, std_err, NULL, RC_OTHER);
-
+
tab_double (t, 5, r + rx, 0, 2 * multiple_comparison_sig (std_err, pvw, dd_i, dd_j, ph), NULL, RC_PVALUE);
half_range = mc_half_range (cmd, pvw, std_err, dd_i, dd_j, ph);
-static double
+static double
matrix_mindist (const gsl_matrix *m, int *mn, int *mm)
{
int i, j;
const union value *val = case_data (c, qc->vars[j]);
if ( var_is_value_missing (qc->vars[j], val, qc->exclude))
NOT_REACHED ();
-
+
dist += pow2 (gsl_matrix_get (kmeans->centers, which, j) - val->f);
}
-
+
return dist;
}
{
dist += pow2 (gsl_matrix_get (kmeans->centers, i, j) - gsl_matrix_get (kmeans->centers, which, j));
}
-
+
if (dist < mindist)
{
mindist = dist;
}
}
else if (dist_from_case (kmeans, c, qc, mp) > min_dist_from (kmeans, qc, mq))
- /* If the distance between C and the second nearest group (MP) is greater than the
+ /* If the distance between C and the second nearest group (MP) is greater than the
smallest distance between the nearest group (MQ) and any other group, then replace
MQ with C */
{
if ( var_is_value_missing (qc->vars[j], val, qc->exclude))
missing = true;
}
-
+
if (missing)
continue;
double *x = gsl_matrix_ptr (kmeans->updated_centers, group, j);
*x += val->f * (qc->wv ? case_data (c, qc->wv)->f : 1.0);
}
- }
+ }
casereader_destroy (r);
}
*x /= n + 1; // Plus 1 for the initial centers
}
}
-
+
gsl_matrix_memcpy (kmeans->centers, kmeans->updated_centers);
struct casereader *cs = casereader_clone (reader);
for (; (c = casereader_read (cs)) != NULL; case_unref (c))
{
- int group = -1;
+ int group = -1;
kmeans_get_nearest_group (kmeans, c, qc, &group, NULL, NULL, NULL);
for (j = 0; j < qc->n_vars; ++j)
for (i = 0; (c = casereader_read (cs)) != NULL; i++, case_unref (c))
{
- int clust = -1;
+ int clust = -1;
assert (i < kmeans->n);
kmeans_get_nearest_group (kmeans, c, qc, &clust, NULL, NULL, NULL);
clust = ip->data[clust];
quick_cluster_show_results (struct Kmeans *kmeans, const struct casereader *reader, const struct qc *qc)
{
kmeans_order_groups (kmeans, qc); /* what does this do? */
-
+
if( qc->print_initial_clusters )
quick_cluster_show_centers (kmeans, true, qc);
quick_cluster_show_centers (kmeans, false, qc);
lex_error (lexer, NULL);
goto error;
}
- }
+ }
}
else if (lex_match_id (lexer, "PRINT"))
{
cmd->rs = pool_realloc (cmd->pool, cmd->rs, sizeof (*cmd->rs) * (cmd->n_rs + 1));
rs = &cmd->rs[cmd->n_rs];
-
+
if (lex_match_id (lexer, "RANK"))
{
rs->rfunc = RANK;
{
if ( !lex_force_match (lexer, T_LPAREN))
return false;
-
+
if (! lex_force_int (lexer) )
return false;
-
+
cmd->k_ntiles = lex_integer (lexer);
lex_get (lexer);
-
+
if ( !lex_force_match (lexer, T_RPAREN))
return false;
function_name[f], var_get_name (src_var));
pool_label = pool_strdup (cmd->pool, ds_cstr (&label));
-
+
ds_destroy (&label);
return pool_label;
struct regression_workspace
{
/* The new variables which will be introduced by /SAVE */
- const struct variable **predvars;
+ const struct variable **predvars;
const struct variable **residvars;
- /* A reader/writer pair to temporarily hold the
+ /* A reader/writer pair to temporarily hold the
values of the new variables */
struct casewriter *writer;
struct casereader *reader;
return true;
}
-static int
+static int
save_trans_func (void *aux, struct ccase **c, casenumber x UNUSED)
{
struct save_trans_data *save_trans_data = aux;
double pred = case_data_idx (in, ws->extras * k + ws->pred_idx)->f;
case_data_rw (*c, ws->predvars[k])->f = pred;
}
-
+
if (ws->res_idx != -1)
{
double resid = case_data_idx (in, ws->extras * k + ws->res_idx)->f;
free (regression.dep_vars);
regression.n_dep_vars = 0;
-
+
if (!parse_variables_const (lexer, dict,
®ression.dep_vars,
®ression.n_dep_vars,
workspace.extras = 0;
workspace.res_idx = -1;
workspace.pred_idx = -1;
- workspace.writer = NULL;
+ workspace.writer = NULL;
workspace.reader = NULL;
workspace.residvars = NULL;
workspace.predvars = NULL;
save_trans_data->ws = xmalloc (sizeof (workspace));
memcpy (save_trans_data->ws, &workspace, sizeof (workspace));
save_trans_data->n_dep_vars = regression.n_dep_vars;
-
+
add_transformation (ds, save_trans_func, save_trans_free, save_trans_data);
}
subcommand_statistics (const struct regression *cmd, const linreg * c, const gsl_matrix * cm,
const struct variable *var)
{
- if (cmd->stats & STATS_R)
+ if (cmd->stats & STATS_R)
reg_stats_r (c, var);
- if (cmd->stats & STATS_ANOVA)
+ if (cmd->stats & STATS_ANOVA)
reg_stats_anova (c, var);
if (cmd->stats & STATS_COEFF)
static void
-run_regression (const struct regression *cmd,
+run_regression (const struct regression *cmd,
struct regression_workspace *ws,
struct casereader *input)
{
if (ws->extras > 0)
{
struct casereader *r = casereader_clone (reader);
-
+
for (; (c = casereader_read (r)) != NULL; case_unref (c))
{
struct ccase *outc = case_create (casewriter_get_proto (ws->writer));
}
free (vals);
free (vars);
- }
+ }
casewriter_write (ws->writer, outc);
}
casereader_destroy (r);
tab_vline (t, TAL_0, 1, 0, 0);
- tab_hline (t, TAL_1, 2, 4, 1);
+ tab_hline (t, TAL_1, 2, 4, 1);
tab_joint_text (t, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE, _("Unstandardized Coefficients"));
tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("B"));
tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
tab_double (t, 8, heading_rows, 0, upper, NULL, RC_OTHER);
tab_joint_text_format (t, 7, 0, 8, 0, TAB_CENTER | TAT_TITLE, _("%g%% Confidence Interval for B"), cmd->ci * 100);
- tab_hline (t, TAL_1, 7, 8, 1);
+ tab_hline (t, TAL_1, 7, 8, 1);
tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
}
{
double lower = linreg_coeff (c, j) - tval * std_err ;
double upper = linreg_coeff (c, j) + tval * std_err ;
-
+
tab_double (t, 7, this_row, 0, lower, NULL, RC_OTHER);
tab_double (t, 8, this_row, 0, upper, NULL, RC_OTHER);
}
if ( ! lex_force_match (lexer, T_LPAREN))
goto error;
- if ( ! lex_force_string (lexer) )
+ if ( ! lex_force_string (lexer) )
goto error;
ds_assign_substring (&reliability.scale_name, lex_tokss (lexer));
}
- if ( ! run_reliability (ds, &reliability))
+ if ( ! run_reliability (ds, &reliability))
goto error;
reliability_destroy (&reliability);
}
}
- if ( ! run_roc (ds, &roc))
+ if ( ! run_roc (ds, &roc))
goto error;
if ( roc.state_var)
#endif
-/*
+/*
Return true iff the state variable indicates that C has positive actual state.
- As a side effect, this function also accumulates the roc->{pos,neg} and
+ As a side effect, this function also accumulates the roc->{pos,neg} and
roc->{pos,neg}_weighted counts.
*/
static bool
#define N_EQ 1
#define N_PRED 2
-/* Some intermediate state for calculating the cutpoints and the
+/* Some intermediate state for calculating the cutpoints and the
standard error values */
struct roc_state
{
double n2; /* total weight of negatives */
/* intermediates for standard error */
- double q1hat;
+ double q1hat;
double q2hat;
/* intermediates for cutpoints */
double max;
};
-/*
+/*
Return a new casereader based upon CUTPOINT_RDR.
The number of "positive" cases are placed into
the position TRUE_INDEX, and the number of "negative" cases
into FALSE_INDEX.
- POS_COND and RESULT determine the semantics of what is
+ POS_COND and RESULT determine the semantics of what is
"positive".
WEIGHT is the value of a single count.
*/
static struct casereader *
accumulate_counts (struct casereader *input,
- double result, double weight,
+ double result, double weight,
bool (*pos_cond) (double, double),
int true_index, int false_index)
{
CUTPOINT_RDR accordingly. TRUE_INDEX and FALSE_INDEX are the indices
which receive these values. POS_COND is the condition defining true
and false.
-
+
3. CC is filled with the cumulative weight of all cases of READER.
*/
static struct casereader *
bool (*pred) (double, double),
const struct dictionary *dict,
double *cc,
- struct casereader **cutpoint_rdr,
+ struct casereader **cutpoint_rdr,
bool (*pos_cond) (double, double),
int true_index,
int false_index)
const int weight_idx = w ? var_get_case_index (w) :
caseproto_get_n_widths (casereader_get_proto (r1)) - 1;
-
+
struct ccase *c1;
struct casereader *rclone = casereader_clone (r1);
proto = caseproto_add_width (proto, 0);
proto = caseproto_add_width (proto, 0);
- wtr = autopaging_writer_create (proto);
+ wtr = autopaging_writer_create (proto);
*cc = 0;
casereader_destroy (r2);
}
-
+
casereader_destroy (r1);
casereader_destroy (rclone);
}
-/*
+/*
Create and initialise the rs[x].cutpoint_rdr casereaders. That is, the readers will
be created with width 5, ready to take the values (cutpoint, ROC_TP, ROC_FN, ROC_TN, ROC_FP), and the
reader will be populated with its final number of cases.
{
for (i = 0 ; i < roc->n_vars; ++i)
{
- const union value *v = case_data (c, roc->vars[i]);
+ const union value *v = case_data (c, roc->vars[i]);
const double result = v->f;
if ( mv_is_value_missing (var_get_missing_values (roc->vars[i]), v, roc->exclude))
/* Separate the positive actual state cases from the negative ones */
- positives =
+ positives =
casereader_create_filter_func (input,
match_positives,
NULL,
neg_wtr);
n_proto = caseproto_create ();
-
+
n_proto = caseproto_add_width (n_proto, 0);
n_proto = caseproto_add_width (n_proto, 0);
n_proto = caseproto_add_width (n_proto, 0);
n_pos_gt = prev_pos_gt;
case_data_rw_idx (nc, N_POS_GT)->f = n_pos_gt;
}
-
+
casewriter_write (w, nc);
prev_pos_gt = n_pos_gt;
}
n_neg_lt = prev_neg_lt;
case_data_rw_idx (nc, N_NEG_LT)->f = n_neg_lt;
}
-
+
casewriter_write (w, nc);
prev_neg_lt = n_neg_lt;
}
casereader_destroy (r);
case_unref (prev_case);
- rs[i].auc /= rs[i].n1 * rs[i].n2;
- if ( roc->invert )
+ rs[i].auc /= rs[i].n1 * rs[i].n2;
+ if ( roc->invert )
rs[i].auc = 1 - rs[i].auc;
if ( roc->bi_neg_exp )
subcase_destroy (&down_ordering);
output_roc (rs, roc);
-
+
for (i = 0 ; i < roc->n_vars; ++i)
casereader_destroy (rs[i].cutpoint_rdr);
static void show_runs_result (const struct runs_test *, const struct run_state *, const struct dictionary *);
-void
+void
runs_execute (const struct dataset *ds,
struct casereader *input,
enum mv_class exclude,
const struct variable *var = otp->vars[v];
reader = sort_execute_1var (reader, var);
-
+
grouper = casegrouper_create_vars (reader, &var, 1);
last_cc = SYSMIS;
while (casegrouper_get_next_group (grouper, &group))
median = percentile_create (0.5, cc);
os = &median->parent;
-
+
order_stats_accumulate (&os, 1,
reader,
weight,
double z = runs_statistic (run);
- tab_text (table, row_headers + i, 0,
+ tab_text (table, row_headers + i, 0,
TAT_TITLE | TAB_CENTER ,
var_to_string (otp->vars[i]));
tab_double (table, row_headers +i, 2, 0,
run->nn, NULL, RC_WEIGHT);
-
+
tab_double (table, row_headers +i, 3, 0,
run->np, NULL, RC_WEIGHT);
const struct variable **local_vars = NULL;
size_t var_cnt = 0;
- if (vars == NULL)
+ if (vars == NULL)
vars = &local_vars;
*vars = NULL;
else
direction = SC_ASCEND;
- for (i = prev_var_cnt; i < var_cnt; i++)
+ for (i = prev_var_cnt; i < var_cnt; i++)
{
const struct variable *var = (*vars)[i];
if (!subcase_add_var (ordering, var, direction))
msg (SW, _("Variable %s specified twice in sort criteria."),
- var_get_name (var));
+ var_get_name (var));
}
}
while (lex_token (lexer) == T_ID
double w = dict_get_case_weight (tt->dict, c, NULL);
const union value *gv = case_data (c, gvar);
-
+
int grp = which_group (gv, &is);
if ( grp < 0)
continue;
for (v = 0; v < tt->n_vars; ++v)
ps[v].lev = levene_calculate (ps[v].nl);
-
+
indep_summary (tt, &is, ps);
indep_test (tt, ps);
{
double cc, mean, sigma;
moments_calculate (ps[v].mom[i], &cc, &mean, &sigma, NULL, NULL);
-
+
tab_double (t, 2, v * 2 + i + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT);
tab_double (t, 3, v * 2 + i + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER);
tab_double (t, 4, v * 2 + i + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER);
df = cc0 + cc1 - 2.0;
tab_double (t, 5, v * 2 + heading_rows, TAB_RIGHT, df, NULL, RC_OTHER);
-
+
pooled_variance = ((cc0 - 1)* sigma0 + (cc1 - 1) * sigma1) / df ;
tval = (mean0 - mean1) / sqrt (pooled_variance);
/* second var */
moments_calculate (pp->mom1, &cc, &mean, &sigma, NULL, NULL);
- tab_text (t, 1, v * 2 + 1 + heading_rows, TAB_LEFT, var_to_string (pp->var1));
+ tab_text (t, 1, v * 2 + 1 + heading_rows, TAB_LEFT, var_to_string (pp->var1));
tab_double (t, 3, v * 2 + 1 + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT);
tab_double (t, 2, v * 2 + 1 + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER);
tab_double (t, 4, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER);
tab_text_format (t, 0, v + heading_rows, TAB_LEFT, _("Pair %d"), pp->posn + 1);
- tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s & %s"),
+ tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s & %s"),
var_to_string (pp->var0),
var_to_string (pp->var1));
corr *= cc0 / (cc0 - 1);
tab_double (t, 3, v + heading_rows, TAB_RIGHT, corr, NULL, RC_OTHER);
- tab_double (t, 4, v + heading_rows, TAB_RIGHT,
+ tab_double (t, 4, v + heading_rows, TAB_RIGHT,
2.0 * significance_of_correlation (corr, cc0), NULL, RC_PVALUE);
}
df = cc - 1.0;
tab_text_format (t, 0, v + heading_rows, TAB_LEFT, _("Pair %d"), v + 1);
- tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s - %s"),
+ tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s - %s"),
var_to_string (pp->var0),
var_to_string (pp->var1));
size_t n_v1 = 0;
const struct variable **v2 = NULL;
size_t n_v2 = 0;
-
+
size_t n_pairs = 0;
vp *pairs = NULL;
if (NULL == (gvar = parse_variable (lexer, dict)))
goto parse_failed;
-
+
if (lex_match (lexer, T_LPAREN))
{
n_pairs = n_v1;
else
n_pairs = n_v1 * n_v2;
-
+
pairs = xcalloc (n_pairs, sizeof *pairs);
if ( with)
vp *pair = &pairs[i];
(*pair)[0] = v1[i];
(*pair)[1] = v2[i];
- }
+ }
}
else
{
goto parse_failed;
}
}
- else
+ else
{
lex_error (lexer, NULL);
goto parse_failed;
if (!lex_force_string_or_id (lexer))
return CMD_FAILURE;
- relative_name = utf8_to_filename (lex_tokcstr (lexer));
+ relative_name = utf8_to_filename (lex_tokcstr (lexer));
if (NULL == relative_name)
return CMD_FAILURE;
-
+
filename = include_path_search (relative_name);
free (relative_name);
extern struct fmt_spec ugly [n_RC];
-static const struct thing things[] =
+static const struct thing things[] =
{
{"SIGNIFICANCE", RC_PVALUE},
{"COUNT" ,RC_WEIGHT}
int j, i;
struct output_spec *output_specs = NULL;
int n_os = 0;
-
+
if (!lex_force_match_id (lexer, "MODIFY"))
{
lex_error (lexer, NULL);
os->n_rc = 0;
os->rc = NULL;
bool format = false;
-
- while (lex_token (lexer) != T_SLASH &&
+
+ while (lex_token (lexer) != T_SLASH &&
lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "SELECT"))
{
if (! lex_force_match (lexer, T_EQUALS))
goto error;
-
+
if (! lex_force_match (lexer, T_LBRACK))
goto error;
-
+
while (lex_token (lexer) != T_RBRACK &&
lex_token (lexer) != T_ENDCMD)
{
}
else if (lex_match_id (lexer, "FORMAT"))
{
- struct fmt_spec fmt;
+ struct fmt_spec fmt;
char type[FMT_TYPE_LEN_MAX + 1];
int width = -1;
int decimals = -1;
os->fmt = fmt;
format = true;
}
- else
+ else
{
lex_error (lexer, NULL);
goto error;
if (!format)
goto error;
}
- else
+ else
{
lex_error (lexer, NULL);
- goto error;
+ goto error;
}
}
ugly [output_specs[i].rc[j]] = output_specs[i].fmt;
}
}
-
+
for (j = 0; j < n_os; ++j)
free (output_specs[j].rc);
free (output_specs);
if (!fmt_check_output (&fmt))
return 0;
-
+
if (fmt_is_string (fmt.type))
{
char str[FMT_STRING_LEN_MAX + 1];
{
len <<= 1;
buf = xrealloc (buf, len);
- }
+ }
while (NULL == (wd = getcwd (buf, len)));
return wd;
set_map_in_generic (in, MAP_MISSING);
else if (!lex_force_string (lexer))
return false;
- else
+ else
{
set_map_in_str (in, pool, lex_tokss (lexer), max_src_width,
dict_encoding);
set_map_out_str (out, pool, lex_tokss (lexer));
lex_get (lexer);
}
- else if (lex_match_id (lexer, "COPY"))
+ else if (lex_match_id (lexer, "COPY"))
{
out->copy_input = true;
- out->width = 0;
+ out->width = 0;
}
else
{
const struct variable *narrow_var = NULL;
int min_dst_width = INT_MAX;
trns->max_dst_width = 0;
-
+
for (i = 0; i < trns->var_cnt; i++)
{
const struct variable *v = trns->dst_vars[i];
{
if (out->width > min_dst_width)
{
- msg (ME,
+ msg (ME,
_("Cannot recode because the variable %s would require a width of %d bytes or greater, but it has a width of only %d bytes."),
var_get_name (narrow_var), out->width, min_dst_width);
return false;
}
-
+
value_resize_pool (trns->pool, &out->value,
out->width, trns->max_dst_width);
}
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
should iterate through the map and free the data items before
destroying it. */
void
-hmap_destroy (struct hmap *map)
+hmap_destroy (struct hmap *map)
{
- if (map != NULL && map->buckets != &map->one)
+ if (map != NULL && map->buckets != &map->one)
free (map->buckets);
}
NEW_MASK must be a power of 2 minus 1 (including 0), that is,
its value in binary must be all 1-bits. */
static void
-hmap_rehash (struct hmap *map, size_t new_mask)
+hmap_rehash (struct hmap *map, size_t new_mask)
{
struct hmap_node **new_buckets;
struct hmap_node *node, *next;
assert ((new_mask & (new_mask + 1)) == 0);
if (new_mask)
new_buckets = xcalloc (new_mask + 1, sizeof *new_buckets);
- else
+ else
{
new_buckets = &map->one;
new_buckets[0] = NULL;
}
-
+
if (map->count > 0)
{
for (node = hmap_first (map); node != NULL; node = next)
next = hmap_next (map, node);
node->next = *new_bucket;
*new_bucket = node;
- }
+ }
}
if (map->buckets != &map->one)
free (map->buckets);
store its current number of elements, allocating a new set of
buckets and rehashing if that would save space. */
void
-hmap_shrink (struct hmap *map)
+hmap_shrink (struct hmap *map)
{
size_t new_mask = capacity_to_mask (map->count);
- if (new_mask < map->mask)
- hmap_rehash (map, new_mask);
+ if (new_mask < map->mask)
+ hmap_rehash (map, new_mask);
}
/* Moves NODE around in MAP to compensate for its hash value
void
hmap_changed (struct hmap *map, struct hmap_node *node, size_t new_hash)
{
- if ((new_hash ^ node->hash) & map->mask)
+ if ((new_hash ^ node->hash) & map->mask)
{
hmap_delete (map, node);
hmap_insert_fast (map, node, new_hash);
this function runs in constant time. */
void
hmap_moved (struct hmap *map,
- struct hmap_node *node, const struct hmap_node *old)
+ struct hmap_node *node, const struct hmap_node *old)
{
struct hmap_node **p = &map->buckets[node->hash & map->mask];
while (*p != old)
a bit-mask suitable for use as the "mask" member of struct
hmap, that is, a power of 2 minus 1 (including 0). */
static size_t
-capacity_to_mask (size_t capacity)
+capacity_to_mask (size_t capacity)
{
/* Calculate the minimum mask necesary to support the given
capacity. */
hmap_init (&map);
or, alternatively:
struct hmap map = HMAP_INITIALIZER (map);
-
+
Each node in the hash table, presumably a structure type, must
include a struct hmap_node member. Here's an example:
struct foo
/* Returns the hash value associated with NODE. */
static inline size_t
-hmap_node_hash (const struct hmap_node *node)
+hmap_node_hash (const struct hmap_node *node)
{
return node->hash;
}
interface to this particular function that is often more
convenient. */
static inline struct hmap_node *
-hmap_next_with_hash (const struct hmap_node *node)
+hmap_next_with_hash (const struct hmap_node *node)
{
return hmap_find_hash__ (node->next, node->hash);
}
then the client must check for duplicates itself before
inserting the new node. */
static inline void
-hmap_insert_fast (struct hmap *map, struct hmap_node *node, size_t hash)
+hmap_insert_fast (struct hmap *map, struct hmap_node *node, size_t hash)
{
struct hmap_node **bucket = &map->buckets[hash & map->mask];
node->hash = hash;
The HMAP_FIRST macro is an interface to this particular
function that is often more convenient. */
static inline struct hmap_node *
-hmap_first (const struct hmap *map)
+hmap_first (const struct hmap *map)
{
return hmap_first_nonempty_bucket__ (map, 0);
}
The HMAP_NEXT macro is an interface to this particular
function that is often more convenient. */
static inline struct hmap_node *
-hmap_next (const struct hmap *map, const struct hmap_node *node)
+hmap_next (const struct hmap *map, const struct hmap_node *node)
{
return (node->next != NULL
? node->next
/* Returns the number of data items currently in MAP. */
static inline size_t
-hmap_count (const struct hmap *map)
+hmap_count (const struct hmap *map)
{
return map->count;
}
capacity. However, inserting many more elements than the
map's capacity will degrade search performance. */
static inline size_t
-hmap_capacity (const struct hmap *map)
+hmap_capacity (const struct hmap *map)
{
return hmap_mask_to_capacity__ (map->mask);
}
/* Returns the first node at or after NODE in NODE's chain that
has hash value HASH. */
static inline struct hmap_node *
-hmap_find_hash__ (struct hmap_node *node, size_t hash)
+hmap_find_hash__ (struct hmap_node *node, size_t hash)
{
- for (; node != NULL; node = node->next)
+ for (; node != NULL; node = node->next)
if (node->hash == hash)
break;
return node;
MASK must be a power of 2 minus 1 (including 0), that is, its
value in binary must be all 1-bits. */
static inline size_t
-hmap_mask_to_capacity__ (size_t mask)
+hmap_mask_to_capacity__ (size_t mask)
{
return (mask + 1) * 2;
}
argument more than once). */
static inline void *
hmap_nullable_data__ (struct hmap_node *node, size_t member_offset)
-{
+{
return node != NULL ? (char *) node - member_offset : NULL;
}
items should be freed, then it should be done by iterating
through MAP's contents before destroying MAP. */
void
-hmapx_destroy (struct hmapx *map)
+hmapx_destroy (struct hmapx *map)
{
- if (map != NULL)
+ if (map != NULL)
{
if (!(hmapx_is_empty (map)))
{
for (node = hmapx_first (map); node != NULL; node = next)
{
next = hmapx_next (map, node);
- free (node);
+ free (node);
}
}
hmap_destroy (&map->hmap);
/* Allocates and returns a new hmapx_node with DATA as its data
item. */
static struct hmapx_node *
-make_hmapx_node (void *data)
+make_hmapx_node (void *data)
{
struct hmapx_node *node = xmalloc (sizeof *node);
node->data = data;
then the client must check for duplicates itself before
inserting the new item. */
struct hmapx_node *
-hmapx_insert (struct hmapx *map, void *data, size_t hash)
+hmapx_insert (struct hmapx *map, void *data, size_t hash)
{
struct hmapx_node *node = make_hmapx_node (data);
hmap_insert (&map->hmap, &node->hmap_node, hash);
then the client must check for duplicates itself before
inserting the new node. */
struct hmapx_node *
-hmapx_insert_fast (struct hmapx *map, void *data, size_t hash)
+hmapx_insert_fast (struct hmapx *map, void *data, size_t hash)
{
struct hmapx_node *node = make_hmapx_node (data);
hmap_insert_fast (&map->hmap, &node->hmap_node, hash);
These macros automatically use hmapx_node_data() to obtain the
data elements that encapsulate hmap nodes, which often saves
typing and can make code easier to read. Refer to the large
- comment near the top of this file for an example.
+ comment near the top of this file for an example.
These macros evaluate their arguments many times. */
#define HMAPX_FOR_EACH(DATA, NODE, HMAPX) \
/* Initializes MAP as a new hash map that is initially empty. */
static inline void
-hmapx_init (struct hmapx *map)
+hmapx_init (struct hmapx *map)
{
hmap_init (&map->hmap);
}
store its current number of elements, allocating a new set of
buckets and rehashing if that would save space. */
static inline void
-hmapx_shrink (struct hmapx *map)
+hmapx_shrink (struct hmapx *map)
{
hmap_shrink (&map->hmap);
}
macros provide convenient ways to iterate over all the nodes
with a given hash. */
static inline struct hmapx_node *
-hmapx_first_with_hash (struct hmapx *map, size_t hash)
+hmapx_first_with_hash (struct hmapx *map, size_t hash)
{
return HMAP_FIRST_WITH_HASH (struct hmapx_node, hmap_node, &map->hmap, hash);
}
macros provide convenient ways to iterate over all the nodes
with a given hash. */
static inline struct hmapx_node *
-hmapx_next_with_hash (struct hmapx_node *node)
+hmapx_next_with_hash (struct hmapx_node *node)
{
return HMAP_NEXT_WITH_HASH (node, struct hmapx_node, hmap_node);
}
hmapx_delete() does not change NODE's hash value reported by
hmapx_node_hash(). */
static inline void
-hmapx_delete (struct hmapx *map, struct hmapx_node *node)
+hmapx_delete (struct hmapx *map, struct hmapx_node *node)
{
hmap_delete (&map->hmap, &node->hmap_node);
free (node);
convenient ways to iterate over all the nodes in a hash
map. */
static inline struct hmapx_node *
-hmapx_first (const struct hmapx *map)
+hmapx_first (const struct hmapx *map)
{
return HMAP_FIRST (struct hmapx_node, hmap_node, &map->hmap);
}
convenient ways to iterate over all the nodes in a hash
map. */
static inline struct hmapx_node *
-hmapx_next (const struct hmapx *map, const struct hmapx_node *node)
+hmapx_next (const struct hmapx *map, const struct hmapx_node *node)
{
return HMAP_NEXT (node, struct hmapx_node, hmap_node, &map->hmap);
}
/* Returns the number of data items currently in MAP. */
static inline size_t
-hmapx_count (const struct hmapx *map)
+hmapx_count (const struct hmapx *map)
{
return hmap_count (&map->hmap);
}
capacity. However, inserting many more elements than the
map's capacity will degrade search performance. */
static inline size_t
-hmapx_capacity (const struct hmapx *map)
+hmapx_capacity (const struct hmapx *map)
{
return hmap_capacity (&map->hmap);
}
value. */
static inline void
hmapx_change (struct hmapx *map,
- struct hmapx_node *node, void *data, size_t new_hash)
+ struct hmapx_node *node, void *data, size_t new_hash)
{
hmapx_move (node, data);
hmapx_changed (map, node, new_hash);
case), then the client must check for duplicates before
changing NODE's value. */
static inline void
-hmapx_changed (struct hmapx *map, struct hmapx_node *node, size_t new_hash)
+hmapx_changed (struct hmapx *map, struct hmapx_node *node, size_t new_hash)
{
hmap_changed (&map->hmap, &node->hmap_node, new_hash);
}
free (soutbuf);
iconv_close (bconv);
}
-
+
hmapx_insert (&map, converter, hash);
return converter;
for (i = 0 ; i < null_bytes ; ++i)
*out++ = '\0';
-
+
return out - 1 - out_;
}
{
int r;
struct inflator *inf = xzalloc (sizeof *inf);
-
- uint16_t flg = 0 ;
+
+ uint16_t flg = 0 ;
uint16_t cmf = 0x8; /* Always 8 for inflate */
const uint16_t cinfo = 7; /* log_2(Window size) - 8 */
}
bytes_to_read = zm->comp_size - inf->ucomp_bytes_read;
-
+
if (bytes_to_read == 0)
return 0;
{
return n - inf->zss.avail_out;
}
-
+
ds_put_format (zm->errs, _("Error inflating: %s"), zError (r));
return -1;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2010,
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010,
2011, 2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
void
str_copy_rpad (char *dst, size_t dst_size, const char *src)
{
- if (dst_size > 0)
+ if (dst_size > 0)
{
size_t src_len = strlen (src);
if (src_len < dst_size - 1)
}
-/* Formats FORMAT as a printf string, using fmt_func (a snprintf like function)
+/* Formats FORMAT as a printf string, using fmt_func (a snprintf like function)
and appends the result to ST. */
static void
ds_put_vformat_int (struct string *st, const char *format, va_list args_,
ds_put_vformat_int (st, format, args_, vsnprintf);
}
-/* Formats FORMAT as a printf string, as if in the C locale,
+/* Formats FORMAT as a printf string, as if in the C locale,
and appends the result to ST. */
void
ds_put_c_vformat (struct string *st, const char *format, va_list args_)
struct hmapx_node *node = hmapx_first_with_hash (&map, hash_pointer (file, 0));
char *fn = node->data;
fclose_temp (file);
- cleanup_temp_file (temp_dir, fn);
+ cleanup_temp_file (temp_dir, fn);
hmapx_delete (&map, node);
free (fn);
}
{
const struct abt_node *p = &node->abt_node;
unsigned long level = get_subtree_size (p->down[0]);
- while (p->up != NULL)
+ while (p->up != NULL)
{
if (p == p->up->down[1])
- level += (get_subtree_size (p->up->down[0])
+ level += (get_subtree_size (p->up->down[0])
+ abt_to_tower_node (p->up)->size);
p = p->up;
}
{
const struct abt_node *p = &node->abt_node;
unsigned long index = get_subtree_count (p->down[0]);
- while (p->up != NULL)
+ while (p->up != NULL)
{
if (p == p->up->down[1])
index += get_subtree_count (p->up->down[0]) + 1;
less than the number of nodes in T (as returned by
tower_count). */
struct tower_node *
-tower_get (const struct tower *t_, unsigned long int index)
+tower_get (const struct tower *t_, unsigned long int index)
{
struct tower *t = CONST_CAST (struct tower *, t_);
struct abt_node *p;
}
-static struct decompressor decompressors[n_COMPRESSION] =
+static struct decompressor decompressors[n_COMPRESSION] =
{
{stored_init, stored_read, stored_finish},
{inflate_init, inflate_read, inflate_finish}
zip_reader_destroy (struct zip_reader *zr)
{
int i;
- if (zr == NULL)
+ if (zr == NULL)
return;
fclose (zr->fr);
/* Read N bytes from F, storing the result in X */
static bool
-get_bytes (FILE *f, void *x, size_t n)
+get_bytes (FILE *f, void *x, size_t n)
{
return (n == fread (x, 1, n, f));
}
if ((expected != magic))
{
ds_put_format (err,
- _("Corrupt file at 0x%llx: Expected %"PRIx32"; got %"PRIx32),
+ _("Corrupt file at 0x%llx: Expected %"PRIx32"; got %"PRIx32),
(long long int) ftello (f) - sizeof (uint32_t), expected, magic);
return false;
/*
Read a local file header from ZR and add it to ZR's internal array.
Returns a pointer to the member read. This pointer belongs to ZR.
- If the caller wishes to control it, she should ref it with
+ If the caller wishes to control it, she should ref it with
zip_member_ref.
*/
static struct zip_member *
uint16_t v, nlen, extralen;
uint16_t gp, time, date;
-
+
uint16_t clen, diskstart, iattr;
uint32_t eattr;
uint16_t comp_type;
if (! get_bytes (zr->fr, zm->name, nlen)) return NULL;
skip_bytes (zr->fr, extralen);
-
+
zr->members[zr->nm++] = zm;
zm->fp = fopen (zr->filename, "rb");
free (zr);
return NULL;
}
-
+
if (! get_u16 (zr->fr, &disknum)) return NULL;
if (! get_u16 (zr->fr, &disknum)) return NULL;
uint16_t v, nlen, extra_len;
uint16_t gp, comp_type, time, date;
uint32_t ucomp_size, comp_size;
-
+
uint32_t crc;
bool new_member = false;
char *name = NULL;
else
zm = NULL;
}
-
+
if ( zm == NULL)
return NULL;
free (name);
zm->bytes_unread = zm->ucomp_size;
-
+
if ( !new_member)
decompressors[zm->compression].finish (zm);
const uint32_t magic = MAGIC_EOCD;
bool found = false;
- /* The magic cannot be more than 22 bytes from the end of the file,
+ /* The magic cannot be more than 22 bytes from the end of the file,
because that is the minimum length of the EndOfCentralDirectory
record.
*/
}
start = ftello (fp);
stop = start + sizeof (magic);
- do
+ do
{
found = probe_magic (fp, magic, start, stop, off);
/* FIXME: For extra confidence lookup the directory start record here*/
state++;
else
state = 0;
-
+
if ( state == 4)
{
*off = ftello (fp) - 4;
if (y > bw->whiskers[1])
bw->whiskers[1] = y;
-
+
return;
}
TH are the tukey hinges of the dataset.
- id_idx is the index into the casereader which will be used to label
+ id_idx is the index into the casereader which will be used to label
outliers.
id_var is the variable from which that label came, or NULL
*/
if (value_equal (&vn->val, val, width))
break;
}
-
+
return vn;
}
{
if (vn->var == var)
break;
-
+
fprintf (stderr, "%s:%d Warning: Hash table collision\n", __FILE__, __LINE__);
}
-
+
return vn;
}
int n_cats;
/* An array of integers df_n * df_{n-1} * df_{n-2} ...
- These are the products of the degrees of freedom for the current
+ These are the products of the degrees of freedom for the current
variable and all preceeding variables */
- int *df_prod;
+ int *df_prod;
double *enc_sum;
return iv;
}
-bool
+bool
categoricals_sane (const struct categoricals *cat)
{
return cat->sane;
{
size_t i;
struct categoricals *cat = xmalloc (sizeof *cat);
-
+
cat->n_iap = n_inter;
cat->wv = wv;
cat->n_cats_total = 0;
if (valn == NULL)
{
valn = pool_malloc (cat->pool, sizeof *valn);
- valn->index = -1;
+ valn->index = -1;
vn->n_vals++;
value_init (&valn->val, width);
value_copy (&valn->val, val, width);
hmap_insert (&vn->valmap, &valn->node, hash);
}
}
-
+
for (i = 0 ; i < cat->n_iap; ++i)
{
const struct interaction *iact = cat->iap[i].iact;
hmap_insert (&cat->iap[i].ivmap, &node->node, hash);
- if (cat->payload)
+ if (cat->payload)
{
node->user_data = cat->payload->create (cat->aux1, cat->aux2);
}
cat->iap[i].df_prod = iact->n_vars ? xcalloc (iact->n_vars, sizeof (int)) : NULL;
cat->iap[i].n_cats = 1;
-
+
for (v = 0 ; v < iact->n_vars; ++v)
{
int x;
x = 0;
HMAP_FOR_EACH (valnd, struct value_node, node, &vn->valmap)
{
- /* Note: This loop is probably superfluous, it could be done in the
+ /* Note: This loop is probably superfluous, it could be done in the
update stage (at the expense of a realloc) */
array[x++] = valnd;
}
- sort (array, vn->n_vals, sizeof (*array),
+ sort (array, vn->n_vals, sizeof (*array),
compare_value_node_3way, vn);
for (x = 0; x < vn->n_vals; ++x)
bin = -1.0;
else if ( valn->index != index )
bin = 0;
-
+
result *= bin;
}
}
/* Returns unity if the value in case C at SUBSCRIPT is equal to the category
- for that subscript.
+ for that subscript.
Else if it is the last category, return -1.
Otherwise return 0.
*/
}
-/* Return a case containing the set of values corresponding to
+/* Return a case containing the set of values corresponding to
the Nth Category of the IACTth interaction */
const struct ccase *
categoricals_get_case_by_category_real (const struct categoricals *cat, int iact, int n)
/*
The *_by_subscript functions use the short map.
- Their intended use is by covariance matrix routines, where normally 1 less than
+ Their intended use is by covariance matrix routines, where normally 1 less than
the total number of distinct values of each categorical variable should
be considered.
*/
const struct ccase *c);
/* Returns unity if the value in case C at SUBSCRIPT is equal to the category
- for that subscript.
+ for that subscript.
Else if it is the last category, return -1.
Otherwise return 0.
*/
static const double standard_tick[] = {1, 2, 5, 10};
-/*
+/*
Find a set {LOWER, INTERVAL, N_TICKS} such that:
LOWER <= LOWDBL,
LOWER + INTERVAL > LOWDBL,
-
+
LOWER + N_TICKS * INTERVAL < HIGHDBL
LOWER + (N_TICKS + 1) * INTERVAL >= HIGHDBL
INTERVAL = X * 10^N
- where: N is integer
+ where: N is integer
and X is an element of {1, 2, 5}
In other words:
}
}
-/*
+/*
Generate a format string which can be passed to printf like functions,
- which will produce a string in scientific notation representing a real
- number. N_DECIMALS is the number of decimal places EXPONENT is the
+ which will produce a string in scientific notation representing a real
+ number. N_DECIMALS is the number of decimal places EXPONENT is the
value of the exponent.
*/
static inline char *
{
/* TRANSLATORS: This is a format string which, when presented to
printf like functions, will create a pango markup string to
- display real number in scientific notation.
-
- In its untranslated form, it will display similar to "1.23 x 10^4". You
+ display real number in scientific notation.
+
+ In its untranslated form, it will display similar to "1.23 x 10^4". You
can leave it untranslated if this is how scientific notation is usually
presented in your language.
-
+
Some locales (such as German) prefer the centered dot rather than the
multiplication sign between the mantissa an exponent. In which
case, you can change "#215;" to "#8901;" or other unicode code
- point as appropriate.
+ point as appropriate.
The . in this string does not and should not be changed, since
- that is taken care of by the stdc library.
+ that is taken care of by the stdc library.
- For information on Pango markup, see
+ For information on Pango markup, see
http://developer.gnome.org/pango/stable/PangoMarkupFormat.html
For tables of unicode code points, see http://unicode.org/charts
t = sqrt (t);
t *= rho;
-
+
if (t > 0)
return gsl_cdf_tdist_Q (t, w - 2);
else
{
size_t i, j;
gsl_matrix *corr = gsl_matrix_calloc (cv->size1, cv->size2);
-
+
for (i = 0 ; i < cv->size1; ++i)
{
for (j = 0 ; j < cv->size2; ++j)
{
double rho = gsl_matrix_get (cv, i, j);
-
+
rho /= sqrt (gsl_matrix_get (v, i, j))
- *
+ *
sqrt (gsl_matrix_get (v, j, i));
-
+
gsl_matrix_set (corr, i, j, rho);
}
}
-
+
return corr;
}
gsl_matrix_set (out, i, j, x);
}
}
-
+
gsl_matrix_free (in);
return out;
double *cm;
int n_cm;
- /* 1 for single pass algorithm;
+ /* 1 for single pass algorithm;
2 for double pass algorithm
*/
short passes;
/*
0 : No pass has been made
1 : First pass has been started
- 2 : Second pass has been
-
+ 2 : Second pass has been
+
IE: How many passes have been (partially) made. */
short state;
cov->passes = 1;
cov->state = 0;
cov->pass_one_first_case_seen = cov->pass_two_first_case_seen = false;
-
+
cov->vars = vars;
cov->wv = weight;
cov->dim = n_vars;
cov->moments = xmalloc (sizeof *cov->moments * n_MOMENTS);
-
+
for (i = 0; i < n_MOMENTS; ++i)
cov->moments[i] = gsl_matrix_calloc (n_vars, n_vars);
cov->passes = 2;
cov->state = 0;
cov->pass_one_first_case_seen = cov->pass_two_first_case_seen = false;
-
+
cov->vars = vars;
cov->wv = wv;
cov->dim = n_vars;
cov->moments = xmalloc (sizeof *cov->moments * n_MOMENTS);
-
+
for (i = 0; i < n_MOMENTS; ++i)
cov->moments[i] = gsl_matrix_calloc (n_vars, n_vars);
return cov;
}
-/* Return an integer, which can be used to index
+/* Return an integer, which can be used to index
into COV->cm, to obtain the I, J th element
of the covariance matrix. If COV->cm does not
contain that element, then a negative value
int as;
const int n2j = cov->dim - 2 - j;
const int nj = cov->dim - 2 ;
-
+
assert (i >= 0);
assert (j < cov->dim);
if (j >= cov->dim - 1)
return -1;
- if ( i <= j)
+ if ( i <= j)
return -1 ;
as = nj * (nj + 1) ;
- as -= n2j * (n2j + 1) ;
+ as -= n2j * (n2j + 1) ;
as /= 2;
return i - 1 + as;
/*
- Returns true iff the variable corresponding to the Ith element of the covariance matrix
+ Returns true iff the variable corresponding to the Ith element of the covariance matrix
has a missing value for case C
*/
static bool
is_missing (const struct covariance *cov, int i, const struct ccase *c)
{
const struct variable *var = i < cov->n_vars ?
- cov->vars[i] :
+ cov->vars[i] :
categoricals_get_interaction_by_subscript (cov->categoricals, i - cov->n_vars)->vars[0];
const union value *val = case_data (c, var);
categoricals_done (cov->categoricals);
cov->dim = cov->n_vars;
-
+
if (cov->categoricals)
cov->dim += categoricals_df_total (cov->categoricals);
*x += s;
}
- ss =
+ ss =
(v1 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j))
- *
+ *
(v2 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j))
* weight
;
}
-/*
+/*
Allocate and return a gsl_matrix containing the covariances of the
data.
*/
for (i = j + 1 ; i < cov->dim; ++i)
{
double *x = &cov->cm [cm_idx (cov, i, j)];
-
+
*x /= gsl_matrix_get (cov->moments[0], i, j);
*x -=
- gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)
+ gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)
*
- gsl_matrix_get (cov->moments[MOMENT_MEAN], j, i);
+ gsl_matrix_get (cov->moments[MOMENT_MEAN], j, i);
}
}
switch (cov->passes)
{
case 1:
- return covariance_calculate_single_pass (cov);
+ return covariance_calculate_single_pass (cov);
break;
case 2:
- return covariance_calculate_double_pass (cov);
+ return covariance_calculate_double_pass (cov);
break;
default:
NOT_REACHED ();
for (i = j + 1 ; i < cov->dim; ++i)
{
double *x = &cov->cm [cm_idx (cov, i, j)];
-
+
*x -=
- gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)
+ gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)
*
- gsl_matrix_get (cov->moments[MOMENT_MEAN], j, i)
+ gsl_matrix_get (cov->moments[MOMENT_MEAN], j, i)
/ gsl_matrix_get (cov->moments[MOMENT_NONE], i, j);
}
}
switch (cov->passes)
{
case 1:
- cov->unnormalised = covariance_calculate_single_pass_unnormalized (cov);
+ cov->unnormalised = covariance_calculate_single_pass_unnormalized (cov);
break;
case 2:
- cov->unnormalised = covariance_calculate_double_pass_unnormalized (cov);
+ cov->unnormalised = covariance_calculate_double_pass_unnormalized (cov);
break;
default:
NOT_REACHED ();
tab_title (t, "Covariance Encoding");
- tab_box (t,
+ tab_box (t,
TAL_2, TAL_2, 0, 0,
0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
struct ccase ;
struct categoricals;
-struct covariance * covariance_1pass_create (size_t n_vars, const struct variable *const *vars,
+struct covariance * covariance_1pass_create (size_t n_vars, const struct variable *const *vars,
const struct variable *wv, enum mv_class excl);
struct covariance *
gsl_histogram *gsl_hist;
};
-/*
+/*
Prepare a histogram for data which lies in the range [min, max)
bin_width is a nominal figure only. It is a hint about what might be
an good approximate bin width, but the implementation will adjust it
Interaction is commutative. That means, that from a mathematical point of
view, the order of the variables is irrelevant. However, for display
- purposes, and for matching with an interaction's value the order is
+ purposes, and for matching with an interaction's value the order is
pertinent.
-
- Therefore, when using these functions, make sure the orders of variables
+
+ Therefore, when using these functions, make sure the orders of variables
and values match when appropriate.
*/
}
/*
- Do the variables in X->VARS constitute a
+ Do the variables in X->VARS constitute a
subset (proper or otherwise) of the variables in Y->VARS?
*/
bool
}
}
- /* If ALL the members of X were also found in Y, then this must be a subset */
+ /* If ALL the members of X were also found in Y, then this must be a subset */
if (n >= x->n_vars)
return true;
/* Data accumulation. First pass */
-void
+void
levene_pass_one (struct levene *nl, double value, double weight, const union value *gv)
{
struct lev *lev = find_group (nl, gv);
- if ( nl->pass == 0 )
+ if ( nl->pass == 0 )
{
nl->pass = 1;
}
}
/* Data accumulation. Second pass */
-void
+void
levene_pass_two (struct levene *nl, double value, double weight, const union value *gv)
{
struct lev *lev = NULL;
}
/* Data accumulation. Third pass */
-void
+void
levene_pass_three (struct levene *nl, double value, double weight, const union value *gv)
{
double z;
}
numerator *= nn - hmap_count (&nl->hmap);
-
+
return numerator / nl->denominator;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 2005, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2010, 2011 Free Software Foundation, Inc.
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
size_t i;
size_t j;
int rc;
-
+
assert (sw != NULL);
assert (l != NULL);
Get the covariance matrix of the parameter estimates.
Only the upper triangle is necessary.
*/
-
+
/*
The loops below do not compute the entries related
to the estimated intercept.
xm = gsl_matrix_calloc (1, l->n_indeps);
for (i = 0; i < xm->size2; i++)
{
- gsl_matrix_set (xm, 0, i,
+ gsl_matrix_set (xm, 0, i,
linreg_get_indep_variable_mean (l, i));
}
rc = gsl_blas_dsymm (CblasRight, CblasUpper, l->mse,
* linreg_get_indep_variable_mean (l, i - 1);
}
gsl_matrix_set (l->cov, 0, 0, tmp);
-
+
l->intercept = m;
}
else
__FILE__, __LINE__, gsl_strerror (rc));
exit (rc);
}
-}
+}
/*
Predict the value of the dependent variable with the new set of
/* Covariances related to the intercept. */
intercept_variance += linreg_mse (l) / linreg_n_obs (l);
- gsl_matrix_set (l->cov, 0, 0, intercept_variance);
+ gsl_matrix_set (l->cov, 0, 0, intercept_variance);
for (i = 0; i < q->size1; i++)
{
for (j = 0; j < q->size2; j++)
{
- intcpt_coef -= gsl_matrix_get (q, i, j)
+ intcpt_coef -= gsl_matrix_get (q, i, j)
* linreg_get_indep_variable_mean (l, j);
}
gsl_matrix_set (l->cov, 0, i + 1, intcpt_coef);
gsl_matrix_set (l->cov, i + 1, 0, intcpt_coef);
intcpt_coef = 0.0;
}
-
+
gsl_matrix_free (q);
gsl_matrix_free (r);
gsl_vector_free (xty);
params = gsl_matrix_calloc (cov->size1, cov->size2);
gsl_matrix_memcpy (params, cov);
reg_sweep (params, l->dependent_column);
- post_sweep_computations (l, params);
+ post_sweep_computations (l, params);
gsl_matrix_free (params);
}
else if (l->method == LINREG_QR)
return c->cov;
}
-double
+double
linreg_coeff (const linreg *c, size_t i)
{
return (c->coeff[i]);
return (c->indep_vars[i]);
}
-size_t
+size_t
linreg_n_coeffs (const linreg *c)
{
return c->n_coeffs;
return c->sst;
}
-double
+double
linreg_dfmodel ( const linreg *c)
{
return c->dfm;
c->depvar_mean = x;
}
-double
+double
linreg_get_depvar_mean (const linreg *c)
{
return c->depvar_mean;
-linreg *linreg_alloc (const struct variable *, const struct variable **,
+linreg *linreg_alloc (const struct variable *, const struct variable **,
double, size_t);
void linreg_unref (linreg *);
start_side = right;
end_side = left;
}
-
+
return ((end_side * RENDER_N_LINES + bottom) * RENDER_N_LINES + start_side) * RENDER_N_LINES + top;
}
file_name = xr_draw_png_chart (chart_item, a->chart_file_name,
a->chart_cnt++,
- &a->fg,
+ &a->fg,
&a->bg);
if (file_name != NULL)
{
}
#endif
-/*
- These colours come from:
+/*
+ These colours come from:
http://tango.freedesktop.org/static/cvs/tango-art-tools/palettes/Tango-Palette.gpl */
const struct xrchart_colour data_colour[XRCHART_N_COLOURS] =
{
if (orientation == SCALE_ABSCISSA)
{
- if ( rotated)
+ if ( rotated)
xrchart_label_rotate (cr, 'l', 'c', geom->font_size, s, -G_PI_4);
else
xrchart_label (cr, 'c', 't', geom->font_size, s);
tick_format_string = chart_get_ticks_format (lower, interval, ticks, &tickscale);
upper = lower + interval * (ticks+1);
-
+
geom->axis[orient].max = upper;
geom->axis[orient].min = lower;
-
+
geom->axis[orient].scale = (fabs (geom->axis[orient].data_max - geom->axis[orient].data_min)
/ fabs (geom->axis[orient].max - geom->axis[orient].min));
tickoversize = width > 0.9 *
((double)(geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min))/(ticks+1);
}
-
+
double pos = lower;
for (s = 0 ; s <= ticks; ++s)
return r;
}
-void
+void
xr_rendering_apply_options (struct xr_rendering *xr, struct string_map *o)
{
if (is_table_item (xr->item))
size_t hash = value_hash (prev, bc->widths[0], 0);
HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bc->primaries)
{
- if (value_equal (&foo->val, prev, bc->widths[0]))
+ if (value_equal (&foo->val, prev, bc->widths[0]))
break;
}
-
+
draw_tick (cr, geom, SCALE_ABSCISSA, false,
x_pos - (width * n_last_cat) / 2.0,
"%s", ds_cstr (&foo->label));
{
const int blob_size = 13;
const int height = blob_size * (hmap_count (&bc->secondaries) * 2);
-
+
cairo_rectangle (cr,
geom->axis[SCALE_ABSCISSA].data_max + 10,
geom->axis[SCALE_ORDINATE].data_max - height,
{
const struct category *foo = bc->ss[i];
- cairo_move_to (cr,
+ cairo_move_to (cr,
geom->axis[SCALE_ABSCISSA].data_max + (1.5 * blob_size) + 20,
geom->axis[SCALE_ORDINATE].data_max - ypos);
-
+
xrchart_label (cr, 'l', 'b', geom->font_size, ds_cstr (&foo->label));
cairo_rectangle (cr,
cairo_fill_preserve (cr);
cairo_restore (cr);
-
+
cairo_stroke (cr);
ypos += blob_size * 2;
/* Creates and returns a chart that will render a barchart with
- the given TITLE and the N_CATS described in CATS.
+ the given TITLE and the N_CATS described in CATS.
- VAR is an array containing the categorical variables, and N_VAR
+ VAR is an array containing the categorical variables, and N_VAR
the number of them. N_VAR must be exactly 1 or 2.
CATS are the counts of the values of those variables. N_CATS is the
*/
struct chart_item *
barchart_create (const struct variable **var, int n_vars,
- const char *ylabel, bool percent,
+ const char *ylabel, bool percent,
struct freq *const *cats, int n_cats)
{
struct barchart *bar;
int idx = 0;
hmap_init (&bar->primaries);
- /*
+ /*
Iterate the categories and create a hash table of the primary categories.
We need to do this to find out how many there are and to cache the labels.
*/
}
}
- if (!flag)
+ if (!flag)
{
struct category *s = xzalloc (sizeof *s);
s->idx = idx++;
break;
}
}
-
- if (!flag)
+
+ if (!flag)
{
struct category *s = xzalloc (sizeof *s);
s->idx = idx++;
sort (bar->ss, n_category, sizeof *bar->ss,
compare_category_3way, bar);
}
-
+
/* Deep copy. Not necessary for cmd line, but essential for the GUI,
since an expose callback will access these structs which may not
struct hmap level2table;
hmap_init (&level2table);
int x = 0;
-
+
for (i = 0; i < n_cats; i++)
{
struct freq *c = cats[i];
{
foo->count += c->count;
bar->total_count += c->count;
-
+
if (foo->count > bar->largest)
bar->largest = foo->count;
-
+
flag = true;
break;
}
}
-
- if (!flag)
+
+ if (!flag)
{
- struct freq *aggregated_freq = freq_clone (c, n_vars, bar->widths);
+ struct freq *aggregated_freq = freq_clone (c, n_vars, bar->widths);
hmap_insert (&level2table, &aggregated_freq->node, hash);
-
+
if (c->count > bar->largest)
bar->largest = aggregated_freq->count;
-
+
bar->total_count += c->count;
bar->cats[x++] = aggregated_freq;
}
{
freq_destroy (bar->cats[i], bar->n_vars, bar->widths);
}
-
+
free (bar->cats);
free (bar->ylabel);
free (bar->ss);
struct hmap secondaries;
- /* A array of pointers to the members of the above hmap,
+ /* A array of pointers to the members of the above hmap,
sorted by VAL */
struct category **ss;
};
int byvar_width = 0;
int i = 0;
const struct xrchart_colour *colour;
-
+
if (spc->byvar)
byvar_width = var_get_width (spc->byvar);
colour->red / 255.0,
colour->green / 255.0,
colour->blue / 255.0);
-
+
xrchart_datum (cr, geom, 0,
case_data_idx (c, SP_IDX_X)->f,
case_data_idx (c, SP_IDX_Y)->f);
xrchart_write_title (cr, geom, _("Spread vs. Level Plot of %s"), name);
xrchart_write_xlabel (cr, geom, _("Level"));
xrchart_write_ylabel (cr, geom, _("Spread"));
-
+
xrchart_write_xscale (cr, geom, sl->x_lower, sl->x_upper);
xrchart_write_yscale (cr, geom, sl->y_lower, sl->y_upper);
sl->n_data = 0;
sl->data = NULL;
-
+
return &sl->chart_item;
}
-void
+void
spreadlevel_plot_add (struct chart_item *ci, double spread, double level)
{
struct spreadlevel_plot_chart *sl = to_spreadlevel_plot_chart (ci);
#include "output/chart-item.h"
-struct datum
+struct datum
{
double x;
double y;
chart_item_submit (&instance->chart_item);
}
\f
-#endif
+#endif
device_string, "terminal", "listing");
device_type = default_device_type (file_name);
}
-
+
struct file_handle *fh = fh_create_file (NULL, file_name, NULL, fh_default_properties ());
driver = f->create (fh, device_type, options);
#ifdef HAVE_CAIRO
struct xr_color fg;
struct xr_color bg;
-#endif
+#endif
struct file_handle *handle;
char *chart_file_name;
{
/* Cell borders. */
n_borders = 0;
-
+
top = table_get_rule (t, TABLE_VERT, x, y);
if (top > TAL_GAP)
put_border (html->file, n_borders++, top, "top");
SETTINGS_DEVICE_UNFILTERED);
journal.file = NULL;
journal.command_name = NULL;
-
+
/* Register journal driver. */
output_driver_register (&journal.driver);
_xml ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0") );
xmlTextWriterWriteAttribute (w, _xml ("office:version"), _xml ("1.1"));
-
+
xmlTextWriterStartElement (w, _xml ("office:styles"));
zip_writer_close (odt->zip);
}
-
+
free (odt->file_name);
free (odt->command_name);
free (odt);
/* Start table */
xmlTextWriterStartElement (odt->content_wtr, _xml("table:table"));
- xmlTextWriterWriteFormatAttribute (odt->content_wtr, _xml("table:name"),
+ xmlTextWriterWriteFormatAttribute (odt->content_wtr, _xml("table:name"),
"TABLE-%d", odt->table_num++);
/* Deal with row headers */
if ( table_ht (tab) > 0)
xmlTextWriterStartElement (odt->content_wtr, _xml("table:table-header-rows"));
-
+
/* Write all the rows */
for (r = 0 ; r < table_nr (tab); ++r)
table_cell_free (&cell);
}
-
+
xmlTextWriterEndElement (odt->content_wtr); /* row */
if ( table_ht (tab) > 0 && r == table_ht (tab) - 1)
hmap_destroy (&page->overflows);
table_unref (page->table);
-
+
for (i = 0; i < TABLE_N_AXES; ++i)
{
free (page->join_crossing[i]);
bool
render_direction_rtl (void)
{
- /* TRANSLATORS: Do not translate this string. If the script of your language
- reads from right to left (eg Persian, Arabic, Hebrew etc), then replace
- this string with "output-direction-rtl". Otherwise either leave it
+ /* TRANSLATORS: Do not translate this string. If the script of your language
+ reads from right to left (eg Persian, Arabic, Hebrew etc), then replace
+ this string with "output-direction-rtl". Otherwise either leave it
untranslated or copy it verbatim. */
const char *dir = _("output-direction-ltr");
if ( 0 == strcmp ("output-direction-rtl", dir))
}
-GtkBuilder *
+GtkBuilder *
builder_new_x (const gchar *obj_name)
{
GtkBuilder *b;
g_critical ("Object `%s' could not be found\n", name);
else if ( ! g_type_is_a (G_OBJECT_TYPE (o), type))
{
- g_critical ("Object `%s' was expected to have type %s, but in fact has type %s",
+ g_critical ("Object `%s' was expected to have type %s, but in fact has type %s",
name, g_type_name (type), G_OBJECT_TYPE_NAME (o));
}
get_widget_assert (GtkBuilder *builder, const gchar *name)
{
GtkWidget *w = GTK_WIDGET (get_object_assert (builder, name, GTK_TYPE_WIDGET));
-
+
g_object_set (w, "name", name, NULL);
return w;
#include "helper.h"
-/*
- If m is not a base TreeModel type (ie, is a filter or sorter) then
+/*
+ If m is not a base TreeModel type (ie, is a filter or sorter) then
convert OP to a TreePath for the base and return it.
The return value must be freed by the caller.
*/
while ( ! PSPPIRE_IS_DICT (m))
{
GtkTreePath *oldp = p;
-
+
if (GTK_IS_TREE_MODEL_FILTER (m))
{
p = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (m), oldp);
{
g_error ("Unexpected model type: %s", G_OBJECT_TYPE_NAME (m));
}
-
+
gtk_tree_path_free (oldp);
}
dictionary in GTK widgets.
*/
-#ifndef DICT_DISPLAY
+#ifndef DICT_DISPLAY
#define DICT_DISPLAY 1
#include <gtk/gtk.h>
gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about),
"Free Software Foundation");
- gtk_about_dialog_set_translator_credits
+ gtk_about_dialog_set_translator_credits
(
GTK_ABOUT_DIALOG (about),
/* TRANSLATORS: Do not translate this string. Instead, put the names of the people
GtkWidget *help_ref = gtk_menu_item_new_with_mnemonic (_("_Reference Manual"));
GtkAccelGroup *accel_group = gtk_accel_group_new ();
-
+
gtk_window_add_accel_group (toplevel, accel_group);
gtk_widget_add_accelerator (help_ref,
g_signal_connect (help_about, "activate", G_CALLBACK (about_new), toplevel);
g_signal_connect (help_ref, "activate", G_CALLBACK (reference_manual), NULL);
-
+
g_object_set (menuitem, "submenu", menu, NULL);
gtk_widget_show_all (menuitem);
-
+
return menuitem;
}
-static gboolean
+static gboolean
on_delete (GtkWindow *window, GdkEvent *e, GtkWindow **addr)
{
*addr = NULL;
start_time = g_get_monotonic_time ();
}
-
+
return -1;
}
fd.maximize = get_widget_assert (fd.xml, "checkbutton-maximize");
fd.alert = get_widget_assert (fd.xml, "checkbutton-alert");
fd.raise = get_widget_assert (fd.xml, "checkbutton-raise");
-
+
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
fd.conf = psppire_conf_new ();
&status))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.maximize), status);
}
-
+
{
gboolean status = true;
psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "alert", &status);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.alert), status);
}
-
+
{
gboolean status;
if (psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "raise",
&status))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.raise), status);
}
-
+
const int result = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
if (result == GTK_RESPONSE_OK)
{
sort_order = PSPP_OPTIONS_VAR_ORDER_UNSORTED;
}
-
+
psppire_conf_set_enum (fd.conf,
"VariableLists", "sort-order",
PSPP_TYPE_OPTIONS_VAR_ORDER,
psppire_conf_set_boolean (fd.conf, "OutputWindowAction", "maximize",
gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (fd.maximize)));
-
+
psppire_conf_set_boolean (fd.conf, "OutputWindowAction", "raise",
gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (fd.raise)));
guint enable_search : 1;
guint disable_popdown : 1;
guint search_custom_entry_set : 1;
-
+
guint hover_selection : 1;
guint imcontext_changed : 1;
/**
* pspp_sheet_selection_get_tree_view:
* @selection: A #PsppSheetSelection
- *
+ *
* Returns the tree view associated with @selection.
- *
+ *
* Return value: A #PsppSheetView
**/
PsppSheetView *
* Returns the number of rows that have been selected in @tree.
*
* Return value: The number of rows selected.
- *
+ *
* Since: 2.2
**/
gint
G_CALLBACK (model_changed),
&stop);
changed_id = g_signal_connect_swapped (selection->tree_view, "notify::model",
- G_CALLBACK (model_changed),
+ G_CALLBACK (model_changed),
&stop);
RANGE_TOWER_FOR_EACH (node, start, selection->tree_view->priv->selected)
path,
&node);
- if (node < 0 || pspp_sheet_view_node_is_selected (selection->tree_view, node))
+ if (node < 0 || pspp_sheet_view_node_is_selected (selection->tree_view, node))
return;
if (selection->type == PSPP_SHEET_SELECTION_MULTIPLE ||
path,
&node);
- if (node < 0 || !pspp_sheet_view_node_is_selected (selection->tree_view, node))
+ if (node < 0 || !pspp_sheet_view_node_is_selected (selection->tree_view, node))
return;
_pspp_sheet_selection_internal_select_node (selection,
* pspp_sheet_selection_path_is_selected:
* @selection: A #PsppSheetSelection.
* @path: A #GtkTreePath to check selection on.
- *
+ *
* Returns %TRUE if the row pointed to by @path is currently selected. If @path
* does not point to a valid location, %FALSE is returned
- *
+ *
* Return value: %TRUE if @path is selected.
**/
gboolean
path,
&node);
- if (node < 0 || !pspp_sheet_view_node_is_selected (selection->tree_view, node))
+ if (node < 0 || !pspp_sheet_view_node_is_selected (selection->tree_view, node))
return FALSE;
return TRUE;
* pspp_sheet_selection_iter_is_selected:
* @selection: A #PsppSheetSelection
* @iter: A valid #GtkTreeIter
- *
+ *
* Returns %TRUE if the row at @iter is currently selected.
- *
+ *
* Return value: %TRUE, if @iter is selected
**/
gboolean
if (selection->tree_view->priv->row_count == 0 || selection->tree_view->priv->model == NULL)
return;
-
+
if (pspp_sheet_selection_real_unselect_all (selection))
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
gtk_tree_path_free (anchor_path);
if (dirty)
- g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
+ g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
-void
+void
_pspp_sheet_selection_emit_changed (PsppSheetSelection *selection)
{
- g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
+ g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
/* NOTE: Any {un,}selection ever done _MUST_ be done through this function!
pspp_sheet_view_node_unselect (selection->tree_view, node);
_pspp_sheet_view_queue_draw_node (selection->tree_view, node, NULL);
-
+
return TRUE;
}
object_class->finalize = pspp_sheet_view_column_finalize;
object_class->set_property = pspp_sheet_view_column_set_property;
object_class->get_property = pspp_sheet_view_column_get_property;
-
+
tree_column_signals[CLICKED] =
g_signal_new ("clicked",
G_OBJECT_CLASS_TYPE (object_class),
P_("Whether to display the column"),
TRUE,
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_RESIZABLE,
g_param_spec_boolean ("resizable",
P_("Column is user-resizable"),
FALSE,
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_WIDTH,
g_param_spec_int ("width",
G_MAXINT,
0,
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_FIXED_WIDTH,
g_param_spec_int ("fixed-width",
P_("Title to appear in column header"),
"",
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_EXPAND,
g_param_spec_boolean ("expand",
P_("Column gets share of extra width allocated to the widget"),
FALSE,
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_CLICKABLE,
g_param_spec_boolean ("clickable",
P_("Whether the header can be clicked"),
FALSE,
GTK_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_WIDGET,
pspp_sheet_view_column_set_sort_order (tree_column,
g_value_get_enum (value));
break;
-
+
case PROP_SORT_COLUMN_ID:
pspp_sheet_view_column_set_sort_column_id (tree_column,
g_value_get_int (value));
g_value_set_enum (value,
pspp_sheet_view_column_get_sort_order (tree_column));
break;
-
+
case PROP_SORT_COLUMN_ID:
g_value_set_int (value,
pspp_sheet_view_column_get_sort_column_id (tree_column));
pspp_sheet_view_column_cell_layout_clear_attributes (cell_layout, info->cell);
g_object_unref (info->cell);
g_free (info);
- column->cell_list = g_list_delete_link (column->cell_list,
+ column->cell_list = g_list_delete_link (column->cell_list,
column->cell_list);
}
}
gtk_box_pack_start (GTK_BOX (hbox), tree_column->bin, TRUE, TRUE, 0);
-
+
gtk_container_add (GTK_CONTAINER (tree_column->bin), child);
gtk_container_add (GTK_CONTAINER (tree_column->button), hbox);
pspp_sheet_view_column_update_button (tree_column);
}
-void
+void
pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column)
{
gint sort_column_id = -1;
tree_column->tree_view &&
gtk_widget_get_realized (tree_column->tree_view))
pspp_sheet_view_column_create_button (tree_column);
-
+
if (! tree_column->button)
return;
g_object_set (alignment,
"halign", tree_column->halign,
"valign", GTK_ALIGN_CENTER, NULL);
-
+
if (tree_column->child)
{
if (current_child != tree_column->child)
tree_column->child);
}
}
- else
+ else
{
if (current_child == NULL)
{
if (event->type == GDK_BUTTON_RELEASE ||
event->type == GDK_LEAVE_NOTIFY)
column->maybe_reordered = FALSE;
-
+
if (event->type == GDK_MOTION_NOTIFY &&
column->maybe_reordered &&
(gtk_drag_check_threshold (widget,
g_signal_connect (model, "sort-column-changed",
G_CALLBACK (pspp_sheet_view_model_sort_column_changed),
tree_column);
-
+
if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model),
&real_sort_column_id,
&real_order) &&
pspp_sheet_view_column_set_sort_indicator (tree_column, TRUE);
pspp_sheet_view_column_set_sort_order (tree_column, real_order);
}
- else
+ else
{
pspp_sheet_view_column_set_sort_indicator (tree_column, FALSE);
}
/**
* pspp_sheet_view_column_new:
- *
+ *
* Creates a new #PsppSheetViewColumn.
- *
+ *
* Return value: A newly created #PsppSheetViewColumn.
**/
PsppSheetViewColumn *
* @title: The title to set the header to.
* @cell: The #GtkCellRenderer.
* @Varargs: A %NULL-terminated list of attributes.
- *
+ *
* Creates a new #PsppSheetViewColumn with a number of default values. This is
* equivalent to calling pspp_sheet_view_column_set_title(),
* pspp_sheet_view_column_pack_start(), and
* {
* PsppSheetViewColumn *column;
* GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
- *
+ *
* column = pspp_sheet_view_column_new_with_attributes ("Title",
* renderer,
* "text", TEXT_COLUMN,
* NULL);
* }
* ]|
- *
+ *
* Return value: A newly created #PsppSheetViewColumn.
**/
PsppSheetViewColumn *
/**
* pspp_sheet_view_column_pack_start:
* @tree_column: A #PsppSheetViewColumn.
- * @cell: The #GtkCellRenderer.
+ * @cell: The #GtkCellRenderer.
* @expand: %TRUE if @cell is to be given extra space allocated to @tree_column.
*
* Packs the @cell into the beginning of the column. If @expand is %FALSE, then
/**
* pspp_sheet_view_column_pack_end:
* @tree_column: A #PsppSheetViewColumn.
- * @cell: The #GtkCellRenderer.
+ * @cell: The #GtkCellRenderer.
* @expand: %TRUE if @cell is to be given extra space allocated to @tree_column.
*
* Adds the @cell to end of the column. If @expand is %FALSE, then the @cell
/**
* pspp_sheet_view_column_clear:
* @tree_column: A #PsppSheetViewColumn
- *
+ *
* Unsets all the mappings on all renderers on the @tree_column.
**/
void
* @cell_renderer: the #GtkCellRenderer to set attributes on
* @attribute: An attribute on the renderer
* @column: The column position on the model to get the attribute from.
- *
+ *
* Adds an attribute mapping to the list in @tree_column. The @column is the
* column of the model to get a value from, and the @attribute is the
* parameter on @cell_renderer to be set from the value. So for example
attribute = va_arg (args, gchar *);
pspp_sheet_view_column_clear_attributes (tree_column, cell_renderer);
-
+
while (attribute != NULL)
{
column = va_arg (args, gint);
* @tree_column: A #PsppSheetViewColumn.
* @cell_renderer: the #GtkCellRenderer we're setting the attributes of
* @Varargs: A %NULL-terminated list of attributes.
- *
+ *
* Sets the attributes in the list as the attributes of @tree_column.
* The attributes should be in attribute/column order, as in
* pspp_sheet_view_column_add_attribute(). All existing attributes
* pspp_sheet_view_column_set_cell_data_func:
* @tree_column: A #PsppSheetViewColumn
* @cell_renderer: A #GtkCellRenderer
- * @func: The #PsppSheetViewColumnFunc to use.
+ * @func: The #PsppSheetViewColumnFunc to use.
* @func_data: The user data for @func.
* @destroy: The destroy notification for @func_data
- *
+ *
* Sets the #PsppSheetViewColumnFunc to use for the column. This
* function is used instead of the standard attributes mapping for
* setting the column value, and should set the value of @tree_column's
* pspp_sheet_view_column_clear_attributes:
* @tree_column: a #PsppSheetViewColumn
* @cell_renderer: a #GtkCellRenderer to clear the attribute mapping on.
- *
+ *
* Clears all existing attributes previously set with
* pspp_sheet_view_column_set_attributes().
**/
* pspp_sheet_view_column_set_spacing:
* @tree_column: A #PsppSheetViewColumn.
* @spacing: distance between cell renderers in pixels.
- *
+ *
* Sets the spacing field of @tree_column, which is the number of pixels to
* place between cell renderers packed into it.
**/
/**
* pspp_sheet_view_column_get_spacing:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the spacing of @tree_column.
- *
+ *
* Return value: the spacing of @tree_column.
**/
gint
* pspp_sheet_view_column_set_visible:
* @tree_column: A #PsppSheetViewColumn.
* @visible: %TRUE if the @tree_column is visible.
- *
+ *
* Sets the visibility of @tree_column.
**/
void
g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column));
visible = !! visible;
-
+
if (tree_column->visible == visible)
return;
/**
* pspp_sheet_view_column_get_visible:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns %TRUE if @tree_column is visible.
- *
+ *
* Return value: whether the column is visible or not. If it is visible, then
* the tree will show the column.
**/
* pspp_sheet_view_column_set_resizable:
* @tree_column: A #PsppSheetViewColumn
* @resizable: %TRUE, if the column can be resized
- *
+ *
* If @resizable is %TRUE, then the user can explicitly resize the column by
* grabbing the outer edge of the column button.
**/
/**
* pspp_sheet_view_column_get_resizable:
* @tree_column: A #PsppSheetViewColumn
- *
+ *
* Returns %TRUE if the @tree_column can be resized by the end user.
- *
+ *
* Return value: %TRUE, if the @tree_column can be resized.
**/
gboolean
/**
* pspp_sheet_view_column_get_width:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the current size of @tree_column in pixels.
- *
+ *
* Return value: The current width of @tree_column.
**/
gint
* pspp_sheet_view_column_set_fixed_width:
* @tree_column: A #PsppSheetViewColumn.
* @fixed_width: The size to set @tree_column to. Must be greater than 0.
- *
+ *
* Sets the size of the column in pixels. The size of the column is clamped to
* the min/max width for the column. Please note that the min/max width of the
* column doesn't actually affect the "fixed_width" property of the widget, just
/**
* pspp_sheet_view_column_get_fixed_width:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Gets the fixed width of the column. This value is only meaning may not be
* the actual width of the column on the screen, just what is requested.
- *
+ *
* Return value: the fixed width of the column
**/
gint
* pspp_sheet_view_column_set_min_width:
* @tree_column: A #PsppSheetViewColumn.
* @min_width: The minimum width of the column in pixels, or -1.
- *
+ *
* Sets the minimum width of the @tree_column. If @min_width is -1, then the
* minimum width is unset.
**/
/**
* pspp_sheet_view_column_get_min_width:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the minimum width in pixels of the @tree_column, or -1 if no minimum
* width is set.
- *
+ *
* Return value: The minimum width of the @tree_column.
**/
gint
* pspp_sheet_view_column_set_max_width:
* @tree_column: A #PsppSheetViewColumn.
* @max_width: The maximum width of the column in pixels, or -1.
- *
+ *
* Sets the maximum width of the @tree_column. If @max_width is -1, then the
* maximum width is unset. Note, the column can actually be wider than max
* width if it's the last column in a view. In this case, the column expands to
/**
* pspp_sheet_view_column_get_max_width:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the maximum width in pixels of the @tree_column, or -1 if no maximum
* width is set.
- *
+ *
* Return value: The maximum width of the @tree_column.
**/
gint
/**
* pspp_sheet_view_column_clicked:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Emits the "clicked" signal on the column. This function will only work if
* @tree_column is clickable.
**/
* pspp_sheet_view_column_set_title:
* @tree_column: A #PsppSheetViewColumn.
* @title: The title of the @tree_column.
- *
+ *
* Sets the title of the @tree_column. If a custom widget has been set, then
* this value is ignored.
**/
const gchar *title)
{
gchar *new_title;
-
+
g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column));
new_title = g_strdup (title);
/**
* pspp_sheet_view_column_get_title:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the title of the widget.
- *
+ *
* Return value: the title of the column. This string should not be
* modified or freed.
**/
* pspp_sheet_view_column_set_expand:
* @tree_column: A #PsppSheetViewColumn
* @expand: %TRUE if the column should take available extra space, %FALSE if not
- *
+ *
* Sets the column to take available extra space. This space is shared equally
* amongst all columns that have the expand set to %TRUE. If no column has this
* option set, then the last column gets all extra space. By default, every
/**
* pspp_sheet_view_column_get_expand:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Return %TRUE if the column expands to take any available space.
- *
+ *
* Return value: %TRUE, if the column expands
*
* Since: 2.4
* pspp_sheet_view_column_set_clickable:
* @tree_column: A #PsppSheetViewColumn.
* @clickable: %TRUE if the header is active.
- *
+ *
* Sets the header to be active if @active is %TRUE. When the header is active,
* then it can take keyboard focus, and can be clicked.
**/
/**
* pspp_sheet_view_column_get_clickable:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Returns %TRUE if the user can click on the header for the column.
- *
+ *
* Return value: %TRUE if user can click the column header.
**/
gboolean
if (widget)
g_object_ref_sink (widget);
- if (tree_column->child)
+ if (tree_column->child)
g_object_unref (tree_column->child);
tree_column->child = widget;
/**
* pspp_sheet_view_column_get_widget:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the #GtkWidget in the button on the column header. If a custom
* widget has not been set then %NULL is returned.
- *
+ *
* Return value: The #GtkWidget in the column header, or %NULL
**/
GtkWidget *
* pspp_sheet_view_column_set_alignment:
* @tree_column: A #PsppSheetViewColumn.
* @xalign: The alignment, which is between [0.0 and 1.0] inclusive.
- *
+ *
* Sets the alignment of the title or custom widget inside the column header.
* The alignment determines its location inside the button.
**/
/**
* pspp_sheet_view_column_get_alignment:
* @tree_column: A #PsppSheetViewColumn.
- *
+ *
* Returns the current x alignment of @tree_column.
- *
+ *
* Return value: The current alignent of @tree_column.
**/
GtkAlign
* pspp_sheet_view_column_set_reorderable:
* @tree_column: A #PsppSheetViewColumn
* @reorderable: %TRUE, if the column can be reordered.
- *
+ *
* If @reorderable is %TRUE, then the column can be reordered by the end user
* dragging the header.
**/
/**
* pspp_sheet_view_column_get_reorderable:
* @tree_column: A #PsppSheetViewColumn
- *
+ *
* Returns %TRUE if the @tree_column can be reordered by the user.
- *
+ *
* Return value: %TRUE if the @tree_column can be reordered by the user.
**/
gboolean
* @tree_column: a #PsppSheetViewColumn
* @sort_column_id: The @sort_column_id of the model to sort on.
*
- * Sets the logical @sort_column_id that this column sorts on when this column
+ * Sets the logical @sort_column_id that this column sorts on when this column
* is selected for sorting. Doing so makes the column header clickable.
**/
void
* the header button indicating the column is sorted. Call
* pspp_sheet_view_column_set_sort_order() to change the direction of
* the arrow.
- *
+ *
**/
void
pspp_sheet_view_column_set_sort_indicator (PsppSheetViewColumn *tree_column,
/**
* pspp_sheet_view_column_get_sort_indicator:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Gets the value set by pspp_sheet_view_column_set_sort_indicator().
- *
+ *
* Return value: whether the sort indicator arrow is displayed
**/
gboolean
* @tree_column: a #PsppSheetViewColumn
* @order: sort order that the sort indicator should indicate
*
- * Changes the appearance of the sort indicator.
- *
+ * Changes the appearance of the sort indicator.
+ *
* This <emphasis>does not</emphasis> actually sort the model. Use
* pspp_sheet_view_column_set_sort_column_id() if you want automatic sorting
* support. This function is primarily for custom sorting behavior, and should
* be used in conjunction with gtk_tree_sortable_set_sort_column() to do
- * that. For custom models, the mechanism will vary.
- *
+ * that. For custom models, the mechanism will vary.
+ *
* The sort indicator changes direction to indicate normal sort or reverse sort.
- * Note that you must have the sort indicator enabled to see anything when
+ * Note that you must have the sort indicator enabled to see anything when
* calling this function; see pspp_sheet_view_column_set_sort_indicator().
**/
void
/**
* pspp_sheet_view_column_get_sort_order:
* @tree_column: a #PsppSheetViewColumn
- *
+ *
* Gets the value set by pspp_sheet_view_column_set_sort_order().
- *
+ *
* Return value: the sort order the sort indicator is indicating
**/
GtkSortType
* @tree_column: A #PsppSheetViewColumn.
* @tree_model: The #GtkTreeModel to to get the cell renderers attributes from.
* @iter: The #GtkTreeIter to to get the cell renderer's attributes from.
- *
+ *
* Sets the cell renderer based on the @tree_model and @iter. That is, for
* every attribute mapping in @tree_column, it will get a value from the set
* column on the @iter, and use that value to set the attribute on the cell
* @y_offset: (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL
* @width: (allow-none): location to return width needed to render a cell, or %NULL
* @height: (allow-none): location to return height needed to render a cell, or %NULL
- *
+ *
* Obtains the width and height needed to render the column. This is used
* primarily by the #PsppSheetView.
**/
* width = 0;
gtk_widget_style_get (tree_column->tree_view, "focus-line-width", &focus_line_width, NULL);
-
+
for (list = tree_column->cell_list; list; list = list->next)
{
PsppSheetViewColumnCellInfo *info = (PsppSheetViewColumnCellInfo *) list->data;
if (real_cell_area.x - focus_line_width + info->real_width > cell_area->x + cell_area->width)
{
info->real_width = cell_area->x + cell_area->width - real_cell_area.x;
- }
+ }
if (real_cell_area.x > cell_area->x + cell_area->width)
break;
rtl_cell_area = real_cell_area;
rtl_background_area = real_background_area;
-
+
if (rtl)
{
rtl_cell_area.x = cell_area->x + cell_area->width - (real_cell_area.x - cell_area->x) - real_cell_area.width;
g_return_val_if_fail (GTK_IS_CELL_EDITABLE (*editable_widget), FALSE);
info->in_editing_mode = TRUE;
pspp_sheet_view_column_focus_cell (tree_column, info->cell);
-
+
flags &= ~GTK_CELL_RENDERER_FOCUSED;
return TRUE;
if (real_cell_area.x - focus_line_width + info->real_width > cell_area->x + cell_area->width)
{
info->real_width = cell_area->x + cell_area->width - real_cell_area.x;
- }
+ }
if (real_cell_area.x > cell_area->x + cell_area->width)
break;
* @background_area: entire cell area (including tree expanders and maybe padding on the sides)
* @cell_area: area normally rendered by a cell renderer
* @flags: flags that affect rendering
- *
+ *
* Renders the cell contained by #tree_column. This is used primarily by the
* #PsppSheetView.
**/
{
gint focus_line_width;
GtkStateType cell_state;
-
+
g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column));
gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
"focus-line-width", &focus_line_width, NULL);
cell_area->y - focus_line_width,
cell_area->width + 2 * focus_line_width,
cell_area->height + 2 * focus_line_width);
-#endif
+#endif
}
else
{
/**
* pspp_sheet_view_column_cell_is_visible:
* @tree_column: A #PsppSheetViewColumn
- *
+ *
* Returns %TRUE if any of the cells packed into the @tree_column are visible.
* For this to be meaningful, you must first initialize the cells with
* pspp_sheet_view_column_cell_set_cell_data()
- *
+ *
* Return value: %TRUE, if any of the cells packed into the @tree_column are currently visible
**/
gboolean
l = r = 0;
- list = pspp_sheet_view_column_cell_first (column);
+ list = pspp_sheet_view_column_cell_first (column);
while (list)
{
info = (PsppSheetViewColumnCellInfo *)list->data;
-
+
list = pspp_sheet_view_column_cell_next (column, list);
if (info->cell == cell)
break;
-
+
if (gtk_cell_renderer_get_visible (info->cell))
l += info->real_width + column->spacing;
}
while (list)
{
info = (PsppSheetViewColumnCellInfo *)list->data;
-
+
list = pspp_sheet_view_column_cell_next (column, list);
if (gtk_cell_renderer_get_visible (info->cell))
* Obtains the horizontal position and size of a cell in a column. If the
* cell is not found in the column, @start_pos and @width are not changed and
* %FALSE is returned.
- *
+ *
* Return value: %TRUE if @cell belongs to @tree_column.
*/
gboolean
glong l;
gchar *endptr;
gchar *string;
-
+
if (!parser_data->attr_name)
return;
l = strtol (string, &endptr, 0);
if (errno || endptr == string)
{
- g_set_error (error,
+ g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Could not parse integer `%s'",
const gchar *type)
{
GtkCellLayoutIface *iface;
-
+
g_return_if_fail (GTK_IS_CELL_LAYOUT (buildable));
g_return_if_fail (GTK_IS_CELL_RENDERER (child));
/**
* PsppSheetView:hover-selection:
- *
+ *
* Enables of disables the hover selection mode of @tree_view.
* Hover selection makes the selected row follow the pointer.
- * Currently, this works only for the selection modes
+ * Currently, this works only for the selection modes
* %PSPP_SHEET_SELECTION_SINGLE and %PSPP_SHEET_SELECTION_BROWSE.
*
* This mode is primarily intended for treeviews in popups, e.g.
* @column: the #PsppSheetViewColumn in which the activation occurred
*
* The "row-activated" signal is emitted when the method
- * pspp_sheet_view_row_activated() is called or the user double clicks
- * a treeview row. It is also emitted when a non-editable row is
- * selected and one of the keys: Space, Shift+Space, Return or
+ * pspp_sheet_view_row_activated() is called or the user double clicks
+ * a treeview row. It is also emitted when a non-editable row is
+ * selected and one of the keys: Space, Shift+Space, Return or
* Enter is pressed.
- *
- * For selection handling refer to the <link linkend="TreeWidget">tree
+ *
+ * For selection handling refer to the <link linkend="TreeWidget">tree
* widget conceptual overview</link> as well as #PsppSheetSelection.
*/
tree_view_signals[ROW_ACTIVATED] =
/**
* PsppSheetView::columns-changed:
- * @tree_view: the object on which the signal is emitted
- *
+ * @tree_view: the object on which the signal is emitted
+ *
* The number of columns of the treeview has changed.
*/
tree_view_signals[COLUMNS_CHANGED] =
/**
* PsppSheetView::cursor-changed:
* @tree_view: the object on which the signal is emitted
- *
+ *
* The position of the cursor (focused cell) has changed.
*/
tree_view_signals[CURSOR_CHANGED] =
tree_view->priv->search_equal_func = pspp_sheet_view_search_equal_func;
tree_view->priv->search_custom_entry_set = FALSE;
tree_view->priv->typeselect_flush_timeout = 0;
- tree_view->priv->init_hadjust_value = TRUE;
+ tree_view->priv->init_hadjust_value = TRUE;
tree_view->priv->width = 0;
-
+
tree_view->priv->hover_selection = FALSE;
tree_view->priv->rubber_banding_enable = FALSE;
/* Need to call those here, since they create GCs */
pspp_sheet_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
- install_presize_handler (tree_view);
+ install_presize_handler (tree_view);
}
static void
g_source_remove (priv->typeselect_flush_timeout);
priv->typeselect_flush_timeout = 0;
}
-
+
for (list = priv->columns; list; list = list->next)
_pspp_sheet_view_column_unrealize_button (PSPP_SHEET_VIEW_COLUMN (list->data));
if (tree_view->priv->model == NULL)
{
tree_view->priv->width = 0;
- tree_view->priv->prev_width = 0;
+ tree_view->priv->prev_width = 0;
tree_view->priv->height = 0;
return;
}
- tree_view->priv->prev_width = tree_view->priv->width;
+ tree_view->priv->prev_width = tree_view->priv->width;
tree_view->priv->width = 0;
/* keep this in sync with size_allocate below */
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
GList *tmp_list;
- /* we validate some rows initially just to make sure we have some size.
+ /* we validate some rows initially just to make sure we have some size.
* In practice, with a lot of static lists, this should get a good width.
*/
initialize_fixed_height_mode (tree_view);
invalid_rect.y = 0;
invalid_rect.width = column->width;
invalid_rect.height = allocation.height;
-
+
gdk_window_invalidate_rect (gtk_widget_get_window (widget), &invalid_rect, TRUE);
break;
}
-
+
column_offset += tmpcolumn->width;
}
}
else
extra_per_column = 0;
- for (list = (rtl ? last_column : first_column);
+ for (list = (rtl ? last_column : first_column);
list != (rtl ? first_column->prev : last_column->next);
- list = (rtl ? list->prev : list->next))
+ list = (rtl ? list->prev : list->next))
{
gint real_requested_width = 0;
gint old_width;
if (allocation->width != old_allocation.width)
width_changed = TRUE;
- if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
+ if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
allocation->x += allocation->width - tree_view->priv->width ;
gtk_widget_set_allocation (widget, allocation);
gtk_adjustment_set_lower (tree_view->priv->hadjustment, 0);
gtk_adjustment_set_upper (tree_view->priv->hadjustment, MAX (gtk_adjustment_get_page_size (tree_view->priv->hadjustment), tree_view->priv->width));
- if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
+ if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
{
if (allocation->width < tree_view->priv->width)
{
pspp_sheet_view_top_row_to_dy (tree_view);
else
pspp_sheet_view_dy_to_top_row (tree_view);
-
+
if (gtk_widget_get_realized (widget))
{
gdk_window_move_resize (gtk_widget_get_window (widget),
gint y)
{
PsppSheetSelectionMode mode = pspp_sheet_selection_get_mode (tree_view->priv->selection);
-
+
if (tree_view->priv->hover_selection &&
(mode == PSPP_SHEET_SELECTION_SINGLE || mode == PSPP_SHEET_SELECTION_BROWSE) &&
!(tree_view->priv->edited_column &&
if (!pspp_sheet_view_node_is_selected (tree_view, node))
{
GtkTreePath *path;
-
+
path = _pspp_sheet_view_find_path (tree_view, node);
pspp_sheet_selection_select_path (tree_view->priv->selection, path);
if (pspp_sheet_view_node_is_selected (tree_view, node))
x = CLAMP (x + (gint)event->x - column->drag_x, 0,
MAX (tree_view->priv->width, allocation.width) - column->allocation.width);
gdk_window_move (tree_view->priv->drag_window, x, y);
-
+
/* autoscroll, if needed */
pspp_sheet_view_horizontal_autoscroll (tree_view);
/* Update the current reorder position and arrow; */
invalid_region = cairo_region_create_rectangle (&old_area);
cairo_region_union_rectangle (invalid_region, &new_area);
- gdk_rectangle_intersect (GDK_RECTANGLE_PTR (&old_area),
+ gdk_rectangle_intersect (GDK_RECTANGLE_PTR (&old_area),
GDK_RECTANGLE_PTR (&new_area), GDK_RECTANGLE_PTR (&common));
if (common.width > 2 && common.height > 2)
{
}
#if GTK_MAJOR_VERSION == 3
- gdk_window_invalidate_region (tree_view->priv->bin_window, invalid_region, TRUE);
+ gdk_window_invalidate_region (tree_view->priv->bin_window, invalid_region, TRUE);
#else
{
cairo_rectangle_int_t extents;
GdkRectangle exposed_rect;
gdk_cairo_get_clip_rectangle (cr, &exposed_rect);
-
+
Zarea.x = 0;
Zarea.y = 0;
Zarea.height = allocation.height;
if (new_y < 0)
new_y = 0;
y_offset = -pspp_sheet_view_find_offset (tree_view, new_y, &node);
- bin_window_width =
+ bin_window_width =
gdk_window_get_width (tree_view->priv->bin_window);
- bin_window_height =
+ bin_window_height =
gdk_window_get_height (tree_view->priv->bin_window);
&iter,
path);
gtk_tree_path_free (path);
-
+
cursor_path = NULL;
drag_dest_path = NULL;
if (draw_vgrid_lines || draw_hgrid_lines)
gtk_widget_style_get (widget, "grid-line-width", &grid_line_width, NULL);
-
+
n_visible_columns = 0;
for (list = tree_view->priv->columns; list; list = list->next)
{
((GdkEventKey *) new_event)->window = g_object_ref (gtk_widget_get_window (tree_view->priv->search_window));
gtk_widget_realize (tree_view->priv->search_window);
- popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
+ popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
"popup-menu", G_CALLBACK (gtk_true),
NULL);
gdk_event_free (new_event);
gtk_widget_hide (tree_view->priv->search_window);
- g_signal_handler_disconnect (tree_view->priv->search_entry,
+ g_signal_handler_disconnect (tree_view->priv->search_entry,
popup_menu_id);
/* We check to make sure that the entry tried to handle the text, and that
"wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
-
+
draw_vgrid_lines =
tree_view->priv->grid_lines == PSPP_SHEET_VIEW_GRID_LINES_VERTICAL
|| tree_view->priv->grid_lines == PSPP_SHEET_VIEW_GRID_LINES_BOTH;
gtk_adjustment_changed (tree_view->priv->hadjustment);
gtk_adjustment_changed (tree_view->priv->vadjustment);
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
-
+
return FALSE;
}
presize_handler_callback (gpointer data)
{
do_presize_handler (PSPP_SHEET_VIEW (data));
-
+
return FALSE;
}
PsppSheetViewColumn *column)
{
PsppSheetViewChild *child;
-
+
g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
g_return_if_fail (GTK_IS_WIDGET (child_widget));
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
gtk_widget_set_parent_window (child->widget, tree_view->priv->bin_window);
-
+
gtk_widget_set_parent (child_widget, GTK_WIDGET (tree_view));
}
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
pspp_sheet_view_node_queue_redraw (tree_view, node);
}
-
+
if (free_path)
gtk_tree_path_free (path);
}
GtkMovementStep step,
gint count)
{
-
+
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
"move-cursor", 2,
G_TYPE_ENUM, step,
/* We know there are always 2 slots possbile, as you can always return column. */
/* If that's all there is, return */
- if (tree_view->priv->column_drag_info->next == NULL ||
+ if (tree_view->priv->column_drag_info->next == NULL ||
(tree_view->priv->column_drag_info->next->next == NULL &&
((PsppSheetViewColumnReorder *)tree_view->priv->column_drag_info->data)->right_column == column &&
((PsppSheetViewColumnReorder *)tree_view->priv->column_drag_info->next->data)->left_column == column))
send_event->button.axes = NULL;
send_event->button.state = 0;
send_event->button.button = 1;
- send_event->button.device =
+ send_event->button.device =
gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
send_event->button.x_root = 0;
if (!(mode & PSPP_SHEET_SELECT_MODE_EXTEND))
pspp_sheet_view_row_activated (tree_view, cursor_path,
tree_view->priv->focus_column);
-
+
gtk_tree_path_free (cursor_path);
return TRUE;
fevent->focus_change.type = GDK_FOCUS_CHANGE;
fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));
fevent->focus_change.in = in;
-
+
gtk_widget_send_focus_change (widget, fevent);
gdk_event_free (fevent);
}
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
return;
}
-
+
tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
}
/* Pops up the interactive search entry. If keybinding is TRUE then the user
- * started this by typing the start_interactive_search keybinding. Otherwise, it came from
+ * started this by typing the start_interactive_search keybinding. Otherwise, it came from
*/
static gboolean
pspp_sheet_view_real_start_interactive_search (PsppSheetView *tree_view,
GList *list;
gboolean found_focus = FALSE;
GtkWidgetClass *entry_parent_class;
-
+
if (!tree_view->priv->enable_search && !keybinding)
return FALSE;
break;
}
}
-
+
if (gtk_widget_has_focus (GTK_WIDGET (tree_view)))
found_focus = TRUE;
rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
column = g_list_nth (tree_view->priv->columns, i)->data;
width = rtl ? (column->allocation.x + column->allocation.width - *x) : (*x - column->allocation.x);
-
+
/* Clamp down the value */
if (column->min_width == -1)
width = MAX (column->button_request, width);
width = MIN (width, column->max_width);
*x = rtl ? (column->allocation.x + column->allocation.width - width) : (column->allocation.x + width);
-
+
return width;
}
-void
+void
pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column);
/* Callbacks */
gdk_window_get_position (tree_view->priv->bin_window, &x, &y);
if (headers_visible)
{
- gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
+ gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
tree_view->priv->width, allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
if (gtk_widget_get_mapped (GTK_WIDGET (tree_view)))
*
* Since: 2.10
**/
-gboolean
+gboolean
pspp_sheet_view_get_headers_clickable (PsppSheetView *tree_view)
{
GList *list;
-
+
g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), FALSE);
for (list = tree_view->priv->columns; list; list = list->next)
}
if (tree_view->priv->n_columns == 0 &&
- pspp_sheet_view_get_headers_visible (tree_view) &&
+ pspp_sheet_view_get_headers_visible (tree_view) &&
tree_view->priv->header_window)
gdk_window_hide (tree_view->priv->header_window);
*
* Sets the current keyboard focus to be at @path, and selects it. This is
* useful when you want to focus the user's attention on a particular row. If
- * @focus_column is not %NULL, then focus is given to the column specified by
- * it. Additionally, if @focus_column is specified, and @start_editing is
- * %TRUE, then editing should be started in the specified cell.
- * This function is often followed by @gtk_widget_grab_focus (@tree_view)
- * in order to give keyboard focus to the widget. Please note that editing
+ * @focus_column is not %NULL, then focus is given to the column specified by
+ * it. Additionally, if @focus_column is specified, and @start_editing is
+ * %TRUE, then editing should be started in the specified cell.
+ * This function is often followed by @gtk_widget_grab_focus (@tree_view)
+ * in order to give keyboard focus to the widget. Please note that editing
* can only happen when the widget is realized.
*
* If @path is invalid for @model, the current cursor (if any) will be unset
/**
* pspp_sheet_view_get_bin_window:
* @tree_view: A #PsppSheetView
- *
+ *
* Returns the window that @tree_view renders to. This is used primarily to
* compare to <literal>event->window</literal> to confirm that the event on
* @tree_view is on the right window.
- *
+ *
* Return value: A #GdkWindow, or %NULL when @tree_view hasn't been realized yet
**/
GdkWindow *
{
if (column)
*column = last_column;
-
+
if (cell_x)
*cell_x = last_column->width + remaining_x;
}
{
int node;
gboolean retval;
-
+
g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), FALSE);
if (!tree_view->priv->row_count)
* @n_targets: the number of items in @targets
* @actions: the bitmask of possible actions for a drag from this
* widget
- *
+ *
* Turns @tree_view into a drop destination for automatic DND. Calling
* this method sets #PsppSheetView:reorderable to %FALSE.
**/
if (!di->dest_set && !di->source_set)
remove_info (tree_view);
}
-
+
unset_reorderable (tree_view);
}
* @tree_view: a #PsppSheetView
* @path: (allow-none): The path of the row to highlight, or %NULL.
* @pos: Specifies whether to drop before, after or into the row
- *
+ *
* Sets the row that is highlighted for feedback.
**/
void
* @tree_view: a #PsppSheetView
* @path: (allow-none): Return location for the path of the highlighted row, or %NULL.
* @pos: (allow-none): Return location for the drop position, or %NULL
- *
+ *
* Gets information about the row that is highlighted for feedback.
**/
void
* @drag_y: the position to determine the destination row for
* @path: (allow-none): Return location for the path of the highlighted row, or %NULL.
* @pos: (allow-none): Return location for the drop position, or %NULL
- *
+ *
* Determines the destination row for a given position. @drag_x and
* @drag_y are expected to be in widget coordinates. This function is only
* meaningful if @tree_view is realized. Therefore this function will always
* return %FALSE if @tree_view is not realized or does not have a model.
- *
+ *
* Return value: whether there is a row at the given position, %TRUE if this
* is indeed the case.
**/
*
* If @enable_search is set, then the user can type in text to search through
* the tree interactively (this is sometimes called "typeahead find").
- *
- * Note that even if this is %FALSE, the user can still initiate a search
+ *
+ * Note that even if this is %FALSE, the user can still initiate a search
* using the "start-interactive-search" key binding.
*/
void
g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
enable_search = !!enable_search;
-
+
if (tree_view->priv->enable_search != enable_search)
{
tree_view->priv->enable_search = enable_search;
* pspp_sheet_view_get_enable_search:
* @tree_view: A #PsppSheetView
*
- * Returns whether or not the tree allows to start interactive searching
+ * Returns whether or not the tree allows to start interactive searching
* by typing in text.
*
* Return value: whether or not to let the user search interactively
* @column: the column of the model to search in, or -1 to disable searching
*
* Sets @column as the column where the interactive search code should
- * search in for the current model.
- *
+ * search in for the current model.
+ *
* If the search column is set, users can use the "start-interactive-search"
* key binding to bring up search popup. The enable-search property controls
* whether simply typing text will also start an interactive search.
*
- * Note that @column refers to a column of the current model. The search
+ * Note that @column refers to a column of the current model. The search
* column is reset to -1 when the model is changed.
*/
void
G_CALLBACK (pspp_sheet_view_search_init),
tree_view);
}
-
+
g_signal_connect (tree_view->priv->search_entry, "key-press-event",
G_CALLBACK (pspp_sheet_view_search_key_press_event),
tree_view);
g_source_remove (tree_view->priv->typeselect_flush_timeout);
tree_view->priv->typeselect_flush_timeout = 0;
}
-
+
if (gtk_widget_get_visible (search_dialog))
{
/* send focus-in event */
if (gtk_tree_row_reference_valid (tree_view->priv->cursor))
{
path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
-
+
_pspp_sheet_view_find_node (tree_view, path, &node);
-
+
if (node >= 0 && pspp_sheet_view_node_is_selected (tree_view, node))
pspp_sheet_view_row_activated (tree_view, path, tree_view->priv->focus_column);
-
+
gtk_tree_path_free (path);
}
}
tree_view);
gtk_container_remove (GTK_CONTAINER (tree_view),
- GTK_WIDGET (cell_editable));
+ GTK_WIDGET (cell_editable));
/* FIXME should only redraw a single node */
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
*
* Enables of disables the hover selection mode of @tree_view.
* Hover selection makes the selected row follow the pointer.
- * Currently, this works only for the selection modes
+ * Currently, this works only for the selection modes
* %PSPP_SHEET_SELECTION_SINGLE and %PSPP_SHEET_SELECTION_BROWSE.
- *
+ *
* Since: 2.6
**/
-void
+void
pspp_sheet_view_set_hover_selection (PsppSheetView *tree_view,
gboolean hover)
{
/**
* pspp_sheet_view_get_hover_selection:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether hover selection mode is turned on for @tree_view.
- *
+ *
* Return value: %TRUE if @tree_view is in hover selection mode
*
- * Since: 2.6
+ * Since: 2.6
**/
-gboolean
+gboolean
pspp_sheet_view_get_hover_selection (PsppSheetView *tree_view)
{
return tree_view->priv->hover_selection;
* Enables or disables rubber banding in @tree_view. If the selection mode is
* #PSPP_SHEET_SELECTION_MULTIPLE or #PSPP_SHEET_SELECTION_RECTANGLE, rubber
* banding will allow the user to select multiple rows by dragging the mouse.
- *
+ *
* Since: 2.10
**/
void
/**
* pspp_sheet_view_get_rubber_banding:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether rubber banding is turned on for @tree_view. If the
* selection mode is #PSPP_SHEET_SELECTION_MULTIPLE or
* #PSPP_SHEET_SELECTION_RECTANGLE, rubber banding will allow the user to
* select multiple rows by dragging the mouse.
- *
+ *
* Return value: %TRUE if rubber banding in @tree_view is enabled.
*
* Since: 2.10
/**
* pspp_sheet_view_is_rubber_banding_active:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether a rubber banding operation is currently being done
* in @tree_view.
*
old_grid_lines = priv->grid_lines;
priv->grid_lines = grid_lines;
-
+
if (old_grid_lines != grid_lines)
{
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
-
+
g_object_notify (G_OBJECT (tree_view), "enable-grid-lines");
}
}
{
gboolean continue_emission;
gboolean signal_handled;
-
+
signal_handled = g_value_get_boolean (handler_return);
g_value_set_boolean (return_accu, signal_handled);
continue_emission = !signal_handled;
-
+
return continue_emission;
}
get_layout_location (base, &label_area, layout, xpad, ypad, xalign, yalign,
&x, &y);
- gtk_paint_layout (label_style, cr, state_type, FALSE,
+ gtk_paint_layout (label_style, cr, state_type, FALSE,
base, "label", x, y, layout);
g_object_unref (layout);
{ PSPPIRE_BUTTON_PASTE_MASK, "PSPPIRE_BUTTON_PASTE_MASK", "Accept dialog and paste syntax" },
{ 0, NULL, NULL }
};
-
+
ftype = g_flags_register_static
(g_intern_static_string ("PsppireButtonFlags"), values);
GtkStateType state_type;
PsppireCellRendererButton *button = PSPPIRE_CELL_RENDERER_BUTTON (cell);
gfloat xalign, yalign;
-
+
if (!button->editable || ! gtk_cell_renderer_get_sensitive (cell))
state_type = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_SELECTED)
{
cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
- cairo_move_to (cr,
+ cairo_move_to (cr,
cell_area->x,
cell_area->y + cell_area->height);
if (button->dispose_has_run)
return;
-
+
button->dispose_has_run = TRUE;
/* When called with NULL, as we are doing here, update_style_cache
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/*
+/*
This module provides a subclass of GtkTreeView, designed for dialogs
which need lists of annotated checkbox items.
The object contains the necessary model and renderers, which means that
psppire_checkbox_treeview_init (PsppireCheckboxTreeview *cbtv)
{
cbtv->list = GTK_TREE_MODEL (gtk_list_store_new (N_CHECKBOX_COLUMNS,
- G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_STRING));
conf_write (PsppireConf *conf)
{
if ( conf->idle == 0)
- conf->idle = g_idle_add_full (G_PRIORITY_LOW,
+ conf->idle = g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) flush_conf, conf, NULL);
}
{
GEnumClass *ec = g_type_class_ref (enum_type);
GEnumValue *ev = g_enum_get_value (ec, value);
-
+
g_key_file_set_string (conf->keyfile, base, name,
ev->value_nick);
g_type_class_unref (ec);
-
+
conf_write (conf);
}
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de));
gtk_style_context_add_class (context, "psppire-data-editor");
-
+
de->font = NULL;
de->old_vbox_widget = NULL;
de->old_vbox_widget = de->datasheet_vbox_widget;
g_object_ref (de->old_vbox_widget);
/* FIXME: old_vbox_widget needs to be unreffed in dispose.
- (currently it seems to provoke an error if I do that.
+ (currently it seems to provoke an error if I do that.
I don't know why. */
gtk_container_remove (GTK_CONTAINER (de->vbox), de->datasheet_vbox_widget);
TRUE,
G_PARAM_READWRITE));
-
+
g_object_class_install_property (
gobject_class,
PROP_MAY_DELETE_VARS,
{
PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (widget);
-
+
gtk_menu_popup (GTK_MENU (data_sheet->row_popup_menu), NULL, NULL, NULL, NULL, button, time);
}
GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (data_sheet));
if (! PSPPIRE_IS_DATA_WINDOW (top))
return;
-
+
PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (top);
gint n_selected_rows = pspp_sheet_selection_count_selected_rows (selection);
PsppireDict *dict = data_sheet->data_store->dict;
GList *iter;
GList *list = pspp_sheet_selection_get_selected_columns (selection);
-
+
if (list == NULL)
return;
list = g_list_reverse (list);
g_signal_connect_swapped (clear_cases, "activate", G_CALLBACK (psppire_data_sheet_edit_clear_cases), obj);
g_signal_connect_swapped (insert_case, "activate", G_CALLBACK (psppire_data_sheet_insert_case), obj);
-
+
gtk_widget_show_all (obj->row_popup_menu);
}
-
+
{
obj->column_popup_menu = gtk_menu_new ();
int i = 0;
g_signal_connect_swapped (obj->pu_sort_up, "activate", G_CALLBACK (on_sort_up), obj);
g_signal_connect_swapped (obj->pu_sort_down, "activate", G_CALLBACK (on_sort_down), obj);
-
+
gtk_menu_attach (GTK_MENU (obj->column_popup_menu), insert_variable, 0, 1, i, i + 1); ++i;
gtk_menu_attach (GTK_MENU (obj->column_popup_menu), clear_variables, 0, 1, i, i + 1); ++i;
gtk_menu_attach (GTK_MENU (obj->column_popup_menu), gtk_separator_menu_item_new (), 0, 1, i, i + 1); ++i;
-
+
gtk_menu_attach (GTK_MENU (obj->column_popup_menu), obj->pu_sort_up, 0, 1, i, i + 1); ++i;
gtk_menu_attach (GTK_MENU (obj->column_popup_menu), obj->pu_sort_down, 0, 1, i, i + 1); ++i;
gtk_widget_show_all (obj->column_popup_menu);
}
-
+
g_signal_connect (obj, "notify::model",
G_CALLBACK (psppire_data_sheet_model_changed), NULL);
G_CALLBACK (on_query_tooltip), NULL);
g_signal_connect (obj, "button-press-event",
G_CALLBACK (on_button_pressed), NULL);
-
+
g_signal_connect (obj, "popup-menu", G_CALLBACK (on_popup_menu), NULL);
g_signal_connect (pspp_sheet_view_get_selection (sheet_view),
GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (data_sheet));
if (! PSPPIRE_IS_DATA_WINDOW (top))
return;
-
+
PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (top);
gboolean enable =
psppire_data_sheet_get_selected_range (data_sheet, &rows, &cols);
GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (data_sheet));
if (! PSPPIRE_IS_DATA_WINDOW (top))
return;
-
+
PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (top);
gtk_clipboard_request_targets (clip,
GtkWidget *column_popup_menu;
GtkWidget *row_popup_menu;
-
+
GtkWidget *pu_sort_up;
GtkWidget *pu_sort_down;
};
-struct _PsppireDataSheetClass
+struct _PsppireDataSheetClass
{
PsppSheetViewClass parent_class;
};
"transform-pending");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- transformations_pending);
+ transformations_pending);
}
if ( transformations_pending)
{
gchar *utf8_file_name;
struct string filename;
-
+
utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
if (NULL == utf8_file_name)
return FALSE;
- ds_init_empty (&filename);
+ ds_init_empty (&filename);
syntax_gen_string (&filename, ss_cstr (utf8_file_name));
-
+
g_free (utf8_file_name);
if (encoding && encoding[0])
mime_type = "application/x-spss-por";
else if (name_has_sav_suffix (file_name))
mime_type = "application/x-spss-sav";
-
+
add_most_recent (file_name, mime_type, encoding);
}
status_bar_activate (GAction *action, GVariant *param, PsppireDataWindow *de)
{
GtkWidget *statusbar = get_widget_assert (de->builder, "status-bar");
-
+
GVariant *state = g_action_get_state (action);
const gboolean visible = g_variant_get_boolean (state);
g_action_change_state (action, g_variant_new_boolean (!visible));
gtk_widget_show (GTK_WIDGET (de->mi_clear_cases));
break;
-
+
case 1:
g_action_change_state (action, g_variant_new_string ("VARS"));
gtk_widget_hide (GTK_WIDGET (de->ti_insert_case));
gtk_widget_hide (GTK_WIDGET (de->mi_find));
gtk_widget_hide (GTK_WIDGET (de->mi_find_separator));
gtk_widget_hide (GTK_WIDGET (de->mi_clear_cases));
-
+
break;
- }
+ }
}
GtkWidget *dialog = gtk_font_chooser_dialog_new (NULL, GTK_WINDOW (toplevel));
GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET(de->data_editor));
const PangoFontDescription *current_font ;
-
+
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", ¤t_font, NULL);
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (dialog), current_font);
GVariant *new_state = g_action_get_state (action);
labels_active = g_variant_get_boolean (new_state);
g_object_set (de->data_editor, "value-labels", labels_active, NULL);
-
+
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (de->ti_value_labels_button),
labels_active);
}
free (encoding);
- if ( psppire_window_load (PSPPIRE_WINDOW (se), file, encoding, NULL) )
+ if ( psppire_window_load (PSPPIRE_WINDOW (se), file, encoding, NULL) )
gtk_widget_show (se);
else
gtk_widget_destroy (se);
GtkWidget *w = psppire_import_assistant_new (GTK_WINDOW (dw));
PsppireImportAssistant *asst = PSPPIRE_IMPORT_ASSISTANT (w);
gtk_widget_show_all (w);
-
+
asst->main_loop = g_main_loop_new (NULL, TRUE);
g_main_loop_run (asst->main_loop);
g_main_loop_unref (asst->main_loop);
if (!asst->file_name)
goto end;
-
+
switch (asst->response)
{
case GTK_RESPONSE_APPLY:
default:
break;
}
-
- end:
+
+ end:
gtk_widget_destroy (GTK_WIDGET (asst));
}
GAction *act = g_object_new (type,
"top-level", de,
NULL);
-
+
g_action_map_add_action (G_ACTION_MAP (de), act);
}
connect_action_to_menuitem (GActionMap *map, const gchar *action_name, GtkWidget *w, const gchar *accel)
{
GAction *a = g_action_map_lookup_action (map, action_name);
-
+
if (NULL == a)
g_error ("Action \"%s\" not found in map", action_name);
detailed_action_name = g_strdup_printf ("win.%s", action_name);
else if (GTK_IS_APPLICATION (map))
detailed_action_name = g_strdup_printf ("app.%s", action_name);
-
+
gtk_application_set_accels_for_action (app,
detailed_action_name,
accels);
free (detailed_action_name);
}
-
+
g_signal_connect_swapped (w, "activate", G_CALLBACK (g_action_activate_null), a);
}
GtkWidget *new_menu = gtk_menu_new ();
g_object_set (new, "submenu", new_menu, NULL);
-
+
GtkWidget *syntax = gtk_menu_item_new_with_mnemonic (_("_Syntax"));
connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()), "new-syntax", syntax, 0);
-
+
GtkWidget *data = gtk_menu_item_new_with_mnemonic (_("_Data"));
connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()), "new-data", data, 0);
gtk_menu_attach (GTK_MENU (new_menu), syntax, 0, 1, 0, 1);
gtk_menu_attach (GTK_MENU (new_menu), data, 0, 1, 1, 2);
}
-
+
GtkWidget *open = gtk_menu_item_new_with_mnemonic (_("_Open"));
connect_action_to_menuitem (G_ACTION_MAP (dw), "open", open, "<Ctrl>O");
-
+
GtkWidget *import = gtk_menu_item_new_with_mnemonic (_("_Import Data..."));
connect_action_to_menuitem (G_ACTION_MAP (dw), "file-import", import, 0);
-
+
gtk_menu_attach (GTK_MENU (menu), open, 0, 1, 1, 2);
gtk_menu_attach (GTK_MENU (menu), import, 0, 1, 2, 3);
GtkWidget *save = gtk_menu_item_new_with_mnemonic (_("_Save..."));
connect_action_to_menuitem (G_ACTION_MAP (dw), "save", save, "<Ctrl>S");
-
+
GtkWidget *save_as = gtk_menu_item_new_with_mnemonic (_("Save _As..."));
connect_action_to_menuitem (G_ACTION_MAP (dw), "save-as", save_as, "<Shift><Ctrl>S");
-
+
GtkWidget *rename_dataset = gtk_menu_item_new_with_mnemonic (_("_Rename Dataset..."));
connect_action_to_menuitem (G_ACTION_MAP (dw), "rename-dataset", rename_dataset, 0);
-
+
gtk_menu_attach (GTK_MENU (menu), save, 0, 1, 4, 5);
gtk_menu_attach (GTK_MENU (menu), save_as, 0, 1, 5, 6);
gtk_menu_attach (GTK_MENU (menu), rename_dataset, 0, 1, 6, 7);
GtkWidget *dd_menu = gtk_menu_new ();
g_object_set (display_data, "submenu", dd_menu, NULL);
-
+
GtkWidget *working_file = gtk_menu_item_new_with_mnemonic (_("Working File"));
connect_action_to_menuitem (G_ACTION_MAP (dw), "info-working", working_file, 0);
GtkWidget *external_file = gtk_menu_item_new_with_mnemonic (_("_External File..."));
gtk_menu_attach (GTK_MENU (dd_menu), working_file, 0, 1, 0, 1);
gtk_menu_attach (GTK_MENU (dd_menu), external_file, 0, 1, 1, 2);
}
-
+
gtk_menu_attach (GTK_MENU (menu), gtk_separator_menu_item_new (), 0, 1, 9, 10);
{
gtk_menu_attach (GTK_MENU (menu), mi_data, 0, 1, 10, 11);
gtk_menu_attach (GTK_MENU (menu), mi_files, 0, 1, 11, 12);
-
+
g_object_set (menu_data, "show-tips", TRUE, NULL);
g_object_set (menu_files, "show-tips", TRUE, NULL);
g_object_set (mi_data, "submenu", menu_data, NULL);
g_object_set (mi_files, "submenu", menu_files, NULL);
-
+
{
GtkRecentFilter *filter = gtk_recent_filter_new ();
connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()),
"quit", quit, "<Ctrl>Q");
}
-
+
g_object_set (menuitem, "submenu", menu, NULL);
gtk_widget_show_all (menuitem);
-
+
return menuitem;
}
GAction *a = g_action_map_lookup_action (G_ACTION_MAP (dw), "PsppireDialogActionVarInfo");
g_assert (a);
g_signal_connect_swapped (go_to_variable, "activate", G_CALLBACK (psppire_dialog_action_activate_null), a);
-
+
gtk_menu_attach (GTK_MENU (menu), go_to_variable, 0, 1, i, i + 1); ++i;
gtk_menu_attach (GTK_MENU (menu), dw->mi_go_to_case, 0, 1, i, i + 1); ++i;
{
GtkAccelGroup *ag = gtk_accel_group_new ();
-
+
dw->mi_edit_separator = gtk_separator_menu_item_new ();
gtk_menu_attach (GTK_MENU (menu), dw->mi_edit_separator, 0, 1, i, i + 1); ++i;
gtk_window_add_accel_group (GTK_WINDOW (dw), ag);
gtk_widget_add_accelerator (dw->mi_cut, "activate", ag,
'X', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-
+
dw->mi_copy = gtk_menu_item_new_with_mnemonic (_("_Copy"));
gtk_menu_attach (GTK_MENU (menu), dw->mi_copy, 0, 1, i, i + 1); ++i;
g_signal_connect_swapped (dw->mi_copy, "activate", G_CALLBACK (on_copy), dw);
gtk_widget_add_accelerator (dw->mi_copy, "activate", ag,
'C', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-
+
dw->mi_paste = gtk_menu_item_new_with_mnemonic (_("_Paste"));
gtk_menu_attach (GTK_MENU (menu), dw->mi_paste, 0, 1, i, i + 1); ++i;
g_signal_connect_swapped (dw->mi_paste, "activate", G_CALLBACK (on_paste), dw);
dw->mi_clear_variables = gtk_menu_item_new_with_mnemonic (_("Clear _Variables"));
gtk_menu_attach (GTK_MENU (menu), dw->mi_clear_variables, 0, 1, i, i + 1); ++i;
g_signal_connect_swapped (dw->mi_clear_variables, "activate", G_CALLBACK (on_clear_variables), dw);
-
+
dw->mi_clear_cases = gtk_menu_item_new_with_mnemonic (_("Cl_ear Cases"));
gtk_menu_attach (GTK_MENU (menu), dw->mi_clear_cases, 0, 1, i, i + 1); ++i;
g_signal_connect_swapped (dw->mi_clear_cases, "activate", G_CALLBACK (on_clear_cases), dw);
}
-
+
{
dw->mi_find_separator = gtk_separator_menu_item_new ();
gtk_menu_attach (GTK_MENU (menu), dw->mi_find_separator, 0, 1, i, i + 1); ++i;
-
+
dw->mi_find = gtk_menu_item_new_with_mnemonic (_("_Find..."));
g_signal_connect_swapped (dw->mi_find, "activate", G_CALLBACK (find_dialog), dw);
gtk_menu_attach (GTK_MENU (menu), dw->mi_find, 0, 1, i, i + 1); ++i;
G_CALLBACK (options_dialog), dw);
gtk_menu_attach (GTK_MENU (menu), dw->mi_options, 0, 1, i, i + 1); ++i;
}
-
+
g_object_set (menuitem, "submenu", menu, NULL);
-
+
gtk_widget_show_all (menuitem);
-
+
return menuitem;
}
de->data_editor =
PSPPIRE_DATA_EDITOR (psppire_data_editor_new (de->dict, de->data_store));
-
+
g_signal_connect (de, "realize",
G_CALLBACK (set_data_page), de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_FLIP, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, de);
-
+
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_COUNT, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, de);
-
+
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_ROC, de);
-
+
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, de);
connect_dialog_action (PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, de);
g_signal_connect_swapped (file_import_action, "activate", G_CALLBACK (file_import), de);
g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (file_import_action));
}
-
+
{
GSimpleAction *save = g_simple_action_new ("save", NULL);
g_signal_connect_swapped (save, "activate", G_CALLBACK (psppire_window_save), de);
g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (act_gridlines));
}
-
+
{
GSimpleAction *act_view_data = g_simple_action_new_stateful ("view_dv", G_VARIANT_TYPE_STRING,
g_variant_new_string ("DATA"));
g_signal_connect_swapped (find, "activate", G_CALLBACK (find_dialog), de);
g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (find));
}
-
+
{
int idx = 0;
{
{
de->ti_jump_to_case = gtk_tool_button_new (NULL, "Jump to Case");
-
+
GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), "jump-to-case");
g_assert (a);
g_signal_connect_swapped (de->ti_jump_to_case, "clicked",
G_CALLBACK (g_action_activate_null), a);
-
+
gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_jump_to_case, idx++);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_jump_to_case), "edit-go-to-case");
gtk_widget_set_tooltip_text (GTK_WIDGET (de->ti_jump_to_case), _("Jump to a case in the data sheet"));
g_signal_connect_swapped (de->ti_find, "clicked",
G_CALLBACK (g_action_activate_null), a);
-
+
gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_find, idx++);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_find), "edit-find");
gtk_widget_set_tooltip_text (GTK_WIDGET (de->ti_find), _("Search for values in the data"));
GApplication *app = g_application_get_default ();
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (dw));
-
+
return dw;
}
GtkWidget *w = psppire_data_window_new (NULL);
gtk_widget_show (w);
-
+
return GTK_WINDOW (w);
}
return FALSE;
liststore = GTK_TREE_MODEL (PSPPIRE_ACR (agg->summary_acr)->list_store);
-
+
if ( ! gtk_tree_model_get_iter_first (liststore, &iter))
return FALSE;
gpointer data)
{
PsppireDialogActionAggregate *agg = data;
-
+
GString *string = g_string_new ("");
append_summary_spec (agg, iter, string);
-
+
g_object_set (cell, "text", string->str, NULL);
g_string_free (string, TRUE);
_("Cancel"), GTK_RESPONSE_CANCEL,
_("Save"), GTK_RESPONSE_ACCEPT,
NULL);
-
+
g_object_set (dialog, "local-only", FALSE, NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
}
-enum
+enum
{
SUMMARY_COL_VARNAME = 0,
SUMMARY_COL_VARLABEL,
double arg1, arg2;
gchar *text1 = g_strdup ("");
gchar *text2 = g_strdup ("");
-
+
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model (tv);
GtkTreeSelection *sel = gtk_tree_view_get_selection (tv);
gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), varname);
gtk_entry_set_text (GTK_ENTRY (agg->summary_var_label_entry), label);
gtk_entry_set_text (GTK_ENTRY (agg->summary_sv_entry), srcvar);
-
+
text1 = c_xasprintf ("%.*g", DBL_DIG + 1, arg1);
text2 = c_xasprintf ("%.*g", DBL_DIG + 1, arg2);
}
GtkWidget *break_selector = get_widget_assert (xml, "break-selector");
act->pane = get_widget_assert (xml, "hbox1");
-
+
act->break_variables = get_widget_assert (xml, "psppire-var-view1");
act->filename_radiobutton = get_widget_assert (xml, "filename-radiobutton");
act->filename_button = get_widget_assert (xml, "filename-button");
GtkListStore *list = gtk_list_store_new (6,
G_TYPE_STRING,
G_TYPE_STRING,
- G_TYPE_INT,
+ G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE);
g_signal_connect_swapped (PSPPIRE_ACR (act->summary_acr)->tv,
"cursor-changed", G_CALLBACK (on_acr_change), act);
}
-
+
g_signal_connect_swapped (act->summary_var_name_entry, "changed", G_CALLBACK (update_acr), act);
g_signal_connect_swapped (act->function_combo, "changed", G_CALLBACK (update_acr), act);
g_signal_connect_swapped (act->summary_sv_entry, "changed", G_CALLBACK (update_acr), act);
g_string_append (string, ds_cstr (&ss));
ds_destroy (&ss);
}
-
+
g_string_append_printf (string, " = %s", funcname);
if ( has_src_vars != AGR_SV_NO)
{
struct string dss;
ds_init_cstr (&dss, " (");
-
+
ds_put_cstr (&dss, srcvar);
if ( arity > 0)
dialog_state_valid (gpointer pda)
{
PsppireDialogActionAutorecode *rd = PSPPIRE_DIALOG_ACTION_AUTORECODE (pda);
-
+
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->var_view));
const gint n_vars = gtk_tree_model_iter_n_children (model, NULL);
if (n_vars == 0)
return FALSE;
-
+
if (g_hash_table_size (rd->varmap) != n_vars)
return FALSE;
gtk_list_store_clear (GTK_LIST_STORE (target_list));
-
+
}
/* Name-Label pair */
generate_syntax (const PsppireDialogAction *act)
{
PsppireDialogActionAutorecode *rd = PSPPIRE_DIALOG_ACTION_AUTORECODE (act);
-
+
GHashTableIter iter;
gpointer key, value;
gchar *text;
g_string_append (string, "\n\tVARIABLES =");
g_hash_table_iter_init (&iter, rd->varmap);
- while (g_hash_table_iter_next (&iter, &key, &value))
+ while (g_hash_table_iter_next (&iter, &key, &value))
{
struct variable *var = key;
g_string_append (string, " ");
g_string_append (string, " INTO");
g_hash_table_iter_init (&iter, rd->varmap);
- while (g_hash_table_iter_next (&iter, &key, &value))
+ while (g_hash_table_iter_next (&iter, &key, &value))
{
struct nlp *nlp = value;
g_string_append (string, " ");
gpointer key, value;
g_hash_table_iter_init (&iter, rd->varmap);
- while (g_hash_table_iter_next (&iter, &key, &value))
+ while (g_hash_table_iter_next (&iter, &key, &value))
{
struct nlp *nlp = value;
-
+
if ( 0 == strcmp (nlp->name, text))
{
valid = FALSE;
GtkTreeIter iter;
gtk_widget_set_sensitive (rd->new_name_entry, TRUE);
- gtk_widget_set_sensitive (rd->change_button, TRUE);
+ gtk_widget_set_sensitive (rd->change_button, TRUE);
ok = gtk_tree_model_get_iter (model, &iter, (GtkTreePath*) rows->data);
PsppireDialogActionAutorecode *rd = PSPPIRE_DIALOG_ACTION_AUTORECODE (data);
-
+
struct variable *var = NULL;
- gtk_tree_model_get (tree_model, iter,
+ gtk_tree_model_get (tree_model, iter,
0, &var,
-1);
}
}
-
+
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
This ensures that the signal handler gets called. */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->button_summary_func), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->button_freq_func[0]), TRUE);
-
+
gtk_widget_set_sensitive (rd->combobox, FALSE);
gtk_combo_box_set_active (GTK_COMBO_BOX (rd->combobox), 0);
act->button_freq_func[1] = get_widget_assert (xml, "radiobutton-percent");
act->button_freq_func[2] = get_widget_assert (xml, "radiobutton-cum-count");
act->button_freq_func[3] = get_widget_assert (xml, "radiobutton-cum-percent");
-
+
act->button_summary_func = get_widget_assert (xml, "radiobutton3");
act->summary_variables = get_widget_assert (xml, "hbox1");
act->combobox = get_widget_assert (xml, "combobox1");
populate_combo_model (GTK_COMBO_BOX(act->combobox));
-
+
g_signal_connect_swapped (act->button_summary_func, "toggled",
G_CALLBACK (on_summary_toggle), act);
g_string_append (string, " BY ");
g_string_append (string, var_name_cluster);
}
-
+
g_string_append (string, ".\n");
text = string->str;
if (endptr == text)
return FALSE;
- return TRUE;
+ return TRUE;
}
static gboolean
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->range_button)))
{
ds_put_cstr (&dss, "(");
-
- ds_put_cstr (&dss,
+
+ ds_put_cstr (&dss,
gtk_entry_get_text (GTK_ENTRY (scd->value_lower)));
ds_put_cstr (&dss, ", ");
ds_put_cstr (&dss, "\n\t");
ds_put_cstr (&dss, "/EXPECTED = ");
-
+
for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(ls),
&iter);
ok;
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
psppire_dialog_action_set_refresh (pda, refresh);
- g_signal_connect (act->range_button, "toggled",
- G_CALLBACK (set_sensitivity_from_toggle),
+ g_signal_connect (act->range_button, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle),
range_table);
- g_signal_connect (act->values_button, "toggled",
- G_CALLBACK (set_sensitivity_from_toggle),
+ g_signal_connect (act->values_button, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle),
values_acr);
- g_signal_connect (act->values_button, "toggled",
- G_CALLBACK (set_sensitivity_from_toggle),
+ g_signal_connect (act->values_button, "toggled",
+ G_CALLBACK (set_sensitivity_from_toggle),
expected_value_entry);
psppire_acr_set_entry (PSPPIRE_ACR (values_acr),
act->check = get_widget_assert (xml, "comments-checkbutton1");
g_signal_connect_swapped (pda->dialog, "show", G_CALLBACK (retrieve_comments), pda);
-
+
{
PangoContext * context ;
PangoLayout * layout ;
PangoRectangle rect;
-
+
/* Since we're going to truncate lines to 80 chars,
we need a monospaced font otherwise it'll look silly */
PangoFontDescription *font_desc =
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (cssp);
}
-
+
/* And let's just make sure that a complete line fits into the
widget's width */
context = gtk_widget_create_pango_context (act->textview);
pango_font_description_free (font_desc);
}
-
+
g_signal_connect (buffer, "mark-set",
G_CALLBACK (set_column_number), label);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
gtk_text_buffer_place_cursor (buffer, &iter);
}
-
+
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
psppire_dialog_action_set_refresh (pda, refresh);
}
gboolean ok;
GtkTreeIter iter;
struct string dds;
-
+
ds_init_empty (&dds);
ds_put_cstr (&dds, "\nCOUNT ");
PsppireDialogActionCount *cnt = PSPPIRE_DIALOG_ACTION_COUNT (data);
PsppireValChooser *vc = PSPPIRE_VAL_CHOOSER (cnt->chooser);
struct old_value ov;
-
+
g_assert (col == 0);
psppire_val_chooser_get_status (vc, &ov);
GtkTreeIter notused;
- return (gtk_tree_model_get_iter_first (row_vars, ¬used)
+ return (gtk_tree_model_get_iter_first (row_vars, ¬used)
&& gtk_tree_model_get_iter_first (col_vars, ¬used));
}
GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_rows));
gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
+
liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (cd->dest_cols));
gtk_list_store_clear (GTK_LIST_STORE (liststore));
}
cd->format_options_table =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->table_button));
- cd->format_options_pivot =
+ cd->format_options_pivot =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->pivot_button));
}
}
if (cd->format_options_avalue)
g_string_append (string, "AVALUE");
- else
+ else
g_string_append (string, "DVALUE");
g_string_append (string, " ");
if (cd->format_options_pivot)
g_string_append (string, "PIVOT");
- else
+ else
g_string_append (string, "NOPIVOT");
selected = 0;
- for (i = 0, ok = gtk_tree_model_get_iter_first (cd->stat, &iter); ok;
+ for (i = 0, ok = gtk_tree_model_get_iter_first (cd->stat, &iter); ok;
i++, ok = gtk_tree_model_iter_next (cd->stat, &iter))
{
gboolean toggled;
gtk_tree_model_get (cd->stat, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- else
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ else
selected &= ~(1u << i);
}
}
selected = 0;
- for (i = 0, ok = gtk_tree_model_get_iter_first (cd->cell, &iter); ok;
+ for (i = 0, ok = gtk_tree_model_get_iter_first (cd->cell, &iter); ok;
i++, ok = gtk_tree_model_iter_next (cd->cell, &iter))
{
gboolean toggled;
gtk_tree_model_get (cd->cell, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- else
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ else
selected &= ~(1u << i);
}
#include "psppire-dialog-action.h"
-/*
+/*
This module provides a subclass of GtkTreeView, designed for dialogs
which need lists of annotated checkbox items.
The object contains the necessary model and renderers, which means that
GtkWidget *col_vars;
GtkWidget *row_vars;
- GtkWidget *dest_rows;
+ GtkWidget *dest_rows;
GtkWidget *dest_cols ;
GtkWidget *format_button ;
GtkWidget *stat_button ;
"predicate", var_is_numeric, NULL);
act->stat_vars = GTK_TREE_VIEW (act->variables);
-
+
act->include_user_missing =
GTK_TOGGLE_BUTTON (get_widget_assert (xml, "include_user_missing"));
act->exclude_missing_listwise =
act->stats_dialog = get_widget_assert (xml, "statistics-dialog");
act->descriptives_button = get_widget_assert (xml, "descriptives-button");
- act->extremes_button = get_widget_assert (xml, "extremes-button");
+ act->extremes_button = get_widget_assert (xml, "extremes-button");
act->percentiles_button = get_widget_assert (xml, "percentiles-button");
act->opts_dialog = get_widget_assert (xml, "options-dialog");
g_signal_connect_swapped (opts_button, "clicked",
G_CALLBACK (run_opts_dialog), act);
-
+
g_list_free (list);
}
G_DEFINE_TYPE (PsppireDialogActionFactor, psppire_dialog_action_factor, PSPPIRE_TYPE_DIALOG_ACTION);
-static const char *rot_method_syntax[] =
+static const char *rot_method_syntax[] =
{
"NOROTATE",
"VARIMAX",
ds_put_cstr (&str, "\n\t/PRINT = ");
ds_put_cstr (&str, "INITIAL ");
- if ( rd->extraction.unrotated )
+ if ( rd->extraction.unrotated )
ds_put_cstr (&str, "EXTRACTION ");
if ( rd->rotation.rotated_solution )
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->display_rotated_solution),
p->rotated_solution);
-
+
gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->rotate_iterations),
p->iterations);
gtk_combo_box_set_active (GTK_COMBO_BOX (fd->extraction_combo), 1);
else
gtk_combo_box_set_active (GTK_COMBO_BOX (fd->extraction_combo), 0);
-
+
}
static gboolean
gint n_factors;
gint n_iterations;
- gboolean explicit_nfactors;
+ gboolean explicit_nfactors;
gboolean covariance;
gboolean scree;
GtkWidget * avalue;
GtkWidget * dvalue;
GtkWidget * afreq;
- GtkWidget * dfreq;
+ GtkWidget * dfreq;
GtkWidget *tables_dialog;
{
gboolean result = FALSE;
- if (var)
+ if (var)
{
union value val;
const int width = var_get_width (var);
PsppireDialogAction *da = PSPPIRE_DIALOG_ACTION (act);
GtkWidget *parent1 = gtk_widget_get_parent (act->dg_table1);
GtkWidget *parent2 = gtk_widget_get_parent (act->dg_table2);
-
+
g_return_if_fail (act->grp_var);
-
+
if (parent1)
gtk_container_remove (GTK_CONTAINER (parent1), act->dg_table1);
g_hash_table_insert (thing, a, xml);
}
- pda->dialog = get_widget_assert (xml,"independent-samples-dialog");
+ pda->dialog = get_widget_assert (xml,"independent-samples-dialog");
pda->source = get_widget_assert (xml, "indep-samples-treeview1");
act->define_groups_button = get_widget_assert (xml, "define-groups-button");
act->options_button = get_widget_assert (xml, "indep-samples-options-button");
g_string_append (str, "(");
{
- const union value *val =
+ const union value *val =
(act->group_defn == GROUPS_VALUES) ?
&act->grp_val[0] :
&act->cut_point;
- struct string strx;
+ struct string strx;
ds_init_empty (&strx);
syntax_gen_value (&strx, val, var_get_width (act->grp_var),
var_get_print_format (act->grp_var));
-
+
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
{
struct string strx;
ds_init_empty (&strx);
-
+
syntax_gen_value (&strx, &act->grp_val[1], var_get_width (act->grp_var),
var_get_print_format (act->grp_var));
-
+
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
return FALSE;
/* At least one checkbutton must be active */
- if (
+ if (
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (krd->friedman))
- &&
+ &&
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (krd->kendal))
- &&
+ &&
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (krd->cochran))
)
return FALSE;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->cut_point_entry), act->cut_point);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->iterations_entry), act->max_iterations);
-
+
ret = psppire_dialog_run (PSPPIRE_DIALOG (act->opts_dialog));
if ( ret == PSPPIRE_RESPONSE_CONTINUE )
{
act->conf = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(act->conf_checkbox));
act->conf_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (act->conf_entry));
-
+
act->constant = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(act->const_checkbox));
act->cut_point = gtk_spin_button_get_value (GTK_SPIN_BUTTON (act->cut_point_entry));
G_CALLBACK (on_opts_clicked), act);
g_signal_connect (act->conf_checkbox, "toggled",
- G_CALLBACK (set_sensitivity_from_toggle),
+ G_CALLBACK (set_sensitivity_from_toggle),
act->conf_entry);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(act->conf_checkbox), TRUE);
g_string_append_printf (strx, "\n\t/PRINT = CI(%g)", rd->conf_level);
}
- if (rd->constant)
+ if (rd->constant)
g_string_append (strx, "\n\t/NOORIGIN");
else
g_string_append (strx, "\n\t/ORIGIN");
gtk_container_add (GTK_CONTAINER (vb), act->layer);
gtk_widget_show (act->layer);
}
-
+
GtkWidget *selector = get_widget_assert (xml, "layer-selector");
pda->dialog = get_widget_assert (xml, "means-dialog");
act->homogeneity = get_widget_assert (xml, "checkbutton2");
act->contrasts_dialog = get_widget_assert (xml, "contrasts-dialog");
-
+
act->next = get_widget_assert (xml, "next-button");
act->prev = get_widget_assert (xml, "prev-button");
act->ctotal = get_widget_assert (xml, "entry2");
if (v == NULL)
return FALSE;
-
+
/* if ( NULL == pd->valid) */
/* return TRUE; */
{
xml = builder_new ("paired-samples.ui");
g_hash_table_insert (thing, a, xml);
-
+
GtkWidget *selector = get_widget_assert (xml, "psppire-selector3");
GtkWidget *bb = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
GtkWidget *button = gtk_button_new_with_mnemonic (_("O_ptions..."));
gtk_box_pack_start (GTK_BOX (bb), button, TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (box), bb, FALSE, FALSE, 5);
gtk_widget_show_all (box);
-
+
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
psppire_dialog_action_set_refresh (pda, refresh);
select_as_pair_member,
act);
}
-
+
}
static void
{
PsppireDialogActionRecodeDifferent *rdd = PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT (rd);
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->variable_treeview));
-
+
if (g_hash_table_size (rdd->varmap) != gtk_tree_model_iter_n_children (model, NULL) )
return FALSE;
{
PsppireDialogActionRecode *rd = data;
GtkTreeIter not_used;
-
+
if ( ! rd->value_map )
return FALSE;
struct variable *var = NULL;
- gtk_tree_model_get (tree_model, iter,
+ gtk_tree_model_get (tree_model, iter,
0, &var,
-1);
g_return_if_fail (ok);
gtk_tree_model_get (model, &iter,
- 0, &var,
+ 0, &var,
-1);
nlp = g_hash_table_lookup (rdd->varmap, var);
_("Recode into Different Variables: Old and New Values "));
gtk_widget_show (act->output_variable_box);
-
+
g_signal_connect_swapped (act->old_and_new_dialog, "show",
G_CALLBACK (on_old_new_show), act);
GtkTreeIter iter;
ds_put_cstr (dds, "\n\tINTO ");
gboolean ok;
-
+
for (ok = psppire_var_view_get_iter_first (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter);
ok;
ok = psppire_var_view_get_iter_next (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter))
const struct variable *var = psppire_var_view_get_variable (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, &iter);
nlp = g_hash_table_lookup (rdd->varmap, var);
-
+
ds_put_cstr (dds, nlp->name);
ds_put_cstr (dds, " ");
}
{
PsppireDialogActionRecode *rd = data;
GtkTreeIter not_used;
-
+
if ( ! rd->value_map )
return FALSE;
gtk_window_set_title (GTK_WINDOW (pda->dialog),
_("Recode into Same Variables"));
-
+
g_signal_connect_swapped (act->old_and_new_dialog, "show",
G_CALLBACK (on_old_new_show), act);
_("Recode into Same Variables: Old and New Values"));
gtk_widget_hide (act->output_variable_box);
-
+
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda,
pda->dialog = get_widget_assert (xml, "recode-dialog");
pda->source = get_widget_assert (xml, "treeview1");
-
+
GtkWidget *selector = get_widget_assert (xml, "psppire-selector1");
GtkWidget *oldandnew = get_widget_assert (xml, "button1");
if (populate_treeview)
populate_treeview (act);
-
+
psppire_selector_set_allow (PSPPIRE_SELECTOR (selector), homogeneous_types);
/* Set up the Old & New Values subdialog */
ds_init_empty (&dds);
append_string_decls (rd, &dds);
-
+
ds_put_cstr (&dds, "\nRECODE ");
psppire_var_view_append_names_str (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, &dds);
ds_put_cstr (&dds, ".");
append_new_value_labels (rd, &dds);
-
+
ds_put_cstr (&dds, "\nEXECUTE.\n");
GtkWidget *change_button;
GtkWidget *output_variable_box;
-
+
GtkWidget *string_button;
GtkWidget *width_entry;
};
g_string_append (string, "\n\t/DEPENDENT=");
psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->dep_vars), 0, string);
g_string_append (string, "\n\t/METHOD=ENTER");
-
+
selected = 0;
- for (i = 0, ok = gtk_tree_model_get_iter_first (model, &iter); ok;
+ for (i = 0, ok = gtk_tree_model_get_iter_first (model, &iter); ok;
i++, ok = gtk_tree_model_iter_next (model, &iter))
{
gboolean toggled;
gtk_tree_model_get (model, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
- if (toggled)
- selected |= 1u << i;
- else
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ if (toggled)
+ selected |= 1u << i;
+ else
selected &= ~(1u << i);
}
G_DEFINE_TYPE (PsppireDialogActionReliability, psppire_dialog_action_reliability, PSPPIRE_TYPE_DIALOG_ACTION);
-enum
+enum
{
ALPHA = 0,
SPLIT = 1
value_init (&val, width);
result = psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (rd->state_value), &val, width);
-
+
if (var_is_value_missing (var, &val, MV_SYSTEM))
result = FALSE;
-
+
value_destroy (&val, width);
return result;
g_object_set (rd->reference, "inconsistent", TRUE, NULL);
g_object_set (rd->reference, "sensitive", FALSE, NULL);
}
- else
+ else
{
g_object_set (rd->reference, "inconsistent", FALSE, NULL);
g_object_set (rd->reference, "sensitive", TRUE, NULL);
{
struct string str;
ds_init_empty (&str);
-
+
syntax_gen_value (&str, &val, var_get_width (var),
var_get_print_format (var));
-
+
g_string_append (string, ds_cstr (&str));
ds_destroy (&str);
}
ds_init_cstr (&dss, "GRAPH SCATTERPLOT(BIVARIATE) = ");
ds_put_cstr (&dss, gtk_entry_get_text (GTK_ENTRY (ow->x_axis)));
-
+
ds_put_cstr (&dss, " WITH ");
ds_put_cstr (&dss, gtk_entry_get_text (GTK_ENTRY (ow->y_axis)));
if ( 0 == strcmp ("", yvar))
return FALSE;
-
+
return TRUE;
}
g_signal_connect (scd->spin_sample_size, "value-changed", G_CALLBACK (sample_consistent), scd);
g_signal_connect (scd->spin_sample_limit, "value-changed", G_CALLBACK (sample_consistent), scd);
-
+
gtk_widget_show (scd->hbox2);
gtk_widget_set_sensitive (scd->hbox2, FALSE);
pda->dialog = get_widget_assert (xml, "select-cases-dialog");
pda->source = get_widget_assert (xml, "select-cases-treeview");
- g_object_set (pda->source,
+ g_object_set (pda->source,
"selection-mode", GTK_SELECTION_SINGLE,
NULL);
-
+
act->entry = get_widget_assert (xml, "filter-variable-entry");
GtkWidget *selector = get_widget_assert (xml, "psppire-selector-filter");
filter, ranvar);
ds_put_cstr (&dss, "EXECUTE.\n");
-
+
ds_put_c_format (&dss,
"COMPUTE %s = $CASENUM.\n",
(GTK_TOGGLE_BUTTON (scd->radiobutton_sample)))
{
ds_put_cstr (&dss, "SAMPLE ");
-
+
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->percent)))
{
const double percentage =
gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->spin_sample_size));
const gint from_n_cases =
gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->spin_sample_limit));
-
+
ds_put_c_format (&dss, "%d FROM %d .", n_cases, from_n_cases);
}
-
+
}
else if ( gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (scd->radiobutton_range)))
{
return g_strdup ("FILTER OFF.\n");
}
-
+
/* Are we filtering or deleting ? */
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->radiobutton_delete)))
{
GtkWidget *hbox2;
GtkWidget *rsample_dialog;
- GtkWidget *percent ;
- GtkWidget *sample_n_cases ;
+ GtkWidget *percent ;
+ GtkWidget *sample_n_cases ;
GtkWidget *table ;
GtkWidget *l0 ;
GtkWidget *l1 ;
pda->dialog = get_widget_assert (xml, "sort-cases-dialog");
pda->source = get_widget_assert (xml, "sort-cases-treeview1");
-
+
act->variables = get_widget_assert (xml, "sort-cases-treeview2");
act->ascending = get_widget_assert (xml, "sort-cases-radiobutton0");
g_signal_connect (act->off, "toggled", G_CALLBACK (on_off_toggled), pda);
g_signal_connect_swapped (pda->dialog, "show", G_CALLBACK (refresh), pda);
}
-
+
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
psppire_dialog_action_set_refresh (pda, refresh);
GtkWidget *selector;
- GtkWidget *dest ;
- GtkWidget *source ;
+ GtkWidget *dest ;
+ GtkWidget *source ;
- GtkWidget *sort ;
- GtkWidget *layered ;
+ GtkWidget *sort ;
+ GtkWidget *layered ;
- GtkWidget *off ;
+ GtkWidget *off ;
};
pda->dialog = get_widget_assert (xml, "t-test-one-sample-dialog");
pda->source = get_widget_assert (xml, "one-sample-t-test-treeview2");
- g_object_set (pda->source,
+ g_object_set (pda->source,
"predicate", var_is_numeric, NULL);
act->vars_treeview = get_widget_assert (xml, "one-sample-t-test-treeview1");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pd->nts[NT_MCNEMAR].button)))
return TRUE;
-
+
return FALSE;
}
psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
select_as_pair_member,
act);
-
+
}
static void
GString *str = g_string_new ("GLM ");
g_string_append (str, gtk_entry_get_text (GTK_ENTRY (uvd->dep_entry)));
-
+
g_string_append (str, " BY ");
psppire_var_view_append_names (PSPPIRE_VAR_VIEW (uvd->factor_list), 0, str);
act->output =
psppire_output_view_new (GTK_LAYOUT (get_widget_assert (xml, "layout1")),
NULL);
-
+
pda->dialog = get_widget_assert (xml, "variable-info-dialog");
pda->source = get_widget_assert (xml, "treeview2");
"selection-mode", GTK_SELECTION_SINGLE,
"predicate", var_is_numeric,
NULL);
-
+
psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector),
is_currently_in_entry);
}
-
+
psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
psppire_dialog_action_set_refresh (pda, refresh);
{
GHashTable *t = g_object_get_data (w, "thing-table");
GSList *dl = g_object_get_data (w, "widget-list");
-
+
g_slist_free_full (dl, (GDestroyNotify) gtk_widget_destroy);
g_hash_table_unref (t);
}
/* Each toplevel widget - that is the data window, which generally has a 1-1 association
with a dataset - has an associated GHashTable.
-
+
This GHashTable is keyed by the address of a PsppireDialogAction, and its values
are user determined pointers (typically a GtkBuilder*).
}
void
-psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act,
+psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act,
ContentsAreValid dialog_state_valid)
{
psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (act->dialog),
}
void
-psppire_dialog_action_set_refresh (PsppireDialogAction *pda,
+psppire_dialog_action_set_refresh (PsppireDialogAction *pda,
PsppireDialogActionRefresh refresh)
{
g_signal_connect_swapped (pda->dialog, "refresh", G_CALLBACK (refresh), pda);
}
-void
+void
psppire_dialog_action_set_activation (gpointer class, activation activate)
{
PSPPIRE_DIALOG_ACTION_CLASS (class)->activate = (void (*)(PsppireDialogAction *, GVariant *)) activate;
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/*
+/*
This is a an abstract base class, which implements GAction.
It's purpose is to abstract the way in which dialog boxes behave.
- That is, this action will fire whenever a dialog box is to be
+ That is, this action will fire whenever a dialog box is to be
popped up.
-
- Additionally, most dialog boxes generate syntax to
+
+ Additionally, most dialog boxes generate syntax to
be run by the pspp back-end. This provides an abstraction
to do that. The programmer needs only to provide the function
to generate the syntax. This base class looks after the rest.
typedef void (*PsppireDialogActionRefresh) (PsppireDialogAction *) ;
-void psppire_dialog_action_set_refresh (PsppireDialogAction *pda,
+void psppire_dialog_action_set_refresh (PsppireDialogAction *pda,
PsppireDialogActionRefresh refresh);
-void psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act,
+void psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act,
ContentsAreValid dialog_state_valid);
typedef void (*activation) (PsppireDialogAction *);
GParamSpec *sliding_spec ;
GParamSpec *help_page_spec ;
- help_page_spec =
- g_param_spec_string ("help-page",
+ help_page_spec =
+ g_param_spec_string ("help-page",
"Help Page",
"The section of the manual to load when the Help button is clicked",
NULL,
g_signal_connect_swapped (w, "de-selected",
G_CALLBACK (psppire_dialog_notify_change),
dialog);
-
+
psppire_selector_update_subjects (PSPPIRE_SELECTOR (w));
}
dialog);
}
-
+
g_signal_connect_swapped (selection, "changed",
G_CALLBACK (psppire_dialog_notify_change),
dialog);
dict_view->sorted_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (dict_view->dict));
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (dict_view->sorted_model), default_sort, dict_view, 0);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dict_view->sorted_model),
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dict_view->sorted_model),
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
if ( dict_view->predicate )
if (gtk_check_menu_item_get_inconsistent (checkbox))
gtk_check_menu_item_set_active (checkbox, !global_setting);
-
+
gtk_check_menu_item_set_inconsistent (checkbox, FALSE);
-
+
gtk_widget_queue_draw (GTK_WIDGET (dv));
}
dict_view->override_button = item;
gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (item),
TRUE);
-
+
g_signal_connect (item, "toggled",
G_CALLBACK (toggle_label_preference), dict_view);
return hbox;
}
-/*
- Return a string describing the currently selected encoding.
+/*
+ Return a string describing the currently selected encoding.
The caller should free this string when no longer required.
*/
gchar *
GtkWidget *psppire_encoding_selector_new (const char *default_encoding,
gboolean allow_auto);
-/*
- Return a string describing the currently selected encoding.
+/*
+ Return a string describing the currently selected encoding.
The caller should free this string when no longer required.
*/
gchar *psppire_encoding_selector_get_encoding (GtkWidget *selector);
// clear_fields (ia);
destroy_columns (ia);
-
+
ds_destroy (&ia->separators);
ds_destroy (&ia->quotes);
gint pn = gtk_assistant_get_current_page (GTK_ASSISTANT (ia));
{
GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT (ia), pn);
-
+
page_func *on_reset = g_object_get_data (G_OBJECT (page), "on-reset");
if (on_reset)
if (on_entering)
on_entering (ia, new_page);
}
-
+
ia->current_page = pn;
}
ia->file_name);
return FALSE;
}
-
+
ds_init_empty (&input);
for (ia->line_cnt = 0; ia->line_cnt < MAX_PREVIEW_LINES; ia->line_cnt++)
{
destroy_file (ia);
return FALSE;
}
-
+
/* Estimate the number of lines in the file. */
if (ia->line_cnt < MAX_PREVIEW_LINES)
{
g_object_set_data (G_OBJECT (model), "lines", &ia->lines + first_line);
g_object_set_data (G_OBJECT (model), "first-line", GINT_TO_POINTER (first_line));
-
+
pspp_sheet_view_set_model (PSPP_SHEET_VIEW (tree_view), model);
-
+
g_object_unref (model);
}
GtkWidget *page, GtkAssistantPageType type, const gchar *);
-static void
+static void
on_sheet_combo_changed (GtkComboBox *cb, PsppireImportAssistant *ia)
{
GtkTreeIter iter;
GtkWidget *sheet_entry = get_widget_assert (builder, "sheet-entry");
GtkWidget *readnames_checkbox = get_widget_assert (builder, "readnames-checkbox");
- gtk_combo_box_set_model (GTK_COMBO_BOX (sheet_entry),
+ gtk_combo_box_set_model (GTK_COMBO_BOX (sheet_entry),
psppire_spreadsheet_model_new (ia->spreadsheet));
gtk_combo_box_set_active (GTK_COMBO_BOX (sheet_entry), 0);
{
GtkBuilder *builder = ia->builder;
GtkWidget *page = get_widget_assert (builder, "Spreadsheet-Importer");
-
+
GtkWidget *combo_box = get_widget_assert (builder, "sheet-entry");
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box));
}
-static void
+static void
on_chosen (PsppireImportAssistant *ia, GtkWidget *page)
{
GtkFileChooser *fc = GTK_FILE_CHOOSER (page);
if (f && !g_file_test (f, G_FILE_TEST_IS_DIR))
{
gtk_assistant_set_page_complete (GTK_ASSISTANT(ia), GTK_WIDGET (fc), TRUE);
-
+
if (ia->spreadsheet)
spreadsheet_unref (ia->spreadsheet);
-
+
ia->spreadsheet = gnumeric_probe (f, FALSE);
if (!ia->spreadsheet)
{
sheet_spec_page_create (ia);
}
-
+
formats_page_create (ia);
}
- g_free (f);
+ g_free (f);
}
/* This has to be done on a map signal callback,
because GtkFileChooserWidget resets everything when it is mapped. */
-static void
+static void
on_map (PsppireImportAssistant *ia, GtkWidget *page)
{
GtkFileChooser *fc = GTK_FILE_CHOOSER (page);
gtk_file_filter_set_name (ia->default_filter, _("All Files"));
gtk_file_filter_add_pattern (ia->default_filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), ia->default_filter);
-
+
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Text Files"));
gtk_file_filter_add_mime_type (filter, "text/*");
{
ia->builder = builder_new ("text-data-import.ui");
- ia->current_page = -1 ;
+ ia->current_page = -1 ;
ia->column_cnt = 0;
ia->columns = NULL;
ia->encoding = NULL;
ia->spreadsheet = NULL;
ia->watch_cursor = 0;
-
+
ia->prop_renderer = gtk_cell_renderer_text_new ();
g_object_ref_sink (ia->prop_renderer);
ia->fixed_renderer = gtk_cell_renderer_text_new ();
g_signal_connect (ia, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (ia, "cancel", G_CALLBACK (on_cancel), ia);
g_signal_connect (ia, "close", G_CALLBACK (on_close), ia);
-
+
ia->paste_button = gtk_button_new_with_label (_("Paste"));
ia->reset_button = gtk_button_new_with_label (_("Reset"));
-
+
gtk_assistant_add_action_widget (GTK_ASSISTANT(ia), ia->paste_button);
g_signal_connect (ia->paste_button, "clicked", G_CALLBACK (on_paste), ia);
gtk_window_set_title (GTK_WINDOW (ia),
_("Importing Delimited Text Data"));
-
+
gtk_window_set_icon_name (GTK_WINDOW (ia), "pspp");
chooser_page_create (ia);
{
gint row = empty_list_store_iter_to_row (iter);
struct string *lines;
-
+
lines = g_object_get_data (G_OBJECT (tree_model), "lines");
g_return_if_fail (lines != NULL);
{
GtkTreePath *path = gtk_tree_path_new_from_indices (ia->skip_lines, -1);
-
+
set_model_on_treeview (ia, ia->tree_view, 0);
pspp_sheet_view_set_cursor (PSPP_SHEET_VIEW (ia->tree_view),
PsppSheetViewColumn *column =
pspp_sheet_view_column_new_with_attributes (title,
ia->fixed_renderer, (void *) NULL);
-
+
pspp_sheet_view_column_set_cell_data_func (column, ia->fixed_renderer,
render_line, NULL, NULL);
pspp_sheet_view_column_set_resizable (column, TRUE);
GtkWidget *oldtv = gtk_bin_get_child (GTK_BIN (parent));
if (oldtv)
gtk_container_remove (parent, oldtv);
-
+
gtk_container_add (parent, tree_view);
gtk_widget_show (tree_view);
GtkWidget *w = get_widget_assert (ia->builder, "FirstLine");
g_object_set_data (G_OBJECT (w), "on-entering", set_first_line);
-
+
add_page_to_assistant (ia, w,
GTK_ASSISTANT_PAGE_CONTENT, _("Select the First Line"));
if (ia->line_cnt > MAX_PREVIEW_LINES)
ia->line_cnt = MAX_PREVIEW_LINES;
-
+
ds_init_empty (&s);
ds_put_cstr (&s, _("This assistant will guide you through the process of "
"importing data into PSPP from a text file with one line "
if (w)
gtk_container_remove (GTK_CONTAINER (table), w);
-
+
GtkWidget *hbox_n_cases = psppire_scanf_new (_("Only the first %4d cases"), &ia->n_cases_spin);
GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ia->n_cases_spin));
free (col->name);
free (col->contents);
}
-
+
free (ia->columns);
}
{
column = &ia->columns[dict_idx];
name = escape_underscores (column->name);
- char_cnt = column->width;
+ char_cnt = column->width;
}
else
{
GtkWidget *tree_view = make_tree_view (ia);
set_model_on_treeview (ia, tree_view, ia->skip_lines);
-
+
pspp_sheet_selection_set_mode (pspp_sheet_view_get_selection (PSPP_SHEET_VIEW (tree_view)),
PSPP_SHEET_SELECTION_NONE);
g_object_set_data (G_OBJECT (w), "on-entering", prepare_separators_page);
g_object_set_data (G_OBJECT (w), "on-reset", prepare_separators_page);
-
+
add_page_to_assistant (ia, w, GTK_ASSISTANT_PAGE_CONTENT, _("Choose Separators"));
ia->quote_cb = get_widget_assert (builder, "quote-cb");
set_quote_list (GTK_COMBO_BOX (ia->quote_combo));
- ia->fields_tree_view = NULL;
+ ia->fields_tree_view = NULL;
g_signal_connect (ia->quote_combo, "changed",
G_CALLBACK (on_quote_combo_change), ia);
GtkBin *vars_scroller;
GtkWidget *old_var_sheet;
-
+
push_watch_cursor (ia);
if (ia->spreadsheet == NULL)
unsigned long int number = 0;
size_t column_idx;
-
+
ia->dict = dict_create (get_default_encoding ());
fg = fmt_guesser_create ();
for (column_idx = 0; column_idx < ia->column_cnt; column_idx++)
{
- struct variable *modified_var =
+ struct variable *modified_var =
(column_idx < ia->modified_var_cnt ? ia->modified_vars[column_idx] : NULL);
if (modified_var == NULL)
gint num = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
struct spreadsheet_read_options sro;
-
+
sro.sheet_name = NULL;
sro.cell_range = NULL;
sro.sheet_index = num + 1;
sro.read_names = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (readnames_checkbox));
sro.asw = -1;
-
+
switch (ia->spreadsheet->type)
{
case SPREADSHEET_ODS:
{
char *ss;
const struct variable *var = dict_get_var (ia->dict, col);
-
+
ia->columns[col].contents = xrealloc (ia->columns[col].contents,
sizeof (struct substring) * rows);
-
- ss = data_out (case_data (c, var), dict_get_encoding (ia->dict),
+
+ ss = data_out (case_data (c, var), dict_get_encoding (ia->dict),
var_get_print_format (var));
-
+
ia->columns[col].contents[rows - 1] = ss_cstr (ss);
}
-
+
if (rows > MAX_PREVIEW_LINES)
{
case_unref (c);
G_CALLBACK (on_variable_change), ia);
ia->psppire_dict = psppire_dict;
-
+
/* XXX: PsppireVarStore doesn't hold a reference to
psppire_dict for now, but it should. After it does, we
should g_object_ref the psppire_dict here, since we also
GtkWidget *w = get_widget_assert (builder, "Formats");
g_object_set_data (G_OBJECT (w), "on-entering", prepare_formats_page);
g_object_set_data (G_OBJECT (w), "on-reset", reset_formats_page);
-
+
add_page_to_assistant (ia, w,
GTK_ASSISTANT_PAGE_CONFIRM, _("Adjust Variable Formats"));
\f
-static void
+static void
separators_append_syntax (const PsppireImportAssistant *ia, struct string *s)
{
int i;
int var_cnt;
g_return_if_fail (ia->dict);
-
+
ds_put_cstr (s, " /VARIABLES=\n");
-
+
var_cnt = dict_get_var_cnt (ia->dict);
for (i = 0; i < var_cnt; i++)
{
"\n /SHEET=index %d"
"\n /READNAMES=%ss",
(ia->spreadsheet->type == SPREADSHEET_GNUMERIC) ? "GNM" : "ODS",
- ia->file_name,
+ ia->file_name,
sheet_index,
read_names ? "ON" : "OFF");
syntax_gen_pspp (&s, ".");
-
+
return ds_cstr (&s);
}
{
return sheet_spec_gen_syntax (ia);
}
-
+
return ds_cstr (&s);
}
GtkFileFilter *default_filter;
/* END The chooser page of the assistant. */
-
+
/* START The introduction page of the assistant. */
GtkWidget *all_cases_button;
GtkWidget *n_cases_button;
}
-static void
+static void
psppire_means_layer_class_init (PsppireMeansLayerClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (ml->var_view));
g_ptr_array_add (ml->layer, tm);
g_signal_connect_swapped (tm, "row-inserted", G_CALLBACK (refresh_view), ml);
-
+
g_object_ref (tm);
}
l = g_strdup_printf (_("Layer %d of %d"),
ml->current_layer + 1, ml->n_layers);
-
+
gtk_label_set_text (GTK_LABEL (ml->label), l);
g_free (l);
GtkTreeModel *tm = g_ptr_array_index (ml->layer, ml->current_layer);
g_return_if_fail (GTK_IS_TREE_MODEL (tm));
-
+
gtk_widget_set_sensitive (ml->forward,
gtk_tree_model_get_iter_first (tm, &dummy));
}
psppire_means_layer_update (ml);
}
-static void
+static void
psppire_means_layer_init (PsppireMeansLayer *ml)
{
GtkWidget *hbox_upper = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
gtk_orientable_set_orientation (GTK_ORIENTABLE (ml), GTK_ORIENTATION_VERTICAL);
-
+
ml->dispose_has_run = FALSE;
ml->forward = gtk_button_new_with_label (_("Forward"));
ml->back = gtk_button_new_with_label (_("Back"));
cairo_destroy (cr);
}
-/* Return the horizontal position to place a widget whose
+/* Return the horizontal position to place a widget whose
width is CHILD_WIDTH */
static gint
get_xpos (const struct psppire_output_view *view, gint child_width)
GAction *copy_action = g_action_map_lookup_action (G_ACTION_MAP (toplevel),
"copy");
-
+
GAction *select_all_action = g_action_map_lookup_action (G_ACTION_MAP (toplevel),
"select-all");
- g_object_set (copy_action, "enabled", FALSE, NULL);
+ g_object_set (copy_action, "enabled", FALSE, NULL);
g_signal_connect_swapped (select_all_action, "activate",
G_CALLBACK (on_select_all), view);
g_signal_connect_swapped (copy_action, "activate",
G_CALLBACK (on_copy), view);
-
+
g_signal_connect (sel, "changed", G_CALLBACK (on_selection_change),
copy_action);
}
GtkCellRenderer *renderer;
GtkTreeModel *model;
-
+
view = xmalloc (sizeof *view);
view->xr = NULL;
view->font_height = 0;
get_cairo_context_from_print_context (GtkPrintContext *context)
{
cairo_t *cr = gtk_print_context_get_cairo_context (context);
-
+
/*
For all platforms except windows, gtk_print_context_get_dpi_[xy] returns 72.
Windows returns 600.
*/
double xres = gtk_print_context_get_dpi_x (context);
double yres = gtk_print_context_get_dpi_y (context);
-
+
/* This means that the cairo context now has its dimensions in Points */
cairo_scale (cr, xres / 72.0, yres / 72.0);
-
+
return cr;
}
GtkPrintOperation *print = gtk_print_operation_new ();
- if (view->print_settings != NULL)
+ if (view->print_settings != NULL)
gtk_print_operation_set_print_settings (print, view->print_settings);
g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), view);
{
PsppireOutputWindow *window = PSPPIRE_OUTPUT_WINDOW (obj);
- if (window->dispose_has_run)
+ if (window->dispose_has_run)
return;
window->dispose_has_run = TRUE;
parent_class = g_type_class_peek_parent (class);
object_class->dispose = psppire_output_window_dispose;
-
+
object_class->finalize = psppire_output_window_finalize;
}
\f
const gchar *ext;
};
-enum
+enum
{
FT_AUTO = 0,
FT_PDF,
gboolean sensitive = FALSE;
GtkWidget *combo = gtk_file_chooser_get_extra_widget (chooser);
- int x = 0;
+ int x = 0;
gchar *fn = gtk_file_chooser_get_filename (chooser);
if (combo && gtk_widget_get_realized (combo))
int i;
GtkTreeIter iter;
GtkListStore *list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
+
for (i = 0 ; i < n_FT ; ++i)
{
gtk_list_store_append (list, &iter);
1, ft[i].ext,
-1);
}
-
+
return list;
}
GtkListStore *list;
GtkFileChooser *chooser;
-
+
GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Export Output"),
GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
filename = g_strconcat (filename, ft[file_type].ext, NULL);
g_free (of);
}
-
+
string_map_init (&options);
string_map_insert (&options, "output-file", filename);
gtk_container_add (GTK_CONTAINER (window), box);
GtkWidget *paned = get_widget_assert (xml, "paned1");
-
+
window->dispose_has_run = FALSE;
window->view = psppire_output_view_new (
gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
create_windows_menu (GTK_WINDOW (window)));
-
+
gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
create_help_menu (GTK_WINDOW (window)));
accels);
}
-
+
{
GSimpleAction *export = g_simple_action_new ("export", NULL);
g_signal_connect_swapped (export, "activate", G_CALLBACK (psppire_output_window_export), window);
accels);
}
-
+
g_object_unref (xml);
g_signal_connect (window, "delete-event",
static const GTypeInfo psppire_selector_info =
{
sizeof (PsppireSelectorClass),
- (GBaseInitFunc) NULL,
+ (GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc)psppire_selector_class_init,
(GClassFinalizeFunc) NULL,
}
/* This function is for debugging only */
-void
+void
psppire_selector_show_map (PsppireSelector *obj)
{
PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
sel->source_litem = NULL;
}
-
+
g_object_unref (sel->dest);
g_object_unref (sel->source);
FALSE,
G_PARAM_READWRITE);
- GParamSpec *source_widget_spec =
+ GParamSpec *source_widget_spec =
g_param_spec_object ("source-widget",
"Source Widget",
"The widget to be used as the source for this selector",
GTK_TYPE_WIDGET,
G_PARAM_READWRITE);
- GParamSpec *dest_widget_spec =
+ GParamSpec *dest_widget_spec =
g_param_spec_object ("dest-widget",
"Destination Widget",
"The widget to be used as the destination for this selector",
if ( selector->row_activate_id )
g_signal_handler_disconnect (selector->source, selector->row_activate_id);
- selector->row_activate_id =
+ selector->row_activate_id =
g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector);
}
if ( selector->source_select_id )
g_signal_handler_disconnect (selection, selector->source_select_id);
- selector->source_select_id =
+ selector->source_select_id =
g_signal_connect (selection, "changed", G_CALLBACK (on_source_select), selector);
}
de_select_tree_model (selection, model);
}
-static void
+static void
de_select_tree_model (GtkTreeSelection *selection, GtkTreeModel *model)
{
GList *item;
g_return_if_fail (selector->select_items);
- if (selector->allow_selection &&
+ if (selector->allow_selection &&
! selector->allow_selection (selector->source, selector->dest))
return;
GList *list = NULL;
PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
-
+
if ( ! (list = g_hash_table_lookup (class->source_hash, selector->source)))
{
- /* Base case: This widget is currently not the source of
+ /* Base case: This widget is currently not the source of
any selector. Create a hash entry and make this selector
the first selector in the list */
if (model && (model == g_object_get_data (G_OBJECT (source), "model-copy")))
return;
- if (model != NULL)
- {
- GtkTreeModel *new_model = gtk_tree_model_filter_new (model, NULL);
+ if (model != NULL)
+ {
+ GtkTreeModel *new_model = gtk_tree_model_filter_new (model, NULL);
- g_object_set_data (G_OBJECT (source), "model-copy", new_model);
+ g_object_set_data (G_OBJECT (source), "model-copy", new_model);
gtk_tree_view_set_model (source, new_model);
-
+
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (new_model),
is_source_item_visible,
selector,
{
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
- if (model == NULL)
+ if (model == NULL)
return;
g_signal_connect (model, "row-changed", G_CALLBACK (on_dest_data_change),
selector);
-
+
g_signal_connect (model, "row-deleted", G_CALLBACK (on_dest_data_delete),
selector);
g_signal_connect (selector, "destroy", G_CALLBACK (remove_selector_handlers), model);
-
+
if ( selector->selecting ) return;
-
+
refilter (selector);
}
{
set_tree_view_source (selector);
- g_signal_connect (selector->source, "notify::model",
- G_CALLBACK (update_model), selector);
+ g_signal_connect (selector->source, "notify::model",
+ G_CALLBACK (update_model), selector);
update_model (GTK_TREE_VIEW (selector->source), 0, selector);
}
GObjectClass *class = G_OBJECT_GET_CLASS (selector);
GType type = G_OBJECT_TYPE (selector->dest);
- SelectItemsFunc *func =
+ SelectItemsFunc *func =
g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type);
if ( func )
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* This file implements a GtkTreeModel. It allows GtkComboBox and
+/* This file implements a GtkTreeModel. It allows GtkComboBox and
GtkTreeView to display the names and non-empty cell ranges of the
sheets aka "Tables" of spreadsheet files.
It doesn't take any notice of the spreadsheet data itself.
const GValue * value,
GParamSpec * pspec)
{
- PsppireSpreadsheetModel *spreadsheetModel =
+ PsppireSpreadsheetModel *spreadsheetModel =
PSPPIRE_SPREADSHEET_MODEL (object);
switch (prop_id)
const char *x =
spreadsheet_get_sheet_name (spreadsheetModel->spreadsheet,
(intptr_t) iter->user_data);
-
+
g_value_set_string (value, x);
}
break;
iter->stamp = spreadsheetModel->stamp;
iter->user_data = 0;
-
+
return TRUE;
}
{
GtkTextIter begin, end;
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (sw->buffer);
-
+
if ( gtk_text_buffer_get_selection_bounds (buffer, &begin, &end) )
gtk_text_buffer_delete (buffer, &begin, &end);
}
on_edit_cut (PsppireSyntaxWindow *sw)
{
GtkTextIter begin, end;
-
+
if ( set_clip (sw, &begin, &end))
gtk_text_buffer_delete (GTK_TEXT_BUFFER (sw->buffer), &begin, &end);
}
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (window->undo_menuitem));
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (window->redo_menuitem));
-
+
if (class->lan)
window->buffer = gtk_source_buffer_new_with_language (class->lan);
else
window->sb = get_widget_assert (xml, "statusbar2");
window->text_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->sb), "Text Context");
- g_signal_connect (window->buffer, "changed",
+ g_signal_connect (window->buffer, "changed",
G_CALLBACK (on_text_changed), window);
- g_signal_connect (window->buffer, "modified-changed",
+ g_signal_connect (window->buffer, "modified-changed",
G_CALLBACK (on_modified_changed), window);
{
GSimpleAction *print = g_simple_action_new ("print", NULL);
-
+
g_signal_connect_swapped (print, "activate",
G_CALLBACK (psppire_syntax_window_print), window);
-
+
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (print));
}
undo_redo_update (window);
- window->sel_handler = g_signal_connect_swapped (clip_primary, "owner-change",
+ window->sel_handler = g_signal_connect_swapped (clip_primary, "owner-change",
G_CALLBACK (selection_changed), window);
- window->ps_handler = g_signal_connect (clip_selection, "owner-change",
+ window->ps_handler = g_signal_connect (clip_selection, "owner-change",
G_CALLBACK (set_paste_sensitivity), window);
connect_help (xml);
{
GSimpleAction *open = g_simple_action_new ("open", NULL);
-
+
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (open));
g_signal_connect_swapped (open,
{
GSimpleAction *save = g_simple_action_new ("save", NULL);
-
+
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (save));
-
+
g_signal_connect_swapped (save,
"activate",
G_CALLBACK (psppire_window_save),
gtk_application_set_accels_for_action (app,
"win.save",
accels);
-
+
}
{
GSimpleAction *save_as = g_simple_action_new ("save_as", NULL);
-
+
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (save_as));
-
+
g_signal_connect_swapped (save_as,
"activate",
G_CALLBACK (psppire_window_save_as),
gtk_application_set_accels_for_action (app,
"win.save_as",
accels);
-
-
+
+
}
{
GSimpleAction *run_selection = g_simple_action_new ("run-selection", NULL);
-
+
g_signal_connect_swapped (run_selection, "activate",
G_CALLBACK (on_run_selection), window);
{
GSimpleAction *run_to_end = g_simple_action_new ("run-to-end", NULL);
-
+
g_signal_connect_swapped (run_to_end, "activate",
G_CALLBACK (on_run_to_end), window);
-
+
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_to_end));
}
"description", _("Syntax Editor"),
"encoding", encoding,
NULL);
-
+
GApplication *app = g_application_get_default ();
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (sw));
{
gint n_pages = gtk_source_print_compositor_get_n_pages (window->compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
-
+
return TRUE;
}
gint page_nr,
PsppireSyntaxWindow *window)
{
- gtk_source_print_compositor_draw_page (window->compositor,
+ gtk_source_print_compositor_draw_page (window->compositor,
context,
page_nr);
}
GtkPrintOperation *print = gtk_print_operation_new ();
- if (window->print_settings != NULL)
+ if (window->print_settings != NULL)
gtk_print_operation_set_print_settings (print, window->print_settings);
};
-enum
+enum
{
VC_VALUE,
VC_SYSMIS,
gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_SYSMIS].rb), !vr->input_var_is_string);
gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_MISSING].rb), !vr->input_var_is_string);
gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_RANGE].rb), !vr->input_var_is_string);
- gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_LOW_UP].rb), !vr->input_var_is_string);
+ gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_LOW_UP].rb), !vr->input_var_is_string);
gtk_widget_set_sensitive (GTK_WIDGET (vr->rw[VC_HIGH_DOWN].rb), !vr->input_var_is_string);
break;
default:
static void lo_up_set (PsppireValChooser *vr, struct old_value *ov, const struct range_widgets *rw)
{
const gchar *text = gtk_entry_get_text (rw->e1);
-
+
ov->type = OV_LOW_UP;
ov->v.range[1] = g_strtod (text, 0);
}
static void hi_down_set (PsppireValChooser *vr, struct old_value *ov, const struct range_widgets *rw)
{
const gchar *text = gtk_entry_get_text (rw->e1);
-
+
ov->type = OV_HIGH_DOWN;
ov->v.range[0] = g_strtod (text, 0);
}
ov->type = OV_RANGE;
ov->v.range[0] = g_strtod (text, 0);
-
+
text = gtk_entry_get_text (rw->e2);
ov->v.range[1] = g_strtod (text, 0);
}
"valign", GTK_ALIGN_CENTER,
"halign", GTK_ALIGN_START,
NULL);
-
+
g_signal_connect (vbox, "notify::sensitive", G_CALLBACK (focus_follows_sensitivity), entrylo);
}
-static struct layout range_opt[n_VAL_CHOOSER_BUTTONS]=
+static struct layout range_opt[n_VAL_CHOOSER_BUTTONS]=
{
{N_("_Value:"), simple_entry, simple_set },
{N_("_System Missing"), NULL, sysmis_set },
"margin-start", 5,
"margin-end", 5,
NULL);
-
+
vr->input_var_is_string = FALSE;
for (i = 0; i < n_VAL_CHOOSER_BUTTONS; ++i)
0, row, 1, 1);
gtk_widget_set_hexpand (GTK_WIDGET (vr->rw[i].rb), FALSE);
-
+
/* Attach the labels */
gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (vr->rw[i].label),
1, row, 1, 1);
gtk_widget_set_hexpand (GTK_WIDGET (vr->rw[i].label), TRUE);
-
+
++row;
if (l->fill)
gtk_grid_attach (GTK_GRID (grid), fill, 1, row, 1, 1);
gtk_widget_set_hexpand (fill, TRUE);
-
+
++row;
g_signal_connect (vr->rw[i].rb, "toggled", G_CALLBACK (set_sensitivity_from_toggle), fill);
gtk_toggle_button_set_active (vr->rw[0].rb, TRUE);
gtk_entry_set_text (vr->rw[0].e1, ov->v.s);
break;
-
+
case OV_NUMERIC:
{
gchar *str;
gtk_toggle_button_set_active (vr->rw[0].rb, TRUE);
-
+
str = num_to_string (ov->v.v);
-
+
gtk_entry_set_text (vr->rw[0].e1, str);
g_free (str);
}
GtkEntryBuffer *buffer = gtk_entry_get_buffer (entry);
gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (w), COL_LABEL);
-
+
g_signal_connect (buffer, "notify::text",
G_CALLBACK (psppire_value_entry_text_changed), w);
typedef struct _PsppireValueEntry PsppireValueEntry;
typedef struct _PsppireValueEntryClass PsppireValueEntryClass;
-struct _PsppireValueEntry
+struct _PsppireValueEntry
{
GtkComboBox parent;
const union value *cur_value;
};
-struct _PsppireValueEntryClass
+struct _PsppireValueEntryClass
{
GtkComboBoxClass parent_class;
};
gtk_menu_attach (GTK_MENU (menu), clear_variables, 0, 1, i, i + 1); ++i;
gtk_widget_show_all (menu);
-
+
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, time);
}
if (var_sheet->dict)
g_object_unref (var_sheet->dict);
-
+
/* These dialogs are not GObjects (although they should be!)
But for now, unreffing them only causes a GCritical Error
so comment them out for now. (and accept the memory leakage)
PsppireDict *dict = var_sheet->dict;
const struct range_set_node *node;
struct range_set *selected = pspp_sheet_selection_get_range_set (selection);
-
+
for (node = range_set_last (selected); node != NULL;
node = range_set_prev (selected, node))
{
GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (var_sheet));
if (! PSPPIRE_IS_DATA_WINDOW (top))
return;
-
+
PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (top);
gtk_widget_set_sensitive (dw->mi_insert_var, n_selected_rows > 0);
-
+
switch (n_selected_rows)
{
case 0:
break;
}
- gtk_widget_set_sensitive (dw->mi_clear_variables, var_sheet->may_delete_vars && may_delete);
+ gtk_widget_set_sensitive (dw->mi_clear_variables, var_sheet->may_delete_vars && may_delete);
}
void
G_CALLBACK (on_query_var_tooltip), NULL);
g_signal_connect (obj, "button-press-event",
G_CALLBACK (on_button_pressed), NULL);
-
+
g_signal_connect (obj, "popup-menu", G_CALLBACK (on_popup_menu), NULL);
g_signal_connect (pspp_sheet_view_get_selection (sheet_view),
if (var_sheet->dict != NULL)
{
int i;
-
+
for (i = 0; i < PSPPIRE_VAR_SHEET_N_SIGNALS; i++)
{
if (var_sheet->dict_signals[i])
g_signal_handler_disconnect (var_sheet->dict,
var_sheet->dict_signals[i]);
-
+
var_sheet->dict_signals[i] = 0;
}
return psppire_var_view_type;
}
-void
+void
psppire_var_view_clear (PsppireVarView *vv)
{
GtkListStore *l = gtk_list_store_newv (vv->n_cols, vv->cols);
{
gint c;
var_view->nums = g_malloc (sizeof *var_view->nums * var_view->n_cols);
-
+
for (c = 0 ; c < var_view->n_cols; ++c)
{
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GtkTreeViewColumn *col = gtk_tree_view_column_new ();
-
+
gchar *label = g_strdup_printf (_("Var%d"), c + 1);
-
+
gtk_tree_view_column_set_min_width (col, 100);
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_title (col, label);
-
+
g_free (label);
-
+
var_view->nums[c] = c;
-
+
gtk_tree_view_column_pack_start (col, renderer, TRUE);
gtk_tree_view_column_set_cell_data_func (col, renderer,
display_cell_var_name,
&var_view->nums[c], 0);
-
+
gtk_tree_view_append_column (GTK_TREE_VIEW (var_view), col);
}
}
{
GtkTreeIter iter;
GSList *list = NULL;
-
+
if ( psppire_var_view_get_iter_first (vv, &iter) )
{
do
Append the names of selected variables to STR
Returns the number of variables appended.
*/
-gint
+gint
psppire_var_view_append_names_str (PsppireVarView *vv, gint column, struct string *str)
{
gint n_vars = 0;
/*
This is an abstract base class upon which all (well almost all) windows in
- psppire are based. The exceptions are transient windows such as the
+ psppire are based. The exceptions are transient windows such as the
splash screen and popups.
It currently provides the feature where the window's geometry "persists"
return FALSE;
}
-static void
+static void
psppire_window_base_class_init (PsppireWindowBaseClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = realize;
}
-static void
+static void
psppire_window_base_init (PsppireWindowBase *window)
{
}
/*
This is an abstract base class upon which all (well almost all) windows in
- psppire are based. The exceptions are transient windows such as the
+ psppire are based. The exceptions are transient windows such as the
splash screen and popups.
*/
GObjectConstructParam *construct_params)
{
GObject *object;
-
+
if (!the_instance)
{
object = G_OBJECT_CLASS (parent_class)->constructor (type,
sscanf (bare_version, "%*d.%d.%*d", &minor);
if (minor % 2)
g_string_append_printf (title, " - Test version! Please report bugs to %s", PACKAGE_BUGREPORT);
-
+
gtk_window_set_title (GTK_WINDOW (window), title->str);
g_string_free (title, TRUE);
filename = g_filename_display_name (key);
item = gtk_check_menu_item_new_with_label (filename);
g_free (filename);
-
+
g_hash_table_insert (window->menuitem_table, key, item);
}
insert_menuitem (GObject *reg, const gchar *key, gpointer data)
{
PsppireWindow *window = PSPPIRE_WINDOW (data);
-
+
insert_menuitem_into_menu (window, (gpointer) key);
}
window_model_type =
g_type_register_static (G_TYPE_INTERFACE, "PsppireWindowModel",
&window_model_info, 0);
-
+
g_type_interface_add_prerequisite (window_model_type, G_TYPE_OBJECT);
}
psppire_preload_file (const gchar *file)
{
const gchar *local_encoding = "UTF-8";
-
+
struct file_handle *fh = fh_create_file (NULL,
file,
local_encoding,
fh_default_properties ());
const char *filename = fh_get_file_name (fh);
-
+
int retval = any_reader_detect (fh, NULL);
GtkWindow *w = NULL;
proto = casereader_get_proto (reader);
nvals = caseproto_get_n_widths (proto);
-
+
for (; (c = casereader_read (reader)) != NULL; case_unref (c))
{
int i;
{
char *ss = xzalloc (width + 1);
memcpy (ss, value_str (val, width), width);
-
+
printf ("%s ", ss);
free (ss);
}
casereader_destroy (reader);
}
-static void
+static void
print_msg (const struct msg *m, void *aux UNUSED)
{
fprintf (stderr, "%s\n", m->text);
settings_init ();
gtk_init (&argc, &argv);
-
+
if ( argc < 2)
g_error ("Usage: prog file\n");
if (stuff.sp == NULL)
stuff.sp = ods_probe (argv[1], false);
-
+
if (stuff.sp == NULL)
{
g_error ("%s is neither a gnumeric nor a ods file\n", argv[1]);
button = gtk_button_new_with_label ("Test reader");
g_signal_connect (button, "clicked", G_CALLBACK (on_clicked), &stuff);
-
+
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
-
+
stuff.combo_box = gtk_combo_box_new();
{
tto->confidence =
psppire_scanf_new (_("Con_fidence Interval: %2d %%"), &tto->conf_percent);
-
- g_object_set (tto->confidence,
- "use-underline", TRUE,
+
+ g_object_set (tto->confidence,
+ "use-underline", TRUE,
"mnemonic-widget", psppire_scanf_get_child (PSPPIRE_SCANF (tto->confidence), 0),
NULL);
if (vl != NULL)
*label = val_lab_get_escaped_label (vl);
}
-
+
return TRUE;
}
if (! get_selected_tuple (dialog, &value, NULL))
return;
-
+
vl = val_labs_lookup (dialog->labs, &value);
if (vl != NULL)
val_labs_remove (dialog->labs, vl);
if (! get_selected_tuple (dialog, &value, &label))
return;
-
+
text = value_to_text__ (value, &dialog->format, dialog->encoding);
g_signal_handler_block (GTK_ENTRY (dialog->value_entry),
/* Any custom widgets which are to be used in GtkBuilder ui files
- need to be preregistered, otherwise GtkBuilder refuses to
+ need to be preregistered, otherwise GtkBuilder refuses to
acknowledge their existence. */
void
preregister_widgets (void)
if (state == TRUE)
gtk_window_present (win);
-
+
/* Prevent the state from actually changing */
g_signal_handlers_block_by_func (widget, reset_check_state, ud);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), !state);
GtkWidget *minimize = gtk_menu_item_new_with_mnemonic (_("_Minimize all Windows"));
GtkWidget *split = gtk_check_menu_item_new_with_mnemonic (_("_Split"));
-
+
GtkWidget *sep = gtk_separator_menu_item_new ();
-
+
gtk_menu_attach (GTK_MENU (menu), minimize, 0, 1, 0, 1);
if (PSPPIRE_DATA_WINDOW_TYPE == G_OBJECT_TYPE (toplevel) )
g_signal_connect_swapped (split, "toggled",
G_CALLBACK (toggle_split_window), toplevel);
}
-
+
gtk_container_add (GTK_CONTAINER (menu), sep);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
g_object_set_data (G_OBJECT (menu), "toplevel", toplevel);
-
+
g_hash_table_foreach (reg->name_table, add_menuitem, menu);
g_signal_connect (minimize, "activate", G_CALLBACK (min_all), NULL);
-
+
gtk_widget_show_all (GTK_WIDGET (mi));
}
create_windows_menu (GtkWindow *toplevel)
{
PsppireWindowRegister *reg = psppire_window_register_new ();
-
+
GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_Windows"));
g_object_set_data (G_OBJECT (menuitem), "toplevel", toplevel);
-
+
g_signal_connect (reg, "removed", G_CALLBACK (repopulate_windows_menu), menuitem);
g_signal_connect (reg, "inserted", G_CALLBACK (repopulate_windows_menu), menuitem);
}
conv[x++] = directive;
conv[x++] = '\0';
-
+
ds_put_c_format (output, conv, d);
break;
}
return to;
}
-/* Return true iff the terminal appears to be an xterm with
+/* Return true iff the terminal appears to be an xterm with
UTF-8 capabilities */
static bool
term_is_utf8_xterm (void)
{
string_map_insert (&to->options, "box", "unicode");
}
-
+
string_map_insert (&to->options, "output-file", "-");
string_map_insert (&to->options, "format", "txt");
register_output_driver (to);
if (0 == tcgetattr (0, &t))
{
cc_t c = t.c_cc[VINTR];
-
+
if (c >= 0 && c <= 'Z' - 'A')
fprintf (rl_outstream, "^%c", 'A' + c - 1);
else
fprintf (rl_outstream, "^C");
fflush (rl_outstream);
-}
+}
#endif
#endif
static bool sigint_received ;
-/*
+/*
A function similar to getc from stdio.
However this one may be interrupted by SIGINT.
If that happens it will return EOF and the global variable
#if HAVE_READLINE
-static void
+static void
handler (int sig)
{
rl_end = 0;
free (history_file);
}
-/* Prompt the user for a line of input and return it in LINE.
+/* Prompt the user for a line of input and return it in LINE.
Returns true if the LINE should be considered valid, false otherwise.
*/
static bool
fflush (stdout);
ds_init_empty (&string);
ds_read_line (&string, stdin, SIZE_MAX);
-
+
*line = string.ss;
-
+
return false;
}
#endif /* !HAVE_READLINE */
typedef size_t hash_function (int data);
static size_t
-identity_hash (int data)
+identity_hash (int data)
{
return data;
}
static size_t
-constant_hash (int data UNUSED)
+constant_hash (int data UNUSED)
{
return 0x12345678u;
}
count = 0;
HMAP_FOR_EACH_WITH_HASH (e, struct element, node, hash (order[i]), hmap)
- if (e->data == order[i])
+ if (e->data == order[i])
count++;
check (count == j - i);
check (hmap_node_hash (&e->node) == hash (e->data));
for (j = 0; j < left; j++)
- if (order[j] == e->data)
+ if (order[j] == e->data)
{
order[j] = order[--left];
goto next;
}
static void
-test_insert_any_remove_any_random_hash (void)
+test_insert_any_remove_any_random_hash (void)
{
test_insert_any_remove_any (random_hash);
}
static void
-test_insert_any_remove_any_identity_hash (void)
+test_insert_any_remove_any_identity_hash (void)
{
test_insert_any_remove_any (identity_hash);
}
static void
-test_insert_any_remove_any_constant_hash (void)
+test_insert_any_remove_any_constant_hash (void)
{
test_insert_any_remove_any (constant_hash);
}
}
static void
-test_insert_any_remove_same_random_hash (void)
+test_insert_any_remove_same_random_hash (void)
{
test_insert_any_remove_same (random_hash);
}
static void
-test_insert_any_remove_same_identity_hash (void)
+test_insert_any_remove_same_identity_hash (void)
{
test_insert_any_remove_same (identity_hash);
}
static void
-test_insert_any_remove_same_constant_hash (void)
+test_insert_any_remove_same_constant_hash (void)
{
test_insert_any_remove_same (constant_hash);
}
}
static void
-test_random_sequence_random_hash (void)
+test_random_sequence_random_hash (void)
{
test_random_sequence (64, random_hash);
}
static void
-test_random_sequence_identity_hash (void)
+test_random_sequence_identity_hash (void)
{
test_random_sequence (64, identity_hash);
}
static void
-test_random_sequence_constant_hash (void)
+test_random_sequence_constant_hash (void)
{
test_random_sequence (32, constant_hash);
}
hmap_insert (&hmap, &elements[i].node, hash (elements[i].data));
check_hmap (&hmap, values, i + 1, hash);
- if (hash == identity_hash)
+ if (hash == identity_hash)
{
/* Check that every every hash bucket has (almost) the
same number of nodes in it. */
int max = INT_MIN;
int j;
- for (j = 0; j <= hmap.mask; j++)
+ for (j = 0; j <= hmap.mask; j++)
{
int count = 0;
struct hmap_node *node;
}
static void
-test_moved_random_hash (void)
+test_moved_random_hash (void)
{
test_moved (128, random_hash);
}
static void
-test_moved_identity_hash (void)
+test_moved_identity_hash (void)
{
test_moved (128, identity_hash);
}
static void
-test_moved_constant_hash (void)
+test_moved_constant_hash (void)
{
test_moved (32, constant_hash);
}
}
static void
-test_swap (int max_elems, hash_function *hash)
+test_swap (int max_elems, hash_function *hash)
{
struct element *elements;
int *values;
}
static void
-test_swap_random_hash (void)
+test_swap_random_hash (void)
{
test_swap (128, random_hash);
}
}
static void
-test_destroy_null (void)
+test_destroy_null (void)
{
hmap_destroy (NULL);
}
typedef size_t hash_function (int data);
static size_t
-identity_hash (int data)
+identity_hash (int data)
{
return data;
}
static size_t
-constant_hash (int data UNUSED)
+constant_hash (int data UNUSED)
{
return 0x12345678u;
}
count = 0;
HMAPX_FOR_EACH_WITH_HASH (e, node, hash (order[i]), hmapx)
- if (e->data == order[i])
- count++;
+ if (e->data == order[i])
+ count++;
check (count == j - i);
}
check (hmapx_node_hash (p) == hash (e->data));
for (j = 0; j < left; j++)
- if (order[j] == e->data)
+ if (order[j] == e->data)
{
order[j] = order[--left];
goto next;
check_hmapx (&hmapx, insertions, i + 1, hash);
/* A series of insertions should not produce a shrinkable hmapx. */
- if (i >= reserve)
+ if (i >= reserve)
{
capacity = hmapx_capacity (&hmapx);
hmapx_shrink (&hmapx);
- check (capacity == hmapx_capacity (&hmapx));
+ check (capacity == hmapx_capacity (&hmapx));
}
}
for (i = 0; i < cnt; i++)
}
static void
-test_insert_any_remove_any_random_hash (void)
+test_insert_any_remove_any_random_hash (void)
{
test_insert_any_remove_any (random_hash);
}
static void
-test_insert_any_remove_any_identity_hash (void)
+test_insert_any_remove_any_identity_hash (void)
{
test_insert_any_remove_any (identity_hash);
}
static void
-test_insert_any_remove_any_constant_hash (void)
+test_insert_any_remove_any_constant_hash (void)
{
test_insert_any_remove_any (constant_hash);
}
}
static void
-test_insert_any_remove_same_random_hash (void)
+test_insert_any_remove_same_random_hash (void)
{
test_insert_any_remove_same (random_hash);
}
static void
-test_insert_any_remove_same_identity_hash (void)
+test_insert_any_remove_same_identity_hash (void)
{
test_insert_any_remove_same (identity_hash);
}
static void
-test_insert_any_remove_same_constant_hash (void)
+test_insert_any_remove_same_constant_hash (void)
{
test_insert_any_remove_same (constant_hash);
}
}
static void
-test_random_sequence_random_hash (void)
+test_random_sequence_random_hash (void)
{
test_random_sequence (64, random_hash);
}
static void
-test_random_sequence_identity_hash (void)
+test_random_sequence_identity_hash (void)
{
test_random_sequence (64, identity_hash);
}
static void
-test_random_sequence_constant_hash (void)
+test_random_sequence_constant_hash (void)
{
test_random_sequence (32, constant_hash);
}
nodes[i] = hmapx_insert (&hmapx, &elements[i], hash (elements[i].data));
check_hmapx (&hmapx, values, i + 1, hash);
- if (hash == identity_hash)
+ if (hash == identity_hash)
{
/* Check that every every hash bucket has (almost) the
same number of nodes in it. */
int max = INT_MIN;
int j;
- for (j = 0; j <= hmapx.hmap.mask; j++)
+ for (j = 0; j <= hmapx.hmap.mask; j++)
{
int count = 0;
struct hmap_node *node;
}
static void
-test_moved_random_hash (void)
+test_moved_random_hash (void)
{
test_moved (128, random_hash);
}
static void
-test_moved_identity_hash (void)
+test_moved_identity_hash (void)
{
test_moved (128, identity_hash);
}
static void
-test_moved_constant_hash (void)
+test_moved_constant_hash (void)
{
test_moved (32, constant_hash);
}
/* Change value i to j. */
elements[i].data = j;
- hmapx_changed (&hmapx, nodes[i],
+ hmapx_changed (&hmapx, nodes[i],
hash (elements[i].data));
for (k = 0; k < cnt; k++)
changed_values[k] = k;
}
static void
-test_swap (int max_elems, hash_function *hash)
+test_swap (int max_elems, hash_function *hash)
{
struct element *elements;
int *values;
}
static void
-test_swap_random_hash (void)
+test_swap_random_hash (void)
{
test_swap (128, random_hash);
}
}
static void
-test_destroy_null (void)
+test_destroy_null (void)
{
hmapx_destroy (NULL);
}
}
zip_reader_destroy (zr);
}
- else
+ else
exit (1);
return 0;
assert (n_ticks <= 10);
#if 0
- printf("%s: high: %lg, low %lg, interval: %lg, nticks: %d\n",
+ printf("%s: high: %lg, low %lg, interval: %lg, nticks: %d\n",
__FUNCTION__, high, low, interval, n_ticks);
dump_scale (lower, interval, n_ticks);
#endif
}
-int
+int
main (int argc UNUSED, char **argv UNUSED)
{
test_range (0, 0);
test_range (-50010, -49999);
test_range (0.000100002, 0.000100010);
- test_range (102, 50030);
- test_range (0.00102, 0.0050030);
+ test_range (102, 50030);
+ test_range (0.00102, 0.0050030);
return 0;
}
va_start (args, format);
ds_init_empty (&syntax);
-
+
syntax_gen_pspp_valist (&syntax, format, args);
va_end (args);
puts (ds_cstr (&syntax));
- ds_destroy (&syntax);
+ ds_destroy (&syntax);
}
int
if (! decrypt_file (enc, input_fh, output_fh, password))
goto error;
-
+
goto exit;
}
if (argc - optind > 1)
printf ("Reading \"%s\":\n", r.file_name);
-
+
read_header (&r);
while ((rec_type = read_int (&r)) != 999)
{
fclose (r.file);
}
-
+
return 0;
}
const char *key;
int index;
- for (;;)
+ for (;;)
{
key = text_tokenize (text, '(');
if (key == NULL)
return true;
-
+
for (index = 1; ; index++)
{
/* Parse the value. */
const char *value = text_tokenize (text, '\n');
- if (value == NULL)
+ if (value == NULL)
{
sys_warn (r, "%s: Error parsing attribute value %s[%d]",
variable, key, index);
}
if (text_match (text, '/'))
- return true;
+ return true;
}
}
}
static void
-read_datafile_attributes (struct sfm_reader *r, size_t size, size_t count)
+read_datafile_attributes (struct sfm_reader *r, size_t size, size_t count)
{
struct text_record *text;
-
+
printf ("%08llx: datafile attributes\n", (long long int) ftello (r->file));
text = open_text_record (r, size * count);
read_attributes (r, text, "datafile");
}
static void
-read_variable_attributes (struct sfm_reader *r, size_t size, size_t count)
+read_variable_attributes (struct sfm_reader *r, size_t size, size_t count)
{
struct text_record *text;
-
+
printf ("%08llx: variable attributes\n", (long long int) ftello (r->file));
text = open_text_record (r, size * count);
- for (;;)
+ for (;;)
{
const char *variable = text_tokenize (text, ':');
if (variable == NULL || !read_attributes (r, text, variable))
- break;
+ break;
}
close_text_record (text);
}
}
static bool
-text_match (struct text_record *text, int c)
+text_match (struct text_record *text, int c)
{
- if (text->pos < text->size && text->buffer[text->pos] == c)
+ if (text->pos < text->size && text->buffer[text->pos] == c)
{
text->pos++;
return true;