From 37fdb53cc4baf4624d46993e24e7f8c1ec135f18 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 20 Jun 2023 22:11:51 +0200 Subject: [PATCH] Change TAB characters to spaces Most of our code is indented with four spaces. However some files had been using tabs. Some code used both tabs and spaces in the same file!. This change replaces all tabs with eight spaces. --- lib/linreg/sweep.c | 104 +-- lib/tukey/ptukey.c | 306 +++---- lib/tukey/qtukey.c | 136 +-- perl-module/ppport.h | 226 ++--- src/data/any-reader.h | 2 +- src/data/case.h | 2 +- src/data/casereader-filter.c | 18 +- src/data/casereader-translator.c | 88 +- src/data/casereader.h | 16 +- src/data/casewriter.c | 4 +- src/data/csv-file-writer.c | 2 +- src/data/data-in.c | 2 +- src/data/data-out.c | 10 +- src/data/dataset.c | 2 +- src/data/datasheet.c | 8 +- src/data/dictionary.c | 26 +- src/data/dictionary.h | 8 +- src/data/file-handle-def.c | 50 +- src/data/file-name.c | 26 +- src/data/format.c | 6 +- src/data/format.h | 6 +- src/data/gnumeric-reader.c | 610 ++++++------- src/data/make-file.c | 14 +- src/data/mdd-writer.c | 4 +- src/data/ods-reader.c | 438 +++++----- src/data/pc+-file-reader.c | 4 +- src/data/por-file-reader.c | 82 +- src/data/por-file-writer.c | 6 +- src/data/psql-reader.c | 816 +++++++++--------- src/data/settings.c | 22 +- src/data/spreadsheet-reader.c | 8 +- src/data/spreadsheet-reader.h | 8 +- src/data/subcase.h | 8 +- src/data/sys-file-reader.c | 24 +- src/data/sys-file-writer.c | 12 +- src/data/variable.c | 18 +- src/data/variable.h | 6 +- src/language/command.c | 16 +- src/language/command.h | 2 +- src/language/commands/aggregate.c | 244 +++--- src/language/commands/apply-dictionary.c | 24 +- src/language/commands/binomial.c | 88 +- src/language/commands/binomial.h | 6 +- src/language/commands/chisquare.c | 74 +- src/language/commands/chisquare.h | 8 +- src/language/commands/cochran.c | 72 +- src/language/commands/cochran.h | 10 +- src/language/commands/combine-files.c | 36 +- src/language/commands/compute.c | 26 +- src/language/commands/correlations.c | 112 +-- src/language/commands/count.c | 70 +- src/language/commands/crosstabs.c | 368 ++++---- src/language/commands/data-list.c | 124 +-- src/language/commands/data-parser.c | 44 +- src/language/commands/data-parser.h | 10 +- src/language/commands/descriptives.c | 98 +-- src/language/commands/examine.c | 302 +++---- src/language/commands/factor.c | 772 ++++++++--------- src/language/commands/fail.c | 2 +- src/language/commands/file-handle.c | 2 +- src/language/commands/flip.c | 32 +- src/language/commands/formats.c | 24 +- src/language/commands/freq.c | 2 +- src/language/commands/freq.h | 2 +- src/language/commands/frequencies.c | 356 ++++---- src/language/commands/friedman.c | 98 +-- src/language/commands/friedman.h | 10 +- src/language/commands/get-data.c | 162 ++-- src/language/commands/get.c | 26 +- src/language/commands/glm.c | 284 +++--- src/language/commands/graph.c | 502 +++++------ src/language/commands/include.c | 76 +- src/language/commands/inpt-pgm.c | 58 +- src/language/commands/jonckheere-terpstra.c | 24 +- src/language/commands/jonckheere-terpstra.h | 12 +- src/language/commands/kruskal-wallis.c | 104 +-- src/language/commands/kruskal-wallis.h | 12 +- src/language/commands/ks-one-sample.c | 168 ++-- src/language/commands/ks-one-sample.h | 8 +- src/language/commands/logistic.c | 540 ++++++------ src/language/commands/loop.c | 2 +- src/language/commands/mann-whitney.c | 108 +-- src/language/commands/mann-whitney.h | 12 +- src/language/commands/matrix-data.c | 86 +- src/language/commands/matrix.c | 54 +- src/language/commands/mcnemar.c | 126 +-- src/language/commands/mcnemar.h | 10 +- src/language/commands/means-parser.c | 118 +-- src/language/commands/means.c | 580 ++++++------- src/language/commands/median.c | 286 +++--- src/language/commands/median.h | 12 +- src/language/commands/npar-summary.c | 26 +- src/language/commands/npar-summary.h | 12 +- src/language/commands/npar.c | 158 ++-- src/language/commands/npar.h | 10 +- src/language/commands/numeric.c | 60 +- src/language/commands/oneway.c | 402 ++++----- src/language/commands/output.c | 82 +- src/language/commands/permissions.c | 4 +- src/language/commands/placement-parser.c | 40 +- src/language/commands/print-space.c | 20 +- src/language/commands/print.c | 78 +- src/language/commands/quick-cluster.c | 648 +++++++------- src/language/commands/rank.c | 232 ++--- src/language/commands/recode.c | 68 +- src/language/commands/regression.c | 188 ++-- src/language/commands/reliability.c | 168 ++-- src/language/commands/rename-variables.c | 26 +- src/language/commands/repeat.c | 44 +- src/language/commands/roc.c | 374 ++++---- src/language/commands/runs.c | 306 +++---- src/language/commands/runs.h | 8 +- src/language/commands/sample.c | 14 +- src/language/commands/save-translate.c | 12 +- src/language/commands/save.c | 42 +- src/language/commands/select-if.c | 20 +- src/language/commands/set.c | 6 +- src/language/commands/sign.c | 60 +- src/language/commands/sign.h | 10 +- src/language/commands/sort-criteria.c | 16 +- src/language/commands/split-file.c | 2 +- src/language/commands/sys-file-info.c | 22 +- src/language/commands/t-test-indep.c | 64 +- src/language/commands/t-test-one-sample.c | 28 +- src/language/commands/t-test-paired.c | 38 +- src/language/commands/t-test.h | 6 +- src/language/commands/trim.c | 6 +- src/language/commands/value-labels.c | 26 +- src/language/commands/variable-display.c | 10 +- src/language/commands/variable-label.c | 10 +- src/language/commands/vector.c | 70 +- src/language/commands/weight.c | 18 +- src/language/commands/wilcoxon.c | 126 +-- src/language/commands/wilcoxon.h | 12 +- src/language/expressions/evaluate.c | 18 +- src/language/expressions/optimize.c | 10 +- src/language/expressions/parse.c | 14 +- src/language/lexer/lexer.c | 12 +- src/language/lexer/variable-parser.c | 78 +- src/language/lexer/variable-parser.h | 18 +- src/language/tests/pool-test.c | 70 +- src/libpspp/array.c | 130 +-- src/libpspp/copyleft.c | 12 +- src/libpspp/freaderror.c | 4 +- src/libpspp/i18n.c | 24 +- src/libpspp/i18n.h | 2 +- src/libpspp/message.h | 6 +- src/libpspp/misc.c | 8 +- src/libpspp/pool.c | 160 ++-- src/libpspp/prompt.h | 4 +- src/libpspp/str.c | 10 +- src/libpspp/str.h | 4 +- src/libpspp/taint.c | 34 +- src/libpspp/zip-reader.c | 34 +- src/math/box-whisker.c | 6 +- src/math/chart-geometry.c | 56 +- src/math/chart-geometry.h | 4 +- src/math/correlation.c | 28 +- src/math/covariance.c | 342 ++++---- src/math/covariance.h | 6 +- src/math/histogram.c | 8 +- src/math/interaction.h | 2 +- src/math/levene.c | 6 +- src/math/linreg.c | 122 +-- src/math/linreg.h | 2 +- src/math/order-stats.c | 20 +- src/math/order-stats.h | 8 +- src/math/percentiles.c | 84 +- src/math/shapiro-wilk.c | 6 +- src/math/tukey-hinges.c | 30 +- src/output/cairo-chart.c | 120 +-- src/output/cairo-chart.h | 8 +- src/output/cairo-fsm.c | 26 +- src/output/charts/barchart-cairo.c | 110 +-- src/output/charts/barchart.c | 206 ++--- src/output/charts/barchart.h | 2 +- src/output/charts/boxplot-cairo.c | 4 +- src/output/charts/piechart-cairo.c | 34 +- src/output/charts/piechart.c | 8 +- src/output/charts/plot-hist-cairo.c | 20 +- src/output/charts/roc-chart-cairo.c | 14 +- src/output/charts/scatterplot-cairo.c | 62 +- src/output/charts/scatterplot.c | 12 +- src/output/charts/scatterplot.h | 12 +- src/output/driver.c | 2 +- src/output/html.c | 120 +-- src/output/journal.c | 6 +- src/output/measure.c | 10 +- src/output/odt.c | 60 +- src/output/render.c | 18 +- src/output/table.h | 6 +- src/ui/gui/builder-wrapper.c | 2 +- src/ui/gui/dialog-common.c | 32 +- src/ui/gui/dialog-common.h | 8 +- src/ui/gui/dict-display.c | 64 +- src/ui/gui/dict-display.h | 26 +- src/ui/gui/dummy.c | 2 +- src/ui/gui/executor.c | 12 +- src/ui/gui/find-dialog.c | 90 +- src/ui/gui/goto-case-dialog.c | 10 +- src/ui/gui/help-menu.c | 22 +- src/ui/gui/helper.c | 40 +- src/ui/gui/main.c | 16 +- src/ui/gui/missing-val-dialog.c | 180 ++-- src/ui/gui/options-dialog.c | 66 +- src/ui/gui/psppire-acr.c | 68 +- src/ui/gui/psppire-acr.h | 24 +- src/ui/gui/psppire-buttonbox.c | 90 +- src/ui/gui/psppire-checkbox-treeview.c | 14 +- src/ui/gui/psppire-checkbox-treeview.h | 6 +- src/ui/gui/psppire-conf.c | 82 +- src/ui/gui/psppire-conf.h | 56 +- src/ui/gui/psppire-data-editor.c | 134 +-- src/ui/gui/psppire-data-sheet.c | 60 +- src/ui/gui/psppire-data-store.c | 152 ++-- src/ui/gui/psppire-data-store.h | 32 +- src/ui/gui/psppire-data-window.c | 252 +++--- src/ui/gui/psppire-delimited-text.c | 72 +- src/ui/gui/psppire-delimited-text.h | 4 +- src/ui/gui/psppire-dialog-action-1sks.c | 2 +- src/ui/gui/psppire-dialog-action-1sks.h | 12 +- src/ui/gui/psppire-dialog-action-aggregate.c | 132 +-- src/ui/gui/psppire-dialog-action-aggregate.h | 12 +- src/ui/gui/psppire-dialog-action-autorecode.c | 50 +- src/ui/gui/psppire-dialog-action-autorecode.h | 12 +- src/ui/gui/psppire-dialog-action-barchart.c | 66 +- src/ui/gui/psppire-dialog-action-barchart.h | 12 +- src/ui/gui/psppire-dialog-action-binomial.c | 4 +- src/ui/gui/psppire-dialog-action-binomial.h | 12 +- src/ui/gui/psppire-dialog-action-chisquare.c | 34 +- src/ui/gui/psppire-dialog-action-chisquare.h | 12 +- src/ui/gui/psppire-dialog-action-comments.c | 20 +- src/ui/gui/psppire-dialog-action-comments.h | 12 +- src/ui/gui/psppire-dialog-action-compute.c | 92 +- src/ui/gui/psppire-dialog-action-compute.h | 12 +- .../gui/psppire-dialog-action-correlation.h | 12 +- src/ui/gui/psppire-dialog-action-count.c | 10 +- src/ui/gui/psppire-dialog-action-count.h | 12 +- src/ui/gui/psppire-dialog-action-crosstabs.c | 74 +- src/ui/gui/psppire-dialog-action-crosstabs.h | 12 +- src/ui/gui/psppire-dialog-action-ctables.h | 12 +- .../gui/psppire-dialog-action-descriptives.c | 10 +- .../gui/psppire-dialog-action-descriptives.h | 12 +- src/ui/gui/psppire-dialog-action-examine.c | 146 ++-- src/ui/gui/psppire-dialog-action-examine.h | 12 +- src/ui/gui/psppire-dialog-action-factor.c | 12 +- src/ui/gui/psppire-dialog-action-factor.h | 12 +- src/ui/gui/psppire-dialog-action-flip.h | 12 +- .../gui/psppire-dialog-action-frequencies.c | 52 +- .../gui/psppire-dialog-action-frequencies.h | 12 +- src/ui/gui/psppire-dialog-action-histogram.c | 4 +- src/ui/gui/psppire-dialog-action-histogram.h | 12 +- .../gui/psppire-dialog-action-indep-samps.c | 74 +- .../gui/psppire-dialog-action-indep-samps.h | 12 +- .../gui/psppire-dialog-action-k-independent.c | 42 +- .../gui/psppire-dialog-action-k-independent.h | 12 +- src/ui/gui/psppire-dialog-action-k-related.c | 4 +- src/ui/gui/psppire-dialog-action-k-related.h | 12 +- src/ui/gui/psppire-dialog-action-kmeans.c | 2 +- src/ui/gui/psppire-dialog-action-kmeans.h | 12 +- src/ui/gui/psppire-dialog-action-logistic.c | 16 +- src/ui/gui/psppire-dialog-action-logistic.h | 12 +- src/ui/gui/psppire-dialog-action-means.c | 16 +- src/ui/gui/psppire-dialog-action-means.h | 12 +- src/ui/gui/psppire-dialog-action-oneway.c | 78 +- src/ui/gui/psppire-dialog-action-oneway.h | 12 +- src/ui/gui/psppire-dialog-action-paired.c | 30 +- src/ui/gui/psppire-dialog-action-paired.h | 12 +- src/ui/gui/psppire-dialog-action-rank.c | 34 +- src/ui/gui/psppire-dialog-action-rank.h | 12 +- .../psppire-dialog-action-recode-different.c | 96 +-- .../psppire-dialog-action-recode-different.h | 12 +- .../gui/psppire-dialog-action-recode-same.c | 10 +- .../gui/psppire-dialog-action-recode-same.h | 12 +- src/ui/gui/psppire-dialog-action-recode.c | 144 ++-- src/ui/gui/psppire-dialog-action-recode.h | 20 +- src/ui/gui/psppire-dialog-action-regression.c | 40 +- src/ui/gui/psppire-dialog-action-regression.h | 12 +- .../gui/psppire-dialog-action-reliability.c | 18 +- .../gui/psppire-dialog-action-reliability.h | 12 +- src/ui/gui/psppire-dialog-action-roc.c | 16 +- src/ui/gui/psppire-dialog-action-roc.h | 12 +- src/ui/gui/psppire-dialog-action-runs.c | 4 +- src/ui/gui/psppire-dialog-action-runs.h | 12 +- .../gui/psppire-dialog-action-scatterplot.h | 12 +- src/ui/gui/psppire-dialog-action-select.c | 244 +++--- src/ui/gui/psppire-dialog-action-select.h | 12 +- src/ui/gui/psppire-dialog-action-sort.c | 4 +- src/ui/gui/psppire-dialog-action-sort.h | 12 +- src/ui/gui/psppire-dialog-action-split.c | 56 +- src/ui/gui/psppire-dialog-action-split.h | 12 +- src/ui/gui/psppire-dialog-action-tt1s.c | 6 +- src/ui/gui/psppire-dialog-action-tt1s.h | 12 +- src/ui/gui/psppire-dialog-action-two-sample.c | 30 +- src/ui/gui/psppire-dialog-action-two-sample.h | 12 +- src/ui/gui/psppire-dialog-action-univariate.h | 12 +- src/ui/gui/psppire-dialog-action-var-info.c | 14 +- src/ui/gui/psppire-dialog-action-var-info.h | 12 +- src/ui/gui/psppire-dialog-action-weight.c | 12 +- src/ui/gui/psppire-dialog-action-weight.h | 12 +- src/ui/gui/psppire-dialog-action.c | 70 +- src/ui/gui/psppire-dialog-action.h | 16 +- src/ui/gui/psppire-dialog.c | 192 ++--- src/ui/gui/psppire-dialog.h | 4 +- src/ui/gui/psppire-dict.c | 204 ++--- src/ui/gui/psppire-dict.h | 4 +- src/ui/gui/psppire-dictview.c | 142 +-- src/ui/gui/psppire-import-assistant.c | 78 +- src/ui/gui/psppire-import-assistant.h | 12 +- src/ui/gui/psppire-import-spreadsheet.c | 8 +- src/ui/gui/psppire-import-textfile.c | 228 ++--- src/ui/gui/psppire-keypad.c | 70 +- src/ui/gui/psppire-keypad.h | 20 +- src/ui/gui/psppire-means-layer.c | 12 +- src/ui/gui/psppire-output-view.c | 114 +-- src/ui/gui/psppire-output-view.h | 2 +- src/ui/gui/psppire-output-window.c | 122 +-- src/ui/gui/psppire-scanf.c | 138 +-- src/ui/gui/psppire-search-dialog.c | 28 +- src/ui/gui/psppire-select-dest.c | 22 +- src/ui/gui/psppire-selector.c | 324 +++---- src/ui/gui/psppire-selector.h | 16 +- src/ui/gui/psppire-spreadsheet-data-model.c | 28 +- src/ui/gui/psppire-spreadsheet-data-model.h | 12 +- src/ui/gui/psppire-spreadsheet-model.c | 22 +- src/ui/gui/psppire-spreadsheet-model.h | 12 +- src/ui/gui/psppire-syntax-window.c | 182 ++-- src/ui/gui/psppire-text-file.c | 202 ++--- src/ui/gui/psppire-text-file.h | 4 +- src/ui/gui/psppire-val-chooser.c | 224 ++--- src/ui/gui/psppire-value-entry.c | 18 +- src/ui/gui/psppire-var-ptr.c | 12 +- src/ui/gui/psppire-var-sheet-header.c | 14 +- src/ui/gui/psppire-var-view.c | 84 +- src/ui/gui/psppire-variable-sheet.c | 92 +- src/ui/gui/psppire-window-register.c | 38 +- src/ui/gui/psppire-window-register.h | 16 +- src/ui/gui/psppire-window.c | 142 +-- src/ui/gui/psppire-window.h | 2 +- src/ui/gui/psppire.c | 14 +- src/ui/gui/spreadsheet-test.c | 40 +- src/ui/gui/t-test-options.c | 12 +- src/ui/gui/val-labs-dialog.c | 82 +- src/ui/gui/var-display.c | 62 +- src/ui/gui/var-type-dialog.c | 82 +- src/ui/gui/widget-io.c | 12 +- src/ui/gui/windows-menu.c | 4 +- src/ui/source-init-opts.c | 8 +- src/ui/syntax-gen.c | 12 +- src/ui/terminal/main.c | 2 +- src/ui/terminal/terminal-reader.c | 42 +- tests/data/datasheet-test.c | 2 +- tests/data/spreadsheet-test.c | 16 +- tests/libpspp/zip-test.c | 74 +- tests/math/chart-get-scale-test.c | 4 +- tests/math/chart-get-ticks-format-test.c | 2 +- utilities/pspp-convert.c | 6 +- utilities/pspp-dump-sav.c | 12 +- 358 files changed, 11301 insertions(+), 11301 deletions(-) diff --git a/lib/linreg/sweep.c b/lib/linreg/sweep.c index 536fb3b02c..9738d72b73 100644 --- a/lib/linreg/sweep.c +++ b/lib/linreg/sweep.c @@ -89,58 +89,58 @@ reg_sweep (gsl_matrix * A, int last_col) { const double sweep_element = gsl_matrix_get (A, k, k); if (fabs (sweep_element) > GSL_DBL_MIN) - { - gsl_matrix_set (B, k, k, -1.0 / sweep_element); - /* - Rows before current row k. - */ - for (i = 0; i < k; i++) - { - for (j = i; j < A->size2; j++) - { - /* Use only the upper triangle of A. */ - double tmp; - if (j < k) - { - tmp = gsl_matrix_get (A, i, j) - - gsl_matrix_get (A, i, k) - * gsl_matrix_get (A, j, k) / sweep_element; - } - else if (j > k) - { - tmp = gsl_matrix_get (A, i, j) - - gsl_matrix_get (A, i, k) - * gsl_matrix_get (A, k, j) / sweep_element; - } - else - { - tmp = gsl_matrix_get (A, i, k) / sweep_element; - } - gsl_matrix_set (B, i, j, tmp); - } - } - /* - Current row k. - */ - for (j = k + 1; j < A->size1; j++) - { - double tmp = gsl_matrix_get (A, k, j) / sweep_element; - gsl_matrix_set (B, k, j, tmp); - } - /* - Rows after the current row k. - */ - for (i = k + 1; i < A->size1; i++) - { - for (j = i; j < A->size2; j++) - { - double tmp = gsl_matrix_get (A, i, j) - - gsl_matrix_get (A, k, i) - * gsl_matrix_get (A, k, j) / sweep_element; - gsl_matrix_set (B, i, j, tmp); - } - } - } + { + gsl_matrix_set (B, k, k, -1.0 / sweep_element); + /* + Rows before current row k. + */ + for (i = 0; i < k; i++) + { + for (j = i; j < A->size2; j++) + { + /* Use only the upper triangle of A. */ + double tmp; + if (j < k) + { + tmp = gsl_matrix_get (A, i, j) - + gsl_matrix_get (A, i, k) + * gsl_matrix_get (A, j, k) / sweep_element; + } + else if (j > k) + { + tmp = gsl_matrix_get (A, i, j) - + gsl_matrix_get (A, i, k) + * gsl_matrix_get (A, k, j) / sweep_element; + } + else + { + tmp = gsl_matrix_get (A, i, k) / sweep_element; + } + gsl_matrix_set (B, i, j, tmp); + } + } + /* + Current row k. + */ + for (j = k + 1; j < A->size1; j++) + { + double tmp = gsl_matrix_get (A, k, j) / sweep_element; + gsl_matrix_set (B, k, j, tmp); + } + /* + Rows after the current row k. + */ + for (i = k + 1; i < A->size1; i++) + { + for (j = i; j < A->size2; j++) + { + double tmp = gsl_matrix_get (A, i, j) - + gsl_matrix_get (A, k, i) + * gsl_matrix_get (A, k, j) / sweep_element; + gsl_matrix_set (B, i, j, tmp); + } + } + } gsl_matrix_memcpy (A, B); } gsl_matrix_free (B); diff --git a/lib/tukey/ptukey.c b/lib/tukey/ptukey.c index 07923d98bd..415355bb2c 100644 --- a/lib/tukey/ptukey.c +++ b/lib/tukey/ptukey.c @@ -71,17 +71,17 @@ #include #include -#define R_D__0 (log_p ? -INFINITY : 0.) /* 0 */ -#define R_D__1 (log_p ? 0. : 1.) /* 1 */ -#define R_DT_0 (lower_tail ? R_D__0 : R_D__1) /* 0 */ -#define R_DT_1 (lower_tail ? R_D__1 : R_D__0) /* 1 */ +#define R_D__0 (log_p ? -INFINITY : 0.) /* 0 */ +#define R_D__1 (log_p ? 0. : 1.) /* 1 */ +#define R_DT_0 (lower_tail ? R_D__0 : R_D__1) /* 0 */ +#define R_DT_1 (lower_tail ? R_D__1 : R_D__0) /* 1 */ -#define R_D_val(x) (log_p ? log(x) : (x)) /* x in pF(x,..) */ -#define R_D_Clog(p) (log_p ? log1p(-(p)) : (0.5 - (p) + 0.5)) /* [log](1-p) */ -#define R_DT_val(x) (lower_tail ? R_D_val(x) : R_D_Clog(x)) +#define R_D_val(x) (log_p ? log(x) : (x)) /* x in pF(x,..) */ +#define R_D_Clog(p) (log_p ? log1p(-(p)) : (0.5 - (p) + 0.5)) /* [log](1-p) */ +#define R_DT_val(x) (lower_tail ? R_D_val(x) : R_D_Clog(x)) -#define ME_PRECISION 8 +#define ME_PRECISION 8 static inline double @@ -103,34 +103,34 @@ wprob (double w, double rr, double cc) /* wprob() : - This function calculates probability integral of Hartley's - form of the range. - - w = value of range - rr = no. of rows or groups - cc = no. of columns or treatments - ir = error flag = 1 if pr_w probability > 1 - pr_w = returned probability integral from (0, w) - - program will not terminate if ir is raised. - - bb = upper limit of legendre integration - iMax = maximum acceptable value of integral - nleg = order of legendre quadrature - ihalf = int ((nleg + 1) / 2) - wlar = value of range above which wincr1 intervals are used to - calculate second part of integral, - else wincr2 intervals are used. - C1, C2, C3 = values which are used as cutoffs for terminating - or modifying a calculation. - - M_1_SQRT_2PI = 1 / sqrt(2 * pi); from abramowitz & stegun, p. 3. - M_SQRT2 = sqrt(2) - xleg = legendre 12-point nodes - aleg = legendre 12-point coefficients + This function calculates probability integral of Hartley's + form of the range. + + w = value of range + rr = no. of rows or groups + cc = no. of columns or treatments + ir = error flag = 1 if pr_w probability > 1 + pr_w = returned probability integral from (0, w) + + program will not terminate if ir is raised. + + bb = upper limit of legendre integration + iMax = maximum acceptable value of integral + nleg = order of legendre quadrature + ihalf = int ((nleg + 1) / 2) + wlar = value of range above which wincr1 intervals are used to + calculate second part of integral, + else wincr2 intervals are used. + C1, C2, C3 = values which are used as cutoffs for terminating + or modifying a calculation. + + M_1_SQRT_2PI = 1 / sqrt(2 * pi); from abramowitz & stegun, p. 3. + M_SQRT2 = sqrt(2) + xleg = legendre 12-point nodes + aleg = legendre 12-point coefficients */ -#define nleg 12 -#define ihalf 6 +#define nleg 12 +#define ihalf 6 /* looks like this is suboptimal for double precision. (see how C1-C3 are used) @@ -176,7 +176,7 @@ wprob (double w, double rr, double cc) /* find (f(w/2) - 1) ^ cc */ /* (first term in integral of hartley's form). */ - pr_w = 2 * pnorm (qsqz, 0., 1., 1, 0) - 1.; /* erf(qsqz / M_SQRT2) */ + pr_w = 2 * pnorm (qsqz, 0., 1., 1, 0) - 1.; /* erf(qsqz / M_SQRT2) */ /* if pr_w ^ cc < 2e-22 then set pr_w = 0 */ if (pr_w >= exp (C2 / cc)) pr_w = pow (pr_w, cc); @@ -217,41 +217,41 @@ wprob (double w, double rr, double cc) b = 0.5 * (bub - blb); for (jj = 1; jj <= nleg; jj++) - { - if (ihalf < jj) - { - j = (nleg - jj) + 1; - xx = xleg[j - 1]; - } - else - { - j = jj; - xx = -xleg[j - 1]; - } - c = b * xx; - ac = a + c; - - /* if exp(-qexpo/2) < 9e-14, */ - /* then doesn't contribute to integral */ - - qexpo = ac * ac; - if (qexpo > C3) - break; - - pplus = 2 * pnorm (ac, 0., 1., 1, 0); - pminus = 2 * pnorm (ac, w, 1., 1, 0); - - /* if rinsum ^ (cc-1) < 9e-14, */ - /* then doesn't contribute to integral */ - - rinsum = (pplus * 0.5) - (pminus * 0.5); - if (rinsum >= exp (C1 / cc1)) - { - rinsum = - (aleg[j - 1] * exp (-(0.5 * qexpo))) * pow (rinsum, cc1); - elsum += rinsum; - } - } + { + if (ihalf < jj) + { + j = (nleg - jj) + 1; + xx = xleg[j - 1]; + } + else + { + j = jj; + xx = -xleg[j - 1]; + } + c = b * xx; + ac = a + c; + + /* if exp(-qexpo/2) < 9e-14, */ + /* then doesn't contribute to integral */ + + qexpo = ac * ac; + if (qexpo > C3) + break; + + pplus = 2 * pnorm (ac, 0., 1., 1, 0); + pminus = 2 * pnorm (ac, w, 1., 1, 0); + + /* if rinsum ^ (cc-1) < 9e-14, */ + /* then doesn't contribute to integral */ + + rinsum = (pplus * 0.5) - (pminus * 0.5); + if (rinsum >= exp (C1 / cc1)) + { + rinsum = + (aleg[j - 1] * exp (-(0.5 * qexpo))) * pow (rinsum, cc1); + elsum += rinsum; + } + } elsum *= (((2.0 * b) * cc) * M_1_SQRT_2PI); einsum += elsum; blb = bub; @@ -264,77 +264,77 @@ wprob (double w, double rr, double cc) return 0.; pr_w = pow (pr_w, rr); - if (pr_w >= 1.) /* 1 was iMax was eps */ + if (pr_w >= 1.) /* 1 was iMax was eps */ return 1.; return pr_w; -} /* wprob() */ +} /* wprob() */ double ptukey (double q, double rr, double cc, double df, int lower_tail, int log_p) { /* function ptukey() [was qprob() ]: - q = value of studentized range - rr = no. of rows or groups - cc = no. of columns or treatments - df = degrees of freedom of error term - ir[0] = error flag = 1 if wprob probability > 1 - ir[1] = error flag = 1 if qprob probability > 1 + q = value of studentized range + rr = no. of rows or groups + cc = no. of columns or treatments + df = degrees of freedom of error term + ir[0] = error flag = 1 if wprob probability > 1 + ir[1] = error flag = 1 if qprob probability > 1 - qprob = returned probability integral over [0, q] + qprob = returned probability integral over [0, q] - The program will not terminate if ir[0] or ir[1] are raised. + The program will not terminate if ir[0] or ir[1] are raised. - All references in wprob to Abramowitz and Stegun - are from the following reference: + All references in wprob to Abramowitz and Stegun + are from the following reference: - Abramowitz, Milton and Stegun, Irene A. - Handbook of Mathematical Functions. - New York: Dover publications, Inc. (1970). + Abramowitz, Milton and Stegun, Irene A. + Handbook of Mathematical Functions. + New York: Dover publications, Inc. (1970). - All constants taken from this text are - given to 25 significant digits. + All constants taken from this text are + given to 25 significant digits. - nlegq = order of legendre quadrature - ihalfq = int ((nlegq + 1) / 2) - eps = max. allowable value of integral - eps1 & eps2 = values below which there is - no contribution to integral. + nlegq = order of legendre quadrature + ihalfq = int ((nlegq + 1) / 2) + eps = max. allowable value of integral + eps1 & eps2 = values below which there is + no contribution to integral. - d.f. <= dhaf: integral is divided into ulen1 length intervals. else - d.f. <= dquar: integral is divided into ulen2 length intervals. else - d.f. <= deigh: integral is divided into ulen3 length intervals. else - d.f. <= dlarg: integral is divided into ulen4 length intervals. + d.f. <= dhaf: integral is divided into ulen1 length intervals. else + d.f. <= dquar: integral is divided into ulen2 length intervals. else + d.f. <= deigh: integral is divided into ulen3 length intervals. else + d.f. <= dlarg: integral is divided into ulen4 length intervals. - d.f. > dlarg: the range is used to calculate integral. + d.f. > dlarg: the range is used to calculate integral. - M_LN2 = log(2) + M_LN2 = log(2) - xlegq = legendre 16-point nodes - alegq = legendre 16-point coefficients + xlegq = legendre 16-point nodes + alegq = legendre 16-point coefficients - The coefficients and nodes for the legendre quadrature used in - qprob and wprob were calculated using the algorithms found in: + The coefficients and nodes for the legendre quadrature used in + qprob and wprob were calculated using the algorithms found in: - Stroud, A. H. and Secrest, D. - Gaussian Quadrature Formulas. - Englewood Cliffs, - New Jersey: Prentice-Hall, Inc, 1966. + Stroud, A. H. and Secrest, D. + Gaussian Quadrature Formulas. + Englewood Cliffs, + New Jersey: Prentice-Hall, Inc, 1966. - All values matched the tables (provided in same reference) - to 30 significant digits. + All values matched the tables (provided in same reference) + to 30 significant digits. - f(x) = .5 + erf(x / sqrt(2)) / 2 for x > 0 + f(x) = .5 + erf(x / sqrt(2)) / 2 for x > 0 - f(x) = erfc(-x / sqrt(2)) / 2 for x < 0 + f(x) = erfc(-x / sqrt(2)) / 2 for x < 0 - where f(x) is standard normal c. d. f. + where f(x) is standard normal c. d. f. - if degrees of freedom large, approximate integral - with range distribution. + if degrees of freedom large, approximate integral + with range distribution. */ -#define nlegq 16 -#define ihalfq 8 +#define nlegq 16 +#define ihalfq 8 /* const double eps = 1.0; not used if = 1 */ static const double eps1 = -30.0; @@ -422,49 +422,49 @@ ptukey (double q, double rr, double cc, double df, int lower_tail, int log_p) twa1 = (2 * i - 1) * ulen; for (jj = 1; jj <= nlegq; jj++) - { - if (ihalfq < jj) - { - j = jj - ihalfq - 1; - t1 = (f2lf + (f21 * log (twa1 + (xlegq[j] * ulen)))) - - (((xlegq[j] * ulen) + twa1) * ff4); - } - else - { - j = jj - 1; - t1 = (f2lf + (f21 * log (twa1 - (xlegq[j] * ulen)))) - + (((xlegq[j] * ulen) - twa1) * ff4); - - } - - /* if exp(t1) < 9e-14, then doesn't contribute to integral */ - if (t1 >= eps1) - { - if (ihalfq < jj) - { - qsqz = q * sqrt (((xlegq[j] * ulen) + twa1) * 0.5); - } - else - { - qsqz = q * sqrt (((-(xlegq[j] * ulen)) + twa1) * 0.5); - } - - /* call wprob to find integral of range portion */ - - wprb = wprob (qsqz, rr, cc); - rotsum = (wprb * alegq[j]) * exp (t1); - otsum += rotsum; - } - /* end legendre integral for interval i */ - /* L200: */ - } + { + if (ihalfq < jj) + { + j = jj - ihalfq - 1; + t1 = (f2lf + (f21 * log (twa1 + (xlegq[j] * ulen)))) + - (((xlegq[j] * ulen) + twa1) * ff4); + } + else + { + j = jj - 1; + t1 = (f2lf + (f21 * log (twa1 - (xlegq[j] * ulen)))) + + (((xlegq[j] * ulen) - twa1) * ff4); + + } + + /* if exp(t1) < 9e-14, then doesn't contribute to integral */ + if (t1 >= eps1) + { + if (ihalfq < jj) + { + qsqz = q * sqrt (((xlegq[j] * ulen) + twa1) * 0.5); + } + else + { + qsqz = q * sqrt (((-(xlegq[j] * ulen)) + twa1) * 0.5); + } + + /* call wprob to find integral of range portion */ + + wprb = wprob (qsqz, rr, cc); + rotsum = (wprb * alegq[j]) * exp (t1); + otsum += rotsum; + } + /* end legendre integral for interval i */ + /* L200: */ + } /* if integral for interval i < 1e-14, then stop. * However, in order to avoid small area under left tail, * at least 1 / ulen intervals are calculated. */ if (i * ulen >= 1.0 && otsum <= eps2) - break; + break; /* end of interval i */ /* L330: */ diff --git a/lib/tukey/qtukey.c b/lib/tukey/qtukey.c index 54c174be20..443d036aa5 100644 --- a/lib/tukey/qtukey.c +++ b/lib/tukey/qtukey.c @@ -20,7 +20,7 @@ /* * Mathlib : A C Library of Special Functions - * Copyright (C) 1998 Ross Ihaka + * Copyright (C) 1998 Ross Ihaka * Copyright (C) 2000--2005 The R Development Core Team * based in part on AS70 (C) 1974 Royal Statistical Society * @@ -40,24 +40,24 @@ * * SYNOPSIS * - * #include - * double qtukey(p, rr, cc, df, lower_tail, log_p); + * #include + * double qtukey(p, rr, cc, df, lower_tail, log_p); * * DESCRIPTION * - * Computes the quantiles of the maximum of rr studentized - * ranges, each based on cc means and with df degrees of freedom - * for the standard error, is less than q. + * Computes the quantiles of the maximum of rr studentized + * ranges, each based on cc means and with df degrees of freedom + * for the standard error, is less than q. * - * The algorithm is based on that of the reference. + * The algorithm is based on that of the reference. * * REFERENCE * - * Copenhaver, Margaret Diponzio & Holland, Burt S. - * Multiple comparisons of simple effects in - * the two-way analysis of variance with fixed effects. - * Journal of Statistical Computation and Simulation, - * Vol.30, pp.1-15, 1988. + * Copenhaver, Margaret Diponzio & Holland, Burt S. + * Multiple comparisons of simple effects in + * the two-way analysis of variance with fixed effects. + * Journal of Statistical Computation and Simulation, + * Vol.30, pp.1-15, 1988. */ #include @@ -70,54 +70,54 @@ #define TRUE (1) #define FALSE (0) -#define ML_POSINF (1.0 / 0.0) -#define ML_NEGINF (-1.0 / 0.0) +#define ML_POSINF (1.0 / 0.0) +#define ML_NEGINF (-1.0 / 0.0) -#define R_D_Lval(p) (lower_tail ? (p) : (0.5 - (p) + 0.5)) /* p */ +#define R_D_Lval(p) (lower_tail ? (p) : (0.5 - (p) + 0.5)) /* p */ -#define R_DT_qIv(p) (log_p ? (lower_tail ? exp(p) : - expm1(p)) \ - : R_D_Lval(p)) +#define R_DT_qIv(p) (log_p ? (lower_tail ? exp(p) : - expm1(p)) \ + : R_D_Lval(p)) static double fmax2(double x, double y) { - if (isnan(x) || isnan(y)) - return x + y; - return (x < y) ? y : x; + if (isnan(x) || isnan(y)) + return x + y; + return (x < y) ? y : x; } -#define R_Q_P01_boundaries(p, _LEFT_, _RIGHT_) \ - if (log_p) { \ - assert (p <= 0); \ - if(p == 0) /* upper bound*/ \ - return lower_tail ? _RIGHT_ : _LEFT_; \ - if(p == ML_NEGINF) \ - return lower_tail ? _LEFT_ : _RIGHT_; \ - } \ - else { /* !log_p */ \ - assert (p >= 0 && p <= 1); \ - if(p == 0) \ - return lower_tail ? _LEFT_ : _RIGHT_; \ - if(p == 1) \ - return lower_tail ? _RIGHT_ : _LEFT_; \ +#define R_Q_P01_boundaries(p, _LEFT_, _RIGHT_) \ + if (log_p) { \ + assert (p <= 0); \ + if(p == 0) /* upper bound*/ \ + return lower_tail ? _RIGHT_ : _LEFT_; \ + if(p == ML_NEGINF) \ + return lower_tail ? _LEFT_ : _RIGHT_; \ + } \ + else { /* !log_p */ \ + assert (p >= 0 && p <= 1); \ + if(p == 0) \ + return lower_tail ? _LEFT_ : _RIGHT_; \ + if(p == 1) \ + return lower_tail ? _RIGHT_ : _LEFT_; \ } /* qinv() : - * this function finds percentage point of the studentized range - * which is used as initial estimate for the secant method. - * function is adapted from portion of algorithm as 70 - * from applied statistics (1974) ,vol. 23, no. 1 - * by odeh, r. e. and evans, j. o. + * this function finds percentage point of the studentized range + * which is used as initial estimate for the secant method. + * function is adapted from portion of algorithm as 70 + * from applied statistics (1974) ,vol. 23, no. 1 + * by odeh, r. e. and evans, j. o. * - * p = percentage point - * c = no. of columns or treatments - * v = degrees of freedom - * qinv = returned initial estimate + * p = percentage point + * c = no. of columns or treatments + * v = degrees of freedom + * qinv = returned initial estimate * - * vmax is cutoff above which degrees of freedom - * is treated as infinity. + * vmax is cutoff above which degrees of freedom + * is treated as infinity. */ static double qinv(double p, double c, double v) @@ -144,7 +144,7 @@ static double qinv(double p, double c, double v) ps = 0.5 - 0.5 * p; yi = sqrt (log (1.0 / (ps * ps))); t = yi + ((((yi * p4 + p3) * yi + p2) * yi + p1) * yi + p0) - / ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0); + / ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0); if (v < vmax) t += (t * t * t + t) / v / 4.0; q = c1 - c2 * t; if (v < vmax) q += -c3 / v + c4 * t / v; @@ -168,7 +168,7 @@ static double qinv(double p, double c, double v) * ir(1) = error flag = 1 if wprob probability > 1 * ir(2) = error flag = 1 if ptukey probability > 1 * ir(3) = error flag = 1 if convergence not reached in 50 iterations - * = 2 if df < 2 + * = 2 if df < 2 * * qtukey = returned critical value * @@ -178,7 +178,7 @@ static double qinv(double p, double c, double v) double qtukey(double p, double rr, double cc, double df, - int lower_tail, int log_p) + int lower_tail, int log_p) { static const double eps = 0.0001; const int maxiter = 50; @@ -187,8 +187,8 @@ double qtukey(double p, double rr, double cc, double df, int iter; if (isnan(p) || isnan(rr) || isnan(cc) || isnan(df)) { - /* ML_ERROR(ME_DOMAIN, "qtukey"); */ - return p + rr + cc + df; + /* ML_ERROR(ME_DOMAIN, "qtukey"); */ + return p + rr + cc + df; } /* df must be > 1 ; there must be at least two values */ @@ -219,35 +219,35 @@ double qtukey(double p, double rr, double cc, double df, /* first iterate; otherwise it is 1 greater. */ if (valx0 > 0.0) - x1 = fmax2(0.0, x0 - 1.0); + x1 = fmax2(0.0, x0 - 1.0); else - x1 = x0 + 1.0; + x1 = x0 + 1.0; valx1 = ptukey(x1, rr, cc, df, /*LOWER*/TRUE, /*LOG_P*/FALSE) - p; /* Find new iterate */ for(iter=1 ; iter < maxiter ; iter++) { - ans = x1 - ((valx1 * (x1 - x0)) / (valx1 - valx0)); - valx0 = valx1; + ans = x1 - ((valx1 * (x1 - x0)) / (valx1 - valx0)); + valx0 = valx1; - /* New iterate must be >= 0 */ + /* New iterate must be >= 0 */ - x0 = x1; - if (ans < 0.0) { - ans = 0.0; - valx1 = -p; - } - /* Find prob(value < new iterate) */ + x0 = x1; + if (ans < 0.0) { + ans = 0.0; + valx1 = -p; + } + /* Find prob(value < new iterate) */ - valx1 = ptukey(ans, rr, cc, df, /*LOWER*/TRUE, /*LOG_P*/FALSE) - p; - x1 = ans; + valx1 = ptukey(ans, rr, cc, df, /*LOWER*/TRUE, /*LOG_P*/FALSE) - p; + x1 = ans; - /* If the difference between two successive */ - /* iterates is less than eps, stop */ + /* If the difference between two successive */ + /* iterates is less than eps, stop */ - xabs = fabs(x1 - x0); - if (xabs < eps) - return ans; + xabs = fabs(x1 - x0); + if (xabs < eps) + return ans; } /* The process did not converge in 'maxiter' iterations */ diff --git a/perl-module/ppport.h b/perl-module/ppport.h index 055919b033..1c6481c911 100644 --- a/perl-module/ppport.h +++ b/perl-module/ppport.h @@ -3089,7 +3089,7 @@ __DATA__ # define PL_errgv errgv # define PL_hexdigit hexdigit # define PL_hints hints -# define PL_na na +# define PL_na na # define PL_no_modify no_modify # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb @@ -3185,15 +3185,15 @@ typedef NVTYPE NV; #undef STMT_START #undef STMT_END #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) -# define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ -# define STMT_END ) +# define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ +# define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) -# define STMT_START if (1) -# define STMT_END else (void)0 +# define STMT_START if (1) +# define STMT_END else (void)0 # else -# define STMT_START do -# define STMT_END while (0) +# define STMT_START do +# define STMT_END while (0) # endif #endif #ifndef boolSV @@ -3432,7 +3432,7 @@ DPPP_(my_eval_pv)(char *p, I32 croak_on_error) PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) - croak(SvPVx(GvSV(errgv), na)); + croak(SvPVx(GvSV(errgv), na)); return sv; } @@ -3493,35 +3493,35 @@ extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv); void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv) { - U32 oldhints = PL_hints; - HV *old_cop_stash = PL_curcop->cop_stash; - HV *old_curstash = PL_curstash; - line_t oldline = PL_curcop->cop_line; - PL_curcop->cop_line = PL_copline; + U32 oldhints = PL_hints; + HV *old_cop_stash = PL_curcop->cop_stash; + HV *old_curstash = PL_curstash; + line_t oldline = PL_curcop->cop_line; + PL_curcop->cop_line = PL_copline; - PL_hints &= ~HINT_BLOCK_SCOPE; - if (stash) - PL_curstash = PL_curcop->cop_stash = stash; + PL_hints &= ~HINT_BLOCK_SCOPE; + if (stash) + PL_curstash = PL_curcop->cop_stash = stash; - newSUB( + newSUB( #if ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))) - start_subparse(), + start_subparse(), #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22)) - start_subparse(0), + start_subparse(0), #else /* 5.003_23 onwards */ - start_subparse(FALSE, 0), + start_subparse(FALSE, 0), #endif - newSVOP(OP_CONST, 0, newSVpv(name,0)), - newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ - newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) - ); + newSVOP(OP_CONST, 0, newSVpv(name,0)), + newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ + newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) + ); - PL_hints = oldhints; - PL_curcop->cop_stash = old_cop_stash; - PL_curstash = old_curstash; - PL_curcop->cop_line = oldline; + PL_hints = oldhints; + PL_curcop->cop_stash = old_cop_stash; + PL_curstash = old_curstash; + PL_curcop->cop_line = oldline; } #endif #endif @@ -3558,64 +3558,64 @@ DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv) #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68)) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ - SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) + SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ - SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ - sizeof(MY_CXT_KEY)-1, TRUE) + SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ + sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ -#define dMY_CXT \ - dMY_CXT_SV; \ - my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) +#define dMY_CXT \ + dMY_CXT_SV; \ + my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ - dMY_CXT_SV; \ - /* newSV() allocates one more than needed */ \ - my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ - Zero(my_cxtp, 1, my_cxt_t); \ - sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) + dMY_CXT_SV; \ + /* newSV() allocates one more than needed */ \ + my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ + Zero(my_cxtp, 1, my_cxt_t); \ + sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ -#define MY_CXT (*my_cxtp) +#define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ -#define pMY_CXT my_cxt_t *my_cxtp -#define pMY_CXT_ pMY_CXT, -#define _pMY_CXT ,pMY_CXT -#define aMY_CXT my_cxtp -#define aMY_CXT_ aMY_CXT, -#define _aMY_CXT ,aMY_CXT +#define pMY_CXT my_cxt_t *my_cxtp +#define pMY_CXT_ pMY_CXT, +#define _pMY_CXT ,pMY_CXT +#define aMY_CXT my_cxtp +#define aMY_CXT_ aMY_CXT, +#define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ - dMY_CXT_SV; \ - my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ - Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ - sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) + dMY_CXT_SV; \ + my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ + Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ + sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT -#define START_MY_CXT static my_cxt_t my_cxt; -#define dMY_CXT_SV dNOOP -#define dMY_CXT dNOOP -#define MY_CXT_INIT NOOP -#define MY_CXT my_cxt +#define START_MY_CXT static my_cxt_t my_cxt; +#define dMY_CXT_SV dNOOP +#define dMY_CXT dNOOP +#define MY_CXT_INIT NOOP +#define MY_CXT my_cxt -#define pMY_CXT void +#define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT @@ -3625,25 +3625,25 @@ DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv) #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE -#define MY_CXT_CLONE NOOP +#define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE -# define IVdf "ld" -# define UVuf "lu" -# define UVof "lo" -# define UVxf "lx" -# define UVXf "lX" +# define IVdf "ld" +# define UVuf "lu" +# define UVof "lo" +# define UVxf "lx" +# define UVXf "lX" # else # if IVSIZE == INTSIZE -# define IVdf "d" -# define UVuf "u" -# define UVof "o" -# define UVxf "x" -# define UVXf "X" +# define IVdf "d" +# define UVuf "u" +# define UVof "o" +# define UVxf "x" +# define UVXf "X" # endif # endif #endif @@ -4273,8 +4273,8 @@ DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ - || (CopSTASHPV(c) && HvNAME(hv) \ - && strEQ(CopSTASHPV(c), HvNAME(hv))))) + || (CopSTASHPV(c) && HvNAME(hv) \ + && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else @@ -4502,7 +4502,7 @@ DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; - if (++s < send) { + if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; @@ -4550,7 +4550,7 @@ DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) } } } - } + } } } } @@ -4562,7 +4562,7 @@ DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) } } } - } + } } } numtype |= IS_NUMBER_IN_UV; @@ -4715,22 +4715,22 @@ DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) value_nv = (NV) value; } value_nv *= 2.0; - /* If an NV has not enough bits in its mantissa to - * represent a UV this summing of small low-order numbers - * is a waste of time (because the NV cannot preserve - * the low-order bits anyway): we could just remember when - * did we overflow and in the end just multiply value_nv by the - * right amount. */ + /* If an NV has not enough bits in its mantissa to + * represent a UV this summing of small low-order numbers + * is a waste of time (because the NV cannot preserve + * the low-order bits anyway): we could just remember when + * did we overflow and in the end just multiply value_nv by the + * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) - { - --len; - ++s; + { + --len; + ++s; goto redo; - } + } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; @@ -4738,10 +4738,10 @@ DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) if ((overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 - || (!overflowed && value > 0xffffffff) + || (!overflowed && value > 0xffffffff) #endif - ) { - warn("Binary number > 0b11111111111111111111111111111111 non-portable"); + ) { + warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { @@ -4801,7 +4801,7 @@ DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) } for (; len-- && *s; s++) { - xdigit = strchr((char *) PL_hexdigit, *s); + xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. @@ -4817,22 +4817,22 @@ DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) value_nv = (NV) value; } value_nv *= 16.0; - /* If an NV has not enough bits in its mantissa to - * represent a UV this summing of small low-order numbers - * is a waste of time (because the NV cannot preserve - * the low-order bits anyway): we could just remember when - * did we overflow and in the end just multiply value_nv by the - * right amount of 16-tuples. */ + /* If an NV has not enough bits in its mantissa to + * represent a UV this summing of small low-order numbers + * is a waste of time (because the NV cannot preserve + * the low-order bits anyway): we could just remember when + * did we overflow and in the end just multiply value_nv by the + * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] - && (xdigit = strchr((char *) PL_hexdigit, s[1]))) - { - --len; - ++s; + && (xdigit = strchr((char *) PL_hexdigit, s[1]))) + { + --len; + ++s; goto redo; - } + } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; @@ -4840,10 +4840,10 @@ DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) if ((overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 - || (!overflowed && value > 0xffffffff) + || (!overflowed && value > 0xffffffff) #endif - ) { - warn("Hexadecimal number > 0xffffffff non-portable"); + ) { + warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { @@ -4905,22 +4905,22 @@ DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) value_nv = (NV) value; } value_nv *= 8.0; - /* If an NV has not enough bits in its mantissa to - * represent a UV this summing of small low-order numbers - * is a waste of time (because the NV cannot preserve - * the low-order bits anyway): we could just remember when - * did we overflow and in the end just multiply value_nv by the - * right amount of 8-tuples. */ + /* If an NV has not enough bits in its mantissa to + * represent a UV this summing of small low-order numbers + * is a waste of time (because the NV cannot preserve + * the low-order bits anyway): we could just remember when + * did we overflow and in the end just multiply value_nv by the + * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) - { - --len; - ++s; + { + --len; + ++s; goto redo; - } + } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ @@ -4933,10 +4933,10 @@ DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result) if ((overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 - || (!overflowed && value > 0xffffffff) + || (!overflowed && value > 0xffffffff) #endif - ) { - warn("Octal number > 037777777777 non-portable"); + ) { + warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { diff --git a/src/data/any-reader.h b/src/data/any-reader.h index 6e4d751f78..0c448a0516 100644 --- a/src/data/any-reader.h +++ b/src/data/any-reader.h @@ -81,7 +81,7 @@ struct any_read_info enum float_format float_format; enum any_compression compression; casenumber n_cases; /* -1 if unknown. */ - char *product; /* Product name. */ + char *product; /* Product name. */ char *product_ext; /* Extra product info. */ /* Writer's version number in X.Y.Z format. diff --git a/src/data/case.h b/src/data/case.h index 190073973a..ab511aa642 100644 --- a/src/data/case.h +++ b/src/data/case.h @@ -109,7 +109,7 @@ int case_compare (const struct ccase *, const struct ccase *, const struct variable *const *, size_t n_vars); int case_compare_2dict (const struct ccase *, const struct ccase *, const struct variable *const *, - const struct variable *const *, + const struct variable *const *, size_t n_vars); const union value *case_data_all (const struct ccase *); diff --git a/src/data/casereader-filter.c b/src/data/casereader-filter.c index f4ad7e625a..6b5d91dd41 100644 --- a/src/data/casereader-filter.c +++ b/src/data/casereader-filter.c @@ -218,9 +218,9 @@ casereader_filter_weight_include (const struct ccase *c, void *cfw_) { if (*cfw->warn_on_invalid) { - msg (SW, _("At least one case in the data read had a weight value " - "that was user-missing, system-missing, zero, or " - "negative. These case(s) were ignored.")); + msg (SW, _("At least one case in the data read had a weight value " + "that was user-missing, system-missing, zero, or " + "negative. These case(s) were ignored.")); *cfw->warn_on_invalid = false; } return false; @@ -275,7 +275,7 @@ struct casereader * casereader_create_filter_missing (struct casereader *reader, const struct variable *const *vars, size_t n_vars, enum mv_class class, - casenumber *n_missing, + casenumber *n_missing, struct casewriter *exclude) { if (n_vars > 0 && class) @@ -309,11 +309,11 @@ casereader_filter_missing_include (const struct ccase *c, void *cfm_) struct variable *var = cfm->vars[i]; const union value *value = case_data (c, var); if (var_is_value_missing (var, value) & cfm->class) - { - if (cfm->n_missing) - (*cfm->n_missing)++; - return false; - } + { + if (cfm->n_missing) + (*cfm->n_missing)++; + return false; + } } return true; } diff --git a/src/data/casereader-translator.c b/src/data/casereader-translator.c index 3dcc37a028..cf3232e683 100644 --- a/src/data/casereader-translator.c +++ b/src/data/casereader-translator.c @@ -232,8 +232,8 @@ static struct ccase *can_translate (struct ccase *, void *can_); when the translating casereader is destroyed. */ struct casereader * casereader_create_append_numeric (struct casereader *subreader, - new_value_func func, void *aux, - void (*destroy) (void *aux)) + new_value_func func, void *aux, + void (*destroy) (void *aux)) { struct casereader_append_numeric *can = xmalloc (sizeof *can); can->proto = caseproto_ref (casereader_get_proto (subreader)); @@ -281,8 +281,8 @@ struct arithmetic_sequence static double next_arithmetic (const struct ccase *c UNUSED, - casenumber n, - void *aux) + casenumber n, + void *aux) { struct arithmetic_sequence *as = aux; return n * as->increment + as->first; @@ -305,7 +305,7 @@ casereader_create_arithmetic_sequence (struct casereader *subreader, as->first = first; as->increment = increment; return casereader_create_append_numeric (subreader, next_arithmetic, - as, free); + as, free); } @@ -356,12 +356,12 @@ static struct ccase *car_translate (struct ccase *input, void *car_); when the translating casereader is destroyed. */ struct casereader * casereader_create_append_rank (struct casereader *subreader, - const struct variable *v, - const struct variable *w, - enum rank_error *err, - distinct_func *distinct_callback, - void *aux - ) + const struct variable *v, + const struct variable *w, + enum rank_error *err, + distinct_func *distinct_callback, + void *aux + ) { struct casereader_append_rank *car = xmalloc (sizeof *car); car->proto = caseproto_ref (casereader_get_proto (subreader)); @@ -404,7 +404,7 @@ car_translate (struct ccase *input, void *car_) if (car->prev_value != SYSMIS) { if (car->err && value < car->prev_value) - *car->err |= RANK_ERR_UNSORTED; + *car->err |= RANK_ERR_UNSORTED; } if (car->n_common == 1) @@ -413,42 +413,42 @@ car_translate (struct ccase *input, void *car_) casenumber k = 0; double weight = 1.0; if (car->weight) - { - weight = case_num (input, car->weight); - if (car->err && weight < 0) - *car->err |= RANK_ERR_NEGATIVE_WEIGHT; - } + { + weight = case_num (input, car->weight); + if (car->err && weight < 0) + *car->err |= RANK_ERR_NEGATIVE_WEIGHT; + } do - { - struct ccase *c = casereader_peek (car->clone, car->n + ++k); - if (c == NULL) - break; - vxx = case_num (c, car->var); - - if (vxx == value) - { - if (car->weight) - { - double w = case_num (c, car->weight); - - if (car->err && w < 0) - *car->err |= RANK_ERR_NEGATIVE_WEIGHT; - - weight += w; - } - else - weight += 1.0; - car->n_common++; - } + { + struct ccase *c = casereader_peek (car->clone, car->n + ++k); + if (c == NULL) + break; + vxx = case_num (c, car->var); + + if (vxx == value) + { + if (car->weight) + { + double w = case_num (c, car->weight); + + if (car->err && w < 0) + *car->err |= RANK_ERR_NEGATIVE_WEIGHT; + + weight += w; + } + else + weight += 1.0; + car->n_common++; + } case_unref (c); - } + } while (vxx == value); car->mean_rank = car->cc + (weight + 1) / 2.0; car->cc += weight; if (car->distinct) - car->distinct (value, car->n_common, weight, car->aux); + car->distinct (value, car->n_common, weight, car->aux); } else car->n_common--; @@ -495,7 +495,7 @@ uniquify (const struct ccase *c, void *aux) goto end; dir = value_compare_3way (case_data (next_case, cdr->key), - current_value, key_width); + current_value, key_width); if (dir > 0) dir = 1; if (dir < 0) @@ -566,8 +566,8 @@ uniquify_destroy (void *aux) */ struct casereader * casereader_create_distinct (struct casereader *input, - const struct variable *key, - const struct variable *weight) + const struct variable *key, + const struct variable *weight) { struct casereader *u ; struct caseproto *output_proto = caseproto_ref (casereader_get_proto (input)); @@ -586,7 +586,7 @@ casereader_create_distinct (struct casereader *input, cdr->proto = output_proto; u = casereader_create_filter_func (input, uniquify, - NULL, cdr, NULL); + NULL, cdr, NULL); static const struct casereader_translator_class class = { consolodate_weight, uniquify_destroy, diff --git a/src/data/casereader.h b/src/data/casereader.h index 06f7a7b13a..c175f42f79 100644 --- a/src/data/casereader.h +++ b/src/data/casereader.h @@ -100,7 +100,7 @@ struct casereader * casereader_create_filter_missing (struct casereader *, const struct variable *const *vars, size_t n_vars, enum mv_class, - casenumber *n_missing, + casenumber *n_missing, struct casewriter *exclude); struct casereader * @@ -135,8 +135,8 @@ typedef double new_value_func (const struct ccase *, casenumber, void *); struct casereader * casereader_create_append_numeric (struct casereader *subreader, - new_value_func func, void *aux, - void (*destroy) (void *aux)); + new_value_func func, void *aux, + void (*destroy) (void *aux)); struct casereader * casereader_create_arithmetic_sequence (struct casereader *, @@ -154,14 +154,14 @@ typedef void distinct_func (double v, casenumber n, double w, void *aux); struct casereader * casereader_create_append_rank (struct casereader *, - const struct variable *v, const struct variable *w, - enum rank_error *err, - distinct_func *distinct_callback, void *aux); + const struct variable *v, const struct variable *w, + enum rank_error *err, + distinct_func *distinct_callback, void *aux); struct casereader * casereader_create_distinct (struct casereader *input, - const struct variable *key, - const struct variable *weight); + const struct variable *key, + const struct variable *weight); #endif /* data/casereader.h */ diff --git a/src/data/casewriter.c b/src/data/casewriter.c index 51d5e10bfb..c4e0273c9c 100644 --- a/src/data/casewriter.c +++ b/src/data/casewriter.c @@ -253,8 +253,8 @@ casewriter_window_convert_to_reader (struct casewriter *writer UNUSED, struct casewindow *window = window_; struct casereader *reader = casereader_create_random (casewindow_get_proto (window), - casewindow_get_n_cases (window), - &casereader_window_class, window); + casewindow_get_n_cases (window), + &casereader_window_class, window); taint_propagate (casewindow_get_taint (window), casereader_get_taint (reader)); diff --git a/src/data/csv-file-writer.c b/src/data/csv-file-writer.c index 279c63685d..1a772112ea 100644 --- a/src/data/csv-file-writer.c +++ b/src/data/csv-file-writer.c @@ -68,7 +68,7 @@ struct csv_writer { struct file_handle *fh; /* File handle. */ struct fh_lock *lock; /* Mutual exclusion for file. */ - FILE *file; /* File stream. */ + FILE *file; /* File stream. */ struct replace_file *rf; /* Ticket for replacing output file. */ struct csv_writer_options opts; diff --git a/src/data/data-in.c b/src/data/data-in.c index d734eb911d..7d18ef34dd 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -881,7 +881,7 @@ parse_month (struct data_in *i, long *month) { char *error = parse_int (i, month, SIZE_MAX); if (error != NULL) - return error; + return error; if (*month >= 1 && *month <= 12) return NULL; } diff --git a/src/data/data-out.c b/src/data/data-out.c index 563c63566a..7fd2146eaf 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -167,7 +167,7 @@ binary_to_utf8 (const char *in, struct pool *pool) If POOL is non-null, then the return value is allocated on that pool. */ char * data_out_pool (const union value *input, const char *input_encoding, - struct fmt_spec format, + struct fmt_spec format, const struct fmt_settings *settings, struct pool *pool) { assert (fmt_check_output (format)); @@ -353,7 +353,7 @@ output_IB (const union value *input, struct fmt_spec format, if (number < 0) integer = -integer; output_binary_integer (integer, format.w, - settings_get_output_integer_format (), + settings_get_output_integer_format (), output); } @@ -371,7 +371,7 @@ output_PIB (const union value *input, struct fmt_spec format, memset (output, 0, format.w); else output_binary_integer (number, format.w, - settings_get_output_integer_format (), output); + settings_get_output_integer_format (), output); output[format.w] = '\0'; } @@ -532,11 +532,11 @@ output_date (const union value *input, struct fmt_spec format, int d = MIN (format.d, excess_width - 4); int w = d + 3; c_snprintf (p, 64, ":%0*.*f", w, d, number); - if (settings->decimal != '.') + if (settings->decimal != '.') { char *cp = strchr (p, '.'); if (cp != NULL) - *cp = settings->decimal; + *cp = settings->decimal; } p += strlen (p); } diff --git a/src/data/dataset.c b/src/data/dataset.c index 2af19bd756..310e66ef57 100644 --- a/src/data/dataset.c +++ b/src/data/dataset.c @@ -87,7 +87,7 @@ struct dataset { time_t last_proc_invocation; /* Cases just before ("lagging") the current one. */ - int n_lag; /* Number of cases to lag. */ + int n_lag; /* Number of cases to lag. */ struct deque lag; /* Deque of lagged cases. */ struct ccase **lag_cases; /* Lagged cases managed by deque. */ diff --git a/src/data/datasheet.c b/src/data/datasheet.c index 970a7bbac2..816b7150e2 100644 --- a/src/data/datasheet.c +++ b/src/data/datasheet.c @@ -51,8 +51,8 @@ static bool axis_allocate (struct axis *, unsigned long int request, unsigned long int *start, unsigned long int *width); static void axis_make_available (struct axis *, - unsigned long int start, - unsigned long int width); + unsigned long int start, + unsigned long int width); static unsigned long int axis_extend (struct axis *, unsigned long int width); static unsigned long int axis_map (const struct axis *, unsigned long log_pos); @@ -526,7 +526,7 @@ datasheet_resize_column (struct datasheet *ds, size_t column, int new_width, value_destroy (&src, old_width); value_destroy (&dst, new_width); if (lrow < n_rows) - return false; + return false; release_source (ds, old_col.source); } @@ -869,7 +869,7 @@ rw_case (struct datasheet *ds, enum rw_op op, struct axis { struct tower log_to_phy; /* Map from logical to physical ordinates; - contains "struct axis_group"s. */ + contains "struct axis_group"s. */ struct range_set *available; /* Set of unused, available ordinates. */ unsigned long int phy_size; /* Current physical length of axis. */ }; diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 8b5f381296..fb69d624af 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -59,19 +59,19 @@ struct dictionary { int ref_cnt; - struct vardict_info *vars; /* Variables. */ + struct vardict_info *vars; /* Variables. */ size_t n_vars; /* Number of variables. */ size_t allocated_vars; /* Allocated space in 'vars'. */ struct caseproto *proto; /* Prototype for dictionary cases (updated lazily). */ - struct hmap name_map; /* Variable index by name. */ + struct hmap name_map; /* Variable index by name. */ const struct variable **split; /* SPLIT FILE vars. */ size_t n_splits; /* SPLIT FILE count. */ enum split_type split_type; struct variable *weight; /* WEIGHT variable. */ struct variable *filter; /* FILTER variable. */ casenumber case_limit; /* Current case limit (N command). */ - char *label; /* File label. */ + char *label; /* File label. */ struct string_array documents; /* Documents. */ struct vector **vector; /* Vectors of variables. */ size_t n_vectors; /* Number of vectors. */ @@ -93,7 +93,7 @@ struct dictionary char *encoding; /* Character encoding of string data */ const struct dict_callbacks *callbacks; /* Callbacks on dictionary - modification */ + modification */ void *cb_data ; /* Data passed to callbacks */ void (*changed) (struct dictionary *, void *); /* Generic change callback */ @@ -214,8 +214,8 @@ dict_id_is_valid (const struct dictionary *dict, const char *id, void dict_set_change_callback (struct dictionary *d, - void (*changed) (struct dictionary *, void*), - void *data) + void (*changed) (struct dictionary *, void*), + void *data) { d->changed = changed; d->changed_data = data; @@ -246,8 +246,8 @@ dict_dump (const struct dictionary *d) */ void dict_set_callbacks (struct dictionary *dict, - const struct dict_callbacks *callbacks, - void *callback_data) + const struct dict_callbacks *callbacks, + void *callback_data) { dict->callbacks = callbacks; dict->cb_data = callback_data; @@ -256,7 +256,7 @@ dict_set_callbacks (struct dictionary *dict, /* Shallow copy the callbacks from SRC to DEST */ void dict_copy_callbacks (struct dictionary *dest, - const struct dictionary *src) + const struct dictionary *src) { dest->callbacks = src->callbacks; dest->cb_data = src->cb_data; @@ -568,10 +568,10 @@ dict_delete_consecutive_vars (struct dictionary *d, size_t idx, size_t count) dict_unset_varset_var (d, v); if (d->weight == v) - dict_set_weight (d, NULL); + dict_set_weight (d, NULL); if (d->filter == v) - dict_set_filter (d, NULL); + dict_set_filter (d, NULL); } dict_clear_vectors (d); @@ -1264,7 +1264,7 @@ dict_get_weight (const struct dictionary *d) found. */ double dict_get_case_weight (const struct dictionary *d, const struct ccase *c, - bool *warn_on_invalid) + bool *warn_on_invalid) { assert (c != NULL); @@ -1841,7 +1841,7 @@ dict_var_changed (const struct variable *v, unsigned int what, struct variable * struct dictionary *d = vardict->dict; if (NULL == d) - return; + return; if (what & (VAR_TRAIT_WIDTH | VAR_TRAIT_POSITION)) invalidate_proto (d); diff --git a/src/data/dictionary.h b/src/data/dictionary.h index 284d71ca95..02add403a9 100644 --- a/src/data/dictionary.h +++ b/src/data/dictionary.h @@ -96,7 +96,7 @@ void dict_set_names_must_be_ids (struct dictionary *, bool); /* Weight variable. */ double dict_get_case_weight (const struct dictionary *, - const struct ccase *, bool *); + const struct ccase *, bool *); double dict_get_rounded_case_weight (const struct dictionary *, const struct ccase *, bool *); struct variable *dict_get_weight (const struct dictionary *); @@ -213,12 +213,12 @@ struct dict_callbacks }; void dict_set_callbacks (struct dictionary *, const struct dict_callbacks *, - void *); + void *); void dict_copy_callbacks (struct dictionary *, const struct dictionary *); void dict_set_change_callback (struct dictionary *d, - void (*changed) (struct dictionary *, void*), - void *data); + void (*changed) (struct dictionary *, void*), + void *data); /* Debug use only. */ diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index e6bedcca87..5db7a6df6f 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -57,10 +57,10 @@ struct file_handle enum fh_referent referent; /* What the file handle refers to. */ /* FH_REF_FILE only. */ - char *file_name; /* File name as provided by user. */ - char *file_name_encoding; /* The character encoding of file_name, - This is NOT the encoding of the file contents! */ - enum fh_mode mode; /* File mode. */ + char *file_name; /* File name as provided by user. */ + char *file_name_encoding; /* The character encoding of file_name, + This is NOT the encoding of the file contents! */ + enum fh_mode mode; /* File mode. */ enum fh_line_ends line_ends; /* Line ends for text files. */ /* FH_REF_FILE and FH_REF_INLINE only. */ @@ -536,10 +536,10 @@ fh_lock (struct file_handle *h, enum fh_referent mask UNUSED, HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks) { if (0 == compare_fh_locks (lock, key)) - { - found_lock = true; - break; - } + { + found_lock = true; + break; + } } if (found_lock) @@ -575,10 +575,10 @@ fh_lock (struct file_handle *h, enum fh_referent mask UNUSED, HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks) { if (0 == compare_fh_locks (lock, key)) - { - found_lock = true; - break; - } + { + found_lock = true; + break; + } } assert (found_lock); @@ -605,7 +605,7 @@ fh_unlock (struct fh_lock *lock) assert (lock->open_cnt > 0); if (--lock->open_cnt == 0) { - hmap_delete (&locks, &lock->node); + hmap_delete (&locks, &lock->node); free_key (lock); free (lock); return false; @@ -650,10 +650,10 @@ fh_is_locked (const struct file_handle *handle, enum fh_access access) HMAP_FOR_EACH_WITH_HASH (k, struct fh_lock, node, hash, &locks) { if (0 == compare_fh_locks (k, &key)) - { - is_locked = true; - break; - } + { + is_locked = true; + break; + } } free_key (&key); @@ -785,11 +785,11 @@ fh_get_identity (const struct file_handle *fh) ok = GetFileInformationByHandle (h, &fi); if (ok) { - identity->device = fi.dwVolumeSerialNumber; - identity->inode = fi.nFileIndexHigh; - identity->inode <<= (sizeof fi.nFileIndexLow) * CHAR_BIT; - identity->inode |= fi.nFileIndexLow; - identity->name = 0; + identity->device = fi.dwVolumeSerialNumber; + identity->inode = fi.nFileIndexHigh; + identity->inode <<= (sizeof fi.nFileIndexLow) * CHAR_BIT; + identity->inode |= fi.nFileIndexLow; + identity->name = 0; } CloseHandle (h); } @@ -804,9 +804,9 @@ fh_get_identity (const struct file_handle *fh) char *cname = NULL; do { - bufsize = pathlen; - cname = xrealloc (cname, bufsize); - pathlen = GetFullPathName (file_name, bufsize, cname, NULL); + bufsize = pathlen; + cname = xrealloc (cname, bufsize); + pathlen = GetFullPathName (file_name, bufsize, cname, NULL); } while (pathlen > bufsize); identity->name = xstrdup (cname); diff --git a/src/data/file-name.c b/src/data/file-name.c index 184a79aa4f..43d0d3f2c6 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -99,7 +99,7 @@ fn_search_path (const char *base_name, char **path) struct stat temp; if (((stat (file, &temp) == 0) && (! S_ISDIR (temp.st_mode)))) - return file; + return file; free (file); } @@ -164,7 +164,7 @@ fn_open (const struct file_handle *fh, const char *mode) if (fn[0] == '|') { if (settings_get_safer_mode ()) - return safety_violation (fn); + return safety_violation (fn); return popen (&fn[1], mode[0] == 'r' ? "r" : "w"); } @@ -174,7 +174,7 @@ fn_open (const struct file_handle *fh, const char *mode) FILE *f; if (settings_get_safer_mode ()) - return safety_violation (fn); + return safety_violation (fn); s = xmalloca (strlen (fn)); memcpy (s, fn, strlen (fn) - 1); @@ -238,22 +238,22 @@ default_output_path (void) if (path == NULL) { /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference - to HOME, because the user can change HOME. */ + to HOME, because the user can change HOME. */ const char *home_dir = getenv ("HOME"); int i; if (home_dir == NULL) - { - const char *home_drive = getenv ("HOMEDRIVE"); - const char *home_path = getenv ("HOMEPATH"); + { + const char *home_drive = getenv ("HOMEDRIVE"); + const char *home_path = getenv ("HOMEPATH"); - if (home_drive != NULL && home_path != NULL) - home_dir = xasprintf ("%s%s", - home_drive, home_path); - } + if (home_drive != NULL && home_path != NULL) + home_dir = xasprintf ("%s%s", + home_drive, home_path); + } if (home_dir == NULL) - home_dir = "c:/users/default"; /* poor default */ + home_dir = "c:/users/default"; /* poor default */ /* Copy home_dir into path. Add a slash at the end but only if there isn't already one there, because Windows @@ -265,7 +265,7 @@ default_output_path (void) path = xstrdup (home_dir); for(i = 0; i < strlen (path); i++) - if (path[i] == '\\') path[i] = '/'; + if (path[i] == '\\') path[i] = '/'; } return path; diff --git a/src/data/format.c b/src/data/format.c index 87a40e2eed..c4180edf8d 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -236,7 +236,7 @@ fmt_for_output_from_input (struct fmt_spec input, case FMT_Z: output.w++; if (output.d > 0) - output.w++; + output.w++; break; case FMT_F: @@ -246,7 +246,7 @@ fmt_for_output_from_input (struct fmt_spec input, case FMT_PCT: { const struct fmt_number_style *style = - fmt_settings_get_style (settings, input.type); + fmt_settings_get_style (settings, input.type); output.w += fmt_affix_width (style); if (style->grouping != 0 && input.w - input.d >= 3) @@ -1431,7 +1431,7 @@ get_fmt_desc (enum fmt_type type) static const struct fmt_desc formats[FMT_NUMBER_OF_FORMATS] = { #define FMT(NAME, METHOD, IMIN, OMIN, IO, CATEGORY) \ - {#NAME, IMIN, OMIN, IO, CATEGORY}, + {#NAME, IMIN, OMIN, IO, CATEGORY}, #include "format.def" }; diff --git a/src/data/format.h b/src/data/format.h index b01faa42c4..c6c7c705dc 100644 --- a/src/data/format.h +++ b/src/data/format.h @@ -75,9 +75,9 @@ enum ATTRIBUTE ((packed)) fmt_type /* Display format. */ struct fmt_spec { - enum fmt_type type; /* One of FMT_*. */ - uint8_t d; /* Number of decimal places. */ - uint16_t w; /* Width. */ + enum fmt_type type; /* One of FMT_*. */ + uint8_t d; /* Number of decimal places. */ + uint16_t w; /* Width. */ }; /* Maximum width of any numeric format. */ diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index 87d9db6a69..fbeaf44f3a 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -63,7 +63,7 @@ enum gnm_value_type VALUE_EMPTY = 10, VALUE_BOOLEAN = 20, VALUE_INTEGER = 30, /* Note, this was removed from gnumeric in 2006 - old versions may of - course still be around. New ones are supposed to use float.*/ + course still be around. New ones are supposed to use float.*/ VALUE_FLOAT = 40, VALUE_ERROR = 50, VALUE_STRING = 60, @@ -228,18 +228,18 @@ gnumeric_get_sheet_range (struct spreadsheet *s, int n) struct gnumeric_reader *gr = (struct gnumeric_reader *) s; while ((gr->spreadsheet.sheets[n].last_col == -1) - && - (1 == (ret = xmlTextReaderRead (gr->msd.xtr)))) + && + (1 == (ret = xmlTextReaderRead (gr->msd.xtr)))) { process_node (gr, &gr->msd); } assert (n < gr->n_sheets); return create_cell_range ( - gr->spreadsheet.sheets[n].first_col, - gr->spreadsheet.sheets[n].first_row, - gr->spreadsheet.sheets[n].last_col, - gr->spreadsheet.sheets[n].last_row); + gr->spreadsheet.sheets[n].first_col, + gr->spreadsheet.sheets[n].first_row, + gr->spreadsheet.sheets[n].last_col, + gr->spreadsheet.sheets[n].last_row); } @@ -249,8 +249,8 @@ gnumeric_get_sheet_n_rows (struct spreadsheet *s, int n) struct gnumeric_reader *gr = (struct gnumeric_reader *) s; while ((gr->spreadsheet.sheets[n].last_col == -1) - && - (1 == xmlTextReaderRead (gr->msd.xtr))) + && + (1 == xmlTextReaderRead (gr->msd.xtr))) { process_node (gr, &gr->msd); } @@ -265,8 +265,8 @@ gnumeric_get_sheet_n_columns (struct spreadsheet *s, int n) struct gnumeric_reader *gr = (struct gnumeric_reader *) s; while ((gr->spreadsheet.sheets[n].last_col == -1) - && - (1 == xmlTextReaderRead (gr->msd.xtr))) + && + (1 == xmlTextReaderRead (gr->msd.xtr))) { process_node (gr, &gr->msd); } @@ -292,17 +292,17 @@ gnumeric_get_sheet_cell (struct spreadsheet *s, int n, int row, int column) hash = hash_int (column, hash); HMAP_FOR_EACH_WITH_HASH (lookup, struct cache_datum, node, hash, - &gr->cache) - { - if (lookup->row == row && lookup->col == column) - { - break; - } - } + &gr->cache) + { + if (lookup->row == row && lookup->col == column) + { + break; + } + } if (lookup) - { - return strdup (lookup->value); - } + { + return strdup (lookup->value); + } } struct state_data sd; @@ -353,28 +353,28 @@ gnumeric_get_sheet_cell (struct spreadsheet *s, int n, int row, int column) } if (use_cache) - { - /* See if this cell has already been cached ... */ - unsigned int hash = hash_int (current_row, 0); - hash = hash_int (current_col, hash); - struct cache_datum *probe = NULL; - HMAP_FOR_EACH_WITH_HASH (probe, struct cache_datum, node, hash, - &gr->cache) - { - if (probe->row == current_row && probe->col == current_col) - break; - } - /* If not, then cache it. */ - if (!probe) - { - char *str = CHAR_CAST (char *, xmlTextReaderValue (sd.xtr)); - struct cache_datum *cell_data = XMALLOC (struct cache_datum); - cell_data->row = current_row; - cell_data->col = current_col; - cell_data->value = str; - hmap_insert (&gr->cache, &cell_data->node, hash); - } - } + { + /* See if this cell has already been cached ... */ + unsigned int hash = hash_int (current_row, 0); + hash = hash_int (current_col, hash); + struct cache_datum *probe = NULL; + HMAP_FOR_EACH_WITH_HASH (probe, struct cache_datum, node, hash, + &gr->cache) + { + if (probe->row == current_row && probe->col == current_col) + break; + } + /* If not, then cache it. */ + if (!probe) + { + char *str = CHAR_CAST (char *, xmlTextReaderValue (sd.xtr)); + struct cache_datum *cell_data = XMALLOC (struct cache_datum); + cell_data->row = current_row; + cell_data->col = current_col; + cell_data->value = str; + hmap_insert (&gr->cache, &cell_data->node, hash); + } + } } while (xmlTextReaderRead (sd.xtr)) @@ -402,7 +402,7 @@ gnm_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) struct gnumeric_reader *r = r_; if (r == NULL) - return ; + return ; state_data_destroy (&r->rsd); @@ -430,175 +430,175 @@ process_node (struct gnumeric_reader *r, struct state_data *sd) case STATE_PRE_INIT: sd->current_sheet = -1; if (0 == xmlStrcasecmp (name, _xml("gnm:SheetNameIndex")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - sd->state = STATE_SHEET_COUNT; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + sd->state = STATE_SHEET_COUNT; + } break; case STATE_SHEET_COUNT: if (0 == xmlStrcasecmp (name, _xml("gnm:SheetName")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - ++sd->current_sheet; - if (sd->current_sheet + 1 > r->n_sheets) - { - struct sheet_detail *detail ; - r->spreadsheet.sheets = xrealloc (r->spreadsheet.sheets, (sd->current_sheet + 1) * sizeof *r->spreadsheet.sheets); - detail = &r->spreadsheet.sheets[sd->current_sheet]; - detail->first_col = detail->last_col = detail->first_row = detail->last_row = -1; - detail->name = NULL; - r->n_sheets = sd->current_sheet + 1; - } - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + ++sd->current_sheet; + if (sd->current_sheet + 1 > r->n_sheets) + { + struct sheet_detail *detail ; + r->spreadsheet.sheets = xrealloc (r->spreadsheet.sheets, (sd->current_sheet + 1) * sizeof *r->spreadsheet.sheets); + detail = &r->spreadsheet.sheets[sd->current_sheet]; + detail->first_col = detail->last_col = detail->first_row = detail->last_row = -1; + detail->name = NULL; + r->n_sheets = sd->current_sheet + 1; + } + } else if (0 == xmlStrcasecmp (name, _xml("gnm:SheetNameIndex")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_INIT; - sd->current_sheet = -1; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_INIT; + sd->current_sheet = -1; + } else if (XML_READER_TYPE_TEXT == sd->node_type) - { - if (r->spreadsheet.sheets [r->n_sheets - 1].name == NULL) - r->spreadsheet.sheets [r->n_sheets - 1].name = + { + if (r->spreadsheet.sheets [r->n_sheets - 1].name == NULL) + r->spreadsheet.sheets [r->n_sheets - 1].name = CHAR_CAST (char *, xmlTextReaderValue (sd->xtr)); - } + } break; case STATE_INIT: if (0 == xmlStrcasecmp (name, _xml("gnm:Sheet")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - ++sd->current_sheet; - sd->state = STATE_SHEET_START; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + ++sd->current_sheet; + sd->state = STATE_SHEET_START; + } break; case STATE_SHEET_START: if (0 == xmlStrcasecmp (name, _xml("gnm:Name")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - sd->state = STATE_SHEET_NAME; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + sd->state = STATE_SHEET_NAME; + } break; case STATE_SHEET_NAME: if (0 == xmlStrcasecmp (name, _xml("gnm:Name")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_INIT; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_INIT; + } else if (0 == xmlStrcasecmp (name, _xml("gnm:Sheet")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_INIT; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_INIT; + } else if (XML_READER_TYPE_TEXT == sd->node_type) - { - if (r->target_sheet_name != NULL) - { - xmlChar *value = xmlTextReaderValue (sd->xtr); - if (0 == xmlStrcmp (value, r->target_sheet_name)) - sd->state = STATE_SHEET_FOUND; - free (value); - } - else if (r->target_sheet_index == sd->current_sheet + 1) - { - sd->state = STATE_SHEET_FOUND; - } - else if (r->target_sheet_index == -1) - { - sd->state = STATE_SHEET_FOUND; - } - } + { + if (r->target_sheet_name != NULL) + { + xmlChar *value = xmlTextReaderValue (sd->xtr); + if (0 == xmlStrcmp (value, r->target_sheet_name)) + sd->state = STATE_SHEET_FOUND; + free (value); + } + else if (r->target_sheet_index == sd->current_sheet + 1) + { + sd->state = STATE_SHEET_FOUND; + } + else if (r->target_sheet_index == -1) + { + sd->state = STATE_SHEET_FOUND; + } + } break; case STATE_SHEET_FOUND: if (0 == xmlStrcasecmp (name, _xml("gnm:Cells")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - sd->min_col = INT_MAX; - if (! xmlTextReaderIsEmptyElement (sd->xtr)) - sd->state = STATE_CELLS_START; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + sd->min_col = INT_MAX; + if (! xmlTextReaderIsEmptyElement (sd->xtr)) + sd->state = STATE_CELLS_START; + } else if (0 == xmlStrcasecmp (name, _xml("gnm:MaxRow")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - sd->state = STATE_MAXROW; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + sd->state = STATE_MAXROW; + } else if (0 == xmlStrcasecmp (name, _xml("gnm:MaxCol")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - sd->state = STATE_MAXCOL; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + sd->state = STATE_MAXCOL; + } else if (0 == xmlStrcasecmp (name, _xml("gnm:Sheet")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_INIT; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_INIT; + } break; case STATE_MAXROW: if (0 == xmlStrcasecmp (name, _xml("gnm:MaxRow")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_SHEET_FOUND; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_SHEET_FOUND; + } else if (sd->node_type == XML_READER_TYPE_TEXT) - { - xmlChar *value = xmlTextReaderValue (sd->xtr); - xmlFree (value); - } + { + xmlChar *value = xmlTextReaderValue (sd->xtr); + xmlFree (value); + } break; case STATE_MAXCOL: if (0 == xmlStrcasecmp (name, _xml("gnm:MaxCol")) && - XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_SHEET_FOUND; - } + XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_SHEET_FOUND; + } else if (sd->node_type == XML_READER_TYPE_TEXT) - { - xmlChar *value = xmlTextReaderValue (sd->xtr); - xmlFree (value); - } + { + xmlChar *value = xmlTextReaderValue (sd->xtr); + xmlFree (value); + } break; case STATE_CELLS_START: if (0 == xmlStrcasecmp (name, _xml ("gnm:Cell")) && - XML_READER_TYPE_ELEMENT == sd->node_type) - { - xmlChar *attr = xmlTextReaderGetAttribute (sd->xtr, _xml ("Col")); - sd->col = _xmlchar_to_int (attr); - free (attr); - - if (sd->col < sd->min_col) - sd->min_col = sd->col; - - attr = xmlTextReaderGetAttribute (sd->xtr, _xml ("Row")); - sd->row = _xmlchar_to_int (attr); - free (attr); - - if (r->spreadsheet.sheets[sd->current_sheet].first_row == -1) - { - r->spreadsheet.sheets[sd->current_sheet].first_row = sd->row; - } - - if (r->spreadsheet.sheets[sd->current_sheet].first_col == -1) - { - r->spreadsheet.sheets[sd->current_sheet].first_col = sd->col; - } - if (! xmlTextReaderIsEmptyElement (sd->xtr)) - sd->state = STATE_CELL; - } + XML_READER_TYPE_ELEMENT == sd->node_type) + { + xmlChar *attr = xmlTextReaderGetAttribute (sd->xtr, _xml ("Col")); + sd->col = _xmlchar_to_int (attr); + free (attr); + + if (sd->col < sd->min_col) + sd->min_col = sd->col; + + attr = xmlTextReaderGetAttribute (sd->xtr, _xml ("Row")); + sd->row = _xmlchar_to_int (attr); + free (attr); + + if (r->spreadsheet.sheets[sd->current_sheet].first_row == -1) + { + r->spreadsheet.sheets[sd->current_sheet].first_row = sd->row; + } + + if (r->spreadsheet.sheets[sd->current_sheet].first_col == -1) + { + r->spreadsheet.sheets[sd->current_sheet].first_col = sd->col; + } + if (! xmlTextReaderIsEmptyElement (sd->xtr)) + sd->state = STATE_CELL; + } else if ((0 == xmlStrcasecmp (name, _xml("gnm:Cells"))) - && (XML_READER_TYPE_END_ELEMENT == sd->node_type)) - { - r->spreadsheet.sheets[sd->current_sheet].last_col = sd->col; - r->spreadsheet.sheets[sd->current_sheet].last_row = sd->row; - sd->state = STATE_SHEET_NAME; - } + && (XML_READER_TYPE_END_ELEMENT == sd->node_type)) + { + r->spreadsheet.sheets[sd->current_sheet].last_col = sd->col; + r->spreadsheet.sheets[sd->current_sheet].last_row = sd->row; + sd->state = STATE_SHEET_NAME; + } break; case STATE_CELL: if (0 == xmlStrcasecmp (name, _xml("gnm:Cell")) - && XML_READER_TYPE_END_ELEMENT == sd->node_type) - { - sd->state = STATE_CELLS_START; - } + && XML_READER_TYPE_END_ELEMENT == sd->node_type) + { + sd->state = STATE_CELLS_START; + } break; default: break; @@ -613,7 +613,7 @@ process_node (struct gnumeric_reader *r, struct state_data *sd) */ static void convert_xml_string_to_value (struct ccase *c, const struct variable *var, - const xmlChar *xv, enum gnm_value_type type, int col, int row) + const xmlChar *xv, enum gnm_value_type type, int col, int row) { union value *v = case_data_rw (c, var); @@ -629,7 +629,7 @@ convert_xml_string_to_value (struct ccase *c, const struct variable *var, errno = 0; v->f = c_strtod (text, &endptr); if (errno != 0 || endptr == text) - v->f = SYSMIS; + v->f = SYSMIS; } else { @@ -639,17 +639,17 @@ convert_xml_string_to_value (struct ccase *c, const struct variable *var, char *m = data_in (ss_cstr (text), "UTF-8", fmt.type, settings_get_fmt_settings (), v, var_get_width (var), - "UTF-8"); + "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"), - cell, fmt_to_string (fmt, buf), m); - free (cell); - } + { + 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"), + cell, fmt_to_string (fmt, buf), m); + free (cell); + } free (m); } } @@ -665,8 +665,8 @@ struct var_spec static void gnumeric_error_handler (void *ctx, const char *mesg, - xmlParserSeverities sev UNUSED, - xmlTextReaderLocatorPtr loc) + xmlParserSeverities sev UNUSED, + xmlTextReaderLocatorPtr loc) { struct gnumeric_reader *r = ctx; @@ -679,7 +679,7 @@ gnumeric_error_handler (void *ctx, const char *mesg, static struct casereader * gnumeric_make_reader (struct spreadsheet *spreadsheet, - const struct spreadsheet_read_options *opts) + const struct spreadsheet_read_options *opts) { int type = 0; int x = 0; @@ -697,13 +697,13 @@ gnumeric_make_reader (struct spreadsheet *spreadsheet, if (opts->cell_range) { if (! convert_cell_ref (opts->cell_range, - &r->spreadsheet.start_col, &r->spreadsheet.start_row, - &r->spreadsheet.stop_col, &r->spreadsheet.stop_row)) - { - msg (SE, _("Invalid cell range `%s'"), - opts->cell_range); - goto error; - } + &r->spreadsheet.start_col, &r->spreadsheet.start_row, + &r->spreadsheet.stop_col, &r->spreadsheet.stop_row)) + { + msg (SE, _("Invalid cell range `%s'"), + opts->cell_range); + goto error; + } } else { @@ -722,16 +722,16 @@ gnumeric_make_reader (struct spreadsheet *spreadsheet, /* Advance to the start of the cells for the target sheet */ while ((r->rsd.state != STATE_CELL || r->rsd.row < r->spreadsheet.start_row) - && 1 == (ret = xmlTextReaderRead (r->rsd.xtr))) + && 1 == (ret = xmlTextReaderRead (r->rsd.xtr))) { xmlChar *value ; process_node (r, &r->rsd); value = xmlTextReaderValue (r->rsd.xtr); if (r->rsd.state == STATE_MAXROW && r->rsd.node_type == XML_READER_TYPE_TEXT) - { - n_cases = 1 + _xmlchar_to_int (value) ; - } + { + n_cases = 1 + _xmlchar_to_int (value) ; + } free (value); } @@ -752,94 +752,94 @@ gnumeric_make_reader (struct spreadsheet *spreadsheet, /* Read in the first row of cells, including the headers if read_names was set */ while ( - ((r->rsd.state == STATE_CELLS_START && r->rsd.row <= r->spreadsheet.start_row) || r->rsd.state == STATE_CELL) - && (ret = xmlTextReaderRead (r->rsd.xtr)) - ) + ((r->rsd.state == STATE_CELLS_START && r->rsd.row <= r->spreadsheet.start_row) || r->rsd.state == STATE_CELL) + && (ret = xmlTextReaderRead (r->rsd.xtr)) + ) { int idx; if (r->rsd.state == STATE_CELL && r->rsd.node_type == XML_READER_TYPE_TEXT) - { - xmlChar *attr = - xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); + { + xmlChar *attr = + xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); - type = _xmlchar_to_int (attr); + type = _xmlchar_to_int (attr); - xmlFree (attr); - } + xmlFree (attr); + } process_node (r, &r->rsd); if (r->rsd.row > r->spreadsheet.start_row) - { - xmlChar *attr = - xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); + { + xmlChar *attr = + xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); - r->vtype = _xmlchar_to_int (attr); + r->vtype = _xmlchar_to_int (attr); - xmlFree (attr); - break; - } + xmlFree (attr); + break; + } if (r->rsd.col < r->spreadsheet.start_col || - (r->spreadsheet.stop_col != -1 && r->rsd.col > r->spreadsheet.stop_col)) - continue; + (r->spreadsheet.stop_col != -1 && r->rsd.col > r->spreadsheet.stop_col)) + continue; idx = r->rsd.col - r->spreadsheet.start_col; if (idx >= n_var_specs) - { - int i; - var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1)); - for (i = n_var_specs; i <= idx; ++i) - { - var_spec [i].name = NULL; - var_spec [i].width = -1; - var_spec [i].first_value = NULL; - var_spec [i].first_type = -1; - } - n_var_specs = idx + 1 ; - } + { + int i; + var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1)); + for (i = n_var_specs; i <= idx; ++i) + { + var_spec [i].name = NULL; + var_spec [i].width = -1; + var_spec [i].first_value = NULL; + var_spec [i].first_type = -1; + } + n_var_specs = idx + 1 ; + } var_spec [idx].first_type = type; if (r->rsd.node_type == XML_READER_TYPE_TEXT) - { - xmlChar *value = xmlTextReaderValue (r->rsd.xtr); - const char *text = CHAR_CAST (const char *, value); - - if (r->rsd.row < r->spreadsheet.start_row) - { - if (opts->read_names) - { - var_spec [idx].name = xstrdup (text); - } - } - else - { - var_spec [idx].first_value = xmlStrdup (value); - - if (-1 == var_spec [idx].width) - var_spec [idx].width = (opts->asw == -1) ? - ROUND_UP (strlen(text), SPREADSHEET_DEFAULT_WIDTH) : opts->asw; - } - - free (value); - } + { + xmlChar *value = xmlTextReaderValue (r->rsd.xtr); + const char *text = CHAR_CAST (const char *, value); + + if (r->rsd.row < r->spreadsheet.start_row) + { + if (opts->read_names) + { + var_spec [idx].name = xstrdup (text); + } + } + else + { + var_spec [idx].first_value = xmlStrdup (value); + + if (-1 == var_spec [idx].width) + var_spec [idx].width = (opts->asw == -1) ? + ROUND_UP (strlen(text), SPREADSHEET_DEFAULT_WIDTH) : opts->asw; + } + + free (value); + } else if (r->rsd.node_type == XML_READER_TYPE_ELEMENT - && r->rsd.state == STATE_CELL) - { - if (r->rsd.row == r->spreadsheet.start_row) - { - xmlChar *attr = - xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); - - if (NULL == attr || VALUE_STRING != _xmlchar_to_int (attr)) - var_spec [idx].width = 0; - - free (attr); - } - } + && r->rsd.state == STATE_CELL) + { + if (r->rsd.row == r->spreadsheet.start_row) + { + xmlChar *attr = + xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); + + if (NULL == attr || VALUE_STRING != _xmlchar_to_int (attr)) + var_spec [idx].width = 0; + + free (attr); + } + } } { @@ -854,12 +854,12 @@ gnumeric_make_reader (struct spreadsheet *spreadsheet, { struct var_spec *vs = &var_spec[i]; if (vs->name == NULL && !vs->first_value) - continue; + continue; /* Probably no data exists for this variable, so allocate a - default width */ + default width */ if (vs->width == -1) - vs->width = SPREADSHEET_DEFAULT_WIDTH; + vs->width = SPREADSHEET_DEFAULT_WIDTH; dict_create_var_with_unique_name (r->spreadsheet.dict, vs->name, vs->width); @@ -885,15 +885,15 @@ gnumeric_make_reader (struct spreadsheet *spreadsheet, const struct variable *var; if ((var_spec[i].name == NULL) && (var_spec[i].first_value == NULL)) - continue; + continue; var = dict_get_var (r->spreadsheet.dict, x++); convert_xml_string_to_value (r->spreadsheet.first_case, var, - var_spec[i].first_value, - var_spec[i].first_type, - r->rsd.col + i - 1, - r->rsd.row - 1); + var_spec[i].first_value, + var_spec[i].first_type, + r->rsd.col + i - 1, + r->rsd.row - 1); } for (i = 0 ; i < n_var_specs ; ++i) @@ -952,42 +952,42 @@ gnm_file_casereader_read (struct casereader *reader UNUSED, void *r_) while ((r->rsd.state == STATE_CELL || r->rsd.state == STATE_CELLS_START) - && r->rsd.row == current_row && (ret = xmlTextReaderRead (r->rsd.xtr))) + && r->rsd.row == current_row && (ret = xmlTextReaderRead (r->rsd.xtr))) { process_node (r, &r->rsd); if (r->rsd.state == STATE_CELL && r->rsd.node_type == XML_READER_TYPE_ELEMENT) - { - xmlChar *attr = - xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); + { + xmlChar *attr = + xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType")); - r->vtype = _xmlchar_to_int (attr); + r->vtype = _xmlchar_to_int (attr); - xmlFree (attr); - } + xmlFree (attr); + } if (r->rsd.col < r->spreadsheet.start_col || (r->spreadsheet.stop_col != -1 && - r->rsd.col > r->spreadsheet.stop_col)) - continue; + r->rsd.col > r->spreadsheet.stop_col)) + continue; if (r->rsd.col - r->spreadsheet.start_col >= caseproto_get_n_widths (r->spreadsheet.proto)) - continue; + continue; if (r->spreadsheet.stop_row != -1 && r->rsd.row > r->spreadsheet.stop_row) - break; + break; if (r->rsd.node_type == XML_READER_TYPE_TEXT) - { - xmlChar *value = xmlTextReaderValue (r->rsd.xtr); - const int idx = r->rsd.col - r->spreadsheet.start_col; - const struct variable *var = dict_get_var (r->spreadsheet.dict, idx); + { + xmlChar *value = xmlTextReaderValue (r->rsd.xtr); + const int idx = r->rsd.col - r->spreadsheet.start_col; + const struct variable *var = dict_get_var (r->spreadsheet.dict, idx); - convert_xml_string_to_value (c, var, value, r->vtype, - r->rsd.col, r->rsd.row); + convert_xml_string_to_value (c, var, value, r->vtype, + r->rsd.col, r->rsd.row); - xmlFree (value); - } + xmlFree (value); + } } if (ret == 1) @@ -1051,15 +1051,15 @@ gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_erro { xtr = xmlReaderForIO ((xmlInputReadCallback) gzread, - (xmlInputCloseCallback) gzclose, gz, - NULL, NULL, - show_errors ? 0 : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING)); + (xmlInputCloseCallback) gzclose, gz, + NULL, NULL, + show_errors ? 0 : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING)); if (xtr == NULL) { - gzclose (gz); - free (r); - return NULL; + gzclose (gz); + free (r); + return NULL; } if (show_errors) @@ -1079,7 +1079,7 @@ gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_erro spreadsheet. */ while ((sd->state != STATE_INIT) - && 1 == (ret = xmlTextReaderRead (sd->xtr))) + && 1 == (ret = xmlTextReaderRead (sd->xtr))) { process_node (r, sd); } @@ -1097,14 +1097,14 @@ gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_erro xmlCharEncoding xce = xmlParseCharEncoding (CHAR_CAST (const char *, enc)); if (XML_CHAR_ENCODING_UTF8 != xce) - { - /* 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."), - r->spreadsheet.file_name, - enc); - } + { + /* 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."), + r->spreadsheet.file_name, + enc); + } } return r; diff --git a/src/data/make-file.c b/src/data/make-file.c index a1a541a5d0..0090c09c43 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -213,10 +213,10 @@ replace_file_start (const struct file_handle *fh, const char *mode, 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); + free (Tfile_name); return NULL; } @@ -224,11 +224,11 @@ replace_file_start (const struct file_handle *fh, const char *mode, *fp = fdopen (fd, mode); if (*fp == NULL) { - saved_errno = errno; - msg (ME, _("Opening stream for %s: %s."), + saved_errno = errno; + msg (ME, _("Opening stream for %s: %s."), file_name, strerror (saved_errno)); close (fd); - free (Tfile_name); + free (Tfile_name); return NULL; } @@ -256,7 +256,7 @@ replace_file_start (const struct file_handle *fh, const char *mode, rf->tmp_name_verbatim = xasprintf ("%stmpXXXXXX", file_name); if (gen_tempname (rf->tmp_name_verbatim, 0, 0600, GT_NOCREATE) < 0) { - saved_errno = errno; + saved_errno = errno; msg (ME, _("Creating temporary file to replace %s: %s."), file_name, strerror (saved_errno)); goto error; @@ -273,7 +273,7 @@ replace_file_start (const struct file_handle *fh, const char *mode, break; if (errno != EEXIST) { - saved_errno = errno; + saved_errno = errno; msg (ME, _("Creating temporary file %s: %s."), rf->tmp_name_verbatim, strerror (saved_errno)); goto error; diff --git a/src/data/mdd-writer.c b/src/data/mdd-writer.c index a0387843a2..d540e2d127 100644 --- a/src/data/mdd-writer.c +++ b/src/data/mdd-writer.c @@ -88,7 +88,7 @@ struct mdd_writer { struct file_handle *fh; /* File handle. */ struct fh_lock *lock; /* Mutual exclusion for file. */ - FILE *file; /* File stream. */ + FILE *file; /* File stream. */ struct replace_file *rf; /* Ticket for replacing output file. */ xmlTextWriter *writer; @@ -470,7 +470,7 @@ mdd_write (struct file_handle *fh, struct dictionary *dict, if (!w->writer) { msg (ME, _("Internal error creating xmlTextWriter. " - "Please report this to %s."), PACKAGE_BUGREPORT); + "Please report this to %s."), PACKAGE_BUGREPORT); goto error; } diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index db2b401ba6..bc9399bc12 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -180,7 +180,7 @@ reading_target_sheet (const struct ods_reader *r, const struct state_data *sd) if (r->target_sheet_name != NULL) { if (0 == xmlStrcmp (r->target_sheet_name, sd->current_sheet_name)) - return true; + return true; } if (r->target_sheet_index == sd->current_sheet + 1) @@ -249,10 +249,10 @@ ods_get_sheet_range (struct spreadsheet *s, int n) state_data_destroy (&sd); return create_cell_range ( - r->spreadsheet.sheets[n].first_col, - r->spreadsheet.sheets[n].first_row, - r->spreadsheet.sheets[n].last_col, - r->spreadsheet.sheets[n].last_row); + r->spreadsheet.sheets[n].first_col, + r->spreadsheet.sheets[n].first_row, + r->spreadsheet.sheets[n].last_col, + r->spreadsheet.sheets[n].last_row); } static unsigned int @@ -405,70 +405,70 @@ process_node (struct ods_reader *or, struct state_data *r) { case STATE_INIT: if (0 == xmlStrcasecmp (name, _xml("office:spreadsheet")) && - XML_READER_TYPE_ELEMENT == r->node_type) - { - r->state = STATE_SPREADSHEET; - r->current_sheet = -1; - r->current_sheet_name = NULL; - } + XML_READER_TYPE_ELEMENT == r->node_type) + { + r->state = STATE_SPREADSHEET; + r->current_sheet = -1; + r->current_sheet_name = NULL; + } break; case STATE_SPREADSHEET: if (0 == xmlStrcasecmp (name, _xml("table:table")) - && - (XML_READER_TYPE_ELEMENT == r->node_type)) - { - xmlFree (r->current_sheet_name); - r->current_sheet_name = xmlTextReaderGetAttribute (r->xtr, _xml ("table:name")); - - ++r->current_sheet; - - if (r->current_sheet >= or->n_allocated_sheets) - { - assert (r->current_sheet == or->n_allocated_sheets); - or->spreadsheet.sheets = xrealloc (or->spreadsheet.sheets, sizeof (*or->spreadsheet.sheets) * ++or->n_allocated_sheets); - or->spreadsheet.sheets[or->n_allocated_sheets - 1].first_col = -1; - or->spreadsheet.sheets[or->n_allocated_sheets - 1].last_col = -1; - or->spreadsheet.sheets[or->n_allocated_sheets - 1].first_row = -1; - or->spreadsheet.sheets[or->n_allocated_sheets - 1].last_row = -1; - or->spreadsheet.sheets[or->n_allocated_sheets - 1].name = CHAR_CAST (char *, xmlStrdup (r->current_sheet_name)); - } - if (or->n_allocated_sheets > or->n_sheets) - or->n_sheets = or->n_allocated_sheets; - - r->col = 0; - r->row = 0; - - r->state = STATE_TABLE; - } + && + (XML_READER_TYPE_ELEMENT == r->node_type)) + { + xmlFree (r->current_sheet_name); + r->current_sheet_name = xmlTextReaderGetAttribute (r->xtr, _xml ("table:name")); + + ++r->current_sheet; + + if (r->current_sheet >= or->n_allocated_sheets) + { + assert (r->current_sheet == or->n_allocated_sheets); + or->spreadsheet.sheets = xrealloc (or->spreadsheet.sheets, sizeof (*or->spreadsheet.sheets) * ++or->n_allocated_sheets); + or->spreadsheet.sheets[or->n_allocated_sheets - 1].first_col = -1; + or->spreadsheet.sheets[or->n_allocated_sheets - 1].last_col = -1; + or->spreadsheet.sheets[or->n_allocated_sheets - 1].first_row = -1; + or->spreadsheet.sheets[or->n_allocated_sheets - 1].last_row = -1; + or->spreadsheet.sheets[or->n_allocated_sheets - 1].name = CHAR_CAST (char *, xmlStrdup (r->current_sheet_name)); + } + if (or->n_allocated_sheets > or->n_sheets) + or->n_sheets = or->n_allocated_sheets; + + r->col = 0; + r->row = 0; + + r->state = STATE_TABLE; + } else if (0 == xmlStrcasecmp (name, _xml("office:spreadsheet")) && - XML_READER_TYPE_ELEMENT == r->node_type) - { - r->state = STATE_INIT; - } + XML_READER_TYPE_ELEMENT == r->node_type) + { + r->state = STATE_INIT; + } break; case STATE_TABLE: 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")); + (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; + int row_span = value ? _xmlchar_to_int (value) : 1; - r->row += row_span; - r->col = 0; + r->row += row_span; + r->col = 0; - if (! xmlTextReaderIsEmptyElement (r->xtr)) - r->state = STATE_ROW; + if (! xmlTextReaderIsEmptyElement (r->xtr)) + r->state = STATE_ROW; - xmlFree (value); - } + xmlFree (value); + } else if (0 == xmlStrcasecmp (name, _xml("table:table")) && - (XML_READER_TYPE_END_ELEMENT == r->node_type)) - { - r->state = STATE_SPREADSHEET; - } + (XML_READER_TYPE_END_ELEMENT == r->node_type)) + { + r->state = STATE_SPREADSHEET; + } break; case STATE_CELL: @@ -476,18 +476,18 @@ process_node (struct ods_reader *or, struct state_data *r) /* Fall through. */ 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; - xmlFree (value); - - if (! xmlTextReaderIsEmptyElement (r->xtr)) + && + (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; + xmlFree (value); + + if (! xmlTextReaderIsEmptyElement (r->xtr)) { assert (r->current_sheet >= 0); assert (r->current_sheet < or->n_allocated_sheets); @@ -512,11 +512,11 @@ process_node (struct ods_reader *or, struct state_data *r) } } else if ((0 == xmlStrcasecmp (name, _xml ("table:table-row"))) - && - (XML_READER_TYPE_END_ELEMENT == r->node_type)) - { - r->state = STATE_TABLE; - } + && + (XML_READER_TYPE_END_ELEMENT == r->node_type)) + { + r->state = STATE_TABLE; + } break; default: NOT_REACHED (); @@ -561,10 +561,10 @@ xmv_to_width (const struct xml_value *xmv, int fallback) if (xmv->value) width = ROUND_UP (xmlStrlen (xmv->value), - SPREADSHEET_DEFAULT_WIDTH); + SPREADSHEET_DEFAULT_WIDTH); else if (xmv->text) width = ROUND_UP (xmlStrlen (xmv->text), - SPREADSHEET_DEFAULT_WIDTH); + SPREADSHEET_DEFAULT_WIDTH); return width; } @@ -574,7 +574,7 @@ xmv_to_width (const struct xml_value *xmv, int fallback) */ static void convert_xml_to_value (struct ccase *c, const struct variable *var, - const struct xml_value *xmv, int col, int row) + const struct xml_value *xmv, int col, int row) { union value *v = case_data_rw (c, var); @@ -592,29 +592,29 @@ convert_xml_to_value (struct ccase *c, const struct variable *var, assert (fc != FMT_CAT_STRING); if (0 == xmlStrcmp (xmv->type, _xml("float"))) - { - v->f = c_strtod (CHAR_CAST (const char *, xmv->value), NULL); - } + { + v->f = c_strtod (CHAR_CAST (const char *, xmv->value), NULL); + } else - { - const char *text = xmv->value ? - CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text); + { + const char *text = xmv->value ? + CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text); - char *m = data_in (ss_cstr (text), "UTF-8", fmt.type, + char *m = data_in (ss_cstr (text), "UTF-8", fmt.type, settings_get_fmt_settings (), 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"), - cell, fmt_to_string (fmt, buf), m); - free (cell); - } - free (m); - } + 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"), + cell, fmt_to_string (fmt, buf), m); + free (cell); + } + free (m); + } } } @@ -637,20 +637,20 @@ get_sheet_count (struct zip_reader *zreader) { xmlChar *name = xmlTextReaderName (mxtr); if (0 == xmlStrcmp (name, _xml("meta:document-statistic"))) - { - xmlChar *attr = xmlTextReaderGetAttribute (mxtr, _xml ("meta:table-count")); + { + xmlChar *attr = xmlTextReaderGetAttribute (mxtr, _xml ("meta:table-count")); - if (attr != NULL) - { - int s = _xmlchar_to_int (attr); - xmlFreeTextReader (mxtr); + if (attr != NULL) + { + int s = _xmlchar_to_int (attr); + xmlFreeTextReader (mxtr); zip_member_finish (meta); - xmlFree (name); - xmlFree (attr); - return s; - } - xmlFree (attr); - } + xmlFree (name); + xmlFree (attr); + return s; + } + xmlFree (attr); + } xmlFree (name); } @@ -675,8 +675,8 @@ ods_get_sheet_n_sheets (struct spreadsheet *s) static void ods_error_handler (void *ctx, const char *mesg, - xmlParserSeverities sev UNUSED, - xmlTextReaderLocatorPtr loc) + xmlParserSeverities sev UNUSED, + xmlTextReaderLocatorPtr loc) { struct ods_reader *r = ctx; @@ -692,7 +692,7 @@ static bool init_reader (struct ods_reader *r, bool report_errors, struct state_ static struct casereader * ods_make_reader (struct spreadsheet *spreadsheet, - const struct spreadsheet_read_options *opts) + const struct spreadsheet_read_options *opts) { xmlChar *type = NULL; casenumber n_cases = CASENUMBER_MAX; @@ -716,13 +716,13 @@ ods_make_reader (struct spreadsheet *spreadsheet, if (opts->cell_range) { if (! convert_cell_ref (opts->cell_range, - &r->spreadsheet.start_col, &r->spreadsheet.start_row, - &r->spreadsheet.stop_col, &r->spreadsheet.stop_row)) - { - msg (SE, _("Invalid cell range `%s'"), - opts->cell_range); - goto error; - } + &r->spreadsheet.start_col, &r->spreadsheet.start_row, + &r->spreadsheet.stop_col, &r->spreadsheet.stop_row)) + { + msg (SE, _("Invalid cell range `%s'"), + opts->cell_range); + goto error; + } } else { @@ -749,44 +749,44 @@ ods_make_reader (struct spreadsheet *spreadsheet, if (opts->read_names) { while (process_node (r, &r->rsd)) - { - /* If the row is finished then stop for now */ - if (r->rsd.state == STATE_TABLE && r->rsd.row > r->spreadsheet.start_row) - break; + { + /* If the row is finished then stop for now */ + if (r->rsd.state == STATE_TABLE && r->rsd.row > r->spreadsheet.start_row) + break; - int idx = r->rsd.col - r->spreadsheet.start_col - 1; + int idx = r->rsd.col - r->spreadsheet.start_col - 1; - if (idx < 0) - continue; + if (idx < 0) + continue; - if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col) - continue; + if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col) + continue; - if (r->rsd.state == STATE_CELL) - { + if (r->rsd.state == STATE_CELL) + { char *value = CHAR_CAST (char *, xmlNodeGetContent ( xmlTextReaderExpand (r->rsd.xtr))); - if (idx >= n_var_specs) - { - var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1)); - - /* xrealloc (unlike realloc) doesn't initialise its memory to 0 */ - memset (var_spec + n_var_specs, - 0, - (idx - n_var_specs + 1) * sizeof (*var_spec)); - n_var_specs = idx + 1; - } - for (int i = 0; i < r->rsd.col_span; ++i) - { - var_spec[idx - i].firstval.text = 0; - var_spec[idx - i].firstval.value = 0; - var_spec[idx - i].firstval.type = 0; - var_spec[idx - i].name = xstrdup (value); - } - - xmlFree (value); - } - } + if (idx >= n_var_specs) + { + var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1)); + + /* xrealloc (unlike realloc) doesn't initialise its memory to 0 */ + memset (var_spec + n_var_specs, + 0, + (idx - n_var_specs + 1) * sizeof (*var_spec)); + n_var_specs = idx + 1; + } + for (int i = 0; i < r->rsd.col_span; ++i) + { + var_spec[idx - i].firstval.text = 0; + var_spec[idx - i].firstval.value = 0; + var_spec[idx - i].firstval.type = 0; + var_spec[idx - i].name = xstrdup (value); + } + + xmlFree (value); + } + } } /* Read in the first row of data */ @@ -794,39 +794,39 @@ ods_make_reader (struct spreadsheet *spreadsheet, { int idx; if (! reading_target_sheet (r, &r->rsd)) - break; + break; /* If the row is finished then stop for now */ if (r->rsd.state == STATE_TABLE && - r->rsd.row > r->spreadsheet.start_row + (opts->read_names ? 1 : 0)) - break; + r->rsd.row > r->spreadsheet.start_row + (opts->read_names ? 1 : 0)) + break; idx = r->rsd.col - r->spreadsheet.start_col - 1; if (idx < 0) - continue; + continue; if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col) - continue; + continue; if (r->rsd.state == STATE_CELL && - XML_READER_TYPE_ELEMENT == r->rsd.node_type) - { - type = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value-type")); - val_string = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value")); - } + XML_READER_TYPE_ELEMENT == r->rsd.node_type) + { + type = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value-type")); + val_string = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value")); + } if (r->rsd.state == STATE_CELL) - { - if (idx >= n_var_specs) - { - var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + r->rsd.col_span)); - memset (var_spec + n_var_specs, - 0, - (idx + r->rsd.col_span - n_var_specs) * sizeof (*var_spec)); - - var_spec [idx].name = NULL; - n_var_specs = idx + 1; - } + { + if (idx >= n_var_specs) + { + var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + r->rsd.col_span)); + memset (var_spec + n_var_specs, + 0, + (idx + r->rsd.col_span - n_var_specs) * sizeof (*var_spec)); + + var_spec [idx].name = NULL; + n_var_specs = idx + 1; + } for (int x = 0; x < r->rsd.col_span; ++x) { @@ -838,7 +838,7 @@ ods_make_reader (struct spreadsheet *spreadsheet, free (val_string); free (type); - } + } } /* Create the dictionary and populate it */ @@ -853,13 +853,13 @@ ods_make_reader (struct spreadsheet *spreadsheet, struct fmt_spec fmt; if (0 == xmlStrcmp (var_spec[i].firstval.type, _xml("date"))) - { - fmt.type = FMT_DATE; - fmt.d = 0; - fmt.w = 20; - } + { + fmt.type = FMT_DATE; + fmt.d = 0; + fmt.w = 20; + } else - fmt = fmt_default_for_width (width); + fmt = fmt_default_for_width (width); var_set_both_formats (var, fmt); } @@ -880,8 +880,8 @@ ods_make_reader (struct spreadsheet *spreadsheet, const struct variable *var = dict_get_var (r->spreadsheet.dict, i); convert_xml_to_value (r->spreadsheet.first_case, var, &var_spec[i].firstval, - r->rsd.col - n_var_specs + i, - r->rsd.row - 1); + r->rsd.col - n_var_specs + i, + r->rsd.row - 1); } /* Read in the first row of data */ @@ -960,47 +960,47 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_) while (process_node (r, &r->rsd)) { if (r->spreadsheet.stop_row != -1 && r->rsd.row > r->spreadsheet.stop_row + 1) - break; + break; if (r->rsd.state == STATE_CELL && - r->rsd.node_type == XML_READER_TYPE_ELEMENT) - { - type = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value-type")); - val_string = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value")); - } + r->rsd.node_type == XML_READER_TYPE_ELEMENT) + { + type = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value-type")); + val_string = xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("office:value")); + } if (r->rsd.state == STATE_CELL) - { - int col; - struct xml_value *xmv = XZALLOC (struct xml_value); - xmv->text = xmlNodeGetContent (xmlTextReaderExpand (r->rsd.xtr)); - xmv->value = val_string; - val_string = NULL; - xmv->type = type; - type = NULL; - - for (col = 0; col < r->rsd.col_span; ++col) - { - const struct variable *var; - const int idx = r->rsd.col - col - r->spreadsheet.start_col - 1; - if (idx < 0) - continue; - if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col) - break; - if (idx >= dict_get_n_vars (r->spreadsheet.dict)) - break; + { + int col; + struct xml_value *xmv = XZALLOC (struct xml_value); + xmv->text = xmlNodeGetContent (xmlTextReaderExpand (r->rsd.xtr)); + xmv->value = val_string; + val_string = NULL; + xmv->type = type; + type = NULL; + + for (col = 0; col < r->rsd.col_span; ++col) + { + const struct variable *var; + const int idx = r->rsd.col - col - r->spreadsheet.start_col - 1; + if (idx < 0) + continue; + if (r->spreadsheet.stop_col != -1 && idx > r->spreadsheet.stop_col - r->spreadsheet.start_col) + break; + if (idx >= dict_get_n_vars (r->spreadsheet.dict)) + break; var = dict_get_var (r->spreadsheet.dict, idx); - convert_xml_to_value (c, var, xmv, idx + r->spreadsheet.start_col, r->rsd.row - 1); - } - - xmlFree (xmv->text); - xmlFree (xmv->value); - xmlFree (xmv->type); - free (xmv); - } + convert_xml_to_value (c, var, xmv, idx + r->spreadsheet.start_col, r->rsd.row - 1); + } + + xmlFree (xmv->text); + xmlFree (xmv->value); + xmlFree (xmv->type); + free (xmv); + } if (r->rsd.state <= STATE_TABLE) - break; + break; } xmlFree (type); @@ -1026,16 +1026,16 @@ init_reader (struct ods_reader *r, bool report_errors, } xmlTextReaderPtr xtr = xmlReaderForIO (xml_reader_for_zip_member, NULL, content, NULL, NULL, - report_errors - ? 0 - : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING)); + report_errors + ? 0 + : (XML_PARSE_NOERROR | XML_PARSE_NOWARNING)); if (xtr == NULL) - return false; + return false; *state = (struct state_data) { .xtr = xtr, - .zm = content, - .state = STATE_INIT }; + .zm = content, + .state = STATE_INIT }; if (report_errors) xmlTextReaderSetErrorHandler (xtr, ods_error_handler, r); } diff --git a/src/data/pc+-file-reader.c b/src/data/pc+-file-reader.c index 8c35724138..cb3716cb50 100644 --- a/src/data/pc+-file-reader.c +++ b/src/data/pc+-file-reader.c @@ -70,8 +70,8 @@ struct pcp_main_header { char product[63]; /* "PCSPSS SYSTEM FILE..." */ unsigned int nominal_case_size; /* Number of var positions. */ - char creation_date[9]; /* "[m]m/dd/yy". */ - char creation_time[9]; /* "[H]H:MM:SS". */ + char creation_date[9]; /* "[m]m/dd/yy". */ + char creation_time[9]; /* "[H]H:MM:SS". */ char file_label[65]; /* File label. */ unsigned int weight_index; /* Index of weighting variable, 0 if none. */ }; diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index 213ad115c3..9c0fcf7086 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -73,12 +73,12 @@ struct pfm_reader struct any_read_info info; struct file_handle *fh; /* File handle. */ struct fh_lock *lock; /* Read lock for file. */ - FILE *file; /* File stream. */ + FILE *file; /* File stream. */ int line_length; /* Number of characters so far on this line. */ - char cc; /* Current character. */ + char cc; /* Current character. */ char *trans; /* 256-byte character set translation table. */ int n_vars; /* Number of variables. */ - int weight_index; /* 0-based index of weight variable, or -1. */ + int weight_index; /* 0-based index of weight variable, or -1. */ struct caseproto *proto; /* Format of output cases. */ bool ok; /* Set false on I/O error. */ }; @@ -359,7 +359,7 @@ read_float (struct pfm_reader *r) /* `*' indicates system-missing. */ if (match (r, '*')) { - advance (r); /* Probably a dot (.) but doesn't appear to matter. */ + advance (r); /* Probably a dot (.) but doesn't appear to matter. */ return SYSMIS; } @@ -368,33 +368,33 @@ read_float (struct pfm_reader *r) { int digit = base_30_value (r->cc); if (digit != -1) - { - got_digit = true; - - /* Make sure that multiplication by 30 will not overflow. */ - if (num > DBL_MAX * (1. / 30.)) - /* The value of the digit doesn't matter, since we have already - gotten as many digits as can be represented in a `double'. - This doesn't necessarily mean the result will overflow. - The exponent may reduce it to within range. - - We just need to record that there was another - digit so that we can multiply by 10 later. */ - ++exponent; - else - num = (num * 30.0) + digit; - - /* Keep track of the number of digits after the decimal point. - If we just divided by 30 here, we would lose precision. */ - if (got_dot) - --exponent; - } + { + got_digit = true; + + /* Make sure that multiplication by 30 will not overflow. */ + if (num > DBL_MAX * (1. / 30.)) + /* The value of the digit doesn't matter, since we have already + gotten as many digits as can be represented in a `double'. + This doesn't necessarily mean the result will overflow. + The exponent may reduce it to within range. + + We just need to record that there was another + digit so that we can multiply by 10 later. */ + ++exponent; + else + num = (num * 30.0) + digit; + + /* Keep track of the number of digits after the decimal point. + If we just divided by 30 here, we would lose precision. */ + if (got_dot) + --exponent; + } else if (!got_dot && r->cc == '.') - /* Record that we have found the decimal point. */ - got_dot = 1; + /* Record that we have found the decimal point. */ + got_dot = 1; else - /* Any other character terminates the number. */ - break; + /* Any other character terminates the number. */ + break; advance (r); } @@ -411,19 +411,19 @@ read_float (struct pfm_reader *r) int digit; for (advance (r); (digit = base_30_value (r->cc)) != -1; advance (r)) - { - if (exp > LONG_MAX / 30) + { + if (exp > LONG_MAX / 30) { exp = LONG_MAX; break; } - exp = exp * 30 + digit; - } + exp = exp * 30 + digit; + } /* We don't check whether there were actually any digits, but we probably should. */ if (negative_exponent) - exp = -exp; + exp = -exp; exponent += exp; } @@ -700,18 +700,18 @@ read_variables (struct pfm_reader *r, struct dictionary *dict) int j; if (!match (r, '7')) - error (r, _("Expected variable record.")); + error (r, _("Expected variable record.")); width = read_int (r); if (width < 0) - error (r, _("Invalid variable width %d."), width); + error (r, _("Invalid variable width %d."), width); read_string (r, name); for (j = 0; j < 6; j++) fmt[j] = read_int (r); if (width < 0 || width > 255) - error (r, _("Bad width %d for variable %s."), width, name); + error (r, _("Bad width %d for variable %s."), width, name); v = dict_create_var_with_unique_name (dict, name, width); if (utf8_strcasecmp (name, var_get_name (v))) @@ -807,12 +807,12 @@ read_value_label (struct pfm_reader *r, struct dictionary *dict) v[i] = dict_lookup_var (dict, name); if (v[i] == NULL) - error (r, _("Unknown variable %s while parsing value labels."), name); + error (r, _("Unknown variable %s while parsing value labels."), name); if (var_get_type (v[0]) != var_get_type (v[i])) - error (r, _("Cannot assign value labels to %s and %s, which " - "have different variable types."), - var_get_name (v[0]), var_get_name (v[i])); + error (r, _("Cannot assign value labels to %s and %s, which " + "have different variable types."), + var_get_name (v[0]), var_get_name (v[i])); } n_labels = read_int (r); diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 3d9b4b3fb3..c2132e11aa 100644 --- a/src/data/por-file-writer.c +++ b/src/data/por-file-writer.c @@ -58,10 +58,10 @@ struct pfm_writer { struct file_handle *fh; /* File handle. */ struct fh_lock *lock; /* Lock on file handle. */ - FILE *file; /* File stream. */ + FILE *file; /* File stream. */ struct replace_file *rf; /* Ticket for replacing output file. */ - int lc; /* Number of characters on this line so far. */ + int lc; /* Number of characters on this line so far. */ size_t n_vars; /* Number of variables. */ struct pfm_var *vars; /* Variables. */ @@ -409,7 +409,7 @@ write_value_labels (struct pfm_writer *w, const struct dictionary *dict) int j; if (n_labels == 0) - continue; + continue; buf_write (w, "D", 1); write_int (w, 1); diff --git a/src/data/psql-reader.c b/src/data/psql-reader.c index 63d9cad3d1..21354e0d7c 100644 --- a/src/data/psql-reader.c +++ b/src/data/psql-reader.c @@ -167,9 +167,9 @@ dump (const unsigned char *x, int l) for (i = 0; i < l ; ++i) { if (isprint (x[i])) - printf ("%c ", x[i]); + printf ("%c ", x[i]); else - printf (" "); + printf (" "); } putchar ('\n'); @@ -178,7 +178,7 @@ dump (const unsigned char *x, int l) static struct variable * create_var (struct psql_reader *r, struct fmt_spec fmt, - int width, const char *suggested_name, int col) + int width, const char *suggested_name, int col) { struct variable *var = dict_create_var_with_unique_name (r->dict, suggested_name, width); @@ -240,7 +240,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if (PQstatus (r->conn) != CONNECTION_OK) { msg (ME, _("Error opening psql source: %s."), - PQerrorMessage (r->conn)); + PQerrorMessage (r->conn)); goto error; } @@ -253,12 +253,12 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if (ver_num < 8) { - msg (ME, - _("Postgres server is version %s." - " Reading from versions earlier than 8.0 is not supported."), - vers); + msg (ME, + _("Postgres server is version %s." + " Reading from versions earlier than 8.0 is not supported."), + vers); - goto error; + goto error; } } @@ -273,11 +273,11 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) #endif { if (! info->allow_clear) - { - msg (ME, _("Connection is unencrypted, " - "but unencrypted connections have not been permitted.")); - goto error; - } + { + msg (ME, _("Connection is unencrypted, " + "but unencrypted connections have not been permitted.")); + goto error; + } } r->postgres_epoch = calendar_gregorian_to_offset ( @@ -315,7 +315,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if (PQresultStatus (qres) != PGRES_COMMAND_OK) { msg (ME, _("Error from psql source: %s."), - PQresultErrorMessage (qres)); + PQresultErrorMessage (qres)); goto error; } @@ -339,7 +339,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if (PQresultStatus (qres) != PGRES_TUPLES_OK) { msg (ME, _("Error from psql source: %s."), - PQresultErrorMessage (qres)); + PQresultErrorMessage (qres)); goto error; } n_cases = atol (PQgetvalue (qres, 0, 0)); @@ -349,7 +349,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) if (PQresultStatus (qres) != PGRES_TUPLES_OK) { msg (ME, _("Error from psql source: %s."), - PQresultErrorMessage (qres)); + PQresultErrorMessage (qres)); goto error; } @@ -369,146 +369,146 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) int length ; /* If there are no data then make a finger in the air - guess at the contents */ + guess at the contents */ if (n_tuples > 0) - length = PQgetlength (qres, 0, i); + length = PQgetlength (qres, 0, i); else - length = PSQL_DEFAULT_WIDTH; + length = PSQL_DEFAULT_WIDTH; switch (type) - { - case BOOLOID: + { + case BOOLOID: case OIDOID: - case INT2OID: - case INT4OID: + case INT2OID: + case INT4OID: case INT8OID: case FLOAT4OID: - case FLOAT8OID: - fmt.type = FMT_F; - break; - case CASHOID: - fmt.type = FMT_DOLLAR; - break; + case FLOAT8OID: + fmt.type = FMT_F; + break; + case CASHOID: + fmt.type = FMT_DOLLAR; + break; case CHAROID: - fmt.type = FMT_A; - width = length > 0 ? length : 1; - fmt.d = 0; - fmt.w = 1; - break; + fmt.type = FMT_A; + width = length > 0 ? length : 1; + fmt.d = 0; + fmt.w = 1; + break; case TEXTOID: - case VARCHAROID: - case BPCHAROID: - fmt.type = FMT_A; - width = (info->str_width == -1) ? - ROUND_UP (length, PSQL_DEFAULT_WIDTH) : info->str_width; - fmt.w = width; - fmt.d = 0; + case VARCHAROID: + case BPCHAROID: + fmt.type = FMT_A; + width = (info->str_width == -1) ? + ROUND_UP (length, PSQL_DEFAULT_WIDTH) : info->str_width; + fmt.w = width; + fmt.d = 0; + break; + case BYTEAOID: + fmt.type = FMT_AHEX; + width = length > 0 ? length : PSQL_DEFAULT_WIDTH; + fmt.w = width * 2; + fmt.d = 0; + break; + case INTERVALOID: + fmt.type = FMT_DTIME; + width = 0; + fmt.d = 0; + fmt.w = 13; + break; + case DATEOID: + fmt.type = FMT_DATE; + width = 0; + fmt.w = 11; + fmt.d = 0; + break; + case TIMEOID: + case TIMETZOID: + fmt.type = FMT_TIME; + width = 0; + fmt.w = 11; + fmt.d = 0; + break; + case TIMESTAMPOID: + case TIMESTAMPTZOID: + fmt.type = FMT_DATETIME; + fmt.d = 0; + fmt.w = 22; + width = 0; + break; + case NUMERICOID: + fmt.type = FMT_E; + fmt.d = 2; + fmt.w = 40; + width = 0; break; - case BYTEAOID: - fmt.type = FMT_AHEX; - width = length > 0 ? length : PSQL_DEFAULT_WIDTH; - fmt.w = width * 2; - fmt.d = 0; - break; - case INTERVALOID: - fmt.type = FMT_DTIME; - width = 0; - fmt.d = 0; - fmt.w = 13; - break; - case DATEOID: - fmt.type = FMT_DATE; - width = 0; - fmt.w = 11; - fmt.d = 0; - break; - case TIMEOID: - case TIMETZOID: - fmt.type = FMT_TIME; - width = 0; - fmt.w = 11; - fmt.d = 0; - break; - case TIMESTAMPOID: - case TIMESTAMPTZOID: - fmt.type = FMT_DATETIME; - fmt.d = 0; - fmt.w = 22; - width = 0; - break; - case NUMERICOID: - fmt.type = FMT_E; - fmt.d = 2; - fmt.w = 40; - width = 0; - break; - default: + default: msg (MW, _("Unsupported OID %d. SYSMIS values will be inserted."), type); - fmt.type = FMT_A; - width = length > 0 ? length : PSQL_DEFAULT_WIDTH; - fmt.w = width ; - fmt.d = 0; - break; - } + fmt.type = FMT_A; + width = length > 0 ? length : PSQL_DEFAULT_WIDTH; + fmt.w = width ; + fmt.d = 0; + break; + } if (width == 0 && fmt_is_string (fmt.type)) - fmt.w = width = PSQL_DEFAULT_WIDTH; + fmt.w = width = PSQL_DEFAULT_WIDTH; var = create_var (r, fmt, width, PQfname (qres, i), i); if (type == NUMERICOID && n_tuples > 0) - { - const uint8_t *vptr = (const uint8_t *) PQgetvalue (qres, 0, i); - struct fmt_spec fmt; - int16_t n_digits, weight, dscale; - uint16_t sign; - - GET_VALUE (&vptr, n_digits); - GET_VALUE (&vptr, weight); - GET_VALUE (&vptr, sign); - GET_VALUE (&vptr, dscale); - - fmt.d = dscale; - fmt.type = FMT_E; - fmt.w = fmt_max_output_width (fmt.type) ; - fmt.d = MIN (dscale, fmt_max_output_decimals (fmt.type, fmt.w)); - var_set_both_formats (var, fmt); - } + { + const uint8_t *vptr = (const uint8_t *) PQgetvalue (qres, 0, i); + struct fmt_spec fmt; + int16_t n_digits, weight, dscale; + uint16_t sign; + + GET_VALUE (&vptr, n_digits); + GET_VALUE (&vptr, weight); + GET_VALUE (&vptr, sign); + GET_VALUE (&vptr, dscale); + + fmt.d = dscale; + fmt.type = FMT_E; + fmt.w = fmt_max_output_width (fmt.type) ; + fmt.d = MIN (dscale, fmt_max_output_decimals (fmt.type, fmt.w)); + var_set_both_formats (var, fmt); + } /* Timezones need an extra variable */ switch (type) - { - case TIMETZOID: - { - struct string name; - ds_init_cstr (&name, var_get_name (var)); - ds_put_cstr (&name, "-zone"); - fmt.type = FMT_F; - fmt.w = 8; - fmt.d = 2; - - create_var (r, fmt, 0, ds_cstr (&name), -1); - - ds_destroy (&name); - } - break; - - case INTERVALOID: - { - struct string name; - ds_init_cstr (&name, var_get_name (var)); - ds_put_cstr (&name, "-months"); - fmt.type = FMT_F; - fmt.w = 3; - fmt.d = 0; - - create_var (r, fmt, 0, ds_cstr (&name), -1); - - ds_destroy (&name); - } - default: - break; - } + { + case TIMETZOID: + { + struct string name; + ds_init_cstr (&name, var_get_name (var)); + ds_put_cstr (&name, "-zone"); + fmt.type = FMT_F; + fmt.w = 8; + fmt.d = 2; + + create_var (r, fmt, 0, ds_cstr (&name), -1); + + ds_destroy (&name); + } + break; + + case INTERVALOID: + { + struct string name; + ds_init_cstr (&name, var_get_name (var)); + ds_put_cstr (&name, "-months"); + fmt.type = FMT_F; + fmt.w = 3; + fmt.d = 0; + + create_var (r, fmt, 0, ds_cstr (&name), -1); + + ds_destroy (&name); + } + default: + break; + } } PQclear (qres); @@ -569,7 +569,7 @@ psql_casereader_read (struct casereader *reader UNUSED, void *r_) if (NULL == r->res || r->tuple >= r->cache_size) { if (! reload_cache (r)) - return false; + return false; } return set_value (r); @@ -602,284 +602,284 @@ set_value (struct psql_reader *r) union value *val1 = NULL; switch (type) - { - case INTERVALOID: - case TIMESTAMPTZOID: - case TIMETZOID: - if (i < r->vmapsize && var_get_dict_index(v) + 1 < dict_get_n_vars (r->dict)) - { - const struct variable *v1 = NULL; - v1 = dict_get_var (r->dict, var_get_dict_index (v) + 1); - - val1 = case_data_rw (c, v1); - } - break; - default: - break; - } + { + case INTERVALOID: + case TIMESTAMPTZOID: + case TIMETZOID: + if (i < r->vmapsize && var_get_dict_index(v) + 1 < dict_get_n_vars (r->dict)) + { + const struct variable *v1 = NULL; + v1 = dict_get_var (r->dict, var_get_dict_index (v) + 1); + + val1 = case_data_rw (c, v1); + } + break; + default: + break; + } if (PQgetisnull (r->res, r->tuple, i)) - { - value_set_missing (val, var_get_width (v)); - - switch (type) - { - case INTERVALOID: - case TIMESTAMPTZOID: - case TIMETZOID: - val1->f = SYSMIS; - break; - default: - break; - } - } + { + value_set_missing (val, var_get_width (v)); + + switch (type) + { + case INTERVALOID: + case TIMESTAMPTZOID: + case TIMETZOID: + val1->f = SYSMIS; + break; + default: + break; + } + } else - { - const uint8_t *vptr = (const uint8_t *) PQgetvalue (r->res, r->tuple, i); - int length = PQgetlength (r->res, r->tuple, i); - - int var_width = var_get_width (v); - switch (type) - { - case BOOLOID: - { - int8_t x; - GET_VALUE (&vptr, x); - val->f = x; - } - break; - - case OIDOID: - case INT2OID: - { - int16_t x; - GET_VALUE (&vptr, x); - val->f = x; - } - break; - - case INT4OID: - { - int32_t x; - GET_VALUE (&vptr, x); - val->f = x; - } - break; - - case INT8OID: - { - int64_t x; - GET_VALUE (&vptr, x); - val->f = x; - } - break; - - case FLOAT4OID: - { - float n; - GET_VALUE (&vptr, n); - val->f = n; - } - break; - - case FLOAT8OID: - { - double n; - GET_VALUE (&vptr, n); - val->f = n; - } - break; - - case CASHOID: - { - /* Postgres 8.3 uses 64 bits. - Earlier versions use 32 */ - switch (length) - { - case 8: - { - int64_t x; - GET_VALUE (&vptr, x); - val->f = x / 100.0; - } - break; - case 4: - { - int32_t x; - GET_VALUE (&vptr, x); - val->f = x / 100.0; - } - break; - default: - val->f = SYSMIS; - break; - } - } - break; - - case INTERVALOID: - { - if (r->integer_datetimes) - { - uint32_t months; - uint32_t days; - uint32_t us; - uint32_t things; - - GET_VALUE (&vptr, things); - GET_VALUE (&vptr, us); - GET_VALUE (&vptr, days); - GET_VALUE (&vptr, months); - - val->f = us / 1000000.0; - val->f += days * 24 * 3600; - - val1->f = months; - } - else - { - uint32_t days, months; - double seconds; - - GET_VALUE (&vptr, seconds); - GET_VALUE (&vptr, days); - GET_VALUE (&vptr, months); - - val->f = seconds; - val->f += days * 24 * 3600; - - val1->f = months; - } - } - break; - - case DATEOID: - { - int32_t x; - - GET_VALUE (&vptr, x); - - val->f = (x + r->postgres_epoch) * 24 * 3600 ; - } - break; - - case TIMEOID: - { - if (r->integer_datetimes) - { - uint64_t x; - GET_VALUE (&vptr, x); - val->f = x / 1000000.0; - } - else - { - double x; - GET_VALUE (&vptr, x); - val->f = x; - } - } - break; - - case TIMETZOID: - { - int32_t zone; - if (r->integer_datetimes) - { - uint64_t x; - - - GET_VALUE (&vptr, x); - val->f = x / 1000000.0; - } - else - { - double x; - - GET_VALUE (&vptr, x); - val->f = x ; - } - - GET_VALUE (&vptr, zone); - val1->f = zone / 3600.0; - } - break; - - case TIMESTAMPOID: - case TIMESTAMPTZOID: - { - if (r->integer_datetimes) - { - int64_t x; - - GET_VALUE (&vptr, x); - - x /= 1000000; - - val->f = (x + r->postgres_epoch * 24 * 3600); - } - else - { - double x; - - GET_VALUE (&vptr, x); - - val->f = (x + r->postgres_epoch * 24 * 3600); - } - } - break; - case TEXTOID: - case VARCHAROID: - case BPCHAROID: - case BYTEAOID: - memcpy (val->s, vptr, MIN (length, var_width)); - break; - - case NUMERICOID: - { - double f = 0.0; - int i; - int16_t n_digits, weight, dscale; - uint16_t sign; - - GET_VALUE (&vptr, n_digits); - GET_VALUE (&vptr, weight); - GET_VALUE (&vptr, sign); - GET_VALUE (&vptr, dscale); + { + const uint8_t *vptr = (const uint8_t *) PQgetvalue (r->res, r->tuple, i); + int length = PQgetlength (r->res, r->tuple, i); + + int var_width = var_get_width (v); + switch (type) + { + case BOOLOID: + { + int8_t x; + GET_VALUE (&vptr, x); + val->f = x; + } + break; + + case OIDOID: + case INT2OID: + { + int16_t x; + GET_VALUE (&vptr, x); + val->f = x; + } + break; + + case INT4OID: + { + int32_t x; + GET_VALUE (&vptr, x); + val->f = x; + } + break; + + case INT8OID: + { + int64_t x; + GET_VALUE (&vptr, x); + val->f = x; + } + break; + + case FLOAT4OID: + { + float n; + GET_VALUE (&vptr, n); + val->f = n; + } + break; + + case FLOAT8OID: + { + double n; + GET_VALUE (&vptr, n); + val->f = n; + } + break; + + case CASHOID: + { + /* Postgres 8.3 uses 64 bits. + Earlier versions use 32 */ + switch (length) + { + case 8: + { + int64_t x; + GET_VALUE (&vptr, x); + val->f = x / 100.0; + } + break; + case 4: + { + int32_t x; + GET_VALUE (&vptr, x); + val->f = x / 100.0; + } + break; + default: + val->f = SYSMIS; + break; + } + } + break; + + case INTERVALOID: + { + if (r->integer_datetimes) + { + uint32_t months; + uint32_t days; + uint32_t us; + uint32_t things; + + GET_VALUE (&vptr, things); + GET_VALUE (&vptr, us); + GET_VALUE (&vptr, days); + GET_VALUE (&vptr, months); + + val->f = us / 1000000.0; + val->f += days * 24 * 3600; + + val1->f = months; + } + else + { + uint32_t days, months; + double seconds; + + GET_VALUE (&vptr, seconds); + GET_VALUE (&vptr, days); + GET_VALUE (&vptr, months); + + val->f = seconds; + val->f += days * 24 * 3600; + + val1->f = months; + } + } + break; + + case DATEOID: + { + int32_t x; + + GET_VALUE (&vptr, x); + + val->f = (x + r->postgres_epoch) * 24 * 3600 ; + } + break; + + case TIMEOID: + { + if (r->integer_datetimes) + { + uint64_t x; + GET_VALUE (&vptr, x); + val->f = x / 1000000.0; + } + else + { + double x; + GET_VALUE (&vptr, x); + val->f = x; + } + } + break; + + case TIMETZOID: + { + int32_t zone; + if (r->integer_datetimes) + { + uint64_t x; + + + GET_VALUE (&vptr, x); + val->f = x / 1000000.0; + } + else + { + double x; + + GET_VALUE (&vptr, x); + val->f = x ; + } + + GET_VALUE (&vptr, zone); + val1->f = zone / 3600.0; + } + break; + + case TIMESTAMPOID: + case TIMESTAMPTZOID: + { + if (r->integer_datetimes) + { + int64_t x; + + GET_VALUE (&vptr, x); + + x /= 1000000; + + val->f = (x + r->postgres_epoch * 24 * 3600); + } + else + { + double x; + + GET_VALUE (&vptr, x); + + val->f = (x + r->postgres_epoch * 24 * 3600); + } + } + break; + case TEXTOID: + case VARCHAROID: + case BPCHAROID: + case BYTEAOID: + memcpy (val->s, vptr, MIN (length, var_width)); + break; + + case NUMERICOID: + { + double f = 0.0; + int i; + int16_t n_digits, weight, dscale; + uint16_t sign; + + GET_VALUE (&vptr, n_digits); + GET_VALUE (&vptr, weight); + GET_VALUE (&vptr, sign); + GET_VALUE (&vptr, dscale); #if 0 - { - struct fmt_spec fmt; - fmt.d = dscale; - fmt.type = FMT_E; - fmt.w = fmt_max_output_width (fmt.type) ; - fmt.d = MIN (dscale, fmt_max_output_decimals (fmt.type, fmt.w)); - var_set_both_formats (v, &fmt); - } + { + struct fmt_spec fmt; + fmt.d = dscale; + fmt.type = FMT_E; + fmt.w = fmt_max_output_width (fmt.type) ; + fmt.d = MIN (dscale, fmt_max_output_decimals (fmt.type, fmt.w)); + var_set_both_formats (v, &fmt); + } #endif - for (i = 0 ; i < n_digits; ++i) - { - uint16_t x; - GET_VALUE (&vptr, x); - f += x * pow (10000, weight--); - } - - if (sign == 0x4000) - f *= -1.0; - - if (sign == 0xC000) - val->f = SYSMIS; - else - val->f = f; - } - break; - - default: - val->f = SYSMIS; - break; - } - } + for (i = 0 ; i < n_digits; ++i) + { + uint16_t x; + GET_VALUE (&vptr, x); + f += x * pow (10000, weight--); + } + + if (sign == 0x4000) + f *= -1.0; + + if (sign == 0xC000) + val->f = SYSMIS; + else + val->f = f; + } + break; + + default: + val->f = SYSMIS; + break; + } + } } r->tuple++; diff --git a/src/data/settings.c b/src/data/settings.c index 7e34a60ad4..3b7055245f 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -240,7 +240,7 @@ settings_get_output_integer_format (void) /* Sets the output integer format to INTEGER_FORMAT. */ void settings_set_output_integer_format ( - enum integer_format integer_format) + enum integer_format integer_format) { the_settings.output_integer_format = integer_format; } @@ -396,17 +396,17 @@ settings_set_max_messages (enum msg_severity severity, int max) if (severity == MSG_S_WARNING) { if (max == 0) - { - msg (MW, - _("MXWARNS set to zero. No further warnings will be given even when potentially problematic situations are encountered.")); - msg_ui_disable_warnings (true); - } + { + msg (MW, + _("MXWARNS set to zero. No further warnings will be given even when potentially problematic situations are encountered.")); + msg_ui_disable_warnings (true); + } else if (the_settings.max_messages [MSG_S_WARNING] == 0) - { - msg_ui_disable_warnings (false); - the_settings.max_messages[MSG_S_WARNING] = max; - msg (MW, _("Warnings re-enabled. %d warnings will be issued before aborting syntax processing."), max); - } + { + msg_ui_disable_warnings (false); + the_settings.max_messages[MSG_S_WARNING] = max; + msg (MW, _("Warnings re-enabled. %d warnings will be issued before aborting syntax processing."), max); + } } the_settings.max_messages[severity] = max; diff --git a/src/data/spreadsheet-reader.c b/src/data/spreadsheet-reader.c index 32021fa46c..8528853abb 100644 --- a/src/data/spreadsheet-reader.c +++ b/src/data/spreadsheet-reader.c @@ -125,8 +125,8 @@ create_cell_range (int col0, int row0, int coli, int rowi) */ bool convert_cell_ref (const char *ref, - int *col0, int *row0, - int *coli, int *rowi) + int *col0, int *row0, + int *coli, int *rowi) { char startcol[5]; char stopcol [5]; @@ -135,8 +135,8 @@ convert_cell_ref (const char *ref, int stoprow; int n = sscanf (ref, "%4[a-zA-Z]%d:%4[a-zA-Z]%d", - startcol, &startrow, - stopcol, &stoprow); + startcol, &startrow, + stopcol, &stoprow); if (n != 4) return false; diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index 8e13d03b13..eb68bf5e6b 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -33,7 +33,7 @@ struct spreadsheet_read_options { char *sheet_name ; /* The name of the sheet to open (in UTF-8) */ int sheet_index ; /* The index of the sheet to open (only used if sheet_name is NULL). - The first index is 1 NOT 0 */ + The first index is 1 NOT 0 */ char *cell_range ; /* The cell range (in UTF-8) */ bool read_names ; /* True if the first row is to be used as the names of the variables */ int asw ; /* The width of string variables in the created dictionary */ @@ -41,8 +41,8 @@ struct spreadsheet_read_options bool convert_cell_ref (const char *ref, - int *col0, int *row0, - int *coli, int *rowi); + int *col0, int *row0, + int *coli, int *rowi); #define _xml(X) (CHAR_CAST (const xmlChar *, (X))) @@ -72,7 +72,7 @@ struct spreadsheet void (*destroy) (struct spreadsheet *); struct casereader* (*make_reader) (struct spreadsheet *, - const struct spreadsheet_read_options *); + const struct spreadsheet_read_options *); const char * (*get_sheet_name) (struct spreadsheet *, int); char * (*get_sheet_range) (struct spreadsheet *, int); int (*get_sheet_n_sheets) (struct spreadsheet *); diff --git a/src/data/subcase.h b/src/data/subcase.h index 7abbef6d49..a07d7363c8 100644 --- a/src/data/subcase.h +++ b/src/data/subcase.h @@ -27,8 +27,8 @@ struct variable; /* Sort order. */ enum subcase_direction { - SC_ASCEND, /* A, B, C, ..., X, Y, Z. */ - SC_DESCEND /* Z, Y, X, ..., C, B, A. */ + SC_ASCEND, /* A, B, C, ..., X, Y, Z. */ + SC_DESCEND /* Z, Y, X, ..., C, B, A. */ }; /* A value within a case. */ @@ -55,7 +55,7 @@ void subcase_init_vars (struct subcase *, void subcase_init_var (struct subcase *, const struct variable *, enum subcase_direction); void subcase_init (struct subcase *, int index, int width, - enum subcase_direction); + enum subcase_direction); void subcase_clone (struct subcase *, const struct subcase *); void subcase_clear (struct subcase *); @@ -65,7 +65,7 @@ bool subcase_contains (const struct subcase *, int case_index); bool subcase_contains_var (const struct subcase *, const struct variable *); bool subcase_add (struct subcase *, int case_index, int width, - enum subcase_direction direction); + enum subcase_direction direction); bool subcase_add_var (struct subcase *, const struct variable *, enum subcase_direction); diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 692f90252b..c13d023424 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -102,8 +102,8 @@ struct sfm_header_record /* These correspond to the members of struct any_file_info or a dictionary but in the system file's encoding rather than ASCII. */ - char creation_date[10]; /* "dd mmm yy". */ - char creation_time[9]; /* "hh:mm:ss". */ + char creation_date[10]; /* "dd mmm yy". */ + char creation_time[9]; /* "hh:mm:ss". */ char eye_catcher[61]; /* Eye-catcher string, then product name. */ char file_label[65]; /* File label. */ }; @@ -208,7 +208,7 @@ struct sfm_reader /* Decompression. */ enum any_compression compression; - double bias; /* Compression bias, usually 100.0. */ + double bias; /* Compression bias, usually 100.0. */ uint8_t opcodes[8]; /* Current block of opcodes. */ size_t opcode_idx; /* Next opcode to interpret, 8 if none left. */ bool corruption_warning; /* Warned about possible corruption? */ @@ -1866,7 +1866,7 @@ decode_mrsets (struct sfm_reader *r, struct dictionary *dict) sys_warn (r, -1, _("MRSET %s has only one variable."), mrset->name); mrset_destroy (mrset); - stringi_set_destroy (&var_names); + stringi_set_destroy (&var_names); continue; } @@ -1955,8 +1955,8 @@ parse_display_parameters (struct sfm_reader *r, : ALIGN_CENTRE)); /* Older versions (SPSS 9.0) sometimes set the display - width to zero. This causes confusion in the GUI, so - only set the width if it is nonzero. */ + width to zero. This causes confusion in the GUI, so + only set the width if it is nonzero. */ if (width > 0) var_set_display_width (v, width); } @@ -2013,14 +2013,14 @@ parse_long_var_name_map (struct sfm_reader *r, size_t i; for (i = 0; i < dict_get_n_vars (dict); i++) - { - struct variable *var = dict_get_var (dict, i); + { + struct variable *var = dict_get_var (dict, i); char *new_name; new_name = utf8_to_lower (var_get_name (var)); rename_var_and_save_short_names (r, -1, dict, var, new_name); free (new_name); - } + } return; } @@ -2541,7 +2541,7 @@ parse_long_string_value_labels (struct sfm_reader *r, /* Parse values. */ value_init_pool (r->pool, &value, width); for (i = 0; i < n_labels; i++) - { + { size_t value_length, label_length; bool skip = var == NULL; @@ -2664,7 +2664,7 @@ parse_long_string_missing_values (struct sfm_reader *r, /* Parse values. */ mv_init_pool (r->pool, &mv, var ? var_get_width (var) : 8); for (i = 0; i < n_missing_values; i++) - { + { /* Tolerate files written by old, buggy versions of PSPP where we believed that the value_length was repeated before each missing value. */ @@ -3179,7 +3179,7 @@ text_get_token (struct text_record *text, struct substring delimiters, if (!ss_tokenize (text->buffer, delimiters, &text->pos, &token)) { if (delimiter != NULL) - *delimiter = ss_data (text->buffer)[text->pos-1]; + *delimiter = ss_data (text->buffer)[text->pos-1]; return NULL; } diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 34f420e4a4..147605ecb9 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -70,7 +70,7 @@ struct sfm_writer { struct file_handle *fh; /* File handle. */ struct fh_lock *lock; /* Mutual exclusion for file. */ - FILE *file; /* File stream. */ + FILE *file; /* File stream. */ struct replace_file *rf; /* Ticket for replacing output file. */ enum any_compression compression; @@ -123,10 +123,10 @@ static void write_longvar_table (struct sfm_writer *w, const struct dictionary *dict); static void write_encoding_record (struct sfm_writer *w, - const struct dictionary *); + const struct dictionary *); static void write_vls_length_table (struct sfm_writer *w, - const struct dictionary *dict); + const struct dictionary *dict); static void write_long_string_value_labels (struct sfm_writer *, const struct dictionary *); @@ -936,7 +936,7 @@ write_mrsets (struct sfm_writer *w, const struct dictionary *dict, /* Write the alignment, width and scale values. */ static void write_variable_display_parameters (struct sfm_writer *w, - const struct dictionary *dict) + const struct dictionary *dict) { int i; @@ -972,7 +972,7 @@ write_variable_display_parameters (struct sfm_writer *w, /* Writes the table of lengths for very long string variables. */ static void write_vls_length_table (struct sfm_writer *w, - const struct dictionary *dict) + const struct dictionary *dict) { struct string map; int i; @@ -1130,7 +1130,7 @@ write_long_string_missing_values (struct sfm_writer *w, static void write_encoding_record (struct sfm_writer *w, - const struct dictionary *d) + const struct dictionary *d) { /* IANA says "...character set names may be up to 40 characters taken from the printable characters of US-ASCII," so character set names diff --git a/src/data/variable.c b/src/data/variable.c index b90b32a31c..86725c88fe 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -87,12 +87,12 @@ struct variable int ref_cnt; /* Dictionary information. */ char *name; /* Variable name. Mixed case. */ - int width; /* 0 for numeric, otherwise string width. */ + int width; /* 0 for numeric, otherwise string width. */ struct missing_values miss; /* Missing values. */ - struct fmt_spec print; /* Default format for PRINT. */ - struct fmt_spec write; /* Default format for WRITE. */ + struct fmt_spec print; /* Default format for PRINT. */ + struct fmt_spec write; /* Default format for WRITE. */ struct val_labs *val_labs; /* Value labels. */ - char *label; /* Variable label. */ + char *label; /* Variable label. */ struct string name_and_label; /* The name and label in the same string */ /* GUI information. */ @@ -300,7 +300,7 @@ var_get_width (const struct variable *v) void var_set_width_and_formats (struct variable *v, int new_width, - const struct fmt_spec *print, const struct fmt_spec *write) + const struct fmt_spec *print, const struct fmt_spec *write) { struct variable *ov; unsigned int traits = 0; @@ -566,7 +566,7 @@ var_lookup_value_label (const struct variable *v, const union value *value) */ static void append_value (const struct variable *v, const union value *value, - struct string *str) + struct string *str) { char *s = data_out (value, var_get_encoding (v), v->print, settings_get_fmt_settings ()); @@ -591,9 +591,9 @@ var_append_value_name__ (const struct variable *v, const union value *value, default: case SETTINGS_VALUE_SHOW_LABEL: if (label) - ds_put_cstr (str, label); + ds_put_cstr (str, label); else - append_value (v, value, str); + append_value (v, value, str); break; case SETTINGS_VALUE_SHOW_BOTH: @@ -611,7 +611,7 @@ var_append_value_name__ (const struct variable *v, const union value *value, */ void var_append_value_name (const struct variable *v, const union value *value, - struct string *str) + struct string *str) { var_append_value_name__ (v, value, settings_get_show_values (), str); } diff --git a/src/data/variable.h b/src/data/variable.h index 97079e667e..c1423c2438 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -74,7 +74,7 @@ enum val_type var_get_type (const struct variable *); int var_get_width (const struct variable *); void var_set_width (struct variable *, int width); void var_set_width_and_formats (struct variable *v, int new_width, - const struct fmt_spec *print, const struct fmt_spec *write); + const struct fmt_spec *print, const struct fmt_spec *write); bool var_is_numeric (const struct variable *); bool var_is_alpha (const struct variable *); @@ -94,7 +94,7 @@ const char *var_lookup_value_label (const struct variable *, const union value *); struct string; void var_append_value_name (const struct variable *, const union value *, - struct string *); + struct string *); void var_append_value_name__ (const struct variable *, const union value *, enum settings_value_show, struct string *); @@ -212,6 +212,6 @@ const char *var_get_encoding (const struct variable *); typedef bool var_predicate_func (const struct variable *); double var_force_valid_weight (const struct variable *wv, double w, - bool *warn_on_invalid); + bool *warn_on_invalid); #endif /* data/variable.h */ diff --git a/src/language/command.c b/src/language/command.c index ab5391dc2e..64b9dfd2c2 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -110,9 +110,9 @@ struct command { enum states states; /* States in which command is allowed. */ enum flags flags; /* Other command requirements. */ - const char *name; /* Command name. */ - const char *label; /* Translated command label. */ - int (*function) (struct lexer *, struct dataset *); /* Function to call. */ + const char *name; /* Command name. */ + const char *label; /* Translated command label. */ + int (*function) (struct lexer *, struct dataset *); /* Function to call. */ }; /* Define the command array. */ @@ -142,7 +142,7 @@ static enum cmd_result do_parse_command (struct lexer *, struct dataset *, enum Returns the command's success or failure result. */ enum cmd_result cmd_parse_in_state (struct lexer *lexer, struct dataset *ds, - enum cmd_state state) + enum cmd_state state) { struct session *session = dataset_session (ds); int result; @@ -163,9 +163,9 @@ cmd_parse (struct lexer *lexer, struct dataset *ds) { const struct dictionary *dict = dataset_dict (ds); return cmd_parse_in_state (lexer, ds, - dataset_has_source (ds) && - dict_get_n_vars (dict) > 0 ? - CMD_STATE_DATA : CMD_STATE_INITIAL); + dataset_has_source (ds) && + dict_get_n_vars (dict) > 0 ? + CMD_STATE_DATA : CMD_STATE_INITIAL); } @@ -173,7 +173,7 @@ cmd_parse (struct lexer *lexer, struct dataset *ds) dot. */ static enum cmd_result do_parse_command (struct lexer *lexer, - struct dataset *ds, enum cmd_state state) + struct dataset *ds, enum cmd_state state) { const struct command *command = NULL; size_t nesting_level = SIZE_MAX; diff --git a/src/language/command.h b/src/language/command.h index 71b6a38e3c..36d06c0516 100644 --- a/src/language/command.h +++ b/src/language/command.h @@ -53,7 +53,7 @@ struct dataset; struct lexer; enum cmd_result cmd_parse_in_state (struct lexer *lexer, struct dataset *ds, - enum cmd_state); + enum cmd_state); enum cmd_result cmd_parse (struct lexer *lexer, struct dataset *ds); diff --git a/src/language/commands/aggregate.c b/src/language/commands/aggregate.c index 8396f12c3b..b290df7e23 100644 --- a/src/language/commands/aggregate.c +++ b/src/language/commands/aggregate.c @@ -71,11 +71,11 @@ struct agr_argument struct agr_var { /* Collected during parsing. */ - const struct variable *src; /* Source variable. */ - struct variable *dest; /* Target variable. */ + const struct variable *src; /* Source variable. */ + struct variable *dest; /* Target variable. */ enum agr_function function; /* Function. */ enum mv_class exclude; /* Classes of missing values to exclude. */ - struct agr_argument arg[2]; /* Arguments. */ + struct agr_argument arg[2]; /* Arguments. */ /* Accumulated during AGGREGATE execution. */ double dbl; @@ -105,8 +105,8 @@ AGGREGATE_FUNCTIONS /* Missing value types. */ enum missing_treatment { - ITEMWISE, /* Missing values item by item. */ - COLUMNWISE /* Missing values column by column. */ + ITEMWISE, /* Missing values item by item. */ + COLUMNWISE /* Missing values column by column. */ }; /* An entire AGGREGATE procedure. */ @@ -125,7 +125,7 @@ struct agr_proc int n_cases; /* Counts aggregated cases. */ bool add_variables; /* True iff the aggregated variables should - be appended to the existing dictionary */ + be appended to the existing dictionary */ }; static void initialize_aggregate_info (struct agr_proc *); @@ -134,11 +134,11 @@ static void accumulate_aggregate_info (struct agr_proc *, const struct ccase *); /* Prototypes. */ static bool parse_aggregate_functions (struct lexer *, const struct dictionary *, - struct agr_proc *); + struct agr_proc *); static void agr_destroy (struct agr_proc *); static void dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, - const struct ccase *break_case); + const struct ccase *break_case); /* Parsing. */ @@ -316,27 +316,27 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) initialize_aggregate_info (&agr); if (agr.add_variables) - placeholder = casereader_clone (group); + placeholder = casereader_clone (group); { - struct ccase *cg; - for (; (cg = casereader_read (group)) != NULL; case_unref (cg)) - accumulate_aggregate_info (&agr, cg); + struct ccase *cg; + for (; (cg = casereader_read (group)) != NULL; case_unref (cg)) + accumulate_aggregate_info (&agr, cg); } if (agr.add_variables) - { - struct ccase *cg; - for (; (cg = casereader_read (placeholder)) != NULL; case_unref (cg)) - dump_aggregate_info (&agr, output, cg); + { + struct ccase *cg; + for (; (cg = casereader_read (placeholder)) != NULL; case_unref (cg)) + dump_aggregate_info (&agr, output, cg); - casereader_destroy (placeholder); - } + casereader_destroy (placeholder); + } else - { - dump_aggregate_info (&agr, output, c); - } + { + dump_aggregate_info (&agr, output, c); + } case_unref (c); } if (!casegrouper_destroy (grouper)) @@ -405,7 +405,7 @@ parse_agr_func_name (struct lexer *lexer, int *func_index, /* Parse all the aggregate functions. */ static bool parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, - struct agr_proc *agr) + struct agr_proc *agr) { if (!lex_force_match (lexer, T_SLASH)) return false; @@ -427,25 +427,25 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, /* Parse the list of target variables. */ int dst_start_ofs = lex_ofs (lexer); while (!lex_match (lexer, T_EQUALS)) - { - size_t n_vars_prev = n_vars; + { + size_t n_vars_prev = n_vars; - if (!parse_DATA_LIST_vars (lexer, dict, &dest, &n_vars, + if (!parse_DATA_LIST_vars (lexer, dict, &dest, &n_vars, (PV_APPEND | PV_SINGLE | PV_NO_SCRATCH | PV_NO_DUPLICATE))) - goto error; + goto error; - /* Assign empty labels. */ + /* Assign empty labels. */ dest_label = xnrealloc (dest_label, n_vars, sizeof *dest_label); for (size_t j = n_vars_prev; j < n_vars; j++) dest_label[j] = NULL; - if (lex_is_string (lexer)) - { - dest_label[n_vars - 1] = xstrdup (lex_tokcstr (lexer)); - lex_get (lexer); - } - } + if (lex_is_string (lexer)) + { + dest_label[n_vars - 1] = xstrdup (lex_tokcstr (lexer)); + lex_get (lexer); + } + } int dst_end_ofs = lex_ofs (lexer) - 2; /* Get the name of the aggregation function. */ @@ -457,16 +457,16 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, /* Check for leading lparen. */ if (!lex_match (lexer, T_LPAREN)) - { - if (function->src_vars == AGR_SV_YES) - { + { + if (function->src_vars == AGR_SV_YES) + { bool ok UNUSED = lex_force_match (lexer, T_LPAREN); - goto error; - } - } + goto error; + } + } else { - /* Parse list of source variables. */ + /* Parse list of source variables. */ int pv_opts = PV_NO_SCRATCH; if (func_index == AGRF_SUM || func_index == AGRF_MEAN || func_index == AGRF_MEDIAN || func_index == AGRF_SD) @@ -480,31 +480,31 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, goto error; int src_end_ofs = lex_ofs (lexer) - 1; - /* Parse function arguments, for those functions that - require arguments. */ + /* Parse function arguments, for those functions that + require arguments. */ int args_start_ofs = 0; - if (function->n_args != 0) - for (size_t i = 0; i < function->n_args; i++) - { - lex_match (lexer, T_COMMA); + if (function->n_args != 0) + for (size_t i = 0; i < function->n_args; i++) + { + lex_match (lexer, T_COMMA); - enum val_type type; - if (lex_is_string (lexer)) + enum val_type type; + if (lex_is_string (lexer)) type = VAL_STRING; else if (lex_is_number (lexer)) type = VAL_NUMERIC; else { - lex_error (lexer, _("Missing argument %zu to %s."), + lex_error (lexer, _("Missing argument %zu to %s."), i + 1, function->name); - goto error; - } - - if (type != var_get_type (src[0])) - { - msg (SE, _("Arguments to %s must be of same type as " - "source variables."), - function->name); + goto error; + } + + if (type != var_get_type (src[0])) + { + msg (SE, _("Arguments to %s must be of same type as " + "source variables."), + function->name); if (type == VAL_NUMERIC) { lex_next_msg (lexer, SN, 0, 0, @@ -519,42 +519,42 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, lex_ofs_msg (lexer, SN, src_start_ofs, src_end_ofs, _("The variables are numeric.")); } - goto error; - } + goto error; + } if (i == 0) args_start_ofs = lex_ofs (lexer); - if (type == VAL_NUMERIC) + if (type == VAL_NUMERIC) arg[i].f = lex_tokval (lexer); else arg[i].s = recode_substring_pool (dict_get_encoding (agr->dict), "UTF-8", lex_tokss (lexer), NULL); - lex_get (lexer); - } + lex_get (lexer); + } int args_end_ofs = lex_ofs (lexer) - 1; - /* Trailing rparen. */ - if (!lex_force_match (lexer, T_RPAREN)) + /* Trailing rparen. */ + if (!lex_force_match (lexer, T_RPAREN)) goto error; - /* Now check that the number of source variables match - the number of target variables. If we check earlier - than this, the user can get very misleading error - message, i.e. `AGGREGATE x=SUM(y t).' will get this - error message when a proper message would be more - like `unknown variable t'. */ - if (n_src != n_vars) - { - msg (SE, _("Number of source variables (%zu) does not match " - "number of target variables (%zu)."), + /* Now check that the number of source variables match + the number of target variables. If we check earlier + than this, the user can get very misleading error + message, i.e. `AGGREGATE x=SUM(y t).' will get this + error message when a proper message would be more + like `unknown variable t'. */ + if (n_src != n_vars) + { + msg (SE, _("Number of source variables (%zu) does not match " + "number of target variables (%zu)."), n_src, n_vars); lex_ofs_msg (lexer, SN, src_start_ofs, src_end_ofs, _("These are the source variables.")); lex_ofs_msg (lexer, SN, dst_start_ofs, dst_end_ofs, _("These are the target variables.")); - goto error; - } + goto error; + } if ((func_index == AGRF_PIN || func_index == AGRF_POUT || func_index == AGRF_FIN || func_index == AGRF_FOUT) @@ -573,32 +573,32 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, "they had been specified in the correct order."), function->name); } - } + } /* Finally add these to the aggregation variables. */ for (size_t i = 0; i < n_vars; i++) - { + { const struct variable *existing_var = dict_lookup_var (agr->dict, dest[i]); if (existing_var) { if (var_get_dict_index (existing_var) >= starting_n_vars) - lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, + lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, _("Duplicate target variable name %s."), dest[i]); else if (agr->add_variables) - lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, + lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, _("Variable name %s duplicates the name of a " "variable in the active file dictionary."), dest[i]); else - lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, + lex_ofs_error (lexer, dst_start_ofs, dst_end_ofs, _("Variable name %s duplicates the name of a " "break variable."), dest[i]); goto error; } - /* Add variable. */ + /* Add variable. */ if (agr->n_agr_vars >= allocated_agr_vars) agr->agr_vars = x2nrealloc (agr->agr_vars, &allocated_agr_vars, sizeof *agr->agr_vars); @@ -610,7 +610,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, .src = src ? src[i] : NULL, }; - /* Create the target variable in the aggregate dictionary. */ + /* Create the target variable in the aggregate dictionary. */ if (v->src && var_is_alpha (v->src)) v->string = xmalloc (var_get_width (v->src)); @@ -631,42 +631,42 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, if (dest_label[i]) var_set_label (v->dest, dest_label[i]); - if (v->src != NULL) + if (v->src != NULL) for (size_t j = 0; j < function->n_args; j++) v->arg[j] = (struct agr_argument) { .f = arg[j].f, .s = arg[j].s.string ? ss_clone (arg[j].s) : ss_empty (), }; - } + } ss_dealloc (&arg[0].s); ss_dealloc (&arg[1].s); free (src); for (size_t i = 0; i < n_vars; i++) - { - free (dest[i]); - free (dest_label[i]); - } + { + free (dest[i]); + free (dest_label[i]); + } free (dest); free (dest_label); if (!lex_match (lexer, T_SLASH)) - { - if (lex_token (lexer) == T_ENDCMD) - return true; + { + if (lex_token (lexer) == T_ENDCMD) + return true; - lex_error (lexer, "Syntax error expecting end of command."); - return false; - } + lex_error (lexer, "Syntax error expecting end of command."); + return false; + } continue; error: for (size_t i = 0; i < n_vars; i++) - { - free (dest[i]); - free (dest_label[i]); - } + { + free (dest[i]); + free (dest_label[i]); + } free (dest); free (dest_label); ss_dealloc (&arg[0].s); @@ -931,13 +931,13 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons int value_idx = 0; for (size_t i = 0; i < agr->break_n_vars; i++) - { - const struct variable *v = agr->break_vars[i]; - value_copy (case_data_rw_idx (c, value_idx), - case_data (break_case, v), - var_get_width (v)); - value_idx++; - } + { + const struct variable *v = agr->break_vars[i]; + value_copy (case_data_rw_idx (c, value_idx), + case_data (break_case, v), + var_get_width (v)); + value_idx++; + } } for (size_t i = 0; i < agr->n_agr_vars; i++) @@ -1065,41 +1065,41 @@ initialize_aggregate_info (struct agr_proc *agr) int width = av->src ? var_get_width (av->src) : 0; switch (av->function) - { - case AGRF_MIN: + { + case AGRF_MIN: if (!width) av->dbl = DBL_MAX; else memset (av->string, 255, width); - break; + break; - case AGRF_MAX: + case AGRF_MAX: if (!width) av->dbl = -DBL_MAX; - else + else memset (av->string, 0, width); - break; + break; - case AGRF_MEDIAN: - { + case AGRF_MEDIAN: + { struct caseproto *proto = caseproto_create (); proto = caseproto_add_width (proto, 0); proto = caseproto_add_width (proto, 0); if (!av->dict) av->dict = dict_create ("UTF-8"); - if (! av->subject) - av->subject = dict_create_var (av->dict, "subject", 0); - if (! av->weight) - av->weight = dict_create_var (av->dict, "weight", 0); + if (! av->subject) + av->subject = dict_create_var (av->dict, "subject", 0); + if (! av->weight) + av->weight = dict_create_var (av->dict, "weight", 0); struct subcase ordering; subcase_init_var (&ordering, av->subject, SC_ASCEND); - av->writer = sort_create_writer (&ordering, proto); + av->writer = sort_create_writer (&ordering, proto); subcase_uninit (&ordering); caseproto_unref (proto); - } - break; + } + break; case AGRF_SD: if (av->moments == NULL) @@ -1129,6 +1129,6 @@ initialize_aggregate_info (struct agr_proc *agr) case AGRF_FIRST: case AGRF_LAST: break; - } + } } } diff --git a/src/language/commands/apply-dictionary.c b/src/language/commands/apply-dictionary.c index fb75b3821f..94ae0a7766 100644 --- a/src/language/commands/apply-dictionary.c +++ b/src/language/commands/apply-dictionary.c @@ -63,18 +63,18 @@ cmd_apply_dictionary (struct lexer *lexer, struct dataset *ds) struct variable *t = dict_lookup_var (dataset_dict (ds), var_get_name (s)); if (t == NULL) - continue; + continue; n_matched++; if (var_get_type (s) != var_get_type (t)) - { - msg (SW, _("Variable %s is %s in target file, but %s in " - "source file."), - var_get_name (s), - var_is_alpha (t) ? _("string") : _("numeric"), - var_is_alpha (s) ? _("string") : _("numeric")); - continue; - } + { + msg (SW, _("Variable %s is %s in target file, but %s in " + "source file."), + var_get_name (s), + var_is_alpha (t) ? _("string") : _("numeric"), + var_is_alpha (s) ? _("string") : _("numeric")); + continue; + } if (var_has_label (s)) var_set_label (t, var_get_label (s)); @@ -94,10 +94,10 @@ cmd_apply_dictionary (struct lexer *lexer, struct dataset *ds) } if (var_is_numeric (s)) - { + { var_set_print_format (t, var_get_print_format (s)); var_set_write_format (t, var_get_write_format (s)); - } + } if (var_has_attributes (s)) var_set_attributes (t, var_get_attributes (s)); @@ -105,7 +105,7 @@ cmd_apply_dictionary (struct lexer *lexer, struct dataset *ds) if (!n_matched) msg (SW, _("No matching variables found between the source " - "and target files.")); + "and target files.")); /* Data file attributes. */ if (dict_has_attributes (dict)) diff --git a/src/language/commands/binomial.c b/src/language/commands/binomial.c index df443d8489..0a6048ceb7 100644 --- a/src/language/commands/binomial.c +++ b/src/language/commands/binomial.c @@ -45,7 +45,7 @@ #define _(msgid) gettext (msgid) static double calculate_binomial_internal (double n1, double n2, - double p); + double p); static void @@ -86,12 +86,12 @@ calculate_binomial_internal (double n1, double n2, double p) static bool do_binomial (const struct dictionary *dict, - struct casereader *input, - const struct one_sample_test *ost, - struct freq *cat1, - struct freq *cat2, + struct casereader *input, + const struct one_sample_test *ost, + struct freq *cat1, + struct freq *cat2, enum mv_class exclude - ) + ) { const struct binomial_test *bst = UP_CAST (ost, const struct binomial_test, parent); bool warn = true; @@ -104,40 +104,40 @@ do_binomial (const struct dictionary *dict, double w = dict_get_case_weight (dict, c, &warn); for (v = 0 ; v < ost->n_vars ; ++v) - { - const struct variable *var = ost->vars[v]; - double value = case_num (c, var); - - if (var_is_num_missing (var, value) & exclude) - continue; - - if (bst->cutpoint != SYSMIS) - { - if (cat1[v].values[0].f >= value) - cat1[v].count += w; - else - cat2[v].count += w; - } - else - { - if (SYSMIS == cat1[v].values[0].f) - { - cat1[v].values[0].f = value; - cat1[v].count = w; - } - else if (cat1[v].values[0].f == value) - cat1[v].count += w; - else if (SYSMIS == cat2[v].values[0].f) - { - cat2[v].values[0].f = value; - cat2[v].count = w; - } - else if (cat2[v].values[0].f == value) - cat2[v].count += w; - else if (bst->category1 == SYSMIS) - msg (ME, _("Variable %s is not dichotomous"), var_get_name (var)); - } - } + { + const struct variable *var = ost->vars[v]; + double value = case_num (c, var); + + if (var_is_num_missing (var, value) & exclude) + continue; + + if (bst->cutpoint != SYSMIS) + { + if (cat1[v].values[0].f >= value) + cat1[v].count += w; + else + cat2[v].count += w; + } + else + { + if (SYSMIS == cat1[v].values[0].f) + { + cat1[v].values[0].f = value; + cat1[v].count = w; + } + else if (cat1[v].values[0].f == value) + cat1[v].count += w; + else if (SYSMIS == cat2[v].values[0].f) + { + cat2[v].values[0].f = value; + cat2[v].count = w; + } + else if (cat2[v].values[0].f == value) + cat2[v].count += w; + else if (bst->category1 == SYSMIS) + msg (ME, _("Variable %s is not dichotomous"), var_get_name (var)); + } + } } return casereader_destroy (input); } @@ -146,11 +146,11 @@ do_binomial (const struct dictionary *dict, void binomial_execute (const struct dataset *ds, - struct casereader *input, + struct casereader *input, enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { const struct dictionary *dict = dataset_dict (ds); const struct one_sample_test *ost = UP_CAST (test, const struct one_sample_test, parent); diff --git a/src/language/commands/binomial.h b/src/language/commands/binomial.h index df01a13bc5..5cae8030e2 100644 --- a/src/language/commands/binomial.h +++ b/src/language/commands/binomial.h @@ -38,9 +38,9 @@ struct dataset; void binomial_execute (const struct dataset *, - struct casereader *, + struct casereader *, enum mv_class, - const struct npar_test *, - bool, double); + const struct npar_test *, + bool, double); #endif diff --git a/src/language/commands/chisquare.c b/src/language/commands/chisquare.c index 0a5e27049f..0a96d60fc8 100644 --- a/src/language/commands/chisquare.c +++ b/src/language/commands/chisquare.c @@ -53,9 +53,9 @@ required, even on failure. */ static bool create_freq_hash_with_range (const struct dictionary *dict, - struct casereader *input, - const struct variable *var, - double lo_, double hi_, + struct casereader *input, + const struct variable *var, + double lo_, double hi_, struct hmap *freq_hash) { struct freq **entries; @@ -101,8 +101,8 @@ create_freq_hash_with_range (const struct dictionary *dict, failure. */ static bool create_freq_hash (const struct dictionary *dict, - struct casereader *input, - const struct variable *var, + struct casereader *input, + const struct variable *var, struct hmap *freq_hash) { int width = var_get_width (var); @@ -128,11 +128,11 @@ create_freq_hash (const struct dictionary *dict, void chisquare_execute (const struct dataset *ds, - struct casereader *input, + struct casereader *input, enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { const struct dictionary *dict = dataset_dict (ds); int v, i; @@ -151,21 +151,21 @@ chisquare_execute (const struct dataset *ds, if (cst->ranged == false) { for (v = 0 ; v < ost->n_vars ; ++v) - { + { const struct variable *var = ost->vars[v]; - struct hmap freq_hash = HMAP_INITIALIZER (freq_hash); + struct hmap freq_hash = HMAP_INITIALIZER (freq_hash); struct casereader *reader = casereader_create_filter_missing (casereader_clone (input), &var, 1, exclude, - NULL, NULL); + NULL, NULL); if (!create_freq_hash (dict, reader, var, &freq_hash)) { freq_hmap_destroy (&freq_hash, var_get_width (var)); return; } - size_t n_cells = hmap_count (&freq_hash); + size_t n_cells = hmap_count (&freq_hash); if (cst->n_expected > 0 && n_cells != cst->n_expected) { msg (ME, _("CHISQUARE test specified %d expected values, but " @@ -187,17 +187,17 @@ chisquare_execute (const struct dataset *ds, struct freq **ff = freq_hmap_sort (&freq_hash, var_get_width (var)); - double total_obs = 0.0; - for (size_t i = 0; i < n_cells; i++) - total_obs += ff[i]->count; + double total_obs = 0.0; + for (size_t i = 0; i < n_cells; i++) + total_obs += ff[i]->count; struct pivot_dimension *values = pivot_dimension_create ( table, PIVOT_AXIS_ROW, N_("Value")); values->root->show_label = true; - xsq[v] = 0.0; - for (size_t i = 0; i < n_cells; i++) - { + xsq[v] = 0.0; + for (size_t i = 0; i < n_cells; i++) + { int row = pivot_category_create_leaf ( values->root, pivot_value_new_var_value ( var, &ff[i]->values[0])); @@ -214,10 +214,10 @@ chisquare_execute (const struct dataset *ds, pivot_table_put2 ( table, j, row, pivot_value_new_number (entries[j])); - xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; - } + xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; + } - df[v] = n_cells - 1.0; + df[v] = n_cells - 1.0; int row = pivot_category_create_leaf ( values->root, pivot_value_new_text (N_("Total"))); @@ -228,7 +228,7 @@ chisquare_execute (const struct dataset *ds, freq_hmap_destroy (&freq_hash, var_get_width (var)); free (ff); - } + } } else /* ranged == true */ { @@ -257,13 +257,13 @@ chisquare_execute (const struct dataset *ds, pivot_category_create_leaves (category_dim->root, N_("Total")); for (size_t v = 0 ; v < ost->n_vars ; ++v) - { + { const struct variable *var = ost->vars[v]; struct casereader *reader = casereader_create_filter_missing (casereader_clone (input), &var, 1, exclude, - NULL, NULL); - struct hmap freq_hash = HMAP_INITIALIZER (freq_hash); + NULL, NULL); + struct hmap freq_hash = HMAP_INITIALIZER (freq_hash); if (!create_freq_hash_with_range (dict, reader, var, cst->lo, cst->hi, &freq_hash)) { @@ -271,15 +271,15 @@ chisquare_execute (const struct dataset *ds, continue; } - struct freq **ff = freq_hmap_sort (&freq_hash, var_get_width (var)); + struct freq **ff = freq_hmap_sort (&freq_hash, var_get_width (var)); double total_obs = 0.0; - for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) - total_obs += ff[i]->count; + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) + total_obs += ff[i]->count; - xsq[v] = 0.0; - for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) - { + xsq[v] = 0.0; + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) + { /* Category. */ pivot_table_put3 (table, 0, v, i, pivot_value_new_var_value ( @@ -298,17 +298,17 @@ chisquare_execute (const struct dataset *ds, pivot_value_new_number (entries[j])); - xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; - } + xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; + } - df[v] = n_cells - 1.0; + df[v] = n_cells - 1.0; - freq_hmap_destroy (&freq_hash, var_get_width (var)); + freq_hmap_destroy (&freq_hash, var_get_width (var)); free (ff); pivot_table_put3 (table, 1, v, n_cells, pivot_value_new_number (total_obs)); - } + } pivot_table_submit (table); } diff --git a/src/language/commands/chisquare.h b/src/language/commands/chisquare.h index a12a7608a8..17b351c6c3 100644 --- a/src/language/commands/chisquare.h +++ b/src/language/commands/chisquare.h @@ -39,11 +39,11 @@ struct dataset; void chisquare_execute (const struct dataset *ds, - struct casereader *input, + struct casereader *input, enum mv_class exclude, - const struct npar_test *test, - bool, - double); + const struct npar_test *test, + bool, + double); diff --git a/src/language/commands/cochran.c b/src/language/commands/cochran.c index 2993ea30dd..ac01e81db6 100644 --- a/src/language/commands/cochran.c +++ b/src/language/commands/cochran.c @@ -57,10 +57,10 @@ static void show_sig_box (const struct cochran *ch); void cochran_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, double timer UNUSED) { struct one_sample_test *ct = UP_CAST (test, struct one_sample_test, parent); int v; @@ -82,36 +82,36 @@ cochran_execute (const struct dataset *ds, double case_hits = 0.0; const double w = weight ? case_num (c, weight) : 1.0; for (v = 0; v < ct->n_vars; ++v) - { - const struct variable *var = ct->vars[v]; - const union value *val = case_data (c, var); - - if (var_is_value_missing (var, val) & exclude) - continue; - - if (ch.success == SYSMIS) - { - ch.success = val->f; - } - else if (ch.failure == SYSMIS && val->f != ch.success) - { - ch.failure = val->f; - } - if (ch.success == val->f) - { - ch.hits[v] += w; - case_hits += w; - } - else if (ch.failure == val->f) - { - ch.misses[v] += w; - } - else - { - msg (MW, _("More than two values encountered. Cochran Q test will not be run.")); - goto finish; - } - } + { + const struct variable *var = ct->vars[v]; + const union value *val = case_data (c, var); + + if (var_is_value_missing (var, val) & exclude) + continue; + + if (ch.success == SYSMIS) + { + ch.success = val->f; + } + else if (ch.failure == SYSMIS && val->f != ch.success) + { + ch.failure = val->f; + } + if (ch.success == val->f) + { + ch.hits[v] += w; + case_hits += w; + } + else if (ch.failure == val->f) + { + ch.misses[v] += w; + } + else + { + msg (MW, _("More than two values encountered. Cochran Q test will not be run.")); + goto finish; + } + } ch.cc += w; rowsq += pow2 (case_hits); } @@ -122,8 +122,8 @@ cochran_execute (const struct dataset *ds, double c_l2 = 0; for (v = 0; v < ct->n_vars; ++v) { - c_l += ch.hits[v]; - c_l2 += pow2 (ch.hits[v]); + c_l += ch.hits[v]; + c_l2 += pow2 (ch.hits[v]); } ch.q = ct->n_vars * c_l2; diff --git a/src/language/commands/cochran.h b/src/language/commands/cochran.h index 645813c0d8..ba2573bcde 100644 --- a/src/language/commands/cochran.h +++ b/src/language/commands/cochran.h @@ -24,11 +24,11 @@ void cochran_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool, - double); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool, + double); #endif diff --git a/src/language/commands/combine-files.c b/src/language/commands/combine-files.c index 5641328101..a6441de97e 100644 --- a/src/language/commands/combine-files.c +++ b/src/language/commands/combine-files.c @@ -58,8 +58,8 @@ enum comb_command_type /* File types. */ enum comb_file_type { - COMB_FILE, /* Specified on FILE= subcommand. */ - COMB_TABLE /* Specified on TABLE= subcommand. */ + COMB_FILE, /* Specified on FILE= subcommand. */ + COMB_TABLE /* Specified on TABLE= subcommand. */ }; /* These commands combine multiple input files into a single master file. The @@ -91,7 +91,7 @@ struct comb_file /* Input files. */ struct file_handle *handle; /* Input file handle. */ - struct dictionary *dict; /* Input file dictionary. */ + struct dictionary *dict; /* Input file dictionary. */ struct casereader *reader; /* Input data source. */ struct ccase *data; /* The current input case. */ bool is_minimal; /* Does 'data' have minimum BY values across @@ -331,20 +331,20 @@ combine_files (enum comb_command_type command, while (lex_token (lexer) != T_ENDCMD) { if (lex_match (lexer, T_BY)) - { + { if (saw_by) - { + { lex_sbc_only_once (lexer, "BY"); - goto error; - } + goto error; + } saw_by = true; - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); const struct variable **by_vars; if (!parse_sort_criteria (lexer, proc.dict, &proc.by_vars, &by_vars, NULL)) - goto error; + goto error; size_t n_by_vars = subcase_get_n_fields (&proc.by_vars); for (size_t i = 0; i < n_by_vars; i++) @@ -387,7 +387,7 @@ combine_files (enum comb_command_type command, if (!ok) goto error; - } + } else if (command != COMB_UPDATE && lex_match_id (lexer, "FIRST")) { if (first_name != NULL) @@ -396,7 +396,7 @@ combine_files (enum comb_command_type command, goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (!lex_force_id (lexer)) goto error; first_name = xstrdup (lex_tokcstr (lexer)); @@ -411,7 +411,7 @@ combine_files (enum comb_command_type command, goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (!lex_force_id (lexer)) goto error; last_name = xstrdup (lex_tokcstr (lexer)); @@ -419,9 +419,9 @@ combine_files (enum comb_command_type command, lex_get (lexer); } else if (lex_match_id (lexer, "MAP")) - { - /* FIXME. */ - } + { + /* FIXME. */ + } else if (lex_match_id (lexer, "DROP")) { if (!parse_dict_drop (lexer, proc.dict)) @@ -433,14 +433,14 @@ combine_files (enum comb_command_type command, goto error; } else - { + { if (command == COMB_UPDATE) lex_error_expecting (lexer, "BY", "MAP", "DROP", "KEEP"); else lex_error_expecting (lexer, "BY", "FIRST", "LAST", "MAP", "DROP", "KEEP"); - goto error; - } + goto error; + } if (!lex_match (lexer, T_SLASH) && lex_token (lexer) != T_ENDCMD) { diff --git a/src/language/commands/compute.c b/src/language/commands/compute.c index a1ea72506a..bac9c14b16 100644 --- a/src/language/commands/compute.c +++ b/src/language/commands/compute.c @@ -68,11 +68,11 @@ static void lvalue_destroy (struct lvalue *, struct dictionary *); struct compute_trns { /* Test expression (IF only). */ - struct expression *test; /* Test expression. */ + struct expression *test; /* Test expression. */ /* Variable lvalue, if variable != NULL. */ struct variable *variable; /* Destination variable, if any. */ - int width; /* Lvalue string width; 0=numeric. */ + int width; /* Lvalue string width; 0=numeric. */ /* Vector lvalue, if vector != NULL. */ const struct vector *vector; /* Destination vector, if any. */ @@ -81,12 +81,12 @@ struct compute_trns struct msg_location *lvalue_location; /* Rvalue. */ - struct expression *rvalue; /* Rvalue expression. */ + struct expression *rvalue; /* Rvalue expression. */ }; static struct expression *parse_rvalue (struct lexer *lexer, - const struct lvalue *, - struct dataset *); + const struct lvalue *, + struct dataset *); static struct compute_trns *compute_trns_create (void); static bool compute_trns_free (void *compute_); @@ -322,7 +322,7 @@ get_trns_class (const struct lvalue *lvalue) LVALUE, or a null pointer on failure. */ static struct expression * parse_rvalue (struct lexer *lexer, - const struct lvalue *lvalue, struct dataset *ds) + const struct lvalue *lvalue, struct dataset *ds) { if (lvalue->is_new_variable) return expr_parse_new_variable (lexer, ds, var_get_name (lvalue->variable), @@ -376,16 +376,16 @@ lvalue_parse (struct lexer *lexer, struct dataset *ds) /* Vector. */ lvalue->vector = dict_lookup_vector (dict, lex_tokcstr (lexer)); if (lvalue->vector == NULL) - { - lex_error (lexer, _("There is no vector named %s."), + { + lex_error (lexer, _("There is no vector named %s."), lex_tokcstr (lexer)); goto lossage; - } + } /* Vector element. */ lex_get (lexer); if (!lex_force_match (lexer, T_LPAREN)) - goto lossage; + goto lossage; lvalue->element = expr_parse (lexer, ds, VAL_NUMERIC); if (lvalue->element == NULL) goto lossage; @@ -399,7 +399,7 @@ lvalue_parse (struct lexer *lexer, struct dataset *ds) lvalue->variable = dict_lookup_var (dict, var_name); if (lvalue->variable == NULL) { - lvalue->variable = dict_create_var_assert (dict, var_name, 0); + lvalue->variable = dict_create_var_assert (dict, var_name, 0); lvalue->is_new_variable = true; } lex_get (lexer); @@ -434,8 +434,8 @@ lvalue_is_vector (const struct lvalue *lvalue) target variable if necessary and setting fields in COMPUTE. */ static void lvalue_finalize (struct lvalue *lvalue, - struct compute_trns *compute, - struct dictionary *dict) + struct compute_trns *compute, + struct dictionary *dict) { compute->lvalue_location = lvalue->location; lvalue->location = NULL; diff --git a/src/language/commands/correlations.c b/src/language/commands/correlations.c index e54127e1fe..c44f0c15e3 100644 --- a/src/language/commands/correlations.c +++ b/src/language/commands/correlations.c @@ -79,7 +79,7 @@ struct corr_opts static void output_descriptives (const struct corr *corr, const struct corr_opts *opts, const gsl_matrix *means, - const gsl_matrix *vars, const gsl_matrix *ns) + const gsl_matrix *vars, const gsl_matrix *ns) { struct pivot_table *table = pivot_table_create ( N_("Descriptive Statistics")); @@ -114,8 +114,8 @@ output_descriptives (const struct corr *corr, const struct corr_opts *opts, static void output_correlation (const struct corr *corr, const struct corr_opts *opts, - const gsl_matrix *cm, const gsl_matrix *samples, - const gsl_matrix *cv) + const gsl_matrix *cm, const gsl_matrix *samples, + const gsl_matrix *cv) { struct pivot_table *table = pivot_table_create (N_("Correlations")); pivot_table_set_weight_var (table, opts->wv); @@ -130,7 +130,7 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, for (size_t c = 0; c < matrix_cols; c++) { const struct variable *v = corr->n_vars_total > corr->n_vars1 ? - corr->vars[corr->n_vars1 + c] : corr->vars[c]; + corr->vars[corr->n_vars1 + c] : corr->vars[c]; pivot_category_create_leaf (columns->root, pivot_value_new_variable (v)); } @@ -269,7 +269,7 @@ cmd_correlations (struct lexer *lexer, struct dataset *ds) else if (lex_match_id (lexer, "INCLUDE")) opts.exclude = MV_SYSTEM; else if (lex_match_id (lexer, "EXCLUDE")) - opts.exclude = MV_ANY; + opts.exclude = MV_ANY; else { lex_error_expecting (lexer, "PAIRWISE", "LISTWISE", @@ -280,63 +280,63 @@ cmd_correlations (struct lexer *lexer, struct dataset *ds) } } else if (lex_match_id (lexer, "PRINT")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "TWOTAIL")) - opts.tails = 2; - else if (lex_match_id (lexer, "ONETAIL")) - opts.tails = 1; - else if (lex_match_id (lexer, "SIG")) - opts.sig = false; - else if (lex_match_id (lexer, "NOSIG")) - opts.sig = true; - else - { - lex_error_expecting (lexer, "TWOTAIL", "ONETAIL", + { + if (lex_match_id (lexer, "TWOTAIL")) + opts.tails = 2; + else if (lex_match_id (lexer, "ONETAIL")) + opts.tails = 1; + else if (lex_match_id (lexer, "SIG")) + opts.sig = false; + else if (lex_match_id (lexer, "NOSIG")) + opts.sig = true; + else + { + lex_error_expecting (lexer, "TWOTAIL", "ONETAIL", "SIG", "NOSIG"); - goto error; - } + goto error; + } lex_match (lexer, T_COMMA); - } - } + } + } else if (lex_match_id (lexer, "STATISTICS")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "DESCRIPTIVES")) - opts.descriptive_stats = true; - else if (lex_match_id (lexer, "XPROD")) - opts.xprod_stats = true; - else if (lex_token (lexer) == T_ALL) - { - opts.descriptive_stats = opts.xprod_stats = true; - lex_get (lexer); - } - else - { - lex_error_expecting (lexer, "DESCRIPTIVES", "XPROD", "ALL"); - goto error; - } + { + if (lex_match_id (lexer, "DESCRIPTIVES")) + opts.descriptive_stats = true; + else if (lex_match_id (lexer, "XPROD")) + opts.xprod_stats = true; + else if (lex_token (lexer) == T_ALL) + { + opts.descriptive_stats = opts.xprod_stats = true; + lex_get (lexer); + } + else + { + lex_error_expecting (lexer, "DESCRIPTIVES", "XPROD", "ALL"); + goto error; + } lex_match (lexer, T_COMMA); - } - } + } + } else - { - if (lex_match_id (lexer, "VARIABLES")) + { + if (lex_match_id (lexer, "VARIABLES")) lex_match (lexer, T_EQUALS); const struct variable **vars; size_t n_vars1; - if (!parse_variables_const (lexer, dict, &vars, &n_vars1, PV_NUMERIC)) + if (!parse_variables_const (lexer, dict, &vars, &n_vars1, PV_NUMERIC)) goto error; size_t n_vars_total = n_vars1; - if (lex_match (lexer, T_WITH) + if (lex_match (lexer, T_WITH) && !parse_variables_const (lexer, dict, &vars, &n_vars_total, PV_NUMERIC | PV_APPEND)) goto error; @@ -349,8 +349,8 @@ cmd_correlations (struct lexer *lexer, struct dataset *ds) .vars = vars, }; - n_all_vars += n_vars_total; - } + n_all_vars += n_vars_total; + } } if (n_corrs == 0) { @@ -373,18 +373,18 @@ cmd_correlations (struct lexer *lexer, struct dataset *ds) while (casegrouper_get_next_group (grouper, &group)) { for (size_t i = 0; i < n_corrs; ++i) - { - /* FIXME: No need to iterate the data multiple times */ - struct casereader *r = casereader_clone (group); + { + /* FIXME: No need to iterate the data multiple times */ + struct casereader *r = casereader_clone (group); - if (opts.missing_type == CORR_LISTWISE) - r = casereader_create_filter_missing (r, all_vars, n_all_vars, - opts.exclude, NULL, NULL); + if (opts.missing_type == CORR_LISTWISE) + r = casereader_create_filter_missing (r, all_vars, n_all_vars, + opts.exclude, NULL, NULL); - run_corr (r, &opts, &corrs[i]); - casereader_destroy (r); - } + run_corr (r, &opts, &corrs[i]); + casereader_destroy (r); + } casereader_destroy (group); } bool ok = casegrouper_destroy (grouper); diff --git a/src/language/commands/count.c b/src/language/commands/count.c index a4e1431661..865ba7f232 100644 --- a/src/language/commands/count.c +++ b/src/language/commands/count.c @@ -41,8 +41,8 @@ /* Value or range? */ enum value_type { - CNT_SINGLE, /* Single value. */ - CNT_RANGE /* a <= x <= b. */ + CNT_SINGLE, /* Single value. */ + CNT_RANGE /* a <= x <= b. */ }; /* Numeric count criteria. */ @@ -68,8 +68,8 @@ struct criteria size_t n_values; union { - struct num_value *num; - char **str; + struct num_value *num; + char **str; } values; }; @@ -116,7 +116,7 @@ cmd_count (struct lexer *lexer, struct dataset *ds) /* Get destination variable, or at least its name. */ if (!lex_force_id (lexer)) - goto fail; + goto fail; dv->var = dict_lookup_var (dataset_dict (ds), lex_tokcstr (lexer)); if (dv->var != NULL) { @@ -131,24 +131,24 @@ cmd_count (struct lexer *lexer, struct dataset *ds) lex_get (lexer); if (!lex_force_match (lexer, T_EQUALS)) - goto fail; + goto fail; crit = dv->crit = pool_alloc (trns->pool, sizeof *crit); for (;;) - { + { struct dictionary *dict = dataset_dict (ds); bool ok; - crit->next = NULL; - crit->vars = NULL; - if (!parse_variables_const (lexer, dict, &crit->vars, - &crit->n_vars, + crit->next = NULL; + crit->vars = NULL; + if (!parse_variables_const (lexer, dict, &crit->vars, + &crit->n_vars, PV_DUPLICATE | PV_SAME_TYPE)) - goto fail; + goto fail; pool_register (trns->pool, free, crit->vars); - if (!lex_force_match (lexer, T_LPAREN)) - goto fail; + if (!lex_force_match (lexer, T_LPAREN)) + goto fail; crit->n_values = 0; if (var_is_numeric (crit->vars[0])) @@ -156,20 +156,20 @@ cmd_count (struct lexer *lexer, struct dataset *ds) else ok = parse_string_criteria (lexer, trns->pool, crit, dict_get_encoding (dict)); - if (!ok) - goto fail; + if (!ok) + goto fail; - if (lex_token (lexer) == T_SLASH || lex_token (lexer) == T_ENDCMD) - break; + if (lex_token (lexer) == T_SLASH || lex_token (lexer) == T_ENDCMD) + break; - crit = crit->next = pool_alloc (trns->pool, sizeof *crit); - } + crit = crit->next = pool_alloc (trns->pool, sizeof *crit); + } if (lex_token (lexer) == T_ENDCMD) - break; + break; if (!lex_force_match (lexer, T_SLASH)) - goto fail; + goto fail; dv = dv->next = pool_alloc (trns->pool, sizeof *dv); } @@ -177,11 +177,11 @@ cmd_count (struct lexer *lexer, struct dataset *ds) for (dv = trns->dst_vars; dv; dv = dv->next) if (dv->var == NULL) { - /* It's valid, though motivationally questionable, to count to - the same dest var more than once. */ - dv->var = dict_lookup_var (dataset_dict (ds), dv->name); + /* It's valid, though motivationally questionable, to count to + the same dest var more than once. */ + dv->var = dict_lookup_var (dataset_dict (ds), dv->name); - if (dv->var == NULL) + if (dv->var == NULL) dv->var = dict_create_var_assert (dataset_dict (ds), dv->name, 0); } @@ -209,7 +209,7 @@ parse_numeric_criteria (struct lexer *lexer, struct pool *pool, struct criteria if (lex_match_id (lexer, "SYSMIS")) crit->count_system_missing = true; else if (lex_match_id (lexer, "MISSING")) - crit->count_system_missing = crit->count_user_missing = true; + crit->count_system_missing = crit->count_user_missing = true; else if (parse_num_range (lexer, &low, &high, NULL)) { struct num_value *cur; @@ -228,7 +228,7 @@ parse_numeric_criteria (struct lexer *lexer, struct pool *pool, struct criteria lex_match (lexer, T_COMMA); if (lex_match (lexer, T_RPAREN)) - break; + break; } return true; } @@ -258,7 +258,7 @@ parse_string_criteria (struct lexer *lexer, struct pool *pool, sizeof *crit->values.str); if (!lex_force_string (lexer)) - return false; + return false; s = recode_string (dict_encoding, "UTF-8", lex_tokcstr (lexer), ss_length (lex_tokss (lexer))); @@ -272,7 +272,7 @@ parse_string_criteria (struct lexer *lexer, struct pool *pool, lex_match (lexer, T_COMMA); if (lex_match (lexer, T_RPAREN)) - break; + break; } return true; @@ -328,7 +328,7 @@ count_string (struct criteria *crit, const struct ccase *c) if (!memcmp (case_str (c, crit->vars[i]), *v, var_get_width (crit->vars[i]))) { - counter++; + counter++; break; } } @@ -352,10 +352,10 @@ count_trns_proc (void *trns_, struct ccase **c, counter = 0; for (crit = dv->crit; crit; crit = crit->next) - if (var_is_numeric (crit->vars[0])) - counter += count_numeric (crit, *c); - else - counter += count_string (crit, *c); + if (var_is_numeric (crit->vars[0])) + counter += count_numeric (crit, *c); + else + counter += count_string (crit, *c); *case_num_rw (*c, dv->var) = counter; } return TRNS_CONTINUE; diff --git a/src/language/commands/crosstabs.c b/src/language/commands/crosstabs.c index 9839de2698..f662de2b49 100644 --- a/src/language/commands/crosstabs.c +++ b/src/language/commands/crosstabs.c @@ -174,10 +174,10 @@ struct crosstabulation size_t ns_cols, ns_rows; /* Matrix contents. */ - double *mat; /* Matrix proper. */ - double *row_tot; /* Row totals. */ - double *col_tot; /* Column totals. */ - double total; /* Grand total. */ + double *mat; /* Matrix proper. */ + double *row_tot; /* Row totals. */ + double *col_tot; /* Column totals. */ + double total; /* Grand total. */ /* Syntax. */ int start_ofs; @@ -189,9 +189,9 @@ struct var_range { struct hmap_node hmap_node; /* In struct crosstabs_proc var_ranges map. */ const struct variable *var; /* The variable. */ - int min; /* Minimum value. */ - int max; /* Maximum value + 1. */ - int count; /* max - min. */ + int min; /* Minimum value. */ + int max; /* Maximum value + 1. */ + int count; /* max - min. */ }; struct crosstabs_proc @@ -213,7 +213,7 @@ struct crosstabs_proc size_t n_pivots; /* CELLS. */ - size_t n_cells; /* Number of cells requested. */ + size_t n_cells; /* Number of cells requested. */ unsigned int cells; /* Bit k is 1 if cell k is requested. */ int a_cells[CRS_N_CELLS]; /* 0...n_cells-1 are the requested cells. */ @@ -584,7 +584,7 @@ parse_crosstabs_tables (struct lexer *lexer, struct dataset *ds, /* Ensure that this is a TABLES subcommand. */ if (!lex_match_id (lexer, "TABLES") && (lex_token (lexer) != T_ID || - dict_lookup_var (dataset_dict (ds), lex_tokcstr (lexer)) == NULL) + dict_lookup_var (dataset_dict (ds), lex_tokcstr (lexer)) == NULL) && lex_token (lexer) != T_ALL) { lex_error (lexer, _("Syntax error expecting subcommand name or " @@ -609,7 +609,7 @@ parse_crosstabs_tables (struct lexer *lexer, struct dataset *ds, by_nvar = xnrealloc (by_nvar, n_by + 1, sizeof *by_nvar); if (!parse_const_var_set_vars (lexer, var_set, &by[n_by], &by_nvar[n_by], PV_NO_DUPLICATE | PV_NO_SCRATCH)) - goto done; + goto done; size_t n = by_nvar[n_by++]; if (xalloc_oversized (nx, n)) overflow = true; @@ -696,20 +696,20 @@ parse_crosstabs_variables (struct lexer *lexer, struct dataset *ds, &proc->variables, &proc->n_variables, (PV_APPEND | PV_NUMERIC | PV_NO_DUPLICATE | PV_NO_SCRATCH))) - return false; + return false; if (!lex_force_match (lexer, T_LPAREN)) - goto error; + goto error; if (!lex_force_int (lexer)) - goto error; + goto error; long min = lex_integer (lexer); lex_get (lexer); lex_match (lexer, T_COMMA); if (!lex_force_int_range (lexer, NULL, min, LONG_MAX)) - goto error; + goto error; long max = lex_integer (lexer); lex_get (lexer); @@ -728,10 +728,10 @@ parse_crosstabs_variables (struct lexer *lexer, struct dataset *ds, }; hmap_insert (&proc->var_ranges, &vr->hmap_node, hash_pointer (var, 0)); - } + } if (lex_token (lexer) == T_SLASH) - break; + break; } proc->mode = INTEGER; @@ -920,7 +920,7 @@ postcalc (struct crosstabs_proc *proc, struct lexer *lexer) sort (xt->entries, xt->n_entries, sizeof *xt->entries, proc->descending ? compare_table_entry_3way_inv : compare_table_entry_3way, - xt); + xt); } make_summary_table (proc); @@ -1207,7 +1207,7 @@ output_crosstabulation (struct crosstabs_proc *proc, struct crosstabulation *xt, display_crosstabulation (proc, &x, table, crs_leaves); if (proc->exclude == 0) - delete_missing (&x); + delete_missing (&x); if (chisq) display_chisq (&x, chisq); @@ -1683,8 +1683,8 @@ enum_var_values (const struct crosstabulation *xt, int var_idx, hmapx_destroy (&set); sort (xv->values, xv->n_values, sizeof *xv->values, - descending ? compare_value_3way_inv : compare_value_3way, - &width); + descending ? compare_value_3way_inv : compare_value_3way, + &width); } } @@ -1913,7 +1913,7 @@ display_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, { struct symmetric_statistic *s = &ss[i]; if (s->v == SYSMIS) - continue; + continue; indexes[1] = i; @@ -1962,25 +1962,25 @@ display_risk (struct crosstabulation *xt, struct pivot_table *risk, const struct variable *rv = xt->vars[ROW_VAR].var; if (risk_v[i] == SYSMIS) - continue; + continue; struct string label = DS_EMPTY_INITIALIZER; switch (i) - { - case 0: + { + case 0: ds_put_format (&label, _("Odds Ratio for %s"), var_to_string (rv)); ds_put_cstr (&label, " ("); var_append_value_name (rv, &c[0], &label); ds_put_cstr (&label, " / "); var_append_value_name (rv, &c[1], &label); ds_put_cstr (&label, ")"); - break; - case 1: - case 2: + break; + case 1: + case 2: ds_put_format (&label, _("For cohort %s = "), var_to_string (cv)); var_append_value_name (cv, &xt->vars[ROW_VAR].values[i - 1], &label); - break; - } + break; + } indexes[1] = pivot_category_create_leaf ( risk_statistics->root, @@ -2026,7 +2026,7 @@ display_directional (struct crosstabs_proc *proc, for (size_t i = 0; i < N_DIRECTIONAL; i++) { if (direct_v[i] == SYSMIS) - continue; + continue; indexes[1] = i; @@ -2064,10 +2064,10 @@ static inline double Pr (int a, int b, int c, int d) { return exp (log_gamma_int (a + b + 1.) - log_gamma_int (a + 1.) - + log_gamma_int (c + d + 1.) - log_gamma_int (b + 1.) - + log_gamma_int (a + c + 1.) - log_gamma_int (c + 1.) - + log_gamma_int (b + d + 1.) - log_gamma_int (d + 1.) - - log_gamma_int (a + b + c + d + 1.)); + + log_gamma_int (c + d + 1.) - log_gamma_int (b + 1.) + + log_gamma_int (a + c + 1.) - log_gamma_int (c + 1.) + + log_gamma_int (b + d + 1.) - log_gamma_int (d + 1.) + - log_gamma_int (a + b + c + d + 1.)); } /* Swap the contents of A and B. */ @@ -2091,9 +2091,9 @@ calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2) if (b * c < a * d) { if (b < c) - swap (&a, &b), swap (&c, &d); + swap (&a, &b), swap (&c, &d); else - swap (&a, &c), swap (&b, &d); + swap (&a, &c), swap (&b, &d); } double pn1 = Pr (a, b, c, d); @@ -2106,7 +2106,7 @@ calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2) { double p = Pr (a + xt, b - xt, c - xt, d + xt); if (p < pn1) - *fisher2 += p; + *fisher2 += p; } } @@ -2116,7 +2116,7 @@ calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2) static void calc_chisq (struct crosstabulation *xt, double chisq[N_CHISQ], int df[N_CHISQ], - double *fisher1, double *fisher2) + double *fisher1, double *fisher2) { chisq[0] = chisq[1] = 0.; chisq[2] = chisq[3] = chisq[4] = SYSMIS; @@ -2212,10 +2212,10 @@ calc_r (struct crosstabulation *xt, for (size_t i = 0; i < n_rows; i++) for (size_t j = 0; j < n_cols; j++) { - double fij = xt->mat[j + i * n_cols]; - double product = XT[i] * Y[j]; - double temp = fij * product; - sum_XYf += temp; + double fij = xt->mat[j + i * n_cols]; + double product = XT[i] * Y[j]; + double temp = fij * product; + sum_XYf += temp; } double sum_Xr = 0; @@ -2282,7 +2282,7 @@ calc_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, /* Phi, Cramer's V, contingency coefficient. */ if (proc->statistics & (CRS_ST_PHI | CRS_ST_CC)) { - double Xp = 0.; /* Pearson chi-square. */ + double Xp = 0.; /* Pearson chi-square. */ FOR_EACH_POPULATED_ROW (r, xt) FOR_EACH_POPULATED_COLUMN (c, xt) @@ -2295,12 +2295,12 @@ calc_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, } if (proc->statistics & CRS_ST_PHI) - { - sym[0].v = sqrt (Xp / xt->total); - sym[1].v = sqrt (Xp / (xt->total * (q - 1))); - } + { + sym[0].v = sqrt (Xp / xt->total); + sym[1].v = sqrt (Xp / (xt->total * (q - 1))); + } if (proc->statistics & CRS_ST_CC) - sym[2].v = sqrt (Xp / (Xp + xt->total)); + sym[2].v = sqrt (Xp / (Xp + xt->total)); } if (proc->statistics & (CRS_ST_BTAU | CRS_ST_CTAU @@ -2358,14 +2358,14 @@ calc_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, } if (proc->statistics & CRS_ST_BTAU) - sym[3].v = (P - Q) / sqrt (Dr * Dc); + sym[3].v = (P - Q) / sqrt (Dr * Dc); if (proc->statistics & CRS_ST_CTAU) - sym[4].v = (q * (P - Q)) / (pow2 (xt->total) * (q - 1)); + sym[4].v = (q * (P - Q)) / (pow2 (xt->total) * (q - 1)); if (proc->statistics & CRS_ST_GAMMA) - sym[5].v = (P - Q) / (P + Q); + sym[5].v = (P - Q) / (P + Q); /* ASE for tau-b, tau-c, gamma. Calculations could be - eliminated here, at expense of memory. */ + eliminated here, at expense of memory. */ double btau_cum = 0; double ctau_cum = 0; double gamma_cum = 0; @@ -2418,44 +2418,44 @@ calc_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, } if (proc->statistics & CRS_ST_BTAU) - { + { double btau_var = ((btau_cum - (xt->total * pow2 (xt->total * (P - Q) / sqrt (Dr * Dc) * (Dr + Dc)))) / pow2 (Dr * Dc)); - sym[3].ase = sqrt (btau_var); - sym[3].t = sym[3].v / (2 * sqrt ((ctau_cum - (P - Q) * (P - Q) / xt->total) + sym[3].ase = sqrt (btau_var); + sym[3].t = sym[3].v / (2 * sqrt ((ctau_cum - (P - Q) * (P - Q) / xt->total) / (Dr * Dc))); - } + } if (proc->statistics & CRS_ST_CTAU) - { - sym[4].ase = ((2 * q / ((q - 1) * pow2 (xt->total))) + { + sym[4].ase = ((2 * q / ((q - 1) * pow2 (xt->total))) * sqrt (ctau_cum - (P - Q) * (P - Q) / xt->total)); - sym[4].t = sym[4].v / sym[4].ase; - } + sym[4].t = sym[4].v / sym[4].ase; + } if (proc->statistics & CRS_ST_GAMMA) - { - sym[5].ase = ((4. / ((P + Q) * (P + Q))) * sqrt (gamma_cum)); - sym[5].t = sym[5].v / (2. / (P + Q) + { + sym[5].ase = ((4. / ((P + Q) * (P + Q))) * sqrt (gamma_cum)); + sym[5].t = sym[5].v / (2. / (P + Q) * sqrt (ctau_cum - (P - Q) * (P - Q) / xt->total)); - } + } if (proc->statistics & CRS_ST_D) - { - somers_d[0].v = (P - Q) / (.5 * (Dc + Dr)); - somers_d[0].ase = SYSMIS; - somers_d[0].t = (somers_d[0].v - / (4 / (Dc + Dr) - * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); - somers_d[1].v = (P - Q) / Dc; - somers_d[1].ase = 2. / pow2 (Dc) * sqrt (d_xy_cum); - somers_d[1].t = (somers_d[1].v - / (2. / Dc - * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); - somers_d[2].v = (P - Q) / Dr; - somers_d[2].ase = 2. / pow2 (Dr) * sqrt (d_yx_cum); - somers_d[2].t = (somers_d[2].v - / (2. / Dr - * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); - } + { + somers_d[0].v = (P - Q) / (.5 * (Dc + Dr)); + somers_d[0].ase = SYSMIS; + somers_d[0].t = (somers_d[0].v + / (4 / (Dc + Dr) + * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); + somers_d[1].v = (P - Q) / Dc; + somers_d[1].ase = 2. / pow2 (Dc) * sqrt (d_xy_cum); + somers_d[1].t = (somers_d[1].v + / (2. / Dc + * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); + somers_d[2].v = (P - Q) / Dr; + somers_d[2].ase = 2. / pow2 (Dr) * sqrt (d_yx_cum); + somers_d[2].t = (somers_d[2].v + / (2. / Dr + * sqrt (ctau_cum - pow2 (P - Q) / xt->total))); + } free (cum); } @@ -2504,26 +2504,26 @@ calc_symmetric (struct crosstabs_proc *proc, struct crosstabulation *xt, double sum_fiiri_ci = 0; double sum_riciri_ci = 0; for (size_t i = 0, j = 0; i < xt->ns_rows; i++, j++) - { - while (xt->col_tot[j] == 0.) - j++; + { + while (xt->col_tot[j] == 0.) + j++; - double prod = xt->row_tot[i] * xt->col_tot[j]; - double sum = xt->row_tot[i] + xt->col_tot[j]; + double prod = xt->row_tot[i] * xt->col_tot[j]; + double sum = xt->row_tot[i] + xt->col_tot[j]; - sum_fii += xt->mat[j + i * n_cols]; - sum_rici += prod; - sum_fiiri_ci += xt->mat[j + i * n_cols] * sum; - sum_riciri_ci += prod * sum; - } + sum_fii += xt->mat[j + i * n_cols]; + sum_rici += prod; + sum_fiiri_ci += xt->mat[j + i * n_cols] * sum; + sum_riciri_ci += prod * sum; + } double sum_fijri_ci2 = 0; for (size_t i = 0; i < xt->ns_rows; i++) - for (size_t j = 0; j < xt->ns_cols; j++) - { - double sum = xt->row_tot[i] + xt->col_tot[j]; - sum_fijri_ci2 += xt->mat[j + i * n_cols] * sum * sum; - } + for (size_t j = 0; j < xt->ns_cols; j++) + { + double sum = xt->row_tot[i] + xt->col_tot[j]; + sum_fijri_ci2 += xt->mat[j + i * n_cols] * sum * sum; + } sym[8].v = (xt->total * sum_fii - sum_rici) / (pow2 (xt->total) - sum_rici); @@ -2593,13 +2593,13 @@ calc_risk (struct crosstabulation *xt, value[1] = (f11 * (f21 + f22)) / (f21 * (f11 + f12)); v = sqrt ((f12 / (f11 * (f11 + f12))) - + (f22 / (f21 * (f21 + f22)))); + + (f22 / (f21 * (f21 + f22)))); lower[1] = value[1] * exp (-1.960 * v); upper[1] = value[1] * exp (1.960 * v); value[2] = (f12 * (f21 + f22)) / (f22 * (f11 + f12)); v = sqrt ((f11 / (f12 * (f11 + f12))) - + (f21 / (f22 * (f21 + f22)))); + + (f21 / (f22 * (f21 + f22)))); lower[2] = value[2] * exp (-1.960 * v); upper[2] = value[2] * exp (1.960 * v); @@ -2610,7 +2610,7 @@ calc_risk (struct crosstabulation *xt, static void calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL], - double t[N_DIRECTIONAL], double sig[N_DIRECTIONAL]) + double t[N_DIRECTIONAL], double sig[N_DIRECTIONAL]) { size_t n_rows = xt->vars[ROW_VAR].n_values; size_t n_cols = xt->vars[COL_VAR].n_values; @@ -2625,62 +2625,62 @@ calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, size_t *fim_index = xnmalloc (n_rows, sizeof *fim_index); double sum_fim = 0.0; for (size_t i = 0; i < n_rows; i++) - { - double max = xt->mat[i * n_cols]; - size_t index = 0; + { + double max = xt->mat[i * n_cols]; + size_t index = 0; - for (size_t j = 1; j < n_cols; j++) - if (xt->mat[j + i * n_cols] > max) - { - max = xt->mat[j + i * n_cols]; - index = j; - } + for (size_t j = 1; j < n_cols; j++) + if (xt->mat[j + i * n_cols] > max) + { + max = xt->mat[j + i * n_cols]; + index = j; + } fim[i] = max; - sum_fim += max; - fim_index[i] = index; - } + sum_fim += max; + fim_index[i] = index; + } /* Find maximum for each column. */ double *fmj = xnmalloc (n_cols, sizeof *fmj); size_t *fmj_index = xnmalloc (n_cols, sizeof *fmj_index); double sum_fmj = 0.0; for (size_t j = 0; j < n_cols; j++) - { - double max = xt->mat[j]; - size_t index = 0; + { + double max = xt->mat[j]; + size_t index = 0; - for (size_t i = 1; i < n_rows; i++) - if (xt->mat[j + i * n_cols] > max) - { - max = xt->mat[j + i * n_cols]; - index = i; - } + for (size_t i = 1; i < n_rows; i++) + if (xt->mat[j + i * n_cols] > max) + { + max = xt->mat[j + i * n_cols]; + index = i; + } fmj[j] = max; - sum_fmj += max; - fmj_index[j] = index; - } + sum_fmj += max; + fmj_index[j] = index; + } /* Find maximum row total. */ double rm = xt->row_tot[0]; size_t rm_index = 0; for (size_t i = 1; i < n_rows; i++) - if (xt->row_tot[i] > rm) - { - rm = xt->row_tot[i]; - rm_index = i; - } + if (xt->row_tot[i] > rm) + { + rm = xt->row_tot[i]; + rm_index = i; + } /* Find maximum column total. */ double cm = xt->col_tot[0]; size_t cm_index = 0; for (size_t j = 1; j < n_cols; j++) - if (xt->col_tot[j] > cm) - { - cm = xt->col_tot[j]; - cm_index = j; - } + if (xt->col_tot[j] > cm) + { + cm = xt->col_tot[j]; + cm_index = j; + } v[0] = (sum_fim + sum_fmj - cm - rm) / (2. * xt->total - rm - cm); v[1] = (sum_fmj - rm) / (xt->total - rm); @@ -2689,7 +2689,7 @@ calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, /* ASE1 for Y given XT. */ { double accum = 0.0; - for (size_t i = 0; i < n_rows; i++) + for (size_t i = 0; i < n_rows; i++) if (cm_index == fim_index[i]) accum += fim[i]; ase[2] = sqrt ((xt->total - sum_fim) * (sum_fim + cm - 2. * accum) @@ -2698,18 +2698,18 @@ calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, /* ASE0 for Y given XT. */ { - double accum = 0.0; - for (size_t i = 0; i < n_rows; i++) - if (cm_index != fim_index[i]) - accum += (xt->mat[i * n_cols + fim_index[i]] - + xt->mat[i * n_cols + cm_index]); - t[2] = v[2] / (sqrt (accum - pow2 (sum_fim - cm) / xt->total) / (xt->total - cm)); + double accum = 0.0; + for (size_t i = 0; i < n_rows; i++) + if (cm_index != fim_index[i]) + accum += (xt->mat[i * n_cols + fim_index[i]] + + xt->mat[i * n_cols + cm_index]); + t[2] = v[2] / (sqrt (accum - pow2 (sum_fim - cm) / xt->total) / (xt->total - cm)); } /* ASE1 for XT given Y. */ { double accum = 0.0; - for (size_t j = 0; j < n_cols; j++) + for (size_t j = 0; j < n_cols; j++) if (rm_index == fmj_index[j]) accum += fmj[j]; ase[1] = sqrt ((xt->total - sum_fmj) * (sum_fmj + rm - 2. * accum) @@ -2718,30 +2718,30 @@ calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, /* ASE0 for XT given Y. */ { - double accum = 0.0; - for (size_t j = 0; j < n_cols; j++) - if (rm_index != fmj_index[j]) - accum += (xt->mat[j + n_cols * fmj_index[j]] - + xt->mat[j + n_cols * rm_index]); - t[1] = v[1] / (sqrt (accum - pow2 (sum_fmj - rm) / xt->total) / (xt->total - rm)); + double accum = 0.0; + for (size_t j = 0; j < n_cols; j++) + if (rm_index != fmj_index[j]) + accum += (xt->mat[j + n_cols * fmj_index[j]] + + xt->mat[j + n_cols * rm_index]); + t[1] = v[1] / (sqrt (accum - pow2 (sum_fmj - rm) / xt->total) / (xt->total - rm)); } /* Symmetric ASE0 and ASE1. */ { - double accum0 = 0.0; - double accum1 = 0.0; - for (size_t i = 0; i < n_rows; i++) - for (size_t j = 0; j < n_cols; j++) - { - int temp0 = (fmj_index[j] == i) + (fim_index[i] == j); - int temp1 = (i == rm_index) + (j == cm_index); - accum0 += xt->mat[j + i * n_cols] * pow2 (temp0 - temp1); - accum1 += (xt->mat[j + i * n_cols] - * pow2 (temp0 + (v[0] - 1.) * temp1)); - } - ase[0] = sqrt (accum1 - 4. * xt->total * v[0] * v[0]) / (2. * xt->total - rm - cm); - t[0] = v[0] / (sqrt (accum0 - pow2 (sum_fim + sum_fmj - cm - rm) / xt->total) - / (2. * xt->total - rm - cm)); + double accum0 = 0.0; + double accum1 = 0.0; + for (size_t i = 0; i < n_rows; i++) + for (size_t j = 0; j < n_cols; j++) + { + int temp0 = (fmj_index[j] == i) + (fim_index[i] == j); + int temp1 = (i == rm_index) + (j == cm_index); + accum0 += xt->mat[j + i * n_cols] * pow2 (temp0 - temp1); + accum1 += (xt->mat[j + i * n_cols] + * pow2 (temp0 + (v[0] - 1.) * temp1)); + } + ase[0] = sqrt (accum1 - 4. * xt->total * v[0] * v[0]) / (2. * xt->total - rm - cm); + t[0] = v[0] / (sqrt (accum0 - pow2 (sum_fim + sum_fmj - cm - rm) / xt->total) + / (2. * xt->total - rm - cm)); } for (size_t i = 0; i < 3; i++) @@ -2788,36 +2788,36 @@ calc_directional (struct crosstabs_proc *proc, struct crosstabulation *xt, double UXY = 0.0; double P = 0.0; for (size_t i = 0; i < n_rows; i++) - for (size_t j = 0; j < n_cols; j++) - { - double entry = xt->mat[j + i * n_cols]; + for (size_t j = 0; j < n_cols; j++) + { + double entry = xt->mat[j + i * n_cols]; - if (entry <= 0.) - continue; + if (entry <= 0.) + continue; - P += entry * pow2 (log (xt->col_tot[j] * xt->row_tot[i] / (xt->total * entry))); - UXY -= entry / xt->total * log (entry / xt->total); - } + P += entry * pow2 (log (xt->col_tot[j] * xt->row_tot[i] / (xt->total * entry))); + UXY -= entry / xt->total * log (entry / xt->total); + } double ase1_yx = 0.0; double ase1_xy = 0.0; double ase1_sym = 0.0; for (size_t i = 0; i < n_rows; i++) - for (size_t j = 0; j < n_cols; j++) - { - double entry = xt->mat[j + i * n_cols]; - - if (entry <= 0.) - continue; - - ase1_yx += entry * pow2 (UY * log (entry / xt->row_tot[i]) - + (UX - UXY) * log (xt->col_tot[j] / xt->total)); - ase1_xy += entry * pow2 (UX * log (entry / xt->col_tot[j]) - + (UY - UXY) * log (xt->row_tot[i] / xt->total)); - ase1_sym += entry * pow2 ((UXY - * log (xt->row_tot[i] * xt->col_tot[j] / pow2 (xt->total))) - - (UX + UY) * log (entry / xt->total)); - } + for (size_t j = 0; j < n_cols; j++) + { + double entry = xt->mat[j + i * n_cols]; + + if (entry <= 0.) + continue; + + ase1_yx += entry * pow2 (UY * log (entry / xt->row_tot[i]) + + (UX - UXY) * log (xt->col_tot[j] / xt->total)); + ase1_xy += entry * pow2 (UX * log (entry / xt->col_tot[j]) + + (UY - UXY) * log (xt->row_tot[i] / xt->total)); + ase1_sym += entry * pow2 ((UXY + * log (xt->row_tot[i] * xt->col_tot[j] / pow2 (xt->total))) + - (UX + UY) * log (entry / xt->total)); + } v[5] = 2. * ((UX + UY - UXY) / (UX + UY)); ase[5] = (2. / (xt->total * pow2 (UX + UY))) * sqrt (ase1_sym); diff --git a/src/language/commands/data-list.c b/src/language/commands/data-list.c index d6a5d0fd55..27ac7c07cd 100644 --- a/src/language/commands/data-list.c +++ b/src/language/commands/data-list.c @@ -60,7 +60,7 @@ struct data_list_trns struct data_parser *parser; /* Parser. */ struct dictionary *dict; /* Dictionary. */ struct dfm_reader *reader; /* Data file reader. */ - struct variable *end; /* Variable specified on END subcommand. */ + struct variable *end; /* Variable specified on END subcommand. */ }; static bool parse_fixed (struct lexer *, struct dictionary *, @@ -93,51 +93,51 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) while (lex_token (lexer) != T_SLASH) { if (lex_match_id (lexer, "FILE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); fh_unref (fh); - fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); - if (fh == NULL) - goto error; - } + fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); + if (fh == NULL) + goto error; + } else if (lex_match_id (lexer, "ENCODING")) - { + { encoding_start = lex_ofs (lexer) - 1; - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto error; + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (lexer)); encoding_end = lex_ofs (lexer); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "RECORDS")) - { + { if (data_parser_get_records (parser) > 0) { lex_sbc_only_once (lexer, "RECORDS"); goto error; } - lex_match (lexer, T_EQUALS); - lex_match (lexer, T_LPAREN); - if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX)) - goto error; + lex_match (lexer, T_EQUALS); + lex_match (lexer, T_LPAREN); + if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX)) + goto error; data_parser_set_records (parser, lex_integer (lexer)); - lex_get (lexer); - lex_match (lexer, T_RPAREN); - } + lex_get (lexer); + lex_match (lexer, T_RPAREN); + } else if (lex_match_id (lexer, "SKIP")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_int_range (lexer, "SKIP", 0, INT_MAX)) - goto error; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_int_range (lexer, "SKIP", 0, INT_MAX)) + goto error; data_parser_set_skip (parser, lex_integer (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "END")) - { + { if (!in_input_program ()) { lex_next_error (lexer, -1, -1, @@ -145,29 +145,29 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) "END", "INPUT PROGRAM"); goto error; } - if (end) - { + if (end) + { lex_sbc_only_once (lexer, "END"); - goto error; - } + goto error; + } end_start = lex_ofs (lexer) - 1; - lex_match (lexer, T_EQUALS); - if (!lex_force_id (lexer)) - goto error; + lex_match (lexer, T_EQUALS); + if (!lex_force_id (lexer)) + goto error; end_end = lex_ofs (lexer); - end = dict_lookup_var (dict, lex_tokcstr (lexer)); - if (!end) + end = dict_lookup_var (dict, lex_tokcstr (lexer)); + if (!end) end = dict_create_var_assert (dict, lex_tokcstr (lexer), 0); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "NOTABLE")) table = 0; else if (lex_match_id (lexer, "TABLE")) table = 1; else if (lex_token (lexer) == T_ID) - { + { if (lex_match_id (lexer, "FIXED")) data_parser_set_type (parser, DP_FIXED); else if (lex_match_id (lexer, "FREE")) @@ -248,12 +248,12 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) } } else - { + { lex_error_expecting (lexer, "FILE", "ENCODING", "RECORDS", "SKIP", "END", "NOTABLE", "TABLE", "FIXED", "FREE", "LIST"); - goto error; - } + goto error; + } } if (!fh) @@ -335,7 +335,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) successful. */ static bool parse_fixed (struct lexer *lexer, struct dictionary *dict, - struct pool *tmp_pool, struct data_parser *parser) + struct pool *tmp_pool, struct data_parser *parser) { int max_records = data_parser_get_records (parser); int record = 0; @@ -480,16 +480,16 @@ parse_free (struct lexer *lexer, struct dictionary *dict, int vars_start = lex_ofs (lexer); if (!parse_DATA_LIST_vars_pool (lexer, dict, tmp_pool, - &names, &n_names, PV_NONE)) - return false; + &names, &n_names, PV_NONE)) + return false; int vars_end = lex_ofs (lexer) - 1; struct fmt_spec input, output; if (lex_match (lexer, T_LPAREN)) - { + { char type[FMT_TYPE_LEN_MAX + 1]; - if (!parse_abstract_format_specifier (lexer, type, &input.w, + if (!parse_abstract_format_specifier (lexer, type, &input.w, &input.d)) return NULL; if (!fmt_from_name (type, &input.type)) @@ -524,32 +524,32 @@ parse_free (struct lexer *lexer, struct dictionary *dict, if (input.type == FMT_N) input.type = FMT_F; - output = fmt_for_output_from_input (input, + output = fmt_for_output_from_input (input, settings_get_fmt_settings ()); - } + } else - { - lex_match (lexer, T_ASTERISK); + { + lex_match (lexer, T_ASTERISK); input = fmt_for_input (FMT_F, 8, 0); - output = settings_get_format (); - } + output = settings_get_format (); + } for (size_t i = 0; i < n_names; i++) - { - struct variable *v = dict_create_var (dict, names[i], + { + struct variable *v = dict_create_var (dict, names[i], fmt_var_width (input)); - if (!v) - { - lex_ofs_error (lexer, vars_start, vars_end, + if (!v) + { + lex_ofs_error (lexer, vars_start, vars_end, _("%s is a duplicate variable name."), names[i]); - return false; - } + return false; + } var_set_both_formats (v, output); data_parser_add_delimited_field (parser, input, var_get_dict_index (v), var_get_name (v)); - } + } } while (lex_token (lexer) != T_ENDCMD); diff --git a/src/language/commands/data-parser.c b/src/language/commands/data-parser.c index 5105bd5aa8..7a0555a085 100644 --- a/src/language/commands/data-parser.c +++ b/src/language/commands/data-parser.c @@ -68,12 +68,12 @@ struct data_parser /* How to parse one variable. */ struct field { - struct fmt_spec format; /* Input format of this field. */ + struct fmt_spec format; /* Input format of this field. */ int case_idx; /* First value in case. */ char *name; /* Var name for error messages and tables. */ /* DP_FIXED only. */ - int record; /* Record number (1-based). */ + int record; /* Record number (1-based). */ int first_column; /* First column in record (1-based). */ }; @@ -188,7 +188,7 @@ data_parser_set_empty_line_has_field (struct data_parser *parser, This setting affects parsing of DP_DELIMITED files only. */ void data_parser_set_warn_missing_fields (struct data_parser *parser, - bool warn_missing_fields) + bool warn_missing_fields) { parser->warn_missing_fields = warn_missing_fields; } @@ -627,18 +627,18 @@ parse_delimited_span (const struct data_parser *parser, /* Cut out a field and read in a new record if necessary. */ while (!cut_field (parser, reader, &first_column, &last_column, &tmp, &s)) - { - if (!dfm_eof (reader)) + { + if (!dfm_eof (reader)) dfm_forward_record (reader); - if (dfm_eof (reader)) - { - if (f > parser->fields) - msg (DW, _("Partial case discarded. The first variable " + if (dfm_eof (reader)) + { + if (f > parser->fields) + msg (DW, _("Partial case discarded. The first variable " "missing was %s."), f->name); ds_destroy (&tmp); - return false; - } - } + return false; + } + } const char *input_encoding = dfm_reader_get_encoding (reader); error = data_in (s, input_encoding, f->format.type, @@ -675,17 +675,17 @@ parse_delimited_no_span (const struct data_parser *parser, char *error; if (!cut_field (parser, reader, &first_column, &last_column, &tmp, &s)) - { - if (f < end - 1 && settings_get_undefined () && parser->warn_missing_fields) - msg (DW, _("Missing value(s) for all variables from %s onward. " + { + if (f < end - 1 && settings_get_undefined () && parser->warn_missing_fields) + msg (DW, _("Missing value(s) for all variables from %s onward. " "These will be filled with the system-missing value " "or blanks, as appropriate."), - f->name); + f->name); for (; f < end; f++) value_set_missing (case_data_rw_idx (c, f->case_idx), fmt_var_width (f->format)); goto exit; - } + } const char *input_encoding = dfm_reader_get_encoding (reader); error = data_in (s, input_encoding, f->format.type, @@ -821,12 +821,12 @@ static const struct casereader_class data_parser_casereader_class; transferred to the dataset. */ void data_parser_make_active_file (struct data_parser *parser, struct dataset *ds, - struct dfm_reader *reader, + struct dfm_reader *reader, struct dictionary *dict, - struct casereader* (*func)(struct casereader *, - const struct dictionary *, - void *), - void *ud) + struct casereader* (*func)(struct casereader *, + const struct dictionary *, + void *), + void *ud) { struct data_parser_casereader *r; struct casereader *casereader0; diff --git a/src/language/commands/data-parser.h b/src/language/commands/data-parser.h index 0194c066f4..92c348634e 100644 --- a/src/language/commands/data-parser.h +++ b/src/language/commands/data-parser.h @@ -54,7 +54,7 @@ void data_parser_set_span (struct data_parser *, bool may_cases_span_records); void data_parser_set_empty_line_has_field (struct data_parser *, bool empty_line_has_field); void data_parser_set_warn_missing_fields (struct data_parser *parser, - bool warn_missing_fields); + bool warn_missing_fields); void data_parser_set_quotes (struct data_parser *, struct substring); void data_parser_set_quote_escape (struct data_parser *, bool escape); @@ -84,10 +84,10 @@ void data_parser_output_description (struct data_parser *, struct casereader; void data_parser_make_active_file (struct data_parser *, struct dataset *, struct dfm_reader *, struct dictionary *, - struct casereader* (*func)(struct casereader *, - const struct dictionary *, - void *), - void *ud); + struct casereader* (*func)(struct casereader *, + const struct dictionary *, + void *), + void *ud); #endif /* language/commands/data-parser.h */ diff --git a/src/language/commands/descriptives.c b/src/language/commands/descriptives.c index 10bbbdbbde..db52d9ff69 100644 --- a/src/language/commands/descriptives.c +++ b/src/language/commands/descriptives.c @@ -62,8 +62,8 @@ struct dsc_z_score { const struct variable *src_var; /* Variable on which z-score is based. */ struct variable *z_var; /* New z-score variable. */ - double mean; /* Distribution mean. */ - double std_dev; /* Distribution standard deviation. */ + double mean; /* Distribution mean. */ + double std_dev; /* Distribution standard deviation. */ }; /* DESCRIPTIVES transformation (for calculating Z-scores). */ @@ -97,8 +97,8 @@ enum dsc_statistic struct dsc_statistic_info { const char *identifier; /* Identifier. */ - const char *name; /* Full name. */ - enum moment moment; /* Highest moment needed to calculate. */ + const char *name; /* Full name. */ + enum moment moment; /* Highest moment needed to calculate. */ }; /* Table of statistics, indexed by DSC_*. */ @@ -121,7 +121,7 @@ static const struct dsc_statistic_info dsc_info[DSC_N_STATS] = /* Statistics calculated by default if none are explicitly requested. */ #define DEFAULT_STATS \ - ((1UL << DSC_MEAN) | (1UL << DSC_STDDEV) | (1UL << DSC_MIN) \ + ((1UL << DSC_MEAN) | (1UL << DSC_STDDEV) | (1UL << DSC_MIN) \ | (1UL << DSC_MAX)) /* A variable specified on DESCRIPTIVES. */ @@ -129,10 +129,10 @@ struct dsc_var { const struct variable *v; /* Variable to calculate on. */ char *z_name; /* Name for z-score variable. */ - double valid, missing; /* Valid, missing counts. */ + double valid, missing; /* Valid, missing counts. */ struct moments *moments; /* Moments. */ double min, max; /* Maximum and mimimum values. */ - double stats[DSC_N_STATS]; /* All the stats' values. */ + double stats[DSC_N_STATS]; /* All the stats' values. */ }; /* A DESCRIPTIVES procedure. */ @@ -167,7 +167,7 @@ static void free_dsc_proc (struct dsc_proc *); /* Z-score functions. */ static bool try_name (const struct dictionary *dict, - struct dsc_proc *dsc, const char *name); + struct dsc_proc *dsc, const char *name); static char *generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, const char *name, int *n_zs); @@ -267,12 +267,12 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) else if (lex_match_id (lexer, "DEFAULT")) dsc->show_stats |= DEFAULT_STATS; else - { - enum dsc_statistic s = match_statistic (lexer); - if (s == DSC_NONE) + { + enum dsc_statistic s = match_statistic (lexer); + if (s == DSC_NONE) goto error; - dsc->show_stats |= 1UL << s; - } + dsc->show_stats |= 1UL << s; + } lex_match (lexer, T_COMMA); } if (dsc->show_stats == 0) @@ -284,11 +284,11 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) if (lex_match_id (lexer, "NAME")) dsc->sort_by_stat = DSC_NAME; else - { - dsc->sort_by_stat = match_statistic (lexer); - if (dsc->sort_by_stat == DSC_NONE) - dsc->sort_by_stat = DSC_MEAN; - } + { + dsc->sort_by_stat = match_statistic (lexer); + if (dsc->sort_by_stat == DSC_NONE) + dsc->sort_by_stat = DSC_MEAN; + } if (lex_match (lexer, T_LPAREN)) { if (lex_match_id (lexer, "A")) @@ -301,7 +301,7 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) goto error; } if (!lex_force_match (lexer, T_RPAREN)) - goto error; + goto error; } } else if (n_vars == 0) @@ -311,7 +311,7 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) { if (!parse_variables_const (lexer, dict, &vars, &n_vars, PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) - goto error; + goto error; dsc->vars = xnrealloc ((void *)dsc->vars, n_vars, sizeof *dsc->vars); for (size_t i = dsc->n_vars; i < n_vars; i++) @@ -335,7 +335,7 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) lex_tokcstr (lexer)); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) - goto error; + goto error; } } } @@ -456,7 +456,7 @@ match_statistic (struct lexer *lexer) { for (enum dsc_statistic stat = 0; stat < DSC_N_STATS; stat++) if (lex_match_id (lexer, dsc_info[stat].identifier)) - return stat; + return stat; const char *stat_names[DSC_N_STATS]; for (enum dsc_statistic stat = 0; stat < DSC_N_STATS; stat++) @@ -493,7 +493,7 @@ free_dsc_proc (struct dsc_proc *dsc) of any previously-declared z-var name; otherwise returns true. */ static bool try_name (const struct dictionary *dict, struct dsc_proc *dsc, - const char *name) + const char *name) { if (dict_lookup_var (dict, name) != NULL) return false; @@ -531,20 +531,20 @@ generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, (*n_zs)++; if (*n_zs <= 99) - sprintf (name, "ZSC%03d", *n_zs); + sprintf (name, "ZSC%03d", *n_zs); else if (*n_zs <= 108) - sprintf (name, "STDZ%02d", *n_zs - 99); + sprintf (name, "STDZ%02d", *n_zs - 99); else if (*n_zs <= 117) - sprintf (name, "ZZZZ%02d", *n_zs - 108); + sprintf (name, "ZZZZ%02d", *n_zs - 108); else if (*n_zs <= 126) - sprintf (name, "ZQZQ%02d", *n_zs - 117); + sprintf (name, "ZQZQ%02d", *n_zs - 117); else - { - msg (SE, _("Ran out of generic names for Z-score variables. " - "There are only 126 generic names: ZSC001-ZSC099, " - "STDZ01-STDZ09, ZZZZ01-ZZZZ09, ZQZQ01-ZQZQ09.")); - return NULL; - } + { + msg (SE, _("Ran out of generic names for Z-score variables. " + "There are only 126 generic names: ZSC001-ZSC099, " + "STDZ01-STDZ09, ZZZZ01-ZZZZ09, ZQZQ01-ZQZQ09.")); + return NULL; + } if (try_name (dict, dsc, name)) return xstrdup (name); @@ -635,8 +635,8 @@ descriptives_trns_proc (void *trns_, struct ccase **c, if (t->ok) { msg (SE, _("Internal error processing Z scores. " - "Please report this to %s."), - PACKAGE_BUGREPORT); + "Please report this to %s."), + PACKAGE_BUGREPORT); t->ok = false; } descriptives_set_all_sysmis_zscores (t, *c); @@ -650,14 +650,14 @@ descriptives_trns_proc (void *trns_, struct ccase **c, assert (t->vars != NULL); for (const struct variable **vars = t->vars; vars < t->vars + t->n_vars; vars++) - { - double score = case_num (*c, *vars); - if (var_is_num_missing (*vars, score) & t->exclude) - { + { + double score = case_num (*c, *vars); + if (var_is_num_missing (*vars, score) & t->exclude) + { descriptives_set_all_sysmis_zscores (t, *c); - return TRNS_CONTINUE; - } - } + return TRNS_CONTINUE; + } + } } for (struct dsc_z_score *z = t->z_scores; z < t->z_scores + t->n_z_scores; @@ -668,9 +668,9 @@ descriptives_trns_proc (void *trns_, struct ccase **c, if (z->mean == SYSMIS || z->std_dev == SYSMIS || var_is_num_missing (z->src_var, input) & t->exclude) - *output = SYSMIS; + *output = SYSMIS; else - *output = (input - z->mean) / z->std_dev; + *output = (input - z->mean) / z->std_dev; } return TRNS_CONTINUE; } @@ -721,7 +721,7 @@ setup_z_trns (struct dsc_proc *dsc, struct dataset *ds) t->n_vars = dsc->n_vars; t->vars = xnmalloc (t->n_vars, sizeof *t->vars); for (size_t i = 0; i < t->n_vars; i++) - t->vars[i] = dsc->vars[i].v; + t->vars[i] = dsc->vars[i].v; } dsc->z_writer = NULL; @@ -730,8 +730,8 @@ setup_z_trns (struct dsc_proc *dsc, struct dataset *ds) { struct dsc_var *dv = &dsc->vars[i]; if (dv->z_name != NULL) - { - struct variable *dst_var = dict_create_var_assert (dataset_dict (ds), + { + struct variable *dst_var = dict_create_var_assert (dataset_dict (ds), dv->z_name, 0); char *label = xasprintf (_("Z-score of %s"), var_to_string (dv->v)); @@ -743,7 +743,7 @@ setup_z_trns (struct dsc_proc *dsc, struct dataset *ds) .src_var = dv->v, .z_var = dst_var, }; - } + } } add_transformation (ds, &descriptives_trns_class, t); @@ -977,7 +977,7 @@ display (struct dsc_proc *dsc) pivot_value_new_number (dv->valid)); for (int j = 0; j < DSC_N_STATS; j++) - if (dsc->show_stats & (1UL << j)) + if (dsc->show_stats & (1UL << j)) { union value v = { .f = dv->stats[j] }; struct pivot_value *pv = (j == DSC_MIN || j == DSC_MAX diff --git a/src/language/commands/examine.c b/src/language/commands/examine.c index a9a426ee01..cabe39153b 100644 --- a/src/language/commands/examine.c +++ b/src/language/commands/examine.c @@ -289,7 +289,7 @@ show_boxplot_variabled (const struct examine *cmd, int iact_idx) double y_max = -DBL_MAX; const struct ccase *c = - categoricals_get_case_by_category_real (cmd->cats, iact_idx, grp); + categoricals_get_case_by_category_real (cmd->cats, iact_idx, grp); struct string title; ds_init_empty (&title); @@ -413,7 +413,7 @@ show_npplot (const struct examine *cmd, int iact_idx) chart_submit (npp); chart_submit (dnpp); } - casereader_destroy (reader); + casereader_destroy (reader); ds_destroy (&label); } @@ -439,14 +439,14 @@ show_spreadlevel (const struct examine *cmd, int iact_idx) struct string label; ds_init_cstr (&label, - var_to_string (cmd->dep_vars[v])); + var_to_string (cmd->dep_vars[v])); if (iact->n_vars > 0) - { - ds_put_cstr (&label, " ("); - interaction_to_string (iact, &label); - ds_put_cstr (&label, ")"); - } + { + ds_put_cstr (&label, " ("); + interaction_to_string (iact, &label); + ds_put_cstr (&label, ")"); + } sl = spreadlevel_plot_create (ds_cstr (&label), cmd->sl_power); @@ -455,18 +455,18 @@ show_spreadlevel (const struct examine *cmd, int iact_idx) const struct exploratory_stats *es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp); - double median = percentile_calculate (es[v].quartiles[1], cmd->pc_alg); + double median = percentile_calculate (es[v].quartiles[1], cmd->pc_alg); - double iqr = percentile_calculate (es[v].quartiles[2], cmd->pc_alg) - - percentile_calculate (es[v].quartiles[0], cmd->pc_alg); + double iqr = percentile_calculate (es[v].quartiles[2], cmd->pc_alg) - + percentile_calculate (es[v].quartiles[0], cmd->pc_alg); - spreadlevel_plot_add (sl, iqr, median); - } + spreadlevel_plot_add (sl, iqr, median); + } if (sl == NULL) - msg (MW, _("Not creating spreadlevel chart for %s"), ds_cstr (&label)); + msg (MW, _("Not creating spreadlevel chart for %s"), ds_cstr (&label)); else - chart_submit (sl); + chart_submit (sl); ds_destroy (&label); } @@ -497,8 +497,8 @@ show_histogram (const struct examine *cmd, int iact_idx) struct string label; - if (es[v].histogram == NULL) - continue; + if (es[v].histogram == NULL) + continue; ds_init_cstr (&label, var_to_string (cmd->dep_vars[v])); @@ -658,9 +658,9 @@ normality_report (const struct examine *cmd, int iact_idx) struct pivot_dimension *test = pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Shapiro-Wilk"), - N_("Statistic"), - N_("df"), PIVOT_RC_COUNT, - N_("Sig.")); + N_("Statistic"), + N_("df"), PIVOT_RC_COUNT, + N_("Sig.")); test->root->show_label = true; @@ -677,37 +677,37 @@ normality_report (const struct examine *cmd, int iact_idx) for (size_t v = 0; v < cmd->n_dep_vars; ++v) { indexes[table->n_dimensions - 1] = - pivot_category_create_leaf (dep_dim->root, pivot_value_new_variable (cmd->dep_vars[v])); + pivot_category_create_leaf (dep_dim->root, pivot_value_new_variable (cmd->dep_vars[v])); for (size_t i = 0; i < n_cats; ++i) { - indexes[1] = i; + indexes[1] = i; const struct exploratory_stats *es = categoricals_get_user_data_by_category_real ( cmd->cats, iact_idx, i); - struct shapiro_wilk *sw = es[v].shapiro_wilk; + struct shapiro_wilk *sw = es[v].shapiro_wilk; - if (sw == NULL) - continue; + if (sw == NULL) + continue; - double w = shapiro_wilk_calculate (sw); + double w = shapiro_wilk_calculate (sw); - int j = 0; - indexes[0] = j; + int j = 0; + indexes[0] = j; - pivot_table_put (table, indexes, table->n_dimensions, - pivot_value_new_number (w)); + pivot_table_put (table, indexes, table->n_dimensions, + pivot_value_new_number (w)); - indexes[0] = ++j; - pivot_table_put (table, indexes, table->n_dimensions, - pivot_value_new_number (sw->n)); + indexes[0] = ++j; + pivot_table_put (table, indexes, table->n_dimensions, + pivot_value_new_number (sw->n)); - indexes[0] = ++j; - pivot_table_put (table, indexes, table->n_dimensions, - pivot_value_new_number (shapiro_wilk_significance (sw->n, w))); - } + indexes[0] = ++j; + pivot_table_put (table, indexes, table->n_dimensions, + pivot_value_new_number (shapiro_wilk_significance (sw->n, w))); + } } free (indexes); @@ -831,8 +831,8 @@ extremes_report (const struct examine *cmd, int iact_idx) pivot_category_create_leaf (order->root, pivot_value_new_integer (i + 1)); pivot_dimension_create (table, PIVOT_AXIS_ROW, - /* TRANSLATORS: This is a noun, not an adjective. */ - N_("Extreme"), + /* TRANSLATORS: This is a noun, not an adjective. */ + N_("Extreme"), N_("Highest"), N_("Lowest")); const struct interaction *iact = cmd->iacts[iact_idx]; @@ -1035,16 +1035,16 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data, if (!examine->missing_pw) { for (v = 0; v < examine->n_dep_vars; v++) - { - const struct variable *var = examine->dep_vars[v]; + { + const struct variable *var = examine->dep_vars[v]; - if (var_is_value_missing (var, case_data (c, var)) + if (var_is_value_missing (var, case_data (c, var)) & examine->dep_excl) - { - es[v].missing += weight; - this_case_is_missing = true; - } - } + { + es[v].missing += weight; + this_case_is_missing = true; + } + } } if (this_case_is_missing) @@ -1135,7 +1135,7 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) { const double val = case_num_idx (c, EX_VAL); double wt = case_num_idx (c, EX_WT); - wt = var_force_valid_weight (examine->wv, wt, &warn); + wt = var_force_valid_weight (examine->wv, wt, &warn); moments_pass_two (es[v].mom, val, wt); @@ -1177,41 +1177,41 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) if (examine->calc_extremes > 0 && es[v].non_missing > 0) { assert (es[v].minima[0].val == es[v].minimum); - assert (es[v].maxima[0].val == es[v].maximum); + assert (es[v].maxima[0].val == es[v].maximum); } { - const int n_os = 5 + examine->n_percentiles; - es[v].percentiles = pool_calloc (examine->pool, examine->n_percentiles, sizeof (*es[v].percentiles)); + const int n_os = 5 + examine->n_percentiles; + es[v].percentiles = pool_calloc (examine->pool, examine->n_percentiles, sizeof (*es[v].percentiles)); - es[v].trimmed_mean = trimmed_mean_create (es[v].cc, 0.05); - es[v].shapiro_wilk = NULL; + es[v].trimmed_mean = trimmed_mean_create (es[v].cc, 0.05); + es[v].shapiro_wilk = NULL; - struct order_stats **os = XCALLOC (n_os, struct order_stats *); - os[0] = &es[v].trimmed_mean->parent; + struct order_stats **os = XCALLOC (n_os, struct order_stats *); + os[0] = &es[v].trimmed_mean->parent; - es[v].quartiles[0] = percentile_create (0.25, es[v].cc); - es[v].quartiles[1] = percentile_create (0.5, es[v].cc); - es[v].quartiles[2] = percentile_create (0.75, es[v].cc); + es[v].quartiles[0] = percentile_create (0.25, es[v].cc); + es[v].quartiles[1] = percentile_create (0.5, es[v].cc); + es[v].quartiles[2] = percentile_create (0.75, es[v].cc); - os[1] = &es[v].quartiles[0]->parent; - os[2] = &es[v].quartiles[1]->parent; - os[3] = &es[v].quartiles[2]->parent; + os[1] = &es[v].quartiles[0]->parent; + os[2] = &es[v].quartiles[1]->parent; + os[3] = &es[v].quartiles[2]->parent; - es[v].hinges = tukey_hinges_create (es[v].cc, es[v].cmin); - os[4] = &es[v].hinges->parent; + es[v].hinges = tukey_hinges_create (es[v].cc, es[v].cmin); + os[4] = &es[v].hinges->parent; - for (i = 0; i < examine->n_percentiles; ++i) - { - es[v].percentiles[i] = percentile_create (examine->ptiles[i] / 100.00, es[v].cc); - os[5 + i] = &es[v].percentiles[i]->parent; - } + for (i = 0; i < examine->n_percentiles; ++i) + { + es[v].percentiles[i] = percentile_create (examine->ptiles[i] / 100.00, es[v].cc); + os[5 + i] = &es[v].percentiles[i]->parent; + } - order_stats_accumulate_idx (os, n_os, - casereader_clone (es[v].sorted_reader), - EX_WT, EX_VAL); + order_stats_accumulate_idx (os, n_os, + casereader_clone (es[v].sorted_reader), + EX_WT, EX_VAL); - free (os); + free (os); } if (examine->plot_boxplot) @@ -1222,27 +1222,27 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) EX_ID, examine->id_var); os = &es[v].box_whisker->parent; - order_stats_accumulate_idx (&os, 1, - casereader_clone (es[v].sorted_reader), - EX_WT, EX_VAL); + order_stats_accumulate_idx (&os, 1, + casereader_clone (es[v].sorted_reader), + EX_WT, EX_VAL); } if (examine->plot_boxplot || examine->plot_histogram || examine->plot_npplot || examine->plot_spreadlevel) { - double mean; + double mean; - moments_calculate (es[v].mom, NULL, &mean, NULL, NULL, NULL); + moments_calculate (es[v].mom, NULL, &mean, NULL, NULL, NULL); es[v].shapiro_wilk = shapiro_wilk_create (es[v].non_missing, mean); - if (es[v].shapiro_wilk) - { - struct order_stats *os = &es[v].shapiro_wilk->parent; - order_stats_accumulate_idx (&os, 1, - casereader_clone (es[v].sorted_reader), - EX_WT, EX_VAL); - } + if (es[v].shapiro_wilk) + { + struct order_stats *os = &es[v].shapiro_wilk->parent; + order_stats_accumulate_idx (&os, 1, + casereader_clone (es[v].sorted_reader), + EX_WT, EX_VAL); + } } if (examine->plot_npplot) @@ -1257,8 +1257,8 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data) os = &es[v].np->parent; order_stats_accumulate_idx (&os, 1, - casereader_clone (es[v].sorted_reader), - EX_WT, EX_VAL); + casereader_clone (es[v].sorted_reader), + EX_WT, EX_VAL); } } @@ -1274,31 +1274,31 @@ cleanup_exploratory_stats (struct examine *cmd) const size_t n_cats = categoricals_n_count (cmd->cats, i); for (v = 0; v < cmd->n_dep_vars; ++v) - { - int grp; - for (grp = 0; grp < n_cats; ++grp) - { - int q; - const struct exploratory_stats *es = - categoricals_get_user_data_by_category_real (cmd->cats, i, grp); - - struct order_stats *os = &es[v].hinges->parent; - struct statistic *stat = &os->parent; - stat->destroy (stat); - - for (q = 0; q < 3; q++) - { - os = &es[v].quartiles[q]->parent; - stat = &os->parent; - stat->destroy (stat); - } - - for (q = 0; q < cmd->n_percentiles; q++) - { - os = &es[v].percentiles[q]->parent; - stat = &os->parent; - stat->destroy (stat); - } + { + int grp; + for (grp = 0; grp < n_cats; ++grp) + { + int q; + const struct exploratory_stats *es = + categoricals_get_user_data_by_category_real (cmd->cats, i, grp); + + struct order_stats *os = &es[v].hinges->parent; + struct statistic *stat = &os->parent; + stat->destroy (stat); + + for (q = 0; q < 3; q++) + { + os = &es[v].quartiles[q]->parent; + stat = &os->parent; + stat->destroy (stat); + } + + for (q = 0; q < cmd->n_percentiles; q++) + { + os = &es[v].percentiles[q]->parent; + stat = &os->parent; + stat->destroy (stat); + } if (es[v].shapiro_wilk) { @@ -1306,19 +1306,19 @@ cleanup_exploratory_stats (struct examine *cmd) stat->destroy (stat); } - os = &es[v].trimmed_mean->parent; - stat = &os->parent; - stat->destroy (stat); + os = &es[v].trimmed_mean->parent; + stat = &os->parent; + stat->destroy (stat); - os = &es[v].np->parent; - if (os) - { - stat = &os->parent; - stat->destroy (stat); - } + os = &es[v].np->parent; + if (os) + { + stat = &os->parent; + stat->destroy (stat); + } - statistic_destroy (&es[v].histogram->parent); - moments_destroy (es[v].mom); + statistic_destroy (&es[v].histogram->parent); + moments_destroy (es[v].mom); if (es[v].box_whisker) { @@ -1326,9 +1326,9 @@ cleanup_exploratory_stats (struct examine *cmd) stat->destroy (stat); } - casereader_destroy (es[v].sorted_reader); - } - } + casereader_destroy (es[v].sorted_reader); + } + } } } @@ -1377,7 +1377,7 @@ run_examine (struct examine *cmd, struct casereader *input) const size_t n_cats = categoricals_n_count (cmd->cats, i); if (n_cats == 0) - continue; + continue; if (cmd->disp_extremes > 0) extremes_report (cmd, i); @@ -1415,7 +1415,7 @@ run_examine (struct examine *cmd, struct casereader *input) if (cmd->plot_histogram || cmd->plot_npplot || cmd->plot_spreadlevel || cmd->plot_boxplot) - normality_report (cmd, i); + normality_report (cmd, i); } cleanup_exploratory_stats (cmd); @@ -1469,8 +1469,8 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) goto error; if (!parse_variables_const (lexer, examine.dict, - &examine.dep_vars, &examine.n_dep_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + &examine.dep_vars, &examine.n_dep_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) goto error; if (lex_match (lexer, T_BY)) @@ -1491,12 +1491,12 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "STATISTICS")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "DESCRIPTIVES")) examine.descriptives = true; else if (lex_match_id (lexer, "EXTREME")) @@ -1555,11 +1555,11 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "HAVERAGE")) examine.pc_alg = PC_HAVERAGE; else if (lex_match_id (lexer, "WAVERAGE")) @@ -1590,11 +1590,11 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "MISSING")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "LISTWISE")) examine.missing_pw = false; else if (lex_match_id (lexer, "PAIRWISE")) @@ -1618,7 +1618,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "COMPARE")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (lex_match_id (lexer, "VARIABLES")) examine.boxplot_mode = BP_VARIABLES; else if (lex_match_id (lexer, "GROUPS")) @@ -1631,11 +1631,11 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "PLOT")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "BOXPLOT")) examine.plot_boxplot = true; else if (lex_match_id (lexer, "NPPLOT")) @@ -1645,15 +1645,15 @@ cmd_examine (struct lexer *lexer, struct dataset *ds) else if (lex_match_id (lexer, "SPREADLEVEL")) { examine.plot_spreadlevel = true; - examine.sl_power = 0; - if (lex_match (lexer, T_LPAREN) && lex_force_num (lexer)) - { + examine.sl_power = 0; + if (lex_match (lexer, T_LPAREN) && lex_force_num (lexer)) + { examine.sl_power = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } + } } else if (lex_match_id (lexer, "NONE")) examine.plot_boxplot = examine.plot_npplot diff --git a/src/language/commands/factor.c b/src/language/commands/factor.c index 3540b6899e..bfed29c429 100644 --- a/src/language/commands/factor.c +++ b/src/language/commands/factor.c @@ -105,14 +105,14 @@ enum rotation_type }; typedef void (*rotation_coefficients) (double *x, double *y, - double a, double b, double c, double d, - const gsl_matrix *loadings); + double a, double b, double c, double d, + const gsl_matrix *loadings); static void varimax_coefficients (double *x, double *y, - double a, double b, double c, double d, - const gsl_matrix *loadings) + double a, double b, double c, double d, + const gsl_matrix *loadings) { *x = d - 2 * a * b / loadings->size1; *y = c - (a * a - b * b) / loadings->size1; @@ -120,8 +120,8 @@ varimax_coefficients (double *x, double *y, static void equamax_coefficients (double *x, double *y, - double a, double b, double c, double d, - const gsl_matrix *loadings) + double a, double b, double c, double d, + const gsl_matrix *loadings) { *x = d - loadings->size2 * a * b / loadings->size1; *y = c - loadings->size2 * (a * a - b * b) / (2 * loadings->size1); @@ -129,8 +129,8 @@ equamax_coefficients (double *x, double *y, static void quartimax_coefficients (double *x, double *y, - double a UNUSED, double b UNUSED, double c, double d, - const gsl_matrix *loadings UNUSED) + double a UNUSED, double b UNUSED, double c, double d, + const gsl_matrix *loadings UNUSED) { *x = d; *y = c; @@ -154,8 +154,8 @@ diag_rcp_sqrt (const gsl_matrix *C) assert (C->size1 == C->size2); gsl_linalg_matmult_mod (C, GSL_LINALG_MOD_TRANSPOSE, - C, GSL_LINALG_MOD_NONE, - d); + C, GSL_LINALG_MOD_NONE, + d); for (int j = 0; j < d->size2; ++j) { @@ -351,7 +351,7 @@ dump_matrix (const gsl_matrix *m) for (int i = 0; i < m->size1; ++i) { for (int j = 0; j < m->size2; ++j) - printf ("%02f ", gsl_matrix_get (m, i, j)); + printf ("%02f ", gsl_matrix_get (m, i, j)); printf ("\n"); } } @@ -362,7 +362,7 @@ dump_matrix_permute (const gsl_matrix *m, const gsl_permutation *p) for (int i = 0; i < m->size1; ++i) { for (int j = 0; j < m->size2; ++j) - printf ("%02f ", gsl_matrix_get (m, gsl_permutation_get (p, i), j)); + printf ("%02f ", gsl_matrix_get (m, gsl_permutation_get (p, i), j)); printf ("\n"); } } @@ -401,7 +401,7 @@ n_extracted_factors (const struct cmd_factor *factor, struct idata *idata) idata->n_extractions = i; if (evali < factor->min_eigen) - goto finish; + goto finish; } finish: @@ -546,7 +546,7 @@ factor_matrix_workspace_free (struct factor_matrix_workspace *ws) */ static void perm_shift_apply (gsl_permutation *target, const gsl_permutation *p, - size_t offset) + size_t offset) { assert (target->size == p->size); assert (offset <= target->size); @@ -590,18 +590,18 @@ sort_matrix_indirect (const gsl_matrix *input, gsl_permutation *perm) int i; for (i = 0; i < n; ++i) - { - gsl_vector_view row = gsl_matrix_row (mat, p->data[n - 1 - i]); - size_t maxindex = gsl_vector_max_index (&row.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; + if (maxindex > column_n) + break; - /* All subsequent elements of this row, are of no interest. - So set them all to a highly negative value */ - for (int j = column_n + 1; j < row.vector.size; ++j) - gsl_vector_set (&row.vector, j, -DBL_MAX); - } + /* All subsequent elements of this row, are of no interest. + So set them all to a highly negative value */ + for (int j = column_n + 1; j < row.vector.size; ++j) + gsl_vector_set (&row.vector, j, -DBL_MAX); + } perm_shift_apply (perm, p, row_n); row_n += i; @@ -653,14 +653,14 @@ initial_sv (const gsl_matrix *fm) double l2s = 0; for (int k = j + 1; k < fm->size2; ++k) - { - double lambda = gsl_matrix_get (fm, k, j); - double lambda_sq = lambda * lambda; - double lambda_4 = lambda_sq * lambda_sq; - - l4s += lambda_4; - l2s += lambda_sq; - } + { + double lambda = gsl_matrix_get (fm, k, j); + double lambda_sq = lambda * lambda; + double lambda_4 = lambda_sq * lambda_sq; + + l4s += lambda_4; + l2s += lambda_sq; + } sv += (fm->size1 * l4s - (l2s * l2s)) / (fm->size1 * fm->size1); } return sv; @@ -668,11 +668,11 @@ initial_sv (const gsl_matrix *fm) static void rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, - const gsl_vector *communalities, - gsl_matrix *result, - gsl_vector *rotated_loadings, - gsl_matrix *pattern_matrix, - gsl_matrix *factor_correlation_matrix) + const gsl_vector *communalities, + gsl_matrix *result, + gsl_vector *rotated_loadings, + gsl_matrix *pattern_matrix, + gsl_matrix *factor_correlation_matrix) { /* First get a normalised version of UNROT */ gsl_matrix *normalised = gsl_matrix_calloc (unrot->size1, unrot->size2); @@ -705,64 +705,64 @@ rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, { double sv = 0.0; for (int j = 0; j < normalised->size2; ++j) - { - /* These variables relate to the convergence criterium */ - double l4s = 0; - double l2s = 0; - - for (int k = j + 1; k < normalised->size2; ++k) - { - double a = 0.0; - double b = 0.0; - double c = 0.0; - double d = 0.0; - for (int p = 0; p < normalised->size1; ++p) - { - 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; - b += v; - c += u * u - v * v; - d += 2 * u * v; - } - - double x, y; - rotation_coeff [cf->rotation] (&x, &y, a, b, c, d, normalised); - double phi = atan2 (x, y) / 4.0; - - /* Don't bother rotating if the angle is small */ - if (fabs (sin (phi)) <= pow (10.0, -15.0)) - continue; - - for (int p = 0; p < normalised->size1; ++p) - { - double *lambda0 = gsl_matrix_ptr (normalised, p, j); - double *lambda1 = gsl_matrix_ptr (normalised, p, k); - drot_go (phi, lambda0, lambda1); - } - - /* Calculate the convergence criterium */ + { + /* These variables relate to the convergence criterium */ + double l4s = 0; + double l2s = 0; + + for (int k = j + 1; k < normalised->size2; ++k) + { + double a = 0.0; + double b = 0.0; + double c = 0.0; + double d = 0.0; + for (int p = 0; p < normalised->size1; ++p) + { + 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; + b += v; + c += u * u - v * v; + d += 2 * u * v; + } + + double x, y; + rotation_coeff [cf->rotation] (&x, &y, a, b, c, d, normalised); + double phi = atan2 (x, y) / 4.0; + + /* Don't bother rotating if the angle is small */ + if (fabs (sin (phi)) <= pow (10.0, -15.0)) + continue; + + for (int p = 0; p < normalised->size1; ++p) + { + double *lambda0 = gsl_matrix_ptr (normalised, p, j); + double *lambda1 = gsl_matrix_ptr (normalised, p, k); + drot_go (phi, lambda0, lambda1); + } + + /* Calculate the convergence criterium */ double lambda = gsl_matrix_get (normalised, k, j); double lambda_sq = lambda * lambda; double lambda_4 = lambda_sq * lambda_sq; l4s += lambda_4; l2s += lambda_sq; - } - sv += (normalised->size1 * l4s - (l2s * l2s)) / (normalised->size1 * normalised->size1); - } + } + sv += (normalised->size1 * l4s - (l2s * l2s)) / (normalised->size1 * normalised->size1); + } if (fabs (sv - prev_sv) <= cf->rconverge) - break; + break; prev_sv = sv; } gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1.0, - h_sqrt, normalised, 0.0, result); + h_sqrt, normalised, 0.0, result); gsl_matrix_free (h_sqrt); gsl_matrix_free (normalised); @@ -782,64 +782,64 @@ rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, /* The following variables follow the notation by SPSS Statistical - Algorithms page 342. */ + Algorithms page 342. */ gsl_matrix *L = gsl_matrix_calloc (unrot->size2, unrot->size2); gsl_matrix *P = clone_matrix (result); /* Vector of length p containing (indexed by i) - \Sum^m_j {\lambda^2_{ij}} */ + \Sum^m_j {\lambda^2_{ij}} */ gsl_vector *rssq = gsl_vector_calloc (unrot->size1); for (int i = 0; i < P->size1; ++i) - { - double sum = 0; - for (int j = 0; j < P->size2; ++j) + { + double sum = 0; + for (int j = 0; j < P->size2; ++j) sum += gsl_matrix_get (result, i, j) * gsl_matrix_get (result, i, j); - gsl_vector_set (rssq, i, sqrt (sum)); - } + gsl_vector_set (rssq, i, sqrt (sum)); + } for (int i = 0; i < P->size1; ++i) - { - for (int j = 0; j < P->size2; ++j) - { - double l = gsl_matrix_get (result, i, j); - double r = gsl_vector_get (rssq, i); - gsl_matrix_set (P, i, j, pow (fabs (l / r), cf->promax_power + 1) * r / l); - } - } + { + for (int j = 0; j < P->size2; ++j) + { + double l = gsl_matrix_get (result, i, j); + double r = gsl_vector_get (rssq, i); + gsl_matrix_set (P, i, j, pow (fabs (l / r), cf->promax_power + 1) * r / l); + } + } gsl_vector_free (rssq); gsl_linalg_matmult_mod (result, - GSL_LINALG_MOD_TRANSPOSE, - result, - GSL_LINALG_MOD_NONE, - mm1); + GSL_LINALG_MOD_TRANSPOSE, + result, + GSL_LINALG_MOD_NONE, + mm1); int signum; gsl_linalg_LU_decomp (mm1, perm, &signum); gsl_linalg_LU_invert (mm1, perm, mm2); gsl_linalg_matmult_mod (mm2, GSL_LINALG_MOD_NONE, - result, GSL_LINALG_MOD_TRANSPOSE, - mp1); + result, GSL_LINALG_MOD_TRANSPOSE, + mp1); gsl_linalg_matmult_mod (mp1, GSL_LINALG_MOD_NONE, - P, GSL_LINALG_MOD_NONE, - L); + P, GSL_LINALG_MOD_NONE, + L); gsl_matrix *D = diag_rcp_sqrt (L); gsl_matrix *Q = gsl_matrix_calloc (unrot->size2, unrot->size2); gsl_linalg_matmult_mod (L, GSL_LINALG_MOD_NONE, - D, GSL_LINALG_MOD_NONE, - Q); + D, GSL_LINALG_MOD_NONE, + Q); gsl_matrix *QQinv = gsl_matrix_calloc (unrot->size2, unrot->size2); gsl_linalg_matmult_mod (Q, GSL_LINALG_MOD_TRANSPOSE, - Q, GSL_LINALG_MOD_NONE, - QQinv); + Q, GSL_LINALG_MOD_NONE, + QQinv); gsl_linalg_cholesky_decomp (QQinv); gsl_linalg_cholesky_invert (QQinv); @@ -853,25 +853,25 @@ rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, gsl_linalg_matmult_mod (result, GSL_LINALG_MOD_NONE, - Q, GSL_LINALG_MOD_NONE, - pm1); + Q, GSL_LINALG_MOD_NONE, + pm1); gsl_linalg_matmult_mod (pm1, GSL_LINALG_MOD_NONE, - Cinv, GSL_LINALG_MOD_NONE, - pattern_matrix); + Cinv, GSL_LINALG_MOD_NONE, + pattern_matrix); gsl_linalg_matmult_mod (C, GSL_LINALG_MOD_NONE, - QQinv, GSL_LINALG_MOD_NONE, - mm1); + QQinv, GSL_LINALG_MOD_NONE, + mm1); gsl_linalg_matmult_mod (mm1, GSL_LINALG_MOD_NONE, - C, GSL_LINALG_MOD_TRANSPOSE, - factor_correlation_matrix); + 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); + factor_correlation_matrix, GSL_LINALG_MOD_NONE, + pm1); gsl_matrix_memcpy (result, pm1); @@ -900,20 +900,20 @@ rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, double ssq = 0.0; double sum = 0.0; for (int j = 0; j < result->size1; ++j) - { - double s = gsl_matrix_get (result, j, i); - ssq += s * s; - sum += s; - } + { + double s = gsl_matrix_get (result, j, i); + ssq += s * s; + sum += s; + } gsl_vector_set (rotated_loadings, i, ssq); if (sum < 0) - for (int j = 0; j < result->size1; ++j) - { - double *lambda = gsl_matrix_ptr (result, j, i); - *lambda = - *lambda; - } + for (int j = 0; j < result->size1; ++j) + { + double *lambda = gsl_matrix_ptr (result, j, i); + *lambda = - *lambda; + } } } @@ -924,7 +924,7 @@ rotate (const struct cmd_factor *cf, const gsl_matrix *unrot, */ static void iterate_factor_matrix (const gsl_matrix *r, gsl_vector *communalities, gsl_matrix *factors, - struct factor_matrix_workspace *ws) + struct factor_matrix_workspace *ws) { assert (r->size1 == r->size2); assert (r->size1 == communalities->size); @@ -1015,40 +1015,40 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) vars_start = lex_ofs (lexer); if (!parse_variables_const (lexer, dict, &factor.vars, &factor.n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) - goto error; + PV_NO_DUPLICATE | PV_NUMERIC)) + goto error; vars_end = lex_ofs (lexer) - 1; } else if (lex_match_id (lexer, "MATRIX")) { lex_match (lexer, T_EQUALS); if (!lex_force_match_phrase (lexer, "IN(")) - goto error; + goto error; if (!lex_match_id (lexer, "CORR") && !lex_match_id (lexer, "COV")) - { - lex_error (lexer, _("Matrix input for %s must be either COV or CORR"), + { + lex_error (lexer, _("Matrix input for %s must be either COV or CORR"), "FACTOR"); - goto error; - } + goto error; + } if (!lex_force_match (lexer, T_EQUALS)) - goto error; + goto error; vars_start = lex_ofs (lexer); if (lex_match (lexer, T_ASTERISK)) - { - dict = dataset_dict (ds); - matrix_reader = casereader_clone (dataset_source (ds)); - } + { + dict = dataset_dict (ds); + matrix_reader = casereader_clone (dataset_source (ds)); + } else - { - struct file_handle *fh = fh_parse (lexer, FH_REF_FILE, NULL); - if (fh == NULL) - goto error; + { + struct file_handle *fh = fh_parse (lexer, FH_REF_FILE, NULL); + if (fh == NULL) + goto error; - matrix_reader = any_reader_open_and_decode (fh, NULL, &dict, NULL); + matrix_reader = any_reader_open_and_decode (fh, NULL, &dict, NULL); - if (!(matrix_reader && dict)) + if (!(matrix_reader && dict)) goto error; - } + } vars_end = lex_ofs (lexer) - 1; if (!lex_force_match (lexer, T_RPAREN)) @@ -1098,119 +1098,119 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) } } else if (lex_match_id (lexer, "PLOT")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "EIGEN")) - { - factor.plot |= PLOT_SCREE; - } + { + if (lex_match_id (lexer, "EIGEN")) + { + factor.plot |= PLOT_SCREE; + } #if FACTOR_FULLY_IMPLEMENTED - else if (lex_match_id (lexer, "ROTATION")) - { - } + else if (lex_match_id (lexer, "ROTATION")) + { + } #endif - else - { - lex_error_expecting (lexer, "EIGEN" + else + { + lex_error_expecting (lexer, "EIGEN" #if FACTOR_FULLY_IMPLEMENTED , "ROTATION" #endif ); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "METHOD")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "COVARIANCE")) + { + if (lex_match_id (lexer, "COVARIANCE")) factor.method = METHOD_COV; - else if (lex_match_id (lexer, "CORRELATION")) + else if (lex_match_id (lexer, "CORRELATION")) factor.method = METHOD_CORR; - else - { - lex_error_expecting (lexer, "COVARIANCE", "CORRELATION"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "COVARIANCE", "CORRELATION"); + goto error; + } + } + } else if (lex_match_id (lexer, "ROTATION")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - /* VARIMAX and DEFAULT are defaults */ - if (lex_match_id (lexer, "VARIMAX") || lex_match_id (lexer, "DEFAULT")) + { + /* VARIMAX and DEFAULT are defaults */ + if (lex_match_id (lexer, "VARIMAX") || lex_match_id (lexer, "DEFAULT")) factor.rotation = ROT_VARIMAX; - else if (lex_match_id (lexer, "EQUAMAX")) + else if (lex_match_id (lexer, "EQUAMAX")) factor.rotation = ROT_EQUAMAX; - else if (lex_match_id (lexer, "QUARTIMAX")) + else if (lex_match_id (lexer, "QUARTIMAX")) factor.rotation = ROT_QUARTIMAX; - else if (lex_match_id (lexer, "PROMAX")) - { - factor.promax_power = 5; - if (lex_match (lexer, T_LPAREN)) + else if (lex_match_id (lexer, "PROMAX")) + { + factor.promax_power = 5; + if (lex_match (lexer, T_LPAREN)) { if (!lex_force_int (lexer)) goto error; - factor.promax_power = lex_integer (lexer); - lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - factor.rotation = ROT_PROMAX; - } - else if (lex_match_id (lexer, "NOROTATE")) + factor.promax_power = lex_integer (lexer); + lex_get (lexer); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + factor.rotation = ROT_PROMAX; + } + else if (lex_match_id (lexer, "NOROTATE")) factor.rotation = ROT_NONE; - else - { - lex_error_expecting (lexer, "DEFAULT", "VARIMAX", "EQUAMAX", + else + { + lex_error_expecting (lexer, "DEFAULT", "VARIMAX", "EQUAMAX", "QUARTIMAX", "PROMAX", "NOROTATE"); - goto error; - } - } + goto error; + } + } factor.rotation_iterations = n_iterations; - } + } else if (lex_match_id (lexer, "CRITERIA")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "FACTORS")) - { - if (!lex_force_match (lexer, T_LPAREN) + { + if (lex_match_id (lexer, "FACTORS")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_int (lexer)) goto error; factor.n_factors = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "MINEIGEN")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "MINEIGEN")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; factor.min_eigen = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "ECONVERGE")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "ECONVERGE")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; factor.econverge = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "RCONVERGE")) + } + else if (lex_match_id (lexer, "RCONVERGE")) { if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) @@ -1219,169 +1219,169 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "ITERATE")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "ITERATE")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_int_range (lexer, "ITERATE", 0, INT_MAX)) goto error; n_iterations = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "DEFAULT")) - { - factor.n_factors = 0; - factor.min_eigen = 1; - n_iterations = 25; - } - else - { - lex_error_expecting (lexer, "FACTORS", "MINEIGEN", + } + else if (lex_match_id (lexer, "DEFAULT")) + { + factor.n_factors = 0; + factor.min_eigen = 1; + n_iterations = 25; + } + else + { + lex_error_expecting (lexer, "FACTORS", "MINEIGEN", "ECONVERGE", "RCONVERGE", "ITERATE", "DEFAULT"); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "EXTRACTION")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "PAF")) + { + if (lex_match_id (lexer, "PAF")) factor.extraction = EXTRACTION_PAF; - else if (lex_match_id (lexer, "PC")) + else if (lex_match_id (lexer, "PC")) factor.extraction = EXTRACTION_PC; - else if (lex_match_id (lexer, "PA1")) + else if (lex_match_id (lexer, "PA1")) factor.extraction = EXTRACTION_PC; - else if (lex_match_id (lexer, "DEFAULT")) + else if (lex_match_id (lexer, "DEFAULT")) factor.extraction = EXTRACTION_PC; - else - { - lex_error_expecting (lexer, "PAF", "PC", "PA1", "DEFAULT"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "PAF", "PC", "PA1", "DEFAULT"); + goto error; + } + } factor.extraction_iterations = n_iterations; - } + } else if (lex_match_id (lexer, "FORMAT")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "SORT")) + { + if (lex_match_id (lexer, "SORT")) factor.sort = true; - else if (lex_match_id (lexer, "BLANK")) - { - if (!lex_force_match (lexer, T_LPAREN) + else if (lex_match_id (lexer, "BLANK")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; factor.blank = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "DEFAULT")) - { - factor.blank = 0; - factor.sort = false; - } - else - { - lex_error_expecting (lexer, "SORT", "BLANK", "DEFAULT"); - goto error; - } - } - } + } + else if (lex_match_id (lexer, "DEFAULT")) + { + factor.blank = 0; + factor.sort = false; + } + else + { + lex_error_expecting (lexer, "SORT", "BLANK", "DEFAULT"); + goto error; + } + } + } else if (lex_match_id (lexer, "PRINT")) - { - factor.print = 0; + { + factor.print = 0; lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) { if (lex_match_id (lexer, "UNIVARIATE")) factor.print |= PRINT_UNIVARIATE; - else if (lex_match_id (lexer, "DET")) + else if (lex_match_id (lexer, "DET")) factor.print |= PRINT_DETERMINANT; #if FACTOR_FULLY_IMPLEMENTED - else if (lex_match_id (lexer, "INV")) - { - } + else if (lex_match_id (lexer, "INV")) + { + } #endif - else if (lex_match_id (lexer, "AIC")) + else if (lex_match_id (lexer, "AIC")) factor.print |= PRINT_AIC; - else if (lex_match_id (lexer, "SIG")) + else if (lex_match_id (lexer, "SIG")) factor.print |= PRINT_SIG; - else if (lex_match_id (lexer, "CORRELATION")) + else if (lex_match_id (lexer, "CORRELATION")) factor.print |= PRINT_CORRELATION; - else if (lex_match_id (lexer, "COVARIANCE")) + else if (lex_match_id (lexer, "COVARIANCE")) factor.print |= PRINT_COVARIANCE; - else if (lex_match_id (lexer, "ROTATION")) + else if (lex_match_id (lexer, "ROTATION")) factor.print |= PRINT_ROTATION; - else if (lex_match_id (lexer, "EXTRACTION")) + else if (lex_match_id (lexer, "EXTRACTION")) factor.print |= PRINT_EXTRACTION; - else if (lex_match_id (lexer, "INITIAL")) + else if (lex_match_id (lexer, "INITIAL")) factor.print |= PRINT_INITIAL; - else if (lex_match_id (lexer, "KMO")) + else if (lex_match_id (lexer, "KMO")) factor.print |= PRINT_KMO; #if FACTOR_FULLY_IMPLEMENTED - else if (lex_match_id (lexer, "REPR")) - { - } - else if (lex_match_id (lexer, "FSCORE")) - { - } + else if (lex_match_id (lexer, "REPR")) + { + } + else if (lex_match_id (lexer, "FSCORE")) + { + } #endif else if (lex_match (lexer, T_ALL)) factor.print = -1; - else if (lex_match_id (lexer, "DEFAULT")) - { - factor.print |= PRINT_INITIAL; - factor.print |= PRINT_EXTRACTION; - factor.print |= PRINT_ROTATION; - } - else - { - lex_error_expecting (lexer, "UNIVARIATE", "DET", "AIC", "SIG", + else if (lex_match_id (lexer, "DEFAULT")) + { + factor.print |= PRINT_INITIAL; + factor.print |= PRINT_EXTRACTION; + factor.print |= PRINT_ROTATION; + } + else + { + lex_error_expecting (lexer, "UNIVARIATE", "DET", "AIC", "SIG", "CORRELATION", "COVARIANCE", "ROTATION", "EXTRACTION", "INITIAL", "KMO", "ALL", "DEFAULT"); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "MISSING")) { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) { - if (lex_match_id (lexer, "INCLUDE")) + if (lex_match_id (lexer, "INCLUDE")) factor.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) factor.exclude = MV_ANY; - else if (lex_match_id (lexer, "LISTWISE")) + else if (lex_match_id (lexer, "LISTWISE")) factor.missing_type = MISS_LISTWISE; - else if (lex_match_id (lexer, "PAIRWISE")) + else if (lex_match_id (lexer, "PAIRWISE")) factor.missing_type = MISS_PAIRWISE; - else if (lex_match_id (lexer, "MEANSUB")) + else if (lex_match_id (lexer, "MEANSUB")) factor.missing_type = MISS_MEANSUB; - else - { + else + { lex_error_expecting (lexer, "INCLUDE", "EXCLUDE", "LISTWISE", "PAIRRWISE", "MEANSUB"); - goto error; - } - } - } + goto error; + } + } + } else - { - lex_error_expecting (lexer, "ANALYSIS", "PLOT", "METHOD", "ROTATION", + { + lex_error_expecting (lexer, "ANALYSIS", "PLOT", "METHOD", "ROTATION", "CRITERIA", "EXTRACTION", "FORMAT", "PRINT", "MISSING"); - goto error; - } + goto error; + } } if (factor.rotation == ROT_NONE) @@ -1397,8 +1397,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) struct idata *id = idata_alloc (factor.n_vars); while (matrix_reader_next (&id->mm, mr, NULL)) - { - do_factor_by_matrix (&factor, id); + { + do_factor_by_matrix (&factor, id); gsl_matrix_free (id->ai_cov); id->ai_cov = NULL; @@ -1406,7 +1406,7 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) id->ai_cor = NULL; matrix_material_uninit (&id->mm); - } + } idata_free (id); } @@ -1439,9 +1439,9 @@ run_factor (struct dataset *ds, const struct cmd_factor *factor) while (casegrouper_get_next_group (grouper, &group)) { if (factor->missing_type == MISS_LISTWISE) - group = casereader_create_filter_missing (group, factor->vars, factor->n_vars, - factor->exclude, - NULL, NULL); + group = casereader_create_filter_missing (group, factor->vars, factor->n_vars, + factor->exclude, + NULL, NULL); do_factor (factor, group); } @@ -1501,7 +1501,7 @@ show_scree (const struct cmd_factor *f, const struct idata *idata) static void show_communalities (const struct cmd_factor * factor, - const gsl_vector *initial, const gsl_vector *extracted) + const gsl_vector *initial, const gsl_vector *extracted) { if (!(factor->print & (PRINT_INITIAL | PRINT_EXTRACTION))) return; @@ -1575,13 +1575,13 @@ show_factor_matrix (const struct cmd_factor *factor, const struct idata *idata, variables->root, pivot_value_new_variable (factor->vars[matrix_row])); for (size_t j = 0; j < n_factors; ++j) - { - double x = gsl_matrix_get (fm, matrix_row, j); - if (fabs (x) < factor->blank) - continue; + { + double x = gsl_matrix_get (fm, matrix_row, j); + if (fabs (x) < factor->blank) + continue; pivot_table_put2 (table, j, var_idx, pivot_value_new_number (x)); - } + } } gsl_permutation_free (perm); @@ -1601,10 +1601,10 @@ put_variance (struct pivot_table *table, int row, int phase_idx, static void show_explained_variance (const struct cmd_factor * factor, - const struct idata *idata, - const gsl_vector *initial_eigenvalues, - const gsl_vector *extracted_eigenvalues, - const gsl_vector *rotated_loadings) + const struct idata *idata, + const gsl_vector *initial_eigenvalues, + const gsl_vector *extracted_eigenvalues, + const gsl_vector *rotated_loadings) { if (!(factor->print & (PRINT_INITIAL | PRINT_EXTRACTION | PRINT_ROTATION))) return; @@ -1616,7 +1616,7 @@ show_explained_variance (const struct cmd_factor * factor, N_("Total"), PIVOT_RC_OTHER, /* xgettext:no-c-format */ N_("% of Variance"), PIVOT_RC_PERCENT, - /* xgettext:no-c-format */ + /* xgettext:no-c-format */ N_("Cumulative %"), PIVOT_RC_PERCENT); struct pivot_dimension *phase = pivot_dimension_create ( @@ -1839,7 +1839,7 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) struct idata *idata = idata_alloc (factor->n_vars); idata->cvm = covariance_1pass_create (factor->n_vars, factor->vars, - factor->wv, factor->exclude, true); + factor->wv, factor->exclude, true); for (; (c = casereader_read (r)); case_unref (c)) { @@ -1938,8 +1938,8 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) table, PIVOT_AXIS_ROW, N_("Variables")); for (size_t i = 0; i < factor->n_vars; ++i) - { - const struct variable *v = factor->vars[i]; + { + const struct variable *v = factor->vars[i]; int row = pivot_category_create_leaf ( variables->root, pivot_value_new_variable (v)); @@ -1952,7 +1952,7 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) for (size_t j = 0; j < sizeof entries / sizeof *entries; j++) pivot_table_put2 (table, j, row, pivot_value_new_number (entries[j])); - } + } pivot_table_submit (table); } @@ -1972,11 +1972,11 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) N_("Sig."), PIVOT_RC_SIGNIFICANCE); /* 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. */ + missing values are involved. The best thing I can think of + is to take the mean average. */ double w = 0; for (int i = 0; i < idata->mm.n->size1; ++i) - w += gsl_matrix_get (idata->mm.n, i, i); + w += gsl_matrix_get (idata->mm.n, i, i); w /= idata->mm.n->size1; double xsq = ((w - 1 - (2 * factor->n_vars + 5) / 6.0) @@ -2022,8 +2022,8 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) 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."), - "FACTOR"); + _("The %s criteria result in more factors than variables, which is not meaningful. No analysis will be performed."), + "FACTOR"); return; } @@ -2041,51 +2041,51 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) if (factor->extraction == EXTRACTION_PAF) { - gsl_vector *diff = gsl_vector_alloc (idata->msr->size); - struct smr_workspace *ws = ws_create (idata->analysis_matrix); + gsl_vector *diff = gsl_vector_alloc (idata->msr->size); + struct smr_workspace *ws = ws_create (idata->analysis_matrix); - for (size_t i = 0; i < factor->n_vars; ++i) - { - double r2 = squared_multiple_correlation (idata->analysis_matrix, i, ws); + for (size_t i = 0; i < factor->n_vars; ++i) + { + double r2 = squared_multiple_correlation (idata->analysis_matrix, i, ws); - gsl_vector_set (idata->msr, i, r2); - } - ws_destroy (ws); + gsl_vector_set (idata->msr, i, r2); + } + ws_destroy (ws); - gsl_vector_memcpy (initial_communalities, idata->msr); + gsl_vector_memcpy (initial_communalities, idata->msr); - for (size_t i = 0; i < factor->extraction_iterations; ++i) - { - double min, max; - gsl_vector_memcpy (diff, idata->msr); + for (size_t i = 0; i < factor->extraction_iterations; ++i) + { + double min, max; + gsl_vector_memcpy (diff, idata->msr); - iterate_factor_matrix (idata->analysis_matrix, idata->msr, factor_matrix, fmw); + iterate_factor_matrix (idata->analysis_matrix, idata->msr, factor_matrix, fmw); - gsl_vector_sub (diff, idata->msr); + gsl_vector_sub (diff, idata->msr); - gsl_vector_minmax (diff, &min, &max); + gsl_vector_minmax (diff, &min, &max); - if (fabs (min) < factor->econverge && fabs (max) < factor->econverge) - break; - } - gsl_vector_free (diff); + if (fabs (min) < factor->econverge && fabs (max) < factor->econverge) + break; + } + gsl_vector_free (diff); - gsl_vector_memcpy (extracted_communalities, idata->msr); - extracted_eigenvalues = fmw->eval; + gsl_vector_memcpy (extracted_communalities, idata->msr); + extracted_eigenvalues = fmw->eval; } else if (factor->extraction == EXTRACTION_PC) { - for (size_t i = 0; i < factor->n_vars; ++i) - gsl_vector_set (initial_communalities, i, communality (idata, i, factor->n_vars)); + for (size_t i = 0; i < factor->n_vars; ++i) + gsl_vector_set (initial_communalities, i, communality (idata, i, factor->n_vars)); - gsl_vector_memcpy (extracted_communalities, initial_communalities); + gsl_vector_memcpy (extracted_communalities, initial_communalities); - iterate_factor_matrix (idata->analysis_matrix, extracted_communalities, factor_matrix, fmw); + iterate_factor_matrix (idata->analysis_matrix, extracted_communalities, factor_matrix, fmw); - extracted_eigenvalues = idata->eval; + extracted_eigenvalues = idata->eval; } @@ -2094,16 +2094,16 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) if (factor->rotation != ROT_NONE) { - rotated_factors = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2); - rotated_loadings = gsl_vector_calloc (factor_matrix->size2); - if (factor->rotation == ROT_PROMAX) - { - pattern_matrix = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2); - fcm = gsl_matrix_calloc (factor_matrix->size2, factor_matrix->size2); - } + rotated_factors = gsl_matrix_calloc (factor_matrix->size1, factor_matrix->size2); + rotated_loadings = gsl_vector_calloc (factor_matrix->size2); + if (factor->rotation == ROT_PROMAX) + { + 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); + rotate (factor, factor_matrix, extracted_communalities, rotated_factors, rotated_loadings, pattern_matrix, fcm); } show_explained_variance (factor, idata, idata->eval, extracted_eigenvalues, rotated_loadings); @@ -2113,34 +2113,34 @@ do_factor_by_matrix (const struct cmd_factor *factor, struct idata *idata) show_scree (factor, idata); show_factor_matrix (factor, idata, - (factor->extraction == EXTRACTION_PC + (factor->extraction == EXTRACTION_PC ? N_("Component Matrix") : N_("Factor Matrix")), - factor_matrix); + factor_matrix); if (factor->rotation == ROT_PROMAX) { - show_factor_matrix (factor, idata, N_("Pattern Matrix"), + show_factor_matrix (factor, idata, N_("Pattern Matrix"), pattern_matrix); - gsl_matrix_free (pattern_matrix); + gsl_matrix_free (pattern_matrix); } if (factor->rotation != ROT_NONE) { - show_factor_matrix (factor, idata, - (factor->rotation == ROT_PROMAX + show_factor_matrix (factor, idata, + (factor->rotation == ROT_PROMAX ? N_("Structure Matrix") : factor->extraction == EXTRACTION_PC ? N_("Rotated Component Matrix") - : N_("Rotated Factor Matrix")), - rotated_factors); + : N_("Rotated Factor Matrix")), + rotated_factors); - gsl_matrix_free (rotated_factors); + gsl_matrix_free (rotated_factors); } if (factor->rotation == ROT_PROMAX) { - show_factor_correlation (factor, fcm); - gsl_matrix_free (fcm); + show_factor_correlation (factor, fcm); + gsl_matrix_free (fcm); } gsl_matrix_free (factor_matrix); diff --git a/src/language/commands/fail.c b/src/language/commands/fail.c index f90b19673e..bca199cbf5 100644 --- a/src/language/commands/fail.c +++ b/src/language/commands/fail.c @@ -29,7 +29,7 @@ static enum trns_result trns_fail (void *x UNUSED, struct ccase **c UNUSED, - casenumber n UNUSED) + casenumber n UNUSED) { msg (SE, "DEBUG XFORM FAIL transformation executed"); return TRNS_ERROR; diff --git a/src/language/commands/file-handle.c b/src/language/commands/file-handle.c index 3c2494ca38..29b8ab1b2d 100644 --- a/src/language/commands/file-handle.c +++ b/src/language/commands/file-handle.c @@ -367,7 +367,7 @@ fh_parse (struct lexer *lexer, enum fh_referent referent_mask, if (lex_token (lexer) == T_ID) handle = fh_from_id (lex_tokcstr (lexer)); if (handle == NULL) - handle = fh_create_file (NULL, lex_tokcstr (lexer), lex_get_encoding (lexer), + handle = fh_create_file (NULL, lex_tokcstr (lexer), lex_get_encoding (lexer), fh_default_properties ()); lex_get (lexer); } diff --git a/src/language/commands/flip.c b/src/language/commands/flip.c index cf11e2312c..f1ebd6c181 100644 --- a/src/language/commands/flip.c +++ b/src/language/commands/flip.c @@ -118,7 +118,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_EQUALS); if (!parse_variables_const (lexer, old_dict, &vars, &flip->n_vars, PV_NO_DUPLICATE)) - goto error; + goto error; lex_match (lexer, T_SLASH); } else @@ -139,12 +139,12 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) if (flip->new_names_var) { for (i = 0; i < flip->n_vars; i++) - if (vars[i] == flip->new_names_var) - { + if (vars[i] == flip->new_names_var) + { remove_element (vars, flip->n_vars, sizeof *vars, i); - flip->n_vars--; - break; - } + flip->n_vars--; + break; + } } if (flip->n_vars <= 0) goto error; @@ -324,11 +324,11 @@ flip_file (struct flip_pgm *flip) else input_buf = xmalloc (bytes); if (input_buf != NULL) - break; + break; case_capacity /= 2; if (case_capacity < 2) - case_capacity = 2; + case_capacity = 2; } pool_register (flip->pool, free, input_buf); @@ -367,13 +367,13 @@ flip_file (struct flip_pgm *flip) } for (i = 0; i < flip->n_vars; i++) - { - unsigned long j; + { + unsigned long j; - for (j = 0; j < read_cases; j++) - output_buf[j] = input_buf[i + j * flip->n_vars]; + for (j = 0; j < read_cases; j++) + output_buf[j] = input_buf[i + j * flip->n_vars]; - if (fseeko (output_file, + if (fseeko (output_file, sizeof *input_buf * (case_idx + (off_t) i * flip->n_cases), SEEK_SET) != 0) @@ -383,14 +383,14 @@ flip_file (struct flip_pgm *flip) return false; } - if (fwrite (output_buf, sizeof *output_buf, read_cases, output_file) - != read_cases) + if (fwrite (output_buf, sizeof *output_buf, read_cases, output_file) + != read_cases) { msg (SE, _("Error writing %s source file: %s."), "FLIP", strerror (errno)); return false; } - } + } case_idx += read_cases; } diff --git a/src/language/commands/formats.c b/src/language/commands/formats.c index e30c8c58fd..55a5a0d662 100644 --- a/src/language/commands/formats.c +++ b/src/language/commands/formats.c @@ -72,17 +72,17 @@ cmd_formats__ (struct lexer *lexer, struct dataset *ds, lex_match (lexer, T_SLASH); if (lex_token (lexer) == T_ENDCMD) - break; + break; if (!parse_variables (lexer, dataset_dict (ds), &v, &cv, PV_SAME_WIDTH)) - return CMD_FAILURE; + return CMD_FAILURE; width = var_get_width (v[0]); if (!lex_match (lexer, T_LPAREN)) - { + { lex_error_expecting (lexer, "`('"); - goto fail; - } + goto fail; + } if (!parse_format_specifier (lexer, &f)) goto fail; char *error = fmt_check_output__ (f); @@ -96,18 +96,18 @@ cmd_formats__ (struct lexer *lexer, struct dataset *ds, } if (!lex_match (lexer, T_RPAREN)) - { + { lex_error_expecting (lexer, "`)'"); - goto fail; - } + goto fail; + } for (i = 0; i < cv; i++) - { - if (print_format) + { + if (print_format) var_set_print_format (v[i], f); - if (write_format) + if (write_format) var_set_write_format (v[i], f); - } + } free (v); v = NULL; } diff --git a/src/language/commands/freq.c b/src/language/commands/freq.c index fd45e05f52..b4d06f9794 100644 --- a/src/language/commands/freq.c +++ b/src/language/commands/freq.c @@ -30,7 +30,7 @@ freq_clone (const struct freq *in, int values, int *widths) { int i; struct freq *f = xmalloc (sizeof (struct freq) + - (sizeof (union value) * (values - 1))); + (sizeof (union value) * (values - 1))); f->node = in->node; f->count = in->count; diff --git a/src/language/commands/freq.h b/src/language/commands/freq.h index fcb0e3f74a..f1b78d28da 100644 --- a/src/language/commands/freq.h +++ b/src/language/commands/freq.h @@ -24,7 +24,7 @@ struct freq { struct hmap_node node; /* Element in hash table. */ - double count; /* The number of occurrences of the value. */ + double count; /* The number of occurrences of the value. */ union value values[1]; /* The value. */ }; diff --git a/src/language/commands/frequencies.c b/src/language/commands/frequencies.c index db2d821a19..c3dd1a444c 100644 --- a/src/language/commands/frequencies.c +++ b/src/language/commands/frequencies.c @@ -138,15 +138,15 @@ struct freq_tab { struct hmap data; /* Hash table for accumulating counts. */ struct freq *valid; /* Valid freqs. */ - size_t n_valid; /* Number of total freqs. */ + size_t n_valid; /* Number of total freqs. */ const struct dictionary *dict; /* Source of entries in the table. */ struct freq *missing; /* Missing freqs. */ - size_t n_missing; /* Number of missing freqs. */ + size_t n_missing; /* Number of missing freqs. */ /* Statistics. */ - double total_cases; /* Sum of weights of all cases. */ - double valid_cases; /* Sum of weights of valid cases. */ + double total_cases; /* Sum of weights of all cases. */ + double valid_cases; /* Sum of weights of valid cases. */ }; struct frq_chart @@ -169,7 +169,7 @@ struct var_freqs const struct variable *var; /* Freqency table. */ - struct freq_tab tab; /* Frequencies table to use. */ + struct freq_tab tab; /* Frequencies table to use. */ /* Statistics. */ double stat[FRQ_ST_count]; @@ -217,12 +217,12 @@ static void calc_stats (const struct frq_proc *, const struct var_freqs *, double d[FRQ_ST_count]); 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 do_barchart(const struct frq_chart *bar, - const struct variable **var, - const struct freq_tab *frq_tab); + const struct variable **var, + const struct freq_tab *frq_tab); static struct frq_stats_table *frq_stats_table_submit ( struct frq_stats_table *, const struct frq_proc *, @@ -495,27 +495,27 @@ postcalc (struct frq_proc *frq, const struct dataset *ds, } if (frq->hist && var_is_numeric (vf->var) && vf->tab.n_valid > 0) - { - double d[FRQ_ST_count]; - struct histogram *histogram; + { + double d[FRQ_ST_count]; + struct histogram *histogram; - calc_stats (frq, vf, d); + calc_stats (frq, vf, d); - histogram = freq_tab_to_hist (frq, vf); + histogram = freq_tab_to_hist (frq, vf); - if (histogram) - { + if (histogram) + { output_splits_once (&need_splits, ds, example); - chart_submit (histogram_chart_create ( + chart_submit (histogram_chart_create ( histogram->gsl_hist, var_to_string(vf->var), vf->tab.valid_cases, d[FRQ_ST_MEAN], d[FRQ_ST_STDDEV], frq->hist->draw_normal)); - statistic_destroy (&histogram->parent); - } - } + statistic_destroy (&histogram->parent); + } + } if (frq->pie) { @@ -601,7 +601,7 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) goto done; if (!parse_variables_const (lexer, dataset_dict (ds), - &vars, &frq.n_vars, PV_NO_DUPLICATE)) + &vars, &frq.n_vars, PV_NO_DUPLICATE)) goto done; frq.vars = xcalloc (frq.n_vars, sizeof *frq.vars); @@ -616,14 +616,14 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "STATISTICS")) - { + { lex_match (lexer, T_EQUALS); - frq.stats = 0; + frq.stats = 0; int ofs = lex_ofs (lexer); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { for (int s = 0; s < FRQ_ST_count; s++) if (lex_match_id (lexer, st_keywords[s])) { @@ -655,28 +655,28 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "PERCENTILES")) { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (!lex_force_num_range_closed (lexer, "PERCENTILES", 0, 100)) goto done; add_percentile (&frq, lex_number (lexer) / 100.0, true, &allocated_percentiles); lex_get (lexer); lex_match (lexer, T_COMMA); - } - } + } + } else if (lex_match_id (lexer, "FORMAT")) { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "TABLE")) - { - } - else if (lex_match_id (lexer, "NOTABLE")) + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "TABLE")) + { + } + else if (lex_match_id (lexer, "NOTABLE")) frq.max_categories = 0; else if (lex_match_id (lexer, "LIMIT")) { @@ -690,49 +690,49 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) if (!lex_force_match (lexer, T_RPAREN)) goto done; } - else if (lex_match_id (lexer, "AVALUE")) + else if (lex_match_id (lexer, "AVALUE")) frq.sort = FRQ_AVALUE; - else if (lex_match_id (lexer, "DVALUE")) + else if (lex_match_id (lexer, "DVALUE")) frq.sort = FRQ_DVALUE; - else if (lex_match_id (lexer, "AFREQ")) + else if (lex_match_id (lexer, "AFREQ")) frq.sort = FRQ_AFREQ; - else if (lex_match_id (lexer, "DFREQ")) + else if (lex_match_id (lexer, "DFREQ")) frq.sort = FRQ_DFREQ; - else - { - lex_error_expecting (lexer, "TABLE", "NOTABLE", + else + { + lex_error_expecting (lexer, "TABLE", "NOTABLE", "LIMIT", "AVALUE", "DVALUE", "AFREQ", "DFREQ"); - goto done; - } - } - } + goto done; + } + } + } else if (lex_match_id (lexer, "NTILES")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - if (!lex_force_int_range (lexer, "NTILES", 0, INT_MAX)) + if (!lex_force_int_range (lexer, "NTILES", 0, INT_MAX)) goto done; int n = lex_integer (lexer); lex_get (lexer); for (int i = 0; i < n + 1; ++i) add_percentile (&frq, i / (double) n, true, &allocated_percentiles); - } + } else if (lex_match_id (lexer, "ALGORITHM")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "COMPATIBLE")) + if (lex_match_id (lexer, "COMPATIBLE")) settings_set_cmd_algorithm (COMPATIBLE); - else if (lex_match_id (lexer, "ENHANCED")) + else if (lex_match_id (lexer, "ENHANCED")) settings_set_cmd_algorithm (ENHANCED); - else - { - lex_error_expecting (lexer, "COMPATIBLE", "ENHANCED"); - goto done; - } - } + else + { + lex_error_expecting (lexer, "COMPATIBLE", "ENHANCED"); + goto done; + } + } else if (lex_match_id (lexer, "HISTOGRAM")) { double hi_min = -DBL_MAX; @@ -742,17 +742,17 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) int hi_pcnt = INT_MIN; bool hi_draw_normal = false; - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "NORMAL")) + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "NORMAL")) hi_draw_normal = true; - else if (lex_match_id (lexer, "NONORMAL")) + else if (lex_match_id (lexer, "NONORMAL")) hi_draw_normal = false; - else if (lex_match_id (lexer, "FREQ")) - { + else if (lex_match_id (lexer, "FREQ")) + { hi_scale = FRQ_FREQ; if (lex_match (lexer, T_LPAREN)) { @@ -763,9 +763,9 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) if (!lex_force_match (lexer, T_RPAREN)) goto done; } - } - else if (lex_match_id (lexer, "PERCENT")) - { + } + else if (lex_match_id (lexer, "PERCENT")) + { hi_scale = FRQ_PERCENT; if (lex_match (lexer, T_LPAREN)) { @@ -776,36 +776,36 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) if (!lex_force_match (lexer, T_RPAREN)) goto done; } - } - else if (lex_match_id (lexer, "MINIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "MINIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MINIMUM", -DBL_MAX, hi_max)) goto done; hi_min = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else if (lex_match_id (lexer, "MAXIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else if (lex_match_id (lexer, "MAXIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MAXIMUM", hi_min, DBL_MAX)) - goto done; + goto done; hi_max = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else - { - lex_error_expecting (lexer, "NORMAL", "NONORMAL", + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else + { + lex_error_expecting (lexer, "NORMAL", "NONORMAL", "FREQ", "PERCENT", "MINIMUM", "MAXIMUM"); - goto done; - } - } + goto done; + } + } free (frq.hist); frq.hist = xmalloc (sizeof *frq.hist); @@ -820,50 +820,50 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) add_percentile (&frq, .25, false, &allocated_percentiles); add_percentile (&frq, .75, false, &allocated_percentiles); - } + } else if (lex_match_id (lexer, "PIECHART")) { double pie_min = -DBL_MAX; double pie_max = DBL_MAX; bool pie_missing = true; - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "MINIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "MINIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MINIMUM", -DBL_MAX, pie_max)) - goto done; + goto done; pie_min = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else if (lex_match_id (lexer, "MAXIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else if (lex_match_id (lexer, "MAXIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MAXIMUM", pie_min, DBL_MAX)) - goto done; + goto done; pie_max = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else if (lex_match_id (lexer, "MISSING")) + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else if (lex_match_id (lexer, "MISSING")) pie_missing = true; - else if (lex_match_id (lexer, "NOMISSING")) + else if (lex_match_id (lexer, "NOMISSING")) pie_missing = false; - else - { - lex_error_expecting (lexer, "MINIMUM", "MAXIMUM", + else + { + lex_error_expecting (lexer, "MINIMUM", "MAXIMUM", "MISSING", "NOMISSING"); - goto done; - } - } + goto done; + } + } free (frq.pie); frq.pie = xmalloc (sizeof *frq.pie); @@ -879,66 +879,66 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) double bar_max = DBL_MAX; bool bar_freq = true; - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "MINIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "MINIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MINIMUM", -DBL_MAX, bar_max)) goto done; bar_min = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else if (lex_match_id (lexer, "MAXIMUM")) - { - if (!lex_force_match (lexer, T_LPAREN) + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else if (lex_match_id (lexer, "MAXIMUM")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "MAXIMUM", bar_min, DBL_MAX)) - goto done; + goto done; bar_max = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - else if (lex_match_id (lexer, "FREQ")) - { - if (lex_match (lexer, T_LPAREN)) - { + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + else if (lex_match_id (lexer, "FREQ")) + { + if (lex_match (lexer, T_LPAREN)) + { if (!lex_force_num_range_open (lexer, "FREQ", 0, DBL_MAX)) goto done; /* XXX TODO */ lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - bar_freq = true; - } - else if (lex_match_id (lexer, "PERCENT")) - { - if (lex_match (lexer, T_LPAREN)) - { + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + bar_freq = true; + } + else if (lex_match_id (lexer, "PERCENT")) + { + if (lex_match (lexer, T_LPAREN)) + { if (!lex_force_num_range_open (lexer, "PERCENT", 0, DBL_MAX)) goto done; /* XXX TODO */ lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto done; - } - bar_freq = false; - } - else - { - lex_error_expecting (lexer, "MINIMUM", "MAXIMUM", + if (!lex_force_match (lexer, T_RPAREN)) + goto done; + } + bar_freq = false; + } + else + { + lex_error_expecting (lexer, "MINIMUM", "MAXIMUM", "FREQ", "PERCENT"); - goto done; - } - } + goto done; + } + } free (frq.bar); frq.bar = xmalloc (sizeof *frq.bar); @@ -948,14 +948,14 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) .include_missing = false, .y_scale = bar_freq ? FRQ_FREQ : FRQ_PERCENT, }; - } + } else if (lex_match_id (lexer, "MISSING")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "EXCLUDE")) { /* XXX TODO */ @@ -1125,8 +1125,8 @@ freq_tab_to_hist (const struct frq_proc *frq, const struct var_freqs *vf) */ static struct freq * pick_cat_counts (const struct frq_chart *catchart, - const struct freq_tab *frq_tab, - int *n_slicesp) + const struct freq_tab *frq_tab, + int *n_slicesp) { int n_slices = 0; struct freq *slices = xnmalloc (frq_tab->n_valid + frq_tab->n_missing, sizeof *slices); @@ -1142,16 +1142,16 @@ pick_cat_counts (const struct frq_chart *catchart, if (catchart->include_missing) { for (size_t i = 0; i < frq_tab->n_missing; i++) - { - const struct freq *f = &frq_tab->missing[i]; - slices[n_slices].count += f->count; + { + 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 (i == 0) + slices[n_slices].values[0] = f->values[0]; + } if (frq_tab->n_missing > 0) - n_slices++; + n_slices++; } *n_slicesp = n_slices; @@ -1166,8 +1166,8 @@ pick_cat_counts (const struct frq_chart *catchart, */ static struct freq ** pick_cat_counts_ptr (const struct frq_chart *catchart, - const struct freq_tab *frq_tab, - int *n_slicesp) + const struct freq_tab *frq_tab, + int *n_slicesp) { int n_slices = 0; struct freq **slices = xnmalloc (frq_tab->n_valid + frq_tab->n_missing, sizeof *slices); diff --git a/src/language/commands/friedman.c b/src/language/commands/friedman.c index 774c20b644..d228e858d7 100644 --- a/src/language/commands/friedman.c +++ b/src/language/commands/friedman.c @@ -46,10 +46,10 @@ struct friedman }; static void show_ranks_box (const struct one_sample_test *ost, - const struct friedman *fr); + const struct friedman *fr); static void show_sig_box (const struct one_sample_test *ost, - const struct friedman *fr); + const struct friedman *fr); struct datum { @@ -83,11 +83,11 @@ cmp_posn (const void *a_, const void *b_) void friedman_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { double numerator = 0.0; double denominator = 0.0; @@ -115,8 +115,8 @@ friedman_execute (const struct dataset *ds, input = casereader_create_filter_weight (input, dict, &warn, NULL); input = casereader_create_filter_missing (input, - ost->vars, ost->n_vars, - exclude, 0, 0); + ost->vars, ost->n_vars, + exclude, 0, 0); for (; (c = casereader_read (input)); case_unref (c)) { @@ -128,52 +128,52 @@ friedman_execute (const struct dataset *ds, fr.cc += w; for (v = 0; v < ost->n_vars; ++v) - { - const struct variable *var = ost->vars[v]; - const union value *val = case_data (c, var); - row[v].x = val->f; - } + { + const struct variable *var = ost->vars[v]; + const union value *val = case_data (c, var); + row[v].x = val->f; + } qsort (row, ost->n_vars, sizeof *row, cmp_x); for (v = 0; v < ost->n_vars; ++v) - { - double x = row[v].x; - /* Replace value by the Rank */ - if (prev_x == x) - { - /* Deal with ties */ - int i; - run_length++; - for (i = v - run_length; i < v; ++i) - { - row[i].x *= run_length ; - row[i].x += v + 1; - row[i].x /= run_length + 1; - } - row[v].x = row[v-1].x; - } - else - { - row[v].x = v + 1; - if (run_length > 0) - { - double t = run_length + 1; - sigma_t += w * (pow3 (t) - t); - } - run_length = 0; - } - prev_x = x; - } + { + double x = row[v].x; + /* Replace value by the Rank */ + if (prev_x == x) + { + /* Deal with ties */ + int i; + run_length++; + for (i = v - run_length; i < v; ++i) + { + row[i].x *= run_length ; + row[i].x += v + 1; + row[i].x /= run_length + 1; + } + row[v].x = row[v-1].x; + } + else + { + row[v].x = v + 1; + if (run_length > 0) + { + double t = run_length + 1; + sigma_t += w * (pow3 (t) - t); + } + run_length = 0; + } + prev_x = x; + } if (run_length > 0) - { - double t = run_length + 1; - sigma_t += w * (pow3 (t) - t); - } + { + double t = run_length + 1; + sigma_t += w * (pow3 (t) - t); + } qsort (row, ost->n_vars, sizeof *row, cmp_posn); for (v = 0; v < ost->n_vars; ++v) - fr.rank_sum[v] += row[v].x * w; + fr.rank_sum[v] += row[v].x * w; } casereader_destroy (input); free (row); @@ -197,10 +197,10 @@ friedman_execute (const struct dataset *ds, { fr.w = 12 * rsq ; fr.w -= 3 * pow2 (fr.cc) * - ost->n_vars * pow2 (ost->n_vars + 1); + ost->n_vars * pow2 (ost->n_vars + 1); fr.w /= pow2 (fr.cc) * (pow3 (ost->n_vars) - ost->n_vars) - - fr.cc * sigma_t; + - fr.cc * sigma_t; } else fr.w = SYSMIS; diff --git a/src/language/commands/friedman.h b/src/language/commands/friedman.h index 59dd953ee4..b72bd8dc0c 100644 --- a/src/language/commands/friedman.h +++ b/src/language/commands/friedman.h @@ -31,11 +31,11 @@ struct friedman_test void friedman_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool, - double); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool, + double); #endif diff --git a/src/language/commands/get-data.c b/src/language/commands/get-data.c index 93c933ad6a..059b694fbe 100644 --- a/src/language/commands/get-data.c +++ b/src/language/commands/get-data.c @@ -47,7 +47,7 @@ #define N_(msgid) (msgid) static bool parse_spreadsheet (struct lexer *lexer, char **filename, - struct spreadsheet_read_options *opts); + struct spreadsheet_read_options *opts); static void destroy_spreadsheet_read_info (struct spreadsheet_read_options *); @@ -129,33 +129,33 @@ parse_get_psql (struct lexer *lexer, struct dataset *ds) while (lex_match (lexer, T_SLASH)) { if (lex_match_id (lexer, "ASSUMEDSTRWIDTH")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); if (!lex_force_int_range (lexer, "ASSUMEDSTRWIDTH", 1, 32767)) goto done; psql.str_width = lex_integer (lexer); lex_get (lexer); - } + } else if (lex_match_id (lexer, "BSIZE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); if (!lex_force_int_range (lexer, "BSIZE", 1, INT_MAX)) goto done; psql.bsize = lex_integer (lexer); lex_get (lexer); - } + } else if (lex_match_id (lexer, "UNENCRYPTED")) psql.allow_clear = true; else if (lex_match_id (lexer, "SQL")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto done; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto done; free (psql.sql); psql.sql = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } } struct dictionary *dict = NULL; @@ -175,7 +175,7 @@ parse_get_psql (struct lexer *lexer, struct dataset *ds) static bool parse_spreadsheet (struct lexer *lexer, char **filename, - struct spreadsheet_read_options *opts) + struct spreadsheet_read_options *opts) { *opts = (struct spreadsheet_read_options) { .sheet_index = 1, @@ -193,79 +193,79 @@ parse_spreadsheet (struct lexer *lexer, char **filename, while (lex_match (lexer, T_SLASH)) { if (lex_match_id (lexer, "ASSUMEDSTRWIDTH")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); if (!lex_force_int_range (lexer, "ASSUMEDSTRWIDTH", 1, 32767)) goto error; opts->asw = lex_integer (lexer); lex_get (lexer); - } + } else if (lex_match_id (lexer, "SHEET")) - { - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "NAME")) - { - if (!lex_force_string (lexer)) - goto error; - - opts->sheet_name = ss_xstrdup (lex_tokss (lexer)); - opts->sheet_index = -1; - - lex_get (lexer); - } - else if (lex_match_id (lexer, "INDEX")) - { + { + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "NAME")) + { + if (!lex_force_string (lexer)) + goto error; + + opts->sheet_name = ss_xstrdup (lex_tokss (lexer)); + opts->sheet_index = -1; + + lex_get (lexer); + } + else if (lex_match_id (lexer, "INDEX")) + { if (!lex_force_int_range (lexer, "INDEX", 1, INT_MAX)) goto error; - opts->sheet_index = lex_integer (lexer); - lex_get (lexer); - } - else - { + opts->sheet_index = lex_integer (lexer); + lex_get (lexer); + } + else + { lex_error_expecting (lexer, "NAME", "INDEX"); - goto error; - } - } + goto error; + } + } else if (lex_match_id (lexer, "CELLRANGE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "FULL")) + if (lex_match_id (lexer, "FULL")) opts->cell_range = NULL; - else if (lex_match_id (lexer, "RANGE")) - { - if (!lex_force_string (lexer)) - goto error; - - opts->cell_range = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } - else - { + else if (lex_match_id (lexer, "RANGE")) + { + if (!lex_force_string (lexer)) + goto error; + + opts->cell_range = ss_xstrdup (lex_tokss (lexer)); + lex_get (lexer); + } + else + { lex_error_expecting (lexer, "FULL", "RANGE"); - goto error; - } - } + goto error; + } + } else if (lex_match_id (lexer, "READNAMES")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "ON")) + if (lex_match_id (lexer, "ON")) opts->read_names = true; - else if (lex_match_id (lexer, "OFF")) + else if (lex_match_id (lexer, "OFF")) opts->read_names = false; - else - { + else + { lex_error_expecting (lexer, "ON", "OFF"); - goto error; - } - } + goto error; + } + } else - { - lex_error_expecting (lexer, "ASSUMEDSTRWIDTH", "SHEET", "CELLRANGE", + { + lex_error_expecting (lexer, "ASSUMEDSTRWIDTH", "SHEET", "CELLRANGE", "READNAMES"); - goto error; - } + goto error; + } } return true; @@ -330,21 +330,21 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; if (lex_match_id (lexer, "ENCODING")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto error; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "ARRANGEMENT")) { bool ok; - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (lex_match_id (lexer, "FIXED")) ok = set_type (lexer, parser, DP_FIXED, lex_ofs (lexer) - 3, lex_ofs (lexer) - 1, @@ -363,7 +363,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "FIRSTCASE")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (!lex_force_int_range (lexer, "FIRSTCASE", 1, INT_MAX)) goto error; data_parser_set_skip (parser, lex_integer (lexer) - 1); @@ -516,8 +516,8 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) { lex_error (lexer, "%s", error); free (error); - goto error; - } + goto error; + } lex_get (lexer); struct fmt_spec input, output; @@ -528,11 +528,11 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) goto error; error = fmt_check_input__ (input); if (error) - { + { lex_next_error (lexer, -1, -1, "%s", error); free (error); - goto error; - } + goto error; + } output = fmt_for_output_from_input (input, settings_get_fmt_settings ()); } diff --git a/src/language/commands/get.c b/src/language/commands/get.c index 79d8dc40cd..4ca9a80ba1 100644 --- a/src/language/commands/get.c +++ b/src/language/commands/get.c @@ -82,17 +82,17 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "FILE") || lex_is_string (lexer)) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); fh_unref (fh); - fh = fh_parse (lexer, FH_REF_FILE, NULL); - if (fh == NULL) + fh = fh_parse (lexer, FH_REF_FILE, NULL); + if (fh == NULL) goto error; - } + } else if (command == GET_CMD && lex_match_id (lexer, "ENCODING")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (!lex_force_string (lexer)) goto error; @@ -103,16 +103,16 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, lex_get (lexer); } else if (command == IMPORT_CMD && lex_match_id (lexer, "TYPE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - if (!lex_match_id (lexer, "COMM") + if (!lex_match_id (lexer, "COMM") && !lex_match_id (lexer, "TAPE")) - { - lex_error_expecting (lexer, "COMM", "TAPE"); + { + lex_error_expecting (lexer, "COMM", "TAPE"); goto error; - } - } + } + } else break; } diff --git a/src/language/commands/glm.c b/src/language/commands/glm.c index 25ccb7f275..05ab9bf9ca 100644 --- a/src/language/commands/glm.c +++ b/src/language/commands/glm.c @@ -102,14 +102,14 @@ design_full (struct glm_spec *glm) gsl_combination *c = gsl_combination_calloc (glm->n_factor_vars, sz); do - { - struct interaction *iact = interaction_create (NULL); + { + struct interaction *iact = interaction_create (NULL); for (int e = 0; e < gsl_combination_k (c); ++e) - interaction_add_variable ( + interaction_add_variable ( iact, glm->factor_vars [gsl_combination_get (c, e)]); - glm->interactions[glm->n_interactions++] = iact; - } + glm->interactions[glm->n_interactions++] = iact; + } while (gsl_combination_next (c) == GSL_SUCCESS); gsl_combination_free (c); @@ -118,9 +118,9 @@ design_full (struct glm_spec *glm) } static void output_glm (const struct glm_spec *, - const struct glm_workspace *ws); + const struct glm_workspace *ws); static void run_glm (struct glm_spec *cmd, struct casereader *input, - const struct dataset *ds); + const struct dataset *ds); static struct interaction *parse_design_term (struct lexer *, const struct dictionary *); @@ -142,8 +142,8 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) int dep_vars_start = lex_ofs (lexer); if (!parse_variables_const (lexer, glm.dict, - &glm.dep_vars, &glm.n_dep_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + &glm.dep_vars, &glm.n_dep_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) goto error; int dep_vars_end = lex_ofs (lexer) - 1; @@ -151,8 +151,8 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) goto error; if (!parse_variables_const (lexer, glm.dict, - &glm.factor_vars, &glm.n_factor_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + &glm.factor_vars, &glm.n_factor_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) goto error; if (glm.n_dep_vars > 1) @@ -170,66 +170,66 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "MISSING")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "INCLUDE")) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "INCLUDE")) glm.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) glm.exclude = MV_ANY; - else - { - lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); + goto error; + } + } + } else if (lex_match_id (lexer, "INTERCEPT")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "INCLUDE")) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "INCLUDE")) glm.intercept = true; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) glm.intercept = false; - else - { - lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); + goto error; + } + } + } else if (lex_match_id (lexer, "CRITERIA")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_match_phrase (lexer, "ALPHA(") + { + lex_match (lexer, T_EQUALS); + if (!lex_force_match_phrase (lexer, "ALPHA(") || !lex_force_num (lexer)) goto error; glm.alpha = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } + } else if (lex_match_id (lexer, "METHOD")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_match_phrase (lexer, "SSTYPE(") + { + lex_match (lexer, T_EQUALS); + if (!lex_force_match_phrase (lexer, "SSTYPE(") || !lex_force_int_range (lexer, "SSTYPE", 1, 3)) goto error; - glm.ss_type = lex_integer (lexer); - lex_get (lexer); + glm.ss_type = lex_integer (lexer); + lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) + if (!lex_force_match (lexer, T_RPAREN)) goto error; - } + } else if (lex_match_id (lexer, "DESIGN")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); do { @@ -247,20 +247,20 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) } while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH); - if (glm.n_interactions > 0) - design = true; - } + if (glm.n_interactions > 0) + design = true; + } else if (lex_match_id (lexer, "SHOWCODES")) - { + { /* Undocumented debug option */ - glm.dump_coding = true; - } + glm.dump_coding = true; + } else - { - lex_error_expecting (lexer, "MISSING", "INTERCEPT", "CRITERIA", + { + lex_error_expecting (lexer, "MISSING", "INTERCEPT", "CRITERIA", "METHOD", "DESIGN"); - goto error; - } + goto error; + } } if (!design) @@ -312,19 +312,19 @@ fill_submatrix (const gsl_matrix * cov, gsl_matrix * submatrix, bool *dropped_f) for (i = 0; i < cov->size1; i++) { if (not_dropped (i, dropped_f)) - { - m = 0; - for (j = 0; j < cov->size2; j++) - { - if (not_dropped (j, dropped_f)) - { - gsl_matrix_set (submatrix, n, m, - gsl_matrix_get (cov, i, j)); - m++; - } - } - n++; - } + { + m = 0; + for (j = 0; j < cov->size2; j++) + { + if (not_dropped (j, dropped_f)) + { + gsl_matrix_set (submatrix, n, m, + gsl_matrix_get (cov, i, j)); + m++; + } + } + n++; + } } } @@ -364,16 +364,16 @@ ssq_type1 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) submodel_dropped[i] = model_dropped[i]; for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++) - { - const struct interaction * x = - categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); + { + const struct interaction * x = + categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); - if (x == cmd->interactions [k]) - { - model_dropped[i] = false; - n_dropped_model--; - } - } + if (x == cmd->interactions [k]) + { + model_dropped[i] = false; + n_dropped_model--; + } + } model_cov = gsl_matrix_alloc (cm->size1 - n_dropped_model, cm->size2 - n_dropped_model); submodel_cov = gsl_matrix_alloc (cm->size1 - n_dropped_submodel, cm->size2 - n_dropped_submodel); @@ -385,8 +385,8 @@ ssq_type1 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) reg_sweep (submodel_cov, 0); gsl_vector_set (ssq, k + 1, - gsl_matrix_get (submodel_cov, 0, 0) - gsl_matrix_get (model_cov, 0, 0) - ); + gsl_matrix_get (submodel_cov, 0, 0) - gsl_matrix_get (model_cov, 0, 0) + ); gsl_matrix_free (model_cov); gsl_matrix_free (submodel_cov); @@ -415,26 +415,26 @@ ssq_type2 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) size_t n_dropped_model = 0; size_t n_dropped_submodel = 0; for (size_t i = cmd->n_dep_vars; i < covariance_dim (cov); i++) - { - const struct interaction * x = - categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); - - model_dropped[i] = false; - submodel_dropped[i] = false; - if (interaction_is_subset (cmd->interactions [k], x)) - { - assert (n_dropped_submodel < covariance_dim (cov)); - n_dropped_submodel++; + { + const struct interaction * x = + categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); + + model_dropped[i] = false; + submodel_dropped[i] = false; + if (interaction_is_subset (cmd->interactions [k], x)) + { + assert (n_dropped_submodel < covariance_dim (cov)); + n_dropped_submodel++; submodel_dropped[i] = true; - if (cmd->interactions [k]->n_vars < x->n_vars) - { - assert (n_dropped_model < covariance_dim (cov)); - n_dropped_model++; - model_dropped[i] = true; - } - } - } + if (cmd->interactions [k]->n_vars < x->n_vars) + { + assert (n_dropped_model < covariance_dim (cov)); + n_dropped_model++; + model_dropped[i] = true; + } + } + } model_cov = gsl_matrix_alloc (cm->size1 - n_dropped_model, cm->size2 - n_dropped_model); submodel_cov = gsl_matrix_alloc (cm->size1 - n_dropped_submodel, cm->size2 - n_dropped_submodel); @@ -446,8 +446,8 @@ ssq_type2 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) reg_sweep (submodel_cov, 0); gsl_vector_set (ssq, k + 1, - gsl_matrix_get (submodel_cov, 0, 0) - gsl_matrix_get (model_cov, 0, 0) - ); + gsl_matrix_get (submodel_cov, 0, 0) - gsl_matrix_get (model_cov, 0, 0) + ); gsl_matrix_free (model_cov); gsl_matrix_free (submodel_cov); @@ -480,19 +480,19 @@ ssq_type3 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) { size_t n_dropped_model = 0; for (size_t i = cmd->n_dep_vars; i < covariance_dim (cov); i++) - { - const struct interaction * x = - categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); + { + const struct interaction * x = + categoricals_get_interaction_by_subscript (cats, i - cmd->n_dep_vars); - model_dropped[i] = false; + model_dropped[i] = false; - if (cmd->interactions [k] == x) - { - assert (n_dropped_model < covariance_dim (cov)); - n_dropped_model++; - model_dropped[i] = true; - } - } + if (cmd->interactions [k] == x) + { + assert (n_dropped_model < covariance_dim (cov)); + n_dropped_model++; + model_dropped[i] = true; + } + } gsl_matrix *model_cov = gsl_matrix_alloc (cm->size1 - n_dropped_model, cm->size2 - n_dropped_model); @@ -510,7 +510,7 @@ ssq_type3 (struct covariance *cov, gsl_vector *ssq, const struct glm_spec *cmd) static void run_glm (struct glm_spec *cmd, struct casereader *input, - const struct dataset *ds) + const struct dataset *ds) { bool warn_bad_weight = true; struct dictionary *dict = dataset_dict (ds); @@ -528,7 +528,7 @@ run_glm (struct glm_spec *cmd, struct casereader *input, struct glm_workspace ws = { .cats = categoricals_create (cmd->interactions, cmd->n_interactions, - cmd->wv, MV_ANY) + cmd->wv, MV_ANY) }; struct covariance *cov = covariance_2pass_create ( @@ -547,7 +547,7 @@ run_glm (struct glm_spec *cmd, struct casereader *input, double weight = dict_get_case_weight (dict, c, &warn_bad_weight); for (int v = 0; v < cmd->n_dep_vars; ++v) - moments_pass_one (ws.totals, case_num (c, cmd->dep_vars[v]), weight); + moments_pass_one (ws.totals, case_num (c, cmd->dep_vars[v]), weight); covariance_accumulate_pass1 (cov, c); } @@ -563,7 +563,7 @@ run_glm (struct glm_spec *cmd, struct casereader *input, double weight = dict_get_case_weight (dict, c, &warn_bad_weight); for (size_t v = 0; v < cmd->n_dep_vars; ++v) - moments_pass_two (ws.totals, case_num (c, cmd->dep_vars[v]), weight); + moments_pass_two (ws.totals, case_num (c, cmd->dep_vars[v]), weight); covariance_accumulate_pass2 (cov, c); } @@ -574,10 +574,10 @@ run_glm (struct glm_spec *cmd, struct casereader *input, { struct pivot_table *t = covariance_dump_enc_header (cov); for (reader = input; - (c = casereader_read (reader)) != NULL; case_unref (c)) - { - covariance_dump_enc (cov, c, t); - } + (c = casereader_read (reader)) != NULL; case_unref (c)) + { + covariance_dump_enc (cov, c, t); + } pivot_table_submit (t); } @@ -601,17 +601,17 @@ run_glm (struct glm_spec *cmd, struct casereader *input, switch (cmd->ss_type) { case 1: - ssq_type1 (cov, ws.ssq, cmd); - break; + ssq_type1 (cov, ws.ssq, cmd); + break; case 2: - ssq_type2 (cov, ws.ssq, cmd); - break; + ssq_type2 (cov, ws.ssq, cmd); + break; case 3: - ssq_type3 (cov, ws.ssq, cmd); - break; + ssq_type3 (cov, ws.ssq, cmd); + break; default: - NOT_REACHED (); - break; + NOT_REACHED (); + break; } // dump_matrix (cm); gsl_matrix_free (cm); @@ -672,7 +672,7 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) source->root, pivot_value_new_text (N_("Intercept"))); /* The intercept for unbalanced models is of limited use and - nobody knows how to calculate it properly */ + nobody knows how to calculate it properly */ if (categoricals_isbalanced (ws->cats)) { const double df = 1.0; @@ -689,10 +689,10 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) double ssq = gsl_vector_get (ws->ssq, f + 1); ssq_effects += ssq; if (!cmd->intercept) - { - df++; - ssq += intercept_ssq; - } + { + df++; + ssq += intercept_ssq; + } double F = ssq / df / mse; struct string str = DS_EMPTY_INITIALIZER; @@ -752,10 +752,10 @@ dump_matrix (const gsl_matrix * m) for (i = 0; i < m->size1; ++i) { for (j = 0; j < m->size2; ++j) - { - double x = gsl_matrix_get (m, i, j); - printf ("%.3f ", x); - } + { + double x = gsl_matrix_get (m, i, j); + printf ("%.3f ", x); + } printf ("\n"); } printf ("\n"); diff --git a/src/language/commands/graph.c b/src/language/commands/graph.c index a035b2582f..c130818009 100644 --- a/src/language/commands/graph.c +++ b/src/language/commands/graph.c @@ -221,10 +221,10 @@ parse_function_name (struct lexer *lexer, int *agr) for (size_t i = 0; i < N_AG_FUNCS; ++i) { if (lex_match_id (lexer, ag_func[i].name)) - { - *agr = i; + { + *agr = i; return true; - } + } } const char *ag_func_names[N_AG_FUNCS]; @@ -245,18 +245,18 @@ parse_function (struct lexer *lexer, struct graph *graph) if (arity > 0) { if (!lex_force_match (lexer, T_LPAREN)) - return false; + return false; graph->dep_vars = xcalloc (graph->n_dep_vars, sizeof (graph->dep_vars)); for (int v = 0; v < arity; ++v) - { - graph->dep_vars[v] = parse_variable (lexer, graph->dict); - if (!graph->dep_vars[v]) - return false; - } + { + graph->dep_vars[v] = parse_variable (lexer, graph->dict); + if (!graph->dep_vars[v]) + return false; + } if (!lex_force_match (lexer, T_RPAREN)) - return false; + return false; } if (!lex_force_match (lexer, T_BY)) @@ -296,14 +296,14 @@ show_scatterplot (const struct graph *cmd, struct casereader *input) var_to_string (cmd->dep_vars[0])));; scatterplot = scatterplot_create (input, - var_to_string(cmd->dep_vars[0]), - var_to_string(cmd->dep_vars[1]), - (cmd->n_by_vars > 0) ? cmd->by_var[0] - : NULL, - &byvar_overflow, - title, - cmd->es[0].minimum, cmd->es[0].maximum, - cmd->es[1].minimum, cmd->es[1].maximum); + var_to_string(cmd->dep_vars[0]), + var_to_string(cmd->dep_vars[1]), + (cmd->n_by_vars > 0) ? cmd->by_var[0] + : NULL, + &byvar_overflow, + title, + cmd->es[0].minimum, cmd->es[0].maximum, + cmd->es[1].minimum, cmd->es[1].maximum); scatterplot_chart_submit (scatterplot); free (title); @@ -412,21 +412,21 @@ run_barchart (struct graph *cmd, struct casereader *input) { struct ccase *c = casereader_peek (group, 0); if (any_categorical_missing (cmd, c)) - { - case_unref (c); - continue; - } + { + case_unref (c); + continue; + } if (n_cells >= allocated_cells) cells = x2nrealloc (cells, &allocated_cells, sizeof *cells); cells[n_cells++] = xzalloc (table_entry_size (cmd->n_by_vars)); if (ag_func[cmd->agr].cumulative && n_cells >= 2) - cells[n_cells - 1]->count = cells[n_cells - 2]->count; + cells[n_cells - 1]->count = cells[n_cells - 2]->count; else - cells[n_cells - 1]->count = 0; + cells[n_cells - 1]->count = 0; if (ag_func[cmd->agr].pre) - cells[n_cells - 1]->count = ag_func[cmd->agr].pre(); + cells[n_cells - 1]->count = ag_func[cmd->agr].pre(); if (cmd->n_by_vars > 1) { @@ -453,19 +453,19 @@ run_barchart (struct graph *cmd, struct casereader *input) double cc = 0; for (; (c = casereader_read (group)) != NULL; case_unref (c)) - { - const double weight = dict_get_case_weight (cmd->dict, c, NULL); - const double x = (cmd->n_dep_vars > 0 + { + const double weight = dict_get_case_weight (cmd->dict, c, NULL); + const double x = (cmd->n_dep_vars > 0 ? case_num (c, cmd->dep_vars[0]) : SYSMIS); - cc += weight; - cells[n_cells - 1]->count - = ag_func[cmd->agr].calc (cells[n_cells - 1]->count, x, weight); - } + cc += weight; + cells[n_cells - 1]->count + = ag_func[cmd->agr].calc (cells[n_cells - 1]->count, x, weight); + } if (ag_func[cmd->agr].post) - cells[n_cells - 1]->count - = ag_func[cmd->agr].post (cells[n_cells - 1]->count, cc); + cells[n_cells - 1]->count + = ag_func[cmd->agr].post (cells[n_cells - 1]->count, cc); ccc += cc; } @@ -475,31 +475,31 @@ run_barchart (struct graph *cmd, struct casereader *input) for (int i = 0; i < n_cells; ++i) { if (ag_func[cmd->agr].ppost) - { - struct freq *cell = cells[i]; - if (cmd->n_by_vars > 1) - { - const union value *vv = &cell->values[1]; - - int v1_width = var_get_width (cmd->by_var[1]); - size_t hash = value_hash (vv, v1_width, 0); - - struct freq *fcol = find_fcol (&columns, vv, hash, v1_width); - cell->count = ag_func[cmd->agr].ppost (cell->count, fcol->count); - } - else - cell->count = ag_func[cmd->agr].ppost (cell->count, ccc); - } + { + struct freq *cell = cells[i]; + if (cmd->n_by_vars > 1) + { + const union value *vv = &cell->values[1]; + + int v1_width = var_get_width (cmd->by_var[1]); + size_t hash = value_hash (vv, v1_width, 0); + + struct freq *fcol = find_fcol (&columns, vv, hash, v1_width); + cell->count = ag_func[cmd->agr].ppost (cell->count, fcol->count); + } + else + cell->count = ag_func[cmd->agr].ppost (cell->count, ccc); + } } if (cmd->n_by_vars > 1) { struct freq *cell, *next; HMAP_FOR_EACH_SAFE (cell, next, struct freq, node, &columns) - { - value_destroy (cell->values, var_get_width (cmd->by_var[1])); - free (cell); - } + { + value_destroy (cell->values, var_get_width (cmd->by_var[1])); + free (cell); + } } hmap_destroy (&columns); @@ -558,40 +558,40 @@ run_graph (struct graph *cmd, struct casereader *input) struct ccase *outcase = case_create (cmd->gr_proto); const double weight = dict_get_case_weight (cmd->dict, c, NULL); if (cmd->chart_type == CT_HISTOGRAM) - *case_num_rw_idx (outcase, HG_IDX_WT) = weight; + *case_num_rw_idx (outcase, HG_IDX_WT) = weight; if (cmd->chart_type == CT_SCATTERPLOT && cmd->n_by_vars > 0) - value_copy (case_data_rw_idx (outcase, SP_IDX_BY), - case_data (c, cmd->by_var[0]), - var_get_width (cmd->by_var[0])); + value_copy (case_data_rw_idx (outcase, SP_IDX_BY), + case_data (c, cmd->by_var[0]), + var_get_width (cmd->by_var[0])); for (int v = 0; v < cmd->n_dep_vars; v++) - { - const struct variable *var = cmd->dep_vars[v]; - const double x = case_num (c, var); + { + const struct variable *var = cmd->dep_vars[v]; + const double x = case_num (c, var); - if (var_is_value_missing (var, case_data (c, var)) & cmd->dep_excl) - { - cmd->es[v].missing += weight; - continue; - } + if (var_is_value_missing (var, case_data (c, var)) & cmd->dep_excl) + { + cmd->es[v].missing += weight; + continue; + } - /* Magically v value fits to SP_IDX_X, SP_IDX_Y, HG_IDX_X. */ - *case_num_rw_idx (outcase, v) = x; + /* Magically v value fits to SP_IDX_X, SP_IDX_Y, HG_IDX_X. */ + *case_num_rw_idx (outcase, v) = x; - if (x > cmd->es[v].maximum) - cmd->es[v].maximum = x; + if (x > cmd->es[v].maximum) + cmd->es[v].maximum = x; - if (x < cmd->es[v].minimum) - cmd->es[v].minimum = x; + if (x < cmd->es[v].minimum) + cmd->es[v].minimum = x; - cmd->es[v].non_missing += weight; + cmd->es[v].non_missing += weight; - moments_pass_one (cmd->es[v].mom, x, weight); + moments_pass_one (cmd->es[v].mom, x, weight); - cmd->es[v].cc += weight; + cmd->es[v].cc += weight; - if (cmd->es[v].cmin > weight) - cmd->es[v].cmin = weight; - } + if (cmd->es[v].cmin > weight) + cmd->es[v].cmin = weight; + } casewriter_write (writer, outcase); } @@ -644,13 +644,13 @@ cmd_graph (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "HISTOGRAM")) - { - if (graph.chart_type != CT_NONE) - { - lex_next_error (lexer, -1, -1, + { + if (graph.chart_type != CT_NONE) + { + lex_next_error (lexer, -1, -1, _("Only one chart type is allowed.")); - goto error; - } + goto error; + } graph.normal = false; if (lex_match (lexer, T_LPAREN)) { @@ -659,210 +659,210 @@ cmd_graph (struct lexer *lexer, struct dataset *ds) graph.normal = true; } - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - graph.chart_type = CT_HISTOGRAM; + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + graph.chart_type = CT_HISTOGRAM; int vars_start = lex_ofs (lexer); - if (!parse_variables_const (lexer, graph.dict, - &graph.dep_vars, &graph.n_dep_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) - goto error; - if (graph.n_dep_vars > 1) - { - lex_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, + if (!parse_variables_const (lexer, graph.dict, + &graph.dep_vars, &graph.n_dep_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) + goto error; + if (graph.n_dep_vars > 1) + { + lex_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, _("Only one variable is allowed.")); - goto error; - } - } + goto error; + } + } else if (lex_match_id (lexer, "BAR")) - { - if (graph.chart_type != CT_NONE) - { - lex_next_error (lexer, -1, -1, + { + if (graph.chart_type != CT_NONE) + { + lex_next_error (lexer, -1, -1, _("Only one chart type is allowed.")); - goto error; - } - graph.chart_type = CT_BAR; - graph.bar_type = CBT_SIMPLE; - - if (lex_match (lexer, T_LPAREN)) - { - if (lex_match_id (lexer, "SIMPLE")) - { - /* This is the default anyway */ - } - else if (lex_match_id (lexer, "GROUPED")) - { - graph.bar_type = CBT_GROUPED; - lex_next_error (lexer, -1, -1, + goto error; + } + graph.chart_type = CT_BAR; + graph.bar_type = CBT_SIMPLE; + + if (lex_match (lexer, T_LPAREN)) + { + if (lex_match_id (lexer, "SIMPLE")) + { + /* This is the default anyway */ + } + else if (lex_match_id (lexer, "GROUPED")) + { + graph.bar_type = CBT_GROUPED; + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."), "GROUPED"); - goto error; - } - else if (lex_match_id (lexer, "STACKED")) - { - graph.bar_type = CBT_STACKED; - lex_next_error (lexer, -1, -1, + goto error; + } + else if (lex_match_id (lexer, "STACKED")) + { + graph.bar_type = CBT_STACKED; + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."), "STACKED"); - goto error; - } - else if (lex_match_id (lexer, "RANGE")) - { - graph.bar_type = CBT_RANGE; - lex_next_error (lexer, -1, -1, + goto error; + } + else if (lex_match_id (lexer, "RANGE")) + { + graph.bar_type = CBT_RANGE; + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."), "RANGE"); - goto error; - } - else - { - lex_error_expecting (lexer, "SIMPLE", "GROUPED", + goto error; + } + else + { + lex_error_expecting (lexer, "SIMPLE", "GROUPED", "STACKED", "RANGE"); - goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - - if (!parse_function (lexer, &graph)) - goto error; - } + goto error; + } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + + if (!parse_function (lexer, &graph)) + goto error; + } else if (lex_match_id (lexer, "SCATTERPLOT")) - { - if (graph.chart_type != CT_NONE) - { - lex_next_error (lexer, -1, -1, + { + if (graph.chart_type != CT_NONE) + { + lex_next_error (lexer, -1, -1, _("Only one chart type is allowed.")); - goto error; - } - graph.chart_type = CT_SCATTERPLOT; - if (lex_match (lexer, T_LPAREN)) - { - if (lex_match_id (lexer, "BIVARIATE")) - { - /* This is the default anyway */ - } - else if (lex_match_id (lexer, "OVERLAY")) - { - lex_next_error (lexer, -1, -1, + goto error; + } + graph.chart_type = CT_SCATTERPLOT; + if (lex_match (lexer, T_LPAREN)) + { + if (lex_match_id (lexer, "BIVARIATE")) + { + /* This is the default anyway */ + } + else if (lex_match_id (lexer, "OVERLAY")) + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"OVERLAY"); - goto error; - } - else if (lex_match_id (lexer, "MATRIX")) - { - lex_next_error (lexer, -1, -1, + goto error; + } + else if (lex_match_id (lexer, "MATRIX")) + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"MATRIX"); - goto error; - } - else if (lex_match_id (lexer, "XYZ")) - { - lex_next_error (lexer, -1, -1, + goto error; + } + else if (lex_match_id (lexer, "XYZ")) + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"XYZ"); - goto error; - } - else - { - lex_error_expecting (lexer, "BIVARIATE", "OVERLAY", + goto error; + } + else + { + lex_error_expecting (lexer, "BIVARIATE", "OVERLAY", "MATRIX", "XYZ"); - goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - if (!lex_force_match (lexer, T_EQUALS)) - goto error; + goto error; + } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + if (!lex_force_match (lexer, T_EQUALS)) + goto error; int vars_start = lex_ofs (lexer); - if (!parse_variables_const (lexer, graph.dict, - &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_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, + if (!parse_variables_const (lexer, graph.dict, + &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_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, _("Only one variable is allowed.")); - goto error; - } + goto error; + } - if (!lex_force_match (lexer, T_WITH)) - goto error; + if (!lex_force_match (lexer, T_WITH)) + goto error; vars_start = lex_ofs (lexer); - if (!parse_variables_const (lexer, graph.dict, - &graph.dep_vars, &graph.n_dep_vars, - PV_NO_DUPLICATE | PV_NUMERIC | PV_APPEND)) - goto error; - - if (graph.scatter_type == ST_BIVARIATE && graph.n_dep_vars != 2) - { - lex_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, + if (!parse_variables_const (lexer, graph.dict, + &graph.dep_vars, &graph.n_dep_vars, + PV_NO_DUPLICATE | PV_NUMERIC | PV_APPEND)) + goto error; + + if (graph.scatter_type == ST_BIVARIATE && graph.n_dep_vars != 2) + { + lex_ofs_error (lexer, vars_start, lex_ofs (lexer) - 1, _("Only one variable is allowed.")); - goto error; - } - - if (lex_match (lexer, T_BY)) - { - const struct variable *v = NULL; - if (!lex_match_variable (lexer,graph.dict,&v)) - { - lex_error (lexer, _("Syntax error expecting variable name.")); - goto error; - } - graph.by_var[0] = v; + goto error; + } + + if (lex_match (lexer, T_BY)) + { + const struct variable *v = NULL; + if (!lex_match_variable (lexer,graph.dict,&v)) + { + lex_error (lexer, _("Syntax error expecting variable name.")); + goto error; + } + graph.by_var[0] = v; graph.n_by_vars = 1; - } - } + } + } else if (lex_match_id (lexer, "LINE")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"LINE"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "PIE")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"PIE"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "ERRORBAR")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"ERRORBAR"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "PARETO")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"PARETO"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "TITLE")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"TITLE"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "SUBTITLE")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"SUBTITLE"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "FOOTNOTE")) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("%s is not yet implemented."),"FOOTNOTE"); - goto error; - } + goto error; + } else if (lex_match_id (lexer, "MISSING")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { if (lex_match_id (lexer, "LISTWISE")) graph.missing_pw = false; else if (lex_match_id (lexer, "VARIABLE")) @@ -904,10 +904,10 @@ cmd_graph (struct lexer *lexer, struct dataset *ds) /* y value - SP_IDX_Y*/ graph.gr_proto = caseproto_add_width (graph.gr_proto, 0); /* The by_var contains the plot categories for the different xy - plot colors */ + plot colors */ if (graph.n_by_vars > 0) /* SP_IDX_BY */ - graph.gr_proto = caseproto_add_width (graph.gr_proto, - var_get_width(graph.by_var[0])); + graph.gr_proto = caseproto_add_width (graph.gr_proto, + var_get_width(graph.by_var[0])); break; case CT_HISTOGRAM: diff --git a/src/language/commands/include.c b/src/language/commands/include.c index f02291e5e7..b164365536 100644 --- a/src/language/commands/include.c +++ b/src/language/commands/include.c @@ -81,60 +81,60 @@ do_insert (struct lexer *lexer, struct dataset *ds, enum variant variant) free (encoding); encoding = xstrdup (lex_tokcstr (lexer)); - lex_get (lexer); + lex_get (lexer); } else if (variant == INSERT && lex_match_id (lexer, "SYNTAX")) - { - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "INTERACTIVE")) - syntax_mode = SEG_MODE_INTERACTIVE; - else if (lex_match_id (lexer, "BATCH")) - syntax_mode = SEG_MODE_BATCH; - else if (lex_match_id (lexer, "AUTO")) - syntax_mode = SEG_MODE_AUTO; - else - { - lex_error_expecting (lexer, "BATCH", "INTERACTIVE", "AUTO"); - goto exit; - } - } + { + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "INTERACTIVE")) + syntax_mode = SEG_MODE_INTERACTIVE; + else if (lex_match_id (lexer, "BATCH")) + syntax_mode = SEG_MODE_BATCH; + else if (lex_match_id (lexer, "AUTO")) + syntax_mode = SEG_MODE_AUTO; + else + { + lex_error_expecting (lexer, "BATCH", "INTERACTIVE", "AUTO"); + goto exit; + } + } else if (variant == INSERT && lex_match_id (lexer, "CD")) - { - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "YES")) + { + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "YES")) cd = true; - else if (lex_match_id (lexer, "NO")) + else if (lex_match_id (lexer, "NO")) cd = false; - else - { - lex_error_expecting (lexer, "YES", "NO"); - goto exit; - } - } + else + { + lex_error_expecting (lexer, "YES", "NO"); + goto exit; + } + } else if (variant == INSERT && lex_match_id (lexer, "ERROR")) - { - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "CONTINUE")) + { + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "CONTINUE")) error_mode = LEX_ERROR_CONTINUE; - else if (lex_match_id (lexer, "STOP")) + else if (lex_match_id (lexer, "STOP")) error_mode = LEX_ERROR_STOP; else if (settings_get_testing_mode () && lex_match_id (lexer, "IGNORE")) error_mode = LEX_ERROR_IGNORE; - else - { - lex_error_expecting (lexer, "CONTINUE", "STOP"); - goto exit; - } - } + else + { + lex_error_expecting (lexer, "CONTINUE", "STOP"); + goto exit; + } + } else - { + { if (variant == INSERT) lex_error_expecting (lexer, "ENCODING", "SYNTAX", "CD", "ERROR"); else lex_error_expecting (lexer, "ENCODING"); - goto exit; - } + goto exit; + } } status = lex_end_of_command (lexer); diff --git a/src/language/commands/inpt-pgm.c b/src/language/commands/inpt-pgm.c index f6beea1f54..ff07dc9650 100644 --- a/src/language/commands/inpt-pgm.c +++ b/src/language/commands/inpt-pgm.c @@ -286,8 +286,8 @@ static const struct trns_class end_case_trns_class = { /* REREAD transformation. */ struct reread_trns { - struct dfm_reader *reader; /* File to move file pointer back on. */ - struct expression *column; /* Column to reset file pointer to. */ + struct dfm_reader *reader; /* File to move file pointer back on. */ + struct expression *column; /* Column to reset file pointer to. */ }; /* Parses REREAD command. */ @@ -300,43 +300,43 @@ cmd_reread (struct lexer *lexer, struct dataset *ds) while (lex_token (lexer) != T_ENDCMD) { if (lex_match_id (lexer, "COLUMN")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - if (e) - { + if (e) + { lex_sbc_only_once (lexer, "COLUMN"); goto error; - } + } - e = expr_parse (lexer, ds, VAL_NUMERIC); - if (!e) + e = expr_parse (lexer, ds, VAL_NUMERIC); + if (!e) goto error; - } + } else if (lex_match_id (lexer, "FILE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); fh_unref (fh); fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); - if (fh == NULL) + if (fh == NULL) goto error; - } + } else if (lex_match_id (lexer, "ENCODING")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto error; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } else - { - lex_error_expecting (lexer, "COLUMN", "FILE", "ENCODING"); + { + lex_error_expecting (lexer, "COLUMN", "FILE", "ENCODING"); goto error; - } + } } struct reread_trns *t = xmalloc (sizeof *t); @@ -368,13 +368,13 @@ reread_trns_proc (void *t_, struct ccase **c, casenumber case_num) { double column = expr_evaluate_num (t->column, *c, case_num); if (!isfinite (column) || column < 1) - { - msg (SE, _("REREAD: Column numbers must be positive finite " - "numbers. Column set to 1.")); - dfm_reread_record (t->reader, 1); - } + { + msg (SE, _("REREAD: Column numbers must be positive finite " + "numbers. Column set to 1.")); + dfm_reread_record (t->reader, 1); + } else - dfm_reread_record (t->reader, column); + dfm_reread_record (t->reader, column); } return TRNS_CONTINUE; } diff --git a/src/language/commands/jonckheere-terpstra.c b/src/language/commands/jonckheere-terpstra.c index f8f4fbbecb..4f7b88ea29 100644 --- a/src/language/commands/jonckheere-terpstra.c +++ b/src/language/commands/jonckheere-terpstra.c @@ -119,7 +119,7 @@ u (const struct group_data *grp0, const struct group_data *grp1) else if (x0 < x1) { usum += w0 * (grp1->cc - prev_cc1); - case_unref (c1); + case_unref (c1); break; } else @@ -129,7 +129,7 @@ u (const struct group_data *grp0, const struct group_data *grp1) #else usum += w0 * (grp1->cc - (prev_cc1 + cc1) / 2.0); #endif - case_unref (c1); + case_unref (c1); break; } @@ -227,11 +227,11 @@ static void show_jt (const struct n_sample_test *, const struct jt *, void jonckheere_terpstra_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int v; bool warn = true; @@ -244,16 +244,16 @@ jonckheere_terpstra_execute (const struct dataset *ds, /* If the independent variable is missing, then we ignore the case */ input = casereader_create_filter_missing (input, - &nst->indep_var, 1, - exclude, - NULL, NULL); + &nst->indep_var, 1, + exclude, + NULL, NULL); /* Remove cases with invalid weigths */ 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, - CONST_CAST (struct n_sample_test *, nst), NULL); + CONST_CAST (struct n_sample_test *, nst), NULL); /* Sort the data by the independent variable */ input = sort_execute_1var (input, nst->indep_var); @@ -328,7 +328,7 @@ jonckheere_terpstra_execute (const struct dataset *ds, for (i = 0; i < 3; ++i) sums[i] += mff[i] (grp[g0].cc); - casereader_destroy (grp[g0].reader); + casereader_destroy (grp[g0].reader); } free (grp); diff --git a/src/language/commands/jonckheere-terpstra.h b/src/language/commands/jonckheere-terpstra.h index 6d91de7bda..22fe2b0424 100644 --- a/src/language/commands/jonckheere-terpstra.h +++ b/src/language/commands/jonckheere-terpstra.h @@ -31,11 +31,11 @@ struct casereader; struct dataset; void jonckheere_terpstra_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer - ); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer + ); #endif diff --git a/src/language/commands/kruskal-wallis.c b/src/language/commands/kruskal-wallis.c index 6d54bae782..93c4781168 100644 --- a/src/language/commands/kruskal-wallis.c +++ b/src/language/commands/kruskal-wallis.c @@ -110,7 +110,7 @@ find_rank_entry (const struct hmap *map, const union value *group, size_t width) HMAP_FOR_EACH_WITH_HASH (re, struct rank_entry, node, hash, map) { if (0 == value_compare_3way (group, &re->group, width)) - return re; + return re; } return re; @@ -137,11 +137,11 @@ static void show_sig_box (const struct n_sample_test *, const struct kw *); void kruskal_wallis_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int i; struct ccase *c; @@ -157,15 +157,15 @@ kruskal_wallis_execute (const struct dataset *ds, /* If the independent variable is missing, then we ignore the case */ input = casereader_create_filter_missing (input, - &nst->indep_var, 1, - exclude, - NULL, NULL); + &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, - CONST_CAST (struct n_sample_test *, nst), NULL); + CONST_CAST (struct n_sample_test *, nst), NULL); proto = casereader_get_proto (input); rank_idx = caseproto_get_n_widths (proto); @@ -183,57 +183,57 @@ kruskal_wallis_execute (const struct dataset *ds, /* Ignore missings in the test variable */ r = casereader_create_filter_missing (r, &nst->vars[i], 1, - exclude, - NULL, NULL); + exclude, + NULL, NULL); rr = casereader_create_append_rank (r, - nst->vars[i], - dict_get_weight (dict), - &rerr, - distinct_callback, &tiebreaker); + nst->vars[i], + dict_get_weight (dict), + &rerr, + distinct_callback, &tiebreaker); hmap_init (&kw[i].map); for (; (c = casereader_read (rr)); case_unref (c)) - { - 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); + { + 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); - if (NULL == rank) - { - rank = xzalloc (sizeof *rank); - value_clone (&rank->group, group, group_var_width); + if (NULL == rank) + { + rank = xzalloc (sizeof *rank); + value_clone (&rank->group, group, group_var_width); - hmap_insert (&kw[i].map, &rank->node, - value_hash (&rank->group, group_var_width, 0)); - } + hmap_insert (&kw[i].map, &rank->node, + value_hash (&rank->group, group_var_width, 0)); + } - rank->sum_of_ranks += case_num_idx (c, rank_idx); - rank->n += dict_get_case_weight (dict, c, &warn); + rank->sum_of_ranks += case_num_idx (c, rank_idx); + rank->n += dict_get_case_weight (dict, c, &warn); - /* If this assertion fires, then either the data wasn't sorted or some other - problem occurred */ - assert (rerr == 0); - } + /* If this assertion fires, then either the data wasn't sorted or some other + problem occurred */ + assert (rerr == 0); + } casereader_destroy (rr); /* Calculate the value of h */ { - struct rank_entry *mre; - double n = 0.0; + struct rank_entry *mre; + double n = 0.0; - HMAP_FOR_EACH (mre, struct rank_entry, node, &kw[i].map) - { - kw[i].h += pow2 (mre->sum_of_ranks) / mre->n; - n += mre->n; + HMAP_FOR_EACH (mre, struct rank_entry, node, &kw[i].map) + { + kw[i].h += pow2 (mre->sum_of_ranks) / mre->n; + n += mre->n; - total_n_groups ++; - } - kw[i].h *= 12 / (n * (n + 1)); - kw[i].h -= 3 * (n + 1) ; + total_n_groups ++; + } + kw[i].h *= 12 / (n * (n + 1)); + kw[i].h -= 3 * (n + 1) ; - kw[i].h /= 1 - tiebreaker/ (pow3 (n) - n); + kw[i].h /= 1 - tiebreaker/ (pow3 (n) - n); } } @@ -247,10 +247,10 @@ kruskal_wallis_execute (const struct dataset *ds, { struct rank_entry *mre, *next; HMAP_FOR_EACH_SAFE (mre, next, struct rank_entry, node, &kw[i].map) - { - hmap_delete (&kw[i].map, &mre->node); - free (mre); - } + { + hmap_delete (&kw[i].map, &mre->node); + free (mre); + } hmap_destroy (&kw[i].map); } @@ -285,8 +285,8 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw) const struct rank_entry *re; BT_FOR_EACH (re, struct rank_entry, btn, &bt) { - struct string str = DS_EMPTY_INITIALIZER; - var_append_value_name (nst->indep_var, &re->group, &str); + struct string str = DS_EMPTY_INITIALIZER; + var_append_value_name (nst->indep_var, &re->group, &str); int row = pivot_category_create_leaf ( group, pivot_value_new_user_text_nocopy (ds_steal_cstr (&str))); @@ -295,8 +295,8 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw) pivot_table_put2 (table, j, row, pivot_value_new_number (entries[j])); - tot += re->n; - } + tot += re->n; + } int row = pivot_category_create_leaves (group, N_("Total")); pivot_table_put2 (table, 0, row, pivot_value_new_number (tot)); diff --git a/src/language/commands/kruskal-wallis.h b/src/language/commands/kruskal-wallis.h index 06109c55d7..0eef0a978f 100644 --- a/src/language/commands/kruskal-wallis.h +++ b/src/language/commands/kruskal-wallis.h @@ -31,11 +31,11 @@ struct casereader; struct dataset; void kruskal_wallis_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer - ); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer + ); #endif diff --git a/src/language/commands/ks-one-sample.c b/src/language/commands/ks-one-sample.c index b3e250aea8..6055b1b871 100644 --- a/src/language/commands/ks-one-sample.c +++ b/src/language/commands/ks-one-sample.c @@ -131,10 +131,10 @@ static void show_results (const struct ks *, const struct ks_one_sample_test *, void ks_one_sample_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool x UNUSED, double y UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool x UNUSED, double y UNUSED) { const struct dictionary *dict = dataset_dict (ds); const struct ks_one_sample_test *kst = UP_CAST (test, const struct ks_one_sample_test, parent.parent); @@ -163,20 +163,20 @@ ks_one_sample_execute (const struct dataset *ds, const double weight = dict_get_case_weight (dict, c, &warn); for (v = 0; v < ost->n_vars; ++v) - { - const struct variable *var = ost->vars[v]; - const union value *val = case_data (c, var); + { + const struct variable *var = ost->vars[v]; + const union value *val = case_data (c, var); - if (var_is_value_missing (var, val) & exclude) - continue; + if (var_is_value_missing (var, val) & exclude) + continue; - minimize (&ks[v].test_min, val->f); - maximize (&ks[v].test_max, val->f); + minimize (&ks[v].test_min, val->f); + maximize (&ks[v].test_max, val->f); - ks[v].obs_cc += weight; - ks[v].sum += val->f; - ks[v].ssq += pow2 (val->f); - } + ks[v].obs_cc += weight; + ks[v].sum += val->f; + ks[v].ssq += pow2 (val->f); + } } casereader_destroy (r); @@ -187,73 +187,73 @@ ks_one_sample_execute (const struct dataset *ds, double prev_empirical = 0; switch (kst->dist) - { - case KS_UNIFORM: - if (kst->p[0] != SYSMIS) - ks[v].test_min = kst->p[0]; - - if (kst->p[1] != SYSMIS) - ks[v].test_max = kst->p[1]; - break; - case KS_NORMAL: - if (kst->p[0] != SYSMIS) - ks[v].mu = kst->p[0]; - else - ks[v].mu = ks[v].sum / ks[v].obs_cc; - - if (kst->p[1] != SYSMIS) - ks[v].sigma = kst->p[1]; - else - { - ks[v].sigma = ks[v].ssq - pow2 (ks[v].sum) / ks[v].obs_cc; - ks[v].sigma /= ks[v].obs_cc - 1; - ks[v].sigma = sqrt (ks[v].sigma); - } - - break; - case KS_POISSON: - case KS_EXPONENTIAL: - if (kst->p[0] != SYSMIS) - ks[v].mu = ks[v].sigma = kst->p[0]; - else - ks[v].mu = ks[v].sigma = ks[v].sum / ks[v].obs_cc; - break; - default: - NOT_REACHED (); - } + { + case KS_UNIFORM: + if (kst->p[0] != SYSMIS) + ks[v].test_min = kst->p[0]; + + if (kst->p[1] != SYSMIS) + ks[v].test_max = kst->p[1]; + break; + case KS_NORMAL: + if (kst->p[0] != SYSMIS) + ks[v].mu = kst->p[0]; + else + ks[v].mu = ks[v].sum / ks[v].obs_cc; + + if (kst->p[1] != SYSMIS) + ks[v].sigma = kst->p[1]; + else + { + ks[v].sigma = ks[v].ssq - pow2 (ks[v].sum) / ks[v].obs_cc; + ks[v].sigma /= ks[v].obs_cc - 1; + ks[v].sigma = sqrt (ks[v].sigma); + } + + break; + case KS_POISSON: + case KS_EXPONENTIAL: + if (kst->p[0] != SYSMIS) + ks[v].mu = ks[v].sigma = kst->p[0]; + else + ks[v].mu = ks[v].sigma = ks[v].sum / ks[v].obs_cc; + break; + default: + NOT_REACHED (); + } r = sort_execute_1var (casereader_clone (input), var); for (; (c = casereader_read (r)) != NULL; case_unref (c)) - { - double theoretical, empirical; - double d, dp; - const double weight = dict_get_case_weight (dict, c, &warn); - const union value *val = case_data (c, var); + { + double theoretical, empirical; + double d, dp; + const double weight = dict_get_case_weight (dict, c, &warn); + const union value *val = case_data (c, var); - if (var_is_value_missing (var, val) & exclude) - continue; + if (var_is_value_missing (var, val) & exclude) + continue; - cc += weight; + cc += weight; - empirical = cc / ks[v].obs_cc; + empirical = cc / ks[v].obs_cc; - theoretical = theoreticalf[kst->dist] (&ks[v], val->f); + theoretical = theoreticalf[kst->dist] (&ks[v], val->f); - d = empirical - theoretical; - dp = prev_empirical - theoretical; + d = empirical - theoretical; + dp = prev_empirical - theoretical; - if (d > 0) - maximize (&ks[v].diff_pos, d); - else - minimize (&ks[v].diff_neg, d); + if (d > 0) + maximize (&ks[v].diff_pos, d); + else + minimize (&ks[v].diff_neg, d); - if (dp > 0) - maximize (&ks[v].diff_pos, dp); - else - minimize (&ks[v].diff_neg, dp); + if (dp > 0) + maximize (&ks[v].diff_pos, dp); + else + minimize (&ks[v].diff_neg, dp); - prev_empirical = empirical; - } + prev_empirical = empirical; + } casereader_destroy (r); } @@ -267,8 +267,8 @@ ks_one_sample_execute (const struct dataset *ds, static void show_results (const struct ks *ks, - const struct ks_one_sample_test *kst, - const struct fmt_spec wfmt) + const struct ks_one_sample_test *kst, + const struct fmt_spec wfmt) { struct pivot_table *table = pivot_table_create ( N_("One-Sample Kolmogorov-Smirnov Test")); @@ -326,25 +326,25 @@ show_results (const struct ks *ks, values[n++] = ks[i].obs_cc; switch (kst->dist) - { - case KS_UNIFORM: + { + case KS_UNIFORM: values[n++] = ks[i].test_min; values[n++] = ks[i].test_max; - break; + break; - case KS_NORMAL: + case KS_NORMAL: values[n++] = ks[i].mu; values[n++] = ks[i].sigma; - break; + break; - case KS_POISSON: - case KS_EXPONENTIAL: + case KS_POISSON: + case KS_EXPONENTIAL: values[n++] = ks[i].mu; - break; + break; - default: - NOT_REACHED (); - } + default: + NOT_REACHED (); + } double abs = ks[i].diff_pos; maximize (&abs, -ks[i].diff_neg); diff --git a/src/language/commands/ks-one-sample.h b/src/language/commands/ks-one-sample.h index 6bb827b661..634e631461 100644 --- a/src/language/commands/ks-one-sample.h +++ b/src/language/commands/ks-one-sample.h @@ -42,9 +42,9 @@ struct dataset; void ks_one_sample_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool, double); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool, double); #endif diff --git a/src/language/commands/logistic.c b/src/language/commands/logistic.c index 5e591f34c0..9750c3a54a 100644 --- a/src/language/commands/logistic.c +++ b/src/language/commands/logistic.c @@ -209,10 +209,10 @@ static void output_categories (const struct lr_spec *cmd, const struct lr_result static void output_depvarmap (const struct lr_spec *cmd, const struct lr_result *); static void output_variables (const struct lr_spec *cmd, - const struct lr_result *); + const struct lr_result *); static void output_model_summary (const struct lr_result *, - double initial_likelihood, double likelihood); + double initial_likelihood, double likelihood); static void case_processing_summary (const struct lr_result *); @@ -247,9 +247,9 @@ predictor_value (const struct ccase *c, */ 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) + const struct lr_result *res, + const struct variable **x, size_t n_x, + const struct ccase *c) { int v0; double pi = 0; @@ -264,7 +264,7 @@ pi_hat (const struct lr_spec *cmd, for (v0 = 0; v0 < n_coeffs; ++v0) { pi += gsl_vector_get (res->beta_hat, v0) * - predictor_value (c, x, n_x, res->cats, v0); + predictor_value (c, x, n_x, res->cats, v0); } pi = 1.0 / (1.0 + exp(-pi)); @@ -284,10 +284,10 @@ pi_hat (const struct lr_spec *cmd, */ static void hessian (const struct lr_spec *cmd, - struct lr_result *res, - struct casereader *input, - const struct variable **x, size_t n_x, - bool *converged) + struct lr_result *res, + struct casereader *input, + const struct variable **x, size_t n_x, + bool *converged) { struct casereader *reader; struct ccase *c; @@ -305,19 +305,19 @@ hessian (const struct lr_spec *cmd, double weight = dict_get_case_weight (cmd->dict, c, &res->warn_bad_weight); double w = pi * (1 - pi); if (w > max_w) - max_w = w; + max_w = w; w *= weight; for (v0 = 0; v0 < res->beta_hat->size; ++v0) - { - double in0 = predictor_value (c, x, n_x, res->cats, v0); - for (v1 = 0; v1 < res->beta_hat->size; ++v1) - { - double in1 = predictor_value (c, x, n_x, res->cats, v1); - double *o = gsl_matrix_ptr (res->hessian, v0, v1); - *o += in0 * w * in1; - } - } + { + double in0 = predictor_value (c, x, n_x, res->cats, v0); + for (v1 = 0; v1 < res->beta_hat->size; ++v1) + { + double in1 = predictor_value (c, x, n_x, res->cats, v1); + double *o = gsl_matrix_ptr (res->hessian, v0, v1); + *o += in0 * w * in1; + } + } } casereader_destroy (reader); @@ -340,11 +340,11 @@ hessian (const struct lr_spec *cmd, */ static gsl_vector * xt_times_y_pi (const struct lr_spec *cmd, - struct lr_result *res, - struct casereader *input, - const struct variable **x, size_t n_x, - const struct variable *y_var, - double *llikelihood) + struct lr_result *res, + struct casereader *input, + const struct variable **x, size_t n_x, + const struct variable *y_var, + double *llikelihood) { struct casereader *reader; struct ccase *c; @@ -366,29 +366,29 @@ xt_times_y_pi (const struct lr_spec *cmd, *llikelihood += (weight * y) * log (pi) + log (1 - pi) * weight * (1 - y); for (v0 = 0; v0 < res->beta_hat->size; ++v0) - { - double in0 = predictor_value (c, x, n_x, res->cats, v0); - double *o = gsl_vector_ptr (output, v0); - *o += in0 * (y - pi) * weight; - pred_y += gsl_vector_get (res->beta_hat, v0) * in0; - } + { + double in0 = predictor_value (c, x, n_x, res->cats, v0); + double *o = gsl_vector_ptr (output, v0); + *o += in0 * (y - pi) * weight; + pred_y += gsl_vector_get (res->beta_hat, v0) * in0; + } /* Count the number of cases which would be correctly/incorrectly classified by this - estimated model */ + estimated model */ if (pred_y <= cmd->ilogit_cut_point) - { - if (y == 0) - res->tn += weight; - else - res->fn += weight; - } + { + if (y == 0) + res->tn += weight; + else + res->fn += weight; + } else - { - if (y == 0) - res->fp += weight; - else - res->tp += weight; - } + { + if (y == 0) + res->fp += weight; + else + res->tp += weight; + } } casereader_destroy (reader); @@ -411,7 +411,7 @@ frq_create (const void *aux1 UNUSED, void *aux2 UNUSED) static void frq_update (const void *aux1 UNUSED, void *aux2 UNUSED, - void *ud, const struct ccase *c UNUSED , double weight) + void *ud, const struct ccase *c UNUSED , double weight) { double *freq = ud; *freq += weight; @@ -464,7 +464,7 @@ initial_pass (const struct lr_spec *cmd, struct lr_result *res, struct casereade res->cp.destroy = frq_destroy; res->cats = categoricals_create (cmd->cat_predictors, cmd->n_cat_predictors, - cmd->wv, MV_ANY); + cmd->wv, MV_ANY); categoricals_set_payload (res->cats, &res->cp, cmd, res); } @@ -479,60 +479,60 @@ initial_pass (const struct lr_spec *cmd, struct lr_result *res, struct casereade const union value *depval = case_data (c, cmd->dep_var); if (var_is_value_missing (cmd->dep_var, depval) & cmd->exclude) - { - missing = true; - } + { + missing = true; + } else for (v = 0; v < cmd->n_indep_vars; ++v) - { - const union value *val = case_data (c, cmd->indep_vars[v]); - if (var_is_value_missing (cmd->indep_vars[v], val) & cmd->exclude) - { - missing = true; - break; - } - } + { + const union value *val = case_data (c, cmd->indep_vars[v]); + if (var_is_value_missing (cmd->indep_vars[v], val) & cmd->exclude) + { + missing = true; + break; + } + } /* Accumulate the missing and non-missing counts */ if (missing) - { - res->n_missing++; - continue; - } + { + res->n_missing++; + continue; + } res->n_nonmissing++; /* Find the values of the dependent variable */ if (!v0set) - { - value_clone (&res->y0, depval, width); - v0set = true; - } + { + value_clone (&res->y0, depval, width); + v0set = true; + } else if (!v1set) - { - if (!value_equal (&res->y0, depval, width)) - { - value_clone (&res->y1, depval, width); - v1set = true; - } - } + { + if (!value_equal (&res->y0, depval, width)) + { + value_clone (&res->y1, depval, width); + v1set = true; + } + } else - { - if (!value_equal (&res->y0, depval, width) - && - !value_equal (&res->y1, depval, width) - ) - { - msg (ME, _("Dependent variable's values are not dichotomous.")); + { + if (!value_equal (&res->y0, depval, width) + && + !value_equal (&res->y1, depval, width) + ) + { + msg (ME, _("Dependent variable's values are not dichotomous.")); case_unref (c); - goto error; - } - } + goto error; + } + } if (v0set && value_equal (&res->y0, depval, width)) - sumA += weight; + sumA += weight; if (v1set && value_equal (&res->y1, depval, width)) - sumB += weight; + sumB += weight; res->cc += weight; @@ -578,7 +578,7 @@ initial_pass (const struct lr_spec *cmd, struct lr_result *res, struct casereade /* Start of the logistic regression routine proper */ static bool run_lr (const struct lr_spec *cmd, struct casereader *input, - const struct dataset *ds UNUSED) + const struct dataset *ds UNUSED) { int i; @@ -605,17 +605,17 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, for (i = 0; i < cmd->n_cat_predictors; ++i) { if (1 >= categoricals_n_count (work.cats, i)) - { - struct string str; - ds_init_empty (&str); + { + struct string str; + ds_init_empty (&str); - interaction_to_string (cmd->cat_predictors[i], &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."), - ds_cstr(&str)); - ds_destroy (&str); - goto error; - } + msg (ME, _("Category %s does not have at least two distinct values. Logistic regression will not be run."), + ds_cstr(&str)); + ds_destroy (&str); + goto error; + } } output_depvarmap (cmd, &work); @@ -624,18 +624,18 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, input = casereader_create_filter_missing (input, - cmd->indep_vars, - cmd->n_indep_vars, - cmd->exclude, - NULL, - NULL); + cmd->indep_vars, + cmd->n_indep_vars, + cmd->exclude, + NULL, + NULL); input = casereader_create_filter_missing (input, - &cmd->dep_var, - 1, - cmd->exclude, - NULL, - NULL); + &cmd->dep_var, + 1, + cmd->exclude, + NULL, + NULL); work.hessian = gsl_matrix_calloc (work.beta_hat->size, work.beta_hat->size); @@ -647,52 +647,52 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, hessian (cmd, &work, input, - cmd->predictor_vars, cmd->n_predictor_vars, - &converged); + cmd->predictor_vars, cmd->n_predictor_vars, + &converged); gsl_linalg_cholesky_decomp (work.hessian); gsl_linalg_cholesky_invert (work.hessian); v = xt_times_y_pi (cmd, &work, input, - cmd->predictor_vars, cmd->n_predictor_vars, - cmd->dep_var, - &log_likelihood); + cmd->predictor_vars, cmd->n_predictor_vars, + cmd->dep_var, + &log_likelihood); { - /* delta = M.v */ - gsl_vector *delta = gsl_vector_alloc (v->size); - gsl_blas_dgemv (CblasNoTrans, 1.0, work.hessian, v, 0, delta); - gsl_vector_free (v); + /* delta = M.v */ + gsl_vector *delta = gsl_vector_alloc (v->size); + gsl_blas_dgemv (CblasNoTrans, 1.0, work.hessian, v, 0, delta); + gsl_vector_free (v); - gsl_vector_add (work.beta_hat, delta); + gsl_vector_add (work.beta_hat, delta); - gsl_vector_minmax (delta, &min, &max); + gsl_vector_minmax (delta, &min, &max); - if (fabs (min) < cmd->bcon && fabs (max) < cmd->bcon) - { - msg (MN, _("Estimation terminated at iteration number %d because parameter estimates changed by less than %g"), - i + 1, cmd->bcon); - converged = true; - } + if (fabs (min) < cmd->bcon && fabs (max) < cmd->bcon) + { + msg (MN, _("Estimation terminated at iteration number %d because parameter estimates changed by less than %g"), + i + 1, cmd->bcon); + converged = true; + } - gsl_vector_free (delta); + gsl_vector_free (delta); } if (i > 0) - { - if (-log_likelihood > -(1.0 - cmd->lcon) * prev_log_likelihood) - { - msg (MN, _("Estimation terminated at iteration number %d because Log Likelihood decreased by less than %g%%"), i + 1, 100 * cmd->lcon); - converged = true; - } - } + { + if (-log_likelihood > -(1.0 - cmd->lcon) * prev_log_likelihood) + { + msg (MN, _("Estimation terminated at iteration number %d because Log Likelihood decreased by less than %g%%"), i + 1, 100 * cmd->lcon); + converged = true; + } + } if (i == 0) - initial_log_likelihood = log_likelihood; + initial_log_likelihood = log_likelihood; prev_log_likelihood = log_likelihood; if (converged) - break; + break; } @@ -788,7 +788,7 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) goto error; if (!parse_variables_const (lexer, lr.dict, &pred_vars, &n_pred_vars, - PV_NO_DUPLICATE)) + PV_NO_DUPLICATE)) goto error; while (lex_token (lexer) != T_ENDCMD) @@ -796,22 +796,22 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "MISSING")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "INCLUDE")) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "INCLUDE")) lr.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) lr.exclude = MV_ANY; - else - { - lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); + goto error; + } + } + } else if (lex_match_id (lexer, "ORIGIN")) lr.constant = false; else if (lex_match_id (lexer, "NOORIGIN")) @@ -819,12 +819,12 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) else if (lex_match_id (lexer, "NOCONST")) lr.constant = false; else if (lex_match_id (lexer, "EXTERNAL")) - { - /* This is for compatibility. It does nothing */ - } + { + /* This is for compatibility. It does nothing */ + } else if (lex_match_id (lexer, "CATEGORICAL")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); struct variable **cats; size_t n_cats; if (!parse_variables (lexer, lr.dict, &cats, &n_cats, PV_NO_DUPLICATE)) @@ -836,96 +836,96 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) for (size_t i = 0; i < n_cats; i++) lr.cat_predictors[lr.n_cat_predictors++] = interaction_create (cats[i]); free (cats); - } + } else if (lex_match_id (lexer, "PRINT")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "DEFAULT")) + { + if (lex_match_id (lexer, "DEFAULT")) lr.print |= PRINT_DEFAULT; - else if (lex_match_id (lexer, "SUMMARY")) + else if (lex_match_id (lexer, "SUMMARY")) lr.print |= PRINT_SUMMARY; #if 0 - else if (lex_match_id (lexer, "CORR")) + else if (lex_match_id (lexer, "CORR")) lr.print |= PRINT_CORR; - else if (lex_match_id (lexer, "ITER")) + else if (lex_match_id (lexer, "ITER")) lr.print |= PRINT_ITER; - else if (lex_match_id (lexer, "GOODFIT")) + else if (lex_match_id (lexer, "GOODFIT")) lr.print |= PRINT_GOODFIT; #endif - else if (lex_match_id (lexer, "CI")) - { - lr.print |= PRINT_CI; - if (!lex_force_match (lexer, T_LPAREN) + else if (lex_match_id (lexer, "CI")) + { + lr.print |= PRINT_CI; + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; lr.confidence = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "ALL")) + } + else if (lex_match_id (lexer, "ALL")) lr.print = ~0x0000; - else - { - lex_error_expecting (lexer, "DEFAULT", "SUMMARY", + else + { + lex_error_expecting (lexer, "DEFAULT", "SUMMARY", #if 0 "CORR", "ITER", "GOODFIT", #endif "CI", "ALL"); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "CRITERIA")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "BCON")) - { - if (!lex_force_match (lexer, T_LPAREN) + { + if (lex_match_id (lexer, "BCON")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; lr.bcon = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "ITERATE")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "ITERATE")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_int_range (lexer, "ITERATE", 0, INT_MAX)) goto error; lr.max_iter = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "LCON")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "LCON")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; lr.lcon = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "EPS")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "EPS")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) goto error; lr.min_epsilon = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else if (lex_match_id (lexer, "CUT")) - { - if (!lex_force_match (lexer, T_LPAREN) + } + else if (lex_match_id (lexer, "CUT")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num_range_closed (lexer, "CUT", 0, 1)) goto error; @@ -934,22 +934,22 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) goto error; - } - else - { - lex_error_expecting (lexer, "BCON", "ITERATE", "LCON", "EPS", + } + else + { + lex_error_expecting (lexer, "BCON", "ITERATE", "LCON", "EPS", "CUT"); - goto error; - } - } - } + goto error; + } + } + } else - { - lex_error_expecting (lexer, "MISSING", "ORIGIN", "NOORIGIN", + { + lex_error_expecting (lexer, "MISSING", "ORIGIN", "NOORIGIN", "NOCONST", "EXTERNAL", "CATEGORICAL", "PRINT", "CRITERIA"); - goto error; - } + goto error; + } } lr.ilogit_cut_point = - log (1/cp - 1); @@ -969,21 +969,21 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) insert_variable (&allvars, var, hash); for (size_t cv = 0; cv < lr.n_cat_predictors; ++cv) - { - const struct interaction *iact = lr.cat_predictors[cv]; - for (size_t iv = 0; iv < iact->n_vars; ++iv) - { - const struct variable *ivar = iact->vars[iv]; - unsigned int hash = hash_pointer (ivar, 0); - insert_variable (&allvars, ivar, hash); - - if (var == ivar) + { + const struct interaction *iact = lr.cat_predictors[cv]; + for (size_t iv = 0; iv < iact->n_vars; ++iv) + { + const struct variable *ivar = iact->vars[iv]; + unsigned int hash = hash_pointer (ivar, 0); + insert_variable (&allvars, ivar, hash); + + if (var == ivar) drop = true; - } - } + } + } if (drop) - continue; + continue; if (lr.n_predictor_vars >= allocated_predictor_vars) lr.predictor_vars = x2nrealloc (lr.predictor_vars, @@ -1072,7 +1072,7 @@ output_depvarmap (const struct lr_spec *cmd, const struct lr_result *res) /* Show the Variables in the Equation box */ static void output_variables (const struct lr_spec *cmd, - const struct lr_result *res) + const struct lr_result *res) { struct pivot_table *table = pivot_table_create ( N_("Variables in the Equation")); @@ -1118,58 +1118,58 @@ output_variables (const struct lr_spec *cmd, var_idx = pivot_category_create_leaf ( step1, pivot_value_new_variable (cmd->predictor_vars[idx])); else if (i < cmd->n_cat_predictors) - { - const struct interaction *cat_predictors = cmd->cat_predictors[i]; - struct string str = DS_EMPTY_INITIALIZER; - interaction_to_string (cat_predictors, &str); - if (ivar != 0) + { + const struct interaction *cat_predictors = cmd->cat_predictors[i]; + struct string str = DS_EMPTY_INITIALIZER; + interaction_to_string (cat_predictors, &str); + if (ivar != 0) ds_put_format (&str, "(%d)", ivar); var_idx = pivot_category_create_leaf ( step1, pivot_value_new_user_text_nocopy (ds_steal_cstr (&str))); - int df = categoricals_df (res->cats, i); - bool summary = ivar == 0; + int df = categoricals_df (res->cats, i); + bool summary = ivar == 0; if (summary) - { - /* 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 - hessian matrix. - */ - gsl_matrix_const_view mv = - gsl_matrix_const_submatrix (res->hessian, idx, idx, df, df); - gsl_matrix *subhessian = gsl_matrix_alloc (mv.matrix.size1, mv.matrix.size2); - gsl_vector_const_view vv = gsl_vector_const_subvector (res->beta_hat, idx, df); - gsl_vector *temp = gsl_vector_alloc (df); - - gsl_matrix_memcpy (subhessian, &mv.matrix); - gsl_linalg_cholesky_decomp (subhessian); - gsl_linalg_cholesky_invert (subhessian); - - gsl_blas_dgemv (CblasTrans, 1.0, subhessian, &vv.vector, 0, temp); + { + /* 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 + hessian matrix. + */ + gsl_matrix_const_view mv = + gsl_matrix_const_submatrix (res->hessian, idx, idx, df, df); + gsl_matrix *subhessian = gsl_matrix_alloc (mv.matrix.size1, mv.matrix.size2); + gsl_vector_const_view vv = gsl_vector_const_subvector (res->beta_hat, idx, df); + gsl_vector *temp = gsl_vector_alloc (df); + + gsl_matrix_memcpy (subhessian, &mv.matrix); + gsl_linalg_cholesky_decomp (subhessian); + gsl_linalg_cholesky_invert (subhessian); + + gsl_blas_dgemv (CblasTrans, 1.0, subhessian, &vv.vector, 0, temp); double wald; - gsl_blas_ddot (temp, &vv.vector, &wald); + gsl_blas_ddot (temp, &vv.vector, &wald); double entries[] = { wald, df, gsl_cdf_chisq_Q (wald, df) }; for (size_t j = 0; j < sizeof entries / sizeof *entries; j++) pivot_table_put2 (table, j + 2, var_idx, pivot_value_new_number (entries[j])); - idx_correction++; - gsl_matrix_free (subhessian); - gsl_vector_free (temp); - } + idx_correction++; + gsl_matrix_free (subhessian); + gsl_vector_free (temp); + } - if (ivar++ == df) - { - ++i; /* next interaction */ - ivar = 0; - } + if (ivar++ == df) + { + ++i; /* next interaction */ + ivar = 0; + } - if (summary) - continue; - } + if (summary) + continue; + } else var_idx = pivot_category_create_leaves (step1, N_("Constant")); @@ -1204,7 +1204,7 @@ output_variables (const struct lr_spec *cmd, /* Show the model summary box */ static void output_model_summary (const struct lr_result *res, - double initial_log_likelihood, double log_likelihood) + double initial_log_likelihood, double log_likelihood) { struct pivot_table *table = pivot_table_create (N_("Model Summary")); @@ -1283,7 +1283,7 @@ output_categories (const struct lr_spec *cmd, const struct lr_result *res) size_t n = categoricals_n_count (res->cats, i); size_t df = categoricals_df (res->cats, i); if (max_df < df) - max_df = df; + max_df = df; total_cats += n; } @@ -1315,30 +1315,30 @@ output_categories (const struct lr_spec *cmd, const struct lr_result *res) pivot_value_new_user_text_nocopy (ds_steal_cstr (&str))); for (cat = 0; cat < categoricals_n_count (res->cats, v); ++cat) - { - const struct ccase *c = categoricals_get_case_by_category_real ( + { + const struct ccase *c = categoricals_get_case_by_category_real ( res->cats, v, cat); struct string label = DS_EMPTY_INITIALIZER; - for (int x = 0; x < cat_predictors->n_vars; ++x) - { + for (int x = 0; x < cat_predictors->n_vars; ++x) + { if (!ds_is_empty (&label)) ds_put_byte (&label, ' '); - const union value *val = case_data (c, cat_predictors->vars[x]); - var_append_value_name (cat_predictors->vars[x], val, &label); - } + const union value *val = case_data (c, cat_predictors->vars[x]); + var_append_value_name (cat_predictors->vars[x], val, &label); + } int cat_idx = pivot_category_create_leaf ( var_group, pivot_value_new_user_text_nocopy (ds_steal_cstr (&label))); - double *freq = categoricals_get_user_data_by_category_real ( + double *freq = categoricals_get_user_data_by_category_real ( res->cats, v, cat); pivot_table_put2 (table, 0, cat_idx, pivot_value_new_number (*freq)); - for (int x = 0; x < df; ++x) + for (int x = 0; x < df; ++x) pivot_table_put2 (table, x + 1, cat_idx, pivot_value_new_number (cat == x)); - } + } cumulative_df += df; } diff --git a/src/language/commands/loop.c b/src/language/commands/loop.c index e82020ceb0..1e9769528e 100644 --- a/src/language/commands/loop.c +++ b/src/language/commands/loop.c @@ -160,7 +160,7 @@ cmd_break (struct lexer *lexer, struct dataset *ds) Returns true if successful, false on failure. */ static bool parse_if_clause (struct lexer *lexer, struct dataset *ds, - struct expression **condition) + struct expression **condition) { if (*condition != NULL) { diff --git a/src/language/commands/mann-whitney.c b/src/language/commands/mann-whitney.c index 954ae0f7b1..07df211dd3 100644 --- a/src/language/commands/mann-whitney.c +++ b/src/language/commands/mann-whitney.c @@ -81,11 +81,11 @@ belongs_to_test (const struct ccase *c, void *aux) void mann_whitney_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int i; const struct dictionary *dict = dataset_dict (ds); @@ -106,66 +106,66 @@ mann_whitney_execute (const struct dataset *ds, const struct variable *var = nst->vars[i]; struct casereader *reader = - casereader_create_filter_func (casereader_clone (input), - belongs_to_test, - NULL, - CONST_CAST (struct n_sample_test *, nst), - NULL); + casereader_create_filter_func (casereader_clone (input), + belongs_to_test, + NULL, + CONST_CAST (struct n_sample_test *, nst), + NULL); reader = casereader_create_filter_missing (reader, &var, 1, - exclude, - NULL, NULL); + exclude, + NULL, NULL); reader = sort_execute_1var (reader, var); rr = casereader_create_append_rank (reader, var, - dict_get_weight (dict), - &rerr, - distinct_callback, &tiebreaker); + dict_get_weight (dict), + &rerr, + distinct_callback, &tiebreaker); for (; (c = casereader_read (rr)); case_unref (c)) - { - const union value *group = case_data (c, nst->indep_var); - const size_t group_var_width = var_get_width (nst->indep_var); - const double rank = case_num_idx (c, rank_idx); - - if (value_equal (group, &nst->val1, group_var_width)) - { - mw[i].rank_sum[0] += rank; - mw[i].n[0] += dict_get_case_weight (dict, c, &warn); - } - else if (value_equal (group, &nst->val2, group_var_width)) - { - mw[i].rank_sum[1] += rank; - mw[i].n[1] += dict_get_case_weight (dict, c, &warn); - } - } + { + const union value *group = case_data (c, nst->indep_var); + const size_t group_var_width = var_get_width (nst->indep_var); + const double rank = case_num_idx (c, rank_idx); + + if (value_equal (group, &nst->val1, group_var_width)) + { + mw[i].rank_sum[0] += rank; + mw[i].n[0] += dict_get_case_weight (dict, c, &warn); + } + else if (value_equal (group, &nst->val2, group_var_width)) + { + mw[i].rank_sum[1] += rank; + mw[i].n[1] += dict_get_case_weight (dict, c, &warn); + } + } casereader_destroy (rr); { - double n; - double denominator; - struct mw *mwv = &mw[i]; - - mwv->u = mwv->n[0] * mwv->n[1] ; - mwv->u += mwv->n[0] * (mwv->n[0] + 1) / 2.0; - mwv->u -= mwv->rank_sum[0]; - - mwv->w = mwv->rank_sum[1]; - if (mwv->u > mwv->n[0] * mwv->n[1] / 2.0) - { - mwv->u = mwv->n[0] * mwv->n[1] - mwv->u; - mwv->w = mwv->rank_sum[0]; - } - mwv->z = mwv->u - mwv->n[0] * mwv->n[1] / 2.0; - n = mwv->n[0] + mwv->n[1]; - denominator = pow3(n) - n; - denominator /= 12; - denominator -= tiebreaker; - denominator *= mwv->n[0] * mwv->n[1]; - denominator /= n * (n - 1); - - mwv->z /= sqrt (denominator); + double n; + double denominator; + struct mw *mwv = &mw[i]; + + mwv->u = mwv->n[0] * mwv->n[1] ; + mwv->u += mwv->n[0] * (mwv->n[0] + 1) / 2.0; + mwv->u -= mwv->rank_sum[0]; + + mwv->w = mwv->rank_sum[1]; + if (mwv->u > mwv->n[0] * mwv->n[1] / 2.0) + { + mwv->u = mwv->n[0] * mwv->n[1] - mwv->u; + mwv->w = mwv->rank_sum[0]; + } + mwv->z = mwv->u - mwv->n[0] * mwv->n[1] / 2.0; + n = mwv->n[0] + mwv->n[1]; + denominator = pow3(n) - n; + denominator /= 12; + denominator -= tiebreaker; + denominator *= mwv->n[0] * mwv->n[1]; + denominator /= n * (n - 1); + + mwv->z /= sqrt (denominator); } } casereader_destroy (input); diff --git a/src/language/commands/mann-whitney.h b/src/language/commands/mann-whitney.h index 2cb14a76c6..9f9eefe062 100644 --- a/src/language/commands/mann-whitney.h +++ b/src/language/commands/mann-whitney.h @@ -31,11 +31,11 @@ struct casereader; struct dataset; void mann_whitney_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer - ); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer + ); #endif diff --git a/src/language/commands/matrix-data.c b/src/language/commands/matrix-data.c index 365caf6fd3..fb823b9f0f 100644 --- a/src/language/commands/matrix-data.c +++ b/src/language/commands/matrix-data.c @@ -988,49 +988,49 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) while (lex_token (lexer) != T_ENDCMD) { if (!lex_force_match (lexer, T_SLASH)) - goto error; + goto error; if (lex_match_id (lexer, "N")) - { + { n_start = lex_ofs (lexer) - 1; - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - if (!lex_force_int_range (lexer, "N", 0, INT_MAX)) - goto error; + if (!lex_force_int_range (lexer, "N", 0, INT_MAX)) + goto error; - mf.n = lex_integer (lexer); + mf.n = lex_integer (lexer); n_end = lex_ofs (lexer); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "FORMAT")) - { + { int start_ofs = lex_ofs (lexer) - 1; - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) - { - if (lex_match_id (lexer, "LIST")) + while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) + { + if (lex_match_id (lexer, "LIST")) mf.span = false; - else if (lex_match_id (lexer, "FREE")) + else if (lex_match_id (lexer, "FREE")) mf.span = true; - else if (lex_match_id (lexer, "UPPER")) + else if (lex_match_id (lexer, "UPPER")) mf.triangle = UPPER; - else if (lex_match_id (lexer, "LOWER")) + else if (lex_match_id (lexer, "LOWER")) mf.triangle = LOWER; - else if (lex_match_id (lexer, "FULL")) + else if (lex_match_id (lexer, "FULL")) mf.triangle = FULL; - else if (lex_match_id (lexer, "DIAGONAL")) + else if (lex_match_id (lexer, "DIAGONAL")) mf.diagonal = DIAGONAL; - else if (lex_match_id (lexer, "NODIAGONAL")) + else if (lex_match_id (lexer, "NODIAGONAL")) mf.diagonal = NO_DIAGONAL; - else - { - lex_error_expecting (lexer, "LIST", "FREE", + else + { + lex_error_expecting (lexer, "LIST", "FREE", "UPPER", "LOWER", "FULL", "DIAGONAL", "NODIAGONAL"); - goto error; - } - } + goto error; + } + } int end_ofs = lex_ofs (lexer) - 1; if (mf.diagonal == NO_DIAGONAL && mf.triangle == FULL) @@ -1040,15 +1040,15 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) "mutually exclusive.")); goto error; } - } + } else if (lex_match_id (lexer, "FILE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); fh_unref (fh); - fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); - if (!fh) - goto error; - } + fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); + if (!fh) + goto error; + } else if (!mf.n_svars && lex_match_id (lexer, "SPLIT")) { lex_match (lexer, T_EQUALS); @@ -1079,20 +1079,20 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) goto error; } else if (lex_match_id (lexer, "CELLS")) - { + { if (mf.input_rowtype) lex_next_msg (lexer, SW, -1, -1, _("CELLS is ignored when VARIABLES " "includes ROWTYPE_")); - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - if (!lex_force_int_range (lexer, "CELLS", 0, INT_MAX)) - goto error; + if (!lex_force_int_range (lexer, "CELLS", 0, INT_MAX)) + goto error; - mf.cells = lex_integer (lexer); - lex_get (lexer); - } + mf.cells = lex_integer (lexer); + lex_get (lexer); + } else if (lex_match_id (lexer, "CONTENTS")) { lex_match (lexer, T_EQUALS); @@ -1142,11 +1142,11 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds) } } else - { - lex_error_expecting (lexer, "N", "FORMAT", "FILE", "SPLIT", "FACTORS", + { + lex_error_expecting (lexer, "N", "FORMAT", "FILE", "SPLIT", "FACTORS", "CELLS", "CONTENTS"); - goto error; - } + goto error; + } } if (!mf.input_rowtype) { diff --git a/src/language/commands/matrix.c b/src/language/commands/matrix.c index bd6916a951..80febe3286 100644 --- a/src/language/commands/matrix.c +++ b/src/language/commands/matrix.c @@ -6512,16 +6512,16 @@ matrix_read_parse (struct matrix_state *s) goto error; } else if (lex_match_id (s->lexer, "ENCODING")) - { - lex_match (s->lexer, T_EQUALS); - if (!lex_force_string (s->lexer)) - goto error; + { + lex_match (s->lexer, T_EQUALS); + if (!lex_force_string (s->lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (s->lexer)); - lex_get (s->lexer); - } + lex_get (s->lexer); + } else if (lex_match_id (s->lexer, "FIELD")) { lex_match (s->lexer, T_EQUALS); @@ -7093,16 +7093,16 @@ matrix_write_parse (struct matrix_state *s) goto error; } else if (lex_match_id (s->lexer, "ENCODING")) - { - lex_match (s->lexer, T_EQUALS); - if (!lex_force_string (s->lexer)) - goto error; + { + lex_match (s->lexer, T_EQUALS); + if (!lex_force_string (s->lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (s->lexer)); - lex_get (s->lexer); - } + lex_get (s->lexer); + } else if (lex_match_id (s->lexer, "FIELD")) { lex_match (s->lexer, T_EQUALS); @@ -7464,16 +7464,16 @@ matrix_get_parse (struct matrix_state *s) } } else if (lex_match_id (s->lexer, "ENCODING")) - { - lex_match (s->lexer, T_EQUALS); - if (!lex_force_string (s->lexer)) - goto error; + { + lex_match (s->lexer, T_EQUALS); + if (!lex_force_string (s->lexer)) + goto error; free (get->encoding); get->encoding = ss_xstrdup (lex_tokss (s->lexer)); - lex_get (s->lexer); - } + lex_get (s->lexer); + } else if (lex_match_id (s->lexer, "VARIABLES")) { lex_match (s->lexer, T_EQUALS); @@ -7489,7 +7489,7 @@ matrix_get_parse (struct matrix_state *s) } else if (lex_match_id (s->lexer, "NAMES")) { - lex_match (s->lexer, T_EQUALS); + lex_match (s->lexer, T_EQUALS); if (!lex_force_id (s->lexer)) goto error; @@ -7501,7 +7501,7 @@ matrix_get_parse (struct matrix_state *s) } else if (lex_match_id (s->lexer, "MISSING")) { - lex_match (s->lexer, T_EQUALS); + lex_match (s->lexer, T_EQUALS); if (lex_match_id (s->lexer, "ACCEPT")) get->user.treatment = MGET_ACCEPT; else if (lex_match_id (s->lexer, "OMIT")) @@ -7521,7 +7521,7 @@ matrix_get_parse (struct matrix_state *s) } else if (lex_match_id (s->lexer, "SYSMIS")) { - lex_match (s->lexer, T_EQUALS); + lex_match (s->lexer, T_EQUALS); if (lex_match_id (s->lexer, "OMIT")) get->system.treatment = MGET_OMIT; else if (lex_is_number (s->lexer)) @@ -8253,16 +8253,16 @@ matrix_mget_parse (struct matrix_state *s) goto error; } else if (lex_match_id (s->lexer, "ENCODING")) - { - lex_match (s->lexer, T_EQUALS); - if (!lex_force_string (s->lexer)) - goto error; + { + lex_match (s->lexer, T_EQUALS); + if (!lex_force_string (s->lexer)) + goto error; free (mget->encoding); mget->encoding = ss_xstrdup (lex_tokss (s->lexer)); - lex_get (s->lexer); - } + lex_get (s->lexer); + } else if (lex_match_id (s->lexer, "TYPE")) { lex_match (s->lexer, T_EQUALS); diff --git a/src/language/commands/mcnemar.c b/src/language/commands/mcnemar.c index bfb8c2939c..69582ea2b8 100644 --- a/src/language/commands/mcnemar.c +++ b/src/language/commands/mcnemar.c @@ -55,23 +55,23 @@ struct mcnemar static void output_freq_table (variable_pair *vp, - const struct mcnemar *param, - const struct dictionary *dict); + const struct mcnemar *param, + const struct dictionary *dict); static void output_statistics_table (const struct two_sample_test *t2s, - const struct mcnemar *param, - const struct dictionary *dict); + const struct mcnemar *param, + const struct dictionary *dict); void mcnemar_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int i; bool warn = true; @@ -95,55 +95,55 @@ mcnemar_execute (const struct dataset *ds, const double weight = dict_get_case_weight (dict, c, &warn); for (i = 0 ; i < t2s->n_pairs; ++i) - { - variable_pair *vp = &t2s->pairs[i]; - const union value *value0 = case_data (c, (*vp)[0]); - const union value *value1 = case_data (c, (*vp)[1]); - - if (var_is_value_missing ((*vp)[0], value0) & exclude) - continue; - - if (var_is_value_missing ((*vp)[1], value1) & exclude) - continue; - - - if (mc[i].val0.f == SYSMIS) - { - if (mc[i].val1.f != value0->f) - mc[i].val0.f = value0->f; - else if (mc[i].val1.f != value1->f) - mc[i].val0.f = value1->f; - } - - if (mc[i].val1.f == SYSMIS) - { - if (mc[i].val0.f != value1->f) - mc[i].val1.f = value1->f; - else if (mc[i].val0.f != value0->f) - mc[i].val1.f = value0->f; - } - - if (mc[i].val0.f == value0->f && mc[i].val0.f == value1->f) - { - mc[i].n00 += weight; - } - else if (mc[i].val0.f == value0->f && mc[i].val1.f == value1->f) - { - mc[i].n10 += weight; - } - else if (mc[i].val1.f == value0->f && mc[i].val0.f == value1->f) - { - mc[i].n01 += weight; - } - else if (mc[i].val1.f == value0->f && mc[i].val1.f == value1->f) - { - mc[i].n11 += weight; - } - else - { - msg (ME, _("The McNemar test is appropriate only for dichotomous variables")); - } - } + { + variable_pair *vp = &t2s->pairs[i]; + const union value *value0 = case_data (c, (*vp)[0]); + const union value *value1 = case_data (c, (*vp)[1]); + + if (var_is_value_missing ((*vp)[0], value0) & exclude) + continue; + + if (var_is_value_missing ((*vp)[1], value1) & exclude) + continue; + + + if (mc[i].val0.f == SYSMIS) + { + if (mc[i].val1.f != value0->f) + mc[i].val0.f = value0->f; + else if (mc[i].val1.f != value1->f) + mc[i].val0.f = value1->f; + } + + if (mc[i].val1.f == SYSMIS) + { + if (mc[i].val0.f != value1->f) + mc[i].val1.f = value1->f; + else if (mc[i].val0.f != value0->f) + mc[i].val1.f = value0->f; + } + + if (mc[i].val0.f == value0->f && mc[i].val0.f == value1->f) + { + mc[i].n00 += weight; + } + else if (mc[i].val0.f == value0->f && mc[i].val1.f == value1->f) + { + mc[i].n10 += weight; + } + else if (mc[i].val1.f == value0->f && mc[i].val0.f == value1->f) + { + mc[i].n01 += weight; + } + else if (mc[i].val1.f == value0->f && mc[i].val1.f == value1->f) + { + mc[i].n11 += weight; + } + else + { + msg (ME, _("The McNemar test is appropriate only for dichotomous variables")); + } + } } casereader_destroy (r); @@ -165,8 +165,8 @@ make_pair_name (const variable_pair *pair) static void output_freq_table (variable_pair *vp, - const struct mcnemar *param, - const struct dictionary *dict) + const struct mcnemar *param, + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create__ ( pivot_value_new_user_text_nocopy (make_pair_name (vp)), "Frequencies"); @@ -213,8 +213,8 @@ output_freq_table (variable_pair *vp, static void output_statistics_table (const struct two_sample_test *t2s, - const struct mcnemar *mc, - const struct dictionary *dict) + const struct mcnemar *mc, + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create (N_("Test Statistics")); pivot_table_set_weight_var (table, dict_get_weight (dict)); @@ -236,7 +236,7 @@ output_statistics_table (const struct two_sample_test *t2s, double n = mc[i].n00 + mc[i].n01 + mc[i].n10 + mc[i].n11; double sig = gsl_cdf_binomial_P ((mc[i].n01 > mc[i].n10) ? mc[i].n10: mc[i].n01, - 0.5, mc[i].n01 + mc[i].n10); + 0.5, mc[i].n01 + mc[i].n10); double point = gsl_ran_binomial_pdf (mc[i].n01, 0.5, mc[i].n01 + mc[i].n10); diff --git a/src/language/commands/mcnemar.h b/src/language/commands/mcnemar.h index 41724a3a24..d61fef364b 100644 --- a/src/language/commands/mcnemar.h +++ b/src/language/commands/mcnemar.h @@ -26,10 +26,10 @@ struct dataset; struct npar_test; void mcnemar_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer); #endif diff --git a/src/language/commands/means-parser.c b/src/language/commands/means-parser.c index 0cc0b1b317..823b2f36bf 100644 --- a/src/language/commands/means-parser.c +++ b/src/language/commands/means-parser.c @@ -34,14 +34,14 @@ /* Parse the /TABLES stanza of the command. */ static bool parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, - struct mtable *table) + struct mtable *table) { memset (table, 0, sizeof *table); /* Dependent variable (s) */ if (!parse_variables_const_pool (lexer, cmd->pool, cmd->dict, - &table->dep_vars, &table->n_dep_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + &table->dep_vars, &table->n_dep_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) return false; /* Factor variable (s) */ @@ -50,17 +50,17 @@ parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, struct layer *layer = pool_zalloc (cmd->pool, sizeof *layer); table->layers = - pool_nrealloc (cmd->pool, table->layers, table->n_layers + 1, - sizeof *table->layers); + pool_nrealloc (cmd->pool, table->layers, table->n_layers + 1, + sizeof *table->layers); table->layers[table->n_layers] = layer; table->n_layers++; if (!parse_variables_const_pool - (lexer, cmd->pool, cmd->dict, - &layer->factor_vars, - &layer->n_factor_vars, - PV_NO_DUPLICATE)) - return false; + (lexer, cmd->pool, cmd->dict, + &layer->factor_vars, + &layer->n_factor_vars, + PV_NO_DUPLICATE)) + return false; } return true; @@ -71,7 +71,7 @@ parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, Returns true if successful */ static bool lex_is_variable (struct lexer *lexer, const struct dictionary *dict, - int n) + int n) { if (lex_next_token (lexer, n) != T_ID) return false; @@ -122,7 +122,7 @@ means_parse (struct lexer *lexer, struct means *means) for (;;) { means->table = pool_realloc (means->pool, means->table, - (means->n_tables + 1) * sizeof *means->table); + (means->n_tables + 1) * sizeof *means->table); if (!parse_means_table_syntax (lexer, means, &means->table[means->n_tables])) @@ -142,21 +142,21 @@ means_parse (struct lexer *lexer, struct means *means) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "MISSING")) - { - /* If no MISSING subcommand is specified, each combination of a + { + /* If no MISSING subcommand is specified, each combination of a dependent variable and categorical variables is handled separately. */ - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "INCLUDE")) - { - /* Use the subcommand "/MISSING=INCLUDE" to include user-missing + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "INCLUDE")) + { + /* Use the subcommand "/MISSING=INCLUDE" to include user-missing values in the analysis. */ - means->ctrl_exclude = MV_SYSTEM; - means->dep_exclude = MV_SYSTEM; - } - else if (lex_match_id (lexer, "DEPENDENT")) - /* Use the command "/MISSING=DEPENDENT" to include user-missing + means->ctrl_exclude = MV_SYSTEM; + means->dep_exclude = MV_SYSTEM; + } + else if (lex_match_id (lexer, "DEPENDENT")) + /* Use the command "/MISSING=DEPENDENT" to include user-missing values for the categorical variables, while excluding them for the dependent variables. @@ -166,56 +166,56 @@ means_parse (struct lexer *lexer, struct means *means) Cases are ALWAYS dropped when System Missing values appear in the categorical variables. */ - { - means->dep_exclude = MV_ANY; - means->ctrl_exclude = MV_SYSTEM; - } - else - { - lex_error_expecting (lexer, "INCLUDE", "DEPENDENT"); - return false; - } - } + { + means->dep_exclude = MV_ANY; + means->ctrl_exclude = MV_SYSTEM; + } + else + { + lex_error_expecting (lexer, "INCLUDE", "DEPENDENT"); + return false; + } + } else if (lex_match_id (lexer, "CELLS")) - { - lex_match (lexer, T_EQUALS); - - /* The default values become overwritten */ - means->n_statistics = 0; - while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match (lexer, T_ALL)) - { - means->n_statistics = 0; - for (int i = 0; i < n_MEANS_STATISTICS; ++i) + { + lex_match (lexer, T_EQUALS); + + /* The default values become overwritten */ + means->n_statistics = 0; + while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) + { + if (lex_match (lexer, T_ALL)) + { + means->n_statistics = 0; + for (int i = 0; i < n_MEANS_STATISTICS; ++i) add_statistic (means, i); - } - else if (lex_match_id (lexer, "NONE")) + } + else if (lex_match_id (lexer, "NONE")) means->n_statistics = 0; - else if (lex_match_id (lexer, "DEFAULT")) + else if (lex_match_id (lexer, "DEFAULT")) means_set_default_statistics (means); else - { + { const struct cell_spec *cs = match_cell (lexer); if (cs) add_statistic (means, cs - cell_spec); else - { + { const char *keywords[n_MEANS_STATISTICS]; for (int i = 0; i < n_MEANS_STATISTICS; ++i) keywords[i] = cell_spec[i].keyword; - lex_error_expecting_array (lexer, keywords, + lex_error_expecting_array (lexer, keywords, n_MEANS_STATISTICS); - return false; - } - } - } - } + return false; + } + } + } + } else - { - lex_error_expecting (lexer, "MISSING", "CELLS"); - return false; - } + { + lex_error_expecting (lexer, "MISSING", "CELLS"); + return false; + } } return true; } diff --git a/src/language/commands/means.c b/src/language/commands/means.c index eacc74f3d9..954a09f91d 100644 --- a/src/language/commands/means.c +++ b/src/language/commands/means.c @@ -121,12 +121,12 @@ destroy_workspace (const struct mtable *mt, struct workspace *ws) struct instance *inst; struct instance *next; HMAP_FOR_EACH_SAFE (inst, next, struct instance, hmap_node, - &instances->map) - { - int width = var_get_width (inst->var); - value_destroy (&inst->value, width); - free (inst); - } + &instances->map) + { + int width = var_get_width (inst->var); + value_destroy (&inst->value, width); + free (inst); + } hmap_destroy (&instances->map); } free (ws->control_idx); @@ -136,13 +136,13 @@ destroy_workspace (const struct mtable *mt, struct workspace *ws) /* Destroy CELL. */ static void destroy_cell (const struct means *means, - const struct mtable *mt, struct cell *cell) + const struct mtable *mt, struct cell *cell) { int idx = 0; for (int i = 0; i < mt->n_layers; ++i) { if (0 == ((cell->not_wild >> i) & 0x1)) - continue; + continue; const struct layer *layer = mt->layers[i]; for (int cmb = 0; cmb < mt->n_combinations; ++cmb) @@ -182,7 +182,7 @@ destroy_cell (const struct means *means, cells. */ static void means_destroy_cells (const struct means *means, struct cell *cell, - const struct mtable *table) + const struct mtable *table) { for (int i = 0; i < cell->n_children; ++i) { @@ -190,10 +190,10 @@ means_destroy_cells (const struct means *means, struct cell *cell, struct cell *sub_cell; struct cell *next; HMAP_FOR_EACH_SAFE (sub_cell, next, struct cell, hmap_node, - &container->map) - { - means_destroy_cells (means, sub_cell, table); - } + &container->map) + { + means_destroy_cells (means, sub_cell, table); + } } destroy_cell (means, table, cell); @@ -216,12 +216,12 @@ dump_cell (const struct cell *cell, const struct mtable *mt, int level) for (int i = 0; i < mt->n_layers; ++i) { if ((cell->not_wild >> i) & 0x1) - { - printf ("%s: ", var_get_name (cell->vars[x])); - printf ("%g ", cell->values[x++].f); - } + { + printf ("%s: ", var_get_name (cell->vars[x])); + printf ("%g ", cell->values[x++].f); + } else - printf ("x "); + printf ("x "); } stat_get *sg = cell_spec[MEANS_N].sd; printf ("--- S1: %g", sg (cell->stat[0])); @@ -245,7 +245,7 @@ dump_indeces (const size_t *indexes, int n) /* Dump the tree in pre-order. */ static void dump_tree (const struct cell *cell, const struct mtable *table, - int level, const struct cell *parent) + int level, const struct cell *parent) { assert (cell->parent_cell == parent); dump_cell (cell, table, level); @@ -255,9 +255,9 @@ dump_tree (const struct cell *cell, const struct mtable *table, struct cell_container *container = cell->children + i; struct cell *sub_cell; BT_FOR_EACH (sub_cell, struct cell, bt_node, &container->bt) - { - dump_tree (sub_cell, table, level + 1, cell); - } + { + dump_tree (sub_cell, table, level + 1, cell); + } } } @@ -267,15 +267,15 @@ dump_tree (const struct cell *cell, const struct mtable *table, the array VARS which are taken from the case C. */ static unsigned int generate_hash (const struct mtable *mt, - const struct ccase *c, - unsigned int not_wild, - const struct workspace *ws) + const struct ccase *c, + unsigned int not_wild, + const struct workspace *ws) { unsigned int hash = 0; for (int i = 0; i < mt->n_layers; ++i) { if (0 == ((not_wild >> i) & 0x1)) - continue; + continue; const struct layer *layer = mt->layers[i]; const struct variable *var = layer->factor_vars[ws->control_idx[i]]; @@ -294,11 +294,11 @@ generate_hash (const struct mtable *mt, no longer needed. */ static struct cell * generate_cell (const struct means *means, - const struct mtable *mt, - const struct ccase *c, + const struct mtable *mt, + const struct ccase *c, unsigned int not_wild, - const struct cell *pcell, - const struct workspace *ws) + const struct cell *pcell, + const struct workspace *ws) { int n_vars = count_one_bits (not_wild); struct cell *cell = XZALLOC (struct cell); @@ -315,7 +315,7 @@ generate_cell (const struct means *means, for (int i = 0; i < mt->n_layers; ++i) { if (0 == ((not_wild >> i) & 0x1)) - continue; + continue; const struct layer *layer = mt->layers[i]; const struct variable *var = layer->factor_vars[ws->control_idx[i]]; @@ -353,10 +353,10 @@ generate_cell (const struct means *means, Otherwise, return NULL. */ static struct cell * lookup_cell (const struct mtable *mt, - struct hmap *hmap, unsigned int hash, - const struct ccase *c, - unsigned int not_wild, - const struct workspace *ws) + struct hmap *hmap, unsigned int hash, + const struct ccase *c, + unsigned int not_wild, + const struct workspace *ws) { struct cell *cell = NULL; HMAP_FOR_EACH_WITH_HASH (cell, struct cell, hmap_node, hash, hmap) @@ -364,25 +364,25 @@ lookup_cell (const struct mtable *mt, bool match = true; int idx = 0; if (cell->not_wild != not_wild) - continue; + continue; for (int i = 0; i < mt->n_layers; ++i) - { - if (0 == ((cell->not_wild >> i) & 0x1)) - continue; - - const struct layer *layer = mt->layers[i]; - const struct variable *var = layer->factor_vars[ws->control_idx[i]]; - const union value *vv = case_data (c, var); - int width = var_get_width (var); - assert (var == cell->vars[idx]); - if (!value_equal (vv, &cell->values[idx++], width)) - { - match = false; - break; - } - } + { + if (0 == ((cell->not_wild >> i) & 0x1)) + continue; + + const struct layer *layer = mt->layers[i]; + const struct variable *var = layer->factor_vars[ws->control_idx[i]]; + const union value *vv = case_data (c, var); + int width = var_get_width (var); + assert (var == cell->vars[idx]); + if (!value_equal (vv, &cell->values[idx++], width)) + { + match = false; + break; + } + } if (match) - return cell; + return cell; } return NULL; } @@ -394,8 +394,8 @@ lookup_cell (const struct mtable *mt, tree/map. */ static int cell_compare_3way (const struct bt_node *a, - const struct bt_node *b, - const void *aux UNUSED) + const struct bt_node *b, + const void *aux UNUSED) { const struct cell *fa = BT_DATA (a, struct cell, bt_node); const struct cell *fb = BT_DATA (b, struct cell, bt_node); @@ -405,15 +405,15 @@ cell_compare_3way (const struct bt_node *a, assert (fa->vars[vidx] == fb->vars[vidx]); return value_compare_3way (&fa->values[vidx], - &fb->values[vidx], - var_get_width (fa->vars[vidx])); + &fb->values[vidx], + var_get_width (fa->vars[vidx])); } /* A comparison function used to sort cells in a binary tree. */ static int compare_instance_3way (const struct bt_node *a, - const struct bt_node *b, - const void *aux UNUSED) + const struct bt_node *b, + const void *aux UNUSED) { const struct instance *fa = BT_DATA (a, struct instance, bt_node); const struct instance *fb = BT_DATA (b, struct instance, bt_node); @@ -421,13 +421,13 @@ compare_instance_3way (const struct bt_node *a, assert (fa->var == fb->var); return value_compare_3way (&fa->value, - &fb->value, - var_get_width (fa->var)); + &fb->value, + var_get_width (fa->var)); } static void arrange_cells (struct workspace *ws, - struct cell *cell, const struct mtable *table); + struct cell *cell, const struct mtable *table); /* Iterate CONTAINER's map inserting a copy of its elements into @@ -436,7 +436,7 @@ static void arrange_cells (struct workspace *ws, CONTAINER. */ static void arrange_cell (struct workspace *ws, struct cell_container *container, - const struct mtable *mt) + const struct mtable *mt) { struct bt *bt = &container->bt; struct hmap *map = &container->map; @@ -449,43 +449,43 @@ arrange_cell (struct workspace *ws, struct cell_container *container, int idx = 0; for (int i = 0; i < mt->n_layers; ++i) - { - if (0 == ((cell->not_wild >> i) & 0x1)) - continue; - - struct cell_container *instances = ws->instances + i; - const struct variable *var = cell->vars[idx]; - int width = var_get_width (var); - unsigned int hash - = value_hash (&cell->values[idx], width, 0); - - struct instance *inst = NULL; - struct instance *next = NULL; - HMAP_FOR_EACH_WITH_HASH_SAFE (inst, next, struct instance, - hmap_node, - hash, &instances->map) - { - assert (cell->vars[idx] == var); - if (value_equal (&inst->value, - &cell->values[idx], - width)) - { - break; - } - } - - if (!inst) - { - inst = xzalloc (sizeof *inst); - inst->index = -1; - inst->var = var; - value_clone (&inst->value, &cell->values[idx], - width); - hmap_insert (&instances->map, &inst->hmap_node, hash); - } - - idx++; - } + { + if (0 == ((cell->not_wild >> i) & 0x1)) + continue; + + struct cell_container *instances = ws->instances + i; + const struct variable *var = cell->vars[idx]; + int width = var_get_width (var); + unsigned int hash + = value_hash (&cell->values[idx], width, 0); + + struct instance *inst = NULL; + struct instance *next = NULL; + HMAP_FOR_EACH_WITH_HASH_SAFE (inst, next, struct instance, + hmap_node, + hash, &instances->map) + { + assert (cell->vars[idx] == var); + if (value_equal (&inst->value, + &cell->values[idx], + width)) + { + break; + } + } + + if (!inst) + { + inst = xzalloc (sizeof *inst); + inst->index = -1; + inst->var = var; + value_clone (&inst->value, &cell->values[idx], + width); + hmap_insert (&instances->map, &inst->hmap_node, hash); + } + + idx++; + } arrange_cells (ws, cell, mt); } @@ -494,7 +494,7 @@ arrange_cell (struct workspace *ws, struct cell_container *container, /* Arrange the children and then all the subtotals. */ static void arrange_cells (struct workspace *ws, struct cell *cell, - const struct mtable *table) + const struct mtable *table) { for (int i = 0; i < cell->n_children; ++i) { @@ -510,7 +510,7 @@ arrange_cells (struct workspace *ws, struct cell *cell, then return that instance. Otherwise return NULL. */ static const struct instance * lookup_instance (const struct mtable *mt, const struct workspace *ws, - int l_idx, const struct cell *cell) + int l_idx, const struct cell *cell) { const struct layer *layer = mt->layers[l_idx]; int n_vals = count_one_bits (cell->not_wild); @@ -522,11 +522,11 @@ lookup_instance (const struct mtable *mt, const struct workspace *ws, struct instance *inst = NULL; struct instance *next; HMAP_FOR_EACH_WITH_HASH_SAFE (inst, next, - struct instance, hmap_node, - hash, &instances->map) + struct instance, hmap_node, + hash, &instances->map) { if (value_equal (val, &inst->value, width)) - break; + break; } return inst; } @@ -534,7 +534,7 @@ lookup_instance (const struct mtable *mt, const struct workspace *ws, /* Enter the values into PT. */ static void populate_table (const struct means *means, const struct mtable *mt, - const struct workspace *ws, + const struct workspace *ws, const struct cell *cell, struct pivot_table *pt) { @@ -554,7 +554,7 @@ populate_table (const struct means *means, const struct mtable *mt, for (; i < pt->n_dimensions; ++i) { int l_idx = pt->n_dimensions - i - 1; - const struct cell_container *instances = ws->instances + l_idx; + const struct cell_container *instances = ws->instances + l_idx; if (0 == (cell->not_wild >> l_idx & 0x1U)) { indexes [i] = hmap_count (&instances->map); @@ -563,7 +563,7 @@ populate_table (const struct means *means, const struct mtable *mt, { assert (pc); const struct instance *inst - = lookup_instance (mt, ws, l_idx, pc); + = lookup_instance (mt, ws, l_idx, pc); assert (inst); indexes [i] = inst->index; pc = pc->parent_cell; @@ -571,14 +571,14 @@ populate_table (const struct means *means, const struct mtable *mt, } } - int idx = s + v * means->n_statistics; - struct pivot_value *pv - = pivot_value_new_number (sg (cell->stat[idx])); - if (NULL == cell_spec[stat].rc) - { - const struct variable *dv = mt->dep_vars[v]; - pv->numeric.format = var_get_print_format (dv); - } + int idx = s + v * means->n_statistics; + struct pivot_value *pv + = pivot_value_new_number (sg (cell->stat[idx])); + if (NULL == cell_spec[stat].rc) + { + const struct variable *dv = mt->dep_vars[v]; + pv->numeric.format = var_get_print_format (dv); + } pivot_table_put (pt, indexes, pt->n_dimensions, pv); } } @@ -589,15 +589,15 @@ populate_table (const struct means *means, const struct mtable *mt, struct cell_container *container = cell->children + i; struct cell *child = NULL; BT_FOR_EACH (child, struct cell, bt_node, &container->bt) - { + { populate_table (means, mt, ws, child, pt); - } + } } } static void create_table_structure (const struct mtable *mt, struct pivot_table *pt, - const struct workspace *ws) + const struct workspace *ws) { int * lindexes = ws->control_idx; /* The inner layers are situated rightmost in the table. @@ -608,29 +608,29 @@ create_table_structure (const struct mtable *mt, struct pivot_table *pt, const struct cell_container *instances = ws->instances + l; const struct variable *var = layer->factor_vars[lindexes[l]]; struct pivot_dimension *dim_layer - = pivot_dimension_create (pt, PIVOT_AXIS_ROW, - var_to_string (var)); + = pivot_dimension_create (pt, PIVOT_AXIS_ROW, + var_to_string (var)); dim_layer->root->show_label = true; /* Place the values of the control variables as table headings. */ { - struct instance *inst = NULL; - BT_FOR_EACH (inst, struct instance, bt_node, &instances->bt) - { - struct substring space = SS_LITERAL_INITIALIZER ("\t "); - struct string str; - ds_init_empty (&str); - var_append_value_name (var, - &inst->value, - &str); - - ds_ltrim (&str, space); - - pivot_category_create_leaf (dim_layer->root, + struct instance *inst = NULL; + BT_FOR_EACH (inst, struct instance, bt_node, &instances->bt) + { + struct substring space = SS_LITERAL_INITIALIZER ("\t "); + struct string str; + ds_init_empty (&str); + var_append_value_name (var, + &inst->value, + &str); + + ds_ltrim (&str, space); + + pivot_category_create_leaf (dim_layer->root, pivot_value_new_text (ds_cstr (&str))); - ds_destroy (&str); - } + ds_destroy (&str); + } } pivot_category_create_leaf (dim_layer->root, @@ -642,22 +642,22 @@ create_table_structure (const struct mtable *mt, struct pivot_table *pt, relating to MT, LINDEXES. */ static void layers_to_string (const struct mtable *mt, const int *lindexes, - struct string *c_des) + struct string *c_des) { for (int l = 0; l < mt->n_layers; ++l) { const struct layer *layer = mt->layers[l]; const struct variable *ctrl_var = layer->factor_vars[lindexes[l]]; if (l > 0) - ds_put_cstr (c_des, " * "); + ds_put_cstr (c_des, " * "); ds_put_cstr (c_des, var_get_name (ctrl_var)); } } static void populate_case_processing_summary (struct pivot_category *pc, - const struct mtable *mt, - const int *lindexes) + const struct mtable *mt, + const int *lindexes) { struct string ds; ds_init_empty (&ds); @@ -667,7 +667,7 @@ populate_case_processing_summary (struct pivot_category *pc, const struct layer *layer = mt->layers[l]; const struct variable *ctrl_var = layer->factor_vars[lindexes[l]]; if (l > 0) - ds_put_cstr (&ds, " * "); + ds_put_cstr (&ds, " * "); ds_put_cstr (&ds, var_get_name (ctrl_var)); } for (int dv = 0; dv < mt->n_dep_vars; ++dv) @@ -676,12 +676,12 @@ populate_case_processing_summary (struct pivot_category *pc, ds_init_empty (&dss); ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv])); if (mt->n_layers > 0) - { - ds_put_cstr (&dss, " * "); - ds_put_substring (&dss, ds.ss); - } + { + ds_put_cstr (&dss, " * "); + ds_put_substring (&dss, ds.ss); + } pivot_category_create_leaf (pc, - pivot_value_new_text (ds_cstr (&dss))); + pivot_value_new_text (ds_cstr (&dss))); ds_destroy (&dss); } @@ -700,19 +700,19 @@ means_case_processing_summary (const struct mtable *mt) struct pivot_category *cats[3]; cats[0] = pivot_category_create_group (dim_cases->root, - N_("Included"), NULL); + N_("Included"), NULL); cats[1] = pivot_category_create_group (dim_cases->root, - N_("Excluded"), NULL); + N_("Excluded"), NULL); cats[2] = pivot_category_create_group (dim_cases->root, - N_("Total"), NULL); + N_("Total"), NULL); for (int i = 0; i < 3; ++i) { pivot_category_create_leaf_rc (cats[i], pivot_value_new_text (N_("N")), - PIVOT_RC_COUNT); + PIVOT_RC_COUNT); pivot_category_create_leaf_rc (cats[i], pivot_value_new_text (N_("Percent")), - PIVOT_RC_PERCENT); + PIVOT_RC_PERCENT); } struct pivot_dimension *rows = @@ -749,7 +749,7 @@ means_case_processing_summary (const struct mtable *mt) static void means_shipout_single (const struct mtable *mt, const struct means *means, - const struct workspace *ws) + const struct workspace *ws) { struct pivot_table *pt = pivot_table_create (N_("Report")); @@ -761,8 +761,8 @@ means_shipout_single (const struct mtable *mt, const struct means *means, { const struct cell_spec *cs = cell_spec + means->statistics[i]; pivot_category_create_leaf_rc - (dim_cells->root, - pivot_value_new_text (gettext (cs->title)), cs->rc); + (dim_cells->root, + pivot_value_new_text (gettext (cs->title)), cs->rc); } create_table_structure (mt, pt, ws); @@ -773,14 +773,14 @@ means_shipout_single (const struct mtable *mt, const struct means *means, static void means_shipout_multivar (const struct mtable *mt, const struct means *means, - const struct workspace *ws) + const struct workspace *ws) { struct string dss; ds_init_empty (&dss); for (int dv = 0; dv < mt->n_dep_vars; ++dv) { if (dv > 0) - ds_put_cstr (&dss, " * "); + ds_put_cstr (&dss, " * "); ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv])); } @@ -801,21 +801,21 @@ means_shipout_multivar (const struct mtable *mt, const struct means *means, for (int i = 0; i < mt->n_dep_vars; ++i) { pivot_category_create_leaf - (dim_cells->root, - pivot_value_new_variable (mt->dep_vars[i])); + (dim_cells->root, + pivot_value_new_variable (mt->dep_vars[i])); } struct pivot_dimension *dim_stats = pivot_dimension_create (pt, PIVOT_AXIS_ROW, - N_ ("Statistics")); + N_ ("Statistics")); dim_stats->root->show_label = false; for (int i = 0; i < means->n_statistics; ++i) { const struct cell_spec *cs = cell_spec + means->statistics[i]; pivot_category_create_leaf_rc - (dim_stats->root, - pivot_value_new_text (gettext (cs->title)), cs->rc); + (dim_stats->root, + pivot_value_new_text (gettext (cs->title)), cs->rc); } create_table_structure (mt, pt, ws); @@ -830,20 +830,20 @@ means_shipout (const struct mtable *mt, const struct means *means) { const struct workspace *ws = mt->ws + cmb; if (ws->root_cell == NULL) - { - struct string des; - ds_init_empty (&des); - layers_to_string (mt, ws->control_idx, &des); - msg (MW, _("The table \"%s\" has no non-empty control variables." - " No result for this table will be displayed."), - ds_cstr (&des)); - ds_destroy (&des); - continue; - } + { + struct string des; + ds_init_empty (&des); + layers_to_string (mt, ws->control_idx, &des); + msg (MW, _("The table \"%s\" has no non-empty control variables." + " No result for this table will be displayed."), + ds_cstr (&des)); + ds_destroy (&des); + continue; + } if (mt->n_dep_vars > 1) - means_shipout_multivar (mt, means, ws); + means_shipout_multivar (mt, means, ws); else - means_shipout_single (mt, means, ws); + means_shipout_single (mt, means, ws); } } @@ -852,10 +852,10 @@ means_shipout (const struct mtable *mt, const struct means *means) static bool control_var_missing (const struct means *means, - const struct mtable *mt, - unsigned int not_wild UNUSED, - const struct ccase *c, - const struct workspace *ws) + const struct mtable *mt, + unsigned int not_wild UNUSED, + const struct ccase *c, + const struct workspace *ws) { bool miss = false; for (int l = 0; l < mt->n_layers; ++l) @@ -871,7 +871,7 @@ control_var_missing (const struct means *means, miss = (var_is_value_missing (var, vv) & means->ctrl_exclude) != 0; if (miss) - break; + break; } return miss; @@ -885,54 +885,54 @@ control_var_missing (const struct means *means, */ static struct cell * service_cell_map (const struct means *means, const struct mtable *mt, - const struct ccase *c, + const struct ccase *c, unsigned int not_wild, - struct hmap *map, - const struct cell *pcell, + struct hmap *map, + const struct cell *pcell, int level, - const struct workspace *ws) + const struct workspace *ws) { struct cell *cell = NULL; if (map) { if (!control_var_missing (means, mt, not_wild, c, ws)) - { - /* Lookup this set of values in the cell's hash table. */ - unsigned int hash = generate_hash (mt, c, not_wild, ws); - cell = lookup_cell (mt, map, hash, c, not_wild, ws); - - /* If it has not been seen before, then create a new - subcell, with this set of values, and insert it - into the table. */ - if (cell == NULL) - { + { + /* Lookup this set of values in the cell's hash table. */ + unsigned int hash = generate_hash (mt, c, not_wild, ws); + cell = lookup_cell (mt, map, hash, c, not_wild, ws); + + /* If it has not been seen before, then create a new + subcell, with this set of values, and insert it + into the table. */ + if (cell == NULL) + { cell = generate_cell (means, mt, c, not_wild, pcell, ws); - hmap_insert (map, &cell->hmap_node, hash); - } - } + hmap_insert (map, &cell->hmap_node, hash); + } + } } else { /* This condition should only happen in the root node case. */ cell = ws->root_cell; if (cell == NULL && - !control_var_missing (means, mt, not_wild, c, ws)) - cell = generate_cell (means, mt, c, not_wild, pcell, ws); + !control_var_missing (means, mt, not_wild, c, ws)) + cell = generate_cell (means, mt, c, not_wild, pcell, ws); } if (cell) { /* Here is where the business really happens! After - testing for missing values, the cell's statistics - are accumulated. */ + testing for missing values, the cell's statistics + are accumulated. */ if (!control_var_missing (means, mt, not_wild, c, ws)) { for (int v = 0; v < mt->n_dep_vars; ++v) { const struct variable *dep_var = mt->dep_vars[v]; - const union value *vv = case_data (c, dep_var); - if (var_is_value_missing (dep_var, vv) & means->dep_exclude) - continue; + const union value *vv = case_data (c, dep_var); + if (var_is_value_missing (dep_var, vv) & means->dep_exclude) + continue; for (int stat = 0; stat < means->n_statistics; ++stat) { @@ -940,19 +940,19 @@ service_cell_map (const struct means *means, const struct mtable *mt, NULL); stat_update *su = cell_spec[means->statistics[stat]].su; su (cell->stat[stat + v * means->n_statistics], weight, - case_num (c, dep_var)); + case_num (c, dep_var)); } } } /* Recurse into all the children (if there are any). */ for (int i = 0; i < cell->n_children; ++i) - { - struct cell_container *cc = cell->children + i; - service_cell_map (means, mt, c, + { + struct cell_container *cc = cell->children + i; + service_cell_map (means, mt, c, not_wild | (0x1U << (i + level)), - &cc->map, cell, level + i + 1, ws); - } + &cc->map, cell, level + i + 1, ws); + } } return cell; @@ -970,17 +970,17 @@ prepare_means (struct means *cmd) for (int i = 0; i < mt->n_combinations; ++i) { struct workspace *ws = mt->ws + i; - ws->root_cell = NULL; + ws->root_cell = NULL; ws->control_idx = xcalloc (mt->n_layers, sizeof *ws->control_idx); ws->instances = xcalloc (mt->n_layers, sizeof *ws->instances); int cmb = i; for (int l = mt->n_layers - 1; l >= 0; --l) { - struct cell_container *instances = ws->instances + l; + struct cell_container *instances = ws->instances + l; const struct layer *layer = mt->layers[l]; ws->control_idx[l] = cmb % layer->n_factor_vars; cmb /= layer->n_factor_vars; - hmap_init (&instances->map); + hmap_init (&instances->map); } } } @@ -996,37 +996,37 @@ post_means (struct means *cmd) { struct mtable *mt = cmd->table + t; for (int cmb = 0; cmb < mt->n_combinations; ++cmb) - { - struct workspace *ws = mt->ws + cmb; - if (ws->root_cell == NULL) - continue; - arrange_cells (ws, ws->root_cell, mt); - /* The root cell should have no parent. */ - assert (ws->root_cell->parent_cell == 0); - - for (int l = 0; l < mt->n_layers; ++l) - { - struct cell_container *instances = ws->instances + l; - bt_init (&instances->bt, compare_instance_3way, NULL); - - /* Iterate the instance hash table, and insert each instance - into the binary tree BT. */ - struct instance *inst; - HMAP_FOR_EACH (inst, struct instance, hmap_node, - &instances->map) - { - bt_insert (&instances->bt, &inst->bt_node); - } - - /* Iterate the binary tree (in order) and assign the index - member accordingly. */ - int index = 0; - BT_FOR_EACH (inst, struct instance, bt_node, &instances->bt) - { - inst->index = index++; - } - } - } + { + struct workspace *ws = mt->ws + cmb; + if (ws->root_cell == NULL) + continue; + arrange_cells (ws, ws->root_cell, mt); + /* The root cell should have no parent. */ + assert (ws->root_cell->parent_cell == 0); + + for (int l = 0; l < mt->n_layers; ++l) + { + struct cell_container *instances = ws->instances + l; + bt_init (&instances->bt, compare_instance_3way, NULL); + + /* Iterate the instance hash table, and insert each instance + into the binary tree BT. */ + struct instance *inst; + HMAP_FOR_EACH (inst, struct instance, hmap_node, + &instances->map) + { + bt_insert (&instances->bt, &inst->bt_node); + } + + /* Iterate the binary tree (in order) and assign the index + member accordingly. */ + int index = 0; + BT_FOR_EACH (inst, struct instance, bt_node, &instances->bt) + { + inst->index = index++; + } + } + } } } @@ -1034,45 +1034,45 @@ post_means (struct means *cmd) /* Update the summary information (the missings and the totals). */ static void update_summaries (const struct means *means, struct mtable *mt, - const struct ccase *c, double weight) + const struct ccase *c, double weight) { for (int dv = 0; dv < mt->n_dep_vars; ++dv) { for (int cmb = 0; cmb < mt->n_combinations; ++cmb) - { - struct workspace *ws = mt->ws + cmb; - struct summary *summ = mt->summ - + cmb * mt->n_dep_vars + dv; - - summ->n_total += weight; - const struct variable *var = mt->dep_vars[dv]; - const union value *vv = case_data (c, var); - /* First check if the dependent variable is missing. */ - if (var_is_value_missing (var, vv) & means->dep_exclude) - summ->n_missing += weight; - /* If the dep var is not missing, then check each - control variable. */ - else - for (int l = 0; l < mt->n_layers; ++l) - { - const struct layer *layer = mt->layers [l]; - const struct variable *var - = layer->factor_vars[ws->control_idx[l]]; - const union value *vv = case_data (c, var); - if (var_is_value_missing (var, vv) & means->ctrl_exclude) - { - summ->n_missing += weight; - break; - } - } - } + { + struct workspace *ws = mt->ws + cmb; + struct summary *summ = mt->summ + + cmb * mt->n_dep_vars + dv; + + summ->n_total += weight; + const struct variable *var = mt->dep_vars[dv]; + const union value *vv = case_data (c, var); + /* First check if the dependent variable is missing. */ + if (var_is_value_missing (var, vv) & means->dep_exclude) + summ->n_missing += weight; + /* If the dep var is not missing, then check each + control variable. */ + else + for (int l = 0; l < mt->n_layers; ++l) + { + const struct layer *layer = mt->layers [l]; + const struct variable *var + = layer->factor_vars[ws->control_idx[l]]; + const union value *vv = case_data (c, var); + if (var_is_value_missing (var, vv) & means->ctrl_exclude) + { + summ->n_missing += weight; + break; + } + } + } } } void run_means (struct means *cmd, struct casereader *input, - const struct dataset *ds UNUSED) + const struct dataset *ds UNUSED) { struct ccase *c = NULL; struct casereader *reader; @@ -1083,20 +1083,20 @@ run_means (struct means *cmd, struct casereader *input, (c = casereader_read (reader)) != NULL; case_unref (c)) { const double weight - = dict_get_case_weight (cmd->dict, c, NULL); + = dict_get_case_weight (cmd->dict, c, NULL); for (int t = 0; t < cmd->n_tables; ++t) - { - struct mtable *mt = cmd->table + t; - update_summaries (cmd, mt, c, weight); - - for (int cmb = 0; cmb < mt->n_combinations; ++cmb) - { - struct workspace *ws = mt->ws + cmb; - - ws->root_cell = service_cell_map (cmd, mt, c, - 0U, NULL, NULL, 0, ws); - } - } + { + struct mtable *mt = cmd->table + t; + update_summaries (cmd, mt, c, weight); + + for (int cmb = 0; cmb < mt->n_combinations; ++cmb) + { + struct workspace *ws = mt->ws + cmb; + + ws->root_cell = service_cell_map (cmd, mt, c, + 0U, NULL, NULL, 0, ws); + } + } } casereader_destroy (reader); @@ -1123,7 +1123,7 @@ cmd_means (struct lexer *lexer, struct dataset *ds) struct mtable *mt = means.table + t; mt->n_combinations = 1; for (int l = 0; l < mt->n_layers; ++l) - mt->n_combinations *= mt->layers[l]->n_factor_vars; + mt->n_combinations *= mt->layers[l]->n_factor_vars; } struct casegrouper *grouper @@ -1133,12 +1133,12 @@ cmd_means (struct lexer *lexer, struct dataset *ds) { /* Allocate the workspaces. */ for (int t = 0; t < means.n_tables; ++t) - { - struct mtable *mt = means.table + t; - mt->summ = xcalloc (mt->n_combinations * mt->n_dep_vars, - sizeof *mt->summ); - mt->ws = xcalloc (mt->n_combinations, sizeof *mt->ws); - } + { + struct mtable *mt = means.table + t; + mt->summ = xcalloc (mt->n_combinations * mt->n_dep_vars, + sizeof *mt->summ); + mt->ws = xcalloc (mt->n_combinations, sizeof *mt->ws); + } run_means (&means, group, ds); for (int t = 0; t < means.n_tables; ++t) { diff --git a/src/language/commands/median.c b/src/language/commands/median.c index 10a4d40650..0218a30d3a 100644 --- a/src/language/commands/median.c +++ b/src/language/commands/median.c @@ -86,7 +86,7 @@ show_test_statistics (const struct n_sample_test *nst, const struct results *res static struct val_node * find_value (const struct hmap *map, const union value *val, - const struct variable *var) + const struct variable *var) { struct val_node *foo = NULL; size_t hash = value_hash (val, var_get_width (var), 0); @@ -99,24 +99,24 @@ find_value (const struct hmap *map, const union value *val, void median_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { const struct dictionary *dict = dataset_dict (ds); const struct variable *wvar = dict_get_weight (dict); bool warn = true; int v; const struct median_test *mt = UP_CAST (test, const struct median_test, - parent.parent); + parent.parent); const struct n_sample_test *nst = UP_CAST (test, const struct n_sample_test, - parent); + parent); const bool n_sample_test = (value_compare_3way (&nst->val2, &nst->val1, - var_get_width (nst->indep_var)) > 0); + var_get_width (nst->indep_var)) > 0); struct results *results = XCALLOC (nst->n_vars, struct results); int n_vals = 0; @@ -133,145 +133,145 @@ median_execute (const struct dataset *ds, if (n_sample_test == false) - { - struct val_node *vn = XZALLOC (struct val_node); - value_clone (&vn->val, &nst->val1, var_get_width (nst->indep_var)); - hmap_insert (&map, &vn->node, value_hash (&nst->val1, - var_get_width (nst->indep_var), 0)); - - vn = xzalloc (sizeof *vn); - value_clone (&vn->val, &nst->val2, var_get_width (nst->indep_var)); - hmap_insert (&map, &vn->node, value_hash (&nst->val2, - var_get_width (nst->indep_var), 0)); - } + { + struct val_node *vn = XZALLOC (struct val_node); + value_clone (&vn->val, &nst->val1, var_get_width (nst->indep_var)); + hmap_insert (&map, &vn->node, value_hash (&nst->val1, + var_get_width (nst->indep_var), 0)); + + vn = xzalloc (sizeof *vn); + value_clone (&vn->val, &nst->val2, var_get_width (nst->indep_var)); + hmap_insert (&map, &vn->node, value_hash (&nst->val2, + var_get_width (nst->indep_var), 0)); + } if (median == SYSMIS) - { - struct percentile *ptl; - struct order_stats *os; - - struct casereader *rr; - struct subcase sc; - struct casewriter *writer; - subcase_init_var (&sc, var, SC_ASCEND); - rr = casereader_clone (r); - writer = sort_create_writer (&sc, casereader_get_proto (rr)); - - for (; (c = casereader_read (rr)) != NULL;) - { - if (var_is_value_missing (var, case_data (c, var)) & exclude) - { - case_unref (c); - continue; - } - - cc += dict_get_case_weight (dict, c, &warn); - casewriter_write (writer, c); - } - subcase_uninit (&sc); - casereader_destroy (rr); - - rr = casewriter_make_reader (writer); - - ptl = percentile_create (0.5, cc); - os = &ptl->parent; - - order_stats_accumulate (&os, 1, - rr, - wvar, - var, - exclude); - - median = percentile_calculate (ptl, PC_HAVERAGE); - statistic_destroy (&ptl->parent.parent); - } + { + struct percentile *ptl; + struct order_stats *os; + + struct casereader *rr; + struct subcase sc; + struct casewriter *writer; + subcase_init_var (&sc, var, SC_ASCEND); + rr = casereader_clone (r); + writer = sort_create_writer (&sc, casereader_get_proto (rr)); + + for (; (c = casereader_read (rr)) != NULL;) + { + if (var_is_value_missing (var, case_data (c, var)) & exclude) + { + case_unref (c); + continue; + } + + cc += dict_get_case_weight (dict, c, &warn); + casewriter_write (writer, c); + } + subcase_uninit (&sc); + casereader_destroy (rr); + + rr = casewriter_make_reader (writer); + + ptl = percentile_create (0.5, cc); + os = &ptl->parent; + + order_stats_accumulate (&os, 1, + rr, + wvar, + var, + exclude); + + median = percentile_calculate (ptl, PC_HAVERAGE); + statistic_destroy (&ptl->parent.parent); + } results[v].median = median; for (; (c = casereader_read (r)) != NULL; case_unref (c)) - { - struct val_node *vn ; - const double weight = dict_get_case_weight (dict, c, &warn); - const union value *val = case_data (c, var); - const union value *indep_val = case_data (c, nst->indep_var); - - if (var_is_value_missing (var, case_data (c, var)) & exclude) - { - continue; - } - - if (n_sample_test) - { - int width = var_get_width (nst->indep_var); - /* Ignore out of range values */ - if ( - value_compare_3way (indep_val, &nst->val1, width) < 0 - || - value_compare_3way (indep_val, &nst->val2, width) > 0 - ) - { - continue; - } - } - - vn = find_value (&map, indep_val, nst->indep_var); - if (vn == NULL) - { - if (n_sample_test == true) - { - 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 - { - continue; - } - } - - if (val->f <= median) - vn->le += weight; - else - vn->gt += weight; - - count += weight; - } + { + struct val_node *vn ; + const double weight = dict_get_case_weight (dict, c, &warn); + const union value *val = case_data (c, var); + const union value *indep_val = case_data (c, nst->indep_var); + + if (var_is_value_missing (var, case_data (c, var)) & exclude) + { + continue; + } + + if (n_sample_test) + { + int width = var_get_width (nst->indep_var); + /* Ignore out of range values */ + if ( + value_compare_3way (indep_val, &nst->val1, width) < 0 + || + value_compare_3way (indep_val, &nst->val2, width) > 0 + ) + { + continue; + } + } + + vn = find_value (&map, indep_val, nst->indep_var); + if (vn == NULL) + { + if (n_sample_test == true) + { + 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 + { + continue; + } + } + + if (val->f <= median) + vn->le += weight; + else + vn->gt += weight; + + count += weight; + } casereader_destroy (r); { - int x = 0; - struct val_node *vn = NULL; - double r_0 = 0; - double r_1 = 0; - HMAP_FOR_EACH (vn, struct val_node, node, &map) - { - r_0 += vn->le; - r_1 += vn->gt; - } + int x = 0; + struct val_node *vn = NULL; + double r_0 = 0; + double r_1 = 0; + HMAP_FOR_EACH (vn, struct val_node, node, &map) + { + r_0 += vn->le; + r_1 += vn->gt; + } - results[v].n = count; - results[v].sorted_array = XCALLOC (hmap_count (&map), struct val_node *); - results[v].var = var; + results[v].n = count; + results[v].sorted_array = XCALLOC (hmap_count (&map), struct val_node *); + results[v].var = var; - HMAP_FOR_EACH (vn, struct val_node, node, &map) - { - double e_0j = r_0 * (vn->le + vn->gt) / count; - double e_1j = r_1 * (vn->le + vn->gt) / count; + HMAP_FOR_EACH (vn, struct val_node, node, &map) + { + double e_0j = r_0 * (vn->le + vn->gt) / count; + double e_1j = r_1 * (vn->le + vn->gt) / count; - results[v].chisq += pow2 (vn->le - e_0j) / e_0j; - results[v].chisq += pow2 (vn->gt - e_1j) / e_1j; + results[v].chisq += pow2 (vn->le - e_0j) / e_0j; + results[v].chisq += pow2 (vn->gt - e_1j) / e_1j; - results[v].sorted_array[x++] = vn; - } + results[v].sorted_array[x++] = vn; + } - n_vals = x; - hmap_destroy (&map); + n_vals = x; + hmap_destroy (&map); - sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array), - val_node_cmp_3way, nst->indep_var); + sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array), + val_node_cmp_3way, nst->indep_var); } } @@ -287,11 +287,11 @@ median_execute (const struct dataset *ds, const struct results *rs = results + v; for (i = 0; i < n_vals; ++i) - { - struct val_node *vn = rs->sorted_array[i]; - value_destroy (&vn->val, var_get_width (nst->indep_var)); - free (vn); - } + { + struct val_node *vn = rs->sorted_array[i]; + value_destroy (&vn->val, var_get_width (nst->indep_var)); + free (vn); + } free (rs->sorted_array); } free (results); @@ -326,13 +326,13 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results dep->root, pivot_value_new_variable (rs->var)); for (int indep_idx = 0; indep_idx < n_vals; indep_idx++) - { - const struct val_node *vn = rs->sorted_array[indep_idx]; + { + const struct val_node *vn = rs->sorted_array[indep_idx]; pivot_table_put3 (table, indep_idx, 0, dep_idx, pivot_value_new_number (vn->gt)); pivot_table_put3 (table, indep_idx, 1, dep_idx, pivot_value_new_number (vn->le)); - } + } } pivot_table_submit (table); @@ -340,9 +340,9 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results static void show_test_statistics (const struct n_sample_test *nst, - const struct results *results, - int n_vals, - const struct dictionary *dict) + const struct results *results, + int n_vals, + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create (N_("Test Statistics")); pivot_table_set_weight_var (table, dict_get_weight (dict)); diff --git a/src/language/commands/median.h b/src/language/commands/median.h index ba2a25a4e3..638ddc6962 100644 --- a/src/language/commands/median.h +++ b/src/language/commands/median.h @@ -31,11 +31,11 @@ struct casereader; struct dataset; void median_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer - ); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer + ); #endif diff --git a/src/language/commands/npar-summary.c b/src/language/commands/npar-summary.c index 08a678df83..6c269f24f8 100644 --- a/src/language/commands/npar-summary.c +++ b/src/language/commands/npar-summary.c @@ -37,10 +37,10 @@ void npar_summary_calc_descriptives (struct descriptives *desc, - struct casereader *input, - const struct dictionary *dict, - const struct variable *const *vv, - int n_vars, + struct casereader *input, + const struct dictionary *dict, + const struct variable *const *vv, + int n_vars, enum mv_class filter) { int i = 0; @@ -60,21 +60,21 @@ npar_summary_calc_descriptives (struct descriptives *desc, filter, NULL, NULL); pass = casereader_create_filter_weight (pass, dict, NULL, NULL); while ((c = casereader_read (pass)) != NULL) - { + { double val = case_num (c, v); double w = dict_get_case_weight (dict, c, NULL); minimum = MIN (minimum, val); maximum = MAX (maximum, val); moments1_add (moments, val, w); - case_unref (c); - } + case_unref (c); + } casereader_destroy (pass); moments1_calculate (moments, - &desc[i].n, - &desc[i].mean, - &var, - NULL, NULL); + &desc[i].n, + &desc[i].mean, + &var, + NULL, NULL); desc[i].std_dev = sqrt (var); @@ -91,8 +91,8 @@ npar_summary_calc_descriptives (struct descriptives *desc, void do_summary_box (const struct descriptives *desc, - const struct variable *const *vv, - int n_vars, + const struct variable *const *vv, + int n_vars, const struct fmt_spec wfmt) { if (!desc) diff --git a/src/language/commands/npar-summary.h b/src/language/commands/npar-summary.h index 003cf89e9f..91e8bf2089 100644 --- a/src/language/commands/npar-summary.h +++ b/src/language/commands/npar-summary.h @@ -35,15 +35,15 @@ struct descriptives void do_summary_box (const struct descriptives *desc, - const struct variable *const *vv, - int n_vars, + const struct variable *const *vv, + int n_vars, const struct fmt_spec wfmt); void npar_summary_calc_descriptives (struct descriptives *desc, - struct casereader *input, - const struct dictionary *dict, - const struct variable *const *vv, - int n_vars, + struct casereader *input, + const struct dictionary *dict, + const struct variable *const *vv, + int n_vars, enum mv_class filter); #endif diff --git a/src/language/commands/npar.c b/src/language/commands/npar.c index d3b357cd77..721a84aad8 100644 --- a/src/language/commands/npar.c +++ b/src/language/commands/npar.c @@ -70,7 +70,7 @@ struct npar_specs size_t n_tests; const struct variable **vv; /* Compendium of all variables - (those mentioned on ANY subcommand */ + (those mentioned on ANY subcommand */ int n_vars; /* Number of variables in vv */ enum mv_class filter; /* Missing values to filter. */ @@ -113,25 +113,25 @@ parse_npar_tests (struct lexer *lexer, struct dataset *ds, do { if (lex_match_id (lexer, "COCHRAN")) - { + { if (!npar_cochran (lexer, ds, nps)) return false; - } + } else if (lex_match_id (lexer, "FRIEDMAN")) - { + { if (!npar_friedman (lexer, ds, nps)) return false; - } + } else if (lex_match_id (lexer, "KENDALL")) - { + { if (!npar_kendall (lexer, ds, nps)) return false; - } + } else if (lex_match_id (lexer, "RUNS")) - { + { if (!npar_runs (lexer, ds, nps)) return false; - } + } else if (lex_match_id (lexer, "CHISQUARE")) { lex_match (lexer, T_EQUALS); @@ -145,21 +145,21 @@ parse_npar_tests (struct lexer *lexer, struct dataset *ds, return false; } else if (lex_match_phrase (lexer, "K-S") || - lex_match_phrase (lexer, "KOLMOGOROV-SMIRNOV")) + lex_match_phrase (lexer, "KOLMOGOROV-SMIRNOV")) { lex_match (lexer, T_EQUALS); if (!npar_ks_one_sample (lexer, ds, nps)) return false; } else if (lex_match_phrase (lexer, "J-T") || - lex_match_phrase (lexer, "JONCKHEERE-TERPSTRA")) + lex_match_phrase (lexer, "JONCKHEERE-TERPSTRA")) { lex_match (lexer, T_EQUALS); if (!npar_jonckheere_terpstra (lexer, ds, nps)) return false; } else if (lex_match_phrase (lexer, "K-W") || - lex_match_phrase (lexer, "KRUSKAL-WALLIS")) + lex_match_phrase (lexer, "KRUSKAL-WALLIS")) { lex_match (lexer, T_EQUALS); if (!npar_kruskal_wallis (lexer, ds, nps)) @@ -172,12 +172,12 @@ parse_npar_tests (struct lexer *lexer, struct dataset *ds, return false; } else if (lex_match_phrase (lexer, "M-W") || - lex_match_phrase (lexer, "MANN-WHITNEY")) + lex_match_phrase (lexer, "MANN-WHITNEY")) { lex_match (lexer, T_EQUALS); if (!npar_mann_whitney (lexer, ds, nps)) return false; - } + } else if (lex_match_phrase (lexer, "MEDIAN")) { if (!npar_median (lexer, ds, nps)) @@ -284,18 +284,18 @@ parse_npar_tests (struct lexer *lexer, struct dataset *ds, } static void one_sample_insert_variables (const struct npar_test *test, - struct hmapx *); + struct hmapx *); static void two_sample_insert_variables (const struct npar_test *test, - struct hmapx *); + struct hmapx *); static void n_sample_insert_variables (const struct npar_test *test, - struct hmapx *); + struct hmapx *); static void npar_execute (struct casereader *input, const struct npar_specs *specs, - const struct dataset *ds) + const struct dataset *ds) { struct descriptives *summary_descriptives = NULL; @@ -309,12 +309,12 @@ npar_execute (struct casereader *input, if (specs->descriptives && specs->n_vars > 0) { summary_descriptives = xnmalloc (sizeof (*summary_descriptives), - specs->n_vars); + specs->n_vars); npar_summary_calc_descriptives (summary_descriptives, casereader_clone (input), - dataset_dict (ds), - specs->vv, specs->n_vars, + dataset_dict (ds), + specs->vv, specs->n_vars, specs->filter); } @@ -358,7 +358,7 @@ cmd_npar_tests (struct lexer *lexer, struct dataset *ds) assert (npar_specs.n_vars == hmapx_count (&var_map)); sort (npar_specs.vv, npar_specs.n_vars, sizeof *npar_specs.vv, - compare_var_ptrs_by_name, NULL); + compare_var_ptrs_by_name, NULL); struct casereader *input = proc_open (ds); if (npar_specs.listwise_missing) @@ -385,14 +385,14 @@ static void add_test (struct npar_specs *specs, struct npar_test *nt) { specs->test = pool_realloc (specs->pool, specs->test, - (specs->n_tests + 1) * sizeof *specs->test); + (specs->n_tests + 1) * sizeof *specs->test); specs->test[specs->n_tests++] = nt; } static bool npar_runs (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct runs_test *rt = pool_alloc (specs->pool, sizeof (*rt)); struct one_sample_test *tp = &rt->parent; @@ -437,7 +437,7 @@ npar_runs (struct lexer *lexer, struct dataset *ds, static bool npar_friedman (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct friedman_test *ft = pool_alloc (specs->pool, sizeof (*ft)); struct one_sample_test *ost = &ft->parent; @@ -450,8 +450,8 @@ npar_friedman (struct lexer *lexer, struct dataset *ds, lex_match (lexer, T_EQUALS); if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds), - &ost->vars, &ost->n_vars, - PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) + &ost->vars, &ost->n_vars, + PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) return false; add_test (specs, nt); @@ -460,7 +460,7 @@ npar_friedman (struct lexer *lexer, struct dataset *ds, static bool npar_kendall (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct friedman_test *kt = pool_alloc (specs->pool, sizeof (*kt)); struct one_sample_test *ost = &kt->parent; @@ -473,8 +473,8 @@ npar_kendall (struct lexer *lexer, struct dataset *ds, lex_match (lexer, T_EQUALS); if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds), - &ost->vars, &ost->n_vars, - PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) + &ost->vars, &ost->n_vars, + PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) return false; add_test (specs, nt); @@ -484,7 +484,7 @@ npar_kendall (struct lexer *lexer, struct dataset *ds, static bool npar_cochran (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct one_sample_test *ft = pool_alloc (specs->pool, sizeof (*ft)); struct npar_test *nt = &ft->parent; @@ -495,8 +495,8 @@ npar_cochran (struct lexer *lexer, struct dataset *ds, lex_match (lexer, T_EQUALS); if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds), - &ft->vars, &ft->n_vars, - PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) + &ft->vars, &ft->n_vars, + PV_NO_SCRATCH | PV_NO_DUPLICATE | PV_NUMERIC)) return false; add_test (specs, nt); @@ -505,7 +505,7 @@ npar_cochran (struct lexer *lexer, struct dataset *ds, static bool npar_chisquare (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct chisquare_test *cstp = pool_alloc (specs->pool, sizeof (*cstp)); struct one_sample_test *tp = &cstp->parent; @@ -515,8 +515,8 @@ npar_chisquare (struct lexer *lexer, struct dataset *ds, nt->insert_variables = one_sample_insert_variables; if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds), - &tp->vars, &tp->n_vars, - PV_NO_SCRATCH | PV_NO_DUPLICATE)) + &tp->vars, &tp->n_vars, + PV_NO_SCRATCH | PV_NO_DUPLICATE)) return false; cstp->ranged = false; @@ -594,7 +594,7 @@ npar_chisquare (struct lexer *lexer, struct dataset *ds, static bool npar_binomial (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct binomial_test *btp = pool_alloc (specs->pool, sizeof (*btp)); struct one_sample_test *tp = &btp->parent; @@ -610,7 +610,7 @@ npar_binomial (struct lexer *lexer, struct dataset *ds, if (lex_match (lexer, T_LPAREN)) { if (!lex_force_num (lexer)) - return false; + return false; btp->p = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) @@ -658,14 +658,14 @@ ks_one_sample_parse_params (struct lexer *lexer, struct ks_one_sample_test *kst, lex_get (lexer); if (params == 2) - { - lex_match (lexer, T_COMMA); - if (lex_force_num (lexer)) - { - kst->p[1] = lex_number (lexer); - lex_get (lexer); - } - } + { + lex_match (lexer, T_COMMA); + if (lex_force_num (lexer)) + { + kst->p[1] = lex_number (lexer); + lex_get (lexer); + } + } } } @@ -728,9 +728,9 @@ npar_ks_one_sample (struct lexer *lexer, struct dataset *ds, struct npar_specs * static bool parse_two_sample_related_test (struct lexer *lexer, - const struct dictionary *dict, - struct two_sample_test *tp, - struct pool *pool) + const struct dictionary *dict, + struct two_sample_test *tp, + struct pool *pool) { tp->parent.insert_variables = two_sample_insert_variables; @@ -738,7 +738,7 @@ parse_two_sample_related_test (struct lexer *lexer, size_t n1; int vars_start = lex_ofs (lexer); if (!parse_variables_const_pool (lexer, pool, dict, &v1, &n1, - PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE)) + PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE)) return false; bool with = false; @@ -750,7 +750,7 @@ parse_two_sample_related_test (struct lexer *lexer, with = true; if (!parse_variables_const_pool (lexer, pool, dict, &v2, &n2, PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE)) - return false; + return false; int vars_end = lex_ofs (lexer) - 1; if (lex_match (lexer, T_LPAREN)) @@ -759,9 +759,9 @@ parse_two_sample_related_test (struct lexer *lexer, return false; paired = true; - if (n1 != n2) + if (n1 != n2) { - lex_ofs_error (lexer, vars_start, vars_end, + lex_ofs_error (lexer, vars_start, vars_end, _("PAIRED was specified, but the number of " "variables preceding WITH (%zu) does not match " "the number following (%zu)."), @@ -813,10 +813,10 @@ parse_two_sample_related_test (struct lexer *lexer, static bool parse_n_sample_related_test (struct lexer *lexer, const struct dictionary *dict, - struct n_sample_test *nst, struct pool *pool) + struct n_sample_test *nst, struct pool *pool) { if (!parse_variables_const_pool (lexer, pool, dict, &nst->vars, &nst->n_vars, - PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE)) + PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE)) return false; if (!lex_force_match (lexer, T_BY)) @@ -853,15 +853,15 @@ parse_n_sample_related_test (struct lexer *lexer, const struct dictionary *dict, static bool npar_wilcoxon (struct lexer *lexer, - struct dataset *ds, - struct npar_specs *specs) + struct dataset *ds, + struct npar_specs *specs) { struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); struct npar_test *nt = &tp->parent; nt->execute = wilcoxon_execute; if (!parse_two_sample_related_test (lexer, dataset_dict (ds), - tp, specs->pool)) + tp, specs->pool)) return false; add_test (specs, nt); @@ -888,8 +888,8 @@ npar_mann_whitney (struct lexer *lexer, static bool npar_median (struct lexer *lexer, - struct dataset *ds, - struct npar_specs *specs) + struct dataset *ds, + struct npar_specs *specs) { struct median_test *mt = pool_alloc (specs->pool, sizeof (*mt)); struct n_sample_test *tp = &mt->parent; @@ -905,7 +905,7 @@ npar_median (struct lexer *lexer, lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) - return false; + return false; } lex_match (lexer, T_EQUALS); @@ -922,7 +922,7 @@ npar_median (struct lexer *lexer, static bool npar_sign (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); struct npar_test *nt = &tp->parent; @@ -930,7 +930,7 @@ npar_sign (struct lexer *lexer, struct dataset *ds, nt->execute = sign_execute; if (!parse_two_sample_related_test (lexer, dataset_dict (ds), - tp, specs->pool)) + tp, specs->pool)) return false; add_test (specs, nt); @@ -939,7 +939,7 @@ npar_sign (struct lexer *lexer, struct dataset *ds, static bool npar_mcnemar (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); struct npar_test *nt = &tp->parent; @@ -947,7 +947,7 @@ npar_mcnemar (struct lexer *lexer, struct dataset *ds, nt->execute = mcnemar_execute; if (!parse_two_sample_related_test (lexer, dataset_dict (ds), - tp, specs->pool)) + tp, specs->pool)) return false; add_test (specs, nt); @@ -957,7 +957,7 @@ npar_mcnemar (struct lexer *lexer, struct dataset *ds, static bool npar_jonckheere_terpstra (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct n_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); struct npar_test *nt = &tp->parent; @@ -974,7 +974,7 @@ npar_jonckheere_terpstra (struct lexer *lexer, struct dataset *ds, static bool npar_kruskal_wallis (struct lexer *lexer, struct dataset *ds, - struct npar_specs *specs) + struct npar_specs *specs) { struct n_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); struct npar_test *nt = &tp->parent; @@ -1007,7 +1007,7 @@ insert_variable_into_map (struct hmapx *var_map, const struct variable *var) /* Insert the variables for TEST into VAR_MAP */ static void one_sample_insert_variables (const struct npar_test *test, - struct hmapx *var_map) + struct hmapx *var_map) { const struct one_sample_test *ost = UP_CAST (test, const struct one_sample_test, parent); @@ -1018,7 +1018,7 @@ one_sample_insert_variables (const struct npar_test *test, static void two_sample_insert_variables (const struct npar_test *test, - struct hmapx *var_map) + struct hmapx *var_map) { const struct two_sample_test *tst = UP_CAST (test, const struct two_sample_test, parent); @@ -1033,7 +1033,7 @@ two_sample_insert_variables (const struct npar_test *test, static void n_sample_insert_variables (const struct npar_test *test, - struct hmapx *var_map) + struct hmapx *var_map) { const struct n_sample_test *tst = UP_CAST (test, const struct n_sample_test, parent); @@ -1051,19 +1051,19 @@ npar_method (struct lexer *lexer, struct npar_specs *specs) specs->exact = true; specs->timer = 0.0; if (lex_match_id (lexer, "TIMER")) - { - specs->timer = 5.0; + { + specs->timer = 5.0; - if (lex_match (lexer, T_LPAREN)) - { - if (!lex_force_num (lexer)) + if (lex_match (lexer, T_LPAREN)) + { + if (!lex_force_num (lexer)) return false; specs->timer = lex_number (lexer); lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - return false; - } - } + if (!lex_force_match (lexer, T_RPAREN)) + return false; + } + } } return true; diff --git a/src/language/commands/npar.h b/src/language/commands/npar.h index 367cf65d3b..f8d2759b9d 100644 --- a/src/language/commands/npar.h +++ b/src/language/commands/npar.h @@ -33,14 +33,14 @@ struct dataset; struct npar_test { void (*execute) (const struct dataset *, - struct casereader *, + struct casereader *, enum mv_class exclude, - const struct npar_test *, - bool, - double); + const struct npar_test *, + bool, + double); void (*insert_variables) (const struct npar_test *, - struct hmapx *); + struct hmapx *); }; diff --git a/src/language/commands/numeric.c b/src/language/commands/numeric.c index 73ca39b7da..6f10c927c1 100644 --- a/src/language/commands/numeric.c +++ b/src/language/commands/numeric.c @@ -44,7 +44,7 @@ cmd_numeric (struct lexer *lexer, struct dataset *ds) int vars_start = lex_ofs (lexer); if (!parse_DATA_LIST_vars (lexer, dataset_dict (ds), &v, &nv, PV_NO_DUPLICATE)) - return CMD_FAILURE; + return CMD_FAILURE; int vars_end = lex_ofs (lexer) - 1; bool ok = false; @@ -52,9 +52,9 @@ cmd_numeric (struct lexer *lexer, struct dataset *ds) /* Get the optional format specification. */ struct fmt_spec f = var_default_formats (0); if (lex_match (lexer, T_LPAREN)) - { - if (!parse_format_specifier (lexer, &f)) - goto done; + { + if (!parse_format_specifier (lexer, &f)) + goto done; char *error = fmt_check_output__ (f); if (error) @@ -64,38 +64,38 @@ cmd_numeric (struct lexer *lexer, struct dataset *ds) goto done; } - if (fmt_is_string (f.type)) - { + if (fmt_is_string (f.type)) + { char str[FMT_STRING_LEN_MAX + 1]; - lex_next_error (lexer, -1, -1, + lex_next_error (lexer, -1, -1, _("Format type %s may not be used with a numeric " "variable."), fmt_to_string (f, str)); - goto done; - } + goto done; + } - if (!lex_match (lexer, T_RPAREN)) - { + if (!lex_match (lexer, T_RPAREN)) + { lex_error_expecting (lexer, "`)'"); - goto done; - } - } + goto done; + } + } /* Create each variable. */ for (size_t i = 0; i < nv; i++) - { - struct variable *new_var = dict_create_var (dataset_dict (ds), + { + struct variable *new_var = dict_create_var (dataset_dict (ds), v[i], 0); - if (!new_var) - lex_ofs_error (lexer, vars_start, vars_end, + if (!new_var) + lex_ofs_error (lexer, vars_start, vars_end, _("There is already a variable named %s."), v[i]); - else + else var_set_both_formats (new_var, f); - } + } ok = true; done: for (size_t i = 0; i < nv; i++) - free (v[i]); + free (v[i]); free (v); if (!ok) return CMD_FAILURE; @@ -116,7 +116,7 @@ cmd_string (struct lexer *lexer, struct dataset *ds) int vars_start = lex_ofs (lexer); if (!parse_DATA_LIST_vars (lexer, dataset_dict (ds), &v, &nv, PV_NO_DUPLICATE)) - return CMD_FAILURE; + return CMD_FAILURE; int vars_end = lex_ofs (lexer) - 1; bool ok = false; @@ -124,7 +124,7 @@ cmd_string (struct lexer *lexer, struct dataset *ds) struct fmt_spec f; if (!lex_force_match (lexer, T_LPAREN) || !parse_format_specifier (lexer, &f)) - goto done; + goto done; char *error = fmt_check_type_compat__ (f, NULL, VAL_STRING); if (!error) @@ -142,20 +142,20 @@ cmd_string (struct lexer *lexer, struct dataset *ds) /* Create each variable. */ int width = fmt_var_width (f); for (size_t i = 0; i < nv; i++) - { - struct variable *new_var = dict_create_var (dataset_dict (ds), v[i], + { + struct variable *new_var = dict_create_var (dataset_dict (ds), v[i], width); - if (!new_var) - lex_ofs_error (lexer, vars_start, vars_end, + if (!new_var) + lex_ofs_error (lexer, vars_start, vars_end, _("There is already a variable named %s."), v[i]); - else + else var_set_both_formats (new_var, f); - } + } ok = true; done: for (size_t i = 0; i < nv; i++) - free (v[i]); + free (v[i]); free (v); if (!ok) return CMD_FAILURE; diff --git a/src/language/commands/oneway.c b/src/language/commands/oneway.c index ba4e1c1395..f3296e64aa 100644 --- a/src/language/commands/oneway.c +++ b/src/language/commands/oneway.c @@ -225,9 +225,9 @@ static double gh_pinv (double std_err UNUSED, double alpha, double df, int k, co 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, - const struct posthoc *ph) + const struct per_var_ws *pvw, + const struct descriptive_data *dd_i, const struct descriptive_data *dd_j, + const struct posthoc *ph) { int k = pvw->n_groups; double df = ph->dff (pvw, dd_i->mom, dd_j->mom); @@ -435,8 +435,8 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) } if (!parse_variables_const (lexer, dict, - &oneway.vars, &oneway.n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + &oneway.vars, &oneway.n_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) goto error; if (!lex_force_match (lexer, T_BY)) @@ -451,28 +451,28 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "STATISTICS")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "DESCRIPTIVES")) + { + if (lex_match_id (lexer, "DESCRIPTIVES")) oneway.descriptive_stats = true; - else if (lex_match_id (lexer, "HOMOGENEITY")) + else if (lex_match_id (lexer, "HOMOGENEITY")) oneway.homogeneity_stats = true; - else - { - lex_error_expecting (lexer, "DESCRIPTIVES", "HOMOGENEITY"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "DESCRIPTIVES", "HOMOGENEITY"); + goto error; + } + } + } else if (lex_match_id (lexer, "POSTHOC")) - { + { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - bool method = false; - for (size_t p = 0; p < sizeof ph_tests / sizeof *ph_tests; ++p) + { + bool method = false; + for (size_t p = 0; p < sizeof ph_tests / sizeof *ph_tests; ++p) if (lex_match_id (lexer, ph_tests[p].syntax)) { oneway.n_posthoc++; @@ -481,85 +481,85 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) method = true; break; } - if (method == false) - { - if (lex_match_id (lexer, "ALPHA")) - { - if (!lex_force_match (lexer, T_LPAREN) + if (method == false) + { + if (lex_match_id (lexer, "ALPHA")) + { + if (!lex_force_match (lexer, T_LPAREN) || !lex_force_num (lexer)) - goto error; - oneway.alpha = lex_number (lexer); - lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - else - { - lex_error (lexer, _("Unknown post hoc analysis method.")); - goto error; - } - } - } - } + goto error; + oneway.alpha = lex_number (lexer); + lex_get (lexer); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + else + { + lex_error (lexer, _("Unknown post hoc analysis method.")); + goto error; + } + } + } + } else if (lex_match_id (lexer, "CONTRAST")) - { - struct contrasts_node *cl = XZALLOC (struct contrasts_node); + { + struct contrasts_node *cl = XZALLOC (struct contrasts_node); - struct ll_list *coefficient_list = &cl->coefficient_list; + struct ll_list *coefficient_list = &cl->coefficient_list; lex_match (lexer, T_EQUALS); - ll_init (coefficient_list); + ll_init (coefficient_list); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { + { if (!lex_force_num (lexer)) - { - destroy_coeff_list (cl); - goto error; - } + { + destroy_coeff_list (cl); + goto error; + } struct coeff_node *cc = xmalloc (sizeof *cc); cc->coeff = lex_number (lexer); ll_push_tail (coefficient_list, &cc->ll); lex_get (lexer); - } + } - if (ll_count (coefficient_list) <= 0) + if (ll_count (coefficient_list) <= 0) { destroy_coeff_list (cl); goto error; } - ll_push_tail (&oneway.contrast_list, &cl->ll); - } + ll_push_tail (&oneway.contrast_list, &cl->ll); + } else if (lex_match_id (lexer, "MISSING")) { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) { - if (lex_match_id (lexer, "INCLUDE")) + if (lex_match_id (lexer, "INCLUDE")) oneway.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) oneway.exclude = MV_ANY; - else if (lex_match_id (lexer, "LISTWISE")) + else if (lex_match_id (lexer, "LISTWISE")) oneway.missing_type = MISS_LISTWISE; - else if (lex_match_id (lexer, "ANALYSIS")) + else if (lex_match_id (lexer, "ANALYSIS")) oneway.missing_type = MISS_ANALYSIS; - else - { + else + { lex_error_expecting (lexer, "INCLUDE", "EXCLUDE", "LISTWISE", "ANALYSIS"); - goto error; - } - } - } + goto error; + } + } + } else - { - lex_error_expecting (lexer, "STATISTICS", "POSTHOC", "CONTRAST", + { + lex_error_expecting (lexer, "STATISTICS", "POSTHOC", "CONTRAST", "MISSING"); - goto error; - } + goto error; + } } struct casegrouper *grouper = casegrouper_create_splits (proc_open (ds), dict); @@ -620,7 +620,7 @@ killit (const void *aux1 UNUSED, void *aux2 UNUSED, void *user_data) static void updateit (const void *aux1, void *aux2, void *user_data, - const struct ccase *c, double weight) + const struct ccase *c, double weight) { struct descriptive_data *dd = user_data; @@ -642,8 +642,8 @@ updateit (const void *aux1, void *aux2, void *user_data, const union value *val = case_data (c, var); moments1_add (dd_total->mom, - val->f, - weight); + val->f, + weight); if (val->f < dd_total->minimum) dd_total->minimum = val->f; @@ -680,13 +680,13 @@ run_oneway (const struct oneway_spec *cmd, struct casereader *input, cmd->exclude); categoricals_set_payload (ws.vws[v].cat, &payload, - CONST_CAST (struct variable *, cmd->vars[v]), - ws.dd_total[v]); + 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, - cmd->wv, cmd->exclude, true); + ws.vws[v].cat, + cmd->wv, cmd->exclude, true); ws.vws[v].nl = levene_create (var_get_width (cmd->indep_var), NULL); } @@ -707,20 +707,20 @@ run_oneway (const struct oneway_spec *cmd, struct casereader *input, double w = dict_get_case_weight (dict, c, NULL); for (size_t i = 0; i < cmd->n_vars; ++i) - { - struct per_var_ws *pvw = &ws.vws[i]; - const struct variable *v = cmd->vars[i]; - const union value *val = case_data (c, v); - - if (MISS_ANALYSIS == cmd->missing_type) - { - if (var_is_value_missing (v, val) & cmd->exclude) - continue; - } - - covariance_accumulate_pass1 (pvw->cov, c); - levene_pass_one (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); - } + { + struct per_var_ws *pvw = &ws.vws[i]; + const struct variable *v = cmd->vars[i]; + const union value *val = case_data (c, v); + + if (MISS_ANALYSIS == cmd->missing_type) + { + if (var_is_value_missing (v, val) & cmd->exclude) + continue; + } + + covariance_accumulate_pass1 (pvw->cov, c); + levene_pass_one (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); + } } casereader_destroy (reader); @@ -729,20 +729,20 @@ run_oneway (const struct oneway_spec *cmd, struct casereader *input, { double w = dict_get_case_weight (dict, c, NULL); for (size_t i = 0; i < cmd->n_vars; ++i) - { - struct per_var_ws *pvw = &ws.vws[i]; - const struct variable *v = cmd->vars[i]; - const union value *val = case_data (c, v); - - if (MISS_ANALYSIS == cmd->missing_type) - { - if (var_is_value_missing (v, val) & cmd->exclude) - continue; - } - - covariance_accumulate_pass2 (pvw->cov, c); - levene_pass_two (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); - } + { + struct per_var_ws *pvw = &ws.vws[i]; + const struct variable *v = cmd->vars[i]; + const union value *val = case_data (c, v); + + if (MISS_ANALYSIS == cmd->missing_type) + { + if (var_is_value_missing (v, val) & cmd->exclude) + continue; + } + + covariance_accumulate_pass2 (pvw->cov, c); + levene_pass_two (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); + } } casereader_destroy (reader); @@ -752,19 +752,19 @@ run_oneway (const struct oneway_spec *cmd, struct casereader *input, double w = dict_get_case_weight (dict, c, NULL); for (size_t i = 0; i < cmd->n_vars; ++i) - { - struct per_var_ws *pvw = &ws.vws[i]; - const struct variable *v = cmd->vars[i]; - const union value *val = case_data (c, v); - - if (MISS_ANALYSIS == cmd->missing_type) - { - if (var_is_value_missing (v, val) & cmd->exclude) - continue; - } - - levene_pass_three (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); - } + { + struct per_var_ws *pvw = &ws.vws[i]; + const struct variable *v = cmd->vars[i]; + const union value *val = case_data (c, v); + + if (MISS_ANALYSIS == cmd->missing_type) + { + if (var_is_value_missing (v, val) & cmd->exclude) + continue; + } + + levene_pass_three (pvw->nl, val->f, w, case_data (c, cmd->indep_var)); + } } casereader_destroy (reader); @@ -774,12 +774,12 @@ run_oneway (const struct oneway_spec *cmd, struct casereader *input, const struct categoricals *cats = covariance_get_categoricals (pvw->cov); if (!categoricals_sane (cats)) - { - msg (MW, _("Dependent variable %s has no non-missing values. " + { + 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; - } + var_get_name (cmd->vars[v])); + continue; + } const gsl_matrix *ucm = covariance_calculate_unnormalized (pvw->cov); @@ -850,21 +850,21 @@ output_oneway (const struct oneway_spec *cmd, struct oneway_workspace *ws) ++list_idx; if (ll_count (cl) != ws->actual_number_of_groups) - { - msg (SW, - _("In contrast list %zu, the number of coefficients (%zu) does not equal the number of groups (%d). This contrast list will be ignored."), - list_idx, ll_count (cl), ws->actual_number_of_groups); + { + msg (SW, + _("In contrast list %zu, the number of coefficients (%zu) does not equal the number of groups (%d). This contrast list will be ignored."), + list_idx, ll_count (cl), ws->actual_number_of_groups); - ll_remove (&coeff_list->ll); - destroy_coeff_list (coeff_list); - continue; - } + ll_remove (&coeff_list->ll); + destroy_coeff_list (coeff_list); + continue; + } ll_for_each (cn, struct coeff_node, ll, cl) - sum += cn->coeff; + sum += cn->coeff; if (sum != 0.0) - msg (SW, _("Coefficients for contrast %zu do not total zero"), + msg (SW, _("Coefficients for contrast %zu do not total zero"), list_idx); } @@ -1014,16 +1014,16 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace int count; for (count = 0; count < categoricals_n_total (cats); ++count) - { - const struct descriptive_data *dd + { + const struct descriptive_data *dd = categoricals_get_user_data_by_category (cats, count); - double n, mean, variance; - moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL); + double n, mean, variance; + moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL); - double std_dev = sqrt (variance); - double std_error = std_dev / sqrt (n); - double T = gsl_cdf_tdist_Qinv (q, n - 1); + double std_dev = sqrt (variance); + double std_error = std_dev / sqrt (n); + double T = gsl_cdf_tdist_Qinv (q, n - 1); double entries[] = { n, @@ -1038,7 +1038,7 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace for (size_t i = 0; i < sizeof entries / sizeof *entries; i++) pivot_table_put3 (table, i, count, dep_var_idx, pivot_value_new_number (entries[i])); - } + } if (categoricals_is_complete (cats)) { @@ -1140,9 +1140,9 @@ show_contrast_coeffs (const struct oneway_spec *cmd, const struct oneway_workspa const struct coeff_node *coeffn; int indep_idx = 0; ll_for_each (coeffn, struct coeff_node, ll, &cn->coefficient_list) - { - const struct categoricals *cats = covariance_get_categoricals (cov); - const struct ccase *gcc = categoricals_get_case_by_category ( + { + const struct categoricals *cats = covariance_get_categoricals (cov); + const struct ccase *gcc = categoricals_get_case_by_category ( cats, indep_idx); if (!contrast_idx) @@ -1152,7 +1152,7 @@ show_contrast_coeffs (const struct oneway_spec *cmd, const struct oneway_workspa pivot_table_put2 (table, indep_idx++, contrast_idx, pivot_value_new_integer (coeffn->coeff)); - } + } } pivot_table_submit (table); @@ -1190,7 +1190,7 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac const struct per_var_ws *pvw = &ws->vws[v]; const struct categoricals *cats = covariance_get_categoricals (pvw->cov); if (!categoricals_is_complete (cats)) - continue; + continue; int var_idx = pivot_category_create_leaf ( variables->root, pivot_value_new_variable (cmd->vars[v])); @@ -1198,56 +1198,56 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac struct contrasts_node *cn; int contrast_idx = 0; ll_for_each (cn, struct contrasts_node, ll, &cmd->contrast_list) - { - - /* Note: The calculation of the degrees of freedom in the - "variances not equal" case is painfull!! - The following formula may help to understand it: - \frac{\left (\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2} - { - \sum_{i=1}^k\left ( - \frac{\left (c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1} - \right) - } - */ - - double grand_n; - moments1_calculate (ws->dd_total[v]->mom, &grand_n, NULL, NULL, + { + + /* Note: The calculation of the degrees of freedom in the + "variances not equal" case is painfull!! + The following formula may help to understand it: + \frac{\left (\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2} + { + \sum_{i=1}^k\left ( + \frac{\left (c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1} + \right) + } + */ + + double grand_n; + moments1_calculate (ws->dd_total[v]->mom, &grand_n, NULL, NULL, NULL, NULL); - double df = grand_n - pvw->n_groups; + double df = grand_n - pvw->n_groups; - double contrast_value = 0.0; - double coef_msq = 0.0; - double sec_vneq = 0.0; - double df_denominator = 0.0; - double df_numerator = 0.0; + double contrast_value = 0.0; + double coef_msq = 0.0; + double sec_vneq = 0.0; + double df_denominator = 0.0; + double df_numerator = 0.0; struct coeff_node *coeffn; - int ci = 0; + int ci = 0; ll_for_each (coeffn, struct coeff_node, ll, &cn->coefficient_list) - { - const struct descriptive_data *dd + { + const struct descriptive_data *dd = categoricals_get_user_data_by_category (cats, ci); - const double coef = coeffn->coeff; + const double coef = coeffn->coeff; - double n, mean, variance; - moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL); + double n, mean, variance; + moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL); - double winv = variance / n; - contrast_value += coef * mean; - coef_msq += pow2 (coef) / n; - sec_vneq += pow2 (coef) * variance / n; - df_numerator += pow2 (coef) * winv; - df_denominator += pow2(pow2 (coef) * winv) / (n - 1); + double winv = variance / n; + contrast_value += coef * mean; + coef_msq += pow2 (coef) / n; + sec_vneq += pow2 (coef) * variance / n; + df_numerator += pow2 (coef) * winv; + df_denominator += pow2(pow2 (coef) * winv) / (n - 1); ci++; - } - sec_vneq = sqrt (sec_vneq); - df_numerator = pow2 (df_numerator); + } + sec_vneq = sqrt (sec_vneq); + df_numerator = pow2 (df_numerator); - double std_error_contrast = sqrt (pvw->mse * coef_msq); - double T = contrast_value / std_error_contrast; - double T_ne = contrast_value / sec_vneq; - double df_ne = df_numerator / df_denominator; + double std_error_contrast = sqrt (pvw->mse * coef_msq); + double T = contrast_value / std_error_contrast; + double T_ne = contrast_value / sec_vneq; + double df_ne = df_numerator / df_denominator; struct entry { @@ -1280,7 +1280,7 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac } contrast_idx++; - } + } } pivot_table_submit (table); @@ -1339,30 +1339,30 @@ show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace * test->root, pivot_value_new_text (ph->label)); for (int i = 0; i < pvw->n_groups; ++i) - { - struct descriptive_data *dd_i + { + struct descriptive_data *dd_i = categoricals_get_user_data_by_category (cat, i); - double weight_i, mean_i, var_i; - moments1_calculate (dd_i->mom, &weight_i, &mean_i, &var_i, 0, 0); + double weight_i, mean_i, var_i; + moments1_calculate (dd_i->mom, &weight_i, &mean_i, &var_i, 0, 0); - for (int j = 0; j < pvw->n_groups; ++j) - { - if (j == i) - continue; + for (int j = 0; j < pvw->n_groups; ++j) + { + if (j == i) + continue; - struct descriptive_data *dd_j + struct descriptive_data *dd_j = categoricals_get_user_data_by_category (cat, j); - double weight_j, mean_j, var_j; - moments1_calculate (dd_j->mom, &weight_j, &mean_j, &var_j, 0, 0); + double weight_j, mean_j, var_j; + moments1_calculate (dd_j->mom, &weight_j, &mean_j, &var_j, 0, 0); - double std_err = pvw->mse; - std_err *= weight_i + weight_j; - std_err /= weight_i * weight_j; - std_err = sqrt (std_err); + double std_err = pvw->mse; + std_err *= weight_i + weight_j; + std_err /= weight_i * weight_j; + std_err = sqrt (std_err); double sig = 2 * multiple_comparison_sig (std_err, pvw, dd_i, dd_j, ph); - double half_range = mc_half_range (cmd, pvw, std_err, + double half_range = mc_half_range (cmd, pvw, std_err, dd_i, dd_j, ph); double entries[] = { mean_i - mean_j, @@ -1374,8 +1374,8 @@ show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace * for (size_t k = 0; k < sizeof entries / sizeof *entries; k++) pivot_table_put4 (table, k, j, i, test_idx, pivot_value_new_number (entries[k])); - } - } + } + } } pivot_table_submit (table); diff --git a/src/language/commands/output.c b/src/language/commands/output.c index a3515edbdd..97214dca95 100644 --- a/src/language/commands/output.c +++ b/src/language/commands/output.c @@ -45,64 +45,64 @@ cmd_output_modify (struct lexer *lexer, struct dataset *ds UNUSED) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "SELECT")) - { - if (!lex_force_match_id (lexer, "TABLES")) + { + if (!lex_force_match_id (lexer, "TABLES")) goto error; - } + } else if (lex_match_id (lexer, "TABLECELLS")) - { + { string_set_clear (&rc_names); - struct fmt_spec fmt = { .type = 0 }; + struct fmt_spec fmt = { .type = 0 }; - 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; + 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; + if (!lex_force_match (lexer, T_LBRACK)) + goto error; - while (lex_token (lexer) == T_ID) + while (lex_token (lexer) == T_ID) { string_set_insert (&rc_names, lex_tokcstr (lexer)); lex_get (lexer); } - if (!lex_force_match (lexer, T_RBRACK)) - goto error; - } - else if (lex_match_id (lexer, "FORMAT")) - { - char type[FMT_TYPE_LEN_MAX + 1]; - uint16_t width; - uint8_t decimals; - - if (!lex_force_match (lexer, T_EQUALS) + if (!lex_force_match (lexer, T_RBRACK)) + goto error; + } + else if (lex_match_id (lexer, "FORMAT")) + { + char type[FMT_TYPE_LEN_MAX + 1]; + uint16_t width; + uint8_t decimals; + + if (!lex_force_match (lexer, T_EQUALS) || !parse_abstract_format_specifier (lexer, type, &width, &decimals)) goto error; - if (width <= 0) + if (width <= 0) width = settings_get_format ().w; if (!fmt_from_name (type, &fmt.type)) { lex_error (lexer, _("Unknown format type `%s'."), type); - goto error; + goto error; } - fmt.w = width; - fmt.d = decimals; - } - else - { - lex_error_expecting (lexer, "SELECT", "FORMAT"); - goto error; - } - } + fmt.w = width; + fmt.d = decimals; + } + else + { + lex_error_expecting (lexer, "SELECT", "FORMAT"); + goto error; + } + } if (fmt.w) { @@ -112,12 +112,12 @@ cmd_output_modify (struct lexer *lexer, struct dataset *ds UNUSED) if (!pivot_result_class_change (s, fmt)) lex_error (lexer, _("Unknown cell class %s."), s); } - } + } else - { - lex_error_expecting (lexer, "SELECT", "TABLECELLS"); - goto error; - } + { + lex_error_expecting (lexer, "SELECT", "TABLECELLS"); + goto error; + } } string_set_destroy (&rc_names); diff --git a/src/language/commands/permissions.c b/src/language/commands/permissions.c index 3047c19d2b..77b55a13e5 100644 --- a/src/language/commands/permissions.c +++ b/src/language/commands/permissions.c @@ -75,12 +75,12 @@ cmd_permissions (struct lexer *lexer, struct dataset *ds UNUSED) if (lex_match_id (lexer, "READONLY")) { if (! change_permissions (fn, PER_RO)) - goto error; + goto error; } else if (lex_match_id (lexer, "WRITEABLE")) { if (! change_permissions (fn, PER_RW)) - goto error; + goto error; } else { diff --git a/src/language/commands/placement-parser.c b/src/language/commands/placement-parser.c index 178529a7eb..58b8d03f4e 100644 --- a/src/language/commands/placement-parser.c +++ b/src/language/commands/placement-parser.c @@ -139,25 +139,25 @@ fixed_parse_columns (struct lexer *lexer, struct pool *pool, size_t n_vars, { /* Get format type. */ if (lex_token (lexer) == T_ID) - { - if (!parse_format_specifier_name (lexer, &type)) + { + if (!parse_format_specifier_name (lexer, &type)) return false; - lex_match (lexer, T_COMMA); - } + lex_match (lexer, T_COMMA); + } else - type = FMT_F; + type = FMT_F; /* Get decimal places. */ if (lex_is_integer (lexer)) - { - d = lex_integer (lexer); - lex_get (lexer); - } + { + d = lex_integer (lexer); + lex_get (lexer); + } else - d = 0; + d = 0; if (!lex_force_match (lexer, T_RPAREN)) - return false; + return false; } else { @@ -203,12 +203,12 @@ fixed_parse_fortran (struct lexer *lexer, struct pool *pool, enum fmt_use use, /* Parse count. */ if (lex_is_integer (lexer)) - { - count = lex_integer (lexer); - lex_get (lexer); - } + { + count = lex_integer (lexer); + lex_get (lexer); + } else - count = 1; + count = 1; /* Parse format specifier. */ if (lex_match (lexer, T_LPAREN)) @@ -386,12 +386,12 @@ parse_column_range (struct lexer *lexer, int base, return false; if (*last_column < *first_column) - { - lex_ofs_error (lexer, start_ofs, lex_ofs (lexer) - 1, + { + lex_ofs_error (lexer, start_ofs, lex_ofs (lexer) - 1, _("The ending column for a field must be " "greater than the starting column.")); - return false; - } + return false; + } if (range_specified) *range_specified = true; diff --git a/src/language/commands/print-space.c b/src/language/commands/print-space.c index c2cba8c078..b036ab789c 100644 --- a/src/language/commands/print-space.c +++ b/src/language/commands/print-space.c @@ -38,7 +38,7 @@ struct print_space_trns { struct dfm_writer *writer; /* Output data file. */ - struct expression *expr; /* Number of lines; NULL means 1. */ + struct expression *expr; /* Number of lines; NULL means 1. */ struct msg_location *expr_location; }; @@ -58,18 +58,18 @@ cmd_print_space (struct lexer *lexer, struct dataset *ds) handle = fh_parse (lexer, FH_REF_FILE, NULL); if (handle == NULL) - return CMD_FAILURE; + return CMD_FAILURE; if (lex_match_id (lexer, "ENCODING")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto error; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto error; encoding = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } } else handle = NULL; @@ -84,10 +84,10 @@ cmd_print_space (struct lexer *lexer, struct dataset *ds) goto error; if (lex_token (lexer) != T_ENDCMD) - { + { lex_error (lexer, _("Syntax error expecting end of command.")); goto error; - } + } } else expr = NULL; diff --git a/src/language/commands/print.c b/src/language/commands/print.c index c2fd455dc0..b37ffd8e99 100644 --- a/src/language/commands/print.c +++ b/src/language/commands/print.c @@ -52,22 +52,22 @@ /* Describes what to do when an output field is encountered. */ enum field_type { - PRT_LITERAL, /* Literal string. */ - PRT_VAR /* Variable. */ + PRT_LITERAL, /* Literal string. */ + PRT_VAR /* Variable. */ }; /* Describes how to output one field. */ struct prt_out_spec { /* All fields. */ - enum field_type type; /* What type of field this is. */ + enum field_type type; /* What type of field this is. */ int record; /* 1-based record number. */ - int first_column; /* 0-based first column. */ + int first_column; /* 0-based first column. */ int start_ofs, end_ofs; /* PRT_VAR only. */ - const struct variable *var; /* Associated variable. */ - struct fmt_spec format; /* Output spec. */ + const struct variable *var; /* Associated variable. */ + struct fmt_spec format; /* Output spec. */ bool add_space; /* Add trailing space? */ bool sysmis_as_spaces; /* Output SYSMIS as spaces? */ @@ -83,7 +83,7 @@ struct print_trns bool eject; /* Eject page before printing? */ bool include_prefix; /* Prefix lines with space? */ const char *encoding; /* Encoding to use for output. */ - struct dfm_writer *writer; /* Output file, NULL=listing file. */ + struct dfm_writer *writer; /* Output file, NULL=listing file. */ struct prt_out_spec *specs; size_t n_specs; size_t n_records; /* Number of records to write. */ @@ -152,45 +152,45 @@ cmd_print__ (struct lexer *lexer, struct dataset *ds, while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) { if (lex_match_id (lexer, "OUTFILE")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); - fh = fh_parse (lexer, FH_REF_FILE, NULL); - if (fh == NULL) - goto error; - } + fh = fh_parse (lexer, FH_REF_FILE, NULL); + if (fh == NULL) + goto error; + } else if (lex_match_id (lexer, "ENCODING")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - goto error; + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + goto error; free (encoding); encoding = ss_xstrdup (lex_tokss (lexer)); - lex_get (lexer); - } + lex_get (lexer); + } else if (lex_match_id (lexer, "RECORDS")) - { - lex_match (lexer, T_EQUALS); - lex_match (lexer, T_LPAREN); - if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX)) - goto error; - trns->n_records = lex_integer (lexer); + { + lex_match (lexer, T_EQUALS); + lex_match (lexer, T_LPAREN); + if (!lex_force_int_range (lexer, "RECORDS", 0, INT_MAX)) + goto error; + trns->n_records = lex_integer (lexer); records_ofs = lex_ofs (lexer); - lex_get (lexer); - lex_match (lexer, T_RPAREN); - } + lex_get (lexer); + lex_match (lexer, T_RPAREN); + } else if (lex_match_id (lexer, "TABLE")) - print_table = true; + print_table = true; else if (lex_match_id (lexer, "NOTABLE")) - print_table = false; + print_table = false; else - { + { lex_error_expecting (lexer, "OUTFILE", "ENCODING", "RECORDS", "TABLE", "NOTABLE"); - goto error; - } + goto error; + } } /* When PRINT or PRINT EJECT writes to an external file, we @@ -253,7 +253,7 @@ static bool parse_string_argument (struct lexer *, struct print_trns *, size_t *allocated_specs, int record, int *column); static bool parse_variable_argument (struct lexer *, const struct dictionary *, - struct print_trns *, + struct print_trns *, size_t *allocated_specs, struct pool *tmp_pool, int *record, int *column, @@ -289,7 +289,7 @@ parse_specs (struct lexer *lexer, struct pool *tmp_pool, tmp_pool, &record, &column, which_formats)); if (!ok) - return 0; + return 0; lex_match (lexer, T_COMMA); } @@ -362,7 +362,7 @@ parse_string_argument (struct lexer *lexer, struct print_trns *trns, Returns success. */ static bool parse_variable_argument (struct lexer *lexer, const struct dictionary *dict, - struct print_trns *trns, size_t *allocated_specs, + struct print_trns *trns, size_t *allocated_specs, struct pool *tmp_pool, int *record, int *column, enum which_formats which_formats) { @@ -650,9 +650,9 @@ print_binary_trns_proc (void *trns_, struct ccase **c, { size_t length = spec->string.length; char *data = ss_data (ds_tail (&line, length)); - char *s = recode_string (trns->encoding, UTF8, data, length); - memcpy (data, s, length); - free (s); + char *s = recode_string (trns->encoding, UTF8, data, length); + memcpy (data, s, length); + free (s); } } } diff --git a/src/language/commands/quick-cluster.c b/src/language/commands/quick-cluster.c index 4f512b4756..128130afe3 100644 --- a/src/language/commands/quick-cluster.c +++ b/src/language/commands/quick-cluster.c @@ -83,14 +83,14 @@ struct qc double epsilon; /* The convergence criterion */ - int ngroups; /* Number of group. (Given by the user) */ - int maxiter; /* Maximum iterations (Given by the user) */ + int ngroups; /* Number of group. (Given by the user) */ + int maxiter; /* Maximum iterations (Given by the user) */ bool print_cluster_membership; /* true => print membership */ bool print_initial_clusters; /* true => print initial cluster */ bool initial; /* false => simplified initial cluster selection */ bool update; /* false => do not iterate */ - const struct variable *wv; /* Weighting variable. */ + const struct variable *wv; /* Weighting variable. */ enum missing_type missing_type; enum mv_class exclude; @@ -114,41 +114,41 @@ struct qc kmeans_recalculate_centers in first invocation. */ struct Kmeans { - gsl_matrix *centers; /* Centers for groups. */ + gsl_matrix *centers; /* Centers for groups. */ gsl_matrix *updated_centers; casenumber n; gsl_vector_long *num_elements_groups; - gsl_matrix *initial_centers; /* Initial random centers. */ + gsl_matrix *initial_centers; /* Initial random centers. */ double convergence_criteria; - gsl_permutation *group_order; /* Group order for reporting. */ + gsl_permutation *group_order; /* Group order for reporting. */ }; static struct Kmeans *kmeans_create (const struct qc *); static void kmeans_get_nearest_group (const struct Kmeans *, - struct ccase *, const struct qc *, - int *, double *, int *, double *); + struct ccase *, const struct qc *, + int *, double *, int *, double *); static void kmeans_order_groups (struct Kmeans *, const struct qc *); static void kmeans_cluster (struct Kmeans *, struct casereader *, - const struct qc *); + const struct qc *); static void quick_cluster_show_centers (struct Kmeans *, bool initial, - const struct qc *); + const struct qc *); static void quick_cluster_show_membership (struct Kmeans *, - const struct casereader *, - struct qc *); + const struct casereader *, + struct qc *); static void quick_cluster_show_number_cases (struct Kmeans *, - const struct qc *); + const struct qc *); static void quick_cluster_show_results (struct Kmeans *, - const struct casereader *, - struct qc *); + const struct casereader *, + struct qc *); int cmd_quick_cluster (struct lexer *, struct dataset *); @@ -194,7 +194,7 @@ diff_matrix (const gsl_matrix *m1, const gsl_matrix *m2) for (size_t j = 0; j < m1->size2; ++j) diff += pow2 (gsl_matrix_get (m1,i,j) - gsl_matrix_get (m2,i,j)); if (diff > max_diff) - max_diff = diff; + max_diff = diff; } return max_diff; @@ -227,7 +227,7 @@ matrix_mindist (const gsl_matrix *m, int *mn, int *mm) /* Return the distance of C from the group whose index is WHICH */ static double dist_from_case (const struct Kmeans *kmeans, const struct ccase *c, - const struct qc *qc, int which) + const struct qc *qc, int which) { double dist = 0; for (size_t j = 0; j < qc->n_vars; j++) @@ -248,7 +248,7 @@ min_dist_from (const struct Kmeans *kmeans, const struct qc *qc, int which) for (size_t i = 0; i < qc->ngroups; i++) { if (i == which) - continue; + continue; double dist = 0; for (size_t j = 0; j < qc->n_vars; j++) @@ -265,8 +265,8 @@ min_dist_from (const struct Kmeans *kmeans, const struct qc *qc, int which) /* Calculate the initial cluster centers. */ static void kmeans_initial_centers (struct Kmeans *kmeans, - const struct casereader *reader, - const struct qc *qc) + const struct casereader *reader, + const struct qc *qc) { int nc = 0; @@ -276,59 +276,59 @@ kmeans_initial_centers (struct Kmeans *kmeans, { bool missing = false; for (size_t j = 0; j < qc->n_vars; ++j) - { - const union value *val = case_data (c, qc->vars[j]); - if (var_is_value_missing (qc->vars[j], val) & qc->exclude) - { - missing = true; - break; - } - - if (nc < qc->ngroups) - gsl_matrix_set (kmeans->centers, nc, j, val->f); - } + { + const union value *val = case_data (c, qc->vars[j]); + if (var_is_value_missing (qc->vars[j], val) & qc->exclude) + { + missing = true; + break; + } + + if (nc < qc->ngroups) + gsl_matrix_set (kmeans->centers, nc, j, val->f); + } if (missing) - continue; + continue; if (nc++ < qc->ngroups) - continue; + continue; if (qc->initial) - { - int mn, mm; - double m = matrix_mindist (kmeans->centers, &mn, &mm); - - int mq, mp; - double delta; - kmeans_get_nearest_group (kmeans, c, qc, &mq, &delta, &mp, NULL); - if (delta > m) - /* If the distance between C and the nearest group, is greater than the distance - between the two groups which are clostest to each - other, then one group must be replaced. */ - { - /* Out of mn and mm, which is the clostest of the two groups to C ? */ - int which = (dist_from_case (kmeans, c, qc, mn) - > dist_from_case (kmeans, c, qc, mm)) ? mm : mn; - - for (size_t j = 0; j < qc->n_vars; ++j) - { - const union value *val = case_data (c, qc->vars[j]); - gsl_matrix_set (kmeans->centers, which, j, val->f); - } - } - 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 smallest distance between the - nearest group (MQ) and any other group, then replace - MQ with C. */ - { - for (size_t j = 0; j < qc->n_vars; ++j) - { - const union value *val = case_data (c, qc->vars[j]); - gsl_matrix_set (kmeans->centers, mq, j, val->f); - } - } - } + { + int mn, mm; + double m = matrix_mindist (kmeans->centers, &mn, &mm); + + int mq, mp; + double delta; + kmeans_get_nearest_group (kmeans, c, qc, &mq, &delta, &mp, NULL); + if (delta > m) + /* If the distance between C and the nearest group, is greater than the distance + between the two groups which are clostest to each + other, then one group must be replaced. */ + { + /* Out of mn and mm, which is the clostest of the two groups to C ? */ + int which = (dist_from_case (kmeans, c, qc, mn) + > dist_from_case (kmeans, c, qc, mm)) ? mm : mn; + + for (size_t j = 0; j < qc->n_vars; ++j) + { + const union value *val = case_data (c, qc->vars[j]); + gsl_matrix_set (kmeans->centers, which, j, val->f); + } + } + 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 smallest distance between the + nearest group (MQ) and any other group, then replace + MQ with C. */ + { + for (size_t j = 0; j < qc->n_vars; ++j) + { + const union value *val = case_data (c, qc->vars[j]); + gsl_matrix_set (kmeans->centers, mq, j, val->f); + } + } + } } casereader_destroy (cs); @@ -344,8 +344,8 @@ kmeans_initial_centers (struct Kmeans *kmeans, /* Return the index of the group which is nearest to the case C */ static void kmeans_get_nearest_group (const struct Kmeans *kmeans, struct ccase *c, - const struct qc *qc, int *g_q, double *delta_q, - int *g_p, double *delta_p) + const struct qc *qc, int *g_q, double *delta_q, + int *g_p, double *delta_p) { int result0 = -1; int result1 = -1; @@ -355,27 +355,27 @@ kmeans_get_nearest_group (const struct Kmeans *kmeans, struct ccase *c, { double dist = 0; for (size_t j = 0; j < qc->n_vars; j++) - { - const union value *val = case_data (c, qc->vars[j]); - if (var_is_value_missing (qc->vars[j], val) & qc->exclude) - continue; + { + const union value *val = case_data (c, qc->vars[j]); + if (var_is_value_missing (qc->vars[j], val) & qc->exclude) + continue; - dist += pow2 (gsl_matrix_get (kmeans->centers, i, j) - val->f); - } + dist += pow2 (gsl_matrix_get (kmeans->centers, i, j) - val->f); + } if (dist < mindist0) - { - mindist1 = mindist0; - result1 = result0; + { + mindist1 = mindist0; + result1 = result0; - mindist0 = dist; - result0 = i; - } + mindist0 = dist; + result0 = i; + } else if (dist < mindist1) - { - mindist1 = dist; - result1 = i; - } + { + mindist1 = dist; + result1 = i; + } } if (delta_q) @@ -404,7 +404,7 @@ kmeans_order_groups (struct Kmeans *kmeans, const struct qc *qc) Does iterations, checks convergency. */ static void kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader, - const struct qc *qc) + const struct qc *qc) { kmeans_initial_centers (kmeans, reader, qc); @@ -415,50 +415,50 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader, kmeans->n = 0; if (qc->update) - { - struct casereader *r = casereader_clone (reader); - struct ccase *c; - for (; (c = casereader_read (r)) != NULL; case_unref (c)) - { - bool missing = false; - for (size_t j = 0; j < qc->n_vars; j++) - { - const union value *val = case_data (c, qc->vars[j]); - if (var_is_value_missing (qc->vars[j], val) & qc->exclude) - missing = true; - } - if (missing) - continue; - - double mindist = INFINITY; - int group = -1; - for (size_t g = 0; g < qc->ngroups; ++g) - { - double d = dist_from_case (kmeans, c, qc, g); - - if (d < mindist) - { - mindist = d; - group = g; - } - } - - long *n = gsl_vector_long_ptr (kmeans->num_elements_groups, group); - *n += qc->wv ? case_num (c, qc->wv) : 1.0; - kmeans->n++; - - for (size_t j = 0; j < qc->n_vars; ++j) - { - const union value *val = case_data (c, qc->vars[j]); - if (var_is_value_missing (qc->vars[j], val) & qc->exclude) - continue; - double *x = gsl_matrix_ptr (kmeans->updated_centers, group, j); - *x += val->f * (qc->wv ? case_num (c, qc->wv) : 1.0); - } - } - - casereader_destroy (r); - } + { + struct casereader *r = casereader_clone (reader); + struct ccase *c; + for (; (c = casereader_read (r)) != NULL; case_unref (c)) + { + bool missing = false; + for (size_t j = 0; j < qc->n_vars; j++) + { + const union value *val = case_data (c, qc->vars[j]); + if (var_is_value_missing (qc->vars[j], val) & qc->exclude) + missing = true; + } + if (missing) + continue; + + double mindist = INFINITY; + int group = -1; + for (size_t g = 0; g < qc->ngroups; ++g) + { + double d = dist_from_case (kmeans, c, qc, g); + + if (d < mindist) + { + mindist = d; + group = g; + } + } + + long *n = gsl_vector_long_ptr (kmeans->num_elements_groups, group); + *n += qc->wv ? case_num (c, qc->wv) : 1.0; + kmeans->n++; + + for (size_t j = 0; j < qc->n_vars; ++j) + { + const union value *val = case_data (c, qc->vars[j]); + if (var_is_value_missing (qc->vars[j], val) & qc->exclude) + continue; + double *x = gsl_matrix_ptr (kmeans->updated_centers, group, j); + *x += val->f * (qc->wv ? case_num (c, qc->wv) : 1.0); + } + } + + casereader_destroy (r); + } /* Divide the cluster sums by the number of items in each cluster */ for (size_t g = 0; g < qc->ngroups; ++g) @@ -511,7 +511,7 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader, break; if (!qc->update) - break; + break; } } @@ -524,8 +524,8 @@ quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc { struct pivot_table *table = pivot_table_create (initial - ? N_("Initial Cluster Centers") - : N_("Final Cluster Centers")); + ? N_("Initial Cluster Centers") + : N_("Final Cluster Centers")); struct pivot_dimension *clusters = pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Cluster")); @@ -596,8 +596,8 @@ save_trans_destroy (void *aux) membership and the distance of the case from the cluster centre. */ static void quick_cluster_show_membership (struct Kmeans *kmeans, - const struct casereader *reader, - struct qc *qc) + const struct casereader *reader, + struct qc *qc) { struct pivot_table *table = NULL; struct pivot_dimension *cases = NULL; @@ -606,10 +606,10 @@ quick_cluster_show_membership (struct Kmeans *kmeans, table = pivot_table_create (N_("Cluster Membership")); pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Cluster"), - N_("Cluster")); + N_("Cluster")); cases - = pivot_dimension_create (table, PIVOT_AXIS_ROW, N_("Case Number")); + = pivot_dimension_create (table, PIVOT_AXIS_ROW, N_("Case Number")); cases->root->show_label = true; } @@ -621,22 +621,22 @@ quick_cluster_show_membership (struct Kmeans *kmeans, if (qc->save_membership || qc->save_distance) { /* Prepare data which may potentially be used in a - transformation appending new variables to the active - dataset. */ + transformation appending new variables to the active + dataset. */ int idx = 0; int membership_case_idx = -1; if (qc->save_membership) - { - proto = caseproto_add_width (proto, 0); - membership_case_idx = idx++; - } + { + proto = caseproto_add_width (proto, 0); + membership_case_idx = idx++; + } int distance_case_idx = -1; if (qc->save_distance) - { - proto = caseproto_add_width (proto, 0); - distance_case_idx = idx++; - } + { + proto = caseproto_add_width (proto, 0); + distance_case_idx = idx++; + } qc->save_trans_data = xmalloc (sizeof *qc->save_trans_data); *qc->save_trans_data = (struct save_trans_data) { @@ -670,13 +670,13 @@ quick_cluster_show_membership (struct Kmeans *kmeans, } if (qc->print_cluster_membership) - { - /* Print the cluster membership to the table. */ - int case_idx = pivot_category_create_leaf (cases->root, - pivot_value_new_integer (i + 1)); - pivot_table_put2 (table, 0, case_idx, - pivot_value_new_integer (cluster + 1)); - } + { + /* Print the cluster membership to the table. */ + int case_idx = pivot_category_create_leaf (cases->root, + pivot_value_new_integer (i + 1)); + pivot_table_put2 (table, 0, case_idx, + pivot_value_new_integer (cluster + 1)); + } } caseproto_unref (proto); @@ -708,14 +708,14 @@ quick_cluster_show_number_cases (struct Kmeans *kmeans, const struct qc *qc) for (int i = 0; i < qc->ngroups; i++) { int cluster_idx - = pivot_category_create_leaf (group, pivot_value_new_integer (i + 1)); + = pivot_category_create_leaf (group, pivot_value_new_integer (i + 1)); int count = kmeans->num_elements_groups->data [kmeans->group_order->data[i]]; pivot_table_put2 (table, 0, cluster_idx, pivot_value_new_integer (count)); total += count; } int cluster_idx = pivot_category_create_leaf (clusters->root, - pivot_value_new_text (N_("Valid"))); + pivot_value_new_text (N_("Valid"))); pivot_table_put2 (table, 0, cluster_idx, pivot_value_new_integer (total)); pivot_table_submit (table); } @@ -723,7 +723,7 @@ quick_cluster_show_number_cases (struct Kmeans *kmeans, const struct qc *qc) /* Reports. */ static void quick_cluster_show_results (struct Kmeans *kmeans, const struct casereader *reader, - struct qc *qc) + struct qc *qc) { kmeans_order_groups (kmeans, qc); /* what does this do? */ @@ -741,7 +741,7 @@ static bool quick_cluster_parse (struct lexer *lexer, struct qc *qc) { if (!parse_variables_const (lexer, qc->dict, &qc->vars, &qc->n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + PV_NO_DUPLICATE | PV_NUMERIC)) return false; while (lex_token (lexer) != T_ENDCMD) @@ -749,159 +749,159 @@ quick_cluster_parse (struct lexer *lexer, struct qc *qc) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "MISSING")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "LISTWISE") - || lex_match_id (lexer, "DEFAULT")) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "LISTWISE") + || lex_match_id (lexer, "DEFAULT")) qc->missing_type = MISS_LISTWISE; - else if (lex_match_id (lexer, "PAIRWISE")) + else if (lex_match_id (lexer, "PAIRWISE")) qc->missing_type = MISS_PAIRWISE; - else if (lex_match_id (lexer, "INCLUDE")) + else if (lex_match_id (lexer, "INCLUDE")) qc->exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) qc->exclude = MV_ANY; - else - { - lex_error_expecting (lexer, "LISTWISE", "DEFAULT", + else + { + lex_error_expecting (lexer, "LISTWISE", "DEFAULT", "PAIRWISE", "INCLUDE", "EXCLUDE"); - return false; - } - } - } + return false; + } + } + } else if (lex_match_id (lexer, "PRINT")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "CLUSTER")) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "CLUSTER")) qc->print_cluster_membership = true; - else if (lex_match_id (lexer, "INITIAL")) - qc->print_initial_clusters = true; - else - { - lex_error_expecting (lexer, "CLUSTER", "INITIAL"); - return false; - } - } - } + else if (lex_match_id (lexer, "INITIAL")) + qc->print_initial_clusters = true; + else + { + lex_error_expecting (lexer, "CLUSTER", "INITIAL"); + return false; + } + } + } else if (lex_match_id (lexer, "SAVE")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "CLUSTER")) - { - qc->save_membership = true; - if (lex_match (lexer, T_LPAREN)) - { - if (!lex_force_id (lexer)) - return false; - - free (qc->var_membership); - qc->var_membership = xstrdup (lex_tokcstr (lexer)); - if (NULL != dict_lookup_var (qc->dict, qc->var_membership)) - { - lex_error (lexer, - _("A variable called `%s' already exists."), - qc->var_membership); - free (qc->var_membership); - qc->var_membership = NULL; - return false; - } - - lex_get (lexer); - - if (!lex_force_match (lexer, T_RPAREN)) - return false; - } - } - else if (lex_match_id (lexer, "DISTANCE")) - { - qc->save_distance = true; - if (lex_match (lexer, T_LPAREN)) - { - if (!lex_force_id (lexer)) - return false; - - free (qc->var_distance); - qc->var_distance = xstrdup (lex_tokcstr (lexer)); - if (NULL != dict_lookup_var (qc->dict, qc->var_distance)) - { - lex_error (lexer, - _("A variable called `%s' already exists."), - qc->var_distance); - free (qc->var_distance); - qc->var_distance = NULL; - return false; - } - - lex_get (lexer); - - if (!lex_force_match (lexer, T_RPAREN)) - return false; - } - } - else - { - lex_error_expecting (lexer, "CLUSTER", "DISTANCE"); - return false; - } - } - } + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "CLUSTER")) + { + qc->save_membership = true; + if (lex_match (lexer, T_LPAREN)) + { + if (!lex_force_id (lexer)) + return false; + + free (qc->var_membership); + qc->var_membership = xstrdup (lex_tokcstr (lexer)); + if (NULL != dict_lookup_var (qc->dict, qc->var_membership)) + { + lex_error (lexer, + _("A variable called `%s' already exists."), + qc->var_membership); + free (qc->var_membership); + qc->var_membership = NULL; + return false; + } + + lex_get (lexer); + + if (!lex_force_match (lexer, T_RPAREN)) + return false; + } + } + else if (lex_match_id (lexer, "DISTANCE")) + { + qc->save_distance = true; + if (lex_match (lexer, T_LPAREN)) + { + if (!lex_force_id (lexer)) + return false; + + free (qc->var_distance); + qc->var_distance = xstrdup (lex_tokcstr (lexer)); + if (NULL != dict_lookup_var (qc->dict, qc->var_distance)) + { + lex_error (lexer, + _("A variable called `%s' already exists."), + qc->var_distance); + free (qc->var_distance); + qc->var_distance = NULL; + return false; + } + + lex_get (lexer); + + if (!lex_force_match (lexer, T_RPAREN)) + return false; + } + } + else + { + lex_error_expecting (lexer, "CLUSTER", "DISTANCE"); + return false; + } + } + } else if (lex_match_id (lexer, "CRITERIA")) - { - lex_match (lexer, T_EQUALS); - while (lex_token (lexer) != T_ENDCMD - && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "CLUSTERS")) - { - if (!lex_force_match (lexer, T_LPAREN) - || !lex_force_int_range (lexer, "CLUSTERS", 1, INT_MAX)) + { + lex_match (lexer, T_EQUALS); + while (lex_token (lexer) != T_ENDCMD + && lex_token (lexer) != T_SLASH) + { + if (lex_match_id (lexer, "CLUSTERS")) + { + if (!lex_force_match (lexer, T_LPAREN) + || !lex_force_int_range (lexer, "CLUSTERS", 1, INT_MAX)) return false; qc->ngroups = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) return false; - } - else if (lex_match_id (lexer, "CONVERGE")) - { - if (!lex_force_match (lexer, T_LPAREN) - || !lex_force_num_range_open (lexer, "CONVERGE", + } + else if (lex_match_id (lexer, "CONVERGE")) + { + if (!lex_force_match (lexer, T_LPAREN) + || !lex_force_num_range_open (lexer, "CONVERGE", 0, DBL_MAX)) return false; qc->epsilon = lex_number (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) return false; - } - else if (lex_match_id (lexer, "MXITER")) - { - if (!lex_force_match (lexer, T_LPAREN) - || !lex_force_int_range (lexer, "MXITER", 1, INT_MAX)) + } + else if (lex_match_id (lexer, "MXITER")) + { + if (!lex_force_match (lexer, T_LPAREN) + || !lex_force_int_range (lexer, "MXITER", 1, INT_MAX)) return false; qc->maxiter = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) return false; - } - else if (lex_match_id (lexer, "NOINITIAL")) + } + else if (lex_match_id (lexer, "NOINITIAL")) qc->initial = false; - else if (lex_match_id (lexer, "NOUPDATE")) + else if (lex_match_id (lexer, "NOUPDATE")) qc->update = false; - else - { - lex_error_expecting (lexer, "CLUSTERS", "CONVERGE", "MXITER", + else + { + lex_error_expecting (lexer, "CLUSTERS", "CONVERGE", "MXITER", "NOINITIAL", "NOUPDATE"); - return false; - } - } - } + return false; + } + } + } else { lex_error_expecting (lexer, "MISSING", "PRINT", "SAVE", "CRITERIA"); @@ -957,48 +957,48 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds) std->appending_reader = casewriter_make_reader (std->writer); if (qc.save_membership) - { - /* Invent a variable name if necessary. */ - int idx = 0; - struct string name; - ds_init_empty (&name); - while (qc.var_membership == NULL) - { - ds_clear (&name); - ds_put_format (&name, "QCL_%d", idx++); - - if (!dict_lookup_var (qc.dict, ds_cstr (&name))) - { - qc.var_membership = strdup (ds_cstr (&name)); - break; - } - } - ds_destroy (&name); - - std->membership = dict_create_var_assert (qc.dict, qc.var_membership, 0); - } + { + /* Invent a variable name if necessary. */ + int idx = 0; + struct string name; + ds_init_empty (&name); + while (qc.var_membership == NULL) + { + ds_clear (&name); + ds_put_format (&name, "QCL_%d", idx++); + + if (!dict_lookup_var (qc.dict, ds_cstr (&name))) + { + qc.var_membership = strdup (ds_cstr (&name)); + break; + } + } + ds_destroy (&name); + + std->membership = dict_create_var_assert (qc.dict, qc.var_membership, 0); + } if (qc.save_distance) - { - /* Invent a variable name if necessary. */ - int idx = 0; - struct string name; - ds_init_empty (&name); - while (qc.var_distance == NULL) - { - ds_clear (&name); - ds_put_format (&name, "QCL_%d", idx++); - - if (!dict_lookup_var (qc.dict, ds_cstr (&name))) - { - qc.var_distance = strdup (ds_cstr (&name)); - break; - } - } - ds_destroy (&name); - - std->distance = dict_create_var_assert (qc.dict, qc.var_distance, 0); - } + { + /* Invent a variable name if necessary. */ + int idx = 0; + struct string name; + ds_init_empty (&name); + while (qc.var_distance == NULL) + { + ds_clear (&name); + ds_put_format (&name, "QCL_%d", idx++); + + if (!dict_lookup_var (qc.dict, ds_cstr (&name))) + { + qc.var_distance = strdup (ds_cstr (&name)); + break; + } + } + ds_destroy (&name); + + std->distance = dict_create_var_assert (qc.dict, qc.var_distance, 0); + } static const struct trns_class trns_class = { .name = "QUICK CLUSTER", diff --git a/src/language/commands/rank.c b/src/language/commands/rank.c index 26de7bed81..592cf1c82a 100644 --- a/src/language/commands/rank.c +++ b/src/language/commands/rank.c @@ -50,31 +50,31 @@ struct rank; typedef double (*rank_function_t) (const struct rank*, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_proportion (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_normal (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_percent (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_rfraction (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_rank (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_n (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_savage (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); static double rank_ntiles (const struct rank *, double c, double cc, double cc_1, - int i, double w); + int i, double w); enum rank_func @@ -278,13 +278,13 @@ parse_into (struct lexer *lexer, struct rank *cmd, { if (!lex_force_match (lexer, T_LPAREN) || !lex_force_int_range (lexer, "NTILES", 1, INT_MAX)) - return false; + return false; cmd->k_ntiles = lex_integer (lexer); lex_get (lexer); if (!lex_force_match (lexer, T_RPAREN)) - return false; + return false; rfunc = NTILES; } @@ -308,13 +308,13 @@ parse_into (struct lexer *lexer, struct rank *cmd, int vars_start = lex_ofs (lexer); size_t var_count = 0; while (lex_token (lexer) == T_ID) - { - const char *name = lex_tokcstr (lexer); + { + const char *name = lex_tokcstr (lexer); - if (var_count >= subcase_get_n_fields (&cmd->sc)) + if (var_count >= subcase_get_n_fields (&cmd->sc)) lex_ofs_error (lexer, vars_start, lex_ofs (lexer), _("Too many variables in %s clause."), "INTO"); - else if (dict_lookup_var (cmd->dict, name) != NULL) + else if (dict_lookup_var (cmd->dict, name) != NULL) lex_error (lexer, _("Variable %s already exists."), name); else if (stringi_set_contains (new_names, name)) lex_error (lexer, _("Duplicate variable name %s."), name); @@ -337,56 +337,56 @@ parse_into (struct lexer *lexer, struct rank *cmd, /* Hardly a rank function. */ static double rank_n (const struct rank *cmd UNUSED, double c UNUSED, double cc UNUSED, double cc_1 UNUSED, - int i UNUSED, double w) + int i UNUSED, double w) { return w; } static double rank_rank (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w UNUSED) + int i, double w UNUSED) { double rank; if (c >= 1.0) { switch (cmd->ties) - { - case TIES_LOW: - rank = cc_1 + 1; - break; - case TIES_HIGH: - rank = cc; - break; - case TIES_MEAN: - rank = cc_1 + (c + 1.0)/ 2.0; - break; - case TIES_CONDENSE: - rank = i; - break; - default: - NOT_REACHED (); - } + { + case TIES_LOW: + rank = cc_1 + 1; + break; + case TIES_HIGH: + rank = cc; + break; + case TIES_MEAN: + rank = cc_1 + (c + 1.0)/ 2.0; + break; + case TIES_CONDENSE: + rank = i; + break; + default: + NOT_REACHED (); + } } else { switch (cmd->ties) - { - case TIES_LOW: - rank = cc_1; - break; - case TIES_HIGH: - rank = cc; - break; - case TIES_MEAN: - rank = cc_1 + c / 2.0; - break; - case TIES_CONDENSE: - rank = i; - break; - default: - NOT_REACHED (); - } + { + case TIES_LOW: + rank = cc_1; + break; + case TIES_HIGH: + rank = cc; + break; + case TIES_MEAN: + rank = cc_1 + c / 2.0; + break; + case TIES_CONDENSE: + rank = i; + break; + default: + NOT_REACHED (); + } } return rank; @@ -395,7 +395,7 @@ rank_rank (const struct rank *cmd, double c, double cc, double cc_1, static double rank_rfraction (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w) + int i, double w) { return rank_rank (cmd, c, cc, cc_1, i, w) / w; } @@ -403,7 +403,7 @@ rank_rfraction (const struct rank *cmd, double c, double cc, double cc_1, static double rank_percent (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w) + int i, double w) { return rank_rank (cmd, c, cc, cc_1, i, w) * 100.0 / w; } @@ -411,7 +411,7 @@ rank_percent (const struct rank *cmd, double c, double cc, double cc_1, static double rank_proportion (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w) + int i, double w) { const double r = rank_rank (cmd, c, cc, cc_1, i, w); @@ -441,7 +441,7 @@ rank_proportion (const struct rank *cmd, double c, double cc, double cc_1, static double rank_normal (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w) + int i, double w) { double f = rank_proportion (cmd, c, cc, cc_1, i, w); @@ -450,7 +450,7 @@ rank_normal (const struct rank *cmd, double c, double cc, double cc_1, static double rank_ntiles (const struct rank *cmd, double c, double cc, double cc_1, - int i, double w) + int i, double w) { double r = rank_rank (cmd, c, cc, cc_1, i, w); @@ -473,7 +473,7 @@ ee (int j, double w_star) static double rank_savage (const struct rank *cmd UNUSED, double c, double cc, double cc_1, - int i UNUSED, double w) + int i UNUSED, double w) { double int_part; const int i_1 = floor (cc_1); @@ -499,7 +499,7 @@ rank_savage (const struct rank *cmd UNUSED, double c, double cc, double cc_1, { double sigma = 0.0; for (int j = i_1 + 2; j <= i_2; ++j) - sigma += ee (j, w_star); + sigma += ee (j, w_star); return ((expr1 + expr2 + sigma) / c) -1; } @@ -527,7 +527,7 @@ static void rank_sorted_file (struct casereader *input, struct casewriter *output, int weight_idx, - const struct rank *cmd) + const struct rank *cmd) { int tie_group = 1; double cc = 0.0; @@ -598,11 +598,11 @@ create_var_label (struct rank *cmd, const struct variable *src_var, { struct string group_var_str = DS_EMPTY_INITIALIZER; for (size_t g = 0; g < cmd->n_group_vars; ++g) - { - if (g > 0) + { + if (g > 0) ds_put_cstr (&group_var_str, " "); - ds_put_cstr (&group_var_str, var_get_name (cmd->group_vars[g])); - } + ds_put_cstr (&group_var_str, var_get_name (cmd->group_vars[g])); + } const char *label = pool_asprintf ( cmd->pool, _("%s of %s by %s"), function_name[f], @@ -645,73 +645,73 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) while (lex_token (lexer) != T_ENDCMD) { if (!lex_force_match (lexer, T_SLASH)) - goto error; + goto error; if (lex_match_id (lexer, "TIES")) - { - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - if (lex_match_id (lexer, "MEAN")) + { + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + if (lex_match_id (lexer, "MEAN")) rank.ties = TIES_MEAN; - else if (lex_match_id (lexer, "LOW")) + else if (lex_match_id (lexer, "LOW")) rank.ties = TIES_LOW; - else if (lex_match_id (lexer, "HIGH")) + else if (lex_match_id (lexer, "HIGH")) rank.ties = TIES_HIGH; - else if (lex_match_id (lexer, "CONDENSE")) + else if (lex_match_id (lexer, "CONDENSE")) rank.ties = TIES_CONDENSE; - else - { - lex_error_expecting (lexer, "MEAN", "LOW", "HIGH", "CONDENSE"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "MEAN", "LOW", "HIGH", "CONDENSE"); + goto error; + } + } else if (lex_match_id (lexer, "FRACTION")) - { - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - if (lex_match_id (lexer, "BLOM")) + { + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + if (lex_match_id (lexer, "BLOM")) rank.fraction = FRAC_BLOM; - else if (lex_match_id (lexer, "TUKEY")) + else if (lex_match_id (lexer, "TUKEY")) rank.fraction = FRAC_TUKEY; - else if (lex_match_id (lexer, "VW")) + else if (lex_match_id (lexer, "VW")) rank.fraction = FRAC_VW; - else if (lex_match_id (lexer, "RANKIT")) + else if (lex_match_id (lexer, "RANKIT")) rank.fraction = FRAC_RANKIT; - else - { - lex_error_expecting (lexer, "BLOM", "TUKEY", "VW", "RANKIT"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "BLOM", "TUKEY", "VW", "RANKIT"); + goto error; + } + } else if (lex_match_id (lexer, "PRINT")) - { - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - if (lex_match_id (lexer, "YES")) + { + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + if (lex_match_id (lexer, "YES")) rank.print = true; - else if (lex_match_id (lexer, "NO")) + else if (lex_match_id (lexer, "NO")) rank.print = false; - else - { - lex_error_expecting (lexer, "YES", "NO"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "YES", "NO"); + goto error; + } + } else if (lex_match_id (lexer, "MISSING")) - { - if (!lex_force_match (lexer, T_EQUALS)) - goto error; - if (lex_match_id (lexer, "INCLUDE")) + { + if (!lex_force_match (lexer, T_EQUALS)) + goto error; + if (lex_match_id (lexer, "INCLUDE")) rank.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) rank.exclude = MV_ANY; - else - { - lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); + goto error; + } + } else if (!parse_into (lexer, &rank, &new_names)) - goto error; + goto error; } @@ -767,9 +767,9 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) variables->root->show_label = true; for (size_t i = 0; i < rank.n_rs; ++i) - { - for (size_t v = 0; v < rank.n_vars; v ++) - { + { + for (size_t v = 0; v < rank.n_vars; v ++) + { int row_idx = pivot_category_create_leaf ( variables->root, pivot_value_new_variable (rank.vars[v])); @@ -798,8 +798,8 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) pivot_value_new_user_text (entry, -1)); } ds_destroy (&group_vars); - } - } + } + } pivot_table_submit (table); } diff --git a/src/language/commands/recode.c b/src/language/commands/recode.c index 9c43645676..21e331f687 100644 --- a/src/language/commands/recode.c +++ b/src/language/commands/recode.c @@ -49,12 +49,12 @@ /* Type of source value for RECODE. */ enum map_in_type { - MAP_SINGLE, /* Specific value. */ - MAP_RANGE, /* Range of values. */ + MAP_SINGLE, /* Specific value. */ + MAP_RANGE, /* Range of values. */ MAP_SYSMIS, /* System missing value. */ MAP_MISSING, /* Any missing value. */ - MAP_ELSE, /* Any value. */ - MAP_CONVERT /* "123" => 123. */ + MAP_ELSE, /* Any value. */ + MAP_CONVERT /* "123" => 123. */ }; /* Describes input values to be mapped. */ @@ -91,10 +91,10 @@ struct recode_trns enum val_type dst_type; /* dst_vars[*] type. */ /* Variables. */ - const struct variable **src_vars; /* Source variables. */ - const struct variable **dst_vars; /* Destination variables. */ + const struct variable **src_vars; /* Source variables. */ + const struct variable **dst_vars; /* Destination variables. */ const struct dictionary *dst_dict; /* Dictionary of dst_vars */ - char **dst_names; /* Name of dest variables, if they're new. */ + char **dst_names; /* Name of dest variables, if they're new. */ size_t n_vars; /* Number of variables. */ /* Mappings. */ @@ -212,7 +212,7 @@ cmd_recode (struct lexer *lexer, struct dataset *ds) successful, false on parse error. */ static bool parse_src_vars (struct lexer *lexer, - struct recode_trns *trns, const struct dictionary *dict) + struct recode_trns *trns, const struct dictionary *dict) { if (!parse_variables_const (lexer, dict, &trns->src_vars, &trns->n_vars, PV_SAME_TYPE)) @@ -364,18 +364,18 @@ parse_map_in (struct lexer *lexer, struct map_in *in, struct pool *pool, else if (!lex_force_string (lexer)) return false; else - { - set_map_in_str (in, pool, lex_tokss (lexer), max_src_width, + { + set_map_in_str (in, pool, lex_tokss (lexer), max_src_width, dict_encoding); - lex_get (lexer); - if (lex_match_id (lexer, "THRU")) - { - lex_next_error (lexer, -1, -1, + lex_get (lexer); + if (lex_match_id (lexer, "THRU")) + { + lex_next_error (lexer, -1, -1, _("%s is not allowed with string variables."), "THRU"); - return false; - } - } + return false; + } + } } return true; @@ -468,7 +468,7 @@ set_map_out_str (struct map_out *out, struct pool *pool, TRNS->dst_names. */ static bool parse_dst_vars (struct lexer *lexer, struct recode_trns *trns, - const struct dictionary *dict, int src_start, int src_end, + const struct dictionary *dict, int src_start, int src_end, int mappings_start, int mappings_end) { int dst_start, dst_end; @@ -477,7 +477,7 @@ parse_dst_vars (struct lexer *lexer, struct recode_trns *trns, dst_start = lex_ofs (lexer); size_t n_names; if (!parse_mixed_vars_pool (lexer, dict, trns->pool, - &trns->dst_names, &n_names, + &trns->dst_names, &n_names, PV_NONE)) return false; dst_end = lex_ofs (lexer) - 1; @@ -573,19 +573,19 @@ enlarge_dst_widths (struct lexer *lexer, struct recode_trns *trns, trns->max_dst_width = var_get_width (v); if (var_get_width (v) < min_dst_width) - { - min_dst_width = var_get_width (v); - narrow_var = v; - } + { + min_dst_width = var_get_width (v); + narrow_var = v; + } } for (size_t i = 0; i < trns->n_maps; i++) { struct map_out *out = &trns->mappings[i].out; if (!out->copy_input) - { - if (out->width > min_dst_width) - { + { + if (out->width > min_dst_width) + { msg (SE, _("At least one target variable is too narrow for " "the output values.")); lex_ofs_msg (lexer, SN, out->ofs, out->ofs, @@ -595,12 +595,12 @@ enlarge_dst_widths (struct lexer *lexer, struct recode_trns *trns, _("Target variable %s only has width %d."), var_get_name (narrow_var), var_get_width (narrow_var)); - return false; - } + return false; + } - value_resize_pool (trns->pool, &out->value, - out->width, trns->max_dst_width); - } + value_resize_pool (trns->pool, &out->value, + out->width, trns->max_dst_width); + } } return true; @@ -701,9 +701,9 @@ find_src_string (struct recode_trns *trns, const uint8_t *value, out->value.f = uv.f; break; } - case MAP_MISSING: - match = var_is_str_missing (src_var, value) != 0; - break; + case MAP_MISSING: + match = var_is_str_missing (src_var, value) != 0; + break; default: NOT_REACHED (); } diff --git a/src/language/commands/regression.c b/src/language/commands/regression.c index 43f750e18c..3070f0ed11 100644 --- a/src/language/commands/regression.c +++ b/src/language/commands/regression.c @@ -207,33 +207,33 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) if (lex_match_id (lexer, "VARIABLES")) { - if (method_seen) - { - lex_next_error (lexer, -1, -1, + if (method_seen) + { + lex_next_error (lexer, -1, -1, _("VARIABLES may not appear after %s"), "METHOD"); - goto error; - } - if (dependent_seen) - { - lex_next_error (lexer, -1, -1, + goto error; + } + if (dependent_seen) + { + lex_next_error (lexer, -1, -1, _("VARIABLES may not appear after %s"), "DEPENDENT"); - goto error; - } - variables_seen = true; - lex_match (lexer, T_EQUALS); - - if (!parse_variables_const (lexer, dict, - ®ression.vars, ®ression.n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) - goto error; - } + goto error; + } + variables_seen = true; + lex_match (lexer, T_EQUALS); + + if (!parse_variables_const (lexer, dict, + ®ression.vars, ®ression.n_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) + goto error; + } else if (lex_match_id (lexer, "DEPENDENT")) { - dependent_seen = true; + dependent_seen = true; lex_match (lexer, T_EQUALS); - free (regression.dep_vars); - regression.n_dep_vars = 0; + free (regression.dep_vars); + regression.n_dep_vars = 0; if (!parse_variables_const (lexer, dict, ®ression.dep_vars, @@ -247,23 +247,23 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) regression.origin = false; else if (lex_match_id (lexer, "METHOD")) { - method_seen = true; + method_seen = true; lex_match (lexer, T_EQUALS); if (!lex_force_match_id (lexer, "ENTER")) goto error; - if (!variables_seen) - { - if (!parse_variables_const (lexer, dict, - ®ression.vars, ®ression.n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) - goto error; - } + if (!variables_seen) + { + if (!parse_variables_const (lexer, dict, + ®ression.vars, ®ression.n_vars, + PV_NO_DUPLICATE | PV_NUMERIC)) + goto error; + } } else if (lex_match_id (lexer, "STATISTICS")) { - unsigned long statistics = 0; + unsigned long statistics = 0; lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD @@ -285,18 +285,18 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) statistics |= STATS_TOL; else if (lex_match_id (lexer, "CI")) { - statistics |= STATS_CI; + statistics |= STATS_CI; - if (lex_match (lexer, T_LPAREN)) + if (lex_match (lexer, T_LPAREN)) { if (!lex_force_num (lexer)) goto error; - regression.ci = lex_number (lexer) / 100.0; - lex_get (lexer); + regression.ci = lex_number (lexer) / 100.0; + lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } } else { @@ -306,8 +306,8 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) } } - if (statistics) - regression.stats = statistics; + if (statistics) + regression.stats = statistics; } else if (lex_match_id (lexer, "SAVE")) { @@ -579,16 +579,16 @@ struct model_container */ static void reg_stats_r (const struct linreg *, const struct variable *); static void reg_stats_coeff (const struct regression *, const struct linreg *, - const struct model_container *, const gsl_matrix *, - const struct variable *); + const struct model_container *, const gsl_matrix *, + const struct variable *); static void reg_stats_anova (const struct linreg *, const struct variable *); static void reg_stats_bcov (const struct linreg *, const struct variable *); static struct linreg ** run_regression_get_models (const struct regression *cmd, - struct casereader *input, - bool output) + struct casereader *input, + bool output) { struct model_container *model_container = XCALLOC (cmd->n_vars, struct model_container); @@ -656,28 +656,28 @@ run_regression_get_models (const struct regression *cmd, linreg_set_depvar_mean (models[k], means[n_indep]); if (n_data > 0) { - linreg_fit (cov_matrix, models[k]); + linreg_fit (cov_matrix, models[k]); if (output && !taint_has_tainted_successor (casereader_get_taint (input))) { - /* - Find the least-squares estimates and other statistics. - */ - if (cmd->stats & STATS_R) - reg_stats_r (models[k], dep_var); - - if (cmd->stats & STATS_ANOVA) - reg_stats_anova (models[k], dep_var); - - if (cmd->stats & STATS_COEFF) - reg_stats_coeff (cmd, models[k], - model_container, - cov_matrix, dep_var); - - if (cmd->stats & STATS_BCOV) - reg_stats_bcov (models[k], dep_var); - } + /* + Find the least-squares estimates and other statistics. + */ + if (cmd->stats & STATS_R) + reg_stats_r (models[k], dep_var); + + if (cmd->stats & STATS_ANOVA) + reg_stats_anova (models[k], dep_var); + + if (cmd->stats & STATS_COEFF) + reg_stats_coeff (cmd, models[k], + model_container, + cov_matrix, dep_var); + + if (cmd->stats & STATS_BCOV) + reg_stats_bcov (models[k], dep_var); + } } else msg (SE, _("No valid data found. This command was skipped.")); @@ -740,8 +740,8 @@ run_regression (const struct regression *cmd, double res = linreg_residual (models[k], obs, vals, n_indep); *case_num_rw_idx (outc, k * ws->extras + ws->res_idx) = res; } - free (vals); - free (vars); + free (vals); + free (vars); } casewriter_write (ws->writer, outc); } @@ -790,8 +790,8 @@ reg_stats_r (const struct linreg * c, const struct variable *var) */ static void reg_stats_coeff (const struct regression *cmd, const struct linreg *c, - const struct model_container *mc, const gsl_matrix *cov, - const struct variable *var) + const struct model_container *mc, const gsl_matrix *cov, + const struct variable *var) { struct pivot_table *table = pivot_table_create__ ( pivot_value_new_text_format (N_("Coefficients (%s)"), var_to_string (var)), @@ -818,8 +818,8 @@ reg_stats_coeff (const struct regression *cmd, const struct linreg *c, if (cmd->stats & STATS_TOL) pivot_category_create_group (statistics->root, - N_("Collinearity Statistics"), - N_("Tolerance"), N_("VIF")); + N_("Collinearity Statistics"), + N_("Tolerance"), N_("VIF")); struct pivot_dimension *variables = pivot_dimension_create ( @@ -851,16 +851,16 @@ reg_stats_coeff (const struct regression *cmd, const struct linreg *c, pivot_value_new_number (base_entries[i])); if (cmd->stats & STATS_CI) - { - double interval_entries[] = { - linreg_intercept (c) - tval * std_err, - linreg_intercept (c) + tval * std_err, - }; - - for (size_t i = 0; i < sizeof interval_entries / sizeof *interval_entries; i++) - pivot_table_put2 (table, col++, var_idx, - pivot_value_new_number (interval_entries[i])); - } + { + double interval_entries[] = { + linreg_intercept (c) - tval * std_err, + linreg_intercept (c) + tval * std_err, + }; + + for (size_t i = 0; i < sizeof interval_entries / sizeof *interval_entries; i++) + pivot_table_put2 (table, col++, var_idx, + pivot_value_new_number (interval_entries[i])); + } } for (size_t j = 0; j < linreg_n_coeffs (c); j++) @@ -886,27 +886,27 @@ reg_stats_coeff (const struct regression *cmd, const struct linreg *c, pivot_value_new_number (base_entries[i])); if (cmd->stats & STATS_CI) - { - double interval_entries[] = { - linreg_coeff (c, j) - tval * std_err, - linreg_coeff (c, j) + tval * std_err, - }; + { + double interval_entries[] = { + linreg_coeff (c, j) - tval * std_err, + linreg_coeff (c, j) + tval * std_err, + }; - for (size_t i = 0; i < sizeof interval_entries / sizeof *interval_entries; i++) - pivot_table_put2 (table, col++, var_idx, - pivot_value_new_number (interval_entries[i])); - } + for (size_t i = 0; i < sizeof interval_entries / sizeof *interval_entries; i++) + pivot_table_put2 (table, col++, var_idx, + pivot_value_new_number (interval_entries[i])); + } if (cmd->stats & STATS_TOL) - { - { - struct linreg *m = mc[j].models[0]; - double rsq = linreg_ssreg (m) / linreg_sst (m); - pivot_table_put2 (table, col++, var_idx, pivot_value_new_number (1.0 - rsq)); - pivot_table_put2 (table, col++, var_idx, pivot_value_new_number (1.0 / (1.0 - rsq))); - } - } + { + { + struct linreg *m = mc[j].models[0]; + double rsq = linreg_ssreg (m) / linreg_sst (m); + pivot_table_put2 (table, col++, var_idx, pivot_value_new_number (1.0 - rsq)); + pivot_table_put2 (table, col++, var_idx, pivot_value_new_number (1.0 / (1.0 - rsq))); + } + } } pivot_table_submit (table); diff --git a/src/language/commands/reliability.c b/src/language/commands/reliability.c index 02253251a5..08d9bdb863 100644 --- a/src/language/commands/reliability.c +++ b/src/language/commands/reliability.c @@ -109,13 +109,13 @@ reliability_destroy (struct reliability *rel) if (rel->sc) for (j = 0; j < rel->n_sc; ++j) { - int x; - free (rel->sc[j].items); + int x; + free (rel->sc[j].items); moments1_destroy (rel->sc[j].total); if (rel->sc[j].m) for (x = 0; x < rel->sc[j].n_items; ++x) free (rel->sc[j].m[x]); - free (rel->sc[j].m); + free (rel->sc[j].m); } free (rel->sc); @@ -143,7 +143,7 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) int vars_start = lex_ofs (lexer); if (!parse_variables_const (lexer, dict, &r.vars, &r.n_vars, - PV_NO_DUPLICATE | PV_NUMERIC)) + PV_NO_DUPLICATE | PV_NUMERIC)) goto error; int vars_end = lex_ofs (lexer) - 1; @@ -167,87 +167,87 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "SCALE")) - { - struct const_var_set *vs; - if (!lex_force_match (lexer, T_LPAREN)) - goto error; + { + struct const_var_set *vs; + if (!lex_force_match (lexer, T_LPAREN)) + goto error; - if (!lex_force_string (lexer)) - goto error; + if (!lex_force_string (lexer)) + goto error; free (r.scale_name); r.scale_name = xstrdup (lex_tokcstr (lexer)); - lex_get (lexer); + lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; + if (!lex_force_match (lexer, T_RPAREN)) + goto error; lex_match (lexer, T_EQUALS); - vs = const_var_set_create_from_array (r.vars, r.n_vars); + vs = const_var_set_create_from_array (r.vars, r.n_vars); - free (r.sc->items); - if (!parse_const_var_set_vars (lexer, vs, &r.sc->items, &r.sc->n_items, 0)) - { - const_var_set_destroy (vs); - goto error; - } + free (r.sc->items); + if (!parse_const_var_set_vars (lexer, vs, &r.sc->items, &r.sc->n_items, 0)) + { + const_var_set_destroy (vs); + goto error; + } - const_var_set_destroy (vs); - } + const_var_set_destroy (vs); + } else if (lex_match_id (lexer, "MODEL")) - { + { lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "ALPHA")) + if (lex_match_id (lexer, "ALPHA")) r.model = MODEL_ALPHA; - else if (lex_match_id (lexer, "SPLIT")) - { - r.model = MODEL_SPLIT; - r.split_point = -1; + else if (lex_match_id (lexer, "SPLIT")) + { + r.model = MODEL_SPLIT; + r.split_point = -1; - if (lex_match (lexer, T_LPAREN)) + if (lex_match (lexer, T_LPAREN)) { if (!lex_force_num (lexer)) goto error; split_ofs = lex_ofs (lexer); - r.split_point = lex_number (lexer); - lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - } - else + r.split_point = lex_number (lexer); + lex_get (lexer); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + } + else { lex_error_expecting (lexer, "ALPHA", "SPLIT"); goto error; } - } + } else if (lex_match_id (lexer, "SUMMARY")) { lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "TOTAL") || lex_match (lexer, T_ALL)) + if (lex_match_id (lexer, "TOTAL") || lex_match (lexer, T_ALL)) r.summary_total = true; - else + else { lex_error_expecting (lexer, "TOTAL", "ALL"); goto error; } - } + } else if (lex_match_id (lexer, "MISSING")) { lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) { - if (lex_match_id (lexer, "INCLUDE")) + if (lex_match_id (lexer, "INCLUDE")) r.exclude = MV_SYSTEM; else if (lex_match_id (lexer, "EXCLUDE")) r.exclude = MV_ANY; else - { + { lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "STATISTICS")) { int statistics_start = lex_ofs (lexer) - 1; @@ -261,11 +261,11 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) "No statistics will be produced.")); } else - { - lex_error_expecting (lexer, "SCALE", "MODEL", "SUMMARY", "MISSING", + { + lex_error_expecting (lexer, "SCALE", "MODEL", "SUMMARY", "MISSING", "STATISTICS"); - goto error; - } + goto error; + } } if (r.model == MODEL_SPLIT) @@ -300,10 +300,10 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) i++; } while (i < s->n_items) - { - r.sc[2].items[i - r.sc[1].n_items] = s->items[i]; - i++; - } + { + r.sc[2].items[i - r.sc[1].n_items] = s->items[i]; + i++; + } } if (r.summary_total) @@ -316,17 +316,17 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) r.sc = xrealloc (r.sc, sizeof (struct cronbach) * r.n_sc); for (size_t i = 0; i < r.sc[0].n_items; ++i) - { - struct cronbach *s = &r.sc[i + base_sc]; + { + struct cronbach *s = &r.sc[i + base_sc]; - s->n_items = r.sc[0].n_items - 1; - s->items = xcalloc (s->n_items, sizeof (struct variable *)); + s->n_items = r.sc[0].n_items - 1; + s->items = xcalloc (s->n_items, sizeof (struct variable *)); - size_t v_dest = 0; - for (size_t v_src = 0; v_src < r.sc[0].n_items; ++v_src) + size_t v_dest = 0; + for (size_t v_src = 0; v_src < r.sc[0].n_items; ++v_src) if (v_src != i) s->items[v_dest++] = r.sc[0].items[v_src]; - } + } } if (!run_reliability (ds, &r)) @@ -343,7 +343,7 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) static void do_reliability (struct casereader *group, struct dataset *ds, - const struct reliability *rel); + const struct reliability *rel); static void reliability_summary_total (const struct reliability *rel); @@ -362,7 +362,7 @@ run_reliability (struct dataset *ds, const struct reliability *reliability) s->total = moments1_create (MOMENT_VARIANCE); for (size_t i = 0; i < s->n_items; ++i) - s->m[i] = moments1_create (MOMENT_VARIANCE); + s->m[i] = moments1_create (MOMENT_VARIANCE); } struct dictionary *dict = dataset_dict (ds); @@ -375,7 +375,7 @@ run_reliability (struct dataset *ds, const struct reliability *reliability) reliability_statistics (reliability); if (reliability->summary_total) - reliability_summary_total (reliability); + reliability_summary_total (reliability); } bool ok = casegrouper_destroy (grouper); @@ -398,7 +398,7 @@ append_sum (const struct ccase *c, casenumber n UNUSED, void *aux) static void case_processing_summary (casenumber n_valid, casenumber n_missing, - const struct dictionary *); + const struct dictionary *); static double alpha (int k, double sum_of_variances, double variance_of_sums) @@ -408,7 +408,7 @@ alpha (int k, double sum_of_variances, double variance_of_sums) static void do_reliability (struct casereader *input, struct dataset *ds, - const struct reliability *rel) + const struct reliability *rel) { for (size_t si = 0; si < rel->n_sc; ++si) { @@ -421,11 +421,11 @@ do_reliability (struct casereader *input, struct dataset *ds, casenumber n_missing; input = casereader_create_filter_missing (input, - rel->vars, - rel->n_vars, - rel->exclude, - &n_missing, - NULL); + rel->vars, + rel->n_vars, + rel->exclude, + &n_missing, + NULL); for (size_t si = 0; si < rel->n_sc; ++si) { @@ -442,13 +442,13 @@ do_reliability (struct casereader *input, struct dataset *ds, n_valid++; for (size_t si = 0; si < rel->n_sc; ++si) - { - struct cronbach *s = &rel->sc[si]; + { + struct cronbach *s = &rel->sc[si]; - for (size_t i = 0; i < s->n_items; ++i) - moments1_add (s->m[i], case_num (c, s->items[i]), weight); - moments1_add (s->total, case_num_idx (c, s->totals_idx), weight); - } + for (size_t i = 0; i < s->n_items; ++i) + moments1_add (s->m[i], case_num (c, s->items[i]), weight); + moments1_add (s->total, case_num_idx (c, s->totals_idx), weight); + } } casereader_destroy (input); @@ -458,15 +458,15 @@ do_reliability (struct casereader *input, struct dataset *ds, s->sum_of_variances = 0; for (size_t i = 0; i < s->n_items; ++i) - { - double weight, mean, variance; - moments1_calculate (s->m[i], &weight, &mean, &variance, NULL, NULL); + { + double weight, mean, variance; + moments1_calculate (s->m[i], &weight, &mean, &variance, NULL, NULL); - s->sum_of_variances += variance; - } + s->sum_of_variances += variance; + } moments1_calculate (s->total, NULL, NULL, &s->variance_of_sums, - NULL, NULL); + NULL, NULL); s->alpha = alpha (s->n_items, s->sum_of_variances, s->variance_of_sums); } @@ -481,7 +481,7 @@ do_reliability (struct casereader *input, struct dataset *ds, static void case_processing_summary (casenumber n_valid, casenumber n_missing, - const struct dictionary *dict) + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create ( N_("Case Processing Summary")); diff --git a/src/language/commands/rename-variables.c b/src/language/commands/rename-variables.c index 28af671e87..eecc90af13 100644 --- a/src/language/commands/rename-variables.c +++ b/src/language/commands/rename-variables.c @@ -60,31 +60,31 @@ cmd_rename_variables (struct lexer *lexer, struct dataset *ds) int start_ofs = lex_ofs (lexer); if (!parse_variables (lexer, dataset_dict (ds), &vars_to_be_renamed, &n_vars_to_be_renamed, opts)) - { - goto lossage; - } + { + goto lossage; + } if (!lex_force_match (lexer, T_EQUALS)) - { - goto lossage; - } + { + goto lossage; + } if (!parse_DATA_LIST_vars (lexer, dataset_dict (ds), &new_names, &n_new_names, opts)) - { - goto lossage; - } + { + goto lossage; + } int end_ofs = lex_ofs (lexer) - 1; if (n_new_names != n_vars_to_be_renamed) { lex_ofs_error (lexer, start_ofs, end_ofs, _("Differing number of variables in old name list " "(%zu) and in new name list (%zu)."), - n_vars_to_be_renamed, n_new_names); + n_vars_to_be_renamed, n_new_names); goto lossage; } if (!(opts & PV_SINGLE) && !lex_force_match (lexer, T_RPAREN)) - { - goto lossage; - } + { + goto lossage; + } } while (lex_token (lexer) != T_ENDCMD); diff --git a/src/language/commands/repeat.c b/src/language/commands/repeat.c index 2efce93e2b..af0d89d59e 100644 --- a/src/language/commands/repeat.c +++ b/src/language/commands/repeat.c @@ -101,7 +101,7 @@ parse_specification (struct lexer *lexer, struct dictionary *dict, /* Get a stand-in variable name and make sure it's unique. */ if (!lex_force_id (lexer)) - goto error; + goto error; struct substring name = lex_tokss (lexer); if (dict_lookup_var (dict, name.string)) lex_msg (lexer, SW, @@ -125,23 +125,23 @@ parse_specification (struct lexer *lexer, struct dictionary *dict, /* Skip equals sign. */ lex_get (lexer); if (!lex_force_match (lexer, T_EQUALS)) - goto error; + goto error; /* Get the details of the variable's possible values. */ bool ok; if (lex_token (lexer) == T_ID || lex_token (lexer) == T_ALL) - ok = parse_ids (lexer, dict, dv); + ok = parse_ids (lexer, dict, dv); else if (lex_is_number (lexer)) - ok = parse_numbers (lexer, dv); + ok = parse_numbers (lexer, dv); else if (lex_is_string (lexer)) - ok = parse_strings (lexer, dv); + ok = parse_strings (lexer, dv); else - { - lex_error (lexer, _("Syntax error expecting substitution values.")); - goto error; - } + { + lex_error (lexer, _("Syntax error expecting substitution values.")); + goto error; + } if (!ok) - goto error; + goto error; assert (dv->n_values > 0); if (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) { @@ -151,11 +151,11 @@ parse_specification (struct lexer *lexer, struct dictionary *dict, dv->end_ofs = lex_ofs (lexer) - 1; /* If this is the first variable then it defines how many replacements - there must be; otherwise enforce this number of replacements. */ + there must be; otherwise enforce this number of replacements. */ if (first_dv == NULL) first_dv = dv; else if (first_dv->n_values != dv->n_values) - { + { msg (SE, _("Each dummy variable must have the same number of " "substitutions.")); @@ -169,8 +169,8 @@ parse_specification (struct lexer *lexer, struct dictionary *dict, "Dummy variable %s had %zu substitutions.", dv->n_values), dv->name.string, dv->n_values); - goto error; - } + goto error; + } lex_match (lexer, T_SLASH); } @@ -324,7 +324,7 @@ destroy_dummies (struct hmap *dummies) /* Parses a set of ids for DO REPEAT. */ static bool parse_ids (struct lexer *lexer, const struct dictionary *dict, - struct dummy_var *dv) + struct dummy_var *dv) { return parse_mixed_vars (lexer, dict, &dv->values, &dv->n_values, PV_NONE); } @@ -349,15 +349,15 @@ parse_numbers (struct lexer *lexer, struct dummy_var *dv) do { if (!lex_force_num (lexer)) - return false; + return false; if (lex_next_token (lexer, 1) == T_TO) { if (!lex_is_integer (lexer)) - { - lex_error (lexer, _("Ranges may only have integer bounds.")); - return false; - } + { + lex_error (lexer, _("Ranges may only have integer bounds.")); + return false; + } long a = lex_integer (lexer); lex_get (lexer); @@ -366,14 +366,14 @@ parse_numbers (struct lexer *lexer, struct dummy_var *dv) if (!lex_force_int_range (lexer, NULL, a, LONG_MAX)) return false; - long b = lex_integer (lexer); + long b = lex_integer (lexer); if (b < a) { lex_next_error (lexer, -2, 0, _("%ld TO %ld is an invalid range."), a, b); return false; } - lex_get (lexer); + lex_get (lexer); for (long i = a; i <= b; i++) add_replacement (dv, xasprintf ("%ld", i), &allocated); diff --git a/src/language/commands/roc.c b/src/language/commands/roc.c index cb835967db..c1b20502e0 100644 --- a/src/language/commands/roc.c +++ b/src/language/commands/roc.c @@ -60,7 +60,7 @@ struct cmd_roc bool print_coords; bool print_se; bool bi_neg_exp; /* True iff the bi-negative exponential critieria - should be used */ + should be used */ enum mv_class exclude; bool invert; /* True iff a smaller test result variable indicates @@ -91,7 +91,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars, - PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) + PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) goto error; if (!lex_force_match (lexer, T_BY)) @@ -118,132 +118,132 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) { - if (lex_match_id (lexer, "INCLUDE")) + if (lex_match_id (lexer, "INCLUDE")) roc.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) roc.exclude = MV_ANY; - else - { + else + { lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - } - } + goto error; + } + } + } else if (lex_match_id (lexer, "PLOT")) - { - lex_match (lexer, T_EQUALS); - if (lex_match_id (lexer, "CURVE")) - { - roc.curve = true; - if (lex_match (lexer, T_LPAREN)) - { - roc.reference = true; - if (!lex_force_match_id (lexer, "REFERENCE") + { + lex_match (lexer, T_EQUALS); + if (lex_match_id (lexer, "CURVE")) + { + roc.curve = true; + if (lex_match (lexer, T_LPAREN)) + { + roc.reference = true; + if (!lex_force_match_id (lexer, "REFERENCE") || !lex_force_match (lexer, T_RPAREN)) - goto error; - } - } - else if (lex_match_id (lexer, "NONE")) + goto error; + } + } + else if (lex_match_id (lexer, "NONE")) roc.curve = false; - else - { - lex_error_expecting (lexer, "CURVE", "NONE"); - goto error; - } - } + else + { + lex_error_expecting (lexer, "CURVE", "NONE"); + goto error; + } + } else if (lex_match_id (lexer, "PRINT")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "SE")) + { + if (lex_match_id (lexer, "SE")) roc.print_se = true; - else if (lex_match_id (lexer, "COORDINATES")) + else if (lex_match_id (lexer, "COORDINATES")) roc.print_coords = true; - else - { - lex_error_expecting (lexer, "SE", "COORDINATES"); - goto error; - } - } - } + else + { + lex_error_expecting (lexer, "SE", "COORDINATES"); + goto error; + } + } + } else if (lex_match_id (lexer, "CRITERIA")) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH) - { - if (lex_match_id (lexer, "CUTOFF")) - { - if (!lex_force_match (lexer, T_LPAREN)) - goto error; - if (lex_match_id (lexer, "INCLUDE")) + { + if (lex_match_id (lexer, "CUTOFF")) + { + if (!lex_force_match (lexer, T_LPAREN)) + goto error; + if (lex_match_id (lexer, "INCLUDE")) roc.exclude = MV_SYSTEM; - else if (lex_match_id (lexer, "EXCLUDE")) + else if (lex_match_id (lexer, "EXCLUDE")) roc.exclude = MV_USER | MV_SYSTEM; - else - { - lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); - goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - else if (lex_match_id (lexer, "TESTPOS")) - { - if (!lex_force_match (lexer, T_LPAREN)) - goto error; - if (lex_match_id (lexer, "LARGE")) + else + { + lex_error_expecting (lexer, "INCLUDE", "EXCLUDE"); + goto error; + } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + else if (lex_match_id (lexer, "TESTPOS")) + { + if (!lex_force_match (lexer, T_LPAREN)) + goto error; + if (lex_match_id (lexer, "LARGE")) roc.invert = false; - else if (lex_match_id (lexer, "SMALL")) + else if (lex_match_id (lexer, "SMALL")) roc.invert = true; - else - { - lex_error_expecting (lexer, "LARGE", "SMALL"); - goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - else if (lex_match_id (lexer, "CI")) - { - if (!lex_force_match (lexer, T_LPAREN)) - goto error; - if (!lex_force_num (lexer)) - goto error; - roc.ci = lex_number (lexer); - lex_get (lexer); - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - else if (lex_match_id (lexer, "DISTRIBUTION")) - { - if (!lex_force_match (lexer, T_LPAREN)) - goto error; - if (lex_match_id (lexer, "FREE")) + else + { + lex_error_expecting (lexer, "LARGE", "SMALL"); + goto error; + } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + else if (lex_match_id (lexer, "CI")) + { + if (!lex_force_match (lexer, T_LPAREN)) + goto error; + if (!lex_force_num (lexer)) + goto error; + roc.ci = lex_number (lexer); + lex_get (lexer); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + else if (lex_match_id (lexer, "DISTRIBUTION")) + { + if (!lex_force_match (lexer, T_LPAREN)) + goto error; + if (lex_match_id (lexer, "FREE")) roc.bi_neg_exp = false; - else if (lex_match_id (lexer, "NEGEXPO")) + else if (lex_match_id (lexer, "NEGEXPO")) roc.bi_neg_exp = true; - else - { - lex_error_expecting (lexer, "FREE", "NEGEXPO"); - goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) - goto error; - } - else - { - lex_error_expecting (lexer, "CUTOFF", "TESTPOS", "CI", + else + { + lex_error_expecting (lexer, "FREE", "NEGEXPO"); + goto error; + } + if (!lex_force_match (lexer, T_RPAREN)) + goto error; + } + else + { + lex_error_expecting (lexer, "CUTOFF", "TESTPOS", "CI", "DISTRIBUTION"); - goto error; - } - } - } + goto error; + } + } + } else - { - lex_error_expecting (lexer, "MISSING", "PLOT", "PRINT", "CRITERIA"); - goto error; - } + { + lex_error_expecting (lexer, "MISSING", "PLOT", "PRINT", "CRITERIA"); + goto error; + } } if (!run_roc (ds, &roc)) @@ -363,9 +363,9 @@ struct roc_state */ static struct casereader * accumulate_counts (struct casereader *input, - double result, double weight, - bool (*pos_cond) (double, double), - int true_index, int false_index) + double result, double weight, + bool (*pos_cond) (double, double), + int true_index, int false_index) { const struct caseproto *proto = casereader_get_proto (input); struct casewriter *w = @@ -382,7 +382,7 @@ accumulate_counts (struct casereader *input, /* We don't want duplicates here */ if (cp == prev_cp) - continue; + continue; new_case = case_clone (cpc); @@ -419,13 +419,13 @@ static void output_roc (struct roc_state *rs, const struct cmd_roc *roc); */ static struct casereader * process_group (const struct variable *var, struct casereader *reader, - bool (*pred) (double, double), - const struct dictionary *dict, - double *cc, - struct casereader **cutpoint_rdr, - bool (*pos_cond) (double, double), - int true_index, - int false_index) + bool (*pred) (double, double), + const struct dictionary *dict, + double *cc, + struct casereader **cutpoint_rdr, + bool (*pos_cond) (double, double), + int true_index, + int false_index) { const struct variable *w = dict_get_weight (dict); @@ -461,26 +461,26 @@ process_group (const struct variable *var, struct casereader *reader, double n_pred = 0.0; *cutpoint_rdr = accumulate_counts (*cutpoint_rdr, d1, weight1, - pos_cond, - true_index, false_index); + pos_cond, + true_index, false_index); *cc += weight1; for (; (c2 = casereader_read (r2)); case_unref (c2)) - { - const double d2 = case_num (c2, var); - const double weight2 = case_num_idx (c2, weight_idx); - - if (d1 == d2) - { - n_eq += weight2; - continue; - } - else if (pred (d2, d1)) - { - n_pred += weight2; - } - } + { + const double d2 = case_num (c2, var); + const double weight2 = case_num_idx (c2, weight_idx); + + if (d1 == d2) + { + n_eq += weight2; + continue; + } + else if (pred (d2, d1)) + { + n_pred += weight2; + } + } *case_num_rw_idx (new_case, VALUE) = d1; *case_num_rw_idx (new_case, N_EQ) = n_eq; @@ -534,13 +534,13 @@ lt (double d1, double d2) */ static struct casereader * process_positive_group (const struct variable *var, struct casereader *reader, - const struct dictionary *dict, - struct roc_state *rs) + const struct dictionary *dict, + struct roc_state *rs) { return process_group (var, reader, gt, dict, &rs->n1, - &rs->cutpoint_rdr, - ge, - ROC_TP, ROC_FN); + &rs->cutpoint_rdr, + ge, + ROC_TP, ROC_FN); } /* @@ -552,13 +552,13 @@ process_positive_group (const struct variable *var, struct casereader *reader, */ static struct casereader * process_negative_group (const struct variable *var, struct casereader *reader, - const struct dictionary *dict, - struct roc_state *rs) + const struct dictionary *dict, + struct roc_state *rs) { return process_group (var, reader, lt, dict, &rs->n2, - &rs->cutpoint_rdr, - lt, - ROC_TN, ROC_FP); + &rs->cutpoint_rdr, + lt, + ROC_TN, ROC_FP); } @@ -682,7 +682,7 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict) struct casereader *pos = casereader_clone (positives); struct casereader *n_pos_reader = - process_positive_group (var, pos, dict, &rs[i]); + process_positive_group (var, pos, dict, &rs[i]); if (!negatives) negatives = casewriter_make_reader (neg_wtr); @@ -695,40 +695,40 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict) struct casewriter *w = sort_create_writer (&up_ordering, n_proto); struct ccase *cpos; for (; (cpos = casereader_read (n_pos_reader)); case_unref (cpos)) - { - struct ccase *pos_case = case_create (n_proto); - const double jpos = case_num_idx (cpos, VALUE); + { + struct ccase *pos_case = case_create (n_proto); + const double jpos = case_num_idx (cpos, VALUE); - struct ccase *cneg; - while ((cneg = casereader_read (n_neg_reader))) - { - struct ccase *nc = case_create (n_proto); + struct ccase *cneg; + while ((cneg = casereader_read (n_neg_reader))) + { + struct ccase *nc = case_create (n_proto); - const double jneg = case_num_idx (cneg, VALUE); + const double jneg = case_num_idx (cneg, VALUE); - *case_num_rw_idx (nc, VALUE) = jneg; - *case_num_rw_idx (nc, N_POS_EQ) = 0; + *case_num_rw_idx (nc, VALUE) = jneg; + *case_num_rw_idx (nc, N_POS_EQ) = 0; - *case_num_rw_idx (nc, N_POS_GT) = SYSMIS; + *case_num_rw_idx (nc, N_POS_GT) = SYSMIS; - *case_data_rw_idx (nc, N_NEG_EQ) = *case_data_idx (cneg, N_EQ); - *case_data_rw_idx (nc, N_NEG_LT) = *case_data_idx (cneg, N_PRED); + *case_data_rw_idx (nc, N_NEG_EQ) = *case_data_idx (cneg, N_EQ); + *case_data_rw_idx (nc, N_NEG_LT) = *case_data_idx (cneg, N_PRED); - casewriter_write (w, nc); + casewriter_write (w, nc); - case_unref (cneg); - if (jneg > jpos) - break; - } + case_unref (cneg); + if (jneg > jpos) + break; + } - *case_num_rw_idx (pos_case, VALUE) = jpos; - *case_data_rw_idx (pos_case, N_POS_EQ) = *case_data_idx (cpos, N_EQ); - *case_data_rw_idx (pos_case, N_POS_GT) = *case_data_idx (cpos, N_PRED); - *case_num_rw_idx (pos_case, N_NEG_EQ) = 0; - *case_num_rw_idx (pos_case, N_NEG_LT) = SYSMIS; + *case_num_rw_idx (pos_case, VALUE) = jpos; + *case_data_rw_idx (pos_case, N_POS_EQ) = *case_data_idx (cpos, N_EQ); + *case_data_rw_idx (pos_case, N_POS_GT) = *case_data_idx (cpos, N_PRED); + *case_num_rw_idx (pos_case, N_NEG_EQ) = 0; + *case_num_rw_idx (pos_case, N_NEG_LT) = SYSMIS; - casewriter_write (w, pos_case); - } + casewriter_write (w, pos_case); + } casereader_destroy (n_pos_reader); casereader_destroy (n_neg_reader); @@ -736,7 +736,7 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict) struct casereader *r = casewriter_make_reader (w); /* Propagate the N_POS_GT values from the positive cases - to the negative ones */ + to the negative ones */ double prev_pos_gt = rs[i].n1; w = sort_create_writer (&down_ordering, n_proto); @@ -759,7 +759,7 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict) r = casewriter_make_reader (w); /* Propagate the N_NEG_LT values from the negative cases - to the positive ones */ + to the positive ones */ double prev_neg_lt = rs[i].n2; w = sort_create_writer (&up_ordering, n_proto); @@ -891,17 +891,17 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) pivot_table_put2 (table, 0, var_idx, pivot_value_new_number (rs[i].auc)); if (roc->print_se) - { - double se = (rs[i].auc * (1 - rs[i].auc) + { + double se = (rs[i].auc * (1 - rs[i].auc) + (rs[i].n1 - 1) * (rs[i].q1hat - pow2 (rs[i].auc)) + (rs[i].n2 - 1) * (rs[i].q2hat - pow2 (rs[i].auc))); - se /= rs[i].n1 * rs[i].n2; - se = sqrt (se); + se /= rs[i].n1 * rs[i].n2; + se = sqrt (se); - double ci = 1 - roc->ci / 100.0; - double yy = gsl_cdf_gaussian_Qinv (ci, se); + double ci = 1 - roc->ci / 100.0; + double yy = gsl_cdf_gaussian_Qinv (ci, se); - double sd_0_5 = sqrt ((rs[i].n1 + rs[i].n2 + 1) / + double sd_0_5 = sqrt ((rs[i].n1 + rs[i].n2 + 1) / (12 * rs[i].n1 * rs[i].n2)); double sig = 2.0 * gsl_cdf_ugaussian_Q (fabs ((rs[i].auc - 0.5) / sd_0_5)); @@ -909,7 +909,7 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) for (size_t i = 0; i < sizeof entries / sizeof *entries; i++) pivot_table_put2 (table, i + 1, var_idx, pivot_value_new_number (entries[i])); - } + } } pivot_table_submit (table); @@ -982,12 +982,12 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) struct ccase *cc; int coord_idx = 0; for (; (cc = casereader_read (r)) != NULL; case_unref (cc)) - { - const double se = case_num_idx (cc, ROC_TP) / - (case_num_idx (cc, ROC_TP) + case_num_idx (cc, ROC_FN)); + { + const double se = case_num_idx (cc, ROC_TP) / + (case_num_idx (cc, ROC_TP) + case_num_idx (cc, ROC_FN)); - const double sp = case_num_idx (cc, ROC_TN) / - (case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP)); + const double sp = case_num_idx (cc, ROC_TN) / + (case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP)); if (coord_idx >= n_coords) { @@ -1006,7 +1006,7 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) pivot_table_put3 (table, 2, coord_idx, var_idx, pivot_value_new_number (1 - sp)); coord_idx++; - } + } casereader_destroy (r); } diff --git a/src/language/commands/runs.c b/src/language/commands/runs.c index b2492c16c3..df6da7d98c 100644 --- a/src/language/commands/runs.c +++ b/src/language/commands/runs.c @@ -81,11 +81,11 @@ runs_statistic (const struct run_state *rs) if (rs->n < 50) { if (z <= -0.5) - z += 0.5; + z += 0.5; else if (z >= 0.5) - z -= 0.5; + z -= 0.5; else - return 0; + return 0; } sigma = 2 * rs->np * rs->nn; @@ -103,11 +103,11 @@ static void show_runs_result (const struct runs_test *, const struct run_state * void runs_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int v; struct ccase *c; @@ -122,138 +122,138 @@ runs_execute (const struct dataset *ds, { case CP_MODE: { - for (v = 0; v < otp->n_vars; ++v) - { - bool multimodal = false; - struct run_state *run = &rs[v]; - double last_cc; - struct casereader *group = NULL; - struct casegrouper *grouper; - struct casereader *reader = casereader_clone (input); - 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)) - { - double x = SYSMIS; - double cc = 0.0; - struct ccase *c; - for (; (c = casereader_read (group)); case_unref (c)) - { - const double w = weight ? case_num (c, weight) : 1.0; - const union value *val = case_data (c, var); - if (var_is_value_missing (var, val) & exclude) - continue; - x = val->f; - cc += w; - } - - if (cc > last_cc) - { - run->cutpoint = x; - } - else if (cc == last_cc) - { - multimodal = true; - if (x > run->cutpoint) - run->cutpoint = x; - } - last_cc = cc; - casereader_destroy (group); - } - casegrouper_destroy (grouper); - if (multimodal) - msg (MW, _("Multiple modes exist for variable `%s'. " + for (v = 0; v < otp->n_vars; ++v) + { + bool multimodal = false; + struct run_state *run = &rs[v]; + double last_cc; + struct casereader *group = NULL; + struct casegrouper *grouper; + struct casereader *reader = casereader_clone (input); + 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)) + { + double x = SYSMIS; + double cc = 0.0; + struct ccase *c; + for (; (c = casereader_read (group)); case_unref (c)) + { + const double w = weight ? case_num (c, weight) : 1.0; + const union value *val = case_data (c, var); + if (var_is_value_missing (var, val) & exclude) + continue; + x = val->f; + cc += w; + } + + if (cc > last_cc) + { + run->cutpoint = x; + } + else if (cc == last_cc) + { + multimodal = true; + if (x > run->cutpoint) + run->cutpoint = x; + } + last_cc = cc; + casereader_destroy (group); + } + casegrouper_destroy (grouper); + if (multimodal) + msg (MW, _("Multiple modes exist for variable `%s'. " "Using %.*g as the threshold value."), - var_get_name (var), DBL_DIG + 1, run->cutpoint); - } + var_get_name (var), DBL_DIG + 1, run->cutpoint); + } } break; case CP_MEDIAN: { - for (v = 0; v < otp->n_vars; ++v) - { - double cc = 0.0; - struct ccase *c; - struct run_state *run = &rs[v]; - struct casereader *reader = casereader_clone (input); - const struct variable *var = otp->vars[v]; - struct casewriter *writer; - struct percentile *median; - struct order_stats *os; - struct subcase sc; - subcase_init_var (&sc, var, SC_ASCEND); - writer = sort_create_writer (&sc, casereader_get_proto (reader)); - - for (; (c = casereader_read (reader));) - { - const union value *val = case_data (c, var); - const double w = weight ? case_num (c, weight) : 1.0; - if (var_is_value_missing (var, val) & exclude) - { - case_unref (c); - continue; - } - - cc += w; - casewriter_write (writer, c); - } - subcase_uninit (&sc); - casereader_destroy (reader); - reader = casewriter_make_reader (writer); - - median = percentile_create (0.5, cc); - os = &median->parent; - - order_stats_accumulate (&os, 1, - reader, - weight, - var, - exclude); - - run->cutpoint = percentile_calculate (median, PC_HAVERAGE); - statistic_destroy (&median->parent.parent); - } + for (v = 0; v < otp->n_vars; ++v) + { + double cc = 0.0; + struct ccase *c; + struct run_state *run = &rs[v]; + struct casereader *reader = casereader_clone (input); + const struct variable *var = otp->vars[v]; + struct casewriter *writer; + struct percentile *median; + struct order_stats *os; + struct subcase sc; + subcase_init_var (&sc, var, SC_ASCEND); + writer = sort_create_writer (&sc, casereader_get_proto (reader)); + + for (; (c = casereader_read (reader));) + { + const union value *val = case_data (c, var); + const double w = weight ? case_num (c, weight) : 1.0; + if (var_is_value_missing (var, val) & exclude) + { + case_unref (c); + continue; + } + + cc += w; + casewriter_write (writer, c); + } + subcase_uninit (&sc); + casereader_destroy (reader); + reader = casewriter_make_reader (writer); + + median = percentile_create (0.5, cc); + os = &median->parent; + + order_stats_accumulate (&os, 1, + reader, + weight, + var, + exclude); + + run->cutpoint = percentile_calculate (median, PC_HAVERAGE); + statistic_destroy (&median->parent.parent); + } } break; case CP_MEAN: { - struct casereader *reader = casereader_clone (input); - for (; (c = casereader_read (reader)); case_unref (c)) - { - const double w = weight ? case_num (c, weight) : 1.0; - for (v = 0; v < otp->n_vars; ++v) - { - const struct variable *var = otp->vars[v]; - const union value *val = case_data (c, var); - const double x = val->f; - struct run_state *run = &rs[v]; - - if (var_is_value_missing (var, val) & exclude) - continue; - - run->cutpoint += x * w; - run->n += w; - } - } - casereader_destroy (reader); - for (v = 0; v < otp->n_vars; ++v) - { - struct run_state *run = &rs[v]; - run->cutpoint /= run->n; - } + struct casereader *reader = casereader_clone (input); + for (; (c = casereader_read (reader)); case_unref (c)) + { + const double w = weight ? case_num (c, weight) : 1.0; + for (v = 0; v < otp->n_vars; ++v) + { + const struct variable *var = otp->vars[v]; + const union value *val = case_data (c, var); + const double x = val->f; + struct run_state *run = &rs[v]; + + if (var_is_value_missing (var, val) & exclude) + continue; + + run->cutpoint += x * w; + run->n += w; + } + } + casereader_destroy (reader); + for (v = 0; v < otp->n_vars; ++v) + { + struct run_state *run = &rs[v]; + run->cutpoint /= run->n; + } } break; case CP_CUSTOM: { for (v = 0; v < otp->n_vars; ++v) - { - struct run_state *run = &rs[v]; - run->cutpoint = rt->cutpoint; - } + { + struct run_state *run = &rs[v]; + run->cutpoint = rt->cutpoint; + } } break; } @@ -263,33 +263,33 @@ runs_execute (const struct dataset *ds, const double w = weight ? case_num (c, weight) : 1.0; for (v = 0; v < otp->n_vars; ++v) - { - struct run_state *run = &rs[v]; - const struct variable *var = otp->vars[v]; - const union value *val = case_data (c, var); - double x = val->f; - double d = x - run->cutpoint; - short sign = 0; - - if (var_is_value_missing (var, val) & exclude) - continue; - - if (d >= 0) - { - sign = +1; - run->np += w; - } - else - { - sign = -1; - run->nn += w; - } - - if (sign != run->last_sign) - run->runs++; - - run->last_sign = sign; - } + { + struct run_state *run = &rs[v]; + const struct variable *var = otp->vars[v]; + const union value *val = case_data (c, var); + double x = val->f; + double d = x - run->cutpoint; + short sign = 0; + + if (var_is_value_missing (var, val) & exclude) + continue; + + if (d >= 0) + { + sign = +1; + run->np += w; + } + else + { + sign = -1; + run->nn += w; + } + + if (sign != run->last_sign) + run->runs++; + + run->last_sign = sign; + } } casereader_destroy (input); diff --git a/src/language/commands/runs.h b/src/language/commands/runs.h index f05d0f8ea4..817346dea7 100644 --- a/src/language/commands/runs.h +++ b/src/language/commands/runs.h @@ -41,11 +41,11 @@ struct runs_test void runs_execute (const struct dataset *ds, - struct casereader *input, + struct casereader *input, enum mv_class exclude, - const struct npar_test *test, - bool, - double); + const struct npar_test *test, + bool, + double); #endif diff --git a/src/language/commands/sample.c b/src/language/commands/sample.c index 037cff4a38..8c36232593 100644 --- a/src/language/commands/sample.c +++ b/src/language/commands/sample.c @@ -38,16 +38,16 @@ /* The two different types of samples. */ enum { - TYPE_A_FROM_B, /* 5 FROM 10 */ - TYPE_FRACTION /* 0.5 */ + TYPE_A_FROM_B, /* 5 FROM 10 */ + TYPE_FRACTION /* 0.5 */ }; /* SAMPLE transformation. */ struct sample_trns { - int type; /* One of TYPE_*. */ - int n, N; /* TYPE_A_FROM_B: n from N. */ - int m, t; /* TYPE_A_FROM_B: # picked so far; # so far. */ + int type; /* One of TYPE_*. */ + int n, N; /* TYPE_A_FROM_B: n from N. */ + int m, t; /* TYPE_A_FROM_B: # picked so far; # so far. */ unsigned frac; /* TYPE_FRACTION: a fraction of UINT_MAX. */ }; @@ -82,9 +82,9 @@ cmd_sample (struct lexer *lexer, struct dataset *ds) a = lex_integer (lexer); lex_get (lexer); if (!lex_force_match_id (lexer, "FROM")) - return CMD_FAILURE; + return CMD_FAILURE; if (!lex_force_int_range (lexer, "FROM", a + 1, INT_MAX)) - return CMD_FAILURE; + return CMD_FAILURE; b = lex_integer (lexer); frac = 0; } diff --git a/src/language/commands/save-translate.c b/src/language/commands/save-translate.c index 0bf0bcafeb..b4668aae4a 100644 --- a/src/language/commands/save-translate.c +++ b/src/language/commands/save-translate.c @@ -69,7 +69,7 @@ cmd_save_translate (struct lexer *lexer, struct dataset *ds) for (;;) { if (lex_match_id (lexer, "OUTFILE")) - { + { outfile_start = lex_ofs (lexer) - 1; if (handle != NULL) { @@ -77,13 +77,13 @@ cmd_save_translate (struct lexer *lexer, struct dataset *ds) goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - handle = fh_parse (lexer, FH_REF_FILE, NULL); - if (handle == NULL) - goto error; + handle = fh_parse (lexer, FH_REF_FILE, NULL); + if (handle == NULL) + goto error; outfile_end = lex_ofs (lexer) - 1; - } + } else if (lex_match_id (lexer, "TYPE")) { if (type != 0) diff --git a/src/language/commands/save.c b/src/language/commands/save.c index 8dbb6cd3d1..2bf1540234 100644 --- a/src/language/commands/save.c +++ b/src/language/commands/save.c @@ -155,7 +155,7 @@ parse_output_trns (struct lexer *lexer, struct dataset *ds, enum writer_type wri On failure, returns a null pointer. */ static struct casewriter * parse_write_command (struct lexer *lexer, struct dataset *ds, - enum writer_type writer_type, + enum writer_type writer_type, enum command_type command_type, bool *retain_unselected) { @@ -195,33 +195,33 @@ parse_write_command (struct lexer *lexer, struct dataset *ds, for (;;) { if (lex_match_id (lexer, "OUTFILE")) - { + { if (handle != NULL) { lex_sbc_only_once (lexer, "OUTFILE"); goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - handle = fh_parse (lexer, FH_REF_FILE, NULL); - if (handle == NULL) - goto error; - } + handle = fh_parse (lexer, FH_REF_FILE, NULL); + if (handle == NULL) + goto error; + } else if (lex_match_id (lexer, "METADATA")) - { + { if (metadata != NULL) { lex_sbc_only_once (lexer, "METADATA"); goto error; } - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); - metadata = fh_parse (lexer, FH_REF_FILE, NULL); - if (metadata == NULL) - goto error; - } + metadata = fh_parse (lexer, FH_REF_FILE, NULL); + if (metadata == NULL) + goto error; + } else if (lex_match_id (lexer, "NAMES")) { /* Not yet implemented. */ @@ -257,22 +257,22 @@ parse_write_command (struct lexer *lexer, struct dataset *ds, } else if (writer_type == SYSFILE_WRITER && lex_match_id (lexer, "COMPRESSED")) - sysfile_opts.compression = ANY_COMP_SIMPLE; + sysfile_opts.compression = ANY_COMP_SIMPLE; else if (writer_type == SYSFILE_WRITER && lex_match_id (lexer, "UNCOMPRESSED")) - sysfile_opts.compression = ANY_COMP_NONE; + sysfile_opts.compression = ANY_COMP_NONE; else if (writer_type == SYSFILE_WRITER && lex_match_id (lexer, "ZCOMPRESSED")) - sysfile_opts.compression = ANY_COMP_ZLIB; + sysfile_opts.compression = ANY_COMP_ZLIB; else if (writer_type == SYSFILE_WRITER && lex_match_id (lexer, "VERSION")) - { - lex_match (lexer, T_EQUALS); - if (!lex_force_int_range (lexer, "VERSION", 2, 3)) + { + lex_match (lexer, T_EQUALS); + if (!lex_force_int_range (lexer, "VERSION", 2, 3)) goto error; sysfile_opts.version = lex_integer (lexer); lex_get (lexer); - } + } else if (writer_type == PORFILE_WRITER && lex_match_id (lexer, "TYPE")) { lex_match (lexer, T_EQUALS); @@ -298,7 +298,7 @@ parse_write_command (struct lexer *lexer, struct dataset *ds, goto error; if (!lex_match (lexer, T_SLASH)) - break; + break; } if (lex_end_of_command (lexer) != CMD_SUCCESS) goto error; diff --git a/src/language/commands/select-if.c b/src/language/commands/select-if.c index 2648f9f0c8..98d2594e42 100644 --- a/src/language/commands/select-if.c +++ b/src/language/commands/select-if.c @@ -37,7 +37,7 @@ /* SELECT IF transformation. */ struct select_if_trns { - struct expression *e; /* Test expression. */ + struct expression *e; /* Test expression. */ }; static const struct trns_class select_if_trns_class; @@ -104,21 +104,21 @@ cmd_filter (struct lexer *lexer, struct dataset *ds) { struct variable *v = parse_variable (lexer, dict); if (!v) - return CMD_FAILURE; + return CMD_FAILURE; if (var_is_alpha (v)) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("The filter variable must be numeric.")); - return CMD_FAILURE; - } + return CMD_FAILURE; + } if (dict_class_from_id (var_get_name (v)) == DC_SCRATCH) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("The filter variable may not be scratch.")); - return CMD_FAILURE; - } + return CMD_FAILURE; + } dict_set_filter (dict, v); } diff --git a/src/language/commands/set.c b/src/language/commands/set.c index b05ce691b4..443862d831 100644 --- a/src/language/commands/set.c +++ b/src/language/commands/set.c @@ -659,7 +659,7 @@ parse_LENGTH (struct lexer *lexer) else { if (!lex_force_int_range (lexer, "LENGTH", 1, INT_MAX)) - return false; + return false; page_length = lex_integer (lexer); lex_get (lexer); } @@ -928,7 +928,7 @@ parse_SEED (struct lexer *lexer) else { if (!lex_force_num (lexer)) - return false; + return false; set_rng (lex_number (lexer)); lex_get (lexer); } @@ -1169,7 +1169,7 @@ parse_WIDTH (struct lexer *lexer) else { if (!lex_force_int_range (lexer, "WIDTH", 40, INT_MAX)) - return false; + return false; settings_set_viewwidth (lex_integer (lexer)); lex_get (lexer); } diff --git a/src/language/commands/sign.c b/src/language/commands/sign.c index d4de1a9721..bba46b0116 100644 --- a/src/language/commands/sign.c +++ b/src/language/commands/sign.c @@ -60,8 +60,8 @@ add_pair_leaf (struct pivot_dimension *dimension, variable_pair *pair) static void output_frequency_table (const struct two_sample_test *t2s, - const struct sign_test_params *param, - const struct dictionary *dict) + const struct sign_test_params *param, + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create (N_("Frequencies")); pivot_table_set_weight_var (table, dict_get_weight (dict)); @@ -95,7 +95,7 @@ output_frequency_table (const struct two_sample_test *t2s, static void output_statistics_table (const struct two_sample_test *t2s, - const struct sign_test_params *param) + const struct sign_test_params *param) { struct pivot_table *table = pivot_table_create (N_("Test Statistics")); @@ -126,11 +126,11 @@ output_statistics_table (const struct two_sample_test *t2s, void sign_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact UNUSED, - double timer UNUSED) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact UNUSED, + double timer UNUSED) { int i; bool warn = true; @@ -147,25 +147,25 @@ sign_execute (const struct dataset *ds, const double weight = dict_get_case_weight (dict, c, &warn); for (i = 0 ; i < t2s->n_pairs; ++i) - { - variable_pair *vp = &t2s->pairs[i]; - const union value *value0 = case_data (c, (*vp)[0]); - const union value *value1 = case_data (c, (*vp)[1]); - const double diff = value0->f - value1->f; - - if (var_is_value_missing ((*vp)[0], value0) & exclude) - continue; - - if (var_is_value_missing ((*vp)[1], value1) & exclude) - continue; - - if (diff > 0) - stp[i].pos += weight; - else if (diff < 0) - stp[i].neg += weight; - else - stp[i].ties += weight; - } + { + variable_pair *vp = &t2s->pairs[i]; + const union value *value0 = case_data (c, (*vp)[0]); + const union value *value1 = case_data (c, (*vp)[1]); + const double diff = value0->f - value1->f; + + if (var_is_value_missing ((*vp)[0], value0) & exclude) + continue; + + if (var_is_value_missing ((*vp)[1], value1) & exclude) + continue; + + if (diff > 0) + stp[i].pos += weight; + else if (diff < 0) + stp[i].neg += weight; + else + stp[i].ties += weight; + } } casereader_destroy (r); @@ -174,11 +174,11 @@ sign_execute (const struct dataset *ds, { int r = MIN (stp[i].pos, stp[i].neg); stp[i].one_tailed_sig = gsl_cdf_binomial_P (r, - 0.5, - stp[i].pos + stp[i].neg); + 0.5, + stp[i].pos + stp[i].neg); stp[i].point_prob = gsl_ran_binomial_pdf (r, 0.5, - stp[i].pos + stp[i].neg); + stp[i].pos + stp[i].neg); } output_frequency_table (t2s, stp, dict); diff --git a/src/language/commands/sign.h b/src/language/commands/sign.h index d23b8351ae..25f0b90dec 100644 --- a/src/language/commands/sign.h +++ b/src/language/commands/sign.h @@ -26,10 +26,10 @@ struct dataset; struct npar_test; void sign_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer); #endif diff --git a/src/language/commands/sort-criteria.c b/src/language/commands/sort-criteria.c index 4f33fb390d..72d77ae61b 100644 --- a/src/language/commands/sort-criteria.c +++ b/src/language/commands/sort-criteria.c @@ -64,21 +64,21 @@ parse_sort_criteria (struct lexer *lexer, const struct dictionary *dict, /* Sort direction. */ enum subcase_direction direction; if (lex_match (lexer, T_LPAREN)) - { - if (lex_match_id (lexer, "D") || lex_match_id (lexer, "DOWN")) - direction = SC_DESCEND; - else if (lex_match_id (lexer, "A") || lex_match_id (lexer, "UP")) + { + if (lex_match_id (lexer, "D") || lex_match_id (lexer, "DOWN")) + direction = SC_DESCEND; + else if (lex_match_id (lexer, "A") || lex_match_id (lexer, "UP")) direction = SC_ASCEND; else - { + { lex_error_expecting (lexer, "A", "D"); goto error; - } - if (!lex_force_match (lexer, T_RPAREN)) + } + if (!lex_force_match (lexer, T_RPAREN)) goto error; if (saw_direction != NULL) *saw_direction = true; - } + } else direction = SC_ASCEND; diff --git a/src/language/commands/split-file.c b/src/language/commands/split-file.c index eea3cd510a..323d623485 100644 --- a/src/language/commands/split-file.c +++ b/src/language/commands/split-file.c @@ -58,7 +58,7 @@ cmd_split_file (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_BY); int vars_start = lex_ofs (lexer); if (!parse_variables (lexer, dataset_dict (ds), &v, &n, PV_NO_DUPLICATE)) - return CMD_CASCADING_FAILURE; + return CMD_CASCADING_FAILURE; int vars_end = lex_ofs (lexer) - 1; if (n > MAX_SPLITS) diff --git a/src/language/commands/sys-file-info.c b/src/language/commands/sys-file-info.c index 6611dcd957..3b905950d4 100644 --- a/src/language/commands/sys-file-info.c +++ b/src/language/commands/sys-file-info.c @@ -120,17 +120,17 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "FILE") || lex_is_string (lexer)) - { - lex_match (lexer, T_EQUALS); + { + lex_match (lexer, T_EQUALS); fh_unref (h); - h = fh_parse (lexer, FH_REF_FILE, NULL); - if (h == NULL) + h = fh_parse (lexer, FH_REF_FILE, NULL); + if (h == NULL) goto error; - } + } else if (lex_match_id (lexer, "ENCODING")) { - lex_match (lexer, T_EQUALS); + lex_match (lexer, T_EQUALS); if (!lex_force_string (lexer)) goto error; @@ -288,7 +288,7 @@ cmd_display (struct lexer *lexer, struct dataset *ds) else if (lex_match_id (lexer, "FILE")) { if (!lex_force_match_id (lexer, "LABEL")) - return CMD_FAILURE; + return CMD_FAILURE; const char *label = dict_get_label (dataset_dict (ds)); @@ -307,10 +307,10 @@ cmd_display (struct lexer *lexer, struct dataset *ds) bool sorted = lex_match_id (lexer, "SORTED"); if (lex_match_id (lexer, "VECTORS")) - { - display_vectors (dataset_dict(ds), sorted); - return CMD_SUCCESS; - } + { + display_vectors (dataset_dict(ds), sorted); + return CMD_SUCCESS; + } else if (lex_match_id (lexer, "SCRATCH")) { dict_get_vars (dataset_dict (ds), &vl, &n, DC_ORDINARY); diff --git a/src/language/commands/t-test-indep.c b/src/language/commands/t-test-indep.c index 3bfc7775cc..44e14a8e40 100644 --- a/src/language/commands/t-test-indep.c +++ b/src/language/commands/t-test-indep.c @@ -74,9 +74,9 @@ which_group (const union value *v, const struct indep_samples *is) void indep_run (struct tt *tt, const struct variable *gvar, - bool cut, - const union value *gval0, const union value *gval1, - struct casereader *reader) + bool cut, + const union value *gval0, const union value *gval1, + struct casereader *reader) { struct indep_samples is; struct ccase *c; @@ -107,17 +107,17 @@ indep_run (struct tt *tt, const struct variable *gvar, int grp = which_group (gv, &is); if (grp < 0) - continue; + continue; for (v = 0; v < tt->n_vars; ++v) - { - const union value *val = case_data (c, tt->vars[v]); - if (var_is_value_missing (tt->vars[v], val) & tt->exclude) - continue; - - moments_pass_one (ps[v].mom[grp], val->f, w); - levene_pass_one (ps[v].nl, val->f, w, gv); - } + { + const union value *val = case_data (c, tt->vars[v]); + if (var_is_value_missing (tt->vars[v], val) & tt->exclude) + continue; + + moments_pass_one (ps[v].mom[grp], val->f, w); + levene_pass_one (ps[v].nl, val->f, w, gv); + } } casereader_destroy (r); @@ -130,17 +130,17 @@ indep_run (struct tt *tt, const struct variable *gvar, int grp = which_group (gv, &is); if (grp < 0) - continue; + continue; for (v = 0; v < tt->n_vars; ++v) - { - const union value *val = case_data (c, tt->vars[v]); - if (var_is_value_missing (tt->vars[v], val) & tt->exclude) - continue; - - moments_pass_two (ps[v].mom[grp], val->f, w); - levene_pass_two (ps[v].nl, val->f, w, gv); - } + { + const union value *val = case_data (c, tt->vars[v]); + if (var_is_value_missing (tt->vars[v], val) & tt->exclude) + continue; + + moments_pass_two (ps[v].mom[grp], val->f, w); + levene_pass_two (ps[v].nl, val->f, w, gv); + } } casereader_destroy (r); @@ -153,16 +153,16 @@ indep_run (struct tt *tt, const struct variable *gvar, int grp = which_group (gv, &is); if (grp < 0) - continue; + continue; for (v = 0; v < tt->n_vars; ++v) - { - const union value *val = case_data (c, tt->vars[v]); - if (var_is_value_missing (tt->vars[v], val) & tt->exclude) - continue; + { + const union value *val = case_data (c, tt->vars[v]); + if (var_is_value_missing (tt->vars[v], val) & tt->exclude) + continue; - levene_pass_three (ps[v].nl, val->f, w, gv); - } + levene_pass_three (ps[v].nl, val->f, w, gv); + } } casereader_destroy (r); @@ -234,15 +234,15 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_ dep_vars->root, pivot_value_new_variable (var)); for (int i = 0 ; i < 2; ++i) - { - double cc, mean, sigma; - moments_calculate (ps[v].mom[i], &cc, &mean, &sigma, NULL, NULL); + { + double cc, mean, sigma; + moments_calculate (ps[v].mom[i], &cc, &mean, &sigma, NULL, NULL); double entries[] = { cc, mean, sqrt (sigma), sqrt (sigma / cc) }; for (size_t j = 0; j < sizeof entries / sizeof *entries; j++) pivot_table_put3 (table, j, i, dep_var_idx, pivot_value_new_number (entries[j])); - } + } } pivot_table_submit (table); diff --git a/src/language/commands/t-test-one-sample.c b/src/language/commands/t-test-one-sample.c index 14eca1b11c..f1fc0df6bf 100644 --- a/src/language/commands/t-test-one-sample.c +++ b/src/language/commands/t-test-one-sample.c @@ -173,13 +173,13 @@ one_sample_run (const struct tt *tt, double testval, struct casereader *reader) for (size_t i = 0; i < os.n_stats; i++) { const struct per_var_stats *per_var_stats = &os.stats[i]; - const struct variable *var = per_var_stats->var; - const union value *val = case_data (c, var); - if (var_is_value_missing (var, val) & tt->exclude) - continue; + const struct variable *var = per_var_stats->var; + const union value *val = case_data (c, var); + if (var_is_value_missing (var, val) & tt->exclude) + continue; - moments_pass_one (per_var_stats->mom, val->f, w); - } + moments_pass_one (per_var_stats->mom, val->f, w); + } } casereader_destroy (r); @@ -190,14 +190,14 @@ one_sample_run (const struct tt *tt, double testval, struct casereader *reader) for (size_t i = 0; i < os.n_stats; i++) { struct per_var_stats *per_var_stats = &os.stats[i]; - const struct variable *var = per_var_stats->var; - const union value *val = case_data (c, var); - if (var_is_value_missing (var, val) & tt->exclude) - continue; - - moments_pass_two (per_var_stats->mom, val->f, w); - per_var_stats->sum_diff += w * (val->f - os.testval); - } + const struct variable *var = per_var_stats->var; + const union value *val = case_data (c, var); + if (var_is_value_missing (var, val) & tt->exclude) + continue; + + moments_pass_two (per_var_stats->mom, val->f, w); + per_var_stats->sum_diff += w * (val->f - os.testval); + } } casereader_destroy (r); diff --git a/src/language/commands/t-test-paired.c b/src/language/commands/t-test-paired.c index 9ec459eead..df897380e6 100644 --- a/src/language/commands/t-test-paired.c +++ b/src/language/commands/t-test-paired.c @@ -83,20 +83,20 @@ paired_run (const struct tt *tt, size_t n_pairs, vp *pairs, struct casereader *r double w = dict_get_case_weight (tt->dict, c, NULL); for (int i = 0; i < ps.n_ps; i++) - { + { struct pair_stats *pp = &ps.ps[i]; - const union value *val0 = case_data (c, pp->var0); - const union value *val1 = case_data (c, pp->var1); + const union value *val0 = case_data (c, pp->var0); + const union value *val1 = case_data (c, pp->var1); if (var_is_value_missing (pp->var0, val0) & tt->exclude) - continue; + continue; if (var_is_value_missing (pp->var1, val1) & tt->exclude) - continue; + continue; - moments_pass_one (pp->mom0, val0->f, w); - moments_pass_one (pp->mom1, val1->f, w); - moments_pass_one (pp->mom_diff, val0->f - val1->f, w); - } + moments_pass_one (pp->mom0, val0->f, w); + moments_pass_one (pp->mom1, val1->f, w); + moments_pass_one (pp->mom_diff, val0->f - val1->f, w); + } } casereader_destroy (r); @@ -106,21 +106,21 @@ paired_run (const struct tt *tt, size_t n_pairs, vp *pairs, struct casereader *r double w = dict_get_case_weight (tt->dict, c, NULL); for (int i = 0; i < ps.n_ps; i++) - { + { struct pair_stats *pp = &ps.ps[i]; - const union value *val0 = case_data (c, pp->var0); - const union value *val1 = case_data (c, pp->var1); + const union value *val0 = case_data (c, pp->var0); + const union value *val1 = case_data (c, pp->var1); if (var_is_value_missing (pp->var0, val0) & tt->exclude) - continue; + continue; if (var_is_value_missing (pp->var1, val1) & tt->exclude) - continue; + continue; - moments_pass_two (pp->mom0, val0->f, w); - moments_pass_two (pp->mom1, val1->f, w); - moments_pass_two (pp->mom_diff, val0->f - val1->f, w); - pp->sum_of_prod += val0->f * val1->f * w; - } + moments_pass_two (pp->mom0, val0->f, w); + moments_pass_two (pp->mom1, val1->f, w); + moments_pass_two (pp->mom_diff, val0->f - val1->f, w); + pp->sum_of_prod += val0->f * val1->f * w; + } } casereader_destroy (r); diff --git a/src/language/commands/t-test.h b/src/language/commands/t-test.h index 2b4dba445a..4ed0bf688e 100644 --- a/src/language/commands/t-test.h +++ b/src/language/commands/t-test.h @@ -53,9 +53,9 @@ union value; void one_sample_run (const struct tt *tt, double testval, struct casereader *reader); void paired_run (const struct tt *tt, size_t n_pairs, vp *pairs, struct casereader *reader); void indep_run (struct tt *tt, const struct variable *gvar, - bool cut, - const union value *gval0, const union value *gval1, - struct casereader *reader); + bool cut, + const union value *gval0, const union value *gval1, + struct casereader *reader); #endif diff --git a/src/language/commands/trim.c b/src/language/commands/trim.c index 5828321f8c..ca1b4c16a0 100644 --- a/src/language/commands/trim.c +++ b/src/language/commands/trim.c @@ -98,7 +98,7 @@ parse_dict_rename (struct lexer *lexer, struct dictionary *dict) goto done; if (n_new_vars != n_old_vars) - { + { size_t added_old = n_old_vars - prev_n_old; size_t added_new = n_new_vars - prev_n_new; @@ -112,8 +112,8 @@ parse_dict_rename (struct lexer *lexer, struct dictionary *dict) "There are %zu new variable names.", added_new), added_new); - goto done; - } + goto done; + } } int end_ofs = lex_ofs (lexer) - 1; diff --git a/src/language/commands/value-labels.c b/src/language/commands/value-labels.c index 235c57273b..b8e619d89c 100644 --- a/src/language/commands/value-labels.c +++ b/src/language/commands/value-labels.c @@ -39,7 +39,7 @@ /* Declarations. */ static int do_value_labels (struct lexer *, - const struct dictionary *dict, bool); + const struct dictionary *dict, bool); static void erase_labels (struct variable **vars, size_t n_vars); static int get_label (struct lexer *, struct variable **vars, size_t n_vars, const char *dict_encoding); @@ -72,23 +72,23 @@ do_value_labels (struct lexer *lexer, const struct dictionary *dict, bool erase) while (lex_token (lexer) != T_ENDCMD) { parse_err = !parse_variables (lexer, dict, &vars, &n_vars, - PV_SAME_WIDTH); + PV_SAME_WIDTH); if (n_vars < 1) - { - free(vars); - return CMD_FAILURE; - } + { + free(vars); + return CMD_FAILURE; + } if (erase) erase_labels (vars, n_vars); while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD) - if (!get_label (lexer, vars, n_vars, dict_get_encoding (dict))) + if (!get_label (lexer, vars, n_vars, dict_get_encoding (dict))) goto lossage; if (lex_token (lexer) != T_SLASH) - { + { free (vars); break; - } + } lex_get (lexer); @@ -148,12 +148,12 @@ get_label (struct lexer *lexer, struct variable **vars, size_t n_vars, trunc_len = utf8_encoding_trunc_len (ds_cstr (&label), dict_encoding, MAX_LABEL_LEN); if (ds_length (&label) > trunc_len) - { - lex_next_msg (lexer, SW, 0, 0, + { + lex_next_msg (lexer, SW, 0, 0, _("Truncating value label to %d bytes."), MAX_LABEL_LEN); - ds_truncate (&label, trunc_len); - } + ds_truncate (&label, trunc_len); + } for (i = 0; i < n_vars; i++) var_replace_value_label (vars[i], &value, ds_cstr (&label)); diff --git a/src/language/commands/variable-display.c b/src/language/commands/variable-display.c index 98fadb2a56..7b1c60b451 100644 --- a/src/language/commands/variable-display.c +++ b/src/language/commands/variable-display.c @@ -67,7 +67,7 @@ cmd_variable_alignment (struct lexer *lexer, struct dataset *ds) var_set_alignment (v[i], align); while (lex_token (lexer) == T_SLASH) - lex_get (lexer); + lex_get (lexer); free (v); continue; @@ -103,7 +103,7 @@ cmd_variable_width (struct lexer *lexer, struct dataset *ds) var_set_display_width (v[i], width); while (lex_token (lexer) == T_SLASH) - lex_get (lexer); + lex_get (lexer); free (v); continue; @@ -147,10 +147,10 @@ cmd_variable_level (struct lexer *lexer, struct dataset *ds) goto error; for (size_t i = 0; i < nv; ++i) - var_set_measure (v[i], level); + var_set_measure (v[i], level); while (lex_token (lexer) == T_SLASH) - lex_get (lexer); + lex_get (lexer); free (v); continue; @@ -196,7 +196,7 @@ cmd_variable_role (struct lexer *lexer, struct dataset *ds) return CMD_FAILURE; for (size_t i = 0; i < nv; i++) - var_set_role (v[i], role); + var_set_role (v[i], role); free (v); } diff --git a/src/language/commands/variable-label.c b/src/language/commands/variable-label.c index c4e0df69fe..ad09215c9a 100644 --- a/src/language/commands/variable-label.c +++ b/src/language/commands/variable-label.c @@ -48,17 +48,17 @@ cmd_variable_labels (struct lexer *lexer, struct dataset *ds) return CMD_FAILURE; if (!lex_force_string (lexer)) - { - free (v); - return CMD_FAILURE; - } + { + free (v); + return CMD_FAILURE; + } for (i = 0; i < nv; i++) var_set_label (v[i], lex_tokcstr (lexer)); lex_get (lexer); while (lex_token (lexer) == T_SLASH) - lex_get (lexer); + lex_get (lexer); free (v); } while (lex_token (lexer) != T_ENDCMD); diff --git a/src/language/commands/vector.c b/src/language/commands/vector.c index cece0afb38..0a543136b5 100644 --- a/src/language/commands/vector.c +++ b/src/language/commands/vector.c @@ -57,7 +57,7 @@ cmd_vector (struct lexer *lexer, struct dataset *ds) size_t n_vectors = 0; size_t allocated_vectors = 0; while (lex_token (lexer) == T_ID) - { + { char *error = dict_id_is_valid__ (dict, lex_tokcstr (lexer), DC_ORDINARY | DC_SCRATCH); if (error) @@ -67,54 +67,54 @@ cmd_vector (struct lexer *lexer, struct dataset *ds) goto error; } - if (dict_lookup_vector (dict, lex_tokcstr (lexer))) - { - lex_next_error (lexer, 0, 0, + if (dict_lookup_vector (dict, lex_tokcstr (lexer))) + { + lex_next_error (lexer, 0, 0, _("A vector named %s already exists."), lex_tokcstr (lexer)); - goto error; - } + goto error; + } for (size_t i = 0; i < n_vectors; i++) if (!utf8_strcasecmp (vectors[i], lex_tokcstr (lexer))) - { - lex_ofs_error (lexer, vectors_start, lex_ofs (lexer), + { + lex_ofs_error (lexer, vectors_start, lex_ofs (lexer), _("Vector name %s is given twice."), lex_tokcstr (lexer)); - goto error; - } + goto error; + } if (n_vectors == allocated_vectors) vectors = pool_2nrealloc (pool, vectors, &allocated_vectors, sizeof *vectors); vectors[n_vectors++] = pool_strdup (pool, lex_tokcstr (lexer)); - lex_get (lexer); - lex_match (lexer, T_COMMA); - } + lex_get (lexer); + lex_match (lexer, T_COMMA); + } /* Now that we have the names it's time to check for the short or long forms. */ if (lex_match (lexer, T_EQUALS)) - { - if (n_vectors > 1) - { - lex_ofs_error (lexer, vectors_start, lex_ofs (lexer) - 1, + { + if (n_vectors > 1) + { + lex_ofs_error (lexer, vectors_start, lex_ofs (lexer) - 1, _("Only a single vector name may be specified " "when a list of variables is given.")); - goto error; - } + goto error; + } struct variable **v; size_t nv; - if (!parse_variables_pool (lexer, pool, dict, &v, &nv, + if (!parse_variables_pool (lexer, pool, dict, &v, &nv, PV_SAME_WIDTH | PV_DUPLICATE)) - goto error; + goto error; dict_create_vector (dict, vectors[0], v, nv); - } + } else if (lex_match (lexer, T_LPAREN)) - { + { struct fmt_spec format = fmt_for_output (FMT_F, 8, 2); bool seen_format = false; size_t n_vars = 0; @@ -170,7 +170,7 @@ cmd_vector (struct lexer *lexer, struct dataset *ds) goto error; } - /* Check that none of the variables exist and that their names are + /* Check that none of the variables exist and that their names are not excessively long. */ struct string_set new_names = STRING_SET_INITIALIZER (new_names); for (size_t i = 0; i < n_vectors; i++) @@ -208,26 +208,26 @@ cmd_vector (struct lexer *lexer, struct dataset *ds) } string_set_destroy (&new_names); - /* Finally create the variables and vectors. */ + /* Finally create the variables and vectors. */ struct variable **vars = pool_nmalloc (pool, n_vars, sizeof *vars); for (size_t i = 0; i < n_vectors; i++) - { - for (size_t j = 0; j < n_vars; j++) - { + { + for (size_t j = 0; j < n_vars; j++) + { char *name = xasprintf ("%s%zu", vectors[i], j + 1); - vars[j] = dict_create_var_assert (dict, name, + vars[j] = dict_create_var_assert (dict, name, fmt_var_width (format)); var_set_both_formats (vars[j], format); free (name); - } + } dict_create_vector_assert (dict, vectors[i], vars, n_vars); - } - } + } + } else - { + { lex_error_expecting (lexer, "`='", "`('"); - goto error; - } + goto error; + } } while (lex_match (lexer, T_SLASH)); diff --git a/src/language/commands/weight.c b/src/language/commands/weight.c index d99c2acb0c..473da37266 100644 --- a/src/language/commands/weight.c +++ b/src/language/commands/weight.c @@ -43,19 +43,19 @@ cmd_weight (struct lexer *lexer, struct dataset *ds) lex_match (lexer, T_BY); v = parse_variable (lexer, dict); if (!v) - return CMD_CASCADING_FAILURE; + return CMD_CASCADING_FAILURE; if (var_is_alpha (v)) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("The weighting variable must be numeric.")); - return CMD_CASCADING_FAILURE; - } + return CMD_CASCADING_FAILURE; + } if (dict_class_from_id (var_get_name (v)) == DC_SCRATCH) - { - lex_next_error (lexer, -1, -1, + { + lex_next_error (lexer, -1, -1, _("The weighting variable may not be scratch.")); - return CMD_CASCADING_FAILURE; - } + return CMD_CASCADING_FAILURE; + } dict_set_weight (dict, v); } diff --git a/src/language/commands/wilcoxon.c b/src/language/commands/wilcoxon.c index 363d86510c..d5e8b226cc 100644 --- a/src/language/commands/wilcoxon.c +++ b/src/language/commands/wilcoxon.c @@ -53,12 +53,12 @@ append_difference (const struct ccase *c, casenumber n UNUSED, void *aux) } static void show_ranks_box (const struct wilcoxon_state *, - const struct two_sample_test *, - const struct dictionary *); + const struct two_sample_test *, + const struct dictionary *); static void show_tests_box (const struct wilcoxon_state *, - const struct two_sample_test *, - bool exact, double timer); + const struct two_sample_test *, + bool exact, double timer); @@ -74,11 +74,11 @@ distinct_callback (double v UNUSED, casenumber n, double w UNUSED, void *aux) void wilcoxon_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer) + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer) { int i; bool warn = true; @@ -112,41 +112,41 @@ wilcoxon_execute (const struct dataset *ds, ws[i].weight = dict_create_var (ws[i].dict, "weight", 0); r = casereader_create_filter_missing (r, *vp, 2, - exclude, - NULL, NULL); + exclude, + NULL, NULL); subcase_init_var (&ordering, ws[i].absdiff, SC_ASCEND); writer = sort_create_writer (&ordering, proto); subcase_uninit (&ordering); for (; (c = casereader_read (r)) != NULL; case_unref (c)) - { - struct ccase *output = case_create (proto); - double d = append_difference (c, 0, vp); + { + struct ccase *output = case_create (proto); + double d = append_difference (c, 0, vp); - if (d > 0) + if (d > 0) *case_num_rw (output, ws[i].sign) = 1.0; - else if (d < 0) + else if (d < 0) *case_num_rw (output, ws[i].sign) = -1.0; - else - { - double w = 1.0; - if (weight) - w = case_num (c, weight); - - /* Central point values should be dropped */ - ws[i].n_zeros += w; + else + { + double w = 1.0; + if (weight) + w = case_num (c, weight); + + /* Central point values should be dropped */ + ws[i].n_zeros += w; case_unref (output); continue; - } + } - *case_num_rw (output, ws[i].absdiff) = fabs (d); + *case_num_rw (output, ws[i].absdiff) = fabs (d); - if (weight) - *case_num_rw (output, ws[i].weight) = case_num (c, weight); + if (weight) + *case_num_rw (output, ws[i].weight) = case_num (c, weight); - casewriter_write (writer, output); - } + casewriter_write (writer, output); + } casereader_destroy (r); ws[i].reader = casewriter_make_reader (writer); } @@ -159,29 +159,29 @@ wilcoxon_execute (const struct dataset *ds, enum rank_error err = 0; rr = casereader_create_append_rank (ws[i].reader, ws[i].absdiff, - weight ? ws[i].weight : NULL, &err, - distinct_callback, &ws[i] - ); + weight ? ws[i].weight : NULL, &err, + distinct_callback, &ws[i] + ); for (; (c = casereader_read (rr)) != NULL; case_unref (c)) - { - double sign = case_num (c, ws[i].sign); - double rank = case_num_idx (c, weight ? 3 : 2); - double w = weight ? case_num (c, ws[i].weight) : 1.0; - - if (sign > 0) - { - ws[i].positives.sum += rank * w; - ws[i].positives.n += w; - } - else if (sign < 0) - { - ws[i].negatives.sum += rank * w; - ws[i].negatives.n += w; - } - else - NOT_REACHED (); - } + { + double sign = case_num (c, ws[i].sign); + double rank = case_num_idx (c, weight ? 3 : 2); + double w = weight ? case_num (c, ws[i].weight) : 1.0; + + if (sign > 0) + { + ws[i].positives.sum += rank * w; + ws[i].positives.n += w; + } + else if (sign < 0) + { + ws[i].negatives.sum += rank * w; + ws[i].negatives.n += w; + } + else + NOT_REACHED (); + } casereader_destroy (rr); } @@ -223,8 +223,8 @@ add_pair_leaf (struct pivot_dimension *dimension, variable_pair *pair) static void show_ranks_box (const struct wilcoxon_state *ws, - const struct two_sample_test *t2s, - const struct dictionary *dict) + const struct two_sample_test *t2s, + const struct dictionary *dict) { struct pivot_table *table = pivot_table_create (N_("Ranks")); pivot_table_set_weight_var (table, dict_get_weight (dict)); @@ -260,10 +260,10 @@ show_ranks_box (const struct wilcoxon_state *ws, static void show_tests_box (const struct wilcoxon_state *ws, - const struct two_sample_test *t2s, - bool exact, - double timer UNUSED - ) + const struct two_sample_test *t2s, + bool exact, + double timer UNUSED + ) { struct pivot_table *table = pivot_table_create (N_("Test Statistics")); @@ -301,14 +301,14 @@ show_tests_box (const struct wilcoxon_state *ws, int footnote_idx = -1; if (exact) - { - double p = LevelOfSignificanceWXMPSR (ws[i].positives.sum, n); - if (p < 0) - { + { + double p = LevelOfSignificanceWXMPSR (ws[i].positives.sum, n); + if (p < 0) + { footnote_idx = n_entries; entries[n_entries++] = SYSMIS; - } - else + } + else { entries[n_entries++] = p; entries[n_entries++] = p / 2.0; diff --git a/src/language/commands/wilcoxon.h b/src/language/commands/wilcoxon.h index a155b9e946..e8817dced9 100644 --- a/src/language/commands/wilcoxon.h +++ b/src/language/commands/wilcoxon.h @@ -56,12 +56,12 @@ struct dataset; void wilcoxon_execute (const struct dataset *ds, - struct casereader *input, - enum mv_class exclude, - const struct npar_test *test, - bool exact, - double timer - ); + struct casereader *input, + enum mv_class exclude, + const struct npar_test *test, + bool exact, + double timer + ); diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index 8719e5e950..38b888eeb1 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -54,7 +54,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, { assert (op < e->ops + e->n_ops); switch (op++->operation) - { + { case OP_number: case OP_boolean: *ns++ = op++->number; @@ -77,9 +77,9 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, #include "evaluate.inc" - default: - NOT_REACHED (); - } + default: + NOT_REACHED (); + } } } @@ -180,11 +180,11 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED) goto done; } - if (ds == NULL) - { - ds = dataset_create (NULL, ""); - d = dataset_dict (ds); - } + if (ds == NULL) + { + ds = dataset_create (NULL, ""); + d = dataset_dict (ds); + } v = dict_create_var (d, name, width); if (v == NULL) diff --git a/src/language/expressions/optimize.c b/src/language/expressions/optimize.c index d893d1e995..0e8b823254 100644 --- a/src/language/expressions/optimize.c +++ b/src/language/expressions/optimize.c @@ -57,13 +57,13 @@ expr_optimize (struct expr_node *node, struct expression *e) { node->args[i] = expr_optimize (node->args[i], e); if (node->args[i]->type == OP_number) - { - if (node->args[i]->number == SYSMIS) - n_sysmis++; - } + { + if (node->args[i]->number == SYSMIS) + n_sysmis++; + } if (!is_atom (node->args[i]->type)) - n_nonconst++; + n_nonconst++; } op = &operations[node->type]; diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 72d706cc79..7f618b23f4 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -309,13 +309,13 @@ type_check (const struct expression *e, const struct expr_node *n, { case VAL_NUMERIC: if (actual_type != OP_number && actual_type != OP_boolean) - { - msg_at (SE, expr_location (e, n), + { + msg_at (SE, expr_location (e, n), _("Type mismatch: expression has type '%s', " "but a numeric value is required."), atom_type_name (actual_type)); - return false; - } + return false; + } break; case VAL_STRING: @@ -981,15 +981,15 @@ parse_primary__ (struct lexer *lexer, struct expression *e) ss_length (lex_tokss (lexer)), e->expr_pool); node = expr_allocate_string (e, ss_cstr (s)); - lex_get (lexer); - return node; + lex_get (lexer); + return node; } case T_LPAREN: { lex_get (lexer); struct expr_node *node = parse_or (lexer, e); - return !node || !lex_force_match (lexer, T_RPAREN) ? NULL : node; + return !node || !lex_force_match (lexer, T_RPAREN) ? NULL : node; } default: diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index 3d65d59661..dec38d25a4 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -872,13 +872,13 @@ lex_force_match (struct lexer *lexer, enum token_type type) { const char *type_string = token_type_to_string (type); if (type_string) - { - char *s = xasprintf ("`%s'", type_string); - lex_error_expecting (lexer, s); - free (s); - } + { + char *s = xasprintf ("`%s'", type_string); + lex_error_expecting (lexer, s); + free (s); + } else - lex_error_expecting (lexer, token_type_to_name (type)); + lex_error_expecting (lexer, token_type_to_name (type)); return false; } diff --git a/src/language/lexer/variable-parser.c b/src/language/lexer/variable-parser.c index 02bfcc9dfd..3b3b46e673 100644 --- a/src/language/lexer/variable-parser.c +++ b/src/language/lexer/variable-parser.c @@ -48,9 +48,9 @@ static struct variable *var_set_get_var (const struct var_set *, size_t); static struct variable *var_set_lookup_var (const struct var_set *, - const char *); + const char *); static bool var_set_lookup_var_idx (const struct var_set *, const char *, - size_t *); + size_t *); static bool var_set_get_names_must_be_ids (const struct var_set *); static bool @@ -156,8 +156,8 @@ parse_variables (struct lexer *lexer, const struct dictionary *d, allocations are taken from the given POOL. */ bool parse_variables_pool (struct lexer *lexer, struct pool *pool, - const struct dictionary *dict, - struct variable ***vars, size_t *n_vars, int opts) + const struct dictionary *dict, + struct variable ***vars, size_t *n_vars, int opts) { int retval; @@ -558,8 +558,8 @@ parse_DATA_LIST_vars (struct lexer *lexer, const struct dictionary *dict, if (!name1) goto exit; if (lex_match (lexer, T_TO)) - { - unsigned long int num1, num2; + { + unsigned long int num1, num2; int n_digits1, n_digits2; int root_len1, root_len2; unsigned long int number; @@ -577,23 +577,23 @@ parse_DATA_LIST_vars (struct lexer *lexer, const struct dictionary *dict, root_len2 = extract_numeric_suffix (lexer, end_ofs, name2, &num2, &n_digits2); if (root_len2 == 0) - goto exit; + goto exit; - if (root_len1 != root_len2 || memcasecmp (name1, name2, root_len1)) - { - lex_ofs_error (lexer, start_ofs, end_ofs, + if (root_len1 != root_len2 || memcasecmp (name1, name2, root_len1)) + { + lex_ofs_error (lexer, start_ofs, end_ofs, _("Prefixes don't match in use of TO convention.")); - goto exit; - } - if (num1 > num2) - { - lex_ofs_error (lexer, start_ofs, end_ofs, + goto exit; + } + if (num1 > num2) + { + lex_ofs_error (lexer, start_ofs, end_ofs, _("Bad bounds in use of TO convention.")); - goto exit; - } + goto exit; + } - for (number = num1; number <= num2; number++) - { + for (number = num1; number <= num2; number++) + { char *name = xasprintf ("%.*s%0*lu", root_len1, name1, n_digits1, number); @@ -604,26 +604,26 @@ parse_DATA_LIST_vars (struct lexer *lexer, const struct dictionary *dict, free (name); goto exit; } - } + } free (name1); name1 = NULL; free (name2); name2 = NULL; - } + } else - { + { if (!add_var_name (lexer, start_ofs, start_ofs, name1, &names, &n_vars, &allocated_vars, &set, pv_opts)) goto exit; name1 = NULL; - } + } lex_match (lexer, T_COMMA); if (pv_opts & PV_SINGLE) - break; + break; } while (lex_token (lexer) == T_ID); ok = true; @@ -639,7 +639,7 @@ exit: { int i; for (i = 0; i < n_vars; i++) - free (names[i]); + free (names[i]); free (names); *namesp = NULL; *n_varsp = 0; @@ -690,7 +690,7 @@ parse_DATA_LIST_vars_pool (struct lexer *lexer, const struct dictionary *dict, parse_DATA_LIST_vars(). */ bool parse_mixed_vars (struct lexer *lexer, const struct dictionary *dict, - char ***names, size_t *nnames, int pv_opts) + char ***names, size_t *nnames, int pv_opts) { size_t i; @@ -705,20 +705,20 @@ parse_mixed_vars (struct lexer *lexer, const struct dictionary *dict, while (is_dict_name_token (lexer, dict) || lex_token (lexer) == T_ALL) { if (lex_token (lexer) == T_ALL || dict_lookup_var (dict, lex_tokcstr (lexer)) != NULL) - { - struct variable **v; - size_t nv; - - if (!parse_variables (lexer, dict, &v, &nv, pv_opts)) - goto fail; - *names = xnrealloc (*names, *nnames + nv, sizeof **names); - for (i = 0; i < nv; i++) - (*names)[*nnames + i] = xstrdup (var_get_name (v[i])); - free (v); - *nnames += nv; - } + { + struct variable **v; + size_t nv; + + if (!parse_variables (lexer, dict, &v, &nv, pv_opts)) + goto fail; + *names = xnrealloc (*names, *nnames + nv, sizeof **names); + for (i = 0; i < nv; i++) + (*names)[*nnames + i] = xstrdup (var_get_name (v[i])); + free (v); + *nnames += nv; + } else if (!parse_DATA_LIST_vars (lexer, dict, names, nnames, PV_APPEND | pv_opts)) - goto fail; + goto fail; } if (*nnames == 0) goto fail; diff --git a/src/language/lexer/variable-parser.h b/src/language/lexer/variable-parser.h index abc92825aa..2cd33c05cd 100644 --- a/src/language/lexer/variable-parser.h +++ b/src/language/lexer/variable-parser.h @@ -69,9 +69,9 @@ bool parse_DATA_LIST_vars_pool (struct lexer *, const struct dictionary *, struct pool *, char ***names, size_t *n, int opts); bool parse_mixed_vars (struct lexer *, const struct dictionary *dict, - char ***names, size_t *n, int opts); + char ***names, size_t *n, int opts); bool parse_mixed_vars_pool (struct lexer *, const struct dictionary *dict, - struct pool *, + struct pool *, char ***names, size_t *n, int opts); /* This variable parser supports the unusual situation where set of variables @@ -111,16 +111,16 @@ parse_variable_const (struct lexer *l, const struct dictionary *d) static inline bool parse_variables_const (struct lexer *l, const struct dictionary *d, - const struct variable ***v, size_t *s, - int opts) + const struct variable ***v, size_t *s, + int opts) { return parse_variables (l, d, (struct variable ***) v, s, opts); } static inline bool parse_variables_const_pool (struct lexer *l, struct pool *p, - const struct dictionary *d, - const struct variable ***v, size_t *s, int opts) + const struct dictionary *d, + const struct variable ***v, size_t *s, int opts) { return parse_variables_pool (l, p, d, (struct variable ***) v, s, opts); } @@ -135,7 +135,7 @@ const_var_set_create_from_dict (const struct dictionary *d) static inline struct const_var_set * const_var_set_create_from_array (const struct variable *const *var, - size_t s) + size_t s) { return (struct const_var_set *) var_set_create_from_array ((struct variable *const *) var, s); } @@ -143,10 +143,10 @@ const_var_set_create_from_array (const struct variable *const *var, static inline bool parse_const_var_set_vars (struct lexer *l, const struct const_var_set *vs, - const struct variable ***v, size_t *s, int opts) + const struct variable ***v, size_t *s, int opts) { return parse_var_set_vars (l, (const struct var_set *) vs, - (struct variable ***) v, s, opts); + (struct variable ***) v, s, opts); } static inline void diff --git a/src/language/tests/pool-test.c b/src/language/tests/pool-test.c index 9bfcad0001..8e42bfece0 100644 --- a/src/language/tests/pool-test.c +++ b/src/language/tests/pool-test.c @@ -54,55 +54,55 @@ cmd_debug_pool (struct lexer *lexer UNUSED, struct dataset *ds UNUSED) printf (" Populating pool with random-sized small objects...\n"); for (i = 0; i < N_ITERATIONS; i++) - { - size_t size = rand () % MAX_SUBALLOC; - void *p = pool_alloc (pool, size); - memset (p, 0, size); - } + { + size_t size = rand () % MAX_SUBALLOC; + void *p = pool_alloc (pool, size); + memset (p, 0, size); + } printf (" Marking pool state...\n"); pool_mark (pool, &m2); printf (" Populating pool with random-sized small " - "and large objects...\n"); + "and large objects...\n"); for (i = 0; i < N_ITERATIONS; i++) - { - size_t size = rand () % (2 * MAX_SUBALLOC); - void *p = pool_alloc (pool, size); - memset (p, 0, size); - } + { + size_t size = rand () % (2 * MAX_SUBALLOC); + void *p = pool_alloc (pool, size); + memset (p, 0, size); + } printf (" Releasing pool state...\n"); pool_release (pool, &m2); printf (" Populating pool with random objects and gizmos...\n"); for (i = 0; i < N_FILES; i++) - files[i] = NULL; + files[i] = NULL; cur_file = 0; for (i = 0; i < N_ITERATIONS; i++) - { - int type = rand () % 32; - - if (type == 0) - { - if (files[cur_file] != NULL - && EOF == pool_fclose (pool, files[cur_file])) - printf ("error on fclose: %s\n", strerror (errno)); - - files[cur_file] = pool_fopen (pool, "/dev/null", "r"); - - if (++cur_file >= N_FILES) - cur_file = 0; - } - else if (type == 1) - pool_create_subpool (pool); - else - { - size_t size = rand () % (2 * MAX_SUBALLOC); - void *p = pool_alloc (pool, size); - memset (p, 0, size); - } - } + { + int type = rand () % 32; + + if (type == 0) + { + if (files[cur_file] != NULL + && EOF == pool_fclose (pool, files[cur_file])) + printf ("error on fclose: %s\n", strerror (errno)); + + files[cur_file] = pool_fopen (pool, "/dev/null", "r"); + + if (++cur_file >= N_FILES) + cur_file = 0; + } + else if (type == 1) + pool_create_subpool (pool); + else + { + size_t size = rand () % (2 * MAX_SUBALLOC); + void *p = pool_alloc (pool, size); + memset (p, 0, size); + } + } printf ("Releasing pool state...\n"); pool_release (pool, &m1); diff --git a/src/libpspp/array.c b/src/libpspp/array.c index 9ae278027b..1339998059 100644 --- a/src/libpspp/array.c +++ b/src/libpspp/array.c @@ -609,10 +609,10 @@ typedef struct log(MAX_THRESH)). Since total_elements has type size_t, we get as upper bound for log (total_elements): bits per byte (CHAR_BIT) * sizeof(size_t). */ -#define STACK_SIZE (CHAR_BIT * sizeof(size_t)) -#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -#define STACK_NOT_EMPTY (stack < top) +#define STACK_SIZE (CHAR_BIT * sizeof(size_t)) +#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) +#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) +#define STACK_NOT_EMPTY (stack < top) /* Order size using quicksort. This implementation incorporates @@ -662,56 +662,56 @@ sort (void *array, size_t count, size_t size, char *left_ptr; char *right_ptr; - /* Select median value from among LO, MID, and HI. Rearrange - LO and HI so the three values are sorted. This lowers the - probability of picking a pathological pivot value and - skips a comparison for both the LEFT_PTR and RIGHT_PTR in - the while loops. */ - - char *mid = lo + size * ((hi - lo) / size >> 1); - - if (compare (mid, lo, aux) < 0) - swap (mid, lo, size); - if (compare (hi, mid, aux) < 0) - swap (mid, hi, size); - else - goto jump_over; - if (compare (mid, lo, aux) < 0) - swap (mid, lo, size); - jump_over:; - - left_ptr = lo + size; - right_ptr = hi - size; - - /* Here's the famous ``collapse the walls'' section of quicksort. - Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ - do - { - while (compare (left_ptr, mid, aux) < 0) - left_ptr += size; - - while (compare (mid, right_ptr, aux) < 0) - right_ptr -= size; - - if (left_ptr < right_ptr) - { - swap (left_ptr, right_ptr, size); - if (mid == left_ptr) - mid = right_ptr; - else if (mid == right_ptr) - mid = left_ptr; - left_ptr += size; - right_ptr -= size; - } - else if (left_ptr == right_ptr) - { - left_ptr += size; - right_ptr -= size; - break; - } - } - while (left_ptr <= right_ptr); + /* Select median value from among LO, MID, and HI. Rearrange + LO and HI so the three values are sorted. This lowers the + probability of picking a pathological pivot value and + skips a comparison for both the LEFT_PTR and RIGHT_PTR in + the while loops. */ + + char *mid = lo + size * ((hi - lo) / size >> 1); + + if (compare (mid, lo, aux) < 0) + swap (mid, lo, size); + if (compare (hi, mid, aux) < 0) + swap (mid, hi, size); + else + goto jump_over; + if (compare (mid, lo, aux) < 0) + swap (mid, lo, size); + jump_over:; + + left_ptr = lo + size; + right_ptr = hi - size; + + /* Here's the famous ``collapse the walls'' section of quicksort. + Gotta like those tight inner loops! They are the main reason + that this algorithm runs much faster than others. */ + do + { + while (compare (left_ptr, mid, aux) < 0) + left_ptr += size; + + while (compare (mid, right_ptr, aux) < 0) + right_ptr -= size; + + if (left_ptr < right_ptr) + { + swap (left_ptr, right_ptr, size); + if (mid == left_ptr) + mid = right_ptr; + else if (mid == right_ptr) + mid = left_ptr; + left_ptr += size; + right_ptr -= size; + } + else if (left_ptr == right_ptr) + { + left_ptr += size; + right_ptr -= size; + break; + } + } + while (left_ptr <= right_ptr); /* Set up pointers for next iteration. First determine whether left and right partitions are below the threshold size. If so, @@ -721,24 +721,24 @@ sort (void *array, size_t count, size_t size, if ((size_t) (right_ptr - lo) <= max_thresh) { if ((size_t) (hi - left_ptr) <= max_thresh) - /* Ignore both small partitions. */ + /* Ignore both small partitions. */ POP (lo, hi); else - /* Ignore small left partition. */ + /* Ignore small left partition. */ lo = left_ptr; } else if ((size_t) (hi - left_ptr) <= max_thresh) - /* Ignore small right partition. */ + /* Ignore small right partition. */ hi = right_ptr; else if ((right_ptr - lo) > (hi - left_ptr)) { - /* Push larger left partition indices. */ + /* Push larger left partition indices. */ PUSH (lo, right_ptr); lo = left_ptr; } else { - /* Push larger right partition indices. */ + /* Push larger right partition indices. */ PUSH (left_ptr, hi); hi = right_ptr; } @@ -773,17 +773,17 @@ sort (void *array, size_t count, size_t size, run_ptr = first + size; while ((run_ptr += size) <= end_ptr) { - tmp_ptr = run_ptr - size; - while (compare (run_ptr, tmp_ptr, aux) < 0) - tmp_ptr -= size; + tmp_ptr = run_ptr - size; + while (compare (run_ptr, tmp_ptr, aux) < 0) + tmp_ptr -= size; - tmp_ptr += size; + tmp_ptr += size; if (tmp_ptr != run_ptr) { char *trav; - trav = run_ptr + size; - while (--trav >= run_ptr) + trav = run_ptr + size; + while (--trav >= run_ptr) { char c = *trav; char *hi, *lo; diff --git a/src/libpspp/copyleft.c b/src/libpspp/copyleft.c index 06915c2131..5b83414a25 100644 --- a/src/libpspp/copyleft.c +++ b/src/libpspp/copyleft.c @@ -56,14 +56,14 @@ const char lack_of_warranty[]="" const char copyleft[]="" "\n" -" GNU GENERAL PUBLIC LICENSE\n" -" Version 3, 29 June 2007\n" +" GNU GENERAL PUBLIC LICENSE\n" +" Version 3, 29 June 2007\n" "\n" " Copyright (C) 2007 Free Software Foundation, Inc. \n" " Everyone is permitted to copy and distribute verbatim copies\n" " of this license document, but changing it is not allowed.\n" "\n" -" Preamble\n" +" Preamble\n" "\n" " The GNU General Public License is a free, copyleft license for\n" "software and other kinds of works.\n" @@ -126,7 +126,7 @@ const char copyleft[]="" " The precise terms and conditions for copying, distribution and\n" "modification follow.\n" "\n" -" TERMS AND CONDITIONS\n" +" TERMS AND CONDITIONS\n" "\n" " 0. Definitions.\n" "\n" @@ -676,9 +676,9 @@ const char copyleft[]="" "Program, unless a warranty or assumption of liability accompanies a\n" "copy of the Program in return for a fee.\n" "\n" -" END OF TERMS AND CONDITIONS\n" +" END OF TERMS AND CONDITIONS\n" "\n" -" How to Apply These Terms to Your New Programs\n" +" How to Apply These Terms to Your New Programs\n" "\n" " If you develop a new program, and you want it to be of the greatest\n" "possible use to the public, the best way to achieve this is to make it\n" diff --git a/src/libpspp/freaderror.c b/src/libpspp/freaderror.c index fffe9678c0..07d3dffbf1 100644 --- a/src/libpspp/freaderror.c +++ b/src/libpspp/freaderror.c @@ -47,8 +47,8 @@ freaderror (FILE *fp) if (ferror (fp)) { /* The stream had an error earlier, but its errno was lost. - If the error was not temporary, we can get the same - errno by reading one more byte. */ + If the error was not temporary, we can get the same + errno by reading one more byte. */ getc (fp); fclose (fp); return -1; diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index dc36c73dc5..5e9aa0d59c 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -76,11 +76,11 @@ create_iconv (const char* tocode, const char* fromcode, bool warn) HMAPX_FOR_EACH_WITH_HASH (converter, node, hash, &map) { if (!converter) - return NULL; + return NULL; if (!strcmp (tocode, converter->tocode) - && !strcmp (fromcode, converter->fromcode)) - return converter; + && !strcmp (fromcode, converter->fromcode)) + return converter; } converter = xmalloc (sizeof *converter); @@ -119,7 +119,7 @@ create_iconv (const char* tocode, const char* fromcode, bool warn) char *outptr = outbuf; size_t outbytes = sizeof outbuf; if (-1 != iconv (bconv, &inptr, &inbytes, &outptr, &outbytes)) - converter->null_char_width = outptr - outbuf; + converter->null_char_width = outptr - outbuf; iconv_close (bconv); } @@ -149,7 +149,7 @@ recode_byte (const char *to, const char *from, char c) returned value. */ char * recode_string (const char *to, const char *from, - const char *text, int length) + const char *text, int length) { return recode_string_pool (to, from, text, length, NULL); } @@ -209,8 +209,8 @@ try_recode (struct converter *cvtr, char fallbackchar, if (!fallbackchar) return -EINVAL; *out++ = fallbackchar; - for (j = 0 ; j < null_bytes ; ++j) - *out++ = '\0'; + for (j = 0 ; j < null_bytes ; ++j) + *out++ = '\0'; return out - 1 - out_; case EILSEQ: @@ -784,7 +784,7 @@ i18n_done (void) HMAPX_FOR_EACH (cvtr, node, &map) { if (cvtr == NULL) - continue; + continue; free (cvtr->tocode); free (cvtr->fromcode); if (cvtr->conv != (iconv_t) -1) @@ -1045,10 +1045,10 @@ bool get_encoding_info (struct encoding_info *e, const char *name) { const struct substring in = SS_LITERAL_INITIALIZER ( - "\t\n\v\f\r " - "!\"#$%&'()*+,-./0123456789:;<=>?@" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" - "abcdefghijklmnopqrstuvwxyz{|}~"); + "\t\n\v\f\r " + "!\"#$%&'()*+,-./0123456789:;<=>?@" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" + "abcdefghijklmnopqrstuvwxyz{|}~"); struct substring out, cr, lf, space; bool ok; diff --git a/src/libpspp/i18n.h b/src/libpspp/i18n.h index 8f3113d477..9be1bca203 100644 --- a/src/libpspp/i18n.h +++ b/src/libpspp/i18n.h @@ -148,7 +148,7 @@ char recode_byte (const char *to, const char *from, char); char *recode_string (const char *to, const char *from, const char *text, int len); char *recode_string_pool (const char *to, const char *from, - const char *text, int length, struct pool *); + const char *text, int length, struct pool *); struct substring recode_substring_pool (const char *to, const char *from, struct substring text, struct pool *); int recode_pedantically (const char *to, const char *from, diff --git a/src/libpspp/message.h b/src/libpspp/message.h index e0c98cebf7..096f68e073 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -48,9 +48,9 @@ const char *msg_severity_to_string (enum msg_severity); /* Combination of a category and a severity for convenience. */ enum msg_class { - ME, MW, MN, /* General error/warning/note. */ - SE, SW, SN, /* Script error/warning/note. */ - DE, DW, DN, /* Data-file error/note. */ + ME, MW, MN, /* General error/warning/note. */ + SE, SW, SN, /* Script error/warning/note. */ + DE, DW, DN, /* Data-file error/note. */ MSG_CLASS_CNT, }; diff --git a/src/libpspp/misc.c b/src/libpspp/misc.c index c0120df82b..cd2c2cfcf1 100644 --- a/src/libpspp/misc.c +++ b/src/libpspp/misc.c @@ -46,10 +46,10 @@ c_dtoastr (char *buf, size_t bufsize, int flags, int width, double x) for (i = 0; i < result; ++i) { if (buf[i] == ',') - { - buf[i] = '.'; - break; - } + { + buf[i] = '.'; + break; + } } return result; diff --git a/src/libpspp/pool.c b/src/libpspp/pool.c index a1979abc81..b8ba42de5c 100644 --- a/src/libpspp/pool.c +++ b/src/libpspp/pool.c @@ -32,9 +32,9 @@ /* Fast, low-overhead memory block suballocator. */ struct pool { - struct pool *parent; /* Pool of which this pool is a subpool. */ - struct pool_block *blocks; /* Blocks owned by the pool. */ - struct pool_gizmo *gizmos; /* Other stuff owned by the pool. */ + struct pool *parent; /* Pool of which this pool is a subpool. */ + struct pool_block *blocks; /* Blocks owned by the pool. */ + struct pool_gizmo *gizmos; /* Other stuff owned by the pool. */ }; /* Pool block. */ @@ -64,30 +64,30 @@ struct pool_gizmo struct pool_gizmo *prev; struct pool_gizmo *next; - long serial; /* Serial number. */ - int type; /* Type of this gizmo. */ + long serial; /* Serial number. */ + int type; /* Type of this gizmo. */ /* Type-dependent info. */ union { - FILE *file; /* POOL_GIZMO_FILE, POOL_GIZMO_TEMP_FILE. */ - struct pool *subpool; /* POOL_GIZMO_SUBPOOL. */ - - /* POOL_GIZMO_REGISTERED. */ - struct - { - void (*free) (void *p); - void *p; - } - registered; + FILE *file; /* POOL_GIZMO_FILE, POOL_GIZMO_TEMP_FILE. */ + struct pool *subpool; /* POOL_GIZMO_SUBPOOL. */ + + /* POOL_GIZMO_REGISTERED. */ + struct + { + void (*free) (void *p); + void *p; + } + registered; } p; }; /* Rounds X up to the next multiple of Y. */ #ifndef ROUND_UP -#define ROUND_UP(X, Y) \ - (((X) + ((Y) - 1)) / (Y) * (Y)) +#define ROUND_UP(X, Y) \ + (((X) + ((Y) - 1)) / (Y) * (Y)) #endif /* Types that provide typically useful alignment sizes. */ @@ -208,8 +208,8 @@ pool_destroy (struct pool *pool) pool->blocks->prev->next = NULL; for (cur = pool->blocks; cur; cur = next) { - next = cur->next; - free (cur); + next = cur->next; + free (cur); } } } @@ -262,11 +262,11 @@ pool_alloc (struct pool *pool, size_t amt) struct pool_block *b = pool->blocks; b->ofs = ROUND_UP (b->ofs, ALIGN_SIZE); if (b->ofs + amt <= BLOCK_SIZE) - { - void *const p = ((char *) b) + b->ofs; - b->ofs += amt; - return p; - } + { + void *const p = ((char *) b) + b->ofs; + b->ofs += amt; + return p; + } /* No space in this block, so we must make other arrangements. */ @@ -471,15 +471,15 @@ pool_malloc (struct pool *pool, size_t amt) if (pool != NULL) { if (amt != 0) - { - struct pool_gizmo *g = xmalloc (amt + POOL_GIZMO_SIZE); - g->type = POOL_GIZMO_MALLOC; - add_gizmo (pool, g); + { + struct pool_gizmo *g = xmalloc (amt + POOL_GIZMO_SIZE); + g->type = POOL_GIZMO_MALLOC; + add_gizmo (pool, g); - return ((char *) g) + POOL_GIZMO_SIZE; - } + return ((char *) g) + POOL_GIZMO_SIZE; + } else - return NULL; + return NULL; } else return xmalloc (amt); @@ -539,31 +539,31 @@ pool_realloc (struct pool *pool, void *p, size_t amt) if (pool != NULL) { if (p != NULL) - { - if (amt != 0) - { - struct pool_gizmo *g = (void *) (((char *) p) - POOL_GIZMO_SIZE); + { + if (amt != 0) + { + struct pool_gizmo *g = (void *) (((char *) p) - POOL_GIZMO_SIZE); check_gizmo (pool, g); - g = xrealloc (g, amt + POOL_GIZMO_SIZE); - if (g->next) - g->next->prev = g; - if (g->prev) - g->prev->next = g; - else - pool->gizmos = g; + g = xrealloc (g, amt + POOL_GIZMO_SIZE); + if (g->next) + g->next->prev = g; + if (g->prev) + g->prev->next = g; + else + pool->gizmos = g; check_gizmo (pool, g); - return ((char *) g) + POOL_GIZMO_SIZE; - } - else - { - pool_free (pool, p); - return NULL; - } - } + return ((char *) g) + POOL_GIZMO_SIZE; + } + else + { + pool_free (pool, p); + return NULL; + } + } else - return pool_malloc (pool, amt); + return pool_malloc (pool, amt); } else return xrealloc (p, amt); @@ -619,9 +619,9 @@ pool_nrealloc (struct pool *pool, void *p, size_t n, size_t s) void append_int (int value) { - if (used == allocated) - p = pool_2nrealloc (pool, p, &allocated, sizeof *p); - p[used++] = value; + if (used == allocated) + p = pool_2nrealloc (pool, p, &allocated, sizeof *p); + p[used++] = value; } This causes x2nrealloc to allocate a block of some nonzero size the @@ -640,12 +640,12 @@ pool_nrealloc (struct pool *pool, void *p, size_t n, size_t s) void append_int (int value) { - if (used == allocated) - { - p = pool_2nrealloc (pool, p, &allocated1, sizeof *p); - allocated = allocated1; - } - p[used++] = value; + if (used == allocated) + { + p = pool_2nrealloc (pool, p, &allocated1, sizeof *p); + allocated = allocated1; + } + p[used++] = value; } This function implementation is from gnulib. */ @@ -657,21 +657,21 @@ pool_2nrealloc (struct pool *pool, void *p, size_t *pn, size_t s) if (p == NULL) { if (n == 0) - { - /* The approximate size to use for initial small allocation - requests, when the invoking code specifies an old size of - zero. 64 bytes is the largest "small" request for the - GNU C library malloc. */ - enum { DEFAULT_MXFAST = 64 }; - - n = DEFAULT_MXFAST / s; - n += !n; - } + { + /* The approximate size to use for initial small allocation + requests, when the invoking code specifies an old size of + zero. 64 bytes is the largest "small" request for the + GNU C library malloc. */ + enum { DEFAULT_MXFAST = 64 }; + + n = DEFAULT_MXFAST / s; + n += !n; + } } else { if (SIZE_MAX / 2 / s < n) - xalloc_die (); + xalloc_die (); n *= 2; } @@ -880,10 +880,10 @@ pool_unregister (struct pool *pool, void *p) for (g = pool->gizmos; g; g = g->next) if (g->type == POOL_GIZMO_REGISTERED && g->p.registered.p == p) - { - delete_gizmo (pool, g); - return true; - } + { + delete_gizmo (pool, g); + return true; + } } return false; @@ -918,14 +918,14 @@ pool_release (struct pool *pool, const struct pool_mark *mark) for (cur = pool->gizmos; cur && cur->serial >= mark->serial; cur = next) { - next = cur->next; - free_gizmo (cur); + next = cur->next; + free_gizmo (cur); } if (cur != NULL) { - cur->prev = NULL; - pool->gizmos = cur; + cur->prev = NULL; + pool->gizmos = cur; } else pool->gizmos = NULL; @@ -998,7 +998,7 @@ free_gizmo (struct pool_gizmo *gizmo) free (gizmo); break; case POOL_GIZMO_FILE: - fclose (gizmo->p.file); /* Ignore errors. */ + fclose (gizmo->p.file); /* Ignore errors. */ break; case POOL_GIZMO_TEMP_FILE: close_temp_file (gizmo->p.file); /* Ignore errors. */ diff --git a/src/libpspp/prompt.h b/src/libpspp/prompt.h index 8022e73732..43354315c0 100644 --- a/src/libpspp/prompt.h +++ b/src/libpspp/prompt.h @@ -19,9 +19,9 @@ enum prompt_style { - PROMPT_FIRST, /* First line of command. */ + PROMPT_FIRST, /* First line of command. */ PROMPT_LATER, /* Second or later line of command. */ - PROMPT_DATA, /* Between BEGIN DATA and END DATA. */ + PROMPT_DATA, /* Between BEGIN DATA and END DATA. */ PROMPT_COMMENT, /* COMMENT or * command. */ PROMPT_DOCUMENT, /* DOCUMENT command. */ PROMPT_DO_REPEAT, /* DO REPEAT command. */ diff --git a/src/libpspp/str.c b/src/libpspp/str.c index a85d1fb9ef..1d0bf4d3d5 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -341,7 +341,7 @@ str_parse_26adic (const char *str) : c >= 'a' && c <= 'z' ? c - 'a' : -1); if (digit < 0) - return -1; + return -1; assert (digit >= 0 && digit < RADIX); result += (digit + (i > 0)) * multiplier; @@ -1195,7 +1195,7 @@ ds_extend (struct string *st, size_t min_capacity) { st->capacity *= 2; if (st->capacity < min_capacity) - st->capacity = 2 * min_capacity; + st->capacity = 2 * min_capacity; st->ss.string = xrealloc (st->ss.string, st->capacity + 1); } @@ -1793,7 +1793,7 @@ ds_relocate (struct string *st) ds_clear (st); ds_put_cstr (st, rel); /* The documentation for relocate says that casting away const - and then freeing is appropriate ... */ + and then freeing is appropriate ... */ free (CONST_CAST (char *, rel)); } } @@ -1831,8 +1831,8 @@ relocate_format (const char *format, ...) copies of PAD as needed. */ void u8_buf_copy_rpad (uint8_t *dst, size_t dst_size, - const uint8_t *src, size_t src_size, - char pad) + const uint8_t *src, size_t src_size, + char pad) { if (src_size >= dst_size) memmove (dst, src, dst_size); diff --git a/src/libpspp/str.h b/src/libpspp/str.h index 2fbbf510b3..9262626a10 100644 --- a/src/libpspp/str.h +++ b/src/libpspp/str.h @@ -276,8 +276,8 @@ char *relocate_format (const char *, ...) PRINTF_FORMAT (1, 2) MALLOC_LIKE; void u8_buf_copy_rpad (uint8_t *dst, size_t dst_size, - const uint8_t *src, size_t src_size, - char pad); + const uint8_t *src, size_t src_size, + char pad); static inline struct substring ss_empty (void) diff --git a/src/libpspp/taint.c b/src/libpspp/taint.c index 08bdb6a799..5712653aa7 100644 --- a/src/libpspp/taint.c +++ b/src/libpspp/taint.c @@ -100,23 +100,23 @@ taint_destroy (struct taint *taint) { bool was_tainted = taint_is_tainted (taint); if (--taint->ref_cnt == 0) - { - size_t i, j; - - for (i = 0; i < taint->predecessors.n; i++) - for (j = 0; j < taint->successors.n; j++) - taint_propagate (taint->predecessors.taints[i], - taint->successors.taints[j]); - - for (i = 0; i < taint->predecessors.n; i++) - taint_list_remove (&taint->predecessors.taints[i]->successors, taint); - for (i = 0; i < taint->successors.n; i++) - taint_list_remove (&taint->successors.taints[i]->predecessors, taint); - - taint_list_destroy (&taint->successors); - taint_list_destroy (&taint->predecessors); - free (taint); - } + { + size_t i, j; + + for (i = 0; i < taint->predecessors.n; i++) + for (j = 0; j < taint->successors.n; j++) + taint_propagate (taint->predecessors.taints[i], + taint->successors.taints[j]); + + for (i = 0; i < taint->predecessors.n; i++) + taint_list_remove (&taint->predecessors.taints[i]->successors, taint); + for (i = 0; i < taint->successors.n; i++) + taint_list_remove (&taint->successors.taints[i]->predecessors, taint); + + taint_list_destroy (&taint->successors); + taint_list_destroy (&taint->predecessors); + free (taint); + } return !was_tainted; } diff --git a/src/libpspp/zip-reader.c b/src/libpspp/zip-reader.c index 38cba29566..a4dbabb957 100644 --- a/src/libpspp/zip-reader.c +++ b/src/libpspp/zip-reader.c @@ -567,7 +567,7 @@ find_eocd (FILE *fp, off_t *off) found = probe_magic (fp, magic, start, stop, off); /* FIXME: For extra confidence lookup the directory start record here*/ if (start == 0) - break; + break; stop = start + sizeof (magic); start >>= 1; } @@ -603,21 +603,21 @@ probe_magic (FILE *fp, uint32_t magic, off_t start, off_t stop, off_t *off) do { if (1 != fread (&byte, 1, 1, fp)) - break; + break; if (byte == seq[state]) - state++; + state++; else - state = 0; + state = 0; if (state == 4) - { - *off = ftello (fp) - 4; - return true; - } + { + *off = ftello (fp) - 4; + return true; + } start++; if (start >= stop) - break; + break; } while (!feof (fp)); @@ -728,21 +728,21 @@ inflate_read (struct zip_member *zm, void *buf, size_t n) int pad = 0; if (inf->state == 0) - { - inf->ucomp[1] = inf->cmf_flg ; - inf->ucomp[0] = inf->cmf_flg >> 8 ; + { + inf->ucomp[1] = inf->cmf_flg ; + inf->ucomp[0] = inf->cmf_flg >> 8 ; - pad = 2; - inf->state++; - } + pad = 2; + inf->state++; + } bytes_to_read = zm->comp_size - inf->ucomp_bytes_read; if (bytes_to_read == 0) - return 0; + return 0; if (bytes_to_read > UCOMPSIZE) - bytes_to_read = UCOMPSIZE; + bytes_to_read = UCOMPSIZE; bytes_read = fread (inf->ucomp + pad, 1, bytes_to_read - pad, zm->fp); if (!bytes_read && !zm->error) diff --git a/src/math/box-whisker.c b/src/math/box-whisker.c index e0fbbe94b2..6826e8d0db 100644 --- a/src/math/box-whisker.c +++ b/src/math/box-whisker.c @@ -75,10 +75,10 @@ acc (struct statistic *s, const struct ccase *cx, else /* Not an outlier */ { if (bw->whiskers[0] == SYSMIS) - bw->whiskers[0] = y; + bw->whiskers[0] = y; if (y > bw->whiskers[1]) - bw->whiskers[1] = y; + bw->whiskers[1] = y; return; } @@ -142,7 +142,7 @@ box_whisker_outliers (const struct box_whisker *bw) */ struct box_whisker * box_whisker_create (const struct tukey_hinges *th, - size_t id_idx, const struct variable *id_var) + size_t id_idx, const struct variable *id_var) { double hinges[3]; tukey_hinges_calculate (th, hinges); diff --git a/src/math/chart-geometry.c b/src/math/chart-geometry.c index 21176f85d3..8a14009aec 100644 --- a/src/math/chart-geometry.c +++ b/src/math/chart-geometry.c @@ -52,8 +52,8 @@ */ void chart_get_scale (double high, double low, - double *lower, double *interval, - int *n_ticks) + double *lower, double *interval, + int *n_ticks) { assert (high >= low); if ((high - low) < 10 * DBL_MIN) @@ -156,7 +156,7 @@ gen_pango_markup_scientific_format_string (int n_decimals, int exponent) */ char * chart_get_ticks_format (const double lower, const double interval, - const unsigned int nticks, double *scale) + const unsigned int nticks, double *scale) { double logmax = log10(fmax(fabs(lower + (nticks+1)*interval),fabs(lower))); double logintv = log10(interval); @@ -169,42 +169,42 @@ chart_get_ticks_format (const double lower, const double interval, nrdecs = MIN(6,(int)(ceil(fabs(logintv)))); logshift = 0; if (logmax < 12.0) - format_string = xasprintf("%%.%dlf",nrdecs); + format_string = xasprintf("%%.%dlf",nrdecs); else - format_string = xasprintf("%%lg"); + format_string = xasprintf("%%lg"); } else if (logmax > 0.0) /*logintv is > 0*/ { if (logintv < 5.0 && logmax < 10.0) - { - logshift = 0; /* No scientific format */ - nrdecs = 0; - format_string = xstrdup("%.0lf"); - } + { + logshift = 0; /* No scientific format */ + nrdecs = 0; + format_string = xstrdup("%.0lf"); + } else - { - logshift = (int)logmax; - /* Possible intervals are 0.2Ex, 0.5Ex, 1.0Ex */ - /* log10(0.2E9) = 8.30, log10(0.5E9) = 8.69, log10(1.0E9) = 9 */ - /* 0.2 and 0.5 need one decimal more. For stability subtract 0.1 */ - nrdecs = MIN(8,(int)(ceil(logshift-logintv-0.1))); - format_string = gen_pango_markup_scientific_format_string (nrdecs, logshift); - } + { + logshift = (int)logmax; + /* Possible intervals are 0.2Ex, 0.5Ex, 1.0Ex */ + /* log10(0.2E9) = 8.30, log10(0.5E9) = 8.69, log10(1.0E9) = 9 */ + /* 0.2 and 0.5 need one decimal more. For stability subtract 0.1 */ + nrdecs = MIN(8,(int)(ceil(logshift-logintv-0.1))); + format_string = gen_pango_markup_scientific_format_string (nrdecs, logshift); + } } else /* logmax and logintv are < 0 */ { if (logmax > -3.0) - { - logshift = 0; /* No scientific format */ - nrdecs = MIN(8,(int)(ceil(-logintv))); - format_string = xasprintf("%%.%dlf",nrdecs); - } + { + logshift = 0; /* No scientific format */ + nrdecs = MIN(8,(int)(ceil(-logintv))); + format_string = xasprintf("%%.%dlf",nrdecs); + } else - { - logshift = (int)logmax-1; - nrdecs = MIN(8,(int)(ceil(logshift-logintv-0.1))); - format_string = gen_pango_markup_scientific_format_string (nrdecs, logshift); - } + { + logshift = (int)logmax-1; + nrdecs = MIN(8,(int)(ceil(logshift-logintv-0.1))); + format_string = gen_pango_markup_scientific_format_string (nrdecs, logshift); + } } *scale = pow(10.0,-(double)logshift); return format_string; diff --git a/src/math/chart-geometry.h b/src/math/chart-geometry.h index 3d3955e75e..64cf5473cb 100644 --- a/src/math/chart-geometry.h +++ b/src/math/chart-geometry.h @@ -19,10 +19,10 @@ #define CHART_GEOMETRY_H void chart_get_scale (double high, double low, - double *lower, double *interval, int *n_ticks); + double *lower, double *interval, int *n_ticks); char * chart_get_ticks_format (const double lower, const double interval, const unsigned int nticks, - double *scale); + double *scale); #endif diff --git a/src/math/correlation.c b/src/math/correlation.c index bac81e4349..ad60601756 100644 --- a/src/math/correlation.c +++ b/src/math/correlation.c @@ -56,15 +56,15 @@ correlation_from_covariance (const gsl_matrix *cv, const gsl_matrix *v) for (i = 0 ; i < cv->size1; ++i) { for (j = 0 ; j < cv->size2; ++j) - { - double rho = gsl_matrix_get (cv, i, j); + { + double rho = gsl_matrix_get (cv, i, j); - rho /= sqrt (gsl_matrix_get (v, i, j)) - * - sqrt (gsl_matrix_get (v, j, i)); + rho /= sqrt (gsl_matrix_get (v, i, j)) + * + sqrt (gsl_matrix_get (v, j, i)); - gsl_matrix_set (corr, i, j, rho); - } + gsl_matrix_set (corr, i, j, rho); + } } return corr; @@ -81,15 +81,15 @@ covariance_from_correlation (const gsl_matrix *corr, const gsl_matrix *v) for (i = 0 ; i < corr->size1; ++i) { for (j = 0 ; j < corr->size2; ++j) - { - double r = gsl_matrix_get (corr, i, j); + { + double r = gsl_matrix_get (corr, i, j); - r *= sqrt (gsl_matrix_get (v, i, j)) - * - sqrt (gsl_matrix_get (v, j, i)); + r *= sqrt (gsl_matrix_get (v, i, j)) + * + sqrt (gsl_matrix_get (v, j, i)); - gsl_matrix_set (output, i, j, r); - } + gsl_matrix_set (output, i, j, r); + } } return output; diff --git a/src/math/covariance.c b/src/math/covariance.c index 79fce25cef..c7fb4b70ad 100644 --- a/src/math/covariance.c +++ b/src/math/covariance.c @@ -56,11 +56,11 @@ resize_matrix (gsl_matrix *in, size_t new_size) for (i = 0; i < in->size1; ++i) { for (j = 0; j < in->size2; ++j) - { - double x = gsl_matrix_get (in, i, j); + { + double x = gsl_matrix_get (in, i, j); - gsl_matrix_set (out, i, j, x); - } + gsl_matrix_set (out, i, j, x); + } } gsl_matrix_free (in); @@ -141,8 +141,8 @@ covariance_moments (const struct covariance *cov, int m) */ struct covariance * covariance_1pass_create (size_t n_vars, const struct variable *const *vars, - const struct variable *weight, enum mv_class exclude, - bool centered) + const struct variable *weight, enum mv_class exclude, + bool centered) { size_t i; struct covariance *cov = XZALLOC (struct covariance); @@ -182,9 +182,9 @@ covariance_1pass_create (size_t n_vars, const struct variable *const *vars, */ struct covariance * covariance_2pass_create (size_t n_vars, const struct variable *const *vars, - struct categoricals *cats, - const struct variable *wv, enum mv_class exclude, - bool centered) + struct categoricals *cats, + const struct variable *wv, enum mv_class exclude, + bool centered) { size_t i; struct covariance *cov = xmalloc (sizeof *cov); @@ -290,7 +290,7 @@ dump_matrix (const gsl_matrix *m) for (i = 0 ; i < m->size1; ++i) { for (j = 0 ; j < m->size2; ++j) - printf ("%02f ", gsl_matrix_get (m, i, j)); + printf ("%02f ", gsl_matrix_get (m, i, j)); printf ("\n"); } } @@ -318,23 +318,23 @@ covariance_accumulate_pass1 (struct covariance *cov, const struct ccase *c) double v1 = get_val (cov, i, c); if (is_missing (cov, i, c)) - continue; + continue; for (j = 0 ; j < cov->dim; ++j) - { - double pwr = 1.0; + { + double pwr = 1.0; - if (is_missing (cov, j, c)) - continue; + if (is_missing (cov, j, c)) + continue; - for (m = 0 ; m <= MOMENT_MEAN; ++m) - { - double *x = gsl_matrix_ptr (cov->moments[m], i, j); + for (m = 0 ; m <= MOMENT_MEAN; ++m) + { + double *x = gsl_matrix_ptr (cov->moments[m], i, j); - *x += pwr * weight; - pwr *= v1; - } - } + *x += pwr * weight; + pwr *= v1; + } + } } cov->pass_one_first_case_seen = true; @@ -358,61 +358,61 @@ covariance_accumulate_pass2 (struct covariance *cov, const struct ccase *c) cov->state = 2; if (cov->categoricals) - categoricals_done (cov->categoricals); + categoricals_done (cov->categoricals); cov->dim = cov->n_vars; if (cov->categoricals) - cov->dim += categoricals_df_total (cov->categoricals); + cov->dim += categoricals_df_total (cov->categoricals); cov->n_cm = (cov->dim * (cov->dim - 1)) / 2; cov->cm = xcalloc (cov->n_cm, sizeof *cov->cm); /* Grow the moment matrices so that they're large enough to accommodate the - categorical elements */ + categorical elements */ for (i = 0; i < n_MOMENTS; ++i) - { - cov->moments[i] = resize_matrix (cov->moments[i], cov->dim); - } + { + cov->moments[i] = resize_matrix (cov->moments[i], cov->dim); + } /* Populate the moments matrices with the categorical value elements */ for (i = cov->n_vars; i < cov->dim; ++i) - { - for (j = 0 ; j < cov->dim ; ++j) /* FIXME: This is WRONG !!! */ - { - double w = categoricals_get_weight_by_subscript (cov->categoricals, i - cov->n_vars); + { + for (j = 0 ; j < cov->dim ; ++j) /* FIXME: This is WRONG !!! */ + { + double w = categoricals_get_weight_by_subscript (cov->categoricals, i - cov->n_vars); - gsl_matrix_set (cov->moments[MOMENT_NONE], i, j, w); + gsl_matrix_set (cov->moments[MOMENT_NONE], i, j, w); - w = categoricals_get_sum_by_subscript (cov->categoricals, i - cov->n_vars); + w = categoricals_get_sum_by_subscript (cov->categoricals, i - cov->n_vars); - gsl_matrix_set (cov->moments[MOMENT_MEAN], i, j, w); - } - } + gsl_matrix_set (cov->moments[MOMENT_MEAN], i, j, w); + } + } /* FIXME: This is WRONG!! It must be fixed to properly handle missing values. For now it assumes there are none */ for (m = 0 ; m < n_MOMENTS; ++m) - { - for (i = 0 ; i < cov->dim ; ++i) - { - double x = gsl_matrix_get (cov->moments[m], i, cov->n_vars -1); - for (j = cov->n_vars; j < cov->dim; ++j) - { - gsl_matrix_set (cov->moments[m], i, j, x); - } - } - } + { + for (i = 0 ; i < cov->dim ; ++i) + { + double x = gsl_matrix_get (cov->moments[m], i, cov->n_vars -1); + for (j = cov->n_vars; j < cov->dim; ++j) + { + gsl_matrix_set (cov->moments[m], i, j, x); + } + } + } /* Divide the means by the number of samples */ for (i = 0; i < cov->dim; ++i) - { - for (j = 0; j < cov->dim; ++j) - { - double *x = gsl_matrix_ptr (cov->moments[MOMENT_MEAN], i, j); - *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); - } - } + { + for (j = 0; j < cov->dim; ++j) + { + double *x = gsl_matrix_ptr (cov->moments[MOMENT_MEAN], i, j); + *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); + } + } } for (i = 0 ; i < cov->dim; ++i) @@ -420,37 +420,37 @@ covariance_accumulate_pass2 (struct covariance *cov, const struct ccase *c) double v1 = get_val (cov, i, c); if (is_missing (cov, i, c)) - continue; + continue; for (j = 0 ; j < cov->dim; ++j) - { - int idx; - double ss ; - double v2 = get_val (cov, j, c); - - const double s = pow2 (v1 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) * weight; - - if (is_missing (cov, j, c)) - continue; - - { - double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); - *x += s; - } - - ss = - (v1 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) - * - (v2 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) - * weight - ; - - idx = cm_idx (cov, i, j); - if (idx >= 0) - { - cov->cm [idx] += ss; - } - } + { + int idx; + double ss ; + double v2 = get_val (cov, j, c); + + const double s = pow2 (v1 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) * weight; + + if (is_missing (cov, j, c)) + continue; + + { + double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); + *x += s; + } + + ss = + (v1 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) + * + (v2 - gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) + * weight + ; + + idx = cm_idx (cov, i, j); + if (idx >= 0) + { + cov->cm [idx] += ss; + } + } } cov->pass_two_first_case_seen = true; @@ -479,31 +479,31 @@ covariance_accumulate (struct covariance *cov, const struct ccase *c) const union value *val1 = case_data (c, cov->vars[i]); if (is_missing (cov, i, c)) - continue; + continue; for (j = 0 ; j < cov->dim; ++j) - { - double pwr = 1.0; - int idx; - const union value *val2 = case_data (c, cov->vars[j]); - - if (is_missing (cov, j, c)) - continue; - - idx = cm_idx (cov, i, j); - if (idx >= 0) - { - cov->cm [idx] += val1->f * val2->f * weight; - } - - for (m = 0 ; m < n_MOMENTS; ++m) - { - double *x = gsl_matrix_ptr (cov->moments[m], i, j); - - *x += pwr * weight; - pwr *= val1->f; - } - } + { + double pwr = 1.0; + int idx; + const union value *val2 = case_data (c, cov->vars[j]); + + if (is_missing (cov, j, c)) + continue; + + idx = cm_idx (cov, i, j); + if (idx >= 0) + { + cov->cm [idx] += val1->f * val2->f * weight; + } + + for (m = 0 ; m < n_MOMENTS; ++m) + { + double *x = gsl_matrix_ptr (cov->moments[m], i, j); + + *x += pwr * weight; + pwr *= val1->f; + } + } } cov->pass_one_first_case_seen = true; @@ -524,11 +524,11 @@ cm_to_gsl (struct covariance *cov) for (j = 0 ; j < cov->dim - 1; ++j) { for (i = j+1 ; i < cov->dim; ++i) - { - double x = cov->cm [cm_idx (cov, i, j)]; - gsl_matrix_set (m, i, j, x); - gsl_matrix_set (m, j, i, x); - } + { + double x = cov->cm [cm_idx (cov, i, j)]; + gsl_matrix_set (m, i, j, x); + gsl_matrix_set (m, j, i, x); + } } /* Copy the diagonal elements from cov->moments[2] */ @@ -549,18 +549,18 @@ covariance_calculate_double_pass (struct covariance *cov) for (i = 0 ; i < cov->dim; ++i) { for (j = 0 ; j < cov->dim; ++j) - { - int idx; - double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); - *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); - - idx = cm_idx (cov, i, j); - if (idx >= 0) - { - x = &cov->cm [idx]; - *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); - } - } + { + int idx; + double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); + *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); + + idx = cm_idx (cov, i, j); + if (idx >= 0) + { + x = &cov->cm [idx]; + *x /= gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); + } + } } return cm_to_gsl (cov); @@ -576,38 +576,38 @@ covariance_calculate_single_pass (struct covariance *cov) { /* Divide the moments by the number of samples */ if (m > 0) - { - for (i = 0 ; i < cov->dim; ++i) - { - for (j = 0 ; j < cov->dim; ++j) - { - double *x = gsl_matrix_ptr (cov->moments[m], i, j); - *x /= gsl_matrix_get (cov->moments[0], i, j); - - if (m == MOMENT_VARIANCE) - *x -= pow2 (gsl_matrix_get (cov->moments[1], i, j)); - } - } - } + { + for (i = 0 ; i < cov->dim; ++i) + { + for (j = 0 ; j < cov->dim; ++j) + { + double *x = gsl_matrix_ptr (cov->moments[m], i, j); + *x /= gsl_matrix_get (cov->moments[0], i, j); + + if (m == MOMENT_VARIANCE) + *x -= pow2 (gsl_matrix_get (cov->moments[1], i, j)); + } + } + } } if (cov->centered) { /* Centre the moments */ for (j = 0 ; j < cov->dim - 1; ++j) - { - 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], j, i); - } - } + { + 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], j, i); + } + } } return cm_to_gsl (cov); @@ -655,28 +655,28 @@ covariance_calculate_single_pass_unnormalized (struct covariance *cov) if (cov->centered) { for (i = 0 ; i < cov->dim; ++i) - { - for (j = 0 ; j < cov->dim; ++j) - { - double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); - *x -= pow2 (gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) - / gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); - } - } + { + for (j = 0 ; j < cov->dim; ++j) + { + double *x = gsl_matrix_ptr (cov->moments[MOMENT_VARIANCE], i, j); + *x -= pow2 (gsl_matrix_get (cov->moments[MOMENT_MEAN], i, j)) + / gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); + } + } for (j = 0 ; j < cov->dim - 1; ++j) - { - 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], j, i) - / gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); - } - } + { + 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], j, i) + / gsl_matrix_get (cov->moments[MOMENT_NONE], i, j); + } + } } return cm_to_gsl (cov); @@ -773,7 +773,7 @@ covariance_dump_enc_header (const struct covariance *cov) for (size_t i = 0, n = 0; i < cov->dim - cov->n_vars; n++) { const struct interaction *iact = - categoricals_get_interaction_by_subscript (cov->categoricals, i); + categoricals_get_interaction_by_subscript (cov->categoricals, i); struct string str = DS_EMPTY_INITIALIZER; interaction_to_string (iact, &str); @@ -803,7 +803,7 @@ covariance_dump_enc_header (const struct covariance *cov) */ void covariance_dump_enc (const struct covariance *cov, const struct ccase *c, - struct pivot_table *table) + struct pivot_table *table) { int row = pivot_category_create_leaf ( table->dimensions[1]->root, diff --git a/src/math/covariance.h b/src/math/covariance.h index 5a7be0d689..a239b4c133 100644 --- a/src/math/covariance.h +++ b/src/math/covariance.h @@ -28,12 +28,12 @@ struct ccase ; struct categoricals; struct covariance * covariance_1pass_create (size_t n_vars, const struct variable *const *vars, - const struct variable *wv, enum mv_class excl, bool centered); + const struct variable *wv, enum mv_class excl, bool centered); struct covariance * covariance_2pass_create (size_t n_vars, const struct variable *const *vars, - struct categoricals *cats, - const struct variable *wv, enum mv_class excl, bool centered); + struct categoricals *cats, + const struct variable *wv, enum mv_class excl, bool centered); void covariance_accumulate (struct covariance *, const struct ccase *); void covariance_accumulate_pass1 (struct covariance *, const struct ccase *); diff --git a/src/math/histogram.c b/src/math/histogram.c index 1a4da905f9..b59f1ebf88 100644 --- a/src/math/histogram.c +++ b/src/math/histogram.c @@ -82,9 +82,9 @@ hist_find_pretty_no_of_bins (double bin_width_in, double min, double max, { binwidth = 1.5 * interval; if (min < (lower + 0.5 * interval)) - *adjusted_min = lower; + *adjusted_min = lower; else - *adjusted_min = lower + 0.5 * interval; + *adjusted_min = lower + 0.5 * interval; } else if (bin_width_in >= interval) { @@ -95,9 +95,9 @@ hist_find_pretty_no_of_bins (double bin_width_in, double min, double max, { binwidth = (2.0/3.0 * interval); if (min >= lower + binwidth) - *adjusted_min = lower + binwidth; + *adjusted_min = lower + binwidth; else - *adjusted_min = lower; + *adjusted_min = lower; } else { diff --git a/src/math/interaction.h b/src/math/interaction.h index 8229083f86..f0d1acf988 100644 --- a/src/math/interaction.h +++ b/src/math/interaction.h @@ -62,7 +62,7 @@ bool interaction_is_subset (const struct interaction *, unsigned int interaction_case_hash (const struct interaction *, const struct ccase *, - unsigned int base) WARN_UNUSED_RESULT; + unsigned int base) WARN_UNUSED_RESULT; bool interaction_case_equal (const struct interaction *, const struct ccase *, const struct ccase *); bool interaction_case_is_missing (const struct interaction *, diff --git a/src/math/levene.c b/src/math/levene.c index a005c94360..3631708e60 100644 --- a/src/math/levene.c +++ b/src/math/levene.c @@ -109,7 +109,7 @@ find_group (const struct levene *nl, const union value *target) HMAP_FOR_EACH_WITH_HASH (l, struct lev, node, nl->hash (nl, target), &nl->hmap) { if (nl->cmp (nl, &l->group, target)) - break; + break; } return l; } @@ -173,7 +173,7 @@ levene_pass_two (struct levene *nl, double value, double weight, const union val HMAP_FOR_EACH_SAFE (l, next, struct lev, node, &nl->hmap) { - l->t_bar /= l->n; + l->t_bar /= l->n; } } assert (nl->pass == 2); @@ -200,7 +200,7 @@ levene_pass_three (struct levene *nl, double value, double weight, const union v HMAP_FOR_EACH_SAFE (l, next, struct lev, node, &nl->hmap) { - l->z_mean /= l->n; + l->z_mean /= l->n; } nl->z_grand_mean /= nl->grand_n; diff --git a/src/math/linreg.c b/src/math/linreg.c index d417599bab..bba91f3706 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -59,10 +59,10 @@ struct linreg { - double n_obs; /* Number of observations. */ - int n_indeps; /* Number of independent variables. */ + double n_obs; /* Number of observations. */ + int n_indeps; /* Number of independent variables. */ int n_coeffs; /* The intercept is not considered a - coefficient here. */ + coefficient here. */ /* Pointers to the variables. @@ -88,13 +88,13 @@ struct linreg /* Sums of squares. */ - double ssm; /* Sums of squares for the overall model. */ - double sst; /* Sum of squares total. */ - double sse; /* Sum of squares error. */ - double mse; /* Mean squared error. This is just sse / - dfe, but since it is the best unbiased - estimate of the population variance, it - has its own entry here. */ + double ssm; /* Sums of squares for the overall model. */ + double sst; /* Sum of squares total. */ + double sse; /* Sum of squares error. */ + double mse; /* Mean squared error. This is just sse / + dfe, but since it is the best unbiased + estimate of the population variance, it + has its own entry here. */ /* Covariance matrix of the parameter estimates. */ @@ -124,7 +124,7 @@ linreg_get_vars (const struct linreg *c) */ struct linreg * linreg_alloc (const struct variable *depvar, const struct variable **indep_vars, - double n, size_t p, bool origin) + double n, size_t p, bool origin) { struct linreg *c; size_t i; @@ -220,8 +220,8 @@ post_sweep_computations (struct linreg *l, gsl_matrix *sw) for (i = 0; i < l->n_indeps; i++) for (j = i; j < l->n_indeps; j++) { - double tmp = -1.0 * l->mse * gsl_matrix_get (sw, i, j); - gsl_matrix_set (l->cov, i + 1, j + 1, tmp); + double tmp = -1.0 * l->mse * gsl_matrix_get (sw, i, j); + gsl_matrix_set (l->cov, i + 1, j + 1, tmp); } if (! l->origin) @@ -230,37 +230,37 @@ post_sweep_computations (struct linreg *l, gsl_matrix *sw) gsl_matrix_view xtx; gsl_matrix_view xmxtx; /* - Get the covariances related to the intercept. + Get the covariances related to the intercept. */ xtx = gsl_matrix_submatrix (sw, 0, 0, l->n_indeps, l->n_indeps); xmxtx = gsl_matrix_submatrix (l->cov, 0, 1, 1, l->n_indeps); xm = gsl_matrix_calloc (1, l->n_indeps); for (i = 0; i < xm->size2; i++) - { - gsl_matrix_set (xm, 0, i, - linreg_get_indep_variable_mean (l, i)); - } + { + gsl_matrix_set (xm, 0, i, + linreg_get_indep_variable_mean (l, i)); + } rc = gsl_blas_dsymm (CblasRight, CblasUpper, l->mse, - &xtx.matrix, xm, 0.0, &xmxtx.matrix); + &xtx.matrix, xm, 0.0, &xmxtx.matrix); gsl_matrix_free (xm); if (rc == GSL_SUCCESS) - { - double tmp = l->mse / l->n_obs; - for (i = 1; i < 1 + l->n_indeps; i++) - { - tmp -= gsl_matrix_get (l->cov, 0, i) - * linreg_get_indep_variable_mean (l, i - 1); - } - gsl_matrix_set (l->cov, 0, 0, tmp); - - l->intercept = m; - } + { + double tmp = l->mse / l->n_obs; + for (i = 1; i < 1 + l->n_indeps; i++) + { + tmp -= gsl_matrix_get (l->cov, 0, i) + * linreg_get_indep_variable_mean (l, i - 1); + } + gsl_matrix_set (l->cov, 0, 0, tmp); + + l->intercept = m; + } else - { - fprintf (stderr, "%s:%d:gsl_blas_dsymm: %s\n", - __FILE__, __LINE__, gsl_strerror (rc)); - exit (rc); - } + { + fprintf (stderr, "%s:%d:gsl_blas_dsymm: %s\n", + __FILE__, __LINE__, gsl_strerror (rc)); + exit (rc); + } } } @@ -346,9 +346,9 @@ linreg_fit_qr (const gsl_matrix *cov, struct linreg *l) { gsl_vector_set (xty, i, gsl_matrix_get (cov, cov->size2 - 1, i)); for (j = 0; j < xtx->size2; j++) - { - gsl_matrix_set (xtx, i, j, gsl_matrix_get (cov, i, j)); - } + { + gsl_matrix_set (xtx, i, j, gsl_matrix_get (cov, i, j)); + } } gsl_linalg_QR_decomp (xtx, tau); q = gsl_matrix_alloc (xtx->size1, xtx->size2); @@ -369,44 +369,44 @@ linreg_fit_qr (const gsl_matrix *cov, struct linreg *l) l->sse = l->sst - l->ssm; gsl_blas_dtrsm (CblasLeft, CblasLower, CblasNoTrans, CblasNonUnit, linreg_mse (l), - r, q); + r, q); /* Copy the lower triangle into the upper triangle. */ for (i = 0; i < q->size1; i++) { gsl_matrix_set (l->cov, i + 1, i + 1, gsl_matrix_get (q, i, i)); for (j = i + 1; j < q->size2; j++) - { - intercept_variance -= 2.0 * gsl_matrix_get (q, i, j) * - linreg_get_indep_variable_mean (l, i) * - linreg_get_indep_variable_mean (l, j); - gsl_matrix_set (q, i, j, gsl_matrix_get (q, j, i)); - } + { + intercept_variance -= 2.0 * gsl_matrix_get (q, i, j) * + linreg_get_indep_variable_mean (l, i) * + linreg_get_indep_variable_mean (l, j); + gsl_matrix_set (q, i, j, gsl_matrix_get (q, j, i)); + } } if (!l->origin) { l->intercept = linreg_get_depvar_mean (l); for (i = 0; i < l->n_indeps; i++) - { - double tmp = linreg_get_indep_variable_mean (l, i); - l->intercept -= l->coeff[i] * tmp; - intercept_variance += tmp * tmp * gsl_matrix_get (q, i, i); - } + { + double tmp = linreg_get_indep_variable_mean (l, i); + l->intercept -= l->coeff[i] * tmp; + intercept_variance += tmp * tmp * gsl_matrix_get (q, i, i); + } /* Covariances related to the intercept. */ intercept_variance += linreg_mse (l) / linreg_n_obs (l); 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) - * 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; - } + { + for (j = 0; j < q->size2; 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); @@ -440,7 +440,7 @@ linreg_fit (const gsl_matrix *cov, struct linreg *l) if ((l->n_obs * l->n_obs > l->n_indeps) && (l->n_obs > REG_LARGE_DATA)) { /* - For large data sets, use QR decomposition. + For large data sets, use QR decomposition. */ linreg_fit_qr (cov, l); } diff --git a/src/math/linreg.h b/src/math/linreg.h index 88da7f6227..0c589f2c70 100644 --- a/src/math/linreg.h +++ b/src/math/linreg.h @@ -49,7 +49,7 @@ struct variable; struct linreg *linreg_alloc (const struct variable *, const struct variable **, - double, size_t, bool); + double, size_t, bool); void linreg_unref (struct linreg *); void linreg_ref (struct linreg *); diff --git a/src/math/order-stats.c b/src/math/order-stats.c index 050a7f5be4..b9d42dd2bb 100644 --- a/src/math/order-stats.c +++ b/src/math/order-stats.c @@ -37,7 +37,7 @@ order_stats_dump_k1 (const struct order_stats *os) { struct k *k = &os->k[0]; printf ("K1: tc %g; c %g cc %g ccp %g\n", - k->tc, k->c, k->cc, k->cc_p1); + k->tc, k->c, k->cc, k->cc_p1); } @@ -46,7 +46,7 @@ order_stats_dump_k2 (const struct order_stats *os) { struct k *k = &os->k[1]; printf ("K2: tc %g; c %g cc %g ccp %g\n", - k->tc, k->c, k->cc, k->cc_p1); + k->tc, k->c, k->cc, k->cc_p1); } @@ -61,7 +61,7 @@ order_stats_dump (const struct order_stats *os) static void update_k_values (const struct ccase *cx, double y_i, double c_i, double cc_i, - struct order_stats **os, size_t n_os) + struct order_stats **os, size_t n_os) { for (size_t j = 0; j < n_os; ++j) { @@ -69,7 +69,7 @@ update_k_values (const struct ccase *cx, double y_i, double c_i, double cc_i, struct statistic *stat = &tos->parent; for (struct k *k = tos->k; k < &tos->k[tos->n_k]; ++k) - { + { /* Update 'k' lower values. */ if (cc_i <= k->tc) { @@ -85,10 +85,10 @@ update_k_values (const struct ccase *cx, double y_i, double c_i, double cc_i, k->c_p1 = c_i; k->y_p1 = y_i; } - } + } if (tos->accumulate) - tos->accumulate (stat, cx, c_i, cc_i, y_i); + tos->accumulate (stat, cx, c_i, cc_i, y_i); } } @@ -167,10 +167,10 @@ order_stats_accumulate_idx (struct order_stats **os, size_t n_os, passing it to this function. */ void order_stats_accumulate (struct order_stats **os, size_t n_os, - struct casereader *reader, - const struct variable *weight_var, - const struct variable *data_var, - enum mv_class exclude) + struct casereader *reader, + const struct variable *weight_var, + const struct variable *data_var, + enum mv_class exclude) { reader = casereader_create_filter_missing (reader, &data_var, 1, exclude, NULL, NULL); diff --git a/src/math/order-stats.h b/src/math/order-stats.h index 4bb69383fb..ee0c4d8819 100644 --- a/src/math/order-stats.h +++ b/src/math/order-stats.h @@ -95,10 +95,10 @@ void order_stats_accumulate_idx (struct order_stats **os, size_t n_os, int weight_idx, int data_idx); void order_stats_accumulate (struct order_stats **os, size_t n_os, - struct casereader *, - const struct variable *weight_var, - const struct variable *data_var, - enum mv_class exclude); + struct casereader *, + const struct variable *weight_var, + const struct variable *data_var, + enum mv_class exclude); /* Debugging support. */ void order_stats_dump (const struct order_stats *); diff --git a/src/math/percentiles.c b/src/math/percentiles.c index a9b2913b5c..20ccac912d 100644 --- a/src/math/percentiles.c +++ b/src/math/percentiles.c @@ -43,86 +43,86 @@ percentile_calculate (const struct percentile *ptl, enum pc_alg alg) if (ptl->g2 == SYSMIS) { if (os->k[1].c == 0) - mutable->g2 = os->k[1].tc / os->k[1].c_p1; + mutable->g2 = os->k[1].tc / os->k[1].c_p1; else if (os->k[1].c_p1 == 0) - mutable->g2 = 0; + mutable->g2 = 0; else - mutable->g2 = (os->k[1].tc - os->k[1].cc) / os->k[1].c_p1; + mutable->g2 = (os->k[1].tc - os->k[1].cc) / os->k[1].c_p1; } if (ptl->g2_star == SYSMIS) { if (os->k[1].c == 0) - mutable->g2_star = os->k[1].tc; + mutable->g2_star = os->k[1].tc; else if (os->k[1].c_p1 == 0) - mutable->g2_star = 0; + mutable->g2_star = 0; else - mutable->g2_star = os->k[1].tc - os->k[1].cc; + mutable->g2_star = os->k[1].tc - os->k[1].cc; } switch (alg) { case PC_WAVERAGE: if (ptl->g1_star >= 1.0) - return os->k[0].y_p1; + return os->k[0].y_p1; else - { - double a = (os->k[0].y == SYSMIS) ? 0 : os->k[0].y; - - if (os->k[0].c_p1 >= 1.0) - return (1 - ptl->g1_star) * a + ptl->g1_star * os->k[0].y_p1; - else - return (1 - ptl->g1) * a + ptl->g1 * os->k[0].y_p1; - } + { + double a = (os->k[0].y == SYSMIS) ? 0 : os->k[0].y; + + if (os->k[0].c_p1 >= 1.0) + return (1 - ptl->g1_star) * a + ptl->g1_star * os->k[0].y_p1; + else + return (1 - ptl->g1) * a + ptl->g1 * os->k[0].y_p1; + } break; case PC_ROUND: { - double a = (os->k[0].y == SYSMIS) ? 0 : os->k[0].y; + double a = (os->k[0].y == SYSMIS) ? 0 : os->k[0].y; - if (os->k[0].c_p1 >= 1.0) - return (ptl->g1_star < 0.5) ? a : os->k[0].y_p1; - else - return (ptl->g1 < 0.5) ? a : os->k[0].y_p1; + if (os->k[0].c_p1 >= 1.0) + return (ptl->g1_star < 0.5) ? a : os->k[0].y_p1; + else + return (ptl->g1 < 0.5) ? a : os->k[0].y_p1; } break; case PC_EMPIRICAL: if (ptl->g1_star == 0) - return os->k[0].y; + return os->k[0].y; else - return os->k[0].y_p1; + return os->k[0].y_p1; break; case PC_HAVERAGE: if (ptl->g2_star >= 1.0) - { - return os->k[1].y_p1; - } + { + return os->k[1].y_p1; + } else - { - double a = (os->k[1].y == SYSMIS) ? 0 : os->k[1].y; - - if (os->k[1].c_p1 >= 1.0) - { - if (ptl->g2_star == 0) - return os->k[1].y; - - return (1 - ptl->g2_star) * a + ptl->g2_star * os->k[1].y_p1; - } - else - { - return (1 - ptl->g2) * a + ptl->g2 * os->k[1].y_p1; - } - } + { + double a = (os->k[1].y == SYSMIS) ? 0 : os->k[1].y; + + if (os->k[1].c_p1 >= 1.0) + { + if (ptl->g2_star == 0) + return os->k[1].y; + + return (1 - ptl->g2_star) * a + ptl->g2_star * os->k[1].y_p1; + } + else + { + return (1 - ptl->g2) * a + ptl->g2 * os->k[1].y_p1; + } + } break; case PC_AEMPIRICAL: if (ptl->g1_star == 0) - return (os->k[0].y + os->k[0].y_p1)/ 2.0; + return (os->k[0].y + os->k[0].y_p1)/ 2.0; else - return os->k[0].y_p1; + return os->k[0].y_p1; break; default: diff --git a/src/math/shapiro-wilk.c b/src/math/shapiro-wilk.c index c2c8da6a9b..6a5373c6f2 100644 --- a/src/math/shapiro-wilk.c +++ b/src/math/shapiro-wilk.c @@ -81,7 +81,7 @@ acc (struct statistic *s, const struct ccase *cx UNUSED, double c, if (frac_part != 0 && !sw->warned) { msg (MW, N_ ("One or more weight values are non-integer." - " Fractional parts will be ignored when calculating the Shapiro-Wilk statistic.")); + " Fractional parts will be ignored when calculating the Shapiro-Wilk statistic.")); sw->warned = true; } @@ -123,10 +123,10 @@ shapiro_wilk_create (int n, double mean) struct statistic *stat = &os->parent; const double c1[] = {0, 0.221157, -0.147981, - -2.071190, 4.434685, -2.706056}; + -2.071190, 4.434685, -2.706056}; const double c2[] = {0, 0.042981, -0.293762, - -1.752461, 5.682633, -3.582633}; + -1.752461, 5.682633, -3.582633}; sw->n = n; diff --git a/src/math/tukey-hinges.c b/src/math/tukey-hinges.c index b59b878ba6..1a5d01fcb8 100644 --- a/src/math/tukey-hinges.c +++ b/src/math/tukey-hinges.c @@ -40,22 +40,22 @@ tukey_hinges_calculate (const struct tukey_hinges *th, double hinge[3]) a[i] = a_star[i] / os->k[i].c_p1; if (a_star[i] < 1) - { - if (os->k[i].c_p1 >= 1) - { - hinge[i] = (1 - a_star[i]) * os->k[i].y - + a_star[i] * os->k[i].y_p1; - } - else - { - hinge[i] = (1 - a[i]) * os->k[i].y - + a[i] * os->k[i].y_p1; - } - } + { + if (os->k[i].c_p1 >= 1) + { + hinge[i] = (1 - a_star[i]) * os->k[i].y + + a_star[i] * os->k[i].y_p1; + } + else + { + hinge[i] = (1 - a[i]) * os->k[i].y + + a[i] * os->k[i].y_p1; + } + } else - { - hinge[i] = os->k[i].y_p1; - } + { + hinge[i] = os->k[i].y_p1; + } } } diff --git a/src/output/cairo-chart.c b/src/output/cairo-chart.c index 20488bb96e..c94a3ca00f 100644 --- a/src/output/cairo-chart.c +++ b/src/output/cairo-chart.c @@ -114,37 +114,37 @@ pango_layout_get_baseline (PangoLayout *layout) http://tango.freedesktop.org/static/cvs/tango-art-tools/palettes/Tango-Palette.gpl */ const struct xrchart_colour data_colour[XRCHART_N_COLOURS] = { - {252, 233, 79}, /* Butter 1 */ - {138, 226, 52}, /* Chameleon 1 */ - {252, 175, 62}, /* Orange 1 */ - {114, 159, 207}, /* Sky Blue 1 */ - {173, 127, 168}, /* Plum 1 */ - {233, 185, 110}, /* Chocolate 1 */ - {239, 41, 41}, /* Scarlet Red 1 */ - {238, 238, 236}, /* Aluminium 1 */ - - {237, 212, 0}, /* Butter 2 */ - {115, 210, 22}, /* Chameleon 2 */ - {245, 121, 0}, /* Orange 2 */ - {52, 101, 164}, /* Sky Blue 2 */ - {117, 80, 123}, /* Plum 2 */ - {193, 125, 17}, /* Chocolate 2 */ - {204, 0, 0}, /* Scarlet Red 2 */ - - {136, 138, 133}, /* Aluminium 4 */ - - {196, 160, 0}, /* Butter 3 */ - {78, 154, 6}, /* Chameleon 3 */ - {206, 92, 0}, /* Orange 3 */ - {32, 74, 135}, /* Sky Blue 3 */ - {92, 53, 102}, /* Plum 3 */ - {143, 89, 2}, /* Chocolate 3 */ - {164, 0, 0}, /* Scarlet Red 3 */ - {85, 87, 83}, /* Aluminium 5 */ - - {211, 215, 207}, /* Aluminium 2 */ - {186, 189, 182}, /* Aluminium 3 */ - {46, 52, 54}, /* Aluminium 6 */ + {252, 233, 79}, /* Butter 1 */ + {138, 226, 52}, /* Chameleon 1 */ + {252, 175, 62}, /* Orange 1 */ + {114, 159, 207}, /* Sky Blue 1 */ + {173, 127, 168}, /* Plum 1 */ + {233, 185, 110}, /* Chocolate 1 */ + {239, 41, 41}, /* Scarlet Red 1 */ + {238, 238, 236}, /* Aluminium 1 */ + + {237, 212, 0}, /* Butter 2 */ + {115, 210, 22}, /* Chameleon 2 */ + {245, 121, 0}, /* Orange 2 */ + {52, 101, 164}, /* Sky Blue 2 */ + {117, 80, 123}, /* Plum 2 */ + {193, 125, 17}, /* Chocolate 2 */ + {204, 0, 0}, /* Scarlet Red 2 */ + + {136, 138, 133}, /* Aluminium 4 */ + + {196, 160, 0}, /* Butter 3 */ + {78, 154, 6}, /* Chameleon 3 */ + {206, 92, 0}, /* Orange 3 */ + {32, 74, 135}, /* Sky Blue 3 */ + {92, 53, 102}, /* Plum 3 */ + {143, 89, 2}, /* Chocolate 3 */ + {164, 0, 0}, /* Scarlet Red 3 */ + {85, 87, 83}, /* Aluminium 5 */ + + {211, 215, 207}, /* Aluminium 2 */ + {186, 189, 182}, /* Aluminium 3 */ + {46, 52, 54}, /* Aluminium 6 */ }; void @@ -182,7 +182,7 @@ xrchart_draw_marker (cairo_t *cr, double x, double y, void xrchart_label_rotate (cairo_t *cr, int horz_justify, int vert_justify, - double font_size, const char *string, double angle) + double font_size, const char *string, double angle) { PangoFontDescription *desc; PangoLayout *layout; @@ -259,15 +259,15 @@ xrchart_label (cairo_t *cr, int horz_justify, int vert_justify, */ static void draw_tick_internal (cairo_t *cr, const struct xrchart_geometry *geom, - enum tick_orientation orientation, - bool rotated, - double position, - const char *s); + enum tick_orientation orientation, + bool rotated, + double position, + const char *s); void draw_tick (cairo_t *cr, const struct xrchart_geometry *geom, enum tick_orientation orientation, - bool rotated, + bool rotated, double position, const char *label, ...) { @@ -287,10 +287,10 @@ draw_tick (cairo_t *cr, const struct xrchart_geometry *geom, static void draw_tick_internal (cairo_t *cr, const struct xrchart_geometry *geom, - enum tick_orientation orientation, - bool rotated, - double position, - const char *s) + enum tick_orientation orientation, + bool rotated, + double position, + const char *s) { const int tickSize = 10; double x, y; @@ -318,12 +318,12 @@ draw_tick_internal (cairo_t *cr, const struct xrchart_geometry *geom, cairo_move_to (cr, x, y); if (orientation == SCALE_ABSCISSA) - { - 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); - } + { + 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); + } else if (orientation == SCALE_ORDINATE) { xrchart_label (cr, 'r', 'c', geom->font_size, s); @@ -354,8 +354,8 @@ xrchart_write_title (cairo_t *cr, const struct xrchart_geometry *geom, static void xrchart_text_extents (cairo_t *cr, const struct xrchart_geometry *geom, - const char *utf8, - double *width, double *height) + const char *utf8, + double *width, double *height) { PangoFontDescription *desc; PangoLayout *layout; @@ -378,7 +378,7 @@ xrchart_text_extents (cairo_t *cr, const struct xrchart_geometry *geom, static bool xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom, - double smin, double smax, enum tick_orientation orient) + double smin, double smax, enum tick_orientation orient) { int s; int ticks; @@ -404,7 +404,7 @@ xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom, struct xrchart_axis *axis = &geom->axis[orient]; geom->axis[orient].scale = (fabs ((double) axis->data_max - axis->data_min) - / fabs (axis->max - axis->min)); + / fabs (axis->max - axis->min)); if (orient == SCALE_ABSCISSA) { @@ -418,7 +418,7 @@ xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom, free(test_text); width = MAX(lower_txt_width, upper_txt_width); tickoversize = width > 0.9 * - ((double)(geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min))/(ticks+1); + ((double)(geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min))/(ticks+1); } double pos = lower; @@ -426,8 +426,8 @@ xrchart_write_scale (cairo_t *cr, struct xrchart_geometry *geom, for (s = 0 ; s <= ticks; ++s) { draw_tick (cr, geom, orient, tickoversize, - s * interval * geom->axis[orient].scale, - tick_format_string, pos*tickscale); + s * interval * geom->axis[orient].scale, + tick_format_string, pos*tickscale); pos += interval; } free(tick_format_string); @@ -446,7 +446,7 @@ xrchart_write_yscale (cairo_t *cr, struct xrchart_geometry *geom, /* Set the scale for the abscissa */ bool xrchart_write_xscale (cairo_t *cr, struct xrchart_geometry *geom, - double smin, double smax) + double smin, double smax) { return xrchart_write_scale (cr, geom, smin, smax, SCALE_ABSCISSA); } @@ -589,7 +589,7 @@ xrchart_vector (cairo_t *cr, struct xrchart_geometry *geom, double x, double y) void xrchart_line(cairo_t *cr, const struct xrchart_geometry *geom, double slope, double intercept, - double limit1, double limit2, enum xrchart_dim lim_dim) + double limit1, double limit2, enum xrchart_dim lim_dim) { double x1, y1; double x2, y2; @@ -701,8 +701,8 @@ xr_write_png_image (cairo_surface_t *surface, char * xr_draw_png_chart (const struct chart *chart, const char *file_name_template, int number, - const struct cell_color *fg, - const struct cell_color *bg) + const struct cell_color *fg, + const struct cell_color *bg) { cairo_surface_t *surface = xr_draw_image_chart (chart, fg, bg); char *file_name = xr_write_png_image (surface, file_name_template, number); @@ -713,8 +713,8 @@ xr_draw_png_chart (const struct chart *chart, char * xr_draw_eps_chart (const struct chart *chart, const char *file_name_template, int number, - const struct cell_color *fg, - const struct cell_color *bg) + const struct cell_color *fg, + const struct cell_color *bg) { const int width = 640; const int length = 480; diff --git a/src/output/cairo-chart.h b/src/output/cairo-chart.h index 18c242efce..088b3cfbfd 100644 --- a/src/output/cairo-chart.h +++ b/src/output/cairo-chart.h @@ -98,7 +98,7 @@ void xrchart_label (cairo_t *, int horz_justify, int vert_justify, double font_size, const char *); void xrchart_label_rotate (cairo_t *cr, int horz_justify, int vert_justify, - double font_size, const char *string, double angle); + double font_size, const char *string, double angle); /* Draw a tick mark at position @@ -106,8 +106,8 @@ void xrchart_label_rotate (cairo_t *cr, int horz_justify, int vert_justify, */ void draw_tick (cairo_t *, const struct xrchart_geometry *, enum tick_orientation orientation, - bool rotated, - double position, + bool rotated, + double position, const char *label, ...) PRINTF_FORMAT (6, 7); @@ -190,7 +190,7 @@ char *xr_write_png_image (cairo_surface_t *, char *xr_draw_png_chart (const struct chart *, const char *file_name_template, int number, const struct cell_color *fg, - const struct cell_color *bg); + const struct cell_color *bg); char *xr_draw_eps_chart (const struct chart *, const char *file_name_template, int number, diff --git a/src/output/cairo-fsm.c b/src/output/cairo-fsm.c index 5d9b60a443..43b74a0e0f 100644 --- a/src/output/cairo-fsm.c +++ b/src/output/cairo-fsm.c @@ -468,22 +468,22 @@ xrr_draw_cell (void *xr_, const struct table_cell *cell, int color_idx, cairo_save (xr->cairo); int bg_clip[TABLE_N_AXES][2]; for (int axis = 0; axis < TABLE_N_AXES; axis++) - { - bg_clip[axis][0] = clip[axis][0]; - if (bb[axis][0] == clip[axis][0]) - bg_clip[axis][0] -= spill[axis][0]; - - bg_clip[axis][1] = clip[axis][1]; - if (bb[axis][1] == clip[axis][1]) - bg_clip[axis][1] += spill[axis][1]; - } + { + bg_clip[axis][0] = clip[axis][0]; + if (bb[axis][0] == clip[axis][0]) + bg_clip[axis][0] -= spill[axis][0]; + + bg_clip[axis][1] = clip[axis][1]; + if (bb[axis][1] == clip[axis][1]) + bg_clip[axis][1] += spill[axis][1]; + } xr_clip (xr, bg_clip); xr_set_source_rgba (xr->cairo, bg); fill_rectangle (xr, - bb[H][0] - spill[H][0], - bb[V][0] - spill[V][0], - bb[H][1] + spill[H][1], - bb[V][1] + spill[V][1]); + bb[H][0] - spill[H][0], + bb[V][0] - spill[V][0], + bb[H][1] + spill[H][1], + bb[V][1] + spill[V][1]); cairo_restore (xr->cairo); } cairo_save (xr->cairo); diff --git a/src/output/charts/barchart-cairo.c b/src/output/charts/barchart-cairo.c index 4663471e56..e621568e8d 100644 --- a/src/output/charts/barchart-cairo.c +++ b/src/output/charts/barchart-cairo.c @@ -33,23 +33,23 @@ static void abscissa_label (const struct barchart *bc, cairo_t *cr, - struct xrchart_geometry *geom, - const union value *prev, - double x_pos, - double width, - int n_last_cat) + struct xrchart_geometry *geom, + const union value *prev, + double x_pos, + double width, + int n_last_cat) { struct category *foo = NULL; 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])) - break; + break; } draw_tick (cr, geom, SCALE_ABSCISSA, false, - x_pos - (width * n_last_cat) / 2.0, - "%s", ds_cstr (&foo->label)); + x_pos - (width * n_last_cat) / 2.0, + "%s", ds_cstr (&foo->label)); } @@ -83,41 +83,41 @@ xrchart_draw_barchart (const struct chart *chart, cairo_t *cr, 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, - 100, height); + geom->axis[SCALE_ABSCISSA].data_max + 10, + geom->axis[SCALE_ORDINATE].data_max - height, + 100, height); cairo_stroke (cr); int ypos = blob_size * 1.5; for (i = 0 ; i < hmap_count (&bc->secondaries) ; ++i) - { - const struct category *foo = bc->ss[i]; + { + const struct category *foo = bc->ss[i]; - cairo_move_to (cr, - geom->axis[SCALE_ABSCISSA].data_max + (1.5 * blob_size) + 20, - geom->axis[SCALE_ORDINATE].data_max - ypos); + 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)); + xrchart_label (cr, 'l', 'b', geom->font_size, ds_cstr (&foo->label)); - cairo_rectangle (cr, - geom->axis[SCALE_ABSCISSA].data_max + 20, - geom->axis[SCALE_ORDINATE].data_max - ypos, - blob_size, blob_size); + cairo_rectangle (cr, + geom->axis[SCALE_ABSCISSA].data_max + 20, + geom->axis[SCALE_ORDINATE].data_max - ypos, + blob_size, blob_size); - cairo_save (cr); - cairo_set_source_rgb (cr, - data_colour[foo->idx].red / 255.0, - data_colour[foo->idx].green / 255.0, - data_colour[foo->idx].blue / 255.0); - cairo_fill_preserve (cr); + cairo_save (cr); + cairo_set_source_rgb (cr, + data_colour[foo->idx].red / 255.0, + data_colour[foo->idx].green / 255.0, + data_colour[foo->idx].blue / 255.0); + cairo_fill_preserve (cr); - cairo_restore (cr); + cairo_restore (cr); - cairo_stroke (cr); + cairo_stroke (cr); - ypos += blob_size * 2; - } + ypos += blob_size * 2; + } } int n_last_cat = 0; @@ -125,42 +125,42 @@ xrchart_draw_barchart (const struct chart *chart, cairo_t *cr, { double height = geom->axis[SCALE_ORDINATE].scale * bc->cats[i]->count; if (bc->percent) - height *= 100.0 / bc->total_count ; + height *= 100.0 / bc->total_count ; if (prev && !value_equal (prev, &bc->cats[i]->values[0], bc->widths[0])) - { - abscissa_label (bc, cr, geom, prev, x_pos, width, n_last_cat); + { + abscissa_label (bc, cr, geom, prev, x_pos, width, n_last_cat); - x_pos += width; - n_last_cat = 0; - } + x_pos += width; + n_last_cat = 0; + } cairo_rectangle (cr, - geom->axis[SCALE_ABSCISSA].data_min + x_pos, - geom->axis[SCALE_ORDINATE].data_min, - width, height); + geom->axis[SCALE_ABSCISSA].data_min + x_pos, + geom->axis[SCALE_ORDINATE].data_min, + width, height); cairo_save (cr); int cidx = 0; if (bc->ss) - { - struct category *foo; - size_t hash = value_hash (&bc->cats[i]->values[1], bc->widths[1], 0); - HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bc->secondaries) - { - if (value_equal (&foo->val, &bc->cats[i]->values[1], bc->widths[1])) - { - cidx = foo->idx; - break; - } - } - } + { + struct category *foo; + size_t hash = value_hash (&bc->cats[i]->values[1], bc->widths[1], 0); + HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bc->secondaries) + { + if (value_equal (&foo->val, &bc->cats[i]->values[1], bc->widths[1])) + { + cidx = foo->idx; + break; + } + } + } cairo_set_source_rgb (cr, - data_colour[cidx].red / 255.0, - data_colour[cidx].green / 255.0, - data_colour[cidx].blue / 255.0); + data_colour[cidx].red / 255.0, + data_colour[cidx].green / 255.0, + data_colour[cidx].blue / 255.0); cairo_fill_preserve (cr); cairo_restore (cr); diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c index 6a8d091840..5cb7de9a20 100644 --- a/src/output/charts/barchart.c +++ b/src/output/charts/barchart.c @@ -130,10 +130,10 @@ barchart_dump (const struct barchart *bc, FILE *fp) { fprintf (fp, "Sub-categories:\n"); for (int i = 0; i < bc->n_nzcats / bc->n_pcats; ++i) - { - const struct category *cat = bc->ss[i]; - fprintf (fp, " %d \"%s\"\n", cat->idx, ds_cstr(&cat->label)); - } + { + const struct category *cat = bc->ss[i]; + fprintf (fp, " %d \"%s\"\n", cat->idx, ds_cstr(&cat->label)); + } } fprintf (fp, "All Categories:\n"); @@ -149,10 +149,10 @@ barchart_dump (const struct barchart *bc, FILE *fp) ds_clear (&s); if (bc->ss) - { - var_append_value_name (bc->var[1], &frq->values[1], &s); - fprintf (fp, ", \"%s\"", ds_cstr (&s)); - } + { + var_append_value_name (bc->var[1], &frq->values[1], &s); + fprintf (fp, ", \"%s\"", ds_cstr (&s)); + } ds_destroy (&s); fputc ('\n', fp); } @@ -172,8 +172,8 @@ barchart_dump (const struct barchart *bc, FILE *fp) */ struct chart * barchart_create (const struct variable **var, int n_vars, - const char *ylabel, bool percent, - struct freq *const *cats, int n_cats) + const char *ylabel, bool percent, + struct freq *const *cats, int n_cats) { int i; @@ -200,38 +200,38 @@ barchart_create (const struct variable **var, int n_vars, 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. + 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. */ for (i = 0; i < n_cats; i++) - { - const struct freq *src = cats[i]; - size_t hash = value_hash (&src->values[pidx], width, 0); - - struct category *foo; - int flag = 0; - HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bar->primaries) - { - if (value_equal (&foo->val, &src->values[pidx], width)) - { - flag = 1; - break; - } - } - - if (!flag) - { - struct category *s = XZALLOC (struct category); - s->idx = idx++; - s->width = var_get_width (var[pidx]); - value_init (&s->val, s->width); - value_copy (&s->val, &src->values[pidx], s->width); - ds_init_empty (&s->label); - var_append_value_name (var[pidx], &s->val, &s->label); - - hmap_insert (&bar->primaries, &s->node, hash); - } - } + { + const struct freq *src = cats[i]; + size_t hash = value_hash (&src->values[pidx], width, 0); + + struct category *foo; + int flag = 0; + HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bar->primaries) + { + if (value_equal (&foo->val, &src->values[pidx], width)) + { + flag = 1; + break; + } + } + + if (!flag) + { + struct category *s = XZALLOC (struct category); + s->idx = idx++; + s->width = var_get_width (var[pidx]); + value_init (&s->val, s->width); + value_copy (&s->val, &src->values[pidx], s->width); + ds_init_empty (&s->label); + var_append_value_name (var[pidx], &s->val, &s->label); + + hmap_insert (&bar->primaries, &s->node, hash); + } + } bar->n_pcats = hmap_count (&bar->primaries); } @@ -242,41 +242,41 @@ barchart_create (const struct variable **var, int n_vars, int idx = 0; /* Iterate the categories, and create a hash table of secondary categories */ for (i = 0; i < n_cats; i++) - { - struct freq *src = cats[i]; - - struct category *foo; - int flag = 0; - size_t hash = value_hash (&src->values[sidx], var_get_width (var[sidx]), 0); - HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bar->secondaries) - { - if (value_equal (&foo->val, &src->values[sidx], var_get_width (var[sidx]))) - { - flag = 1; - break; - } - } - - if (!flag) - { - struct category *s = XZALLOC (struct category); - s->idx = idx++; - s->width = var_get_width (var[sidx]); - value_init (&s->val, s->width); - value_copy (&s->val, &src->values[sidx], var_get_width (var[sidx])); - ds_init_empty (&s->label); - var_append_value_name (var[sidx], &s->val, &s->label); - - hmap_insert (&bar->secondaries, &s->node, hash); - bar->ss = xrealloc (bar->ss, idx * sizeof *bar->ss); - bar->ss[idx - 1] = s; - } - } + { + struct freq *src = cats[i]; + + struct category *foo; + int flag = 0; + size_t hash = value_hash (&src->values[sidx], var_get_width (var[sidx]), 0); + HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bar->secondaries) + { + if (value_equal (&foo->val, &src->values[sidx], var_get_width (var[sidx]))) + { + flag = 1; + break; + } + } + + if (!flag) + { + struct category *s = XZALLOC (struct category); + s->idx = idx++; + s->width = var_get_width (var[sidx]); + value_init (&s->val, s->width); + value_copy (&s->val, &src->values[sidx], var_get_width (var[sidx])); + ds_init_empty (&s->label); + var_append_value_name (var[sidx], &s->val, &s->label); + + hmap_insert (&bar->secondaries, &s->node, hash); + bar->ss = xrealloc (bar->ss, idx * sizeof *bar->ss); + bar->ss[idx - 1] = s; + } + } int n_category = hmap_count (&bar->secondaries); sort (bar->ss, n_category, sizeof *bar->ss, - compare_category_3way, bar); + compare_category_3way, bar); } @@ -297,37 +297,37 @@ barchart_create (const struct variable **var, int n_vars, for (i = 0; i < n_cats; i++) { - struct freq *c = cats[i]; - - struct freq *foo; - bool flag = false; - size_t hash = hash_freq_2level_ptr (&c, bar); - HMAP_FOR_EACH_WITH_HASH (foo, struct freq, node, hash, &level2table) - { - if (0 == compare_freq_2level_ptr_3way (&foo, &c, bar)) - { - foo->count += c->count; - bar->total_count += c->count; - - if (foo->count > bar->largest) - bar->largest = foo->count; - - flag = true; - break; - } - } - - if (!flag) - { - 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; - } + struct freq *c = cats[i]; + + struct freq *foo; + bool flag = false; + size_t hash = hash_freq_2level_ptr (&c, bar); + HMAP_FOR_EACH_WITH_HASH (foo, struct freq, node, hash, &level2table) + { + if (0 == compare_freq_2level_ptr_3way (&foo, &c, bar)) + { + foo->count += c->count; + bar->total_count += c->count; + + if (foo->count > bar->largest) + bar->largest = foo->count; + + flag = true; + break; + } + } + + if (!flag) + { + 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; + } } bar->n_nzcats = hmap_count (&level2table); @@ -335,7 +335,7 @@ barchart_create (const struct variable **var, int n_vars, } sort (bar->cats, bar->n_nzcats, sizeof *bar->cats, - compare_freq_2level_ptr_3way, bar); + compare_freq_2level_ptr_3way, bar); if (settings_get_testing_mode ()) barchart_dump (bar, stdout); diff --git a/src/output/charts/barchart.h b/src/output/charts/barchart.h index df27304c56..57261fc573 100644 --- a/src/output/charts/barchart.h +++ b/src/output/charts/barchart.h @@ -80,7 +80,7 @@ struct variable; struct freq; struct chart *barchart_create (const struct variable **, int n_vars, - const char *ylabel, bool percent, + const char *ylabel, bool percent, struct freq *const *, int n_cats); /* This boilerplate for barchart, a subclass of chart, was diff --git a/src/output/charts/boxplot-cairo.c b/src/output/charts/boxplot-cairo.c index 8448b2d6c4..9f1be79598 100644 --- a/src/output/charts/boxplot-cairo.c +++ b/src/output/charts/boxplot-cairo.c @@ -29,7 +29,7 @@ */ static void draw_case (cairo_t *cr, const struct xrchart_geometry *geom, double centreline, - const struct outlier *outlier) + const struct outlier *outlier) { double y = geom->axis[SCALE_ORDINATE].data_min + (outlier->value - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale; xrchart_draw_marker (cr, centreline, y, @@ -141,7 +141,7 @@ boxplot_draw_box (cairo_t *cr, const struct xrchart_geometry *geom, /* Draw tick mark on x axis */ draw_tick (cr, geom, SCALE_ABSCISSA, false, - box_centre - geom->axis[SCALE_ABSCISSA].data_min, "%s", name); + box_centre - geom->axis[SCALE_ABSCISSA].data_min, "%s", name); } void diff --git a/src/output/charts/piechart-cairo.c b/src/output/charts/piechart-cairo.c index 6c43670806..dd14dd5cb4 100644 --- a/src/output/charts/piechart-cairo.c +++ b/src/output/charts/piechart-cairo.c @@ -27,10 +27,10 @@ /* Draw a single slice of the pie */ static void draw_segment(cairo_t *cr, - double x0, double y0, - double radius, - double start_angle, double segment_angle, - const struct xrchart_colour *colour) + double x0, double y0, + double radius, + double start_angle, double segment_angle, + const struct xrchart_colour *colour) { cairo_move_to (cr, x0, y0); cairo_arc (cr, x0, y0, radius, start_angle, start_angle + segment_angle); @@ -78,7 +78,7 @@ xrchart_draw_piechart (const struct chart *chart, cairo_t *cr, for (i = 0; i < pie->n_slices ; ++i) { const double segment_angle = - pie->slices[i].magnitude / total_magnitude * 2 * M_PI ; + pie->slices[i].magnitude / total_magnitude * 2 * M_PI ; /* Fill the segment */ draw_segment (cr, @@ -99,32 +99,32 @@ xrchart_draw_piechart (const struct chart *chart, cairo_t *cr, for (i = 0; i < pie->n_slices ; ++i) { const double segment_angle = - pie->slices[i].magnitude / total_magnitude * 2 * M_PI ; + pie->slices[i].magnitude / total_magnitude * 2 * M_PI ; const double label_x = centre_x + - radius * cos (angle + segment_angle/2.0); + radius * cos (angle + segment_angle/2.0); const double label_y = centre_y + - radius * sin (angle + segment_angle/2.0); + radius * sin (angle + segment_angle/2.0); if (label_x < centre_x) - { + { cairo_move_to (cr, label_x, label_y); cairo_line_to (cr, left_label, label_y); cairo_stroke (cr); - cairo_move_to (cr, left_label, label_y + 5); - xrchart_label (cr, 'l', 'x', geom->font_size, + cairo_move_to (cr, left_label, label_y + 5); + xrchart_label (cr, 'l', 'x', geom->font_size, ds_cstr (&pie->slices[i].label)); - } + } else - { - cairo_move_to (cr, label_x, label_y); + { + cairo_move_to (cr, label_x, label_y); cairo_line_to (cr, right_label, label_y); cairo_stroke (cr); - cairo_move_to (cr, right_label, label_y + 5); - xrchart_label (cr, 'r', 'x', geom->font_size, + cairo_move_to (cr, right_label, label_y + 5); + xrchart_label (cr, 'r', 'x', geom->font_size, ds_cstr (&pie->slices[i].label)); - } + } angle += segment_angle; } diff --git a/src/output/charts/piechart.c b/src/output/charts/piechart.c index ad3b2eafd7..bf7de424f8 100644 --- a/src/output/charts/piechart.c +++ b/src/output/charts/piechart.c @@ -51,13 +51,13 @@ piechart_create (const struct variable *var, const struct freq *slices, int n_sl ds_init_empty (&dst->label); if (var_is_value_missing (var, &src->values[0])) - ds_assign_cstr (&dst->label, _("*MISSING*")); + ds_assign_cstr (&dst->label, _("*MISSING*")); else - var_append_value_name (var, &src->values[0], &dst->label); + var_append_value_name (var, &src->values[0], &dst->label); /* Chomp any whitespace from the RHS of the label. - Doing this ensures that those labels to the right - of the pie, appear right justified. */ + Doing this ensures that those labels to the right + of the pie, appear right justified. */ ds_rtrim (&dst->label, ss_cstr (" \t")); ds_ltrim (&dst->label, ss_cstr (" \t")); dst->magnitude = src->count; diff --git a/src/output/charts/plot-hist-cairo.c b/src/output/charts/plot-hist-cairo.c index c8f604af69..f5f109d168 100644 --- a/src/output/charts/plot-hist-cairo.c +++ b/src/output/charts/plot-hist-cairo.c @@ -96,8 +96,8 @@ hist_draw_bar (cairo_t *cr, const struct xrchart_geometry *geom, height = geom->axis[SCALE_ORDINATE].scale * gsl_histogram_get (h, bar); cairo_rectangle (cr, - x_pos, - geom->axis[SCALE_ORDINATE].data_min, + x_pos, + geom->axis[SCALE_ORDINATE].data_min, width, height); cairo_save (cr); cairo_set_source_rgb (cr, @@ -170,15 +170,15 @@ xrchart_draw_histogram (const struct chart *chart, cairo_t *cr, cairo_move_to (cr, geom->axis[SCALE_ABSCISSA].data_min, geom->axis[SCALE_ORDINATE].data_min); for (x = geom->axis[SCALE_ABSCISSA].min; - x <= geom->axis[SCALE_ABSCISSA].max; - x += (geom->axis[SCALE_ABSCISSA].max - geom->axis[SCALE_ABSCISSA].min) / 100.0) - { - const double y = gsl_ran_gaussian_pdf (x - h->mean, h->stddev) * ordinate_scale; - /* Transform to drawing coordinates */ - const double x_pos = (x - geom->axis[SCALE_ABSCISSA].min) * geom->axis[SCALE_ABSCISSA].scale + geom->axis[SCALE_ABSCISSA].data_min; - const double y_pos = (y - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale + geom->axis[SCALE_ORDINATE].data_min; + x <= geom->axis[SCALE_ABSCISSA].max; + x += (geom->axis[SCALE_ABSCISSA].max - geom->axis[SCALE_ABSCISSA].min) / 100.0) + { + const double y = gsl_ran_gaussian_pdf (x - h->mean, h->stddev) * ordinate_scale; + /* Transform to drawing coordinates */ + const double x_pos = (x - geom->axis[SCALE_ABSCISSA].min) * geom->axis[SCALE_ABSCISSA].scale + geom->axis[SCALE_ABSCISSA].data_min; + const double y_pos = (y - geom->axis[SCALE_ORDINATE].min) * geom->axis[SCALE_ORDINATE].scale + geom->axis[SCALE_ORDINATE].data_min; cairo_line_to (cr, x_pos, y_pos); - } + } cairo_stroke (cr); cairo_restore (cr); diff --git a/src/output/charts/roc-chart-cairo.c b/src/output/charts/roc-chart-cairo.c index bf6398460d..b4407b55bb 100644 --- a/src/output/charts/roc-chart-cairo.c +++ b/src/output/charts/roc-chart-cairo.c @@ -57,15 +57,15 @@ xrchart_draw_roc (const struct chart *chart, cairo_t *cr, xrchart_vector_start (cr, geom, rv->name); for (; (cc = casereader_read (r)) != NULL; case_unref (cc)) - { - double se = case_num_idx (cc, ROC_TP); - double sp = case_num_idx (cc, ROC_TN); + { + double se = case_num_idx (cc, ROC_TP); + double sp = case_num_idx (cc, ROC_TN); - se /= case_num_idx (cc, ROC_FN) + case_num_idx (cc, ROC_TP); - sp /= case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP); + se /= case_num_idx (cc, ROC_FN) + case_num_idx (cc, ROC_TP); + sp /= case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP); - xrchart_vector (cr, geom, 1 - sp, se); - } + xrchart_vector (cr, geom, 1 - sp, se); + } xrchart_vector_end (cr, geom); casereader_destroy (r); } diff --git a/src/output/charts/scatterplot-cairo.c b/src/output/charts/scatterplot-cairo.c index a6a499b868..ee7b8ad98a 100644 --- a/src/output/charts/scatterplot-cairo.c +++ b/src/output/charts/scatterplot-cairo.c @@ -32,7 +32,7 @@ static const struct xrchart_colour black = {0,0,0}; void xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr, - struct xrchart_geometry *geom) + struct xrchart_geometry *geom) { const struct scatterplot_chart *spc = to_scatterplot_chart (chart); struct casereader *data; @@ -63,35 +63,35 @@ xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr, for (; (c = casereader_read (data)) != NULL; case_unref (c)) { if (spc->byvar) - { - const union value *val = case_data_idx (c,SP_IDX_BY); - for(i=0;ibyvar,val)) - ds_put_cstr (&label,"missing"); - else - var_append_value_name (spc->byvar,val,&label); - value_clone (&catvals[n_catvals++],val,byvar_width); - geom->n_datasets++; - geom->dataset = xrealloc (geom->dataset, - geom->n_datasets * sizeof (*geom->dataset)); - - geom->dataset[geom->n_datasets - 1] = strdup (ds_cstr(&label)); - ds_destroy (&label); - } - else /* Use the last plot category */ - { - *(spc->byvar_overflow) = true; - i--; - } - } + { + const union value *val = case_data_idx (c,SP_IDX_BY); + for(i=0;ibyvar,val)) + ds_put_cstr (&label,"missing"); + else + var_append_value_name (spc->byvar,val,&label); + value_clone (&catvals[n_catvals++],val,byvar_width); + geom->n_datasets++; + geom->dataset = xrealloc (geom->dataset, + geom->n_datasets * sizeof (*geom->dataset)); + + geom->dataset[geom->n_datasets - 1] = strdup (ds_cstr(&label)); + ds_destroy (&label); + } + else /* Use the last plot category */ + { + *(spc->byvar_overflow) = true; + i--; + } + } colour = &data_colour[i % XRCHART_N_COLOURS]; - } + } else colour = &black; @@ -101,8 +101,8 @@ xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr, colour->blue / 255.0); xrchart_datum (cr, geom, 0, - case_num_idx (c, SP_IDX_X), - case_num_idx (c, SP_IDX_Y)); + case_num_idx (c, SP_IDX_X), + case_num_idx (c, SP_IDX_Y)); } casereader_destroy (data); cairo_restore (cr); diff --git a/src/output/charts/scatterplot.c b/src/output/charts/scatterplot.c index 5e8d27155e..324983466f 100644 --- a/src/output/charts/scatterplot.c +++ b/src/output/charts/scatterplot.c @@ -30,12 +30,12 @@ /* Creates a scatterplot */ struct scatterplot_chart * scatterplot_create (struct casereader *reader, - const char *xlabel, - const char *ylabel, - const struct variable *byvar, - bool *byvar_overflow, - const char *label, - double xmin, double xmax, double ymin, double ymax) + const char *xlabel, + const char *ylabel, + const struct variable *byvar, + bool *byvar_overflow, + const char *label, + double xmin, double xmax, double ymin, double ymax) { struct scatterplot_chart *spc = XZALLOC (struct scatterplot_chart); chart_init (&spc->chart, &scatterplot_chart_class, label); diff --git a/src/output/charts/scatterplot.h b/src/output/charts/scatterplot.h index cf549e9c1d..1692b481b6 100644 --- a/src/output/charts/scatterplot.h +++ b/src/output/charts/scatterplot.h @@ -46,12 +46,12 @@ struct scatterplot_chart struct scatterplot_chart * scatterplot_create (struct casereader *, - const char *xlabel, - const char *ylabel, - const struct variable *, - bool *, - const char *label, - double xmin, double xmax, double ymin, double ymax); + const char *xlabel, + const char *ylabel, + const struct variable *, + bool *, + const char *label, + double xmin, double xmax, double ymin, double ymax); /* This boilerplate for scatterplot_chart, a subclass of chart, was autogenerated by mk-class-boilerplate. */ diff --git a/src/output/driver.c b/src/output/driver.c index 6df9057a7d..64854d47d7 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -440,7 +440,7 @@ output_driver_get_engine (const struct output_driver *driver) ll_for_each (e, struct output_engine, ll, &engine_stack) { if (llx_find (llx_head (&e->drivers), llx_null (&e->drivers), driver)) - return e; + return e; } return NULL; diff --git a/src/output/html.c b/src/output/html.c index d3049e6564..5b798302d6 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -109,66 +109,66 @@ put_header (struct html_driver *html) if (html->css) { fputs ("\n", - html->file); + "\n" + "\n", + html->file); } fputs ("\n", html->file); fputs ("\n", html->file); diff --git a/src/output/journal.c b/src/output/journal.c index f708e6d787..c00d94ebd3 100644 --- a/src/output/journal.c +++ b/src/output/journal.c @@ -66,7 +66,7 @@ journal_close (void) { if (fwriteerror (journal.file)) msg_error (errno, _("error writing output file `%s'"), - journal.file_name); + journal.file_name); } journal.file = NULL; @@ -170,8 +170,8 @@ journal_enable (void) if (journal.file == NULL) { msg_error (errno, _("error opening output file `%s'"), - journal_get_file_name ()); - journal_close (); + journal_get_file_name ()); + journal_close (); } } } diff --git a/src/output/measure.c b/src/output/measure.c index 1ae1d31fa1..1c1f0de98b 100644 --- a/src/output/measure.c +++ b/src/output/measure.c @@ -249,11 +249,11 @@ read_paper_conf (const char *file_name, double *h, double *v) struct substring name; if (!ds_read_config_line (&line, &line_number, file)) - { - if (ferror (file)) - msg_error (errno, _("error reading file `%s'"), file_name); - break; - } + { + if (ferror (file)) + msg_error (errno, _("error reading file `%s'"), file_name); + break; + } name = ds_ss (&line); ss_trim (&name, ss_cstr (CC_SPACES)); diff --git a/src/output/odt.c b/src/output/odt.c index b0cf5cef9e..bd807ad5c5 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -118,13 +118,13 @@ write_style_data (struct odt_driver *odt) xmlTextWriterStartElement (w, _xml ("office:document-styles")); xmlTextWriterWriteAttribute (w, _xml ("xmlns:office"), - _xml ("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); + _xml ("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); xmlTextWriterWriteAttribute (w, _xml ("xmlns:style"), - _xml ("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); + _xml ("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); xmlTextWriterWriteAttribute (w, _xml ("xmlns:fo"), - _xml ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); + _xml ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); xmlTextWriterWriteAttribute (w, _xml ("office:version"), _xml ("1.1")); @@ -136,13 +136,13 @@ write_style_data (struct odt_driver *odt) { xmlTextWriterStartElement (w, _xml ("style:style")); xmlTextWriterWriteAttribute (w, _xml ("style:name"), - _xml ("Standard")); + _xml ("Standard")); xmlTextWriterWriteAttribute (w, _xml ("style:family"), - _xml ("paragraph")); + _xml ("paragraph")); xmlTextWriterWriteAttribute (w, _xml ("style:class"), - _xml ("text")); + _xml ("text")); xmlTextWriterEndElement (w); /* style:style */ } @@ -150,19 +150,19 @@ write_style_data (struct odt_driver *odt) { xmlTextWriterStartElement (w, _xml ("style:style")); xmlTextWriterWriteAttribute (w, _xml ("style:name"), - _xml ("Table_20_Contents")); + _xml ("Table_20_Contents")); xmlTextWriterWriteAttribute (w, _xml ("style:display-name"), - _xml ("Table Contents")); + _xml ("Table Contents")); xmlTextWriterWriteAttribute (w, _xml ("style:family"), - _xml ("paragraph")); + _xml ("paragraph")); xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"), - _xml ("Standard")); + _xml ("Standard")); xmlTextWriterWriteAttribute (w, _xml ("style:class"), - _xml ("extra")); + _xml ("extra")); xmlTextWriterEndElement (w); /* style:style */ } @@ -170,19 +170,19 @@ write_style_data (struct odt_driver *odt) { xmlTextWriterStartElement (w, _xml ("style:style")); xmlTextWriterWriteAttribute (w, _xml ("style:name"), - _xml ("Table_20_Heading")); + _xml ("Table_20_Heading")); xmlTextWriterWriteAttribute (w, _xml ("style:display-name"), - _xml ("Table Heading")); + _xml ("Table Heading")); xmlTextWriterWriteAttribute (w, _xml ("style:family"), - _xml ("paragraph")); + _xml ("paragraph")); xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"), - _xml ("Table_20_Contents")); + _xml ("Table_20_Contents")); xmlTextWriterWriteAttribute (w, _xml ("style:class"), - _xml ("extra")); + _xml ("extra")); xmlTextWriterStartElement (w, _xml ("style:text-properties")); @@ -309,7 +309,7 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, xmlTextWriterStartElement (odt->manifest_wtr, _xml("manifest:manifest")); xmlTextWriterWriteAttribute (odt->manifest_wtr, _xml("xmlns:manifest"), - _xml("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")); + _xml("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")); /* Add a manifest entry for the document as a whole */ @@ -329,13 +329,13 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, /* Some necessary junk at the start */ xmlTextWriterStartElement (odt->content_wtr, _xml("office:document-content")); xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:office"), - _xml("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); + _xml("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:text"), - _xml("urn:oasis:names:tc:opendocument:xmlns:text:1.0")); + _xml("urn:oasis:names:tc:opendocument:xmlns:text:1.0")); xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:table"), - _xml("urn:oasis:names:tc:opendocument:xmlns:table:1.0")); + _xml("urn:oasis:names:tc:opendocument:xmlns:table:1.0")); xmlTextWriterWriteAttribute (odt->content_wtr, _xml("office:version"), _xml("1.1")); @@ -485,7 +485,7 @@ write_table_layer (struct odt_driver *odt, const struct pivot_table *pt, /* Start table */ xmlTextWriterStartElement (odt->content_wtr, _xml("table:table")); xmlTextWriterWriteFormatAttribute (odt->content_wtr, _xml("table:name"), - "TABLE-%d", odt->table_num++); + "TABLE-%d", odt->table_num++); /* Start column definitions */ @@ -507,7 +507,7 @@ write_table_layer (struct odt_driver *odt, const struct pivot_table *pt, /* Write all the columns */ for (int c = 0 ; c < body->n[H] ; ++c) - { + { struct table_cell cell; table_get_cell (body, c, r, &cell); @@ -541,19 +541,19 @@ write_table_layer (struct odt_driver *odt, const struct pivot_table *pt, xmlTextWriterEndElement (odt->content_wtr); /* text:p */ xmlTextWriterEndElement (odt->content_wtr); /* table:table-cell */ - } - else - { - xmlTextWriterStartElement (odt->content_wtr, _xml("table:covered-table-cell")); - xmlTextWriterEndElement (odt->content_wtr); - } - } + } + else + { + xmlTextWriterStartElement (odt->content_wtr, _xml("table:covered-table-cell")); + xmlTextWriterEndElement (odt->content_wtr); + } + } xmlTextWriterEndElement (odt->content_wtr); /* row */ int ht = body->h[V][0]; if (ht > 0 && r == ht - 1) - xmlTextWriterEndElement (odt->content_wtr); /* table-header-rows */ + xmlTextWriterEndElement (odt->content_wtr); /* table-header-rows */ } xmlTextWriterEndElement (odt->content_wtr); /* table */ diff --git a/src/output/render.c b/src/output/render.c index dcb320a9d0..680e667325 100644 --- a/src/output/render.c +++ b/src/output/render.c @@ -949,10 +949,10 @@ render_page_unref (struct render_page *page) table_unref (page->table); for (int i = 0; i < TABLE_N_AXES; ++i) - { - free (page->join_crossing[i]); - free (page->cp[i]); - } + { + free (page->join_crossing[i]); + free (page->cp[i]); + } free (page); } @@ -1096,11 +1096,11 @@ render_rule (const struct render_page *page, const int ofs[TABLE_N_AXES], bb[H][0] = ofs[H] + page->cp[H][d[H]]; bb[H][1] = ofs[H] + page->cp[H][d[H] + 1]; if (page->params->rtl) - { - int temp = bb[H][0]; - bb[H][0] = render_page_get_size (page, H) - bb[H][1]; - bb[H][1] = render_page_get_size (page, H) - temp; - } + { + int temp = bb[H][0]; + bb[H][0] = render_page_get_size (page, H) - bb[H][1]; + bb[H][1] = render_page_get_size (page, H) - temp; + } bb[V][0] = ofs[V] + page->cp[V][d[V]]; bb[V][1] = ofs[V] + page->cp[V][d[V] + 1]; page->params->ops->draw_line (page->params->aux, bb, styles); diff --git a/src/output/table.h b/src/output/table.h index 1fe78d8e76..d8f77c0f00 100644 --- a/src/output/table.h +++ b/src/output/table.h @@ -223,12 +223,12 @@ struct table cell and the corresponding element of cc[] points to a struct table_cell. */ void **cc; /* Cell contents; void *[nr][nc]. */ - unsigned char *cp; /* Cell properties; unsigned char[nr][nc]. */ + unsigned char *cp; /* Cell properties; unsigned char[nr][nc]. */ struct table_area_style *styles[8]; /* Rules. */ - unsigned char *rh; /* Horiz rules; unsigned char[nr+1][nc]. */ - unsigned char *rv; /* Vert rules; unsigned char[nr][nc+1]. */ + unsigned char *rh; /* Horiz rules; unsigned char[nr+1][nc]. */ + unsigned char *rv; /* Vert rules; unsigned char[nr][nc+1]. */ struct table_border_style *borders; size_t n_borders; }; diff --git a/src/ui/gui/builder-wrapper.c b/src/ui/gui/builder-wrapper.c index 2f3cbdf9cf..0677c47fb7 100644 --- a/src/ui/gui/builder-wrapper.c +++ b/src/ui/gui/builder-wrapper.c @@ -61,7 +61,7 @@ get_object_assert (GtkBuilder *builder, const gchar *name, GType type) 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", - name, g_type_name (type), G_OBJECT_TYPE_NAME (o)); + name, g_type_name (type), G_OBJECT_TYPE_NAME (o)); } return o; diff --git a/src/ui/gui/dialog-common.c b/src/ui/gui/dialog-common.c index cdc0758cb3..d8795f971d 100644 --- a/src/ui/gui/dialog-common.c +++ b/src/ui/gui/dialog-common.c @@ -38,19 +38,19 @@ get_base_tree_path (GtkTreeModel *m, GtkTreePath *op) 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); - m = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (m)); - } + { + p = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (m), oldp); + m = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (m)); + } else if (GTK_IS_TREE_MODEL_SORT (m)) - { - p = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (m), oldp); - m = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (m)); - } + { + p = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (m), oldp); + m = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (m)); + } else - { - g_error ("Unexpected model type: %s", G_OBJECT_TYPE_NAME (m)); - } + { + g_error ("Unexpected model type: %s", G_OBJECT_TYPE_NAME (m)); + } gtk_tree_path_free (oldp); } @@ -173,10 +173,10 @@ numeric_only (GtkWidget *source, GtkWidget *dest) gtk_tree_path_free (p); if (var_is_alpha (v)) - { - retval = FALSE; - break; - } + { + retval = FALSE; + break; + } } g_list_foreach (list, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); @@ -203,7 +203,7 @@ set_sensitivity_from_toggle (GtkToggleButton *togglebutton, GtkWidget *w) /* */ void set_sensitivity_from_toggle_invert (GtkToggleButton *togglebutton, - GtkWidget *w) + GtkWidget *w) { gboolean active = gtk_toggle_button_get_active (togglebutton); diff --git a/src/ui/gui/dialog-common.h b/src/ui/gui/dialog-common.h index d32082477d..70ac2f453e 100644 --- a/src/ui/gui/dialog-common.h +++ b/src/ui/gui/dialog-common.h @@ -29,10 +29,10 @@ It renders the name of the variable into CELL. */ void XXX_cell_var_name (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data); + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data); /* Returns FALSE if the variables represented by the union of the rows diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index f8919de58f..f1a42bf38b 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -39,7 +39,7 @@ void get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter, - GtkTreeModel **model, GtkTreeIter *iter) + GtkTreeModel **model, GtkTreeIter *iter) { *model = top_model; @@ -50,40 +50,40 @@ get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter, { GtkTreeIter parent_iter; if (iter) - parent_iter = *iter; + parent_iter = *iter; if (GTK_IS_TREE_MODEL_FILTER (*model)) - { - GtkTreeModelFilter *parent_model = GTK_TREE_MODEL_FILTER (*model); + { + GtkTreeModelFilter *parent_model = GTK_TREE_MODEL_FILTER (*model); - *model = gtk_tree_model_filter_get_model (parent_model); + *model = gtk_tree_model_filter_get_model (parent_model); - if (iter) - gtk_tree_model_filter_convert_iter_to_child_iter (parent_model, - iter, - &parent_iter); - } + if (iter) + gtk_tree_model_filter_convert_iter_to_child_iter (parent_model, + iter, + &parent_iter); + } else if (GTK_IS_TREE_MODEL_SORT (*model)) - { - GtkTreeModelSort *parent_model = GTK_TREE_MODEL_SORT (*model); + { + GtkTreeModelSort *parent_model = GTK_TREE_MODEL_SORT (*model); - *model = gtk_tree_model_sort_get_model (parent_model); + *model = gtk_tree_model_sort_get_model (parent_model); - if (iter) - gtk_tree_model_sort_convert_iter_to_child_iter (parent_model, - iter, - &parent_iter); - } + if (iter) + gtk_tree_model_sort_convert_iter_to_child_iter (parent_model, + iter, + &parent_iter); + } } } void insert_source_row_into_entry (GtkTreeIter iter, - GtkWidget *dest, - GtkTreeModel *model, - gpointer data - ) + GtkWidget *dest, + GtkTreeModel *model, + gpointer data + ) { GtkTreePath *path; GtkTreeModel *dict; @@ -110,9 +110,9 @@ insert_source_row_into_entry (GtkTreeIter iter, static void insert_source_row_into_tree_model (GtkTreeIter source_iter, - GtkTreeModel *dest_model, - GtkTreeModel *source_model, - gpointer data) + GtkTreeModel *dest_model, + GtkTreeModel *source_model, + gpointer data) { GtkTreePath *path; GtkTreeIter dest_iter; @@ -141,9 +141,9 @@ insert_source_row_into_tree_model (GtkTreeIter source_iter, void insert_source_row_into_tree_view (GtkTreeIter iter, - GtkWidget *dest, - GtkTreeModel *model, - gpointer data) + GtkWidget *dest, + GtkTreeModel *model, + gpointer data) { GtkTreeModel *destmodel = gtk_tree_view_get_model (GTK_TREE_VIEW (dest)); @@ -153,9 +153,9 @@ insert_source_row_into_tree_view (GtkTreeIter iter, void insert_source_row_into_layers (GtkTreeIter iter, - GtkWidget *dest, - GtkTreeModel *model, - gpointer data) + GtkWidget *dest, + GtkTreeModel *model, + gpointer data) { GtkTreeModel *destmodel = psppire_means_layer_get_model (PSPPIRE_MEANS_LAYER (dest)); @@ -169,7 +169,7 @@ insert_source_row_into_layers (GtkTreeIter iter, gboolean is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, - PsppireSelector *selector) + PsppireSelector *selector) { gboolean result; GtkTreeIter dict_iter; diff --git a/src/ui/gui/dict-display.h b/src/ui/gui/dict-display.h index 2f9670f0ce..11d746cb7d 100644 --- a/src/ui/gui/dict-display.h +++ b/src/ui/gui/dict-display.h @@ -29,38 +29,38 @@ void get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter, - GtkTreeModel **model, GtkTreeIter *iter); + GtkTreeModel **model, GtkTreeIter *iter); /* A SelectItemsFunc function for GtkTreeView widgets */ void insert_source_row_into_tree_view (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data); + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data); /* A SelectItemsFunc function for PsppireMeansLayers widgets */ void insert_source_row_into_layers (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data); + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data); /* A SelectItemsFunc function for GtkEntry widgets */ void insert_source_row_into_entry (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data - ); + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data + ); /* A FilterItemsFunc function for GtkEntry widgets */ gboolean is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, - PsppireSelector *selector); + PsppireSelector *selector); /* A FilterItemsFunc function for PsppireVarview widgets */ gboolean is_currently_in_varview (GtkTreeModel *model, GtkTreeIter *iter, - PsppireSelector *sel); + PsppireSelector *sel); #endif diff --git a/src/ui/gui/dummy.c b/src/ui/gui/dummy.c index 93090636b6..89353bd980 100644 --- a/src/ui/gui/dummy.c +++ b/src/ui/gui/dummy.c @@ -71,7 +71,7 @@ psppire_data_store_value_to_string (gpointer unused, PsppireDataStore *store, gi gboolean psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row, - const gchar *in, GValue *out) + const gchar *in, GValue *out) { assert (0); return FALSE; diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index 6d5af138e8..72b6125180 100644 --- a/src/ui/gui/executor.c +++ b/src/ui/gui/executor.c @@ -135,14 +135,14 @@ execute_syntax (PsppireDataWindow *window, struct lex_reader *lex_reader) enum cmd_result result = cmd_parse (lexer, ds); if (cmd_result_is_failure (result)) - { - retval = FALSE; - if (lex_get_error_mode (lexer) == LEX_ERROR_STOP) - break; - } + { + retval = FALSE; + if (lex_get_error_mode (lexer) == LEX_ERROR_STOP) + break; + } if (result == CMD_EOF || result == CMD_FINISH) - break; + break; } session_for_each_dataset (the_session, name_dataset_cb, NULL); diff --git a/src/ui/gui/find-dialog.c b/src/ui/gui/find-dialog.c index d9d3a5f651..8db939a44a 100644 --- a/src/ui/gui/find-dialog.c +++ b/src/ui/gui/find-dialog.c @@ -65,7 +65,7 @@ struct find_dialog static void find_value (const struct find_dialog *fd, casenumber current_row, - casenumber *row, int *column); + casenumber *row, int *column); /* A callback which occurs whenever the "Refresh" button is clicked, @@ -87,7 +87,7 @@ refresh (GObject *obj, const struct find_dialog *fd) gtk_entry_set_text (GTK_ENTRY (fd->value_entry), ""); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->match_regexp_checkbox), - FALSE); + FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->match_substring_checkbox), FALSE); @@ -113,7 +113,7 @@ do_find (GObject *obj, const struct find_dialog *fd) if (x != -1) { gtk_notebook_set_current_page (GTK_NOTEBOOK (fd->de->data_editor), - PSPPIRE_DATA_EDITOR_DATA_VIEW); + PSPPIRE_DATA_EDITOR_DATA_VIEW); ssw_sheet_scroll_to (sheet, column, x); ssw_sheet_set_active_cell (sheet, column, x, NULL); @@ -133,17 +133,17 @@ on_select (GtkEntry *entry, gpointer data) g_return_if_fail (var); gtk_widget_set_sensitive (fd->value_labels_checkbox, - var_has_value_labels (var)); + var_has_value_labels (var)); search_labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->value_labels_checkbox)); gtk_widget_set_sensitive (fd->match_regexp_checkbox, - var_is_alpha (var) || search_labels); + var_is_alpha (var) || search_labels); gtk_widget_set_sensitive (fd->match_substring_checkbox, - var_is_alpha (var) || search_labels); + var_is_alpha (var) || search_labels); } /* Callback on the selector. @@ -169,10 +169,10 @@ value_labels_toggled (GtkToggleButton *tb, gpointer data) gboolean active = gtk_toggle_button_get_active (tb) ; gtk_widget_set_sensitive (fd->match_substring_checkbox, - active || (var && var_is_alpha (var))); + active || (var && var_is_alpha (var))); gtk_widget_set_sensitive (fd->match_regexp_checkbox, - active || (var && var_is_alpha (var))); + active || (var && var_is_alpha (var))); } /* Pops up the Find dialog box @@ -207,9 +207,9 @@ find_dialog (PsppireDataWindow *de) selector = get_widget_assert (fd.xml, "find-selector"); g_object_get (de->data_editor, - "dictionary", &fd.dict, - "data-store", &ds, - NULL); + "dictionary", &fd.dict, + "data-store", &ds, + NULL); fd.data = ds->datasheet; @@ -217,15 +217,15 @@ find_dialog (PsppireDataWindow *de) fd.value_entry = get_widget_assert (fd.xml, "find-value-entry"); fd.value_labels_checkbox = get_widget_assert (fd.xml, - "find-value-labels-checkbutton"); + "find-value-labels-checkbutton"); fd.match_regexp_checkbox = get_widget_assert (fd.xml, - "find-match-regexp-checkbutton"); + "find-match-regexp-checkbutton"); fd.match_substring_checkbox = get_widget_assert (fd.xml, - "find-match-substring-checkbutton"); + "find-match-substring-checkbutton"); @@ -233,25 +233,25 @@ find_dialog (PsppireDataWindow *de) g_object_set (source, "model", fd.dict, - "selection-mode", GTK_SELECTION_SINGLE, - NULL); + "selection-mode", GTK_SELECTION_SINGLE, + NULL); psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector), - is_currently_in_entry); + is_currently_in_entry); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &fd); g_signal_connect (find_button, "clicked", G_CALLBACK (do_find), &fd); g_signal_connect (selector, "selected", - G_CALLBACK (on_select), &fd); + G_CALLBACK (on_select), &fd); g_signal_connect (selector, "de-selected", - G_CALLBACK (on_deselect), &fd); + G_CALLBACK (on_deselect), &fd); g_signal_connect (fd.value_labels_checkbox, "toggled", - G_CALLBACK (value_labels_toggled), &fd); + G_CALLBACK (value_labels_toggled), &fd); psppire_dialog_run (PSPPIRE_DIALOG (dialog)); @@ -394,16 +394,16 @@ get_iteration_params (const struct find_dialog *fd) if (wrap) { if (reverse) - return &case_iterator[REVERSE_WRAP]; + return &case_iterator[REVERSE_WRAP]; else - return &case_iterator[FORWARD_WRAP]; + return &case_iterator[FORWARD_WRAP]; } else { if (reverse) - return &case_iterator[REVERSE]; + return &case_iterator[REVERSE]; else - return &case_iterator[FORWARD]; + return &case_iterator[FORWARD]; } } @@ -411,11 +411,11 @@ get_iteration_params (const struct find_dialog *fd) enum string_cmp_flags { STR_CMP_SUBSTR = 0x01, /* Find strings which are substrings of the - values */ + values */ STR_CMP_REGEXP = 0x02, /* Match against a regular expression */ STR_CMP_LABELS = 0x04 /* Match against the values' labels instead - of the data */ + of the data */ }; @@ -426,7 +426,7 @@ struct comparator enum string_cmp_flags flags; bool (*compare) (const struct comparator *, - const union value *); + const union value *); void (*destroy) (struct comparator *); }; @@ -470,7 +470,7 @@ int_pow10 (int x) static bool value_compare (const struct comparator *cmptr, - const union value *v) + const union value *v) { const struct numeric_comparator *nc = (const struct numeric_comparator *) cmptr; struct fmt_spec fs = var_get_print_format (cmptr->var); @@ -484,7 +484,7 @@ value_compare (const struct comparator *cmptr, /* Return true if the label of VAL matches the reference string*/ static bool string_label_compare (const struct comparator *cmptr, - const union value *val) + const union value *val) { const struct string_comparator *ssc = (const struct string_comparator *) cmptr; @@ -510,7 +510,7 @@ string_label_compare (const struct comparator *cmptr, /* Return true if VAL matches the reference string*/ static bool string_value_compare (const struct comparator *cmptr, - const union value *val) + const union value *val) { bool found; char *text; @@ -537,7 +537,7 @@ string_value_compare (const struct comparator *cmptr, /* Return true if VAL matched the regexp */ static bool regexp_value_compare (const struct comparator *cmptr, - const union value *val) + const union value *val) { char *text; bool retval; @@ -565,7 +565,7 @@ regexp_value_compare (const struct comparator *cmptr, /* Return true if the label of VAL matched the regexp */ static bool regexp_label_compare (const struct comparator *cmptr, - const union value *val) + const union value *val) { const char *text; const struct regexp_comparator *rec = @@ -615,7 +615,7 @@ numeric_comparator_create (const struct variable *var, const char *target) static struct comparator * string_comparator_create (const struct variable *var, const char *target, - enum string_cmp_flags flags) + enum string_cmp_flags flags) { struct string_comparator *ssc = XZALLOC (struct string_comparator); struct comparator *cmptr = &ssc->parent; @@ -636,7 +636,7 @@ string_comparator_create (const struct variable *var, const char *target, static struct comparator * regexp_comparator_create (const struct variable *var, const char *target, - enum string_cmp_flags flags) + enum string_cmp_flags flags) { int code; struct regexp_comparator *rec = XZALLOC (struct regexp_comparator); @@ -673,7 +673,7 @@ regexp_comparator_create (const struct variable *var, const char *target, /* Compare V against CMPTR's reference */ static bool comparator_compare (const struct comparator *cmptr, - const union value *v) + const union value *v) { return cmptr->compare (cmptr, v); } @@ -694,7 +694,7 @@ comparator_destroy (struct comparator *cmptr) static struct comparator * comparator_factory (const struct variable *var, const char *str, - enum string_cmp_flags flags) + enum string_cmp_flags flags) { if (flags & STR_CMP_REGEXP) return regexp_comparator_create (var, str, flags); @@ -712,7 +712,7 @@ comparator_factory (const struct variable *var, const char *str, */ static void find_value (const struct find_dialog *fd, casenumber current_row, - casenumber *row, int *column) + casenumber *row, int *column) { int width; const struct variable *var; @@ -754,16 +754,16 @@ find_value (const struct find_dialog *fd, casenumber current_row, goto finish; for (i = ip->start (current_row, fd->data); - i != ip->end (current_row, fd->data); - ip->next (&i, fd->data)) + i != ip->end (current_row, fd->data); + ip->next (&i, fd->data)) { - datasheet_get_value (fd->data, i, var_get_dict_index (var), &val); + datasheet_get_value (fd->data, i, var_get_dict_index (var), &val); - if (comparator_compare (cmptr, &val)) - { - *row = i; - break; - } + if (comparator_compare (cmptr, &val)) + { + *row = i; + break; + } } finish: diff --git a/src/ui/gui/goto-case-dialog.c b/src/ui/gui/goto-case-dialog.c index dfb059a4aa..8f4ea046ac 100644 --- a/src/ui/gui/goto-case-dialog.c +++ b/src/ui/gui/goto-case-dialog.c @@ -57,19 +57,19 @@ goto_case_dialog (PsppireDataSheet *ds) g_object_get (ds, "data-model", &tm, NULL); GtkWidget *case_num_entry = - get_widget_assert (xml, "goto-case-case-num-entry"); + get_widget_assert (xml, "goto-case-case-num-entry"); gint case_num = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry)) - - FIRST_CASE_NUMBER ; + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry)) + - FIRST_CASE_NUMBER ; gint case_count = gtk_tree_model_iter_n_children (tm, NULL); g_object_unref (tm); if (case_num >= 0 && case_num < case_count) { - ssw_sheet_scroll_to (SSW_SHEET (ds), -1, case_num); - ssw_sheet_set_active_cell (SSW_SHEET (ds), -1, case_num, 0); + ssw_sheet_scroll_to (SSW_SHEET (ds), -1, case_num); + ssw_sheet_set_active_cell (SSW_SHEET (ds), -1, case_num, 0); } } } diff --git a/src/ui/gui/help-menu.c b/src/ui/gui/help-menu.c index 646c47a383..e6dc4b5ebf 100644 --- a/src/ui/gui/help-menu.c +++ b/src/ui/gui/help-menu.c @@ -150,28 +150,28 @@ about_new (GtkMenuItem *mmm, GtkWindow *parent) gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (about), PACKAGE_URL); gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about), - announced_version); + announced_version); gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about), - (const gchar **) authors); + (const gchar **) authors); gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG (about), - artists); + artists); gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (about), - copyleft); + copyleft); gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (about), - _("A program for the analysis of sampled data")); + _("A program for the analysis of sampled data")); gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about), - "Free Software Foundation"); + "Free Software Foundation"); gtk_about_dialog_set_translator_credits ( GTK_ABOUT_DIALOG (about), /* TRANSLATORS: Do not translate this string. Instead, put the names of the people - who have helped in the translation. */ + who have helped in the translation. */ _("translator-credits") ); @@ -211,7 +211,7 @@ online_help (const char *page) which is valid for the multiple page html doc*/ tokens = g_strsplit (page, "#", maxtokens); for (idx = 0; idx < maxtokens && tokens[idx]; idx++) - ; + ; htmlfilename = xasprintf ("%s.html", tokens[idx-1]); g_strfreev (tokens); } @@ -279,9 +279,9 @@ create_help_menu (GtkWindow *toplevel) gtk_window_add_accel_group (toplevel, accel_group); gtk_widget_add_accelerator (help_ref, - "activate", accel_group, - GDK_KEY_F1, 0, - GTK_ACCEL_VISIBLE); + "activate", accel_group, + GDK_KEY_F1, 0, + GTK_ACCEL_VISIBLE); gtk_menu_attach (GTK_MENU (menu), help_ref, 0, 1, 0, 1); gtk_menu_attach (GTK_MENU (menu), help_system_info, 0, 1, 1, 2); diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 6d9fe60378..08a03a1d3a 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include "helper.h" @@ -94,8 +94,8 @@ value_to_text__ (union value v, struct fmt_spec format, const char *encoding) */ union value * text_to_value (const gchar *text, - const struct variable *var, - union value *val) + const struct variable *var, + union value *val) { return text_to_value__ (text, var_get_print_format (var), var_get_encoding (var), val); @@ -122,15 +122,15 @@ text_to_value__ (const gchar *text, if (! text) return NULL; { - const gchar *s = text; - while (*s) - { - if (!isspace (*s)) - break; - s++; - } - - if (!*s) return NULL; + const gchar *s = text; + while (*s) + { + if (!isspace (*s)) + break; + s++; + } + + if (!*s) return NULL; } } @@ -170,7 +170,7 @@ clone_list_store (const GtkListStore *src) dest = gtk_list_store_newv (n_cols, types); for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (src), - &src_iter); + &src_iter); ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (src), &src_iter)) { @@ -178,14 +178,14 @@ clone_list_store (const GtkListStore *src) gtk_list_store_append (dest, &dest_iter); for (i = 0 ; i < n_cols; ++i) - { - GValue val = {0}; + { + GValue val = {0}; - gtk_tree_model_get_value (GTK_TREE_MODEL (src), &src_iter, i, &val); - gtk_list_store_set_value (dest, &dest_iter, i, &val); + gtk_tree_model_get_value (GTK_TREE_MODEL (src), &src_iter, i, &val); + gtk_list_store_set_value (dest, &dest_iter, i, &val); - g_value_unset (&val); - } + g_value_unset (&val); + } } g_free (types); @@ -215,7 +215,7 @@ paste_syntax_to_window (gchar *syntax) { the_syntax_pasteboard = psppire_syntax_window_new (NULL); g_signal_connect (the_syntax_pasteboard, "delete-event", G_CALLBACK (on_delete), - &the_syntax_pasteboard); + &the_syntax_pasteboard); } buffer = GTK_TEXT_BUFFER (PSPPIRE_SYNTAX_WINDOW (the_syntax_pasteboard)->buffer); diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c index 946c607dde..07afa09a2d 100644 --- a/src/ui/gui/main.c +++ b/src/ui/gui/main.c @@ -144,19 +144,19 @@ on_local_options (GApplication * application, { GVariant *b = g_variant_dict_lookup_value (options, "no-unique", - G_VARIANT_TYPE_BOOLEAN); + G_VARIANT_TYPE_BOOLEAN); if (b) { - GApplicationFlags flags = g_application_get_flags (application); - flags |= G_APPLICATION_NON_UNIQUE; - g_application_set_flags (application, flags); - g_variant_unref (b); + GApplicationFlags flags = g_application_get_flags (application); + flags |= G_APPLICATION_NON_UNIQUE; + g_application_set_flags (application, flags); + g_variant_unref (b); } } { GVariant *b = g_variant_dict_lookup_value (options, "no-splash", - G_VARIANT_TYPE_BOOLEAN); + G_VARIANT_TYPE_BOOLEAN); if (b) g_variant_unref (b); else @@ -357,9 +357,9 @@ wait_for_splash (GApplication *app, GtkWindow *x) /* Remove the splash screen after SPLASH_DURATION milliseconds */ gint64 elapsed_time = (g_get_monotonic_time () - start_time) / 1000; if (SPLASH_DURATION - elapsed_time <= 0) - destroy_splash (wsplash); + destroy_splash (wsplash); else - g_timeout_add (SPLASH_DURATION - elapsed_time, destroy_splash, wsplash); + g_timeout_add (SPLASH_DURATION - elapsed_time, destroy_splash, wsplash); } } diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index 3ee221d761..0dfbd24927 100644 --- a/src/ui/gui/missing-val-dialog.c +++ b/src/ui/gui/missing-val-dialog.c @@ -181,10 +181,10 @@ err_dialog (const gchar *msg, GtkWindow *window) { GtkWidget *dialog = gtk_message_dialog_new (window, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s",msg); + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s",msg); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -212,14 +212,14 @@ try_missing_value(const PsppireMissingValDialog *dialog, const gchar *text, unio else { if (mv_is_acceptable (vp, var_width)) - return TRUE; + return TRUE; else - { - err_dialog (_("The maximum length of a missing value" - " for a string variable is 8 in UTF-8."), - GTK_WINDOW (dialog)); - goto error; - } + { + err_dialog (_("The maximum length of a missing value" + " for a string variable is 8 in UTF-8."), + GTK_WINDOW (dialog)); + goto error; + } } error: value_destroy (vp, var_width); @@ -242,35 +242,35 @@ missing_val_dialog_acceptable (gpointer data) mv_clear(&dialog->mvl); for(i = 0 ; i < 3 ; ++i) - { - gchar *text = - g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->mv[i]))); - - union value v; - if (!text || strlen (g_strstrip (text)) == 0) - { - g_free (text); - continue; - } - - if (!try_missing_value (dialog, text, &v)) - { - g_free (text); - gtk_widget_grab_focus (dialog->mv[i]); - return FALSE; - } - mv_add_value (&dialog->mvl, &v); - nvals++; - g_free (text); - value_destroy (&v, var_width); - } + { + gchar *text = + g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->mv[i]))); + + union value v; + if (!text || strlen (g_strstrip (text)) == 0) + { + g_free (text); + continue; + } + + if (!try_missing_value (dialog, text, &v)) + { + g_free (text); + gtk_widget_grab_focus (dialog->mv[i]); + return FALSE; + } + mv_add_value (&dialog->mvl, &v); + nvals++; + g_free (text); + value_destroy (&v, var_width); + } if (nvals == 0) - { - err_dialog (_("At least one value must be specified"), - GTK_WINDOW (dialog)); - gtk_widget_grab_focus (dialog->mv[0]); - return FALSE; - } + { + err_dialog (_("At least one value must be specified"), + GTK_WINDOW (dialog)); + gtk_widget_grab_focus (dialog->mv[0]); + return FALSE; + } } if (gtk_toggle_button_get_active (dialog->button_range)) @@ -284,25 +284,25 @@ missing_val_dialog_acceptable (gpointer data) assert (var_width == 0); /* Ranges are only for numeric variables */ if (!try_missing_value(dialog, low_text, &low_val)) - { - gtk_widget_grab_focus (dialog->low); - return FALSE; - } + { + gtk_widget_grab_focus (dialog->low); + return FALSE; + } if (!try_missing_value (dialog, high_text, &high_val)) - { - gtk_widget_grab_focus (dialog->high); - value_destroy (&low_val, var_width); - return FALSE; - } + { + gtk_widget_grab_focus (dialog->high); + value_destroy (&low_val, var_width); + return FALSE; + } if (low_val.f > high_val.f) - { - err_dialog (_("Incorrect range specification"), - GTK_WINDOW (dialog)); - value_destroy (&low_val, var_width); - value_destroy (&high_val, var_width); - gtk_widget_grab_focus (dialog->low); - return FALSE; - } + { + err_dialog (_("Incorrect range specification"), + GTK_WINDOW (dialog)); + value_destroy (&low_val, var_width); + value_destroy (&high_val, var_width); + gtk_widget_grab_focus (dialog->low); + return FALSE; + } mv_clear (&dialog->mvl); mv_add_range (&dialog->mvl, low_val.f, high_val.f); value_destroy (&low_val, var_width); @@ -311,17 +311,17 @@ missing_val_dialog_acceptable (gpointer data) discrete_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->discrete))); if (discrete_text && strlen (g_strstrip (discrete_text)) > 0) - { - union value discrete_val; - if (!try_missing_value (dialog, discrete_text, &discrete_val)) - { - g_free (discrete_text); - gtk_widget_grab_focus (dialog->discrete); - return FALSE; - } - mv_add_value (&dialog->mvl, &discrete_val); - value_destroy (&discrete_val, var_width); - } + { + union value discrete_val; + if (!try_missing_value (dialog, discrete_text, &discrete_val)) + { + g_free (discrete_text); + gtk_widget_grab_focus (dialog->discrete); + return FALSE; + } + mv_add_value (&dialog->mvl, &discrete_val); + value_destroy (&discrete_val, var_width); + } g_free (discrete_text); } @@ -342,7 +342,7 @@ discrete (GtkToggleButton *button, gpointer data) for (i = 0 ; i < 3 ; ++i) { gtk_widget_set_sensitive (dialog->mv[i], - gtk_toggle_button_get_active (button)); + gtk_toggle_button_get_active (button)); } } @@ -377,7 +377,7 @@ psppire_missing_val_dialog_constructor (GType type, dialog = PSPPIRE_MISSING_VAL_DIALOG (obj); g_object_set (dialog, "help-page", "Missing-Observations", - "title", _("Missing Values"), NULL); + "title", _("Missing Values"), NULL); content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog)); xml = builder_new ("missing-val-dialog.ui"); @@ -407,10 +407,10 @@ psppire_missing_val_dialog_constructor (GType type, dialog); g_signal_connect (dialog->button_discrete, "toggled", - G_CALLBACK (discrete), dialog); + G_CALLBACK (discrete), dialog); g_signal_connect (dialog->button_range, "toggled", - G_CALLBACK (range), dialog); + G_CALLBACK (range), dialog); g_object_unref (xml); @@ -431,9 +431,9 @@ psppire_missing_val_dialog_set_variable (PsppireMissingValDialog *dialog, { const struct missing_values *vmv = var_get_missing_values (var); if (mv_is_empty(vmv)) - mv_init (&dialog->mvl, var_get_width(var)); + mv_init (&dialog->mvl, var_get_width(var)); else - mv_copy (&dialog->mvl, vmv); + mv_copy (&dialog->mvl, vmv); dialog->encoding = g_strdup (var_get_encoding (var)); dialog->format = var_get_print_format (var); } @@ -454,7 +454,7 @@ psppire_missing_val_dialog_set_variable (PsppireMissingValDialog *dialog, var_type = val_type_from_width (fmt_var_width (dialog->format)); gtk_widget_set_sensitive (GTK_WIDGET (dialog->button_range), - var_type == VAL_NUMERIC); + var_type == VAL_NUMERIC); if (var == NULL) return; @@ -482,13 +482,13 @@ psppire_missing_val_dialog_set_variable (PsppireMissingValDialog *dialog, g_free (high_text); if (mv_has_value (&dialog->mvl)) - { - gchar *text; - text = value_to_text__ (*mv_get_value (&dialog->mvl, 0), + { + gchar *text; + text = value_to_text__ (*mv_get_value (&dialog->mvl, 0), dialog->format, dialog->encoding); - gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text); - g_free (text); - } + gtk_entry_set_text (GTK_ENTRY (dialog->discrete), text); + g_free (text); + } gtk_toggle_button_set_active (dialog->button_range, TRUE); gtk_widget_set_sensitive (dialog->low, TRUE); @@ -501,18 +501,18 @@ psppire_missing_val_dialog_set_variable (PsppireMissingValDialog *dialog, const int n = mv_n_values (&dialog->mvl); for (i = 0 ; i < 3 ; ++i) - { - if (i < n) - { - gchar *text ; + { + if (i < n) + { + gchar *text ; - text = value_to_text__ (*mv_get_value (&dialog->mvl, i), + text = value_to_text__ (*mv_get_value (&dialog->mvl, i), dialog->format, dialog->encoding); - gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text); - g_free (text); - } - gtk_widget_set_sensitive (dialog->mv[i], TRUE); - } + gtk_entry_set_text (GTK_ENTRY (dialog->mv[i]), text); + g_free (text); + } + gtk_widget_set_sensitive (dialog->mv[i], TRUE); + } gtk_toggle_button_set_active (dialog->button_discrete, TRUE); } else if (mv_is_empty (&dialog->mvl)) diff --git a/src/ui/gui/options-dialog.c b/src/ui/gui/options-dialog.c index 1890f069f4..435ff4f7c0 100644 --- a/src/ui/gui/options-dialog.c +++ b/src/ui/gui/options-dialog.c @@ -56,10 +56,10 @@ pspp_options_var_order_get_type (void) if (G_UNLIKELY(etype == 0)) { static const GEnumValue values[] = { - { PSPP_OPTIONS_VAR_ORDER_UNSORTED, "PSPP_OPTIONS_VAR_ORDER_UNSORTED", "unsorted" }, - { PSPP_OPTIONS_VAR_ORDER_NAME, "PSPP_OPTIONS_VAR_ORDER_NAME", "name" }, - { PSPP_OPTIONS_VAR_ORDER_LABEL, "PSPP_OPTIONS_VAR_ORDER_LABEL", "label" }, - { 0, NULL, NULL } + { PSPP_OPTIONS_VAR_ORDER_UNSORTED, "PSPP_OPTIONS_VAR_ORDER_UNSORTED", "unsorted" }, + { PSPP_OPTIONS_VAR_ORDER_NAME, "PSPP_OPTIONS_VAR_ORDER_NAME", "name" }, + { PSPP_OPTIONS_VAR_ORDER_LABEL, "PSPP_OPTIONS_VAR_ORDER_LABEL", "label" }, + { 0, NULL, NULL } }; etype = g_enum_register_static (g_intern_static_string ("PsppOptionsVarOrder"), values); } @@ -101,26 +101,26 @@ options_dialog (PsppireDataWindow *de) fd.conf = psppire_conf_new (); if (psppire_conf_get_boolean (fd.conf, - "VariableLists", "display-labels", &disp_labels)) + "VariableLists", "display-labels", &disp_labels)) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.show_labels), - disp_labels); + disp_labels); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.show_names), - !disp_labels); + !disp_labels); } if (psppire_conf_get_boolean (fd.conf, - "startup", "show-user-tips", &show_tips)) + "startup", "show-user-tips", &show_tips)) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.show_tips), - show_tips); + show_tips); } int what = -1; psppire_conf_get_enum (fd.conf, "VariableLists", "sort-order", - PSPP_TYPE_OPTIONS_VAR_ORDER, &what); + PSPP_TYPE_OPTIONS_VAR_ORDER, &what); switch (what) { @@ -138,7 +138,7 @@ options_dialog (PsppireDataWindow *de) { gboolean status; if (psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "maximize", - &status)) + &status)) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.maximize), status); } @@ -151,7 +151,7 @@ options_dialog (PsppireDataWindow *de) { gboolean status; if (psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "raise", - &status)) + &status)) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.raise), status); } @@ -163,41 +163,41 @@ options_dialog (PsppireDataWindow *de) gboolean sl = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd.show_labels)); psppire_conf_set_boolean (fd.conf, - "VariableLists", "display-labels", sl); + "VariableLists", "display-labels", sl); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd.sort_labels))) - { - sort_order = PSPP_OPTIONS_VAR_ORDER_LABEL; - } + { + sort_order = PSPP_OPTIONS_VAR_ORDER_LABEL; + } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd.sort_names))) - { - sort_order = PSPP_OPTIONS_VAR_ORDER_NAME; - } + { + sort_order = PSPP_OPTIONS_VAR_ORDER_NAME; + } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd.sort_none))) - { - sort_order = PSPP_OPTIONS_VAR_ORDER_UNSORTED; - } + { + sort_order = PSPP_OPTIONS_VAR_ORDER_UNSORTED; + } psppire_conf_set_enum (fd.conf, - "VariableLists", "sort-order", - PSPP_TYPE_OPTIONS_VAR_ORDER, - sort_order); + "VariableLists", "sort-order", + PSPP_TYPE_OPTIONS_VAR_ORDER, + sort_order); psppire_conf_set_boolean (fd.conf, "OutputWindowAction", "maximize", - gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (fd.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))); + gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (fd.raise))); psppire_conf_set_boolean (fd.conf, "OutputWindowAction", "alert", - gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (fd.alert))); + gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (fd.alert))); psppire_conf_set_boolean (fd.conf, "startup", "show-user-tips", - gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (fd.show_tips))); + gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (fd.show_tips))); } g_object_unref (fd.xml); diff --git a/src/ui/gui/psppire-acr.c b/src/ui/gui/psppire-acr.c index 0b397fe3dc..0cfffa9fcf 100644 --- a/src/ui/gui/psppire-acr.c +++ b/src/ui/gui/psppire-acr.c @@ -19,17 +19,17 @@ This widget is a GtkBox which looks roughly like: +-----------------------------+ - |+------------+ +----------+ | - || Add | | | | - |+------------+ | | | - | | | | - |+------------+ | | | - || Edit | | | | - |+------------+ | | | - | | | | - |+------------+ | | | - || Remove | | | | - |+------------+ +----------+ | + |+------------+ +----------+ | + || Add | | | | + |+------------+ | | | + | | | | + |+------------+ | | | + || Edit | | | | + |+------------+ | | | + | | | | + |+------------+ | | | + || Remove | | | | + |+------------+ +----------+ | +-----------------------------+ */ @@ -109,7 +109,7 @@ on_entry_change (GtkEntry *entry, PsppireAcr *acr) gtk_widget_set_sensitive (acr->add_button, acr->enabled (entry)); gtk_widget_set_sensitive (acr->change_button, acr->enabled (entry) - && row_is_selected (acr)); + && row_is_selected (acr)); } void @@ -141,10 +141,10 @@ on_add_button_clicked (PsppireAcr *acr) { static GValue value; if (! acr->get_value (i, &value, acr->get_value_data)) - continue; + continue; gtk_list_store_set_value (acr->list_store, &iter, - i, &value); + i, &value); g_value_unset (&value); } @@ -162,7 +162,7 @@ on_change_button_clicked (PsppireAcr *acr) GList *l= gtk_tree_selection_get_selected_rows (acr->selection, - &model); + &model); GtkTreePath *path = l->data; @@ -176,10 +176,10 @@ on_change_button_clicked (PsppireAcr *acr) { static GValue value; if (! acr->get_value (i, &value, acr->get_value_data)) - continue; + continue; gtk_list_store_set_value (acr->list_store, &iter, - i, &value); + i, &value); g_value_unset (&value); } @@ -199,7 +199,7 @@ on_remove_button_clicked (PsppireAcr *acr) GList *l= gtk_tree_selection_get_selected_rows (acr->selection, - &model); + &model); GtkTreePath *path = l->data; @@ -221,7 +221,7 @@ row_is_selected (const PsppireAcr *acr) gboolean result; GtkTreeModel *model = GTK_TREE_MODEL (acr->list_store); GList *l = gtk_tree_selection_get_selected_rows (acr->selection, - &model); + &model); result = (l != NULL); @@ -242,8 +242,8 @@ on_select (GtkTreeSelection *selection, gpointer data) gtk_widget_set_sensitive (acr->remove_button, row_is_selected (acr)); gtk_widget_set_sensitive (acr->change_button, - row_is_selected (acr) - ); + row_is_selected (acr) + ); } @@ -254,7 +254,7 @@ psppire_acr_set_enabled (PsppireAcr *acr, gboolean status) gtk_widget_set_sensitive (acr->add_button, status); gtk_widget_set_sensitive (acr->change_button, status - && row_is_selected (acr)); + && row_is_selected (acr)); } static void @@ -290,10 +290,10 @@ psppire_acr_init (PsppireAcr *acr) gtk_box_pack_start (GTK_BOX (acr), bb, FALSE, TRUE, 5); g_object_set (sw, - "hscrollbar-policy", GTK_POLICY_NEVER, - "vscrollbar-policy", GTK_POLICY_AUTOMATIC, - "shadow-type", GTK_SHADOW_ETCHED_IN, - NULL); + "hscrollbar-policy", GTK_POLICY_NEVER, + "vscrollbar-policy", GTK_POLICY_AUTOMATIC, + "shadow-type", GTK_SHADOW_ETCHED_IN, + NULL); gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (acr->tv)); @@ -301,11 +301,11 @@ psppire_acr_init (PsppireAcr *acr) g_signal_connect_swapped (acr->add_button, "clicked", - G_CALLBACK (on_add_button_clicked), acr); + G_CALLBACK (on_add_button_clicked), acr); g_signal_connect_swapped (acr->change_button, "clicked", - G_CALLBACK (on_change_button_clicked), acr); + G_CALLBACK (on_change_button_clicked), acr); g_signal_connect_swapped (acr->remove_button, "clicked", - G_CALLBACK (on_remove_button_clicked), acr); + G_CALLBACK (on_remove_button_clicked), acr); gtk_widget_show_all (bb); @@ -328,9 +328,9 @@ psppire_acr_init (PsppireAcr *acr) GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("value", - renderer, - "text", 0, - NULL); + renderer, + "text", 0, + NULL); gtk_tree_view_append_column (acr->tv, column); } @@ -359,7 +359,7 @@ psppire_acr_set_model (PsppireAcr *acr, GtkListStore *liststore) acr->list_store = liststore; gtk_tree_view_set_model (GTK_TREE_VIEW (acr->tv), - GTK_TREE_MODEL (liststore)); + GTK_TREE_MODEL (liststore)); gtk_widget_set_sensitive (GTK_WIDGET (acr), liststore != NULL); } @@ -374,7 +374,7 @@ psppire_acr_set_enable_func (PsppireAcr *acr, EnabledFunc func, gpointer p) void psppire_acr_set_get_value_func (PsppireAcr *acr, - GetValueFunc getvalue, gpointer data) + GetValueFunc getvalue, gpointer data) { acr->get_value_data = data; acr->get_value = getvalue; diff --git a/src/ui/gui/psppire-acr.h b/src/ui/gui/psppire-acr.h index c38f3f5f3a..a594056b0d 100644 --- a/src/ui/gui/psppire-acr.h +++ b/src/ui/gui/psppire-acr.h @@ -22,17 +22,17 @@ This widget is a GtkBox which looks roughly like: +-----------------------------+ - |+------------+ +----------+ | - || Add | | | | - |+------------+ | | | - | | | | - |+------------+ | | | - || Edit | | | | - |+------------+ | | | - | | | | - |+------------+ | | | - || Remove | | | | - |+------------+ +----------+ | + |+------------+ +----------+ | + || Add | | | | + |+------------+ | | | + | | | | + |+------------+ | | | + || Edit | | | | + |+------------+ | | | + | | | | + |+------------+ | | | + || Remove | | | | + |+------------+ +----------+ | +-----------------------------+ It interacts with an external widget, such as a GtkEntry. @@ -100,7 +100,7 @@ GtkWidget* psppire_acr_new (void); void psppire_acr_set_model (PsppireAcr *, GtkListStore *); void psppire_acr_set_get_value_func (PsppireAcr *, GetValueFunc, - gpointer); + gpointer); void psppire_acr_set_enable_func (PsppireAcr *, EnabledFunc, gpointer); diff --git a/src/ui/gui/psppire-buttonbox.c b/src/ui/gui/psppire-buttonbox.c index f47852211a..1aa80493b0 100644 --- a/src/ui/gui/psppire-buttonbox.c +++ b/src/ui/gui/psppire-buttonbox.c @@ -130,31 +130,31 @@ psppire_button_box_class_init (PsppireButtonBoxClass *class) button_flags = g_param_spec_flags ("buttons", - "Buttons", - "The mask that decides what buttons appear in the button box", - PSPPIRE_TYPE_BUTTON_MASK, - PSPPIRE_BUTTON_OK_MASK - | PSPPIRE_BUTTON_CANCEL_MASK - | PSPPIRE_BUTTON_CLOSE_MASK - | PSPPIRE_BUTTON_RESET_MASK - | PSPPIRE_BUTTON_HELP_MASK - | PSPPIRE_BUTTON_PASTE_MASK - | PSPPIRE_BUTTON_FIND_MASK, - G_PARAM_READWRITE); + "Buttons", + "The mask that decides what buttons appear in the button box", + PSPPIRE_TYPE_BUTTON_MASK, + PSPPIRE_BUTTON_OK_MASK + | PSPPIRE_BUTTON_CANCEL_MASK + | PSPPIRE_BUTTON_CLOSE_MASK + | PSPPIRE_BUTTON_RESET_MASK + | PSPPIRE_BUTTON_HELP_MASK + | PSPPIRE_BUTTON_PASTE_MASK + | PSPPIRE_BUTTON_FIND_MASK, + G_PARAM_READWRITE); g_object_class_install_property (object_class, - PROP_BUTTONS, - button_flags); + PROP_BUTTONS, + button_flags); default_flags = g_param_spec_flags ("default", - "Default", - "The mask that decides what button grabs the default", - PSPPIRE_TYPE_BUTTON_MASK, - 0, - G_PARAM_READWRITE); + "Default", + "The mask that decides what button grabs the default", + PSPPIRE_TYPE_BUTTON_MASK, + 0, + G_PARAM_READWRITE); g_object_class_install_property (object_class, - PROP_DEFAULT, - default_flags); + PROP_DEFAULT, + default_flags); } static void @@ -282,10 +282,10 @@ on_realize (GtkWidget *buttonbox, gpointer data) if (PSPPIRE_IS_DIALOG (toplevel)) { g_signal_connect (toplevel, "validity-changed", - G_CALLBACK (on_validity_change), buttonbox); + G_CALLBACK (on_validity_change), buttonbox); g_signal_connect (toplevel, "key-press-event", - G_CALLBACK (on_key_press), buttonbox); + G_CALLBACK (on_key_press), buttonbox); } set_default (PSPPIRE_BUTTON_BOX (buttonbox)); @@ -300,7 +300,7 @@ psppire_button_box_init (PsppireButtonBox *bb) bb->button[PSPPIRE_BUTTON_OK] = gtk_button_new_with_label (_("OK")); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_OK]); g_signal_connect (bb->button[PSPPIRE_BUTTON_OK], "clicked", - G_CALLBACK (ok_button_clicked), NULL); + G_CALLBACK (ok_button_clicked), NULL); g_object_set (bb->button[PSPPIRE_BUTTON_OK], "no-show-all", TRUE, NULL); @@ -308,7 +308,7 @@ psppire_button_box_init (PsppireButtonBox *bb) gtk_button_new_with_label (_("Go To")); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_GOTO]); g_signal_connect (bb->button[PSPPIRE_BUTTON_GOTO], "clicked", - G_CALLBACK (goto_button_clicked), NULL); + G_CALLBACK (goto_button_clicked), NULL); g_object_set (bb->button[PSPPIRE_BUTTON_GOTO], "no-show-all", TRUE, NULL); @@ -316,18 +316,18 @@ psppire_button_box_init (PsppireButtonBox *bb) gtk_button_new_with_mnemonic (_("Continue")); psppire_box_pack_start_defaults (GTK_BOX (bb), - bb->button[PSPPIRE_BUTTON_CONTINUE]); + bb->button[PSPPIRE_BUTTON_CONTINUE]); g_signal_connect (bb->button[PSPPIRE_BUTTON_CONTINUE], "clicked", - G_CALLBACK (continue_button_clicked), NULL); + G_CALLBACK (continue_button_clicked), NULL); g_object_set (bb->button[PSPPIRE_BUTTON_CONTINUE], - "no-show-all", TRUE, NULL); + "no-show-all", TRUE, NULL); bb->button[PSPPIRE_BUTTON_PASTE] = gtk_button_new_with_label (_("Paste")); g_signal_connect (bb->button[PSPPIRE_BUTTON_PASTE], "clicked", - G_CALLBACK (paste_button_clicked), NULL); + G_CALLBACK (paste_button_clicked), NULL); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_PASTE]); g_object_set (bb->button[PSPPIRE_BUTTON_PASTE], "no-show-all", TRUE, NULL); @@ -337,27 +337,27 @@ psppire_button_box_init (PsppireButtonBox *bb) bb->button[PSPPIRE_BUTTON_CANCEL] = gtk_button_new_with_label (_("Cancel")); g_signal_connect (bb->button[PSPPIRE_BUTTON_CANCEL], "clicked", - G_CALLBACK (close_dialog), NULL); + G_CALLBACK (close_dialog), NULL); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CANCEL]); g_object_set (bb->button[PSPPIRE_BUTTON_CANCEL], "no-show-all", TRUE, NULL); bb->button[PSPPIRE_BUTTON_CLOSE] = gtk_button_new_with_label (_("Close")); g_signal_connect (bb->button[PSPPIRE_BUTTON_CLOSE], "clicked", - G_CALLBACK (close_dialog), NULL); + G_CALLBACK (close_dialog), NULL); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CLOSE]); g_object_set (bb->button[PSPPIRE_BUTTON_CLOSE], "no-show-all", TRUE, NULL); bb->button[PSPPIRE_BUTTON_RESET] = gtk_button_new_with_label (_("Reset")); g_signal_connect (bb->button[PSPPIRE_BUTTON_RESET], "clicked", - G_CALLBACK (refresh_clicked), NULL); + G_CALLBACK (refresh_clicked), NULL); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_RESET]); g_object_set (bb->button[PSPPIRE_BUTTON_RESET], "no-show-all", TRUE, NULL); bb->button[PSPPIRE_BUTTON_HELP] = gtk_button_new_with_label (_("Help")); g_signal_connect (bb->button[PSPPIRE_BUTTON_HELP], "clicked", - G_CALLBACK (help_clicked), NULL); + G_CALLBACK (help_clicked), NULL); psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_HELP]); g_object_set (bb->button[PSPPIRE_BUTTON_HELP], "no-show-all", TRUE, NULL); @@ -390,21 +390,21 @@ psppire_button_flags_get_type (void) if (ftype == 0) { static const GFlagsValue values[] = - { - { PSPPIRE_BUTTON_OK_MASK, "PSPPIRE_BUTTON_OK_MASK", "Accept dialog and run it" }, - { PSPPIRE_BUTTON_GOTO_MASK, "PSPPIRE_BUTTON_GOTO_MASK", "Goto case/variable" }, - { PSPPIRE_BUTTON_CONTINUE_MASK,"PSPPIRE_BUTTON_CONTINUE_MASK", "Accept and close the subdialog" }, - { PSPPIRE_BUTTON_CANCEL_MASK, "PSPPIRE_BUTTON_CANCEL_MASK", "Close dialog and discard settings" }, - { PSPPIRE_BUTTON_CLOSE_MASK, "PSPPIRE_BUTTON_CLOSE_MASK", "Close dialog" }, - { PSPPIRE_BUTTON_HELP_MASK, "PSPPIRE_BUTTON_HELP_MASK", "Invoke context sensitive help" }, - { PSPPIRE_BUTTON_RESET_MASK, "PSPPIRE_BUTTON_RESET_MASK", "Restore dialog to its default settings" }, - { PSPPIRE_BUTTON_PASTE_MASK, "PSPPIRE_BUTTON_PASTE_MASK", "Accept dialog and paste syntax" }, - { PSPPIRE_BUTTON_FIND_MASK, "PSPPIRE_BUTTON_FIND_MASK", "Find something" }, - { 0, NULL, NULL } - }; + { + { PSPPIRE_BUTTON_OK_MASK, "PSPPIRE_BUTTON_OK_MASK", "Accept dialog and run it" }, + { PSPPIRE_BUTTON_GOTO_MASK, "PSPPIRE_BUTTON_GOTO_MASK", "Goto case/variable" }, + { PSPPIRE_BUTTON_CONTINUE_MASK,"PSPPIRE_BUTTON_CONTINUE_MASK", "Accept and close the subdialog" }, + { PSPPIRE_BUTTON_CANCEL_MASK, "PSPPIRE_BUTTON_CANCEL_MASK", "Close dialog and discard settings" }, + { PSPPIRE_BUTTON_CLOSE_MASK, "PSPPIRE_BUTTON_CLOSE_MASK", "Close dialog" }, + { PSPPIRE_BUTTON_HELP_MASK, "PSPPIRE_BUTTON_HELP_MASK", "Invoke context sensitive help" }, + { PSPPIRE_BUTTON_RESET_MASK, "PSPPIRE_BUTTON_RESET_MASK", "Restore dialog to its default settings" }, + { PSPPIRE_BUTTON_PASTE_MASK, "PSPPIRE_BUTTON_PASTE_MASK", "Accept dialog and paste syntax" }, + { PSPPIRE_BUTTON_FIND_MASK, "PSPPIRE_BUTTON_FIND_MASK", "Find something" }, + { 0, NULL, NULL } + }; ftype = g_flags_register_static - (g_intern_static_string ("PsppireButtonFlags"), values); + (g_intern_static_string ("PsppireButtonFlags"), values); } return ftype; diff --git a/src/ui/gui/psppire-checkbox-treeview.c b/src/ui/gui/psppire-checkbox-treeview.c index 5c543f22bb..6b4b63b6e8 100644 --- a/src/ui/gui/psppire-checkbox-treeview.c +++ b/src/ui/gui/psppire-checkbox-treeview.c @@ -88,9 +88,9 @@ static void psppire_checkbox_treeview_init (PsppireCheckboxTreeview *cbtv) { cbtv->list = GTK_TREE_MODEL (gtk_list_store_new (N_CHECKBOX_COLUMNS, - G_TYPE_STRING, - G_TYPE_BOOLEAN, - G_TYPE_STRING)); + G_TYPE_STRING, + G_TYPE_BOOLEAN, + G_TYPE_STRING)); gtk_tree_view_set_model (GTK_TREE_VIEW (cbtv), cbtv->list); g_object_unref (cbtv->list); @@ -107,9 +107,9 @@ psppire_checkbox_treeview_init (PsppireCheckboxTreeview *cbtv) */ void psppire_checkbox_treeview_populate (PsppireCheckboxTreeview *cbtv, - guint default_items, - gint n_items, - const struct checkbox_entry_item *items) + guint default_items, + gint n_items, + const struct checkbox_entry_item *items) { size_t i; for (i = 0; i < n_items; ++i) @@ -119,7 +119,7 @@ psppire_checkbox_treeview_populate (PsppireCheckboxTreeview *cbtv, gtk_list_store_set (GTK_LIST_STORE (cbtv->list), &iter, CHECKBOX_COLUMN_LABEL, gettext (items[i].label), CHECKBOX_COLUMN_SELECTED, (default_items & (1u << i)) != 0, - CHECKBOX_COLUMN_TOOLTIP, gettext (items[i].tooltip), + CHECKBOX_COLUMN_TOOLTIP, gettext (items[i].tooltip), -1); } diff --git a/src/ui/gui/psppire-checkbox-treeview.h b/src/ui/gui/psppire-checkbox-treeview.h index d18e62cec6..9906564c74 100644 --- a/src/ui/gui/psppire-checkbox-treeview.h +++ b/src/ui/gui/psppire-checkbox-treeview.h @@ -81,9 +81,9 @@ enum }; void psppire_checkbox_treeview_populate (PsppireCheckboxTreeview *pctv, - guint default_items, - gint n_items, - const struct checkbox_entry_item *items); + guint default_items, + gint n_items, + const struct checkbox_entry_item *items); G_END_DECLS diff --git a/src/ui/gui/psppire-conf.c b/src/ui/gui/psppire-conf.c index d0fc6e9de7..4540e32796 100644 --- a/src/ui/gui/psppire-conf.c +++ b/src/ui/gui/psppire-conf.c @@ -39,9 +39,9 @@ static void conf_read (PsppireConf *conf) { g_key_file_load_from_file (conf->keyfile, - conf->filename, - G_KEY_FILE_KEEP_COMMENTS, - NULL); + conf->filename, + G_KEY_FILE_KEEP_COMMENTS, + NULL); } static gboolean @@ -68,7 +68,7 @@ conf_write (PsppireConf *conf) { if (conf->idle == 0) conf->idle = g_idle_add_full (G_PRIORITY_LOW, - (GSourceFunc) flush_conf, conf, NULL); + (GSourceFunc) flush_conf, conf, NULL); } @@ -90,8 +90,8 @@ static PsppireConf *the_instance = NULL; static GObject* psppire_conf_construct (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) + guint n_construct_params, + GObjectConstructParam *construct_params) { GObject *object; @@ -153,14 +153,14 @@ psppire_conf_new (void) gboolean psppire_conf_get_int (PsppireConf *conf, const gchar *base, - const gchar *name, gint *value) + const gchar *name, gint *value) { gboolean ok; GError *err = NULL; conf_read (conf); *value = g_key_file_get_integer (conf->keyfile, - base, - name, &err); + base, + name, &err); ok = (err == NULL); if (err != NULL) @@ -171,15 +171,15 @@ psppire_conf_get_int (PsppireConf *conf, const gchar *base, gboolean psppire_conf_get_boolean (PsppireConf *conf, const gchar *base, - const gchar *name, gboolean *value) + const gchar *name, gboolean *value) { gboolean ok; gboolean b; GError *err = NULL; conf_read (conf); b = g_key_file_get_boolean (conf->keyfile, - base, - name, &err); + base, + name, &err); ok = (err == NULL); if (err != NULL) @@ -195,15 +195,15 @@ psppire_conf_get_boolean (PsppireConf *conf, const gchar *base, gboolean psppire_conf_get_string (PsppireConf *conf, const gchar *base, - const gchar *name, gchar **value) + const gchar *name, gchar **value) { gboolean ok; gchar *b; GError *err = NULL; conf_read (conf); b = g_key_file_get_string (conf->keyfile, - base, - name, &err); + base, + name, &err); ok = (err == NULL); if (err != NULL) @@ -220,15 +220,15 @@ psppire_conf_get_string (PsppireConf *conf, const gchar *base, gboolean psppire_conf_get_variant (PsppireConf *conf, const gchar *base, - const gchar *name, GVariant **v) + const gchar *name, GVariant **v) { gboolean ok; gchar *b; GError *err = NULL; conf_read (conf); b = g_key_file_get_string (conf->keyfile, - base, - name, &err); + base, + name, &err); ok = (err == NULL); if (err != NULL) @@ -245,17 +245,17 @@ psppire_conf_get_variant (PsppireConf *conf, const gchar *base, gboolean psppire_conf_get_enum (PsppireConf *conf, const gchar *base, - const gchar *name, - GType t, - int *v) + const gchar *name, + GType t, + int *v) { gboolean ok; gchar *b; GError *err = NULL; conf_read (conf); b = g_key_file_get_string (conf->keyfile, - base, - name, &err); + base, + name, &err); ok = (err == NULL); if (err != NULL) @@ -275,8 +275,8 @@ psppire_conf_get_enum (PsppireConf *conf, const gchar *base, void psppire_conf_set_int (PsppireConf *conf, - const gchar *base, const gchar *name, - gint value) + const gchar *base, const gchar *name, + gint value) { g_key_file_set_integer (conf->keyfile, base, name, value); conf_write (conf); @@ -284,8 +284,8 @@ psppire_conf_set_int (PsppireConf *conf, void psppire_conf_set_boolean (PsppireConf *conf, - const gchar *base, const gchar *name, - gboolean value) + const gchar *base, const gchar *name, + gboolean value) { g_key_file_set_boolean (conf->keyfile, base, name, value); conf_write (conf); @@ -294,8 +294,8 @@ psppire_conf_set_boolean (PsppireConf *conf, void psppire_conf_set_string (PsppireConf *conf, - const gchar *base, const gchar *name, - const gchar *value) + const gchar *base, const gchar *name, + const gchar *value) { g_key_file_set_string (conf->keyfile, base, name, value); conf_write (conf); @@ -303,8 +303,8 @@ psppire_conf_set_string (PsppireConf *conf, void psppire_conf_set_variant (PsppireConf *conf, - const gchar *base, const gchar *name, - GVariant *value) + const gchar *base, const gchar *name, + GVariant *value) { gchar *v = g_variant_print (value, FALSE); g_key_file_set_string (conf->keyfile, base, name, v); @@ -314,15 +314,15 @@ psppire_conf_set_variant (PsppireConf *conf, void psppire_conf_set_enum (PsppireConf *conf, - const gchar *base, const gchar *name, - GType enum_type, - int value) + const gchar *base, const gchar *name, + GType enum_type, + int value) { 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); + ev->value_nick); g_type_class_unref (ec); @@ -337,8 +337,8 @@ psppire_conf_set_enum (PsppireConf *conf, */ void psppire_conf_set_window_geometry (PsppireConf *conf, - const gchar *base, - GtkWindow *window) + const gchar *base, + GtkWindow *window) { gint height, width; gint x, y; @@ -361,9 +361,9 @@ psppire_conf_set_window_geometry (PsppireConf *conf, if (psppire_conf_get_boolean (conf, base, "maximize", &maximize)) { if (maximize) - gtk_window_maximize (window); + gtk_window_maximize (window); else - gtk_window_unmaximize (window); + gtk_window_unmaximize (window); } } @@ -375,8 +375,8 @@ psppire_conf_set_window_geometry (PsppireConf *conf, */ void psppire_conf_save_window_geometry (PsppireConf *conf, - const gchar *base, - GtkWindow *gtk_window) + const gchar *base, + GtkWindow *gtk_window) { gboolean maximized; GdkWindow *w; diff --git a/src/ui/gui/psppire-conf.h b/src/ui/gui/psppire-conf.h index de8db9397d..31f8d3d0c9 100644 --- a/src/ui/gui/psppire-conf.h +++ b/src/ui/gui/psppire-conf.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_CONF (psppire_conf_get_type ()) -#define PSPPIRE_CONF(obj) \ +#define PSPPIRE_CONF(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_CONF, PsppireConf)) + PSPPIRE_TYPE_CONF, PsppireConf)) #define PSPPIRE_CONF_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_CONF, \ + PSPPIRE_TYPE_CONF, \ PsppireConfClass)) #define PSPPIRE_IS_CONF(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_CONF)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_CONF)) #define PSPPIRE_IS_CONF_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_CONF)) #define PSPPIRE_CONF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_CONF, \ - PsppireConfClass)) + PSPPIRE_TYPE_CONF, \ + PsppireConfClass)) typedef struct _PsppireConf PsppireConf; typedef struct _PsppireConfClass PsppireConfClass; @@ -76,54 +76,54 @@ GType psppire_conf_get_type (void) G_GNUC_CONST; PsppireConf * psppire_conf_new (void); gboolean psppire_conf_get_int (PsppireConf *, - const gchar *, const gchar *, int *); + const gchar *, const gchar *, int *); gboolean psppire_conf_get_string (PsppireConf *, - const gchar *, const gchar *, gchar **); + const gchar *, const gchar *, gchar **); gboolean psppire_conf_get_boolean (PsppireConf *, - const gchar *, const gchar *, gboolean *); + const gchar *, const gchar *, gboolean *); gboolean psppire_conf_get_variant (PsppireConf *, - const gchar *, const gchar *, GVariant **); + const gchar *, const gchar *, GVariant **); gboolean psppire_conf_get_enum (PsppireConf *conf, const gchar *base, - const gchar *name, - GType t, - int *v); + const gchar *name, + GType t, + int *v); void psppire_conf_set_int (PsppireConf *conf, - const gchar *base, const gchar *name, - gint value); + const gchar *base, const gchar *name, + gint value); void psppire_conf_set_boolean (PsppireConf *conf, - const gchar *base, const gchar *name, - gboolean value); + const gchar *base, const gchar *name, + gboolean value); void psppire_conf_set_string (PsppireConf *conf, - const gchar *base, const gchar *name, - const gchar *value); + const gchar *base, const gchar *name, + const gchar *value); void psppire_conf_set_variant (PsppireConf *conf, - const gchar *base, const gchar *name, - GVariant *value); + const gchar *base, const gchar *name, + GVariant *value); void psppire_conf_set_enum (PsppireConf *conf, - const gchar *base, const gchar *name, - GType enum_type, - int value); + const gchar *base, const gchar *name, + GType enum_type, + int value); void psppire_conf_set_window_geometry (PsppireConf *conf, - const gchar *base, - GtkWindow *window); + const gchar *base, + GtkWindow *window); void psppire_conf_save_window_geometry (PsppireConf *, - const gchar *, - GtkWindow *); + const gchar *, + GtkWindow *); G_END_DECLS diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 1928e10820..6d9f069467 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -97,9 +97,9 @@ psppire_data_editor_refresh_model (PsppireDataEditor *de) static void psppire_data_editor_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (object); @@ -126,8 +126,8 @@ psppire_data_editor_set_property (GObject *object, psppire_data_editor_refresh_model (de); g_signal_connect_swapped (de->data_sheet, "selection-changed", - G_CALLBACK (refresh_entry), - de); + G_CALLBACK (refresh_entry), + de); g_signal_connect_swapped (de->data_store, "case-changed", G_CALLBACK (refresh_entry), de); @@ -144,13 +144,13 @@ psppire_data_editor_set_property (GObject *object, case PROP_VALUE_LABELS: { - gboolean l = g_value_get_boolean (value); - de->use_value_labels = l; - g_object_set (de->data_sheet, "forward-conversion", - l ? - psppire_data_store_value_to_string_with_labels : - psppire_data_store_value_to_string, - NULL); + gboolean l = g_value_get_boolean (value); + de->use_value_labels = l; + g_object_set (de->data_sheet, "forward-conversion", + l ? + psppire_data_store_value_to_string_with_labels : + psppire_data_store_value_to_string, + NULL); } break; @@ -162,9 +162,9 @@ psppire_data_editor_set_property (GObject *object, static void psppire_data_editor_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (object); @@ -190,7 +190,7 @@ psppire_data_editor_get_property (GObject *object, static void psppire_data_editor_switch_page (GtkNotebook *notebook, - GtkWidget *w, + GtkWidget *w, guint page_num) { GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num); @@ -243,9 +243,9 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) data_store_spec = g_param_spec_pointer ("data-store", - "Data Store", - "A pointer to the data store associated with this editor", - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE); + "Data Store", + "A pointer to the data store associated with this editor", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE); g_object_class_install_property (object_class, PROP_DATA_STORE, @@ -253,9 +253,9 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) dict_spec = g_param_spec_pointer ("dictionary", - "Dictionary", - "A pointer to the dictionary associated with this editor", - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE); + "Dictionary", + "A pointer to the dictionary associated with this editor", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE); g_object_class_install_property (object_class, PROP_DICTIONARY, @@ -263,10 +263,10 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) value_labels_spec = g_param_spec_boolean ("value-labels", - "Value Labels", - "Whether or not the data sheet should display labels instead of values", - FALSE, - G_PARAM_WRITABLE | G_PARAM_READABLE); + "Value Labels", + "Whether or not the data sheet should display labels instead of values", + FALSE, + G_PARAM_WRITABLE | G_PARAM_READABLE); g_object_class_install_property (object_class, PROP_VALUE_LABELS, @@ -275,10 +275,10 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) split_window_spec = g_param_spec_boolean ("split", - "Split Window", - "True iff the data sheet is split", - FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE); + "Split Window", + "True iff the data sheet is split", + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE); g_object_class_install_property (object_class, PROP_SPLIT_WINDOW, @@ -321,17 +321,17 @@ refresh_entry (PsppireDataEditor *de) union value val; const struct variable *var = psppire_dict_get_variable (de->dict, col); if (var == NULL) - return; + return; psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (de->datum_entry), var); int width = var_get_width (var); if (! psppire_data_store_get_value (PSPPIRE_DATA_STORE (de->data_store), - row, var, &val)) - return; + row, var, &val)) + return; psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (de->datum_entry), - &val, width); + &val, width); value_destroy (&val, width); } } @@ -345,15 +345,15 @@ on_datum_entry_activate (GtkEntry *entry, PsppireDataEditor *de) union value val; const struct variable *var = psppire_dict_get_variable (de->dict, col); if (var == NULL) - return; + return; int width = var_get_width (var); value_init (&val, width); if (psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (de->datum_entry), - &val, width)) - { - psppire_data_store_set_value (de->data_store, row, var, &val); - } + &val, width)) + { + psppire_data_store_set_value (de->data_store, row, var, &val); + } value_destroy (&val, width); gtk_widget_grab_focus (de->data_sheet); @@ -377,30 +377,30 @@ on_data_selection_change (PsppireDataEditor *de, SswRange *sel) const struct variable *var = psppire_dict_get_variable (de->dict, sel->start_x); if (var) - ref_cell_text = g_strdup_printf (_("%d : %s"), - sel->start_y + 1, var_get_name (var)); + ref_cell_text = g_strdup_printf (_("%d : %s"), + sel->start_y + 1, var_get_name (var)); } else { struct string s; /* The glib string library does not understand the ' printf modifier - on all platforms, but the "struct string" library does (because - Gnulib fixes that problem), so use the latter. */ + on all platforms, but the "struct string" library does (because + Gnulib fixes that problem), so use the latter. */ ds_init_empty (&s); ds_put_format (&s, ngettext ("%'d case", "%'d cases", n_cases), - n_cases); + n_cases); ds_put_byte (&s, ' '); ds_put_unichar (&s, 0xd7); /* U+00D7 MULTIPLICATION SIGN */ ds_put_byte (&s, ' '); ds_put_format (&s, ngettext ("%'d variable", "%'d variables", - n_vars), - n_vars); + n_vars), + n_vars); ref_cell_text = ds_steal_cstr (&s); } gtk_label_set_label (GTK_LABEL (de->cell_ref_label), - ref_cell_text ? ref_cell_text : ""); + ref_cell_text ? ref_cell_text : ""); g_free (ref_cell_text); } @@ -429,7 +429,7 @@ psppire_data_editor_var_delete_variables (PsppireDataEditor *de) } psppire_dict_delete_variables (de->dict, range->start_y, - (range->end_y - range->start_y + 1)); + (range->end_y - range->start_y + 1)); gtk_widget_queue_draw (GTK_WIDGET (de->var_sheet)); } @@ -471,7 +471,7 @@ psppire_data_editor_init (PsppireDataEditor *de) de->datum_entry = psppire_value_entry_new (); g_signal_connect (de->datum_entry, "edit-done", - G_CALLBACK (on_datum_entry_activate), de); + G_CALLBACK (on_datum_entry_activate), de); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (hbox), de->cell_ref_label, FALSE, FALSE, 0); @@ -489,10 +489,10 @@ psppire_data_editor_init (PsppireDataEditor *de) g_signal_connect_swapped (de->data_sheet, "selection-changed", - G_CALLBACK (on_data_selection_change), de); + G_CALLBACK (on_data_selection_change), de); gtk_notebook_append_page (GTK_NOTEBOOK (de), de->vbox, - gtk_label_new_with_mnemonic (_("Data View"))); + gtk_label_new_with_mnemonic (_("Data View"))); gtk_widget_show_all (de->vbox); @@ -502,7 +502,7 @@ psppire_data_editor_init (PsppireDataEditor *de) gtk_button_set_label (GTK_BUTTON (var_button), _("Variable")); gtk_notebook_append_page (GTK_NOTEBOOK (de), de->var_sheet, - gtk_label_new_with_mnemonic (_("Variable View"))); + gtk_label_new_with_mnemonic (_("Variable View"))); gtk_widget_show_all (de->var_sheet); @@ -515,8 +515,8 @@ psppire_data_editor_init (PsppireDataEditor *de) g_object_set (de, "can-focus", FALSE, NULL); if (psppire_conf_get_string (psppire_conf_new (), - "Data Editor", "font", - &fontname)) + "Data Editor", "font", + &fontname)) { de->font = pango_font_description_from_string (fontname); g_free (fontname); @@ -528,7 +528,7 @@ psppire_data_editor_init (PsppireDataEditor *de) GtkWidget* psppire_data_editor_new (PsppireDict *dict, - PsppireDataStore *data_store) + PsppireDataStore *data_store) { return g_object_new (PSPPIRE_DATA_EDITOR_TYPE, "dictionary", dict, @@ -574,8 +574,8 @@ set_font_recursively (GtkWidget *w, gpointer data) g_free (css); gtk_style_context_add_provider (style, - GTK_STYLE_PROVIDER (cssp), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + GTK_STYLE_PROVIDER (cssp), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (cssp); @@ -596,8 +596,8 @@ psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_ font_name = pango_font_description_to_string (de->font); psppire_conf_set_string (psppire_conf_new (), - "Data Editor", "font", - font_name); + "Data Editor", "font", + font_name); g_free (font_name); } @@ -619,13 +619,13 @@ psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index) switch (page) { case PSPPIRE_DATA_EDITOR_DATA_VIEW: - ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1); - ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), dict_index, -1, NULL); - break; + ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1); + ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), dict_index, -1, NULL); + break; case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW: - ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index); - ssw_sheet_set_active_cell (SSW_SHEET (de->var_sheet), -1, dict_index, NULL); - break; + ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index); + ssw_sheet_set_active_cell (SSW_SHEET (de->var_sheet), -1, dict_index, NULL); + break; } } @@ -633,7 +633,7 @@ psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index) */ static void store_set_datum (GtkTreeModel *model, gint col, gint row, - const GValue *value) + const GValue *value) { PsppireDataStore *store = PSPPIRE_DATA_STORE (model); GVariant *v = g_value_get_variant (value); @@ -650,7 +650,7 @@ psppire_data_editor_paste (PsppireDataEditor *de) SswSheet *sheet = SSW_SHEET (de->data_sheet); GtkClipboard *clip = gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (sheet)), - GDK_SELECTION_CLIPBOARD); + GDK_SELECTION_CLIPBOARD); ssw_sheet_paste (sheet, clip, store_set_datum); } diff --git a/src/ui/gui/psppire-data-sheet.c b/src/ui/gui/psppire-data-sheet.c index 8073bb0229..7de86975c4 100644 --- a/src/ui/gui/psppire-data-sheet.c +++ b/src/ui/gui/psppire-data-sheet.c @@ -109,7 +109,7 @@ change_data_value (PsppireDataSheet *sheet, gint col, gint row, GValue *value) static void show_cases_row_popup (PsppireDataSheet *sheet, int row, - guint button, guint state, gpointer p) + guint button, guint state, gpointer p) { GListModel *vmodel = NULL; g_object_get (sheet, "vmodel", &vmodel, NULL); @@ -125,7 +125,7 @@ show_cases_row_popup (PsppireDataSheet *sheet, int row, return; g_object_set_data (G_OBJECT (sheet->data_sheet_cases_row_popup), "item", - GINT_TO_POINTER (row)); + GINT_TO_POINTER (row)); gtk_menu_popup_at_pointer (GTK_MENU (sheet->data_sheet_cases_row_popup), NULL); } @@ -138,7 +138,7 @@ insert_new_case (PsppireDataSheet *sheet) g_object_get (sheet, "data-model", &data_store, NULL); gint posn = GPOINTER_TO_INT (g_object_get_data - (G_OBJECT (sheet->data_sheet_cases_row_popup), "item")); + (G_OBJECT (sheet->data_sheet_cases_row_popup), "item")); psppire_data_store_insert_new_case (data_store, posn); @@ -154,7 +154,7 @@ delete_cases (PsppireDataSheet *sheet) g_object_get (sheet, "data-model", &data_store, NULL); psppire_data_store_delete_cases (data_store, range->start_y, - range->end_y - range->start_y + 1); + range->end_y - range->start_y + 1); gtk_widget_queue_draw (GTK_WIDGET (sheet)); } @@ -181,7 +181,7 @@ create_data_row_header_popup_menu (PsppireDataSheet *sheet) gtk_widget_set_sensitive (sheet->data_clear_cases_menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), sheet->data_clear_cases_menu_item); g_signal_connect_swapped (sheet->data_clear_cases_menu_item, "activate", - G_CALLBACK (delete_cases), sheet); + G_CALLBACK (delete_cases), sheet); gtk_widget_show_all (menu); return menu; @@ -190,7 +190,7 @@ create_data_row_header_popup_menu (PsppireDataSheet *sheet) static void show_cases_column_popup (PsppireDataSheet *sheet, int column, guint button, guint state, - gpointer p) + gpointer p) { GListModel *hmodel = NULL; g_object_get (sheet, "hmodel", &hmodel, NULL); @@ -206,7 +206,7 @@ show_cases_column_popup (PsppireDataSheet *sheet, int column, guint button, guin return; g_object_set_data (G_OBJECT (sheet->data_sheet_cases_column_popup), "item", - GINT_TO_POINTER (column)); + GINT_TO_POINTER (column)); gtk_menu_popup_at_pointer (GTK_MENU (sheet->data_sheet_cases_column_popup), NULL); } @@ -214,16 +214,16 @@ show_cases_column_popup (PsppireDataSheet *sheet, int column, guint button, guin /* Insert a new variable before the variable at POSN. */ void psppire_data_sheet_insert_new_variable_at_posn (PsppireDataSheet *sheet, - gint posn) + gint posn) { PsppireDataStore *data_store = NULL; g_object_get (sheet, "data-model", &data_store, NULL); const struct variable *v = psppire_dict_insert_variable (data_store->dict, - posn, NULL); + posn, NULL); psppire_data_store_insert_value (data_store, var_get_width(v), - var_get_dict_index (v)); + var_get_dict_index (v)); ssw_sheet_scroll_to (SSW_SHEET (sheet), posn, -1); @@ -237,8 +237,8 @@ insert_new_variable (PsppireDataSheet *sheet) g_object_get (sheet, "data-model", &data_store, NULL); gint posn = GPOINTER_TO_INT (g_object_get_data - (G_OBJECT (sheet->data_sheet_cases_column_popup), - "item")); + (G_OBJECT (sheet->data_sheet_cases_column_popup), + "item")); psppire_data_sheet_insert_new_variable_at_posn (sheet, posn); } @@ -263,11 +263,11 @@ set_menu_items_sensitivity (PsppireDataSheet *sheet, gpointer selection, gpointe gboolean whole_column_selected = (range->start_y == 0 && range->end_y == length - 1); gtk_widget_set_sensitive (sheet->data_clear_variables_menu_item, - whole_column_selected); + whole_column_selected); gtk_widget_set_sensitive (sheet->data_sort_ascending_menu_item, - whole_column_selected); + whole_column_selected); gtk_widget_set_sensitive (sheet->data_sort_descending_menu_item, - whole_column_selected); + whole_column_selected); } void @@ -286,7 +286,7 @@ psppire_data_sheet_delete_variables (PsppireDataSheet *sheet) } psppire_dict_delete_variables (data_store->dict, range->start_x, - (range->end_x - range->start_x + 1)); + (range->end_x - range->start_x + 1)); ssw_sheet_scroll_to (SSW_SHEET (sheet), range->start_x, -1); @@ -305,7 +305,7 @@ create_data_column_header_popup_menu (PsppireDataSheet *sheet) GtkWidget *item = gtk_menu_item_new_with_mnemonic (_("_Insert Variable")); g_signal_connect_swapped (item, "activate", G_CALLBACK (insert_new_variable), - sheet); + sheet); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_separator_menu_item_new (); @@ -314,8 +314,8 @@ create_data_column_header_popup_menu (PsppireDataSheet *sheet) sheet->data_clear_variables_menu_item = gtk_menu_item_new_with_mnemonic (_("Cl_ear Variables")); g_signal_connect_swapped (sheet->data_clear_variables_menu_item, "activate", - G_CALLBACK (psppire_data_sheet_delete_variables), - sheet); + G_CALLBACK (psppire_data_sheet_delete_variables), + sheet); gtk_widget_set_sensitive (sheet->data_clear_variables_menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), sheet->data_clear_variables_menu_item); @@ -326,14 +326,14 @@ create_data_column_header_popup_menu (PsppireDataSheet *sheet) sheet->data_sort_ascending_menu_item = gtk_menu_item_new_with_mnemonic (_("Sort _Ascending")); g_signal_connect_swapped (sheet->data_sort_ascending_menu_item, "activate", - G_CALLBACK (sort_ascending), sheet); + G_CALLBACK (sort_ascending), sheet); gtk_widget_set_sensitive (sheet->data_sort_ascending_menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), sheet->data_sort_ascending_menu_item); sheet->data_sort_descending_menu_item = gtk_menu_item_new_with_mnemonic (_("Sort _Descending")); g_signal_connect_swapped (sheet->data_sort_descending_menu_item, "activate", - G_CALLBACK (sort_descending), sheet); + G_CALLBACK (sort_descending), sheet); gtk_widget_set_sensitive (sheet->data_sort_descending_menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), sheet->data_sort_descending_menu_item); @@ -463,16 +463,16 @@ set_dictionary (PsppireDataSheet *sheet) g_object_set (sheet, "hmodel", store->dict, NULL); g_signal_connect (store->dict, "resize-item", G_CALLBACK (resize_display_width), - sheet); + sheet); SswAxisModel *vmodel = NULL; g_object_get (sheet, "vmodel", &vmodel, NULL); g_assert (SSW_IS_AXIS_MODEL (vmodel)); g_object_set (vmodel, - "post-button-create-func", button_post_create, - "post-button-create-func-data", store, - NULL); + "post-button-create-func", button_post_create, + "post-button-create-func-data", store, + NULL); } static void @@ -508,19 +508,19 @@ psppire_data_sheet_init (PsppireDataSheet *sheet) create_data_row_header_popup_menu (sheet); g_signal_connect (sheet, "selection-changed", - G_CALLBACK (set_menu_items_sensitivity), sheet); + G_CALLBACK (set_menu_items_sensitivity), sheet); g_signal_connect (sheet, "column-header-pressed", - G_CALLBACK (show_cases_column_popup), sheet); + G_CALLBACK (show_cases_column_popup), sheet); g_signal_connect (sheet, "row-header-pressed", - G_CALLBACK (show_cases_row_popup), sheet); + G_CALLBACK (show_cases_row_popup), sheet); g_signal_connect (sheet, "value-changed", - G_CALLBACK (change_data_value), NULL); + G_CALLBACK (change_data_value), NULL); g_signal_connect (sheet, "notify::data-model", - G_CALLBACK (set_dictionary), NULL); + G_CALLBACK (set_dictionary), NULL); g_signal_connect (sheet, "column-moved", G_CALLBACK (move_variable), NULL); } diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 173bf0e10f..2b18358f5c 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -50,14 +50,14 @@ static void psppire_data_store_finalize (GObject *object); static void psppire_data_store_dispose (GObject *object); static gboolean psppire_data_store_insert_case (PsppireDataStore *ds, - struct ccase *cc, - casenumber posn); + struct ccase *cc, + casenumber posn); static gboolean psppire_data_store_data_in (PsppireDataStore *ds, - casenumber casenum, gint idx, - struct substring input, - struct fmt_spec); + casenumber casenum, gint idx, + struct substring input, + struct fmt_spec); static GObjectClass *parent_class = NULL; @@ -73,7 +73,7 @@ static guint signals [n_SIGNALS]; static gint __tree_model_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model); @@ -104,9 +104,9 @@ __tree_model_get_n_columns (GtkTreeModel *tree_model) static gboolean __iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n) + GtkTreeIter *iter, + GtkTreeIter *parent, + gint n) { PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model); @@ -130,16 +130,16 @@ __iter_nth_child (GtkTreeModel *tree_model, ROW, for MODEL. Returns TRUE if successful. */ gboolean psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row, - const gchar *in, GValue *out) + const gchar *in, GValue *out) { PsppireDataStore *store = PSPPIRE_DATA_STORE (model); while (col >= psppire_dict_get_n_vars (store->dict)) { const struct variable *var = - psppire_dict_insert_variable (store->dict, - psppire_dict_get_n_vars (store->dict), - NULL); + psppire_dict_insert_variable (store->dict, + psppire_dict_get_n_vars (store->dict), + NULL); g_return_val_if_fail (var, FALSE); } @@ -158,13 +158,13 @@ psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row, { vp = val_labs_find_value (value_labels, in); if (vp) - value_copy (&val, vp, width); + value_copy (&val, vp, width); } char *xx = NULL; if (vp == NULL) { xx = data_in (ss_cstr (in), psppire_dict_encoding (store->dict), - fmt.type, settings_get_fmt_settings (), + fmt.type, settings_get_fmt_settings (), &val, width, "UTF-8"); } @@ -233,9 +233,9 @@ psppire_data_store_value_to_string_with_labels (gpointer unused, PsppireDataStor static void __get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value) + GtkTreeIter *iter, + gint column, + GValue *value) { PsppireDataStore *store = PSPPIRE_DATA_STORE (tree_model); @@ -282,8 +282,8 @@ __tree_model_init (GtkTreeModelIface *iface) } G_DEFINE_TYPE_WITH_CODE (PsppireDataStore, psppire_data_store, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - __tree_model_init)) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + __tree_model_init)) static void psppire_data_store_class_init (PsppireDataStoreClass *class) @@ -298,27 +298,27 @@ psppire_data_store_class_init (PsppireDataStoreClass *class) signals [ITEMS_CHANGED] = g_signal_new ("items-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__UINT_UINT_UINT, - G_TYPE_NONE, - 3, - G_TYPE_UINT, /* Index of the start of the change */ - G_TYPE_UINT, /* The number of items deleted */ - G_TYPE_UINT); /* The number of items inserted */ + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + psppire_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, + 3, + G_TYPE_UINT, /* Index of the start of the change */ + G_TYPE_UINT, /* The number of items deleted */ + G_TYPE_UINT); /* The number of items inserted */ signals [CASE_CHANGED] = g_signal_new ("case-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); } @@ -410,7 +410,7 @@ resize_datum (const union value *old, union value *new, const void *aux_) static void variable_changed_callback (GObject *obj, gint var_num, guint what, const struct variable *oldvar, - gpointer data) + gpointer data) { PsppireDataStore *store = PSPPIRE_DATA_STORE (data); struct variable *variable = psppire_dict_get_variable (store->dict, var_num); @@ -464,7 +464,7 @@ psppire_data_store_new (PsppireDict *dict) void psppire_data_store_set_reader (PsppireDataStore *ds, - struct casereader *reader) + struct casereader *reader) { gint i; gint old_n = 0; @@ -481,11 +481,11 @@ psppire_data_store_set_reader (PsppireDataStore *ds, if (ds->dict) for (i = 0 ; i < n_dict_signals; ++i) { - if (ds->dict_handler_id [i] > 0) - { - g_signal_handler_unblock (ds->dict, - ds->dict_handler_id[i]); - } + if (ds->dict_handler_id [i] > 0) + { + g_signal_handler_unblock (ds->dict, + ds->dict_handler_id[i]); + } } g_signal_emit (ds, signals[ITEMS_CHANGED], 0, 0, old_n, new_n); @@ -509,8 +509,8 @@ psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *di if (data_store->dict) for (i = 0 ; i < n_dict_signals; ++i) { - g_signal_handler_disconnect (data_store->dict, - data_store->dict_handler_id[i]); + g_signal_handler_disconnect (data_store->dict, + data_store->dict_handler_id[i]); } data_store->dict = dict; @@ -519,24 +519,24 @@ psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *di { data_store->dict_handler_id [VARIABLE_INSERTED] = - g_signal_connect (dict, "variable-inserted", - G_CALLBACK (insert_variable_callback), - data_store); + g_signal_connect (dict, "variable-inserted", + G_CALLBACK (insert_variable_callback), + data_store); data_store->dict_handler_id [VARIABLES_DELETED] = - g_signal_connect (dict, "variables-deleted", - G_CALLBACK (delete_variables_callback), - data_store); + g_signal_connect (dict, "variables-deleted", + G_CALLBACK (delete_variables_callback), + data_store); data_store->dict_handler_id [VARIABLE_MOVED] = - g_signal_connect (dict, "variable-moved", - G_CALLBACK (move_variable_callback), - data_store); + g_signal_connect (dict, "variable-moved", + G_CALLBACK (move_variable_callback), + data_store); data_store->dict_handler_id [VARIABLE_CHANGED] = - g_signal_connect (dict, "variable-changed", - G_CALLBACK (variable_changed_callback), - data_store); + g_signal_connect (dict, "variable-changed", + G_CALLBACK (variable_changed_callback), + data_store); } @@ -546,11 +546,11 @@ psppire_data_store_set_dictionary (PsppireDataStore *data_store, PsppireDict *di if (data_store->dict) for (i = 0 ; i < n_dict_signals; ++i) { - if (data_store->dict_handler_id [i] > 0) - { - g_signal_handler_block (data_store->dict, - data_store->dict_handler_id[i]); - } + if (data_store->dict_handler_id [i] > 0) + { + g_signal_handler_block (data_store->dict, + data_store->dict_handler_id[i]); + } } } @@ -613,8 +613,8 @@ psppire_data_store_insert_new_case (PsppireDataStore *ds, casenumber posn) gboolean psppire_data_store_get_value (PsppireDataStore *store, - glong row, const struct variable *var, - union value *val) + glong row, const struct variable *var, + union value *val) { g_return_val_if_fail (store != NULL, FALSE); g_return_val_if_fail (store->datasheet != NULL, FALSE); @@ -669,7 +669,7 @@ psppire_data_store_get_string (PsppireDataStore *store, Returns true if anything was updated, false otherwise. */ gboolean psppire_data_store_set_string (PsppireDataStore *store, - const gchar *text, + const gchar *text, glong row, const struct variable *var, gboolean use_value_label) { @@ -726,8 +726,8 @@ psppire_data_store_get_reader (PsppireDataStore *ds) if (ds->dict) for (int i = 0 ; i < n_dict_signals; ++i) { - g_signal_handler_block (ds->dict, - ds->dict_handler_id[i]); + g_signal_handler_block (ds->dict, + ds->dict_handler_id[i]); } reader = datasheet_make_reader (ds->datasheet); @@ -742,7 +742,7 @@ psppire_data_store_get_reader (PsppireDataStore *ds) */ struct ccase * psppire_data_store_get_case (const PsppireDataStore *ds, - casenumber casenum) + casenumber casenum) { g_return_val_if_fail (ds, FALSE); g_return_val_if_fail (ds->datasheet, FALSE); @@ -753,13 +753,13 @@ psppire_data_store_get_case (const PsppireDataStore *ds, gboolean psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber first, - casenumber n_cases) + casenumber n_cases) { g_return_val_if_fail (ds, FALSE); g_return_val_if_fail (ds->datasheet, FALSE); g_return_val_if_fail (first + n_cases <= - psppire_data_store_get_case_count (ds), FALSE); + psppire_data_store_get_case_count (ds), FALSE); datasheet_delete_rows (ds->datasheet, first, n_cases); @@ -774,8 +774,8 @@ psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber first, /* Insert case CC into the case file before POSN */ static gboolean psppire_data_store_insert_case (PsppireDataStore *ds, - struct ccase *cc, - casenumber posn) + struct ccase *cc, + casenumber posn) { bool result ; @@ -801,7 +801,7 @@ psppire_data_store_insert_case (PsppireDataStore *ds, Returns true if successful, false on I/O error. */ gboolean psppire_data_store_set_value (PsppireDataStore *ds, casenumber casenum, - const struct variable *var, const union value *v) + const struct variable *var, const union value *v) { glong n_cases; bool ok; @@ -833,7 +833,7 @@ psppire_data_store_set_value (PsppireDataStore *ds, casenumber casenum, /* Set the IDXth value of case C using D_IN */ static gboolean psppire_data_store_data_in (PsppireDataStore *ds, casenumber casenum, gint idx, - struct substring input, struct fmt_spec fmt) + struct substring input, struct fmt_spec fmt) { union value value; int width; diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index 33d82395e0..ed13d31438 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -25,9 +25,9 @@ G_BEGIN_DECLS -#define PSPPIRE_TYPE_DATA_STORE (psppire_data_store_get_type ()) +#define PSPPIRE_TYPE_DATA_STORE (psppire_data_store_get_type ()) -#define PSPPIRE_DATA_STORE(obj) \ +#define PSPPIRE_DATA_STORE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ PSPPIRE_TYPE_DATA_STORE, PsppireDataStore)) @@ -90,17 +90,17 @@ PsppireDataStore *psppire_data_store_new (PsppireDict *dict); void psppire_data_store_set_reader (PsppireDataStore *ds, - struct casereader *reader); + struct casereader *reader); void psppire_data_store_set_dictionary (PsppireDataStore *data_store, - PsppireDict *dict); + PsppireDict *dict); void psppire_data_store_clear (PsppireDataStore *data_store); gboolean psppire_data_store_insert_new_case (PsppireDataStore *ds, casenumber posn); gboolean psppire_data_store_insert_value (PsppireDataStore *ds, - gint width, gint where); + gint width, gint where); gboolean psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber first, casenumber count); @@ -112,20 +112,20 @@ gchar *psppire_data_store_get_string (PsppireDataStore *, bool use_value_label); gchar * psppire_data_store_value_to_string (gpointer unused, PsppireDataStore *store, - gint col, gint row, - const GValue *v); + gint col, gint row, + const GValue *v); gchar * psppire_data_store_value_to_string_with_labels (gpointer unused, - PsppireDataStore *store, - gint col, gint row, - const GValue *v); + PsppireDataStore *store, + gint col, gint row, + const GValue *v); gboolean psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row, - const gchar *in, GValue *out); + const gchar *in, GValue *out); gboolean psppire_data_store_get_value (PsppireDataStore *store, - glong row, const struct variable *var, - union value *val); + glong row, const struct variable *var, + union value *val); gboolean psppire_data_store_set_value (PsppireDataStore *, casenumber casenum, @@ -134,13 +134,13 @@ gboolean psppire_data_store_set_value (PsppireDataStore *, gboolean psppire_data_store_set_string (PsppireDataStore *ds, - const gchar *text, - glong row, const struct variable *, + const gchar *text, + glong row, const struct variable *, gboolean use_value_label); gboolean psppire_data_store_filtered (PsppireDataStore *ds, - glong row); + glong row); casenumber psppire_data_store_get_case_count (const PsppireDataStore *ds); diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index d581f57ebb..fbb3c69e14 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -117,8 +117,8 @@ static void psppire_data_window_get_property (GObject *object, G_DEFINE_TYPE_WITH_CODE (PsppireDataWindow, psppire_data_window, PSPPIRE_TYPE_WINDOW, - G_IMPLEMENT_INTERFACE (PSPPIRE_TYPE_WINDOW_MODEL, - psppire_data_window_iface_init)) + G_IMPLEMENT_INTERFACE (PSPPIRE_TYPE_WINDOW_MODEL, + psppire_data_window_iface_init)) static GObjectClass *parent_class ; @@ -139,10 +139,10 @@ psppire_data_window_class_init (PsppireDataWindowClass *class) object_class->get_property = psppire_data_window_get_property; g_object_class_install_property ( - object_class, PROP_DATASET, - g_param_spec_pointer ("dataset", "Dataset", - "'struct datset *' represented by the window", - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + object_class, PROP_DATASET, + g_param_spec_pointer ("dataset", "Dataset", + "'struct datset *' represented by the window", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); } @@ -156,7 +156,7 @@ execute (PsppireDataWindow *dw) static void transformation_change_callback (bool transformations_pending, - gpointer data) + gpointer data) { PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); @@ -165,15 +165,15 @@ transformation_change_callback (bool transformations_pending, { GAction *action = g_action_map_lookup_action (G_ACTION_MAP (de), - "transform-pending"); + "transform-pending"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), - transformations_pending); + transformations_pending); } if (transformations_pending) gtk_label_set_text (GTK_LABEL (status_label), - _("Transformations Pending")); + _("Transformations Pending")); else gtk_label_set_text (GTK_LABEL (status_label), ""); } @@ -229,14 +229,14 @@ on_split_change (PsppireDict *dict, gpointer data) gint i; GString *text; const struct variable *const * split_vars = - dict_get_split_vars (dict->dict); + dict_get_split_vars (dict->dict); text = g_string_new (_("Split by ")); for (i = 0 ; i < n_split_vars - 1; ++i) - { - g_string_append_printf (text, "%s, ", var_get_name (split_vars[i])); - } + { + g_string_append_printf (text, "%s, ", var_get_name (split_vars[i])); + } g_string_append (text, var_get_name (split_vars[i])); gtk_label_set_text (GTK_LABEL (split_status_area), text->str); @@ -293,11 +293,11 @@ dump_rm (GtkRecentManager *rm) GtkRecentInfo *ri = i->data; g_print ("Item: %s (Mime: %s) (Desc: %s) (URI: %s)\n", - gtk_recent_info_get_short_name (ri), - gtk_recent_info_get_mime_type (ri), - gtk_recent_info_get_description (ri), - gtk_recent_info_get_uri (ri) - ); + gtk_recent_info_get_short_name (ri), + gtk_recent_info_get_mime_type (ri), + gtk_recent_info_get_description (ri), + gtk_recent_info_get_uri (ri) + ); gtk_recent_info_unref (ri); @@ -351,7 +351,7 @@ load_file (PsppireWindow *de, const gchar *file_name, const char *encoding, utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL); if (NULL == utf8_file_name) - return FALSE; + return FALSE; ds_init_empty (&filename); syntax_gen_string (&filename, ss_cstr (utf8_file_name)); @@ -377,9 +377,9 @@ load_file (PsppireWindow *de, const gchar *file_name, const char *encoding, if (ok && syn == NULL) { if (name_has_por_suffix (file_name)) - mime_type = "application/x-spss-por"; + mime_type = "application/x-spss-por"; else if (name_has_sav_suffix (file_name)) - mime_type = "application/x-spss-sav"; + mime_type = "application/x-spss-sav"; add_most_recent (file_name, mime_type, encoding); } @@ -454,12 +454,12 @@ sysfile_info (PsppireDataWindow *de) { struct string filename; gchar *file_name = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); gchar *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL); const gchar *encoding = psppire_encoding_selector_get_encoding ( - gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog))); + gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog))); gchar *syntax; @@ -492,11 +492,11 @@ data_pick_filename (PsppireWindow *window) GtkFileFilter *filter; GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Save"), - GTK_WINDOW (de), - GTK_FILE_CHOOSER_ACTION_SAVE, - _("Cancel"), GTK_RESPONSE_CANCEL, - _("Save"), GTK_RESPONSE_ACCEPT, - NULL); + GTK_WINDOW (de), + GTK_FILE_CHOOSER_ACTION_SAVE, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("Save"), GTK_RESPONSE_ACCEPT, + NULL); g_object_set (dialog, "local-only", FALSE, NULL); @@ -571,11 +571,11 @@ data_pick_filename (PsppireWindow *window) { case GTK_RESPONSE_ACCEPT: { - GString *filename = - g_string_new - ( - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)) - ); + GString *filename = + g_string_new + ( + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)) + ); GtkTreeIter iter; int format; @@ -584,15 +584,15 @@ data_pick_filename (PsppireWindow *window) gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, 0, &format, -1); - de->format = format; + de->format = format; - if (! name_has_suffix (filename->str)) + if (! name_has_suffix (filename->str)) g_string_append (filename, psppire_data_window_format_to_string (format)); - psppire_window_set_filename (PSPPIRE_WINDOW (de), filename->str); + psppire_window_set_filename (PSPPIRE_WINDOW (de), filename->str); - g_string_free (filename, TRUE); + g_string_free (filename, TRUE); } break; default: @@ -612,14 +612,14 @@ confirm_delete_dataset (PsppireDataWindow *de, int result; dialog = gtk_message_dialog_new ( - GTK_WINDOW (de), 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", - _("Delete Existing Dataset?")); + GTK_WINDOW (de), 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", + _("Delete Existing Dataset?")); gtk_message_dialog_format_secondary_text ( - GTK_MESSAGE_DIALOG (dialog), - _("Renaming \"%s\" to \"%s\" will destroy the existing " - "dataset named \"%s\". Are you sure that you want to do this?"), - old_dataset, new_dataset, existing_dataset); + GTK_MESSAGE_DIALOG (dialog), + _("Renaming \"%s\" to \"%s\" will destroy the existing " + "dataset named \"%s\". Are you sure that you want to do this?"), + old_dataset, new_dataset, existing_dataset); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Cancel"), GTK_RESPONSE_CANCEL, @@ -761,7 +761,7 @@ fonts_activate (PsppireDataWindow *de) gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (dialog), current_font); gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (toplevel)); + GTK_WINDOW (toplevel)); if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog))) { @@ -789,7 +789,7 @@ value_labels_activate (GAction *action, GVariant *param, PsppireDataWindow *de 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); + labels_active); } static void @@ -808,7 +808,7 @@ on_labels_button_toggle (GtkToggleToolButton *ttb, PsppireDataWindow *de) static void on_recent_data_select (GtkMenuShell *menushell, - PsppireWindow *window) + PsppireWindow *window) { gchar *file; @@ -940,9 +940,9 @@ file_import (PsppireDataWindow *dw) { case GTK_RESPONSE_APPLY: { - gchar *fn = g_path_get_basename (asst->file_name); - open_data_window (PSPPIRE_WINDOW (dw), fn, NULL, psppire_import_assistant_generate_syntax (asst)); - g_free (fn); + gchar *fn = g_path_get_basename (asst->file_name); + open_data_window (PSPPIRE_WINDOW (dw), fn, NULL, psppire_import_assistant_generate_syntax (asst)); + g_free (fn); } break; case PSPPIRE_RESPONSE_PASTE: @@ -961,8 +961,8 @@ static void connect_dialog_action (GType type, PsppireDataWindow *de) { GAction *act = g_object_new (type, - "top-level", de, - NULL); + "top-level", de, + NULL); g_action_map_add_action (G_ACTION_MAP (de), act); } @@ -986,7 +986,7 @@ connect_action_to_menuitem (GActionMap *map, const gchar *action_name, GtkWidget GtkApplication *app = GTK_APPLICATION (g_application_get_default()); /* First set the label for the accellerator so that it appears - on the menuitem */ + on the menuitem */ GtkWidget *child = gtk_bin_get_child (GTK_BIN (w)); guint key; GdkModifierType modifier; @@ -994,20 +994,20 @@ connect_action_to_menuitem (GActionMap *map, const gchar *action_name, GtkWidget gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), key, modifier); /* Now tell the application that it must do something when that - key combination is pressed */ + key combination is pressed */ const gchar *accels[2]; accels[0] = accel; accels[1] = NULL; gchar *detailed_action_name = NULL; if (GTK_IS_WINDOW (map)) - detailed_action_name = g_strdup_printf ("win.%s", 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); + detailed_action_name = g_strdup_printf ("app.%s", action_name); gtk_application_set_accels_for_action (app, - detailed_action_name, - accels); + detailed_action_name, + accels); free (detailed_action_name); } @@ -1036,52 +1036,52 @@ on_cut (PsppireDataWindow *dw) SswRange sel = *sheet->selection; if (ssw_sheet_try_cut (sheet)) - return; + return; if (sel.start_x > sel.end_x) - { - gint tmp = sel.start_x; - sel.start_x = sel.end_x; - sel.end_x = tmp; - } + { + gint tmp = sel.start_x; + sel.start_x = sel.end_x; + sel.end_x = tmp; + } if (sel.start_y > sel.end_y) - { - gint tmp = sel.start_y; - sel.start_y = sel.end_y; - sel.end_y = tmp; - } + { + gint tmp = sel.start_y; + sel.start_y = sel.end_y; + sel.end_y = tmp; + } GtkClipboard *clip = - gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)), - GDK_SELECTION_CLIPBOARD); + gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)), + GDK_SELECTION_CLIPBOARD); /* Save the selected area to a string */ GString *str = g_string_new (""); for (y = sel.start_y ; y <= sel.end_y; ++y) - { - for (x = sel.start_x ; x <= sel.end_x; ++x) - { - const struct variable * var = psppire_dict_get_variable (dict, x); - gboolean use_value_label = FALSE; - g_object_get (dw->data_editor, "value-labels", &use_value_label, NULL); - gchar *s = psppire_data_store_get_string (dw->data_editor->data_store, - y, var, use_value_label); - g_string_append (str, s); + { + for (x = sel.start_x ; x <= sel.end_x; ++x) + { + const struct variable * var = psppire_dict_get_variable (dict, x); + gboolean use_value_label = FALSE; + g_object_get (dw->data_editor, "value-labels", &use_value_label, NULL); + gchar *s = psppire_data_store_get_string (dw->data_editor->data_store, + y, var, use_value_label); + g_string_append (str, s); if (x < sel.end_x) g_string_append (str, "\t"); - g_free (s); - } + g_free (s); + } if (y < sel.end_y) g_string_append (str, "\n"); - } + } gtk_clipboard_set_text (clip, str->str, str->len); g_string_free (str, TRUE); /* Now fill the selected area with SYSMIS or blanks */ for (x = sel.start_x ; x <= sel.end_x; ++x) - { - const struct variable *var = psppire_dict_get_variable (dict, x); + { + const struct variable *var = psppire_dict_get_variable (dict, x); int width = var_get_width (var); union value sm ; value_init (&sm, width); @@ -1089,14 +1089,14 @@ on_cut (PsppireDataWindow *dw) sm.f = SYSMIS; else memset (sm.s, 0, width); - for (y = sel.start_y ; y <= sel.end_y; ++y) - { - psppire_data_store_set_value (dw->data_editor->data_store, - y, - var, &sm); - } + for (y = sel.start_y ; y <= sel.end_y; ++y) + { + psppire_data_store_set_value (dw->data_editor->data_store, + y, + var, &sm); + } value_destroy (&sm, width); - } + } } } @@ -1107,8 +1107,8 @@ on_copy (PsppireDataWindow *dw) if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW) { GtkClipboard *clip = - gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)), - GDK_SELECTION_CLIPBOARD); + gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)), + GDK_SELECTION_CLIPBOARD); ssw_sheet_set_clip (SSW_SHEET (dw->data_editor->data_sheet), clip); } @@ -1134,7 +1134,7 @@ on_clear_cases (PsppireDataWindow *dw) SswRange *range = SSW_SHEET(de->data_sheet)->selection; g_return_if_fail (range->start_y >= 0); psppire_data_store_delete_cases (de->data_store, range->start_y, - range->end_y - range->start_y + 1); + range->end_y - range->start_y + 1); gtk_widget_queue_draw (GTK_WIDGET (de->data_sheet)); } } @@ -1325,7 +1325,7 @@ create_file_menu (PsppireDataWindow *dw) gtk_menu_attach (GTK_MENU (menu), quit, 0, 1, 14, 15); connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()), - "quit", quit, "Q"); + "quit", quit, "Q"); } g_object_set (menuitem, "submenu", menu, NULL); @@ -1377,21 +1377,21 @@ create_edit_menu (PsppireDataWindow *dw) gtk_window_add_accel_group (GTK_WINDOW (dw), ag); gtk_accelerator_parse ("X", &key, &modifier); gtk_widget_add_accelerator (dw->mi_cut, "activate", ag, - key, modifier, GTK_ACCEL_VISIBLE); + key, modifier, 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_accelerator_parse ("C", &key, &modifier); gtk_widget_add_accelerator (dw->mi_copy, "activate", ag, - key, modifier, GTK_ACCEL_VISIBLE); + key, modifier, 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); gtk_accelerator_parse ("V", &key, &modifier); gtk_widget_add_accelerator (dw->mi_paste, "activate", ag, - key, modifier, GTK_ACCEL_VISIBLE); + key, modifier, GTK_ACCEL_VISIBLE); 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; @@ -1415,7 +1415,7 @@ create_edit_menu (PsppireDataWindow *dw) { dw->mi_options = gtk_menu_item_new_with_mnemonic (_("_Options...")); g_signal_connect_swapped (dw->mi_options, "activate", - G_CALLBACK (options_dialog), dw); + G_CALLBACK (options_dialog), dw); gtk_menu_attach (GTK_MENU (menu), dw->mi_options, 0, 1, i, i + 1); ++i; } @@ -1461,7 +1461,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, G_CALLBACK (on_realize), de); g_signal_connect_swapped (de->data_store, "case-changed", - G_CALLBACK (set_unsaved), de); + G_CALLBACK (set_unsaved), de); dataset_set_callbacks (de->dataset, &cbs, de); @@ -1473,16 +1473,16 @@ psppire_data_window_finish_init (PsppireDataWindow *de, gtk_container_add (GTK_CONTAINER (de), box); g_signal_connect (de->dict, "weight-changed", - G_CALLBACK (on_weight_change), - de); + G_CALLBACK (on_weight_change), + de); g_signal_connect (de->dict, "filter-changed", - G_CALLBACK (on_filter_change), - de); + G_CALLBACK (on_filter_change), + de); g_signal_connect (de->dict, "split-changed", - G_CALLBACK (on_split_change), - de); + G_CALLBACK (on_split_change), + de); g_signal_connect_swapped (de->dict, "items-changed", G_CALLBACK (enable_save), de); @@ -1577,7 +1577,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { GSimpleAction *rename_dataset_act = g_simple_action_new ("rename-dataset", NULL); g_signal_connect_swapped (rename_dataset_act, "activate", - G_CALLBACK (on_rename_dataset), de); + G_CALLBACK (on_rename_dataset), de); g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (rename_dataset_act)); } @@ -1607,7 +1607,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { GSimpleAction *act_view_data = g_simple_action_new_stateful ("view_dv", G_VARIANT_TYPE_STRING, - g_variant_new_string ("DATA")); + g_variant_new_string ("DATA")); g_signal_connect (act_view_data, "activate", G_CALLBACK (activate_change_view), de); g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (act_view_data)); } @@ -1621,7 +1621,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { GSimpleAction *act_value_labels = g_simple_action_new_stateful ("value_labels", NULL, - g_variant_new_boolean (FALSE)); + g_variant_new_boolean (FALSE)); g_signal_connect (act_value_labels, "activate", G_CALLBACK (value_labels_activate), de); g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (act_value_labels)); } @@ -1685,7 +1685,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), "PsppireDialogActionVarInfo"); g_assert (a); g_signal_connect_swapped (de->ti_jump_to_variable, "clicked", - G_CALLBACK (psppire_dialog_action_activate_null), a); + G_CALLBACK (psppire_dialog_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_jump_to_variable, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_jump_to_variable), "pspp-edit-go-to-variable"); @@ -1698,7 +1698,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, 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); + 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), "pspp-edit-go-to-case"); @@ -1711,7 +1711,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), "find"); g_assert (a); g_signal_connect_swapped (de->ti_find, "clicked", - G_CALLBACK (g_action_activate_null), a); + G_CALLBACK (g_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_find, idx++); @@ -1724,7 +1724,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), "insert-case"); g_assert (a); g_signal_connect_swapped (de->ti_insert_case, "clicked", - G_CALLBACK (g_action_activate_null), a); + G_CALLBACK (g_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_insert_case, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_insert_case), "pspp-edit-insert-case"); @@ -1736,7 +1736,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), "insert-variable"); g_assert (a); g_signal_connect_swapped (de->ti_insert_variable, "clicked", - G_CALLBACK (g_action_activate_null), a); + G_CALLBACK (g_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_insert_variable, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_insert_variable), "pspp-edit-insert-variable"); @@ -1748,10 +1748,10 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { GtkToolItem *ti = gtk_tool_button_new (NULL, "Split"); GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), - "PsppireDialogActionSplit"); + "PsppireDialogActionSplit"); g_assert (a); g_signal_connect_swapped (ti, "clicked", - G_CALLBACK (psppire_dialog_action_activate_null), a); + G_CALLBACK (psppire_dialog_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), ti, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (ti), "pspp-data-split-file"); gtk_widget_set_tooltip_text (GTK_WIDGET (ti), _("Split the active dataset")); @@ -1760,10 +1760,10 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { GtkToolItem *ti = gtk_tool_button_new (NULL, "Weight"); GAction *a = g_action_map_lookup_action (G_ACTION_MAP (de), - "PsppireDialogActionWeight"); + "PsppireDialogActionWeight"); g_assert (a); g_signal_connect_swapped (ti, "clicked", - G_CALLBACK (psppire_dialog_action_activate_null), a); + G_CALLBACK (psppire_dialog_action_activate_null), a); gtk_toolbar_insert (GTK_TOOLBAR (hb), ti, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (ti), "pspp-data-weight-cases"); gtk_widget_set_tooltip_text (GTK_WIDGET (ti), _("Weight cases by variable")); @@ -1772,9 +1772,9 @@ psppire_data_window_finish_init (PsppireDataWindow *de, { de->ti_value_labels_button = gtk_toggle_tool_button_new (); gtk_tool_button_set_label (GTK_TOOL_BUTTON (de->ti_value_labels_button), - "Value Labels"); + "Value Labels"); g_signal_connect (de->ti_value_labels_button, "toggled", - G_CALLBACK (on_labels_button_toggle), de); + G_CALLBACK (on_labels_button_toggle), de); gtk_toolbar_insert (GTK_TOOLBAR (hb), de->ti_value_labels_button, idx++); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (de->ti_value_labels_button), "pspp-view-value-labels"); gtk_widget_set_tooltip_text (GTK_WIDGET (de->ti_value_labels_button), _("Show/hide value labels")); @@ -1915,11 +1915,11 @@ psppire_data_window_new (struct dataset *ds) assert (dataset_session (ds) == the_session); dw = GTK_WIDGET ( - g_object_new ( - psppire_data_window_get_type (), - "description", _("Data Editor"), - "dataset", ds, - NULL)); + g_object_new ( + psppire_data_window_get_type (), + "description", _("Data Editor"), + "dataset", ds, + NULL)); if (dataset_name (ds) != NULL) g_object_set (dw, "id", dataset_name (ds), (void *) NULL); diff --git a/src/ui/gui/psppire-delimited-text.c b/src/ui/gui/psppire-delimited-text.c index a3b110494a..f3deb1d961 100644 --- a/src/ui/gui/psppire-delimited-text.c +++ b/src/ui/gui/psppire-delimited-text.c @@ -109,9 +109,9 @@ cache_invalidate (PsppireDelimitedText *tf) static void psppire_delimited_text_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireDelimitedText *tf = PSPPIRE_DELIMITED_TEXT (object); @@ -142,9 +142,9 @@ psppire_delimited_text_set_property (GObject *object, static void psppire_delimited_text_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireDelimitedText *text_file = PSPPIRE_DELIMITED_TEXT (object); @@ -180,8 +180,8 @@ n_lines (PsppireDelimitedText *file) static gboolean __tree_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path) + GtkTreeIter *iter, + GtkTreePath *path) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); if (path == NULL) @@ -210,7 +210,7 @@ __tree_get_iter (GtkTreeModel *tree_model, static gboolean __tree_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); g_return_val_if_fail (file->stamp == iter->stamp, FALSE); @@ -231,7 +231,7 @@ __tree_iter_next (GtkTreeModel *tree_model, static GType __tree_get_column_type (GtkTreeModel *tree_model, - gint index) + gint index) { if (index == 0) return G_TYPE_INT; @@ -241,7 +241,7 @@ __tree_get_column_type (GtkTreeModel *tree_model, static gboolean __iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { return 0; } @@ -249,15 +249,15 @@ __iter_has_child (GtkTreeModel *tree_model, static gboolean __iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) + GtkTreeIter *iter, + GtkTreeIter *child) { return 0; } static GtkTreePath * __tree_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); g_return_val_if_fail (file->stamp == iter->stamp, FALSE); @@ -284,7 +284,7 @@ __iter_children (GtkTreeModel *tree_model, static gint __tree_model_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); g_assert (iter == NULL); @@ -314,9 +314,9 @@ __tree_model_get_n_columns (GtkTreeModel *tree_model) static gboolean __iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n) + GtkTreeIter *iter, + GtkTreeIter *parent, + gint n) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); @@ -368,9 +368,9 @@ psppire_delimited_text_get_header_title (PsppireDelimitedText *file, gint column static void __get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value) + GtkTreeIter *iter, + gint column, + GValue *value) { PsppireDelimitedText *file = PSPPIRE_DELIMITED_TEXT (tree_model); @@ -415,8 +415,8 @@ __tree_model_init (GtkTreeModelIface *iface) } G_DEFINE_TYPE_WITH_CODE (PsppireDelimitedText, psppire_delimited_text, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - __tree_model_init)) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + __tree_model_init)) static void psppire_delimited_text_class_init (PsppireDelimitedTextClass *class) @@ -428,16 +428,16 @@ psppire_delimited_text_class_init (PsppireDelimitedTextClass *class) GParamSpec *first_line_spec = g_param_spec_int ("first-line", - "First Line", - P_("The first line to be considered."), - 0, 1000, 0, - G_PARAM_READWRITE); + "First Line", + P_("The first line to be considered."), + 0, 1000, 0, + G_PARAM_READWRITE); GParamSpec *delimiters_spec = g_param_spec_pointer ("delimiters", - "Field Delimiters", - P_("A GSList of gunichars which delimit the fields."), - G_PARAM_READWRITE); + "Field Delimiters", + P_("A GSList of gunichars which delimit the fields."), + G_PARAM_READWRITE); GParamSpec *quote_spec = g_param_spec_unichar ("quote", @@ -448,10 +448,10 @@ psppire_delimited_text_class_init (PsppireDelimitedTextClass *class) GParamSpec *child_spec = g_param_spec_object ("child", - "Child Model", - P_("The GtkTextModel which this object wraps."), - GTK_TYPE_TREE_MODEL, - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + "Child Model", + P_("The GtkTextModel which this object wraps."), + GTK_TYPE_TREE_MODEL, + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); object_class->set_property = psppire_delimited_text_set_property; object_class->get_property = psppire_delimited_text_get_property; @@ -502,8 +502,8 @@ psppire_delimited_text_new (GtkTreeModel *child) { return g_object_new (PSPPIRE_TYPE_DELIMITED_TEXT, - "child", child, - NULL); + "child", child, + NULL); } static void diff --git a/src/ui/gui/psppire-delimited-text.h b/src/ui/gui/psppire-delimited-text.h index c24ce10c93..c813961db5 100644 --- a/src/ui/gui/psppire-delimited-text.h +++ b/src/ui/gui/psppire-delimited-text.h @@ -27,9 +27,9 @@ G_BEGIN_DECLS -#define PSPPIRE_TYPE_DELIMITED_TEXT (psppire_delimited_text_get_type ()) +#define PSPPIRE_TYPE_DELIMITED_TEXT (psppire_delimited_text_get_type ()) -#define PSPPIRE_DELIMITED_TEXT(obj) \ +#define PSPPIRE_DELIMITED_TEXT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ PSPPIRE_TYPE_DELIMITED_TEXT, PsppireDelimitedText)) diff --git a/src/ui/gui/psppire-dialog-action-1sks.c b/src/ui/gui/psppire-dialog-action-1sks.c index 13b04c6da6..db2979d3a4 100644 --- a/src/ui/gui/psppire-dialog-action-1sks.c +++ b/src/ui/gui/psppire-dialog-action-1sks.c @@ -90,7 +90,7 @@ dialog_state_valid (gpointer data) for (i = 0; i < 4; ++i) { if (TRUE == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->cb[i]))) - break; + break; } if (i >= 4) return FALSE; diff --git a/src/ui/gui/psppire-dialog-action-1sks.h b/src/ui/gui/psppire-dialog-action-1sks.h index 5e201945fa..35d7368ec8 100644 --- a/src/ui/gui/psppire-dialog-action-1sks.h +++ b/src/ui/gui/psppire-dialog-action-1sks.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_1SKS (psppire_dialog_action_1sks_get_type ()) -#define PSPPIRE_DIALOG_ACTION_1SKS(obj) \ +#define PSPPIRE_DIALOG_ACTION_1SKS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_1SKS, PsppireDialogAction1sks)) + PSPPIRE_TYPE_DIALOG_ACTION_1SKS, PsppireDialogAction1sks)) #define PSPPIRE_DIALOG_ACTION_1SKS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_1SKS, \ + PSPPIRE_TYPE_DIALOG_ACTION_1SKS, \ PsppireDialogAction1sksClass)) #define PSPPIRE_IS_DIALOG_ACTION_1SKS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_1SKS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_1SKS)) #define PSPPIRE_IS_DIALOG_ACTION_1SKS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_1SKS)) #define PSPPIRE_DIALOG_ACTION_1SKS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_1SKS, \ - PsppireDialogAction1sksClass)) + PSPPIRE_TYPE_DIALOG_ACTION_1SKS, \ + PsppireDialogAction1sksClass)) typedef struct _PsppireDialogAction1sks PsppireDialogAction1sks; typedef struct _PsppireDialogAction1sksClass PsppireDialogAction1sksClass; diff --git a/src/ui/gui/psppire-dialog-action-aggregate.c b/src/ui/gui/psppire-dialog-action-aggregate.c index bd78d4ecda..4f0ce60687 100644 --- a/src/ui/gui/psppire-dialog-action-aggregate.c +++ b/src/ui/gui/psppire-dialog-action-aggregate.c @@ -87,9 +87,9 @@ append_destination_filename (const PsppireDialogActionAggregate *agg, GString *g g_string_append (gs, "* "); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->replace_radiobutton))) - g_string_append (gs, "MODE=REPLACE"); + g_string_append (gs, "MODE=REPLACE"); else - g_string_append (gs, "MODE=ADDVARIABLES"); + g_string_append (gs, "MODE=ADDVARIABLES"); } } @@ -182,10 +182,10 @@ enum static void render_summary (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) { PsppireDialogActionAggregate *agg = data; @@ -205,11 +205,11 @@ choose_filename (PsppireDialogActionAggregate *fd) GtkFileFilter *filter; GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Aggregate destination file"), - GTK_WINDOW (PSPPIRE_DIALOG_ACTION (fd)->toplevel), - GTK_FILE_CHOOSER_ACTION_SAVE, - _("Cancel"), GTK_RESPONSE_CANCEL, - _("Save"), GTK_RESPONSE_ACCEPT, - NULL); + GTK_WINDOW (PSPPIRE_DIALOG_ACTION (fd)->toplevel), + GTK_FILE_CHOOSER_ACTION_SAVE, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("Save"), GTK_RESPONSE_ACCEPT, + NULL); g_object_set (dialog, "local-only", FALSE, NULL); @@ -260,14 +260,14 @@ populate_combo_model (GtkComboBox *cb) { const gchar *s = af->description; if (s == NULL) - continue; + continue; gtk_list_store_append (list, &iter); gtk_list_store_set (list, &iter, COMBO_MODEL_COL_DESC, gettext (s), - COMBO_MODEL_COL_SYNTAX, af->name, - COMBO_MODEL_COL_SRC_VARS, af->src_vars, - COMBO_MODEL_COL_ARITY, af->n_args, + COMBO_MODEL_COL_SYNTAX, af->name, + COMBO_MODEL_COL_SRC_VARS, af->src_vars, + COMBO_MODEL_COL_ARITY, af->n_args, -1); } @@ -317,16 +317,16 @@ get_summary_spec (gint col, GValue *val, gpointer data) break; case SUMMARY_COL_ARG1: { - const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)); - g_value_init (val, G_TYPE_DOUBLE); - g_value_set_double (val, g_strtod (text, 0)); + const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)); + g_value_init (val, G_TYPE_DOUBLE); + g_value_set_double (val, g_strtod (text, 0)); } break; case SUMMARY_COL_ARG2: { - const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)); - g_value_init (val, G_TYPE_DOUBLE); - g_value_set_double (val, g_strtod (text, 0)); + const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)); + g_value_init (val, G_TYPE_DOUBLE); + g_value_set_double (val, g_strtod (text, 0)); } break; default: @@ -359,27 +359,27 @@ summary_complete (const PsppireDialogActionAggregate *agg) gtk_tree_model_get (model, - &iter, - COMBO_MODEL_COL_ARITY, &n_args, - COMBO_MODEL_COL_SRC_VARS, &src_vars, - -1); + &iter, + COMBO_MODEL_COL_ARITY, &n_args, + COMBO_MODEL_COL_SRC_VARS, &src_vars, + -1); if (src_vars == AGR_SV_YES) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_sv_entry)))) - return FALSE; + return FALSE; } if (n_args >= 2) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)))) - return FALSE; + return FALSE; } if (n_args >= 1) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)))) - return FALSE; + return FALSE; } @@ -418,12 +418,12 @@ on_acr_change (const PsppireDialogActionAggregate *agg, GtkTreeView *tv) if (gtk_tree_selection_get_selected (sel, &model, &iter)) { gtk_tree_model_get (model, &iter, - SUMMARY_COL_VARNAME, &varname, - SUMMARY_COL_VARLABEL, &label, - SUMMARY_COL_FUNCIDX, &f_idx, - SUMMARY_COL_SRCVAR, &srcvar, - SUMMARY_COL_ARG1, &arg1, - SUMMARY_COL_ARG2, &arg2, -1); + SUMMARY_COL_VARNAME, &varname, + SUMMARY_COL_VARLABEL, &label, + SUMMARY_COL_FUNCIDX, &f_idx, + SUMMARY_COL_SRCVAR, &srcvar, + SUMMARY_COL_ARG1, &arg1, + SUMMARY_COL_ARG2, &arg2, -1); gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), varname); gtk_entry_set_text (GTK_ENTRY (agg->summary_var_label_entry), label); @@ -457,10 +457,10 @@ update_arguments (PsppireDialogActionAggregate *agg) int n_args; enum agr_src_vars src_vars; gtk_tree_model_get (model, - &iter, - COMBO_MODEL_COL_ARITY, &n_args, - COMBO_MODEL_COL_SRC_VARS, &src_vars, - -1); + &iter, + COMBO_MODEL_COL_ARITY, &n_args, + COMBO_MODEL_COL_SRC_VARS, &src_vars, + -1); gtk_widget_set_sensitive (agg->summary_sv, src_vars != AGR_SV_NO); gtk_widget_set_sensitive (agg->summary_arg2, n_args >= 2); @@ -525,18 +525,18 @@ psppire_dialog_action_aggregate_activate (PsppireDialogAction *a, GVariant *para GtkCellRenderer *cell_renderer ; GtkListStore *list = gtk_list_store_new (6, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_STRING, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE); + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE); psppire_acr_set_model (PSPPIRE_ACR (act->summary_acr), list); g_object_unref (list); psppire_acr_set_get_value_func (PSPPIRE_ACR (act->summary_acr), - get_summary_spec, act); + get_summary_spec, act); column = gtk_tree_view_get_column (PSPPIRE_ACR (act->summary_acr)->tv, 0); @@ -545,13 +545,13 @@ psppire_dialog_action_aggregate_activate (PsppireDialogAction *a, GVariant *para cell_renderer = l->data; gtk_tree_view_column_set_cell_data_func (column, - cell_renderer, - render_summary, - act, - NULL); + cell_renderer, + render_summary, + act, + NULL); g_signal_connect_swapped (PSPPIRE_ACR (act->summary_acr)->tv, - "cursor-changed", G_CALLBACK (on_acr_change), act); + "cursor-changed", G_CALLBACK (on_acr_change), act); } g_signal_connect_swapped (act->summary_var_name_entry, "changed", G_CALLBACK (update_acr), act); @@ -562,7 +562,7 @@ psppire_dialog_action_aggregate_activate (PsppireDialogAction *a, GVariant *para g_signal_connect_swapped (act->function_combo, "changed", - G_CALLBACK (update_arguments), act); + G_CALLBACK (update_arguments), act); populate_combo_model (GTK_COMBO_BOX (act->function_combo)); @@ -571,10 +571,10 @@ psppire_dialog_action_aggregate_activate (PsppireDialogAction *a, GVariant *para g_signal_connect (act->filename_radiobutton, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), act->filename_box); + G_CALLBACK (set_sensitivity_from_toggle), act->filename_box); g_signal_connect_swapped (act->filename_button, "clicked", - G_CALLBACK (choose_filename), act); + G_CALLBACK (choose_filename), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); @@ -617,21 +617,21 @@ append_summary_spec (const PsppireDialogActionAggregate *agg, GtkTreeIter *iter, gchar *srcvar = NULL; gtk_tree_model_get (acr_model, iter, - SUMMARY_COL_VARNAME, &varname, - SUMMARY_COL_VARLABEL, &label, - SUMMARY_COL_FUNCIDX, &f_idx, - SUMMARY_COL_SRCVAR, &srcvar, - SUMMARY_COL_ARG1, &arg1, - SUMMARY_COL_ARG2, &arg2, - -1); + SUMMARY_COL_VARNAME, &varname, + SUMMARY_COL_VARLABEL, &label, + SUMMARY_COL_FUNCIDX, &f_idx, + SUMMARY_COL_SRCVAR, &srcvar, + SUMMARY_COL_ARG1, &arg1, + SUMMARY_COL_ARG2, &arg2, + -1); gtk_tree_model_iter_nth_child (combo_model, &combo_iter, NULL, f_idx); gtk_tree_model_get (combo_model, &combo_iter, - COMBO_MODEL_COL_SYNTAX, &funcname, - COMBO_MODEL_COL_ARITY, &arity, - COMBO_MODEL_COL_SRC_VARS, &has_src_vars, - -1); + COMBO_MODEL_COL_SYNTAX, &funcname, + COMBO_MODEL_COL_ARITY, &arity, + COMBO_MODEL_COL_SRC_VARS, &has_src_vars, + -1); g_string_append (string, varname); @@ -655,10 +655,10 @@ append_summary_spec (const PsppireDialogActionAggregate *agg, GtkTreeIter *iter, ds_put_cstr (&dss, srcvar); if (arity > 0) - ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg1); + ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg1); if (arity > 1) - ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg2); + ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg2); ds_put_cstr (&dss, ")"); diff --git a/src/ui/gui/psppire-dialog-action-aggregate.h b/src/ui/gui/psppire-dialog-action-aggregate.h index 0a60954cd9..9ccc023b5b 100644 --- a/src/ui/gui/psppire-dialog-action-aggregate.h +++ b/src/ui/gui/psppire-dialog-action-aggregate.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE (psppire_dialog_action_aggregate_get_type ()) -#define PSPPIRE_DIALOG_ACTION_AGGREGATE(obj) \ +#define PSPPIRE_DIALOG_ACTION_AGGREGATE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, PsppireDialogActionAggregate)) + PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, PsppireDialogActionAggregate)) #define PSPPIRE_DIALOG_ACTION_AGGREGATE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, \ + PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, \ PsppireDialogActionAggregateClass)) #define PSPPIRE_IS_DIALOG_ACTION_AGGREGATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE)) #define PSPPIRE_IS_DIALOG_ACTION_AGGREGATE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE)) #define PSPPIRE_DIALOG_ACTION_AGGREGATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, \ - PsppireDialogActionAggregateClass)) + PSPPIRE_TYPE_DIALOG_ACTION_AGGREGATE, \ + PsppireDialogActionAggregateClass)) typedef struct _PsppireDialogActionAggregate PsppireDialogActionAggregate; typedef struct _PsppireDialogActionAggregateClass PsppireDialogActionAggregateClass; diff --git a/src/ui/gui/psppire-dialog-action-autorecode.c b/src/ui/gui/psppire-dialog-action-autorecode.c index 0789272557..885d92c4fa 100644 --- a/src/ui/gui/psppire-dialog-action-autorecode.c +++ b/src/ui/gui/psppire-dialog-action-autorecode.c @@ -211,15 +211,15 @@ on_entry_change (PsppireDialogActionAutorecode *rd) g_hash_table_iter_init (&iter, rd->varmap); while (g_hash_table_iter_next (&iter, &key, &value)) - { - struct nlp *nlp = value; - - if (0 == strcmp (nlp->name, text)) - { - valid = FALSE; - break; - } - } + { + struct nlp *nlp = value; + + if (0 == strcmp (nlp->name, text)) + { + valid = FALSE; + break; + } + } } gtk_widget_set_sensitive (rd->change_button, valid); @@ -260,9 +260,9 @@ on_selection_change (GtkTreeSelection *selection, gpointer data) nlp = g_hash_table_lookup (rd->varmap, var); if (nlp) - gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), nlp->name ? nlp->name : ""); + gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), nlp->name ? nlp->name : ""); else - gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), ""); + gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), ""); } else { @@ -279,10 +279,10 @@ on_selection_change (GtkTreeSelection *selection, gpointer data) static void render_new_var_name (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) { struct nlp *nlp = NULL; @@ -293,8 +293,8 @@ render_new_var_name (GtkTreeViewColumn *tree_column, struct variable *var = NULL; gtk_tree_model_get (tree_model, iter, - 0, &var, - -1); + 0, &var, + -1); nlp = g_hash_table_lookup (rd->varmap, var); @@ -330,13 +330,13 @@ psppire_dialog_action_autorecode_activate (PsppireDialogAction *a, GVariant *par GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn *col = gtk_tree_view_column_new_with_attributes (_("New"), - renderer, - "text", NULL, - NULL); + renderer, + "text", NULL, + NULL); gtk_tree_view_column_set_cell_data_func (col, renderer, - render_new_var_name, - act, NULL); + render_new_var_name, + act, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (act->var_view), col); @@ -354,13 +354,13 @@ psppire_dialog_action_autorecode_activate (PsppireDialogAction *a, GVariant *par g_signal_connect (sel, "changed", - G_CALLBACK (on_selection_change), act); + G_CALLBACK (on_selection_change), act); g_signal_connect (act->change_button, "clicked", - G_CALLBACK (on_change_clicked), act); + G_CALLBACK (on_change_clicked), act); g_signal_connect_swapped (act->new_name_entry, "changed", - G_CALLBACK (on_entry_change), act); + G_CALLBACK (on_entry_change), act); } diff --git a/src/ui/gui/psppire-dialog-action-autorecode.h b/src/ui/gui/psppire-dialog-action-autorecode.h index 3f222b9979..e48beaa675 100644 --- a/src/ui/gui/psppire-dialog-action-autorecode.h +++ b/src/ui/gui/psppire-dialog-action-autorecode.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE (psppire_dialog_action_autorecode_get_type ()) -#define PSPPIRE_DIALOG_ACTION_AUTORECODE(obj) \ +#define PSPPIRE_DIALOG_ACTION_AUTORECODE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, PsppireDialogActionAutorecode)) + PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, PsppireDialogActionAutorecode)) #define PSPPIRE_DIALOG_ACTION_AUTORECODE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, \ + PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, \ PsppireDialogActionAutorecodeClass)) #define PSPPIRE_IS_DIALOG_ACTION_AUTORECODE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE)) #define PSPPIRE_IS_DIALOG_ACTION_AUTORECODE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE)) #define PSPPIRE_DIALOG_ACTION_AUTORECODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, \ - PsppireDialogActionAutorecodeClass)) + PSPPIRE_TYPE_DIALOG_ACTION_AUTORECODE, \ + PsppireDialogActionAutorecodeClass)) typedef struct _PsppireDialogActionAutorecode PsppireDialogActionAutorecode; typedef struct _PsppireDialogActionAutorecodeClass PsppireDialogActionAutorecodeClass; diff --git a/src/ui/gui/psppire-dialog-action-barchart.c b/src/ui/gui/psppire-dialog-action-barchart.c index 576ed18a5a..20ff009a36 100644 --- a/src/ui/gui/psppire-dialog-action-barchart.c +++ b/src/ui/gui/psppire-dialog-action-barchart.c @@ -45,7 +45,7 @@ dialog_state_valid (gpointer rd_) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->button_summary_func))) { if (0 == g_strcmp0 ("", gtk_entry_get_text (GTK_ENTRY (rd->var)))) - return FALSE; + return FALSE; } if (0 == g_strcmp0 ("", gtk_entry_get_text (GTK_ENTRY (rd->variable_xaxis)))) @@ -95,12 +95,12 @@ populate_combo_model (GtkComboBox *cb) const struct ag_func *af = ag_func + i; if (af->arity == 0) - continue; + continue; gtk_list_store_append (list, &iter); gtk_list_store_set (list, &iter, 0, af->description, - 1, af->name, + 1, af->name, -1); } @@ -140,12 +140,12 @@ psppire_dialog_action_barchart_activate (PsppireDialogAction *a, GVariant *param populate_combo_model (GTK_COMBO_BOX(act->combobox)); g_signal_connect_swapped (act->button_summary_func, "toggled", - G_CALLBACK (on_summary_toggle), act); + G_CALLBACK (on_summary_toggle), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } @@ -163,13 +163,13 @@ generate_syntax (const PsppireDialogAction *a) { GtkTreeIter iter; if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (rd->combobox), &iter)) - { - GValue value = {0}; - GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (rd->combobox)); - gtk_tree_model_get_value (model, &iter, 1, &value); - g_string_append (string, g_value_get_string (&value)); - g_value_unset (&value); - } + { + GValue value = {0}; + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (rd->combobox)); + gtk_tree_model_get_value (model, &iter, 1, &value); + g_string_append (string, g_value_get_string (&value)); + g_value_unset (&value); + } g_string_append (string, " ("); g_string_append (string, gtk_entry_get_text (GTK_ENTRY (rd->var))); g_string_append (string, ")"); @@ -178,28 +178,28 @@ generate_syntax (const PsppireDialogAction *a) { int b; for (b = 0; b < 4; ++b) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->button_freq_func[b]))) - break; - } + { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->button_freq_func[b]))) + break; + } switch (b) - { - case 0: - g_string_append (string, "COUNT"); - break; - case 1: - g_string_append (string, "PCT"); - break; - case 2: - g_string_append (string, "CUFREQ"); - break; - case 3: - g_string_append (string, "CUPCT"); - break; - default: - g_assert_not_reached (); - break; - } + { + case 0: + g_string_append (string, "COUNT"); + break; + case 1: + g_string_append (string, "PCT"); + break; + case 2: + g_string_append (string, "CUFREQ"); + break; + case 3: + g_string_append (string, "CUPCT"); + break; + default: + g_assert_not_reached (); + break; + } } g_string_append (string, " BY "); diff --git a/src/ui/gui/psppire-dialog-action-barchart.h b/src/ui/gui/psppire-dialog-action-barchart.h index 4ebc8e9867..d65782e263 100644 --- a/src/ui/gui/psppire-dialog-action-barchart.h +++ b/src/ui/gui/psppire-dialog-action-barchart.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_BARCHART (psppire_dialog_action_barchart_get_type ()) -#define PSPPIRE_DIALOG_ACTION_BARCHART(obj) \ +#define PSPPIRE_DIALOG_ACTION_BARCHART(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, PsppireDialogActionBarchart)) + PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, PsppireDialogActionBarchart)) #define PSPPIRE_DIALOG_ACTION_BARCHART_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, \ + PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, \ PsppireDialogActionBarchartClass)) #define PSPPIRE_IS_DIALOG_ACTION_BARCHART(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_BARCHART)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_BARCHART)) #define PSPPIRE_IS_DIALOG_ACTION_BARCHART_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_BARCHART)) #define PSPPIRE_DIALOG_ACTION_BARCHART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, \ - PsppireDialogActionBarchartClass)) + PSPPIRE_TYPE_DIALOG_ACTION_BARCHART, \ + PsppireDialogActionBarchartClass)) typedef struct _PsppireDialogActionBarchart PsppireDialogActionBarchart; typedef struct _PsppireDialogActionBarchartClass PsppireDialogActionBarchartClass; diff --git a/src/ui/gui/psppire-dialog-action-binomial.c b/src/ui/gui/psppire-dialog-action-binomial.c index 648e6e551d..fdcc3e92c3 100644 --- a/src/ui/gui/psppire-dialog-action-binomial.c +++ b/src/ui/gui/psppire-dialog-action-binomial.c @@ -115,12 +115,12 @@ psppire_dialog_action_binomial_activate (PsppireDialogAction *a, GVariant *param act->cutpoint_button = get_widget_assert (xml, "radiobutton4"); g_signal_connect (act->cutpoint_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle), - act->cutpoint_entry); + act->cutpoint_entry); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-binomial.h b/src/ui/gui/psppire-dialog-action-binomial.h index 0541a402dd..5b4ca519dc 100644 --- a/src/ui/gui/psppire-dialog-action-binomial.h +++ b/src/ui/gui/psppire-dialog-action-binomial.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL (psppire_dialog_action_binomial_get_type ()) -#define PSPPIRE_DIALOG_ACTION_BINOMIAL(obj) \ +#define PSPPIRE_DIALOG_ACTION_BINOMIAL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, PsppireDialogActionBinomial)) + PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, PsppireDialogActionBinomial)) #define PSPPIRE_DIALOG_ACTION_BINOMIAL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \ + PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \ PsppireDialogActionBinomialClass)) #define PSPPIRE_IS_DIALOG_ACTION_BINOMIAL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL)) #define PSPPIRE_IS_DIALOG_ACTION_BINOMIAL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL)) #define PSPPIRE_DIALOG_ACTION_BINOMIAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \ - PsppireDialogActionBinomialClass)) + PSPPIRE_TYPE_DIALOG_ACTION_BINOMIAL, \ + PsppireDialogActionBinomialClass)) typedef struct _PsppireDialogActionBinomial PsppireDialogActionBinomial; typedef struct _PsppireDialogActionBinomialClass PsppireDialogActionBinomialClass; diff --git a/src/ui/gui/psppire-dialog-action-chisquare.c b/src/ui/gui/psppire-dialog-action-chisquare.c index 4fd09d0a44..eece764e8c 100644 --- a/src/ui/gui/psppire-dialog-action-chisquare.c +++ b/src/ui/gui/psppire-dialog-action-chisquare.c @@ -53,12 +53,12 @@ generate_syntax (const PsppireDialogAction *act) ds_put_cstr (&dss, "("); ds_put_cstr (&dss, - gtk_entry_get_text (GTK_ENTRY (scd->value_lower))); + gtk_entry_get_text (GTK_ENTRY (scd->value_lower))); ds_put_cstr (&dss, ", "); ds_put_cstr (&dss, - gtk_entry_get_text (GTK_ENTRY (scd->value_upper))); + gtk_entry_get_text (GTK_ENTRY (scd->value_upper))); ds_put_cstr (&dss, ")"); } @@ -74,16 +74,16 @@ generate_syntax (const PsppireDialogAction *act) for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(ls), - &iter); - ok; - ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), &iter)) - { - gdouble v; + &iter); + ok; + ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), &iter)) + { + gdouble v; - gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 0, &v, -1); + gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 0, &v, -1); - ds_put_c_format (&dss, " %.*g", DBL_DIG + 1, v); - } + ds_put_c_format (&dss, " %.*g", DBL_DIG + 1, v); + } } ds_put_cstr (&dss, ".\n"); @@ -160,20 +160,20 @@ psppire_dialog_action_chisquare_activate (PsppireDialogAction *a, GVariant *para psppire_dialog_action_set_refresh (pda, refresh); g_signal_connect (act->range_button, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - range_table); + G_CALLBACK (set_sensitivity_from_toggle), + range_table); g_signal_connect (act->values_button, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - values_acr); + G_CALLBACK (set_sensitivity_from_toggle), + values_acr); g_signal_connect (act->values_button, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - expected_value_entry); + G_CALLBACK (set_sensitivity_from_toggle), + expected_value_entry); psppire_acr_set_entry (PSPPIRE_ACR (values_acr), - GTK_ENTRY (expected_value_entry)); + GTK_ENTRY (expected_value_entry)); psppire_acr_set_model(PSPPIRE_ACR (values_acr), act->expected_list); diff --git a/src/ui/gui/psppire-dialog-action-chisquare.h b/src/ui/gui/psppire-dialog-action-chisquare.h index 9ce0421cdd..5e762d8632 100644 --- a/src/ui/gui/psppire-dialog-action-chisquare.h +++ b/src/ui/gui/psppire-dialog-action-chisquare.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE (psppire_dialog_action_chisquare_get_type ()) -#define PSPPIRE_DIALOG_ACTION_CHISQUARE(obj) \ +#define PSPPIRE_DIALOG_ACTION_CHISQUARE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, PsppireDialogActionChisquare)) + PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, PsppireDialogActionChisquare)) #define PSPPIRE_DIALOG_ACTION_CHISQUARE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, \ + PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, \ PsppireDialogActionChisquareClass)) #define PSPPIRE_IS_DIALOG_ACTION_CHISQUARE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE)) #define PSPPIRE_IS_DIALOG_ACTION_CHISQUARE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE)) #define PSPPIRE_DIALOG_ACTION_CHISQUARE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, \ - PsppireDialogActionChisquareClass)) + PSPPIRE_TYPE_DIALOG_ACTION_CHISQUARE, \ + PsppireDialogActionChisquareClass)) typedef struct _PsppireDialogActionChisquare PsppireDialogActionChisquare; typedef struct _PsppireDialogActionChisquareClass PsppireDialogActionChisquareClass; diff --git a/src/ui/gui/psppire-dialog-action-comments.c b/src/ui/gui/psppire-dialog-action-comments.c index 9a423c720d..e88f4e5988 100644 --- a/src/ui/gui/psppire-dialog-action-comments.c +++ b/src/ui/gui/psppire-dialog-action-comments.c @@ -59,7 +59,7 @@ generate_syntax (const PsppireDialogAction *pda) gtk_text_buffer_get_iter_at_line (buffer, &start, i); if (gtk_text_iter_ends_line (&start)) - line = g_strdup (""); + line = g_strdup (""); else { GtkTextIter end = start; @@ -135,7 +135,7 @@ set_column_number (GtkTextBuffer *textbuffer, gchar *text ; text = g_strdup_printf (_("Column Number: %d"), - 1 + gtk_text_iter_get_line_offset (iter)); + 1 + gtk_text_iter_get_line_offset (iter)); gtk_label_set_text (label, text); @@ -188,23 +188,23 @@ psppire_dialog_action_comments_activate (PsppireDialogAction *pda, GVariant *par GError *err = NULL; gtk_css_provider_load_from_data (cssp, css, -1, &err); if (err) - { - g_warning ("Failed to load font css \"%s\": %s", css, err->message); - g_error_free (err); - } + { + g_warning ("Failed to load font css \"%s\": %s", css, err->message); + g_error_free (err); + } gtk_style_context_add_provider (style, - GTK_STYLE_PROVIDER (cssp), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + GTK_STYLE_PROVIDER (cssp), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (cssp); } } GtkTextIter iter; g_signal_connect (buffer, "mark-set", - G_CALLBACK (set_column_number), label); + G_CALLBACK (set_column_number), label); g_signal_connect_after (buffer, "insert-text", - G_CALLBACK (wrap_line), NULL); + G_CALLBACK (wrap_line), NULL); gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); gtk_text_buffer_place_cursor (buffer, &iter); diff --git a/src/ui/gui/psppire-dialog-action-comments.h b/src/ui/gui/psppire-dialog-action-comments.h index 541b859ffe..7f5d226677 100644 --- a/src/ui/gui/psppire-dialog-action-comments.h +++ b/src/ui/gui/psppire-dialog-action-comments.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS (psppire_dialog_action_comments_get_type ()) -#define PSPPIRE_DIALOG_ACTION_COMMENTS(obj) \ +#define PSPPIRE_DIALOG_ACTION_COMMENTS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, PsppireDialogActionComments)) + PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, PsppireDialogActionComments)) #define PSPPIRE_DIALOG_ACTION_COMMENTS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, \ + PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, \ PsppireDialogActionCommentsClass)) #define PSPPIRE_IS_DIALOG_ACTION_COMMENTS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS)) #define PSPPIRE_IS_DIALOG_ACTION_COMMENTS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS)) #define PSPPIRE_DIALOG_ACTION_COMMENTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, \ - PsppireDialogActionCommentsClass)) + PSPPIRE_TYPE_DIALOG_ACTION_COMMENTS, \ + PsppireDialogActionCommentsClass)) typedef struct _PsppireDialogActionComments PsppireDialogActionComments; typedef struct _PsppireDialogActionCommentsClass PsppireDialogActionCommentsClass; diff --git a/src/ui/gui/psppire-dialog-action-compute.c b/src/ui/gui/psppire-dialog-action-compute.c index 78a036d88a..c10019dc91 100644 --- a/src/ui/gui/psppire-dialog-action-compute.c +++ b/src/ui/gui/psppire-dialog-action-compute.c @@ -61,13 +61,13 @@ generate_syntax (const PsppireDialogAction *act) NULL == psppire_dict_lookup_var (act->dict, target_name)) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->str_btn))) - { - const char *w = gtk_entry_get_text (GTK_ENTRY (cd->width_entry)); - g_string_append_printf (string, - "STRING %s (a%s).\n", target_name, w); - } + { + const char *w = gtk_entry_get_text (GTK_ENTRY (cd->width_entry)); + g_string_append_printf (string, + "STRING %s (a%s).\n", target_name, w); + } else - g_string_append_printf (string, "NUMERIC %s.\n", target_name); + g_string_append_printf (string, "NUMERIC %s.\n", target_name); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->user_label))) @@ -77,13 +77,13 @@ generate_syntax (const PsppireDialogAction *act) if (strlen (label) > 0) g_string_append_printf (string, "VARIABLE LABEL %s '%s'.\n", - target_name, - label); + target_name, + label); g_string_append_printf (string, "COMPUTE %s = %s.\n", - target_name, - expression - ); + target_name, + expression + ); g_string_append (string, "EXECUTE.\n"); @@ -165,10 +165,10 @@ function_list_populate (GtkTreeView *tv) gtk_list_store_append (liststore, &iter); gtk_list_store_set (liststore, &iter, - COMPUTE_COL_NAME, expr_operation_get_name (op), - COMPUTE_COL_USAGE, expr_operation_get_prototype (op), - COMPUTE_COL_ARITY, expr_operation_get_n_args (op), - -1); + COMPUTE_COL_NAME, expr_operation_get_name (op), + COMPUTE_COL_USAGE, expr_operation_get_prototype (op), + COMPUTE_COL_ARITY, expr_operation_get_n_args (op), + -1); } @@ -217,18 +217,18 @@ reset_type_label_dialog (PsppireDialogActionCompute *cd) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->user_label), TRUE); if (label) - { - gtk_entry_set_text (GTK_ENTRY (cd->entry), label); - } + { + gtk_entry_set_text (GTK_ENTRY (cd->entry), label); + } gtk_widget_set_sensitive (cd->width_entry, FALSE); if (var_is_numeric (target_var)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->numeric_target), - TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->numeric_target), + TRUE); else - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->str_btn), - TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->str_btn), + TRUE); gtk_widget_set_sensitive (cd->numeric_target, FALSE); gtk_widget_set_sensitive (cd->str_btn, FALSE); @@ -242,7 +242,7 @@ reset_type_label_dialog (PsppireDialogActionCompute *cd) gtk_widget_set_sensitive (cd->str_btn, TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->numeric_target), - TRUE); + TRUE); } } @@ -338,14 +338,14 @@ on_expression_toggle (GtkToggleButton *button, gpointer data) const gchar *target_name = gtk_entry_get_text (GTK_ENTRY (cd->target)); const struct variable *target_var = psppire_dict_lookup_var (pda->dict, target_name); if (target_var) - { - const char *label = var_get_label (target_var); + { + const char *label = var_get_label (target_var); - if (label) - gtk_entry_set_text (GTK_ENTRY (cd->entry), label); - } + if (label) + gtk_entry_set_text (GTK_ENTRY (cd->entry), label); + } else - gtk_entry_set_text (GTK_ENTRY (cd->entry), ""); + gtk_entry_set_text (GTK_ENTRY (cd->entry), ""); gtk_widget_set_sensitive (cd->entry, TRUE); gtk_widget_grab_focus (cd->entry); @@ -358,9 +358,9 @@ on_expression_toggle (GtkToggleButton *button, gpointer data) */ static void insert_source_row_into_text_view (GtkTreeIter iter, - GtkWidget *dest, - GtkTreeModel *model, - gpointer data) + GtkWidget *dest, + GtkTreeModel *model, + gpointer data) { GtkTreePath *path; GtkTreeModel *m; @@ -392,9 +392,9 @@ insert_source_row_into_text_view (GtkTreeIter iter, static void insert_function_into_syntax_area (GtkTreeIter iter, - GtkWidget *text_view, - GtkTreeModel *model, - gpointer data) + GtkWidget *text_view, + GtkTreeModel *model, + gpointer data) { GString *string; GValue name_value = {0}; @@ -438,8 +438,8 @@ insert_function_into_syntax_area (GtkTreeIter iter, gtk_text_buffer_get_iter_at_mark (buffer, &insert, cursor); for (i = 0 ; i < arity ; ++i) { - gtk_text_iter_backward_cursor_position (&insert); - gtk_text_iter_backward_cursor_position (&insert); + gtk_text_iter_backward_cursor_position (&insert); + gtk_text_iter_backward_cursor_position (&insert); } selectbound = insert; gtk_text_iter_forward_cursor_position (&selectbound); @@ -482,35 +482,35 @@ psppire_dialog_action_compute_activate (PsppireDialogAction *a, GVariant *param) act->str_btn = get_widget_assert (xml, "radio-button-string"); g_signal_connect (act->expression, "toggled", - G_CALLBACK (on_expression_toggle), pda); + G_CALLBACK (on_expression_toggle), pda); g_signal_connect (act->str_btn, "toggled", - G_CALLBACK (on_type_toggled), pda); + G_CALLBACK (on_type_toggled), pda); g_object_set (pda->source, - "selection-mode", GTK_SELECTION_SINGLE, - NULL); + "selection-mode", GTK_SELECTION_SINGLE, + NULL); psppire_selector_set_select_func (PSPPIRE_SELECTOR (act->var_selector), - insert_source_row_into_text_view, NULL); + insert_source_row_into_text_view, NULL); function_list_populate (GTK_TREE_VIEW (act->functions)); psppire_selector_set_select_func (PSPPIRE_SELECTOR (act->func_selector), - insert_function_into_syntax_area, NULL); + insert_function_into_syntax_area, NULL); g_signal_connect (act->target, "changed", G_CALLBACK (on_target_change), act); g_signal_connect (act->keypad, "insert-syntax", - G_CALLBACK (on_keypad_button), act); + G_CALLBACK (on_keypad_button), act); g_signal_connect (act->keypad, "erase", - G_CALLBACK (erase), act); + G_CALLBACK (erase), act); g_signal_connect (act->type_and_label, "clicked", - G_CALLBACK (run_type_label_dialog), pda); + G_CALLBACK (run_type_label_dialog), pda); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); diff --git a/src/ui/gui/psppire-dialog-action-compute.h b/src/ui/gui/psppire-dialog-action-compute.h index c988710463..48b9f1738d 100644 --- a/src/ui/gui/psppire-dialog-action-compute.h +++ b/src/ui/gui/psppire-dialog-action-compute.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE (psppire_dialog_action_compute_get_type ()) -#define PSPPIRE_DIALOG_ACTION_COMPUTE(obj) \ +#define PSPPIRE_DIALOG_ACTION_COMPUTE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, PsppireDialogActionCompute)) + PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, PsppireDialogActionCompute)) #define PSPPIRE_DIALOG_ACTION_COMPUTE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, \ + PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, \ PsppireDialogActionComputeClass)) #define PSPPIRE_IS_DIALOG_ACTION_COMPUTE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE)) #define PSPPIRE_IS_DIALOG_ACTION_COMPUTE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE)) #define PSPPIRE_DIALOG_ACTION_COMPUTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, \ - PsppireDialogActionComputeClass)) + PSPPIRE_TYPE_DIALOG_ACTION_COMPUTE, \ + PsppireDialogActionComputeClass)) typedef struct _PsppireDialogActionCompute PsppireDialogActionCompute; typedef struct _PsppireDialogActionComputeClass PsppireDialogActionComputeClass; diff --git a/src/ui/gui/psppire-dialog-action-correlation.h b/src/ui/gui/psppire-dialog-action-correlation.h index f4a4855fab..3ac4bea81a 100644 --- a/src/ui/gui/psppire-dialog-action-correlation.h +++ b/src/ui/gui/psppire-dialog-action-correlation.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION (psppire_dialog_action_correlation_get_type ()) -#define PSPPIRE_DIALOG_ACTION_CORRELATION(obj) \ +#define PSPPIRE_DIALOG_ACTION_CORRELATION(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, PsppireDialogActionCorrelation)) + PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, PsppireDialogActionCorrelation)) #define PSPPIRE_DIALOG_ACTION_CORRELATION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, \ + PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, \ PsppireDialogActionCorrelationClass)) #define PSPPIRE_IS_DIALOG_ACTION_CORRELATION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION)) #define PSPPIRE_IS_DIALOG_ACTION_CORRELATION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION)) #define PSPPIRE_DIALOG_ACTION_CORRELATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, \ - PsppireDialogActionCorrelationClass)) + PSPPIRE_TYPE_DIALOG_ACTION_CORRELATION, \ + PsppireDialogActionCorrelationClass)) typedef struct _PsppireDialogActionCorrelation PsppireDialogActionCorrelation; typedef struct _PsppireDialogActionCorrelationClass PsppireDialogActionCorrelationClass; diff --git a/src/ui/gui/psppire-dialog-action-count.c b/src/ui/gui/psppire-dialog-action-count.c index b1ee11dc15..88d38deafb 100644 --- a/src/ui/gui/psppire-dialog-action-count.c +++ b/src/ui/gui/psppire-dialog-action-count.c @@ -64,7 +64,7 @@ generate_syntax (const PsppireDialogAction *act) ds_put_cstr (&dds, "("); for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (cnt->value_list), - &iter); + &iter); ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (cnt->value_list), &iter)) { @@ -72,7 +72,7 @@ generate_syntax (const PsppireDialogAction *act) struct old_value *ov; gtk_tree_model_get_value (GTK_TREE_MODEL (cnt->value_list), &iter, - 0, &a_value); + 0, &a_value); ov = g_value_get_boxed (&a_value); @@ -117,7 +117,7 @@ dialog_state_valid (gpointer data) if (! cnt->value_list) return FALSE; - if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (cnt->value_list), &iter)) + if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (cnt->value_list), &iter)) return FALSE; if (!gtk_tree_model_get_iter_first (gtk_tree_view_get_model (GTK_TREE_VIEW (cnt->variable_treeview)), &iter)) @@ -211,7 +211,7 @@ on_acr_selection_change (GtkTreeSelection *selection, gpointer data) return; gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, - 0, &ov_value); + 0, &ov_value); ov = g_value_get_boxed (&ov_value); psppire_val_chooser_set_status (PSPPIRE_VAL_CHOOSER (cnt->chooser), ov); @@ -258,7 +258,7 @@ values_dialog (PsppireDialogActionCount *cd) { GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (PSPPIRE_ACR(acr)->tv)); g_signal_connect (sel, "changed", - G_CALLBACK (on_acr_selection_change), cd); + G_CALLBACK (on_acr_selection_change), cd); } response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); diff --git a/src/ui/gui/psppire-dialog-action-count.h b/src/ui/gui/psppire-dialog-action-count.h index af4bdcecd3..48cfa47c7f 100644 --- a/src/ui/gui/psppire-dialog-action-count.h +++ b/src/ui/gui/psppire-dialog-action-count.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_COUNT (psppire_dialog_action_count_get_type ()) -#define PSPPIRE_DIALOG_ACTION_COUNT(obj) \ +#define PSPPIRE_DIALOG_ACTION_COUNT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COUNT, PsppireDialogActionCount)) + PSPPIRE_TYPE_DIALOG_ACTION_COUNT, PsppireDialogActionCount)) #define PSPPIRE_DIALOG_ACTION_COUNT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_COUNT, \ + PSPPIRE_TYPE_DIALOG_ACTION_COUNT, \ PsppireDialogActionCountClass)) #define PSPPIRE_IS_DIALOG_ACTION_COUNT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COUNT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_COUNT)) #define PSPPIRE_IS_DIALOG_ACTION_COUNT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_COUNT)) #define PSPPIRE_DIALOG_ACTION_COUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_COUNT, \ - PsppireDialogActionCountClass)) + PSPPIRE_TYPE_DIALOG_ACTION_COUNT, \ + PsppireDialogActionCountClass)) typedef struct _PsppireDialogActionCount PsppireDialogActionCount; typedef struct _PsppireDialogActionCountClass PsppireDialogActionCountClass; diff --git a/src/ui/gui/psppire-dialog-action-crosstabs.c b/src/ui/gui/psppire-dialog-action-crosstabs.c index 6b26775d71..b423f398c7 100644 --- a/src/ui/gui/psppire-dialog-action-crosstabs.c +++ b/src/ui/gui/psppire-dialog-action-crosstabs.c @@ -70,7 +70,7 @@ refresh (PsppireDialogAction *rd_) #define CROSSTABS_STATS \ CS (CHISQ, N_("Chisq"), N_("Pearson chi-square, " \ "likelihood ratio, Fisher’s exact test, continuity correction, " \ - "linear-by-linear association.")) \ + "linear-by-linear association.")) \ CS (PHI, N_("Phi and Cramer's V"), NULL) \ CS (CC, N_("CC"), N_("Contingency coefficient")) \ CS (LAMBDA, N_("Lambda"), NULL) \ @@ -156,13 +156,13 @@ on_format_clicked (PsppireDialogActionCrosstabs *cd) if (ret == PSPPIRE_RESPONSE_CONTINUE) { cd->format_options_avalue = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->avalue_button)); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->avalue_button)); cd->format_options_table = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->table_button)); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->table_button)); cd->format_options_pivot = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->pivot_button)); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->pivot_button)); } } @@ -235,32 +235,32 @@ psppire_dialog_action_crosstabs_activate (PsppireDialogAction *a, GVariant *para act->format_options_pivot = TRUE; psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (act->cell_view), - B_CS_CELL_DEFAULT, - N_CROSSTABS_CELLS, - cells); + B_CS_CELL_DEFAULT, + N_CROSSTABS_CELLS, + cells); act->cell = gtk_tree_view_get_model (GTK_TREE_VIEW (act->cell_view)); psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (act->stat_view), - B_CS_STATS_DEFAULT, - N_CROSSTABS_STATS, - stats); + B_CS_STATS_DEFAULT, + N_CROSSTABS_STATS, + stats); act->stat = gtk_tree_view_get_model (GTK_TREE_VIEW (act->stat_view)); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); g_signal_connect_swapped (act->cell_button, "clicked", - G_CALLBACK (on_cell_clicked), act); + G_CALLBACK (on_cell_clicked), act); g_signal_connect_swapped (act->stat_button, "clicked", - G_CALLBACK (on_statistics_clicked), act); + G_CALLBACK (on_statistics_clicked), act); g_signal_connect_swapped (act->format_button, "clicked", - G_CALLBACK (on_format_clicked), act); + G_CALLBACK (on_format_clicked), act); return xml; } @@ -302,27 +302,27 @@ generate_syntax (const PsppireDialogAction *a) { gboolean toggled; gtk_tree_model_get (cd->stat, &iter, - CHECKBOX_COLUMN_SELECTED, &toggled, -1); + CHECKBOX_COLUMN_SELECTED, &toggled, -1); if (toggled) - selected |= 1u << i; + selected |= 1u << i; else - selected &= ~(1u << i); + selected &= ~(1u << i); } if (!(selected & (1u << CS_STATS_NONE))) { if (selected) - { - g_string_append (string, "\n\t/STATISTICS="); - n = 0; - for (i = 0; i < N_CROSSTABS_STATS; i++) - if (selected & (1u << i)) - { - if (n++) - g_string_append (string, " "); - g_string_append (string, stats[i].name); - } - } + { + g_string_append (string, "\n\t/STATISTICS="); + n = 0; + for (i = 0; i < N_CROSSTABS_STATS; i++) + if (selected & (1u << i)) + { + if (n++) + g_string_append (string, " "); + g_string_append (string, stats[i].name); + } + } } selected = 0; @@ -331,11 +331,11 @@ generate_syntax (const PsppireDialogAction *a) { gboolean toggled; gtk_tree_model_get (cd->cell, &iter, - CHECKBOX_COLUMN_SELECTED, &toggled, -1); + CHECKBOX_COLUMN_SELECTED, &toggled, -1); if (toggled) - selected |= 1u << i; + selected |= 1u << i; else - selected &= ~(1u << i); + selected &= ~(1u << i); } @@ -347,12 +347,12 @@ generate_syntax (const PsppireDialogAction *a) { n = 0; for (i = 0; i < N_CROSSTABS_CELLS; i++) - if (selected & (1u << i)) - { - if (n++) - g_string_append (string, " "); - g_string_append (string, cells[i].name); - } + if (selected & (1u << i)) + { + if (n++) + g_string_append (string, " "); + g_string_append (string, cells[i].name); + } } g_string_append (string, ".\n"); diff --git a/src/ui/gui/psppire-dialog-action-crosstabs.h b/src/ui/gui/psppire-dialog-action-crosstabs.h index ac287057b7..6df826561a 100644 --- a/src/ui/gui/psppire-dialog-action-crosstabs.h +++ b/src/ui/gui/psppire-dialog-action-crosstabs.h @@ -36,26 +36,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS (psppire_dialog_action_crosstabs_get_type ()) -#define PSPPIRE_DIALOG_ACTION_CROSSTABS(obj) \ +#define PSPPIRE_DIALOG_ACTION_CROSSTABS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, PsppireDialogActionCrosstabs)) + PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, PsppireDialogActionCrosstabs)) #define PSPPIRE_DIALOG_ACTION_CROSSTABS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \ + PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \ PsppireDialogActionCrosstabsClass)) #define PSPPIRE_IS_DIALOG_ACTION_CROSSTABS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS)) #define PSPPIRE_IS_DIALOG_ACTION_CROSSTABS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS)) #define PSPPIRE_DIALOG_ACTION_CROSSTABS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \ - PsppireDialogActionCrosstabsClass)) + PSPPIRE_TYPE_DIALOG_ACTION_CROSSTABS, \ + PsppireDialogActionCrosstabsClass)) typedef struct _PsppireDialogActionCrosstabs PsppireDialogActionCrosstabs; typedef struct _PsppireDialogActionCrosstabsClass PsppireDialogActionCrosstabsClass; diff --git a/src/ui/gui/psppire-dialog-action-ctables.h b/src/ui/gui/psppire-dialog-action-ctables.h index 74fff28ee0..b948d6da93 100644 --- a/src/ui/gui/psppire-dialog-action-ctables.h +++ b/src/ui/gui/psppire-dialog-action-ctables.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_CTABLES (psppire_dialog_action_ctables_get_type ()) -#define PSPPIRE_DIALOG_ACTION_CTABLES(obj) \ +#define PSPPIRE_DIALOG_ACTION_CTABLES(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, PsppireDialogActionCtables)) + PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, PsppireDialogActionCtables)) #define PSPPIRE_DIALOG_ACTION_CTABLES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, \ + PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, \ PsppireDialogActionCtablesClass)) #define PSPPIRE_IS_DIALOG_ACTION_CTABLES(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CTABLES)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_CTABLES)) #define PSPPIRE_IS_DIALOG_ACTION_CTABLES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_CTABLES)) #define PSPPIRE_DIALOG_ACTION_CTABLES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, \ - PsppireDialogActionCtablesClass)) + PSPPIRE_TYPE_DIALOG_ACTION_CTABLES, \ + PsppireDialogActionCtablesClass)) typedef struct _PsppireDialogActionCtables PsppireDialogActionCtables; typedef struct _PsppireDialogActionCtablesClass PsppireDialogActionCtablesClass; diff --git a/src/ui/gui/psppire-dialog-action-descriptives.c b/src/ui/gui/psppire-dialog-action-descriptives.c index 38f63b02f5..fe17a7da3d 100644 --- a/src/ui/gui/psppire-dialog-action-descriptives.c +++ b/src/ui/gui/psppire-dialog-action-descriptives.c @@ -109,7 +109,7 @@ generate_syntax (const PsppireDialogAction *act) { gboolean toggled; gtk_tree_model_get (scd->stats, &iter, - CHECKBOX_COLUMN_SELECTED, &toggled, -1); + CHECKBOX_COLUMN_SELECTED, &toggled, -1); if (toggled) selected |= 1u << i; } @@ -179,7 +179,7 @@ dialog_refresh (PsppireDialogAction *scd_) for (i = 0, ok = gtk_tree_model_get_iter_first (scd->stats, &iter); ok; i++, ok = gtk_tree_model_iter_next (scd->stats, &iter)) gtk_list_store_set (GTK_LIST_STORE (scd->stats), &iter, - CHECKBOX_COLUMN_SELECTED, + CHECKBOX_COLUMN_SELECTED, (B_DS_DEFAULT & (1u << i)) ? true : false, -1); gtk_toggle_button_set_active (scd->exclude_missing_listwise, false); @@ -198,8 +198,8 @@ psppire_dialog_action_descriptives_activate (PsppireDialogAction *a, GVariant *p GtkWidget *stats_treeview = get_widget_assert (xml, "statistics"); psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (stats_treeview), - B_DS_DEFAULT, - N_DESCRIPTIVE_STATS, stats); + B_DS_DEFAULT, + N_DESCRIPTIVE_STATS, stats); act->stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview)); pda->dialog = get_widget_assert (xml, "descriptives-dialog"); @@ -207,7 +207,7 @@ psppire_dialog_action_descriptives_activate (PsppireDialogAction *a, GVariant *p act->variables = get_widget_assert (xml, "stat-variables"); g_object_set (pda->source, - "predicate", var_is_numeric, NULL); + "predicate", var_is_numeric, NULL); act->stat_vars = GTK_TREE_VIEW (act->variables); diff --git a/src/ui/gui/psppire-dialog-action-descriptives.h b/src/ui/gui/psppire-dialog-action-descriptives.h index f39aedb48d..ee77210a93 100644 --- a/src/ui/gui/psppire-dialog-action-descriptives.h +++ b/src/ui/gui/psppire-dialog-action-descriptives.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES (psppire_dialog_action_descriptives_get_type ()) -#define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES(obj) \ +#define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, PsppireDialogActionDescriptives)) + PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, PsppireDialogActionDescriptives)) #define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \ + PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \ PsppireDialogActionDescriptivesClass)) #define PSPPIRE_IS_DIALOG_ACTION_DESCRIPTIVES(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES)) #define PSPPIRE_IS_DIALOG_ACTION_DESCRIPTIVES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES)) #define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \ - PsppireDialogActionDescriptivesClass)) + PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \ + PsppireDialogActionDescriptivesClass)) typedef struct _PsppireDialogActionDescriptives PsppireDialogActionDescriptives; typedef struct _PsppireDialogActionDescriptivesClass PsppireDialogActionDescriptivesClass; diff --git a/src/ui/gui/psppire-dialog-action-examine.c b/src/ui/gui/psppire-dialog-action-examine.c index 36e8505ffb..9c16f6ac6d 100644 --- a/src/ui/gui/psppire-dialog-action-examine.c +++ b/src/ui/gui/psppire-dialog-action-examine.c @@ -45,13 +45,13 @@ run_stats_dialog (PsppireDialogActionExamine *ed) gint response; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->descriptives_button), - ed->stats & STAT_DESCRIPTIVES); + ed->stats & STAT_DESCRIPTIVES); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->extremes_button), - ed->stats & STAT_EXTREMES); + ed->stats & STAT_EXTREMES); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->percentiles_button), - ed->stats & STAT_PERCENTILES); + ed->stats & STAT_PERCENTILES); response = psppire_dialog_run (PSPPIRE_DIALOG (ed->stats_dialog)); @@ -59,13 +59,13 @@ run_stats_dialog (PsppireDialogActionExamine *ed) { ed->stats = 0; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->descriptives_button))) - ed->stats |= STAT_DESCRIPTIVES; + ed->stats |= STAT_DESCRIPTIVES; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->extremes_button))) - ed->stats |= STAT_EXTREMES; + ed->stats |= STAT_EXTREMES; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->percentiles_button))) - ed->stats |= STAT_PERCENTILES; + ed->stats |= STAT_PERCENTILES; } } @@ -95,11 +95,11 @@ run_opts_dialog (PsppireDialogActionExamine *ed) if (response == PSPPIRE_RESPONSE_CONTINUE) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->listwise))) - ed->opts = OPT_LISTWISE; + ed->opts = OPT_LISTWISE; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->pairwise))) - ed->opts = OPT_PAIRWISE; + ed->opts = OPT_PAIRWISE; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->report))) - ed->opts = OPT_REPORT; + ed->opts = OPT_REPORT; } } @@ -179,36 +179,36 @@ run_plots_dialog (PsppireDialogActionExamine *ed) if (response == PSPPIRE_RESPONSE_CONTINUE) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->boxplot_factors_button))) - ed->boxplots = BOXPLOT_FACTORS; + ed->boxplots = BOXPLOT_FACTORS; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->boxplot_dependents_button))) - ed->boxplots = BOXPLOT_DEPENDENTS; + ed->boxplots = BOXPLOT_DEPENDENTS; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->boxplot_none_button))) - ed->boxplots = BOXPLOT_NONE; + ed->boxplots = BOXPLOT_NONE; ed->histogram = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->histogram_button)); ed->npplots = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->npplots_button)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->spread_none_button))) - ed->spreadlevel = SPREAD_NONE; + ed->spreadlevel = SPREAD_NONE; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->spread_power_button))) - ed->spreadlevel = SPREAD_POWER; + ed->spreadlevel = SPREAD_POWER; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->spread_trans_button))) - ed->spreadlevel = SPREAD_TRANS; + ed->spreadlevel = SPREAD_TRANS; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->spread_untrans_button))) - ed->spreadlevel = SPREAD_UNTRANS; + ed->spreadlevel = SPREAD_UNTRANS; if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "natlog")) - ed->spreadpower = SPREADPOWER_NATLOG; + ed->spreadpower = SPREADPOWER_NATLOG; else if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "cube")) - ed->spreadpower = SPREADPOWER_CUBE; + ed->spreadpower = SPREADPOWER_CUBE; else if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "square")) - ed->spreadpower = SPREADPOWER_SQUARE; + ed->spreadpower = SPREADPOWER_SQUARE; else if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "squareroot")) - ed->spreadpower = SPREADPOWER_SQUAREROOT; + ed->spreadpower = SPREADPOWER_SQUAREROOT; else if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "recroot")) - ed->spreadpower = SPREADPOWER_RECROOT; + ed->spreadpower = SPREADPOWER_RECROOT; else if (0 == strcmp (gtk_combo_box_get_active_id (GTK_COMBO_BOX (ed->spread_power_combo)), "reciprocal")) - ed->spreadpower = SPREADPOWER_RECIPROCAL; + ed->spreadpower = SPREADPOWER_RECIPROCAL; } } @@ -248,18 +248,18 @@ generate_syntax (const PsppireDialogAction *act) if (show_stats) { if (ed->stats & (STAT_DESCRIPTIVES | STAT_EXTREMES)) - { - g_string_append (str, "\n\t/STATISTICS ="); + { + g_string_append (str, "\n\t/STATISTICS ="); - if (ed->stats & STAT_DESCRIPTIVES) - g_string_append (str, " DESCRIPTIVES"); + if (ed->stats & STAT_DESCRIPTIVES) + g_string_append (str, " DESCRIPTIVES"); - if (ed->stats & STAT_EXTREMES) - g_string_append (str, " EXTREME"); - } + if (ed->stats & STAT_EXTREMES) + g_string_append (str, " EXTREME"); + } if (ed->stats & STAT_PERCENTILES) - g_string_append (str, "\n\t/PERCENTILES"); + g_string_append (str, "\n\t/PERCENTILES"); } if (show_plots && @@ -271,51 +271,51 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (str, "\n\t/PLOT ="); if (ed->boxplots != BOXPLOT_NONE) - g_string_append (str, " BOXPLOT"); + g_string_append (str, " BOXPLOT"); if (ed->histogram) - g_string_append (str, " HISTOGRAM"); + g_string_append (str, " HISTOGRAM"); if (ed->npplots) - g_string_append (str, " NPPLOT"); + g_string_append (str, " NPPLOT"); if (ed->spreadlevel != SPREAD_NONE) - { - g_string_append (str, " SPREADLEVEL"); - if (ed->spreadlevel != SPREAD_POWER) - { - const gchar *power = NULL; - if (ed->spreadlevel == SPREAD_TRANS) - switch (ed->spreadpower) - { - case SPREADPOWER_NATLOG: - power = "0"; - break; - case SPREADPOWER_CUBE: - power = "3"; - break; - case SPREADPOWER_SQUARE: - power = "2"; - break; - case SPREADPOWER_SQUAREROOT: - power = "0.5"; - break; - case SPREADPOWER_RECROOT: - power = "-0.5"; - break; - case SPREADPOWER_RECIPROCAL: - power = "-1"; - break; - default: - g_assert_not_reached (); - break; - } - else - power = "1"; - g_string_append_printf(str, " (%s)",power); - } - } + { + g_string_append (str, " SPREADLEVEL"); + if (ed->spreadlevel != SPREAD_POWER) + { + const gchar *power = NULL; + if (ed->spreadlevel == SPREAD_TRANS) + switch (ed->spreadpower) + { + case SPREADPOWER_NATLOG: + power = "0"; + break; + case SPREADPOWER_CUBE: + power = "3"; + break; + case SPREADPOWER_SQUARE: + power = "2"; + break; + case SPREADPOWER_SQUAREROOT: + power = "0.5"; + break; + case SPREADPOWER_RECROOT: + power = "-0.5"; + break; + case SPREADPOWER_RECIPROCAL: + power = "-1"; + break; + default: + g_assert_not_reached (); + break; + } + else + power = "1"; + g_string_append_printf(str, " (%s)",power); + } + } if (ed->boxplots == BOXPLOT_FACTORS) - g_string_append (str, "\n\t/COMPARE = GROUPS"); + g_string_append (str, "\n\t/COMPARE = GROUPS"); if (ed->boxplots == BOXPLOT_DEPENDENTS) - g_string_append (str, "\n\t/COMPARE = VARIABLES"); + g_string_append (str, "\n\t/COMPARE = VARIABLES"); } g_string_append (str, "\n\t/MISSING="); @@ -385,12 +385,12 @@ psppire_dialog_action_examine_activate (PsppireDialogAction *a, GVariant *param) GtkWidget *plots_button = get_widget_assert (xml, "plots-button"); g_signal_connect_swapped (stats_button, "clicked", - G_CALLBACK (run_stats_dialog), act); + G_CALLBACK (run_stats_dialog), act); g_signal_connect_swapped (opts_button, "clicked", - G_CALLBACK (run_opts_dialog), act); + G_CALLBACK (run_opts_dialog), act); g_signal_connect_swapped (plots_button, "clicked", - G_CALLBACK (run_plots_dialog), act); + G_CALLBACK (run_plots_dialog), act); GtkWidget *dep_sel = get_widget_assert (xml, "psppire-selector1"); GtkWidget *dep_sel2 = get_widget_assert (xml, "psppire-selector2"); diff --git a/src/ui/gui/psppire-dialog-action-examine.h b/src/ui/gui/psppire-dialog-action-examine.h index 81e290e35c..73a8b68c5d 100644 --- a/src/ui/gui/psppire-dialog-action-examine.h +++ b/src/ui/gui/psppire-dialog-action-examine.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE (psppire_dialog_action_examine_get_type ()) -#define PSPPIRE_DIALOG_ACTION_EXAMINE(obj) \ +#define PSPPIRE_DIALOG_ACTION_EXAMINE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, PsppireDialogActionExamine)) + PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, PsppireDialogActionExamine)) #define PSPPIRE_DIALOG_ACTION_EXAMINE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \ + PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \ PsppireDialogActionExamineClass)) #define PSPPIRE_IS_DIALOG_ACTION_EXAMINE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE)) #define PSPPIRE_IS_DIALOG_ACTION_EXAMINE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE)) #define PSPPIRE_DIALOG_ACTION_EXAMINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \ - PsppireDialogActionExamineClass)) + PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \ + PsppireDialogActionExamineClass)) typedef struct _PsppireDialogActionExamine PsppireDialogActionExamine; typedef struct _PsppireDialogActionExamineClass PsppireDialogActionExamineClass; diff --git a/src/ui/gui/psppire-dialog-action-factor.c b/src/ui/gui/psppire-dialog-action-factor.c index 48f72ffbd6..5d8b4f23c1 100644 --- a/src/ui/gui/psppire-dialog-action-factor.c +++ b/src/ui/gui/psppire-dialog-action-factor.c @@ -132,10 +132,10 @@ static void load_rotation_parameters (PsppireDialogActionFactor *fd, const struct rotation_parameters *p) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->display_rotated_solution), - p->rotated_solution); + p->rotated_solution); gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->rotate_iterations), - p->iterations); + p->iterations); switch (p->method) { @@ -323,9 +323,9 @@ psppire_dialog_action_factor_activate (PsppireDialogAction *a, GVariant *param) eigenvalue_extraction = psppire_scanf_new (_("_Eigenvalues over %4.2f times the mean eigenvalue"), &act->mineigen); g_object_set (eigenvalue_extraction, - "use-underline", TRUE, - "mnemonic-widget", act->mineigen_toggle, - NULL); + "use-underline", TRUE, + "mnemonic-widget", act->mineigen_toggle, + NULL); act->nfactors_toggle = get_widget_assert (xml, "nfactors-radiobutton"); act->n_factors = get_widget_assert (xml, "spinbutton-nfactors"); @@ -356,7 +356,7 @@ psppire_dialog_action_factor_activate (PsppireDialogAction *a, GVariant *param) } g_signal_connect_swapped (extraction_button, "clicked", - G_CALLBACK (run_extractions_subdialog), act); + G_CALLBACK (run_extractions_subdialog), act); g_signal_connect_swapped (rotation_button, "clicked", G_CALLBACK (run_rotations_subdialog), act); psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid); diff --git a/src/ui/gui/psppire-dialog-action-factor.h b/src/ui/gui/psppire-dialog-action-factor.h index 8e4fe867d6..886b4a1c54 100644 --- a/src/ui/gui/psppire-dialog-action-factor.h +++ b/src/ui/gui/psppire-dialog-action-factor.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_FACTOR (psppire_dialog_action_factor_get_type ()) -#define PSPPIRE_DIALOG_ACTION_FACTOR(obj) \ +#define PSPPIRE_DIALOG_ACTION_FACTOR(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, PsppireDialogActionFactor)) + PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, PsppireDialogActionFactor)) #define PSPPIRE_DIALOG_ACTION_FACTOR_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, \ + PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, \ PsppireDialogActionFactorClass)) #define PSPPIRE_IS_DIALOG_ACTION_FACTOR(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FACTOR)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FACTOR)) #define PSPPIRE_IS_DIALOG_ACTION_FACTOR_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_FACTOR)) #define PSPPIRE_DIALOG_ACTION_FACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, \ - PsppireDialogActionFactorClass)) + PSPPIRE_TYPE_DIALOG_ACTION_FACTOR, \ + PsppireDialogActionFactorClass)) typedef struct _PsppireDialogActionFactor PsppireDialogActionFactor; typedef struct _PsppireDialogActionFactorClass PsppireDialogActionFactorClass; diff --git a/src/ui/gui/psppire-dialog-action-flip.h b/src/ui/gui/psppire-dialog-action-flip.h index b7a46e0912..0b40ecb948 100644 --- a/src/ui/gui/psppire-dialog-action-flip.h +++ b/src/ui/gui/psppire-dialog-action-flip.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_FLIP (psppire_dialog_action_flip_get_type ()) -#define PSPPIRE_DIALOG_ACTION_FLIP(obj) \ +#define PSPPIRE_DIALOG_ACTION_FLIP(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FLIP, PsppireDialogActionFlip)) + PSPPIRE_TYPE_DIALOG_ACTION_FLIP, PsppireDialogActionFlip)) #define PSPPIRE_DIALOG_ACTION_FLIP_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_FLIP, \ + PSPPIRE_TYPE_DIALOG_ACTION_FLIP, \ PsppireDialogActionFlipClass)) #define PSPPIRE_IS_DIALOG_ACTION_FLIP(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FLIP)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FLIP)) #define PSPPIRE_IS_DIALOG_ACTION_FLIP_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_FLIP)) #define PSPPIRE_DIALOG_ACTION_FLIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FLIP, \ - PsppireDialogActionFlipClass)) + PSPPIRE_TYPE_DIALOG_ACTION_FLIP, \ + PsppireDialogActionFlipClass)) typedef struct _PsppireDialogActionFlip PsppireDialogActionFlip; typedef struct _PsppireDialogActionFlipClass PsppireDialogActionFlipClass; diff --git a/src/ui/gui/psppire-dialog-action-frequencies.c b/src/ui/gui/psppire-dialog-action-frequencies.c index 714745ca26..741bc1ee53 100644 --- a/src/ui/gui/psppire-dialog-action-frequencies.c +++ b/src/ui/gui/psppire-dialog-action-frequencies.c @@ -36,20 +36,20 @@ #define N_(msgid) msgid -#define FREQUENCY_STATS \ - FS (MEAN, N_("Mean")) \ - FS (STDDEV, N_("Standard deviation")) \ - FS (MINIMUM, N_("Minimum")) \ - FS (MAXIMUM, N_("Maximum")) \ - FS (SEMEAN, N_("Standard error of the mean")) \ - FS (VARIANCE, N_("Variance")) \ - FS (SKEWNESS, N_("Skewness")) \ - FS (SESKEW, N_("Standard error of the skewness")) \ - FS (RANGE, N_("Range")) \ - FS (MODE, N_("Mode")) \ - FS (KURTOSIS, N_("Kurtosis")) \ - FS (SEKURT, N_("Standard error of the kurtosis")) \ - FS (MEDIAN, N_("Median")) \ +#define FREQUENCY_STATS \ + FS (MEAN, N_("Mean")) \ + FS (STDDEV, N_("Standard deviation")) \ + FS (MINIMUM, N_("Minimum")) \ + FS (MAXIMUM, N_("Maximum")) \ + FS (SEMEAN, N_("Standard error of the mean")) \ + FS (VARIANCE, N_("Variance")) \ + FS (SKEWNESS, N_("Skewness")) \ + FS (SESKEW, N_("Standard error of the skewness")) \ + FS (RANGE, N_("Range")) \ + FS (MODE, N_("Mode")) \ + FS (KURTOSIS, N_("Kurtosis")) \ + FS (SEKURT, N_("Standard error of the kurtosis")) \ + FS (MEDIAN, N_("Median")) \ FS (SUM, N_("Sum")) @@ -195,13 +195,13 @@ on_charts_clicked (PsppireDialogActionFrequencies *fd) fd->charts_opts_draw_hist = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->hist)); fd->charts_opts_draw_normal = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->normal)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->freqs))) - fd->charts_opts_scale = FRQ_FREQ; + fd->charts_opts_scale = FRQ_FREQ; else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->percents))) - fd->charts_opts_scale = FRQ_PERCENT; + fd->charts_opts_scale = FRQ_PERCENT; fd->charts_opts_draw_pie = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie)); fd->charts_opts_pie_include_missing - = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing)); + = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing)); fd->charts_opts_draw_bar = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->bar)); @@ -262,7 +262,7 @@ psppire_dialog_action_frequencies_activate (PsppireDialogAction *a, GVariant *pa GtkWidget *stats_treeview = get_widget_assert (xml, "stats-treeview"); psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (stats_treeview), - B_FS_DEFAULT, N_FREQUENCY_STATS, stats); + B_FS_DEFAULT, N_FREQUENCY_STATS, stats); act->stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview)); @@ -283,8 +283,8 @@ psppire_dialog_action_frequencies_activate (PsppireDialogAction *a, GVariant *pa act->limit_spinbutton = get_widget_assert (xml, "limit-spin"); g_signal_connect (act->limit, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - act->limit_spinbutton); + G_CALLBACK (set_sensitivity_from_toggle), + act->limit_spinbutton); act->avalue = get_widget_assert (xml, "avalue"); act->dvalue = get_widget_assert (xml, "dvalue"); @@ -308,16 +308,16 @@ psppire_dialog_action_frequencies_activate (PsppireDialogAction *a, GVariant *pa act->min = get_widget_assert (xml, "min"); act->min_spin = get_widget_assert (xml, "min-spin"); g_signal_connect (act->min, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), act->min_spin); + G_CALLBACK (set_sensitivity_from_toggle), act->min_spin); act->max = get_widget_assert (xml, "max"); act->max_spin = get_widget_assert (xml, "max-spin"); g_signal_connect (act->max, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), act->max_spin); + G_CALLBACK (set_sensitivity_from_toggle), act->max_spin); act->hist = get_widget_assert (xml, "hist"); act->normal = get_widget_assert (xml, "normal"); g_signal_connect (act->hist, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), act->normal); + G_CALLBACK (set_sensitivity_from_toggle), act->normal); act->pie = (get_widget_assert (xml, "pie")); act->pie_include_missing = get_widget_assert (xml, "pie-include-missing"); @@ -329,10 +329,10 @@ psppire_dialog_action_frequencies_activate (PsppireDialogAction *a, GVariant *pa act->tables_opts_limit = 50; g_signal_connect_swapped (tables_button, "clicked", - G_CALLBACK (on_tables_clicked), act); + G_CALLBACK (on_tables_clicked), act); g_signal_connect_swapped (charts_button, "clicked", - G_CALLBACK (on_charts_clicked), act); + G_CALLBACK (on_charts_clicked), act); psppire_dialog_action_set_refresh (pda, refresh); @@ -437,7 +437,7 @@ generate_syntax (const PsppireDialogAction * a) { ds_put_cstr (&str, "\n\t/HISTOGRAM="); ds_put_cstr (&str, - fd->charts_opts_draw_normal ? "NORMAL" : "NONORMAL"); + fd->charts_opts_draw_normal ? "NORMAL" : "NONORMAL"); if (fd->charts_opts_scale == FRQ_PERCENT) ds_put_cstr (&str, " PERCENT"); diff --git a/src/ui/gui/psppire-dialog-action-frequencies.h b/src/ui/gui/psppire-dialog-action-frequencies.h index 9f6c122e4d..c9a821842e 100644 --- a/src/ui/gui/psppire-dialog-action-frequencies.h +++ b/src/ui/gui/psppire-dialog-action-frequencies.h @@ -28,27 +28,27 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES (psppire_dialog_action_frequencies_get_type ()) -#define PSPPIRE_DIALOG_ACTION_FREQUENCIES(obj) \ +#define PSPPIRE_DIALOG_ACTION_FREQUENCIES(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ + PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ PsppireDialogActionFrequencies)) #define PSPPIRE_DIALOG_ACTION_FREQUENCIES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ + PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ PsppireDialogActionFrequenciesClass)) #define PSPPIRE_IS_DIALOG_ACTION_FREQUENCIES(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES)) #define PSPPIRE_IS_DIALOG_ACTION_FREQUENCIES_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES)) #define PSPPIRE_DIALOG_ACTION_FREQUENCIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ - PsppireDialogActionFrequenciesClass)) + PSPPIRE_TYPE_DIALOG_ACTION_FREQUENCIES, \ + PsppireDialogActionFrequenciesClass)) typedef struct _PsppireDialogActionFrequencies PsppireDialogActionFrequencies; typedef struct _PsppireDialogActionFrequenciesClass PsppireDialogActionFrequenciesClass; diff --git a/src/ui/gui/psppire-dialog-action-histogram.c b/src/ui/gui/psppire-dialog-action-histogram.c index 99b07b2846..24a4367c4a 100644 --- a/src/ui/gui/psppire-dialog-action-histogram.c +++ b/src/ui/gui/psppire-dialog-action-histogram.c @@ -70,7 +70,7 @@ psppire_dialog_action_histogram_activate (PsppireDialogAction *a, GVariant *para pda->source = get_widget_assert (xml, "dict-view"); g_object_set (pda->source, - "predicate", var_is_numeric, NULL); + "predicate", var_is_numeric, NULL); act->variable = get_widget_assert (xml, "entry1"); act->curve = get_widget_assert (xml, "curve"); @@ -78,7 +78,7 @@ psppire_dialog_action_histogram_activate (PsppireDialogAction *a, GVariant *para psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-histogram.h b/src/ui/gui/psppire-dialog-action-histogram.h index a80910b826..e8c14a2e31 100644 --- a/src/ui/gui/psppire-dialog-action-histogram.h +++ b/src/ui/gui/psppire-dialog-action-histogram.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM (psppire_dialog_action_histogram_get_type ()) -#define PSPPIRE_DIALOG_ACTION_HISTOGRAM(obj) \ +#define PSPPIRE_DIALOG_ACTION_HISTOGRAM(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, PsppireDialogActionHistogram)) + PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, PsppireDialogActionHistogram)) #define PSPPIRE_DIALOG_ACTION_HISTOGRAM_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, \ + PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, \ PsppireDialogActionHistogramClass)) #define PSPPIRE_IS_DIALOG_ACTION_HISTOGRAM(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM)) #define PSPPIRE_IS_DIALOG_ACTION_HISTOGRAM_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM)) #define PSPPIRE_DIALOG_ACTION_HISTOGRAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, \ - PsppireDialogActionHistogramClass)) + PSPPIRE_TYPE_DIALOG_ACTION_HISTOGRAM, \ + PsppireDialogActionHistogramClass)) typedef struct _PsppireDialogActionHistogram PsppireDialogActionHistogram; typedef struct _PsppireDialogActionHistogramClass PsppireDialogActionHistogramClass; diff --git a/src/ui/gui/psppire-dialog-action-indep-samps.c b/src/ui/gui/psppire-dialog-action-indep-samps.c index c52976e3ae..17f81271b4 100644 --- a/src/ui/gui/psppire-dialog-action-indep-samps.c +++ b/src/ui/gui/psppire-dialog-action-indep-samps.c @@ -104,14 +104,14 @@ value_entry_contains_invalid (PsppireValueEntry *ve, const struct variable *var) value_init (&val, width); if (psppire_value_entry_get_value (ve, &val, width)) - { - if (var_is_value_missing (var, &val) == MV_SYSTEM) - { - result = TRUE; - } - } + { + if (var_is_value_missing (var, &val) == MV_SYSTEM) + { + result = TRUE; + } + } else - result = TRUE; + result = TRUE; value_destroy (&val, width); } @@ -133,17 +133,17 @@ define_groups_state_valid (gpointer data) (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button))) { if (value_entry_contains_invalid (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[0]), - act->grp_var)) + act->grp_var)) return FALSE; if (value_entry_contains_invalid (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[1]), - act->grp_var)) + act->grp_var)) return FALSE; } else { if (value_entry_contains_invalid (PSPPIRE_VALUE_ENTRY (act->dg_cut_point_entry), - act->grp_var)) + act->grp_var)) return FALSE; } @@ -170,7 +170,7 @@ run_define_groups (PsppireDialogActionIndepSamps *act) if (var_is_numeric (act->grp_var)) { gtk_grid_attach (GTK_GRID (act->dg_table1), act->dg_table2, - 1, 1, 1, 1); + 1, 1, 1, 1); gtk_container_add (GTK_CONTAINER (act->dg_box), act->dg_table1); } @@ -182,7 +182,7 @@ run_define_groups (PsppireDialogActionIndepSamps *act) psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (act->dg_dialog), - define_groups_state_valid, act); + define_groups_state_valid, act); psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[0]), act->grp_var); psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[1]), act->grp_var); @@ -191,18 +191,18 @@ run_define_groups (PsppireDialogActionIndepSamps *act) if (act->group_defn != GROUPS_CUT_POINT) { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE); + (GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE); gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button), TRUE); + (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button), TRUE); } else { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button), TRUE); + (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button), TRUE); gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE); + (GTK_TOGGLE_BUTTON (act->dg_cut_point_toggle_button), TRUE); } g_signal_emit_by_name (act->dg_grp_entry[0], "changed"); @@ -216,22 +216,22 @@ run_define_groups (PsppireDialogActionIndepSamps *act) const int width = var_get_width (act->grp_var); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->dg_values_toggle_button))) - { - act->group_defn = GROUPS_VALUES; + { + act->group_defn = GROUPS_VALUES; psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[0]), - &act->grp_val[0], width); + &act->grp_val[0], width); psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (act->dg_grp_entry[1]), - &act->grp_val[1], width); - } + &act->grp_val[1], width); + } else - { - act->group_defn = GROUPS_CUT_POINT; + { + act->group_defn = GROUPS_CUT_POINT; psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (act->dg_cut_point_entry), - &act->cut_point, width); - } + &act->cut_point, width); + } psppire_dialog_notify_change (PSPPIRE_DIALOG (da->dialog)); } @@ -271,9 +271,9 @@ on_grp_var_change (GtkEntry *entry, PsppireDialogActionIndepSamps *act) } else { - act->cut_point.s[0] = '\0'; - act->grp_val[0].s[0] = '\0'; - act->grp_val[1].s[0] = '\0'; + act->cut_point.s[0] = '\0'; + act->grp_val[0].s[0] = '\0'; + act->grp_val[1].s[0] = '\0'; } } @@ -287,7 +287,7 @@ on_grp_var_change (GtkEntry *entry, PsppireDialogActionIndepSamps *act) static void set_group_criterion_type (GtkToggleButton *button, - PsppireDialogActionIndepSamps *act) + PsppireDialogActionIndepSamps *act) { gboolean by_values = gtk_toggle_button_get_active (button); @@ -334,22 +334,22 @@ psppire_dialog_action_indep_samps_activate (PsppireDialogAction *a, GVariant *pa g_object_ref (act->dg_table2); g_signal_connect (act->dg_values_toggle_button, "toggled", - G_CALLBACK (set_group_criterion_type), act); + G_CALLBACK (set_group_criterion_type), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); g_signal_connect_swapped (act->define_groups_button, "clicked", - G_CALLBACK (run_define_groups), act); + G_CALLBACK (run_define_groups), act); g_signal_connect_swapped (act->options_button, "clicked", - G_CALLBACK (tt_options_dialog_run), act->opts); + G_CALLBACK (tt_options_dialog_run), act->opts); g_signal_connect (act->group_var_entry, "changed", - G_CALLBACK (on_grp_var_change), act); + G_CALLBACK (on_grp_var_change), act); on_grp_var_change (GTK_ENTRY (act->group_var_entry), act); @@ -391,8 +391,8 @@ generate_syntax (const PsppireDialogAction *a) } if (act->group_defn == GROUPS_VALUES) - { - g_string_append (str, ","); + { + g_string_append (str, ","); { struct string strx; @@ -405,7 +405,7 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (str, ds_cstr (&strx)); ds_destroy (&strx); } - } + } g_string_append (str, ")"); } diff --git a/src/ui/gui/psppire-dialog-action-indep-samps.h b/src/ui/gui/psppire-dialog-action-indep-samps.h index e6ae0aaef0..c4b7c21c37 100644 --- a/src/ui/gui/psppire-dialog-action-indep-samps.h +++ b/src/ui/gui/psppire-dialog-action-indep-samps.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS (psppire_dialog_action_indep_samps_get_type ()) -#define PSPPIRE_DIALOG_ACTION_INDEP_SAMPS(obj) \ +#define PSPPIRE_DIALOG_ACTION_INDEP_SAMPS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, PsppireDialogActionIndepSamps)) + PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, PsppireDialogActionIndepSamps)) #define PSPPIRE_DIALOG_ACTION_INDEP_SAMPS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, \ + PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, \ PsppireDialogActionIndepSampsClass)) #define PSPPIRE_IS_DIALOG_ACTION_INDEP_SAMPS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS)) #define PSPPIRE_IS_DIALOG_ACTION_INDEP_SAMPS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS)) #define PSPPIRE_DIALOG_ACTION_INDEP_SAMPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, \ - PsppireDialogActionIndepSampsClass)) + PSPPIRE_TYPE_DIALOG_ACTION_INDEP_SAMPS, \ + PsppireDialogActionIndepSampsClass)) typedef struct _PsppireDialogActionIndepSamps PsppireDialogActionIndepSamps; typedef struct _PsppireDialogActionIndepSampsClass PsppireDialogActionIndepSampsClass; diff --git a/src/ui/gui/psppire-dialog-action-k-independent.c b/src/ui/gui/psppire-dialog-action-k-independent.c index e3c0487b7d..c086f8fe3e 100644 --- a/src/ui/gui/psppire-dialog-action-k-independent.c +++ b/src/ui/gui/psppire-dialog-action-k-independent.c @@ -57,21 +57,21 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, "\n\t"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (kid->checkbutton[i]))) - { - g_string_append_printf (string, "/%s = ", keyword[i]); - psppire_var_view_append_names (PSPPIRE_VAR_VIEW (kid->vars_treeview), - 0, string); + { + g_string_append_printf (string, "/%s = ", keyword[i]); + psppire_var_view_append_names (PSPPIRE_VAR_VIEW (kid->vars_treeview), + 0, string); - g_string_append (string, " BY "); + g_string_append (string, " BY "); - g_string_append (string, - gtk_entry_get_text (GTK_ENTRY (kid->groupvar_entry))); + g_string_append (string, + gtk_entry_get_text (GTK_ENTRY (kid->groupvar_entry))); - g_string_append_printf (string, " (%g, %g)", - kid->lower_limit_value.f, - kid->upper_limit_value.f); - } + g_string_append_printf (string, " (%g, %g)", + kid->lower_limit_value.f, + kid->upper_limit_value.f); + } } g_string_append (string, ".\n"); @@ -101,7 +101,7 @@ dialog_state_valid (gpointer data) for (i = 0; i < n_KIDS; ++i) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (kid->checkbutton[i]))) - method_set = TRUE; + method_set = TRUE; } return method_set; @@ -123,7 +123,7 @@ refresh (PsppireDialogAction *rd_) for (i = 0; i < n_KIDS; ++i) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (kid->checkbutton[i]), - FALSE); + FALSE); } } @@ -132,20 +132,20 @@ run_define_groups_dialog (PsppireDialogActionKIndependent *kid) { if (kid->lower_limit_value.f != SYSMIS) psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (kid->lower_limit_entry), - &kid->lower_limit_value, 0); + &kid->lower_limit_value, 0); if (kid->upper_limit_value.f != SYSMIS) psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (kid->upper_limit_entry), - &kid->upper_limit_value, 0); + &kid->upper_limit_value, 0); if (PSPPIRE_RESPONSE_CONTINUE == psppire_dialog_run (PSPPIRE_DIALOG (kid->subdialog))) { psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (kid->lower_limit_entry), - &kid->lower_limit_value, 0); + &kid->lower_limit_value, 0); psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (kid->upper_limit_entry), - &kid->upper_limit_value, 0); + &kid->upper_limit_value, 0); } } @@ -184,16 +184,16 @@ psppire_dialog_action_k_independent_activate (PsppireDialogAction *a, GVariant * kid->upper_limit_entry = get_widget_assert (xml, "upper-limit-entry"); kid->checkbutton[KID_KRUSKAL_WALLIS] = get_widget_assert (xml, - "kruskal-wallis"); + "kruskal-wallis"); kid->checkbutton[KID_MEDIAN] = get_widget_assert (xml, "median"); g_signal_connect_swapped (get_widget_assert (xml, "define-groups-button"), - "clicked", - G_CALLBACK (run_define_groups_dialog), kid); + "clicked", + G_CALLBACK (run_define_groups_dialog), kid); g_signal_connect_swapped (kid->groupvar_entry, "changed", - G_CALLBACK (set_value_entry_variable), kid); + G_CALLBACK (set_value_entry_variable), kid); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); diff --git a/src/ui/gui/psppire-dialog-action-k-independent.h b/src/ui/gui/psppire-dialog-action-k-independent.h index aa0177b256..7e3ab26b2f 100644 --- a/src/ui/gui/psppire-dialog-action-k-independent.h +++ b/src/ui/gui/psppire-dialog-action-k-independent.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT (psppire_dialog_action_k_independent_get_type ()) -#define PSPPIRE_DIALOG_ACTION_K_INDEPENDENT(obj) \ +#define PSPPIRE_DIALOG_ACTION_K_INDEPENDENT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, PsppireDialogActionKIndependent)) + PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, PsppireDialogActionKIndependent)) #define PSPPIRE_DIALOG_ACTION_K_INDEPENDENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, \ + PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, \ PsppireDialogActionKIndependentClass)) #define PSPPIRE_IS_DIALOG_ACTION_K_INDEPENDENT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT)) #define PSPPIRE_IS_DIALOG_ACTION_K_INDEPENDENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT)) #define PSPPIRE_DIALOG_ACTION_K_INDEPENDENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, \ - PsppireDialogActionKIndependentClass)) + PSPPIRE_TYPE_DIALOG_ACTION_K_INDEPENDENT, \ + PsppireDialogActionKIndependentClass)) typedef struct _PsppireDialogActionKIndependent PsppireDialogActionKIndependent; typedef struct _PsppireDialogActionKIndependentClass PsppireDialogActionKIndependentClass; diff --git a/src/ui/gui/psppire-dialog-action-k-related.c b/src/ui/gui/psppire-dialog-action-k-related.c index d3107d386c..97c505af99 100644 --- a/src/ui/gui/psppire-dialog-action-k-related.c +++ b/src/ui/gui/psppire-dialog-action-k-related.c @@ -119,8 +119,8 @@ psppire_dialog_action_k_related_activate (PsppireDialogAction *a, GVariant *para psppire_dialog_action_set_refresh (pda, refresh); g_object_set (pda->source, - "predicate", var_is_numeric, - NULL); + "predicate", var_is_numeric, + NULL); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-k-related.h b/src/ui/gui/psppire-dialog-action-k-related.h index c92c06b03c..c57c76f487 100644 --- a/src/ui/gui/psppire-dialog-action-k-related.h +++ b/src/ui/gui/psppire-dialog-action-k-related.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED (psppire_dialog_action_k_related_get_type ()) -#define PSPPIRE_DIALOG_ACTION_K_RELATED(obj) \ +#define PSPPIRE_DIALOG_ACTION_K_RELATED(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, PsppireDialogActionKRelated)) + PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, PsppireDialogActionKRelated)) #define PSPPIRE_DIALOG_ACTION_K_RELATED_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, \ + PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, \ PsppireDialogActionKRelatedClass)) #define PSPPIRE_IS_DIALOG_ACTION_K_RELATED(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED)) #define PSPPIRE_IS_DIALOG_ACTION_K_RELATED_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED)) #define PSPPIRE_DIALOG_ACTION_K_RELATED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, \ - PsppireDialogActionKRelatedClass)) + PSPPIRE_TYPE_DIALOG_ACTION_K_RELATED, \ + PsppireDialogActionKRelatedClass)) typedef struct _PsppireDialogActionKRelated PsppireDialogActionKRelated; typedef struct _PsppireDialogActionKRelatedClass PsppireDialogActionKRelatedClass; diff --git a/src/ui/gui/psppire-dialog-action-kmeans.c b/src/ui/gui/psppire-dialog-action-kmeans.c index 9279890eec..c368589a53 100644 --- a/src/ui/gui/psppire-dialog-action-kmeans.c +++ b/src/ui/gui/psppire-dialog-action-kmeans.c @@ -40,7 +40,7 @@ generate_syntax (const PsppireDialogAction *act) psppire_var_view_append_names (PSPPIRE_VAR_VIEW (km->variables), 0, string); g_string_append_printf (string, "\n\t/CRITERIA=CLUSTERS(%d)", - atoi (gtk_entry_get_text (GTK_ENTRY (km->entry)))); + atoi (gtk_entry_get_text (GTK_ENTRY (km->entry)))); g_string_append (string, ".\n"); diff --git a/src/ui/gui/psppire-dialog-action-kmeans.h b/src/ui/gui/psppire-dialog-action-kmeans.h index 3c602f25e6..a1f24f79bf 100644 --- a/src/ui/gui/psppire-dialog-action-kmeans.h +++ b/src/ui/gui/psppire-dialog-action-kmeans.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_KMEANS (psppire_dialog_action_kmeans_get_type ()) -#define PSPPIRE_DIALOG_ACTION_KMEANS(obj) \ +#define PSPPIRE_DIALOG_ACTION_KMEANS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, PsppireDialogActionKmeans)) + PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, PsppireDialogActionKmeans)) #define PSPPIRE_DIALOG_ACTION_KMEANS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, \ + PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, \ PsppireDialogActionKmeansClass)) #define PSPPIRE_IS_DIALOG_ACTION_KMEANS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_KMEANS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_KMEANS)) #define PSPPIRE_IS_DIALOG_ACTION_KMEANS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_KMEANS)) #define PSPPIRE_DIALOG_ACTION_KMEANS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, \ - PsppireDialogActionKmeansClass)) + PSPPIRE_TYPE_DIALOG_ACTION_KMEANS, \ + PsppireDialogActionKmeansClass)) typedef struct _PsppireDialogActionKmeans PsppireDialogActionKmeans; typedef struct _PsppireDialogActionKmeansClass PsppireDialogActionKmeansClass; diff --git a/src/ui/gui/psppire-dialog-action-logistic.c b/src/ui/gui/psppire-dialog-action-logistic.c index 962a0d5469..b868a76e7d 100644 --- a/src/ui/gui/psppire-dialog-action-logistic.c +++ b/src/ui/gui/psppire-dialog-action-logistic.c @@ -125,11 +125,11 @@ psppire_dialog_action_logistic_activate (PsppireDialogAction *a, GVariant *param opts_button = get_widget_assert (xml, "options-button"); g_signal_connect_swapped (opts_button, "clicked", - G_CALLBACK (on_opts_clicked), act); + G_CALLBACK (on_opts_clicked), act); g_signal_connect (act->conf_checkbox, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - act->conf_entry); + G_CALLBACK (set_sensitivity_from_toggle), + act->conf_entry); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(act->conf_checkbox), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(act->conf_checkbox), FALSE); @@ -137,7 +137,7 @@ psppire_dialog_action_logistic_activate (PsppireDialogAction *a, GVariant *param psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } @@ -179,10 +179,10 @@ generate_syntax (const PsppireDialogAction *a) enum measure m = var_get_measure (v); if (m == MEASURE_NOMINAL || m == MEASURE_ORDINAL || var_is_alpha (v)) - { - g_string_prepend (categoricals, var_get_name (v)); - g_string_prepend (categoricals, " "); - } + { + g_string_prepend (categoricals, var_get_name (v)); + g_string_prepend (categoricals, " "); + } } if (0 != strcmp (categoricals->str, "")) g_string_prepend (categoricals, "\n\t/CATEGORICAL ="); diff --git a/src/ui/gui/psppire-dialog-action-logistic.h b/src/ui/gui/psppire-dialog-action-logistic.h index 9dab276acb..65821a0163 100644 --- a/src/ui/gui/psppire-dialog-action-logistic.h +++ b/src/ui/gui/psppire-dialog-action-logistic.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC (psppire_dialog_action_logistic_get_type ()) -#define PSPPIRE_DIALOG_ACTION_LOGISTIC(obj) \ +#define PSPPIRE_DIALOG_ACTION_LOGISTIC(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, PsppireDialogActionLogistic)) + PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, PsppireDialogActionLogistic)) #define PSPPIRE_DIALOG_ACTION_LOGISTIC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, \ + PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, \ PsppireDialogActionLogisticClass)) #define PSPPIRE_IS_DIALOG_ACTION_LOGISTIC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC)) #define PSPPIRE_IS_DIALOG_ACTION_LOGISTIC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC)) #define PSPPIRE_DIALOG_ACTION_LOGISTIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, \ - PsppireDialogActionLogisticClass)) + PSPPIRE_TYPE_DIALOG_ACTION_LOGISTIC, \ + PsppireDialogActionLogisticClass)) typedef struct _PsppireDialogActionLogistic PsppireDialogActionLogistic; typedef struct _PsppireDialogActionLogisticClass PsppireDialogActionLogisticClass; diff --git a/src/ui/gui/psppire-dialog-action-means.c b/src/ui/gui/psppire-dialog-action-means.c index 3dacedd6ed..114b889e82 100644 --- a/src/ui/gui/psppire-dialog-action-means.c +++ b/src/ui/gui/psppire-dialog-action-means.c @@ -52,13 +52,13 @@ generate_syntax (const PsppireDialogAction *act) GtkTreeModel *m = psppire_means_layer_get_model_n (layer, l); gboolean ok = gtk_tree_model_get_iter_first (m, &iter); if (ok) - g_string_append (string, "\n\tBY"); + g_string_append (string, "\n\tBY"); for (; ok; ok = gtk_tree_model_iter_next (m, &iter)) - { - const struct variable *var = psppire_var_view_get_var_from_model (m, 0, &iter); - g_string_append (string, " "); - g_string_append (string, var_get_name (var)); - } + { + const struct variable *var = psppire_var_view_get_var_from_model (m, 0, &iter); + g_string_append (string, " "); + g_string_append (string, var_get_name (var)); + } } g_string_append (string, ".\n"); @@ -132,8 +132,8 @@ psppire_dialog_action_means_activate (PsppireDialogAction *a, GVariant *param) psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector), numeric_variable); g_object_set (selector, - "dest-widget", act->layer, - NULL); + "dest-widget", act->layer, + NULL); psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid); psppire_dialog_action_set_refresh (pda, dialog_refresh); diff --git a/src/ui/gui/psppire-dialog-action-means.h b/src/ui/gui/psppire-dialog-action-means.h index 80ee7ba921..080353da44 100644 --- a/src/ui/gui/psppire-dialog-action-means.h +++ b/src/ui/gui/psppire-dialog-action-means.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_MEANS (psppire_dialog_action_means_get_type ()) -#define PSPPIRE_DIALOG_ACTION_MEANS(obj) \ +#define PSPPIRE_DIALOG_ACTION_MEANS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_MEANS, PsppireDialogActionMeans)) + PSPPIRE_TYPE_DIALOG_ACTION_MEANS, PsppireDialogActionMeans)) #define PSPPIRE_DIALOG_ACTION_MEANS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_MEANS, \ + PSPPIRE_TYPE_DIALOG_ACTION_MEANS, \ PsppireDialogActionMeansClass)) #define PSPPIRE_IS_DIALOG_ACTION_MEANS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_MEANS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_MEANS)) #define PSPPIRE_IS_DIALOG_ACTION_MEANS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_MEANS)) #define PSPPIRE_DIALOG_ACTION_MEANS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_MEANS, \ - PsppireDialogActionMeansClass)) + PSPPIRE_TYPE_DIALOG_ACTION_MEANS, \ + PsppireDialogActionMeansClass)) typedef struct _PsppireDialogActionMeans PsppireDialogActionMeans; typedef struct _PsppireDialogActionMeansClass PsppireDialogActionMeansClass; diff --git a/src/ui/gui/psppire-dialog-action-oneway.c b/src/ui/gui/psppire-dialog-action-oneway.c index 71d4873cd2..cf9307a410 100644 --- a/src/ui/gui/psppire-dialog-action-oneway.c +++ b/src/ui/gui/psppire-dialog-action-oneway.c @@ -76,25 +76,25 @@ generate_syntax (const PsppireDialogAction *act) { ds_put_cstr (&dss, "\n\t/STATISTICS="); if (descriptives) - ds_put_cstr (&dss, "DESCRIPTIVES "); + ds_put_cstr (&dss, "DESCRIPTIVES "); if (homogeneity) - ds_put_cstr (&dss, "HOMOGENEITY "); + ds_put_cstr (&dss, "HOMOGENEITY "); } if (ow->posthoc) { ds_put_cstr (&dss, "\n\t/POSTHOC="); if (ow->posthoc & POSTHOC_BONFERRONI) - ds_put_cstr (&dss, "BONFERRONI "); + ds_put_cstr (&dss, "BONFERRONI "); if (ow->posthoc & POSTHOC_GH) - ds_put_cstr (&dss, "GH "); + ds_put_cstr (&dss, "GH "); if (ow->posthoc & POSTHOC_LSD) - ds_put_cstr (&dss, "LSD "); + ds_put_cstr (&dss, "LSD "); if (ow->posthoc & POSTHOC_SCHEFFE) - ds_put_cstr (&dss, "SCHEFFE "); + ds_put_cstr (&dss, "SCHEFFE "); if (ow->posthoc & POSTHOC_SIDAK) - ds_put_cstr (&dss, "SIDAK "); + ds_put_cstr (&dss, "SIDAK "); if (ow->posthoc & POSTHOC_TUKEY) - ds_put_cstr (&dss, "TUKEY "); + ds_put_cstr (&dss, "TUKEY "); } for (i = 0 ; i < ow->contrasts_array->len ; ++i) { @@ -105,16 +105,16 @@ generate_syntax (const PsppireDialogAction *act) ds_put_cstr (&dss, "\n\t/CONTRAST="); for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(ls), - &iter); - ok; - ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), &iter)) - { - gdouble v; + &iter); + ok; + ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ls), &iter)) + { + gdouble v; - gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 0, &v, -1); + gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 0, &v, -1); - ds_put_c_format (&dss, " %.*g", DBL_DIG + 1, v); - } + ds_put_c_format (&dss, " %.*g", DBL_DIG + 1, v); + } } ds_put_cstr (&dss, ".\n"); @@ -173,7 +173,7 @@ list_store_changed (PsppireDialogActionOneway *csd) GtkTreeModel *ls = NULL; gchar *text = g_strdup_printf (_("Contrast %d of %d"), - csd->c, csd->temp_contrasts->len); + csd->c, csd->temp_contrasts->len); gtk_label_set_label (GTK_LABEL (csd->stack_label), text); @@ -188,8 +188,8 @@ list_store_changed (PsppireDialogActionOneway *csd) /* Sensitive iff the liststore has two items or more */ gtk_widget_set_sensitive (csd->next, - gtk_tree_model_iter_nth_child - (ls, &iter, NULL, 1)); + gtk_tree_model_iter_nth_child + (ls, &iter, NULL, 1)); for (ok = gtk_tree_model_get_iter_first (ls, &iter); ok; @@ -217,7 +217,7 @@ clone_contrasts_array (GArray *src_array) GArray *dest_array = g_array_sized_new (FALSE, FALSE, sizeof (GtkListStore *), - src_array->len); + src_array->len); for (i = 0 ; i < src_array->len ; ++i) { @@ -228,8 +228,8 @@ clone_contrasts_array (GArray *src_array) /* Refuse to copy empty stores */ if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (src), - &src_iter)) - continue; + &src_iter)) + continue; dest = clone_list_store (src); @@ -273,7 +273,7 @@ psppire_dialog_action_oneway_activate (PsppireDialogAction *a, GVariant *param) act->tukey_button = get_widget_assert (xml, "tukey-button"); g_signal_connect_swapped (posthoc_button, "clicked", - G_CALLBACK (run_posthoc_dialog), act); + G_CALLBACK (run_posthoc_dialog), act); /* Contrast dialog */ act->contrasts_dialog = get_widget_assert (xml, "contrasts-dialog"); @@ -292,11 +292,11 @@ psppire_dialog_action_oneway_activate (PsppireDialogAction *a, GVariant *param) psppire_acr_set_entry (PSPPIRE_ACR (act->acr), entry); gtk_window_set_transient_for (GTK_WINDOW (act->contrasts_dialog), - GTK_WINDOW (pda->toplevel)); + GTK_WINDOW (pda->toplevel)); g_signal_connect_swapped (contrasts_button, "clicked", - G_CALLBACK (run_contrasts_dialog), act); + G_CALLBACK (run_contrasts_dialog), act); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); @@ -326,22 +326,22 @@ run_posthoc_dialog (PsppireDialogActionOneway *ow) gint response; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->bonferroni_button), - ow->posthoc & POSTHOC_BONFERRONI); + ow->posthoc & POSTHOC_BONFERRONI); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->gh_button), - ow->posthoc & POSTHOC_GH); + ow->posthoc & POSTHOC_GH); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->lsd_button), - ow->posthoc & POSTHOC_LSD); + ow->posthoc & POSTHOC_LSD); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->scheffe_button), - ow->posthoc & POSTHOC_SCHEFFE); + ow->posthoc & POSTHOC_SCHEFFE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->sidak_button), - ow->posthoc & POSTHOC_SIDAK); + ow->posthoc & POSTHOC_SIDAK); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->tukey_button), - ow->posthoc & POSTHOC_TUKEY); + ow->posthoc & POSTHOC_TUKEY); response = psppire_dialog_run (PSPPIRE_DIALOG (ow->posthoc_dialog)); @@ -349,22 +349,22 @@ run_posthoc_dialog (PsppireDialogActionOneway *ow) { ow->posthoc= 0; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->bonferroni_button))) - ow->posthoc |= POSTHOC_BONFERRONI; + ow->posthoc |= POSTHOC_BONFERRONI; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->gh_button))) - ow->posthoc |= POSTHOC_GH; + ow->posthoc |= POSTHOC_GH; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->lsd_button))) - ow->posthoc |= POSTHOC_LSD; + ow->posthoc |= POSTHOC_LSD; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->scheffe_button))) - ow->posthoc |= POSTHOC_SCHEFFE; + ow->posthoc |= POSTHOC_SCHEFFE; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->sidak_button))) - ow->posthoc |= POSTHOC_SIDAK; + ow->posthoc |= POSTHOC_SIDAK; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ow->tukey_button))) - ow->posthoc |= POSTHOC_TUKEY; + ow->posthoc |= POSTHOC_TUKEY; } } @@ -396,10 +396,10 @@ push_new_store (GArray *contrast_stack, PsppireDialogActionOneway *csd) g_array_append_val (contrast_stack, ls); g_signal_connect_swapped (ls, "row-deleted", - G_CALLBACK (list_store_changed), csd); + G_CALLBACK (list_store_changed), csd); g_signal_connect_swapped (ls, "row-changed", - G_CALLBACK (list_store_changed), csd); + G_CALLBACK (list_store_changed), csd); list_store_changed (csd); } diff --git a/src/ui/gui/psppire-dialog-action-oneway.h b/src/ui/gui/psppire-dialog-action-oneway.h index f14b7c8eb4..6887b4297f 100644 --- a/src/ui/gui/psppire-dialog-action-oneway.h +++ b/src/ui/gui/psppire-dialog-action-oneway.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY (psppire_dialog_action_oneway_get_type ()) -#define PSPPIRE_DIALOG_ACTION_ONEWAY(obj) \ +#define PSPPIRE_DIALOG_ACTION_ONEWAY(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, PsppireDialogActionOneway)) + PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, PsppireDialogActionOneway)) #define PSPPIRE_DIALOG_ACTION_ONEWAY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, \ + PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, \ PsppireDialogActionOnewayClass)) #define PSPPIRE_IS_DIALOG_ACTION_ONEWAY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY)) #define PSPPIRE_IS_DIALOG_ACTION_ONEWAY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY)) #define PSPPIRE_DIALOG_ACTION_ONEWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, \ - PsppireDialogActionOnewayClass)) + PSPPIRE_TYPE_DIALOG_ACTION_ONEWAY, \ + PsppireDialogActionOnewayClass)) typedef struct _PsppireDialogActionOneway PsppireDialogActionOneway; typedef struct _PsppireDialogActionOnewayClass PsppireDialogActionOnewayClass; diff --git a/src/ui/gui/psppire-dialog-action-paired.c b/src/ui/gui/psppire-dialog-action-paired.c index f7b33dfb21..effa93e2dc 100644 --- a/src/ui/gui/psppire-dialog-action-paired.c +++ b/src/ui/gui/psppire-dialog-action-paired.c @@ -51,7 +51,7 @@ dialog_state_valid (gpointer data) /* Get the last row */ gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pd->list_store), &dest_iter, - NULL, n_rows - 1); + NULL, n_rows - 1); /* Get the last (2nd) column */ gtk_tree_model_get (GTK_TREE_MODEL (pd->list_store), &dest_iter, 1, &v, -1); @@ -77,9 +77,9 @@ refresh (PsppireDialogAction *rd_) static void select_as_pair_member (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data) + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data) { struct variable *v; struct variable *v1; @@ -89,7 +89,7 @@ select_as_pair_member (GtkTreeIter source_iter, gtk_tree_model_get (source_model, &source_iter, - DICT_TVM_COL_VAR, &v, -1); + DICT_TVM_COL_VAR, &v, -1); n_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (tt_d->list_store), NULL); @@ -97,7 +97,7 @@ select_as_pair_member (GtkTreeIter source_iter, { gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (tt_d->list_store), - &dest_iter, NULL, n_rows - 1); + &dest_iter, NULL, n_rows - 1); gtk_tree_model_get (GTK_TREE_MODEL (tt_d->list_store), &dest_iter, 1, &v1, -1); } @@ -109,15 +109,15 @@ select_as_pair_member (GtkTreeIter source_iter, gtk_list_store_append (tt_d->list_store, &dest_iter); gtk_list_store_set (tt_d->list_store, &dest_iter, - 0, v, - 1, NULL, - -1); + 0, v, + 1, NULL, + -1); } else { gtk_list_store_set (tt_d->list_store, &dest_iter, - 1, v, - -1); + 1, v, + -1); } } @@ -180,12 +180,12 @@ psppire_dialog_action_paired_activate (PsppireDialogAction *a, GVariant *param) psppire_dialog_action_set_refresh (pda, refresh); g_object_set (pda->source, - "predicate", var_is_numeric, - NULL); + "predicate", var_is_numeric, + NULL); psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector), - select_as_pair_member, - act); + select_as_pair_member, + act); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-paired.h b/src/ui/gui/psppire-dialog-action-paired.h index d9ff91a543..6e493efd00 100644 --- a/src/ui/gui/psppire-dialog-action-paired.h +++ b/src/ui/gui/psppire-dialog-action-paired.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_PAIRED (psppire_dialog_action_paired_get_type ()) -#define PSPPIRE_DIALOG_ACTION_PAIRED(obj) \ +#define PSPPIRE_DIALOG_ACTION_PAIRED(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, PsppireDialogActionPaired)) + PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, PsppireDialogActionPaired)) #define PSPPIRE_DIALOG_ACTION_PAIRED_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, \ + PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, \ PsppireDialogActionPairedClass)) #define PSPPIRE_IS_DIALOG_ACTION_PAIRED(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_PAIRED)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_PAIRED)) #define PSPPIRE_IS_DIALOG_ACTION_PAIRED_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_PAIRED)) #define PSPPIRE_DIALOG_ACTION_PAIRED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, \ - PsppireDialogActionPairedClass)) + PSPPIRE_TYPE_DIALOG_ACTION_PAIRED, \ + PsppireDialogActionPairedClass)) typedef struct _PsppireDialogActionPaired PsppireDialogActionPaired; typedef struct _PsppireDialogActionPairedClass PsppireDialogActionPairedClass; diff --git a/src/ui/gui/psppire-dialog-action-rank.c b/src/ui/gui/psppire-dialog-action-rank.c index dcb045a3ef..47fd436fa4 100644 --- a/src/ui/gui/psppire-dialog-action-rank.c +++ b/src/ui/gui/psppire-dialog-action-rank.c @@ -49,8 +49,8 @@ generate_syntax (const PsppireDialogAction *act) psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->rank_vars), 0, str); g_string_append_printf (str, " (%c)", - gtk_toggle_button_get_active (rd->ascending_togglebutton) - ?'A':'D'); + gtk_toggle_button_get_active (rd->ascending_togglebutton) + ?'A':'D'); if (gtk_tree_model_get_iter_first (gs, ¬used)) { @@ -94,13 +94,13 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (str, "\n\t/FRACTION="); if (gtk_toggle_button_get_active (rd->blom)) - g_string_append (str, "BLOM"); + g_string_append (str, "BLOM"); else if (gtk_toggle_button_get_active (rd->tukey)) - g_string_append (str, "TUKEY"); + g_string_append (str, "TUKEY"); else if (gtk_toggle_button_get_active (rd->rankit)) - g_string_append (str, "RANKIT"); + g_string_append (str, "RANKIT"); else if (gtk_toggle_button_get_active (rd->vw)) - g_string_append (str, "VW"); + g_string_append (str, "VW"); } g_string_append (str, "\n\t/TIES="); @@ -153,7 +153,7 @@ types_dialog_reset (PsppireDialogActionRank *rd) for (i = 0 ; i < n_RANK_FUNCS ; ++i) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->func_button [i]), - FALSE); + FALSE); gtk_widget_set_sensitive (rd->ntiles_entry, FALSE); @@ -166,7 +166,7 @@ run_types_dialog (GtkButton *b, PsppireDialogActionRank *dar) PsppireDialogAction *act = PSPPIRE_DIALOG_ACTION (dar); gtk_window_set_transient_for (GTK_WINDOW (dar->types_dialog), - GTK_WINDOW (act->dialog)); + GTK_WINDOW (act->dialog)); types_dialog_reset (dar); @@ -179,7 +179,7 @@ run_ties_dialog (GtkButton *b, PsppireDialogActionRank *dar) PsppireDialogAction *act = PSPPIRE_DIALOG_ACTION (dar); gtk_window_set_transient_for (GTK_WINDOW (dar->ties_dialog), - GTK_WINDOW (act->dialog)); + GTK_WINDOW (act->dialog)); psppire_dialog_run (PSPPIRE_DIALOG (dar->ties_dialog)); } @@ -267,22 +267,22 @@ psppire_dialog_action_rank_activate (PsppireDialogAction *a, GVariant *param) act->condense = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "condense-button")); g_signal_connect_swapped (act->func_button[PROPORTION], "toggled", - G_CALLBACK (set_sensitivity), - act); + G_CALLBACK (set_sensitivity), + act); g_signal_connect_swapped (act->func_button[NORMAL], "toggled", - G_CALLBACK (set_sensitivity), - act); + G_CALLBACK (set_sensitivity), + act); g_signal_connect (types_button, "clicked", - G_CALLBACK (run_types_dialog), act); + G_CALLBACK (run_types_dialog), act); g_signal_connect (ties_button, "clicked", - G_CALLBACK (run_ties_dialog), act); + G_CALLBACK (run_ties_dialog), act); g_signal_connect (act->func_button[NTILES], "toggled", - G_CALLBACK (on_ntiles_toggle), - act->ntiles_entry); + G_CALLBACK (on_ntiles_toggle), + act->ntiles_entry); psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid); psppire_dialog_action_set_refresh (pda, dialog_refresh); diff --git a/src/ui/gui/psppire-dialog-action-rank.h b/src/ui/gui/psppire-dialog-action-rank.h index 0827197734..5531db792d 100644 --- a/src/ui/gui/psppire-dialog-action-rank.h +++ b/src/ui/gui/psppire-dialog-action-rank.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_RANK (psppire_dialog_action_rank_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RANK(obj) \ +#define PSPPIRE_DIALOG_ACTION_RANK(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RANK, PsppireDialogActionRank)) + PSPPIRE_TYPE_DIALOG_ACTION_RANK, PsppireDialogActionRank)) #define PSPPIRE_DIALOG_ACTION_RANK_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RANK, \ + PSPPIRE_TYPE_DIALOG_ACTION_RANK, \ PsppireDialogActionRankClass)) #define PSPPIRE_IS_DIALOG_ACTION_RANK(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RANK)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RANK)) #define PSPPIRE_IS_DIALOG_ACTION_RANK_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RANK)) #define PSPPIRE_DIALOG_ACTION_RANK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RANK, \ - PsppireDialogActionRankClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RANK, \ + PsppireDialogActionRankClass)) typedef struct _PsppireDialogActionRank PsppireDialogActionRank; typedef struct _PsppireDialogActionRankClass PsppireDialogActionRankClass; diff --git a/src/ui/gui/psppire-dialog-action-recode-different.c b/src/ui/gui/psppire-dialog-action-recode-different.c index a49d05306e..09a56a70b6 100644 --- a/src/ui/gui/psppire-dialog-action-recode-different.c +++ b/src/ui/gui/psppire-dialog-action-recode-different.c @@ -62,7 +62,7 @@ dialog_state_valid (gpointer data) return FALSE; if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map), - ¬_used)) + ¬_used)) return FALSE; @@ -144,10 +144,10 @@ nlp_destroy (gpointer data) static void render_new_var_name (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) { struct nlp *nlp = NULL; PsppireDialogActionRecode *rd = data; @@ -156,8 +156,8 @@ render_new_var_name (GtkTreeViewColumn *tree_column, struct variable *var = NULL; gtk_tree_model_get (tree_model, iter, - 0, &var, - -1); + 0, &var, + -1); nlp = g_hash_table_lookup (rdd->varmap, var); @@ -245,21 +245,21 @@ on_selection_change (GtkTreeSelection *selection, gpointer data) g_return_if_fail (ok); gtk_tree_model_get (model, &iter, - 0, &var, - -1); + 0, &var, + -1); nlp = g_hash_table_lookup (rdd->varmap, var); if (nlp) - { - gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), nlp->name ? nlp->name : ""); - gtk_entry_set_text (GTK_ENTRY (rd->new_label_entry), nlp->label ? nlp->label : ""); - } + { + gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), nlp->name ? nlp->name : ""); + gtk_entry_set_text (GTK_ENTRY (rd->new_label_entry), nlp->label ? nlp->label : ""); + } else - { - gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), ""); - gtk_entry_set_text (GTK_ENTRY (rd->new_label_entry), ""); - } + { + gtk_entry_set_text (GTK_ENTRY (rd->new_name_entry), ""); + gtk_entry_set_text (GTK_ENTRY (rd->new_label_entry), ""); + } } else { @@ -286,13 +286,13 @@ populate_treeview (PsppireDialogActionRecode *act) PsppireDialogActionRecodeDifferent *rdd = PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT (act); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn *col = gtk_tree_view_column_new_with_attributes (_("New"), - renderer, - "text", NULL, - NULL); + renderer, + "text", NULL, + NULL); gtk_tree_view_column_set_cell_data_func (col, renderer, - render_new_var_name, - act, NULL); + render_new_var_name, + act, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (act->variable_treeview), col); @@ -307,10 +307,10 @@ populate_treeview (PsppireDialogActionRecode *act) sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (act->variable_treeview)); g_signal_connect (sel, "changed", - G_CALLBACK (on_selection_change), act); + G_CALLBACK (on_selection_change), act); g_signal_connect (act->change_button, "clicked", - G_CALLBACK (on_change_clicked), act); + G_CALLBACK (on_change_clicked), act); } @@ -321,23 +321,23 @@ psppire_dialog_action_recode_different_activate (PsppireDialogAction *a, GVarian PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); GtkBuilder *xml = psppire_dialog_action_recode_pre_activate (act, - populate_treeview); + populate_treeview); gtk_window_set_title (GTK_WINDOW (pda->dialog), - _("Recode into Different Variables")); + _("Recode into Different Variables")); gtk_window_set_title (GTK_WINDOW (act->old_and_new_dialog), - _("Recode into Different Variables: Old and New Values ")); + _("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); + G_CALLBACK (on_old_new_show), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } @@ -380,13 +380,13 @@ append_string_declarations (const PsppireDialogActionRecode *rd, struct string * g_hash_table_iter_init (&iter, rdd->varmap); while (g_hash_table_iter_next (&iter, (void**) &var, (void**) &nlp)) - { - ds_put_cstr (dds, "\nSTRING "); - ds_put_cstr (dds, nlp->name); - ds_put_c_format (dds, " (A%d).", - (int) - gtk_spin_button_get_value (GTK_SPIN_BUTTON (rd->width_entry))); - } + { + ds_put_cstr (dds, "\nSTRING "); + ds_put_cstr (dds, nlp->name); + ds_put_c_format (dds, " (A%d).", + (int) + gtk_spin_button_get_value (GTK_SPIN_BUTTON (rd->width_entry))); + } } } @@ -405,15 +405,15 @@ append_new_value_labels (const PsppireDialogActionRecode *rd, struct string *dds while (g_hash_table_iter_next (&iter, (void**) &var, (void**) &nlp)) { if (nlp->label) - { - struct string sl; - ds_init_empty (&sl); - syntax_gen_string (&sl, ss_cstr (nlp->label)); - ds_put_c_format (dds, "\nVARIABLE LABELS %s %s.", - nlp->name, ds_cstr (&sl)); - - ds_destroy (&sl); - } + { + struct string sl; + ds_init_empty (&sl); + syntax_gen_string (&sl, ss_cstr (nlp->label)); + ds_put_c_format (dds, "\nVARIABLE LABELS %s %s.", + nlp->name, ds_cstr (&sl)); + + ds_destroy (&sl); + } } } @@ -421,9 +421,9 @@ static char * diff_generate_syntax (const PsppireDialogAction *act) { return psppire_dialog_action_recode_generate_syntax (act, - append_string_declarations, - append_into_clause, - append_new_value_labels); + append_string_declarations, + append_into_clause, + append_new_value_labels); } static gboolean diff --git a/src/ui/gui/psppire-dialog-action-recode-different.h b/src/ui/gui/psppire-dialog-action-recode-different.h index 03e199f5f5..557a1fa135 100644 --- a/src/ui/gui/psppire-dialog-action-recode-different.h +++ b/src/ui/gui/psppire-dialog-action-recode-different.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT (psppire_dialog_action_recode_different_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT(obj) \ +#define PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, PsppireDialogActionRecodeDifferent)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, PsppireDialogActionRecodeDifferent)) #define PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, \ + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, \ PsppireDialogActionRecodeDifferentClass)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE_DIFFERENT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE_DIFFERENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT)) #define PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, \ - PsppireDialogActionRecodeDifferentClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_DIFFERENT, \ + PsppireDialogActionRecodeDifferentClass)) typedef struct _PsppireDialogActionRecodeDifferent PsppireDialogActionRecodeDifferent; typedef struct _PsppireDialogActionRecodeDifferentClass PsppireDialogActionRecodeDifferentClass; diff --git a/src/ui/gui/psppire-dialog-action-recode-same.c b/src/ui/gui/psppire-dialog-action-recode-same.c index 7b48a808a7..c652ce3b97 100644 --- a/src/ui/gui/psppire-dialog-action-recode-same.c +++ b/src/ui/gui/psppire-dialog-action-recode-same.c @@ -63,7 +63,7 @@ dialog_state_valid (gpointer data) return FALSE; if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map), - ¬_used)) + ¬_used)) return FALSE; return difx_variable_treeview_is_populated (rd); @@ -105,20 +105,20 @@ psppire_dialog_action_recode_same_activate (PsppireDialogAction *a, GVariant *pa GtkBuilder *xml = psppire_dialog_action_recode_pre_activate (act, NULL); gtk_window_set_title (GTK_WINDOW (pda->dialog), - _("Recode into Same Variables")); + _("Recode into Same Variables")); g_signal_connect_swapped (act->old_and_new_dialog, "show", - G_CALLBACK (on_old_new_show), act); + G_CALLBACK (on_old_new_show), act); gtk_window_set_title (GTK_WINDOW (act->old_and_new_dialog), - _("Recode into Same Variables: Old and New Values")); + _("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, - dialog_state_valid); + dialog_state_valid); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-recode-same.h b/src/ui/gui/psppire-dialog-action-recode-same.h index f2a9be54cf..e43124b9f2 100644 --- a/src/ui/gui/psppire-dialog-action-recode-same.h +++ b/src/ui/gui/psppire-dialog-action-recode-same.h @@ -27,26 +27,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME (psppire_dialog_action_recode_same_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RECODE_SAME(obj) \ +#define PSPPIRE_DIALOG_ACTION_RECODE_SAME(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, PsppireDialogActionRecodeSame)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, PsppireDialogActionRecodeSame)) #define PSPPIRE_DIALOG_ACTION_RECODE_SAME_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, \ + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, \ PsppireDialogActionRecodeSameClass)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE_SAME(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE_SAME_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME)) #define PSPPIRE_DIALOG_ACTION_RECODE_SAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, \ - PsppireDialogActionRecodeSameClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE_SAME, \ + PsppireDialogActionRecodeSameClass)) typedef struct _PsppireDialogActionRecodeSame PsppireDialogActionRecodeSame; typedef struct _PsppireDialogActionRecodeSameClass PsppireDialogActionRecodeSameClass; diff --git a/src/ui/gui/psppire-dialog-action-recode.c b/src/ui/gui/psppire-dialog-action-recode.c index 9598cb7052..d21c1531c3 100644 --- a/src/ui/gui/psppire-dialog-action-recode.c +++ b/src/ui/gui/psppire-dialog-action-recode.c @@ -100,9 +100,9 @@ new_value_to_string (const GValue *src, GValue *dest) { case NV_NUMERIC: { - gchar *text = g_strdup_printf ("%.*g", DBL_DIG + 1, nv->v.v); - g_value_set_string (dest, text); - g_free (text); + gchar *text = g_strdup_printf ("%.*g", DBL_DIG + 1, nv->v.v); + g_value_set_string (dest, text); + g_free (text); } break; case NV_STRING: @@ -130,11 +130,11 @@ new_value_get_type (void) if (t == 0) { t = g_boxed_type_register_static ("psppire-recode-new-values", - (GBoxedCopyFunc) new_value_copy, - (GBoxedFreeFunc) new_value_free); + (GBoxedCopyFunc) new_value_copy, + (GBoxedFreeFunc) new_value_free); g_value_register_transform_func (t, G_TYPE_STRING, - new_value_to_string); + new_value_to_string); } return t; @@ -221,10 +221,10 @@ on_acr_selection_change (GtkTreeSelection *selection, gpointer data) gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, - COL_VALUE_OLD, &ov_value); + COL_VALUE_OLD, &ov_value); gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, - COL_VALUE_NEW, &nv_value); + COL_VALUE_NEW, &nv_value); ov = g_value_get_boxed (&ov_value); nv = g_value_get_boxed (&nv_value); @@ -232,38 +232,38 @@ on_acr_selection_change (GtkTreeSelection *selection, gpointer data) if (nv) { switch (nv->type) - { - case NV_NUMERIC: - { - gchar *str = num_to_string (nv->v.v); - - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); - - gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), str); - g_free (str); - } - break; - case NV_STRING: - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); - - gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), nv->v.s); - break; - case NV_SYSMIS: - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS]), TRUE); - - break; - case NV_COPY: - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY]), TRUE); - - break; - default: - g_warning ("Invalid new value type"); - break; - } + { + case NV_NUMERIC: + { + gchar *str = num_to_string (nv->v.v); + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); + + gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), str); + g_free (str); + } + break; + case NV_STRING: + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); + + gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), nv->v.s); + break; + case NV_SYSMIS: + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS]), TRUE); + + break; + case NV_COPY: + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY]), TRUE); + + break; + default: + g_warning ("Invalid new value type"); + break; + } g_value_unset (&nv_value); } @@ -302,20 +302,20 @@ set_new_value (GValue *val, const PsppireDialogActionRecode *rd) nv.type = NV_NUMERIC; if (PSPPIRE_DIALOG_ACTION_RECODE_CLASS (G_OBJECT_GET_CLASS (rd))->target_is_string (rd)) - nv.type = NV_STRING; + nv.type = NV_STRING; if (nv.type == NV_STRING) - nv.v.s = g_strdup (text); + nv.v.s = g_strdup (text); else - nv.v.v = g_strtod (text, 0); + nv.v.v = g_strtod (text, 0); } else if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY]))) + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY]))) { nv.type = NV_COPY; } else if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS]))) + (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS]))) { nv.type = NV_SYSMIS; } @@ -388,7 +388,7 @@ run_old_and_new_dialog (PsppireDialogActionRecode *rd) g_object_set (rd->old_value_chooser, "is-string", rd->input_var_is_string, NULL); gtk_widget_set_sensitive (rd->toggle [BUTTON_NEW_SYSMIS], - var_is_numeric (v)); + var_is_numeric (v)); gtk_widget_set_sensitive (rd->convert_button, var_is_alpha (v)); } @@ -453,7 +453,7 @@ psppire_dialog_action_recode_refresh (PsppireDialogAction *rd_) GtkBuilder * psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, - void (*populate_treeview) (PsppireDialogActionRecode *)) + void (*populate_treeview) (PsppireDialogActionRecode *)) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (act); @@ -474,8 +474,8 @@ psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, act->new_label_entry = get_widget_assert (xml, "dest-label-entry"); act->value_map = gtk_list_store_new (2, - old_value_get_type (), - new_value_get_type ()); + old_value_get_type (), + new_value_get_type ()); if (populate_treeview) populate_treeview (act); @@ -507,13 +507,13 @@ psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, act->acr = get_widget_assert (xml, "psppire-acr1"); g_signal_connect_swapped (act->toggle[BUTTON_NEW_VALUE], "toggled", - G_CALLBACK (set_acr), act); + G_CALLBACK (set_acr), act); g_signal_connect_after (act->toggle[BUTTON_NEW_VALUE], "toggled", - G_CALLBACK (focus_value_entry), act); + G_CALLBACK (focus_value_entry), act); g_signal_connect_swapped (act->new_value_entry, "changed", - G_CALLBACK (set_acr), act); + G_CALLBACK (set_acr), act); { GtkTreeSelection *sel; @@ -523,18 +523,18 @@ psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, column = - gtk_tree_view_column_new_with_attributes (_("Old"), - gtk_cell_renderer_text_new (), - "text", 0, - NULL); + gtk_tree_view_column_new_with_attributes (_("Old"), + gtk_cell_renderer_text_new (), + "text", 0, + NULL); gtk_tree_view_append_column (PSPPIRE_ACR (act->acr)->tv, column); column = - gtk_tree_view_column_new_with_attributes (_("New"), - gtk_cell_renderer_text_new (), - "text", 1, - NULL); + gtk_tree_view_column_new_with_attributes (_("New"), + gtk_cell_renderer_text_new (), + "text", 1, + NULL); gtk_tree_view_append_column (PSPPIRE_ACR(act->acr)->tv, column); g_object_set (PSPPIRE_ACR (act->acr)->tv, "headers-visible", TRUE, NULL); @@ -542,12 +542,12 @@ psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (PSPPIRE_ACR(act->acr)->tv)); g_signal_connect (sel, "changed", - G_CALLBACK (on_acr_selection_change), act); + G_CALLBACK (on_acr_selection_change), act); } g_signal_connect_swapped (act->old_and_new, "clicked", - G_CALLBACK (run_old_and_new_dialog), act); + G_CALLBACK (run_old_and_new_dialog), act); GtkTreeSelection *sel = @@ -556,16 +556,16 @@ psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, G_CALLBACK (set_old_and_new_button_sensitivity), act); g_signal_connect (act->toggle[BUTTON_NEW_VALUE], "toggled", - G_CALLBACK (toggle_sensitivity), act->new_value_entry); + G_CALLBACK (toggle_sensitivity), act->new_value_entry); g_signal_connect (act->string_button, "toggled", - G_CALLBACK (toggle_sensitivity), act->width_entry); + G_CALLBACK (toggle_sensitivity), act->width_entry); g_signal_connect (act->string_button, "toggled", - G_CALLBACK (on_string_toggled), act); + G_CALLBACK (on_string_toggled), act); g_signal_connect (act->convert_button, "toggled", - G_CALLBACK (on_convert_toggled), act); + G_CALLBACK (on_convert_toggled), act); } return xml; } @@ -599,9 +599,9 @@ new_value_append_syntax (struct string *dds, const struct new_value *nv) char * psppire_dialog_action_recode_generate_syntax (const PsppireDialogAction *act, - void (*append_string_decls) (const PsppireDialogActionRecode *, struct string *), - void (*append_into_clause) (const PsppireDialogActionRecode *, struct string *), - void (*append_new_value_labels) (const PsppireDialogActionRecode *, struct string *)) + void (*append_string_decls) (const PsppireDialogActionRecode *, struct string *), + void (*append_into_clause) (const PsppireDialogActionRecode *, struct string *), + void (*append_new_value_labels) (const PsppireDialogActionRecode *, struct string *)) { PsppireDialogActionRecode *rd = PSPPIRE_DIALOG_ACTION_RECODE (act); gboolean ok; @@ -625,7 +625,7 @@ psppire_dialog_action_recode_generate_syntax (const PsppireDialogAction *act, } for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map), - &iter); + &iter); ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (rd->value_map), &iter)) { @@ -634,10 +634,10 @@ psppire_dialog_action_recode_generate_syntax (const PsppireDialogAction *act, struct old_value *ov; struct new_value *nv; gtk_tree_model_get_value (GTK_TREE_MODEL (rd->value_map), &iter, - COL_VALUE_OLD, &ov_value); + COL_VALUE_OLD, &ov_value); gtk_tree_model_get_value (GTK_TREE_MODEL (rd->value_map), &iter, - COL_VALUE_NEW, &nv_value); + COL_VALUE_NEW, &nv_value); ov = g_value_get_boxed (&ov_value); nv = g_value_get_boxed (&nv_value); diff --git a/src/ui/gui/psppire-dialog-action-recode.h b/src/ui/gui/psppire-dialog-action-recode.h index a4116da265..914f878dd2 100644 --- a/src/ui/gui/psppire-dialog-action-recode.h +++ b/src/ui/gui/psppire-dialog-action-recode.h @@ -35,26 +35,26 @@ enum #define PSPPIRE_TYPE_DIALOG_ACTION_RECODE (psppire_dialog_action_recode_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RECODE(obj) \ +#define PSPPIRE_DIALOG_ACTION_RECODE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE, PsppireDialogActionRecode)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE, PsppireDialogActionRecode)) #define PSPPIRE_DIALOG_ACTION_RECODE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE, \ + PSPPIRE_TYPE_DIALOG_ACTION_RECODE, \ PsppireDialogActionRecodeClass)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RECODE)) #define PSPPIRE_IS_DIALOG_ACTION_RECODE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RECODE)) #define PSPPIRE_DIALOG_ACTION_RECODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RECODE, \ - PsppireDialogActionRecodeClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RECODE, \ + PsppireDialogActionRecodeClass)) typedef struct _PsppireDialogActionRecode PsppireDialogActionRecode; typedef struct _PsppireDialogActionRecodeClass PsppireDialogActionRecodeClass; @@ -109,16 +109,16 @@ GType psppire_dialog_action_recode_get_type (void) ; void psppire_dialog_action_recode_refresh (PsppireDialogAction *); GtkBuilder * psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act, - void (*populate_treeview) (PsppireDialogActionRecode *)); + void (*populate_treeview) (PsppireDialogActionRecode *)); GType new_value_get_type (void); char *psppire_dialog_action_recode_generate_syntax (const PsppireDialogAction *act, - void (*add_string_decls) (const PsppireDialogActionRecode *, struct string *), - void (*add_into_clause) (const PsppireDialogActionRecode *, struct string *), - void (*add_new_value_labels) (const PsppireDialogActionRecode *, struct string *)); + void (*add_string_decls) (const PsppireDialogActionRecode *, struct string *), + void (*add_into_clause) (const PsppireDialogActionRecode *, struct string *), + void (*add_new_value_labels) (const PsppireDialogActionRecode *, struct string *)); G_END_DECLS diff --git a/src/ui/gui/psppire-dialog-action-regression.c b/src/ui/gui/psppire-dialog-action-regression.c index 7c16cbfade..072da23e59 100644 --- a/src/ui/gui/psppire-dialog-action-regression.c +++ b/src/ui/gui/psppire-dialog-action-regression.c @@ -37,7 +37,7 @@ #define REGRESSION_STATS \ - RG (COEFF, N_("Coeff"), N_("Show the regression coefficients")) \ + RG (COEFF, N_("Coeff"), N_("Show the regression coefficients")) \ RG (CI, N_("Conf. Interval"), N_("Show the confidence interval for the regression coefficients")) \ RG (R, N_("R"), N_("Show the correlation between observed and predicted values")) \ RG (ANOVA, N_("Anova"), N_("Show the analysis of variance table")) \ @@ -135,9 +135,9 @@ on_save_clicked (PsppireDialogActionRegression *rd) if (ret == PSPPIRE_RESPONSE_CONTINUE) { rd->pred = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->pred_button)) == TRUE) - ? TRUE : FALSE; + ? TRUE : FALSE; rd->resid = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->resid_button)) == TRUE) - ? TRUE : FALSE; + ? TRUE : FALSE; } } @@ -165,20 +165,20 @@ psppire_dialog_action_regression_activate (PsppireDialogAction *a, GVariant *par act->resid_button = get_widget_assert (xml, "resid-button"); psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (act->stat_view), - B_RG_STATS_DEFAULT, - N_REGRESSION_STATS, - stats); + B_RG_STATS_DEFAULT, + N_REGRESSION_STATS, + stats); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); g_signal_connect_swapped (stat_button, "clicked", - G_CALLBACK (on_statistics_clicked), act); + G_CALLBACK (on_statistics_clicked), act); g_signal_connect_swapped (save_button, "clicked", - G_CALLBACK (on_save_clicked), act); + G_CALLBACK (on_save_clicked), act); return xml; } @@ -209,11 +209,11 @@ generate_syntax (const PsppireDialogAction *a) { gboolean toggled; gtk_tree_model_get (model, &iter, - CHECKBOX_COLUMN_SELECTED, &toggled, -1); + CHECKBOX_COLUMN_SELECTED, &toggled, -1); if (toggled) - selected |= 1u << i; + selected |= 1u << i; else - selected &= ~(1u << i); + selected &= ~(1u << i); } if (selected) @@ -221,21 +221,21 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, "\n\t/STATISTICS="); int n = 0; for (gint i = 0; i < N_REGRESSION_STATS; i++) - if (selected & (1u << i)) - { - if (n++) - g_string_append (string, " "); - g_string_append (string, stats[i].name); - } + if (selected & (1u << i)) + { + if (n++) + g_string_append (string, " "); + g_string_append (string, stats[i].name); + } } if (rd->pred || rd->resid) { g_string_append (string, "\n\t/SAVE="); if (rd->pred) - g_string_append (string, " PRED"); + g_string_append (string, " PRED"); if (rd->resid) - g_string_append (string, " RESID"); + g_string_append (string, " RESID"); } g_string_append (string, ".\n"); diff --git a/src/ui/gui/psppire-dialog-action-regression.h b/src/ui/gui/psppire-dialog-action-regression.h index bb78a36e0b..0182b02588 100644 --- a/src/ui/gui/psppire-dialog-action-regression.h +++ b/src/ui/gui/psppire-dialog-action-regression.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION (psppire_dialog_action_regression_get_type ()) -#define PSPPIRE_DIALOG_ACTION_REGRESSION(obj) \ +#define PSPPIRE_DIALOG_ACTION_REGRESSION(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, PsppireDialogActionRegression)) + PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, PsppireDialogActionRegression)) #define PSPPIRE_DIALOG_ACTION_REGRESSION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \ + PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \ PsppireDialogActionRegressionClass)) #define PSPPIRE_IS_DIALOG_ACTION_REGRESSION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION)) #define PSPPIRE_IS_DIALOG_ACTION_REGRESSION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION)) #define PSPPIRE_DIALOG_ACTION_REGRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \ - PsppireDialogActionRegressionClass)) + PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \ + PsppireDialogActionRegressionClass)) typedef struct _PsppireDialogActionRegression PsppireDialogActionRegression; typedef struct _PsppireDialogActionRegressionClass PsppireDialogActionRegressionClass; diff --git a/src/ui/gui/psppire-dialog-action-reliability.c b/src/ui/gui/psppire-dialog-action-reliability.c index e3570c8849..89231c4d56 100644 --- a/src/ui/gui/psppire-dialog-action-reliability.c +++ b/src/ui/gui/psppire-dialog-action-reliability.c @@ -51,8 +51,8 @@ generate_syntax (const PsppireDialogAction *act) g_string_append (string, "ALPHA"); else g_string_append_printf (string, "SPLIT (%d)", - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (rd->split_spinbutton)) - ); + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (rd->split_spinbutton)) + ); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->scale_if_item_deleted_checkbutton))) g_string_append (string, "\n\t/SUMMARY = TOTAL"); @@ -87,10 +87,10 @@ update_split_control (PsppireDialogActionReliability *pda) gtk_spin_button_set_value (GTK_SPIN_BUTTON (pda->split_spinbutton), n_vars - 1); gtk_spin_button_set_range (GTK_SPIN_BUTTON (pda->split_spinbutton), - 0, n_vars - 1); + 0, n_vars - 1); gtk_widget_set_sensitive (pda->split_point_hbox, - (SPLIT == gtk_combo_box_get_active (GTK_COMBO_BOX (pda->model_combo)))); + (SPLIT == gtk_combo_box_get_active (GTK_COMBO_BOX (pda->model_combo)))); } @@ -108,10 +108,10 @@ refresh (PsppireDialogAction *pda_) gtk_spin_button_set_value (GTK_SPIN_BUTTON (pda->split_spinbutton), 0); gtk_spin_button_set_range (GTK_SPIN_BUTTON (pda->split_spinbutton), - 0, 0); + 0, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pda->scale_if_item_deleted_checkbutton), - FALSE); + FALSE); } static GtkBuilder * @@ -142,13 +142,13 @@ psppire_dialog_action_reliability_activate (PsppireDialogAction *a, GVariant *pa act->scale_if_item_deleted_checkbutton = get_widget_assert (xml, "totals-checkbutton"); g_signal_connect_swapped (act->model_combo, "changed", - G_CALLBACK (update_split_control), pda); + G_CALLBACK (update_split_control), pda); g_signal_connect_swapped (liststore, "row-inserted", - G_CALLBACK (update_split_control), pda); + G_CALLBACK (update_split_control), pda); g_signal_connect_swapped (liststore, "row-deleted", - G_CALLBACK (update_split_control), pda); + G_CALLBACK (update_split_control), pda); psppire_dialog_action_set_refresh (pda, refresh); diff --git a/src/ui/gui/psppire-dialog-action-reliability.h b/src/ui/gui/psppire-dialog-action-reliability.h index a75f6217f7..54434b1965 100644 --- a/src/ui/gui/psppire-dialog-action-reliability.h +++ b/src/ui/gui/psppire-dialog-action-reliability.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY (psppire_dialog_action_reliability_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RELIABILITY(obj) \ +#define PSPPIRE_DIALOG_ACTION_RELIABILITY(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, PsppireDialogActionReliability)) + PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, PsppireDialogActionReliability)) #define PSPPIRE_DIALOG_ACTION_RELIABILITY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, \ + PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, \ PsppireDialogActionReliabilityClass)) #define PSPPIRE_IS_DIALOG_ACTION_RELIABILITY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY)) #define PSPPIRE_IS_DIALOG_ACTION_RELIABILITY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY)) #define PSPPIRE_DIALOG_ACTION_RELIABILITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, \ - PsppireDialogActionReliabilityClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RELIABILITY, \ + PsppireDialogActionReliabilityClass)) typedef struct _PsppireDialogActionReliability PsppireDialogActionReliability; typedef struct _PsppireDialogActionReliabilityClass PsppireDialogActionReliabilityClass; diff --git a/src/ui/gui/psppire-dialog-action-roc.c b/src/ui/gui/psppire-dialog-action-roc.c index 2d19459656..341f7ffca1 100644 --- a/src/ui/gui/psppire-dialog-action-roc.c +++ b/src/ui/gui/psppire-dialog-action-roc.c @@ -77,7 +77,7 @@ on_curve_button_toggle (GtkCheckButton *curve, PsppireDialogActionRoc *rd) if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (curve))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->reference))) - g_object_set (rd->reference, "inconsistent", TRUE, NULL); + g_object_set (rd->reference, "inconsistent", TRUE, NULL); g_object_set (rd->reference, "sensitive", FALSE, NULL); } else @@ -141,15 +141,15 @@ psppire_dialog_action_roc_activate (PsppireDialogAction *a, GVariant *param) act->coordinates = get_widget_assert (xml, "co-ordinates"); g_signal_connect_swapped (act->state_variable, "changed", - G_CALLBACK (on_state_var_changed), act); + G_CALLBACK (on_state_var_changed), act); g_signal_connect (act->curve, "toggled", - G_CALLBACK (on_curve_button_toggle), act); + G_CALLBACK (on_curve_button_toggle), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } @@ -177,7 +177,7 @@ generate_syntax (const PsppireDialogAction *a) value_init (&val, var_get_width (var)); psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (rd->state_value), - &val, var_get_width (var)); + &val, var_get_width (var)); g_return_val_if_fail (var, NULL); @@ -203,7 +203,7 @@ generate_syntax (const PsppireDialogAction *a) { g_string_append (string, "CURVE"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->reference))) - g_string_append (string, " (REFERENCE)"); + g_string_append (string, " (REFERENCE)"); } else g_string_append (string, "NONE"); @@ -216,10 +216,10 @@ generate_syntax (const PsppireDialogAction *a) g_string_append (string, "\n\t/PRINT"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->standard_error))) - g_string_append (string, " SE"); + g_string_append (string, " SE"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->coordinates))) - g_string_append (string, " COORDINATES"); + g_string_append (string, " COORDINATES"); } g_string_append (string, ".\n"); diff --git a/src/ui/gui/psppire-dialog-action-roc.h b/src/ui/gui/psppire-dialog-action-roc.h index a5b56c5922..a86d0ee3b0 100644 --- a/src/ui/gui/psppire-dialog-action-roc.h +++ b/src/ui/gui/psppire-dialog-action-roc.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_ROC (psppire_dialog_action_roc_get_type ()) -#define PSPPIRE_DIALOG_ACTION_ROC(obj) \ +#define PSPPIRE_DIALOG_ACTION_ROC(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_ROC, PsppireDialogActionRoc)) + PSPPIRE_TYPE_DIALOG_ACTION_ROC, PsppireDialogActionRoc)) #define PSPPIRE_DIALOG_ACTION_ROC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_ROC, \ + PSPPIRE_TYPE_DIALOG_ACTION_ROC, \ PsppireDialogActionRocClass)) #define PSPPIRE_IS_DIALOG_ACTION_ROC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_ROC)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_ROC)) #define PSPPIRE_IS_DIALOG_ACTION_ROC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_ROC)) #define PSPPIRE_DIALOG_ACTION_ROC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_ROC, \ - PsppireDialogActionRocClass)) + PSPPIRE_TYPE_DIALOG_ACTION_ROC, \ + PsppireDialogActionRocClass)) typedef struct _PsppireDialogActionRoc PsppireDialogActionRoc; typedef struct _PsppireDialogActionRocClass PsppireDialogActionRocClass; diff --git a/src/ui/gui/psppire-dialog-action-runs.c b/src/ui/gui/psppire-dialog-action-runs.c index 0d06c89f31..7e4f1a973f 100644 --- a/src/ui/gui/psppire-dialog-action-runs.c +++ b/src/ui/gui/psppire-dialog-action-runs.c @@ -92,7 +92,7 @@ dialog_state_valid (gpointer data) for (i = 0; i < 4; ++i) { if (TRUE == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->cb[i]))) - break; + break; } if (i >= 4) return FALSE; @@ -101,7 +101,7 @@ dialog_state_valid (gpointer data) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->cb[CB_CUSTOM]))) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (fd->entry)))) - return FALSE; + return FALSE; } return TRUE; diff --git a/src/ui/gui/psppire-dialog-action-runs.h b/src/ui/gui/psppire-dialog-action-runs.h index 84e796b19a..5e0a015ec0 100644 --- a/src/ui/gui/psppire-dialog-action-runs.h +++ b/src/ui/gui/psppire-dialog-action-runs.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_RUNS (psppire_dialog_action_runs_get_type ()) -#define PSPPIRE_DIALOG_ACTION_RUNS(obj) \ +#define PSPPIRE_DIALOG_ACTION_RUNS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RUNS, PsppireDialogActionRuns)) + PSPPIRE_TYPE_DIALOG_ACTION_RUNS, PsppireDialogActionRuns)) #define PSPPIRE_DIALOG_ACTION_RUNS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_RUNS, \ + PSPPIRE_TYPE_DIALOG_ACTION_RUNS, \ PsppireDialogActionRunsClass)) #define PSPPIRE_IS_DIALOG_ACTION_RUNS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RUNS)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_RUNS)) #define PSPPIRE_IS_DIALOG_ACTION_RUNS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_RUNS)) #define PSPPIRE_DIALOG_ACTION_RUNS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_RUNS, \ - PsppireDialogActionRunsClass)) + PSPPIRE_TYPE_DIALOG_ACTION_RUNS, \ + PsppireDialogActionRunsClass)) typedef struct _PsppireDialogActionRuns PsppireDialogActionRuns; typedef struct _PsppireDialogActionRunsClass PsppireDialogActionRunsClass; diff --git a/src/ui/gui/psppire-dialog-action-scatterplot.h b/src/ui/gui/psppire-dialog-action-scatterplot.h index 948ec3b283..9fff140361 100644 --- a/src/ui/gui/psppire-dialog-action-scatterplot.h +++ b/src/ui/gui/psppire-dialog-action-scatterplot.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT (psppire_dialog_action_scatterplot_get_type ()) -#define PSPPIRE_DIALOG_ACTION_SCATTERPLOT(obj) \ +#define PSPPIRE_DIALOG_ACTION_SCATTERPLOT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, PsppireDialogActionScatterplot)) + PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, PsppireDialogActionScatterplot)) #define PSPPIRE_DIALOG_ACTION_SCATTERPLOT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, \ + PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, \ PsppireDialogActionScatterplotClass)) #define PSPPIRE_IS_DIALOG_ACTION_SCATTERPLOT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT)) #define PSPPIRE_IS_DIALOG_ACTION_SCATTERPLOT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT)) #define PSPPIRE_DIALOG_ACTION_SCATTERPLOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, \ - PsppireDialogActionScatterplotClass)) + PSPPIRE_TYPE_DIALOG_ACTION_SCATTERPLOT, \ + PsppireDialogActionScatterplotClass)) typedef struct _PsppireDialogActionScatterplot PsppireDialogActionScatterplot; typedef struct _PsppireDialogActionScatterplotClass PsppireDialogActionScatterplotClass; diff --git a/src/ui/gui/psppire-dialog-action-select.c b/src/ui/gui/psppire-dialog-action-select.c index 5ee493a45f..70e24e92ba 100644 --- a/src/ui/gui/psppire-dialog-action-select.c +++ b/src/ui/gui/psppire-dialog-action-select.c @@ -56,7 +56,7 @@ dialog_state_valid (gpointer data) { const gchar *text = gtk_entry_get_text (GTK_ENTRY (act->entry)); if (!psppire_dict_lookup_var (PSPPIRE_DIALOG_ACTION (act)->dict, text)) - return FALSE; + return FALSE; } return TRUE; @@ -99,9 +99,9 @@ sample_consistent (GtkSpinButton *spin, PsppireDialogActionSelect *act) if (limit < size) { if (spin == GTK_SPIN_BUTTON (act->spin_sample_size)) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->spin_sample_limit), size); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->spin_sample_limit), size); if (spin == GTK_SPIN_BUTTON (act->spin_sample_limit)) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->spin_sample_size), limit); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->spin_sample_size), limit); } } @@ -115,8 +115,8 @@ sample_subdialog (GtkButton *b, gpointer data) PsppireDataStore *data_store = NULL; g_object_get (PSPPIRE_DATA_WINDOW (pda->toplevel)->data_editor, - "data-store", &data_store, - NULL); + "data-store", &data_store, + NULL); gint case_count = psppire_data_store_get_case_count (data_store); @@ -127,12 +127,12 @@ sample_subdialog (GtkButton *b, gpointer data) gtk_widget_show (scd->hbox1); gtk_grid_attach (GTK_GRID (scd->table), - scd->hbox1, - 1, 0, - 1, 1); + scd->hbox1, + 1, 0, + 1, 1); g_signal_connect (scd->percent, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), scd->hbox1); + G_CALLBACK (set_sensitivity_from_toggle), scd->hbox1); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scd->percent), TRUE); } @@ -141,13 +141,13 @@ sample_subdialog (GtkButton *b, gpointer data) if (!scd->hbox2) { scd->hbox2 = - psppire_scanf_new (gettext (label2), &scd->spin_sample_size, &scd->spin_sample_limit); + psppire_scanf_new (gettext (label2), &scd->spin_sample_size, &scd->spin_sample_limit); gtk_spin_button_set_range (GTK_SPIN_BUTTON (scd->spin_sample_size), - 1, case_count); + 1, case_count); gtk_spin_button_set_range (GTK_SPIN_BUTTON (scd->spin_sample_limit), - 1, case_count); + 1, case_count); 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); @@ -157,32 +157,32 @@ sample_subdialog (GtkButton *b, gpointer data) gtk_widget_set_sensitive (scd->hbox2, FALSE); gtk_grid_attach (GTK_GRID (scd->table), - scd->hbox2, - 1, 1, 1, 1); + scd->hbox2, + 1, 1, 1, 1); g_signal_connect (scd->sample_n_cases, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), scd->hbox2); + G_CALLBACK (set_sensitivity_from_toggle), scd->hbox2); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scd->sample_n_cases), FALSE); } gtk_window_set_transient_for (GTK_WINDOW (scd->rsample_dialog), - GTK_WINDOW (pda->dialog)); + GTK_WINDOW (pda->dialog)); response = psppire_dialog_run (PSPPIRE_DIALOG (scd->rsample_dialog)); if (response != PSPPIRE_RESPONSE_CONTINUE) { g_signal_handlers_disconnect_by_func - (G_OBJECT (scd->percent), - G_CALLBACK (set_sensitivity_from_toggle), - scd->hbox1); + (G_OBJECT (scd->percent), + G_CALLBACK (set_sensitivity_from_toggle), + scd->hbox1); g_signal_handlers_disconnect_by_func - (G_OBJECT (scd->sample_n_cases), - G_CALLBACK (set_sensitivity_from_toggle), - scd->hbox2); + (G_OBJECT (scd->sample_n_cases), + G_CALLBACK (set_sensitivity_from_toggle), + scd->hbox2); gtk_widget_destroy(scd->hbox1); gtk_widget_destroy(scd->hbox2); @@ -193,17 +193,17 @@ sample_subdialog (GtkButton *b, gpointer data) gchar *text; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->percent))) - { - text = widget_printf (gettext(label1), scd->spinbutton); - gtk_label_set_text (GTK_LABEL (scd->l0), text); - } + { + text = widget_printf (gettext(label1), scd->spinbutton); + gtk_label_set_text (GTK_LABEL (scd->l0), text); + } else - { - text = - widget_printf (gettext(label2), scd->spin_sample_size, scd->spin_sample_limit); - gtk_label_set_text (GTK_LABEL (scd->l0), text); + { + text = + widget_printf (gettext(label2), scd->spin_sample_size, scd->spin_sample_limit); + gtk_label_set_text (GTK_LABEL (scd->l0), text); - } + } g_free (text); } } @@ -219,8 +219,8 @@ range_subdialog (GtkButton *b, gpointer data) PsppireDataStore *data_store = NULL; g_object_get (PSPPIRE_DATA_WINDOW (pda->toplevel)->data_editor, - "data-store", &data_store, - NULL); + "data-store", &data_store, + NULL); gint n_cases = psppire_data_store_get_case_count (data_store); @@ -228,7 +228,7 @@ range_subdialog (GtkButton *b, gpointer data) gtk_spin_button_set_range (GTK_SPIN_BUTTON (scd->first), 1, n_cases); gtk_window_set_transient_for (GTK_WINDOW (scd->range_subdialog), - GTK_WINDOW (pda->dialog)); + GTK_WINDOW (pda->dialog)); response = psppire_dialog_run (PSPPIRE_DIALOG (scd->range_subdialog)); if (response == PSPPIRE_RESPONSE_CONTINUE) @@ -249,9 +249,9 @@ consistency (GtkSpinButton *spin, PsppireDialogActionSelect *act) if (last < first) { if (spin == GTK_SPIN_BUTTON (act->first)) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->last), first); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->last), first); if (spin == GTK_SPIN_BUTTON (act->last)) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->first), last); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (act->first), last); } } @@ -281,14 +281,14 @@ psppire_dialog_action_select_activate (PsppireDialogAction *a, GVariant *param) pda->source = get_widget_assert (xml, "select-cases-treeview"); g_object_set (pda->source, - "selection-mode", GTK_SELECTION_SINGLE, - NULL); + "selection-mode", GTK_SELECTION_SINGLE, + NULL); act->entry = get_widget_assert (xml, "filter-variable-entry"); GtkWidget *selector = get_widget_assert (xml, "psppire-selector-filter"); psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector), - is_currently_in_entry); + is_currently_in_entry); act->rsample_dialog = get_widget_assert (xml, "select-cases-random-sample-dialog"); act->percent = get_widget_assert (xml, "radiobutton-sample-percent"); @@ -328,45 +328,45 @@ psppire_dialog_action_select_activate (PsppireDialogAction *a, GVariant *param) GtkWidget *sample_label = get_widget_assert (xml, "random-sample-label"); g_signal_connect (act->radiobutton_all, "toggled", - G_CALLBACK (set_sensitivity_from_toggle_invert), - get_widget_assert (xml, "filter-delete-button-box")); + G_CALLBACK (set_sensitivity_from_toggle_invert), + get_widget_assert (xml, "filter-delete-button-box")); g_signal_connect (button_if, "clicked", - G_CALLBACK (set_radiobutton), radiobutton_if); + G_CALLBACK (set_radiobutton), radiobutton_if); g_signal_connect (button_sample, "clicked", - G_CALLBACK (set_radiobutton), act->radiobutton_sample); + G_CALLBACK (set_radiobutton), act->radiobutton_sample); g_signal_connect (button_range, "clicked", - G_CALLBACK (set_radiobutton), act->radiobutton_range); + G_CALLBACK (set_radiobutton), act->radiobutton_range); g_signal_connect (selector, "clicked", - G_CALLBACK (set_radiobutton), act->radiobutton_filter_variable); + G_CALLBACK (set_radiobutton), act->radiobutton_filter_variable); g_signal_connect (selector, "selected", - G_CALLBACK (set_radiobutton), act->radiobutton_filter_variable); + G_CALLBACK (set_radiobutton), act->radiobutton_filter_variable); g_signal_connect (act->radiobutton_range, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - act->l1); + G_CALLBACK (set_sensitivity_from_toggle), + act->l1); g_signal_connect (act->radiobutton_sample, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - sample_label); + G_CALLBACK (set_sensitivity_from_toggle), + sample_label); g_signal_connect (act->radiobutton_filter_variable, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), - act->entry); + G_CALLBACK (set_sensitivity_from_toggle), + act->entry); g_signal_connect (button_range, - "clicked", G_CALLBACK (range_subdialog), act); + "clicked", G_CALLBACK (range_subdialog), act); g_signal_connect (button_sample, - "clicked", G_CALLBACK (sample_subdialog), act); + "clicked", G_CALLBACK (sample_subdialog), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } @@ -388,75 +388,75 @@ generate_syntax_filter (const PsppireDialogAction *a) (GTK_TOGGLE_BUTTON (scd->radiobutton_range))) { ds_put_c_format (&dss, - "COMPUTE filter_$ = ($CASENUM >= %ld " - "AND $CASENUM <= %ld).\n", - (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->first)), - (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->last))); + "COMPUTE filter_$ = ($CASENUM >= %ld " + "AND $CASENUM <= %ld).\n", + (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->first)), + (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->last))); ds_put_cstr (&dss, "EXECUTE.\n"); } else if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (scd->radiobutton_sample))) + (GTK_TOGGLE_BUTTON (scd->radiobutton_sample))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->percent))) - { - const double percentage = - gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->spinbutton)); - - ds_put_c_format (&dss, - "COMPUTE %s = RV.UNIFORM (0,1) < %.*g.\n", - filter, - DBL_DIG + 1, percentage / 100.0); - } + { + const double percentage = + gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->spinbutton)); + + ds_put_c_format (&dss, + "COMPUTE %s = RV.UNIFORM (0,1) < %.*g.\n", + filter, + DBL_DIG + 1, percentage / 100.0); + } else - { - const gint n_cases = - 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)); + { + const gint n_cases = + 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)); - const gchar ranvar[]="rv_$"; + const gchar ranvar[]="rv_$"; - ds_put_c_format (&dss, - "COMPUTE %s = $CASENUM.\n", key); + ds_put_c_format (&dss, + "COMPUTE %s = $CASENUM.\n", key); - ds_put_c_format (&dss, - "COMPUTE %s = %s > %d.\n", - filter, key, from_n_cases); + ds_put_c_format (&dss, + "COMPUTE %s = %s > %d.\n", + filter, key, from_n_cases); - ds_put_c_format (&dss, - "COMPUTE %s = RV.UNIFORM (0, 1).\n", - ranvar); + ds_put_c_format (&dss, + "COMPUTE %s = RV.UNIFORM (0, 1).\n", + ranvar); - ds_put_c_format (&dss, - "SORT CASES BY %s, %s.\n", - filter, ranvar); + ds_put_c_format (&dss, + "SORT CASES BY %s, %s.\n", + filter, ranvar); - ds_put_cstr (&dss, "EXECUTE.\n"); + ds_put_cstr (&dss, "EXECUTE.\n"); - ds_put_c_format (&dss, - "COMPUTE %s = $CASENUM.\n", - filter); + ds_put_c_format (&dss, + "COMPUTE %s = $CASENUM.\n", + filter); - ds_put_c_format (&dss, - "COMPUTE %s = %s <= %d\n", - filter, - filter, - n_cases); + ds_put_c_format (&dss, + "COMPUTE %s = %s <= %d\n", + filter, + filter, + n_cases); - ds_put_cstr (&dss, "EXECUTE.\n"); + ds_put_cstr (&dss, "EXECUTE.\n"); - ds_put_c_format (&dss, - "SORT CASES BY %s.\n", - key); + ds_put_c_format (&dss, + "SORT CASES BY %s.\n", + key); - ds_put_c_format (&dss, - "DELETE VARIABLES %s, %s.\n", - key, ranvar); - } + ds_put_c_format (&dss, + "DELETE VARIABLES %s, %s.\n", + key, ranvar); + } ds_put_cstr (&dss, "EXECUTE.\n"); } @@ -496,39 +496,39 @@ generate_syntax_delete (const PsppireDialogAction *a) 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->spinbutton)); - ds_put_c_format (&dss, "%g.", percentage / 100.0); - } + { + const double percentage = + gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->spinbutton)); + ds_put_c_format (&dss, "%g.", percentage / 100.0); + } else - { - const gint n_cases = - 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)); + { + const gint n_cases = + 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); - } + 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))) + (GTK_TOGGLE_BUTTON (scd->radiobutton_range))) { ds_put_c_format (&dss, - "COMPUTE filter_$ = ($CASENUM >= %ld " - "AND $CASENUM <= %ld).\n", - (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->first)), - (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->last))); + "COMPUTE filter_$ = ($CASENUM >= %ld " + "AND $CASENUM <= %ld).\n", + (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->first)), + (long) gtk_spin_button_get_value (GTK_SPIN_BUTTON (scd->last))); ds_put_cstr (&dss, "EXECUTE.\n"); ds_put_c_format (&dss, "SELECT IF filter_$.\n"); } else if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (scd->radiobutton_filter_variable))) + (GTK_TOGGLE_BUTTON (scd->radiobutton_filter_variable))) { ds_put_c_format (&dss, "SELECT IF (%s <> 0).", - gtk_entry_get_text (GTK_ENTRY (scd->entry))); + gtk_entry_get_text (GTK_ENTRY (scd->entry))); } diff --git a/src/ui/gui/psppire-dialog-action-select.h b/src/ui/gui/psppire-dialog-action-select.h index 331a6972f7..3f9e2da9e8 100644 --- a/src/ui/gui/psppire-dialog-action-select.h +++ b/src/ui/gui/psppire-dialog-action-select.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_SELECT (psppire_dialog_action_select_get_type ()) -#define PSPPIRE_DIALOG_ACTION_SELECT(obj) \ +#define PSPPIRE_DIALOG_ACTION_SELECT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SELECT, PsppireDialogActionSelect)) + PSPPIRE_TYPE_DIALOG_ACTION_SELECT, PsppireDialogActionSelect)) #define PSPPIRE_DIALOG_ACTION_SELECT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_SELECT, \ + PSPPIRE_TYPE_DIALOG_ACTION_SELECT, \ PsppireDialogActionSelectClass)) #define PSPPIRE_IS_DIALOG_ACTION_SELECT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SELECT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SELECT)) #define PSPPIRE_IS_DIALOG_ACTION_SELECT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_SELECT)) #define PSPPIRE_DIALOG_ACTION_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SELECT, \ - PsppireDialogActionSelectClass)) + PSPPIRE_TYPE_DIALOG_ACTION_SELECT, \ + PsppireDialogActionSelectClass)) typedef struct _PsppireDialogActionSelect PsppireDialogActionSelect; typedef struct _PsppireDialogActionSelectClass PsppireDialogActionSelectClass; diff --git a/src/ui/gui/psppire-dialog-action-sort.c b/src/ui/gui/psppire-dialog-action-sort.c index b34322614d..ef4781d40f 100644 --- a/src/ui/gui/psppire-dialog-action-sort.c +++ b/src/ui/gui/psppire-dialog-action-sort.c @@ -45,7 +45,7 @@ generate_syntax (const PsppireDialogAction *act) else { const char up_down = - (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->ascending)) + (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->ascending)) ? 'A' : 'D'); g_string_append_printf (string, "(%c)", up_down); g_string_append (string, "."); @@ -101,7 +101,7 @@ psppire_dialog_action_sort_activate (PsppireDialogAction *a, GVariant *param) psppire_dialog_action_set_refresh (pda, reset); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-sort.h b/src/ui/gui/psppire-dialog-action-sort.h index 3ab6699073..2219d43977 100644 --- a/src/ui/gui/psppire-dialog-action-sort.h +++ b/src/ui/gui/psppire-dialog-action-sort.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_SORT (psppire_dialog_action_sort_get_type ()) -#define PSPPIRE_DIALOG_ACTION_SORT(obj) \ +#define PSPPIRE_DIALOG_ACTION_SORT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SORT, PsppireDialogActionSort)) + PSPPIRE_TYPE_DIALOG_ACTION_SORT, PsppireDialogActionSort)) #define PSPPIRE_DIALOG_ACTION_SORT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_SORT, \ + PSPPIRE_TYPE_DIALOG_ACTION_SORT, \ PsppireDialogActionSortClass)) #define PSPPIRE_IS_DIALOG_ACTION_SORT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SORT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SORT)) #define PSPPIRE_IS_DIALOG_ACTION_SORT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_SORT)) #define PSPPIRE_DIALOG_ACTION_SORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SORT, \ - PsppireDialogActionSortClass)) + PSPPIRE_TYPE_DIALOG_ACTION_SORT, \ + PsppireDialogActionSortClass)) typedef struct _PsppireDialogActionSort PsppireDialogActionSort; typedef struct _PsppireDialogActionSortClass PsppireDialogActionSortClass; diff --git a/src/ui/gui/psppire-dialog-action-split.c b/src/ui/gui/psppire-dialog-action-split.c index 634e27a7e1..a727cb5c09 100644 --- a/src/ui/gui/psppire-dialog-action-split.c +++ b/src/ui/gui/psppire-dialog-action-split.c @@ -48,27 +48,27 @@ generate_syntax (const PsppireDialogAction *pda) gint n_vars = psppire_var_view_append_names (PSPPIRE_VAR_VIEW (act->tv), 0, varlist); if (n_vars > 0) - { - g_string_assign (string, ""); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(act->sort))) - { - g_string_append (string, "SORT CASES BY"); - g_string_append (string, varlist->str); - g_string_append (string, ".\n"); - } - - g_string_append (string, "SPLIT FILE "); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->layered))) - g_string_append (string, "LAYERED "); - else - g_string_append (string, "SEPARATE "); - - g_string_append (string, "BY "); - g_string_append (string, varlist->str); - g_string_append (string, "."); - } + { + g_string_assign (string, ""); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(act->sort))) + { + g_string_append (string, "SORT CASES BY"); + g_string_append (string, varlist->str); + g_string_append (string, ".\n"); + } + + g_string_append (string, "SPLIT FILE "); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->layered))) + g_string_append (string, "LAYERED "); + else + g_string_append (string, "SEPARATE "); + + g_string_append (string, "BY "); + g_string_append (string, varlist->str); + g_string_append (string, "."); + } g_string_free (varlist, TRUE); } @@ -102,13 +102,13 @@ refresh (PsppireDialogAction *pda) const struct variable *const *vars = dict_get_split_vars (pda->dict->dict); for (i = 0 ; i < n_vars; ++i) - { - gtk_list_store_append (GTK_LIST_STORE (liststore), &iter); + { + gtk_list_store_append (GTK_LIST_STORE (liststore), &iter); - gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, - 0, vars[i], - -1); - } + gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, + 0, vars[i], + -1); + } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (act->layered), TRUE); } @@ -120,7 +120,7 @@ refresh (PsppireDialogAction *pda) static void on_off_toggled (GtkToggleButton *togglebutton, - gpointer user_data) + gpointer user_data) { PsppireDialogActionSplit *act = PSPPIRE_DIALOG_ACTION_SPLIT (user_data); diff --git a/src/ui/gui/psppire-dialog-action-split.h b/src/ui/gui/psppire-dialog-action-split.h index 468ff6129c..de9e9830b5 100644 --- a/src/ui/gui/psppire-dialog-action-split.h +++ b/src/ui/gui/psppire-dialog-action-split.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_SPLIT (psppire_dialog_action_split_get_type ()) -#define PSPPIRE_DIALOG_ACTION_SPLIT(obj) \ +#define PSPPIRE_DIALOG_ACTION_SPLIT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, PsppireDialogActionSplit)) + PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, PsppireDialogActionSplit)) #define PSPPIRE_DIALOG_ACTION_SPLIT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, \ + PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, \ PsppireDialogActionSplitClass)) #define PSPPIRE_IS_DIALOG_ACTION_SPLIT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SPLIT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SPLIT)) #define PSPPIRE_IS_DIALOG_ACTION_SPLIT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_SPLIT)) #define PSPPIRE_DIALOG_ACTION_SPLIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, \ - PsppireDialogActionSplitClass)) + PSPPIRE_TYPE_DIALOG_ACTION_SPLIT, \ + PsppireDialogActionSplitClass)) typedef struct _PsppireDialogActionSplit PsppireDialogActionSplit; typedef struct _PsppireDialogActionSplitClass PsppireDialogActionSplitClass; diff --git a/src/ui/gui/psppire-dialog-action-tt1s.c b/src/ui/gui/psppire-dialog-action-tt1s.c index 1937a75f0c..6f310763cd 100644 --- a/src/ui/gui/psppire-dialog-action-tt1s.c +++ b/src/ui/gui/psppire-dialog-action-tt1s.c @@ -39,7 +39,7 @@ generate_syntax (const PsppireDialogAction *act) GString *str = g_string_new ("T-TEST "); g_string_append_printf (str, "/TESTVAL=%s", - gtk_entry_get_text (GTK_ENTRY (d->test_value_entry))); + gtk_entry_get_text (GTK_ENTRY (d->test_value_entry))); g_string_append (str, "\n\t/VARIABLES="); @@ -110,7 +110,7 @@ psppire_dialog_action_tt1s_activate (PsppireDialogAction *a, GVariant *param) pda->source = get_widget_assert (xml, "one-sample-t-test-treeview2"); g_object_set (pda->source, - "predicate", var_is_numeric, NULL); + "predicate", var_is_numeric, NULL); act->vars_treeview = get_widget_assert (xml, "one-sample-t-test-treeview1"); act->test_value_entry = get_widget_assert (xml, "test-value-entry"); @@ -121,7 +121,7 @@ psppire_dialog_action_tt1s_activate (PsppireDialogAction *a, GVariant *param) psppire_dialog_action_set_refresh (pda, refresh); g_signal_connect_swapped (options_button, "clicked", - G_CALLBACK (tt_options_dialog_run), act->opt); + G_CALLBACK (tt_options_dialog_run), act->opt); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-tt1s.h b/src/ui/gui/psppire-dialog-action-tt1s.h index f09461fc39..1cfd3c7e3f 100644 --- a/src/ui/gui/psppire-dialog-action-tt1s.h +++ b/src/ui/gui/psppire-dialog-action-tt1s.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_TT1S (psppire_dialog_action_tt1s_get_type ()) -#define PSPPIRE_DIALOG_ACTION_TT1S(obj) \ +#define PSPPIRE_DIALOG_ACTION_TT1S(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_TT1S, PsppireDialogActionTt1s)) + PSPPIRE_TYPE_DIALOG_ACTION_TT1S, PsppireDialogActionTt1s)) #define PSPPIRE_DIALOG_ACTION_TT1S_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_TT1S, \ + PSPPIRE_TYPE_DIALOG_ACTION_TT1S, \ PsppireDialogActionTt1sClass)) #define PSPPIRE_IS_DIALOG_ACTION_TT1S(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_TT1S)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_TT1S)) #define PSPPIRE_IS_DIALOG_ACTION_TT1S_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_TT1S)) #define PSPPIRE_DIALOG_ACTION_TT1S_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_TT1S, \ - PsppireDialogActionTt1sClass)) + PSPPIRE_TYPE_DIALOG_ACTION_TT1S, \ + PsppireDialogActionTt1sClass)) typedef struct _PsppireDialogActionTt1s PsppireDialogActionTt1s; typedef struct _PsppireDialogActionTt1sClass PsppireDialogActionTt1sClass; diff --git a/src/ui/gui/psppire-dialog-action-two-sample.c b/src/ui/gui/psppire-dialog-action-two-sample.c index 7d8c0916ef..e279088af0 100644 --- a/src/ui/gui/psppire-dialog-action-two-sample.c +++ b/src/ui/gui/psppire-dialog-action-two-sample.c @@ -49,7 +49,7 @@ dialog_state_valid (gpointer data) /* Get the last row */ gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pd->list_store), &dest_iter, - NULL, n_rows - 1); + NULL, n_rows - 1); /* Get the last (2nd) column */ gtk_tree_model_get (GTK_TREE_MODEL (pd->list_store), &dest_iter, 1, &v, -1); @@ -87,9 +87,9 @@ refresh (PsppireDialogAction *rd_) static void select_as_pair_member (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data) + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data) { struct variable *v; struct variable *v1; @@ -99,7 +99,7 @@ select_as_pair_member (GtkTreeIter source_iter, gtk_tree_model_get (source_model, &source_iter, - DICT_TVM_COL_VAR, &v, -1); + DICT_TVM_COL_VAR, &v, -1); n_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (tt_d->list_store), NULL); @@ -107,7 +107,7 @@ select_as_pair_member (GtkTreeIter source_iter, { gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (tt_d->list_store), - &dest_iter, NULL, n_rows - 1); + &dest_iter, NULL, n_rows - 1); gtk_tree_model_get (GTK_TREE_MODEL (tt_d->list_store), &dest_iter, 1, &v1, -1); } @@ -119,15 +119,15 @@ select_as_pair_member (GtkTreeIter source_iter, gtk_list_store_append (tt_d->list_store, &dest_iter); gtk_list_store_set (tt_d->list_store, &dest_iter, - 0, v, - 1, NULL, - -1); + 0, v, + 1, NULL, + -1); } else { gtk_list_store_set (tt_d->list_store, &dest_iter, - 1, v, - -1); + 1, v, + -1); } } @@ -212,12 +212,12 @@ psppire_dialog_action_two_sample_activate (PsppireDialogAction *a, GVariant *par psppire_dialog_action_set_refresh (pda, refresh); g_object_set (pda->source, - "predicate", var_is_numeric, - NULL); + "predicate", var_is_numeric, + NULL); psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector), - select_as_pair_member, - act); + select_as_pair_member, + act); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-two-sample.h b/src/ui/gui/psppire-dialog-action-two-sample.h index c754e74e5a..ce46617f54 100644 --- a/src/ui/gui/psppire-dialog-action-two-sample.h +++ b/src/ui/gui/psppire-dialog-action-two-sample.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE (psppire_dialog_action_two_sample_get_type ()) -#define PSPPIRE_DIALOG_ACTION_TWO_SAMPLE(obj) \ +#define PSPPIRE_DIALOG_ACTION_TWO_SAMPLE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, PsppireDialogActionTwoSample)) + PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, PsppireDialogActionTwoSample)) #define PSPPIRE_DIALOG_ACTION_TWO_SAMPLE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, \ + PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, \ PsppireDialogActionTwoSampleClass)) #define PSPPIRE_IS_DIALOG_ACTION_TWO_SAMPLE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE)) #define PSPPIRE_IS_DIALOG_ACTION_TWO_SAMPLE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE)) #define PSPPIRE_DIALOG_ACTION_TWO_SAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, \ - PsppireDialogActionTwoSampleClass)) + PSPPIRE_TYPE_DIALOG_ACTION_TWO_SAMPLE, \ + PsppireDialogActionTwoSampleClass)) typedef struct _PsppireDialogActionTwoSample PsppireDialogActionTwoSample; typedef struct _PsppireDialogActionTwoSampleClass PsppireDialogActionTwoSampleClass; diff --git a/src/ui/gui/psppire-dialog-action-univariate.h b/src/ui/gui/psppire-dialog-action-univariate.h index be43ab3c6d..9e0a811fd9 100644 --- a/src/ui/gui/psppire-dialog-action-univariate.h +++ b/src/ui/gui/psppire-dialog-action-univariate.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE (psppire_dialog_action_univariate_get_type ()) -#define PSPPIRE_DIALOG_ACTION_UNIVARIATE(obj) \ +#define PSPPIRE_DIALOG_ACTION_UNIVARIATE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, PsppireDialogActionUnivariate)) + PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, PsppireDialogActionUnivariate)) #define PSPPIRE_DIALOG_ACTION_UNIVARIATE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, \ + PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, \ PsppireDialogActionUnivariateClass)) #define PSPPIRE_IS_DIALOG_ACTION_UNIVARIATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE)) #define PSPPIRE_IS_DIALOG_ACTION_UNIVARIATE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE)) #define PSPPIRE_DIALOG_ACTION_UNIVARIATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, \ - PsppireDialogActionUnivariateClass)) + PSPPIRE_TYPE_DIALOG_ACTION_UNIVARIATE, \ + PsppireDialogActionUnivariateClass)) typedef struct _PsppireDialogActionUnivariate PsppireDialogActionUnivariate; typedef struct _PsppireDialogActionUnivariateClass PsppireDialogActionUnivariateClass; diff --git a/src/ui/gui/psppire-dialog-action-var-info.c b/src/ui/gui/psppire-dialog-action-var-info.c index b4ee58125c..91d62494ea 100644 --- a/src/ui/gui/psppire-dialog-action-var-info.c +++ b/src/ui/gui/psppire-dialog-action-var-info.c @@ -116,7 +116,7 @@ populate_output (GtkTreeSelection *selection, gpointer data) struct variable **vars; g_object_get (treeview, "model", &dict, - NULL); + NULL); psppire_dict_view_get_selected_variables (PSPPIRE_DICT_VIEW (treeview), &vars, &n_vars); @@ -164,18 +164,18 @@ psppire_dialog_action_var_info_activate (PsppireDialogAction *a, GVariant *param pda->source = get_widget_assert (xml, "treeview2"); g_object_set (pda->source, - "selection-mode", GTK_SELECTION_MULTIPLE, - NULL); + "selection-mode", GTK_SELECTION_MULTIPLE, + NULL); g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pda->source)), - "changed", G_CALLBACK (populate_output), - act); + "changed", G_CALLBACK (populate_output), + act); g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to), - pda); + pda); psppire_dialog_action_set_valid_predicate (pda, - treeview_item_selected); + treeview_item_selected); return xml; } diff --git a/src/ui/gui/psppire-dialog-action-var-info.h b/src/ui/gui/psppire-dialog-action-var-info.h index ef72e7789a..495c0d2d56 100644 --- a/src/ui/gui/psppire-dialog-action-var-info.h +++ b/src/ui/gui/psppire-dialog-action-var-info.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO (psppire_dialog_action_var_info_get_type ()) -#define PSPPIRE_DIALOG_ACTION_VAR_INFO(obj) \ +#define PSPPIRE_DIALOG_ACTION_VAR_INFO(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, PsppireDialogActionVarInfo)) + PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, PsppireDialogActionVarInfo)) #define PSPPIRE_DIALOG_ACTION_VAR_INFO_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \ + PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \ PsppireDialogActionVarInfoClass)) #define PSPPIRE_IS_DIALOG_ACTION_VAR_INFO(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO)) #define PSPPIRE_IS_DIALOG_ACTION_VAR_INFO_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO)) #define PSPPIRE_DIALOG_ACTION_VAR_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \ - PsppireDialogActionVarInfoClass)) + PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \ + PsppireDialogActionVarInfoClass)) typedef struct _PsppireDialogActionVarInfo PsppireDialogActionVarInfo; typedef struct _PsppireDialogActionVarInfoClass PsppireDialogActionVarInfoClass; diff --git a/src/ui/gui/psppire-dialog-action-weight.c b/src/ui/gui/psppire-dialog-action-weight.c index a96acc9834..7903f9d90a 100644 --- a/src/ui/gui/psppire-dialog-action-weight.c +++ b/src/ui/gui/psppire-dialog-action-weight.c @@ -49,7 +49,7 @@ generate_syntax (const PsppireDialogAction *pda) syntax = g_strdup ("WEIGHT OFF.\n"); else syntax = g_strdup_printf ("WEIGHT BY %s.\n", - var_get_name (var)); + var_get_name (var)); return syntax; } @@ -77,7 +77,7 @@ refresh (PsppireDialogAction *pda) else { gchar *text = - g_strdup_printf (_("Weight cases by %s"), var_get_name (var)); + g_strdup_printf (_("Weight cases by %s"), var_get_name (var)); gtk_entry_set_text (GTK_ENTRY (wcd->entry), var_get_name (var)); gtk_label_set_text (GTK_LABEL (wcd->status), text); @@ -140,12 +140,12 @@ psppire_dialog_action_weight_activate (PsppireDialogAction *pda, GVariant *param g_signal_connect (act->off, "toggled", G_CALLBACK (on_toggle), act); g_object_set (pda->source, - "selection-mode", GTK_SELECTION_SINGLE, - "predicate", var_is_numeric, - NULL); + "selection-mode", GTK_SELECTION_SINGLE, + "predicate", var_is_numeric, + NULL); psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector), - is_currently_in_entry); + is_currently_in_entry); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); diff --git a/src/ui/gui/psppire-dialog-action-weight.h b/src/ui/gui/psppire-dialog-action-weight.h index 2487b0a188..d07cf1824c 100644 --- a/src/ui/gui/psppire-dialog-action-weight.h +++ b/src/ui/gui/psppire-dialog-action-weight.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT (psppire_dialog_action_weight_get_type ()) -#define PSPPIRE_DIALOG_ACTION_WEIGHT(obj) \ +#define PSPPIRE_DIALOG_ACTION_WEIGHT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, PsppireDialogActionWeight)) + PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, PsppireDialogActionWeight)) #define PSPPIRE_DIALOG_ACTION_WEIGHT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, \ + PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, \ PsppireDialogActionWeightClass)) #define PSPPIRE_IS_DIALOG_ACTION_WEIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT)) #define PSPPIRE_IS_DIALOG_ACTION_WEIGHT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT)) #define PSPPIRE_DIALOG_ACTION_WEIGHT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, \ - PsppireDialogActionWeightClass)) + PSPPIRE_TYPE_DIALOG_ACTION_WEIGHT, \ + PsppireDialogActionWeightClass)) typedef struct _PsppireDialogActionWeight PsppireDialogActionWeight; typedef struct _PsppireDialogActionWeightClass PsppireDialogActionWeightClass; diff --git a/src/ui/gui/psppire-dialog-action.c b/src/ui/gui/psppire-dialog-action.c index f0caabae72..416f1aa932 100644 --- a/src/ui/gui/psppire-dialog-action.c +++ b/src/ui/gui/psppire-dialog-action.c @@ -86,10 +86,10 @@ action_model_init (GActionInterface *iface) } G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PsppireDialogAction, \ - psppire_dialog_action, \ - G_TYPE_OBJECT, \ - G_IMPLEMENT_INTERFACE (G_TYPE_ACTION, \ - action_model_init)) + psppire_dialog_action, \ + G_TYPE_OBJECT, \ + G_IMPLEMENT_INTERFACE (G_TYPE_ACTION, \ + action_model_init)) /* Properties */ enum @@ -105,9 +105,9 @@ enum static void psppire_dialog_action_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireDialogAction *act = PSPPIRE_DIALOG_ACTION (object); @@ -115,8 +115,8 @@ psppire_dialog_action_set_property (GObject *object, { case PROP_TOPLEVEL: { - GObject *p = g_value_get_object (value); - act->toplevel = GTK_WIDGET (p); + GObject *p = g_value_get_object (value); + act->toplevel = GTK_WIDGET (p); } break; default: @@ -128,9 +128,9 @@ psppire_dialog_action_set_property (GObject *object, static void psppire_dialog_action_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireDialogAction *dialog_action = PSPPIRE_DIALOG_ACTION (object); @@ -207,10 +207,10 @@ psppire_dialog_action_activate (PsppireDialogAction *act, GVariant *parameter) GHashTable *thing = psppire_dialog_action_get_hash_table (act); GtkBuilder *xml = g_hash_table_lookup (thing, act); if (xml == NULL) - { - xml = class->initial_activate (act, parameter); - g_hash_table_insert (thing, act, xml); - } + { + xml = class->initial_activate (act, parameter); + g_hash_table_insert (thing, act, xml); + } } if (class->activate) @@ -218,11 +218,11 @@ psppire_dialog_action_activate (PsppireDialogAction *act, GVariant *parameter) GHashTable *thing = psppire_dialog_action_get_hash_table (act); GtkBuilder *xml = g_hash_table_lookup (thing, act); if (xml != NULL) - class->activate (act, parameter); + class->activate (act, parameter); } gtk_window_set_transient_for (GTK_WINDOW (act->dialog), - GTK_WINDOW (act->toplevel)); + GTK_WINDOW (act->toplevel)); if (act->source) { @@ -240,17 +240,17 @@ psppire_dialog_action_activate (PsppireDialogAction *act, GVariant *parameter) if (class->generate_syntax) { switch (response) - { - case GTK_RESPONSE_OK: - g_free (execute_syntax_string (PSPPIRE_DATA_WINDOW (act->toplevel), - class->generate_syntax (act))); - break; - case PSPPIRE_RESPONSE_PASTE: - g_free (paste_syntax_to_window (class->generate_syntax (act))); - break; - default: - break; - } + { + case GTK_RESPONSE_OK: + g_free (execute_syntax_string (PSPPIRE_DATA_WINDOW (act->toplevel), + class->generate_syntax (act))); + break; + case PSPPIRE_RESPONSE_PASTE: + g_free (paste_syntax_to_window (class->generate_syntax (act))); + break; + default: + break; + } } } @@ -263,10 +263,10 @@ psppire_dialog_action_class_init (PsppireDialogActionClass *class) GParamSpec *toplevel_spec = g_param_spec_object ("top-level", - "Top Level", - "The top level widget to which this dialog action belongs", - GTK_TYPE_WINDOW, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + "Top Level", + "The top level widget to which this dialog action belongs", + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); object_class->set_property = psppire_dialog_action_set_property; object_class->get_property = psppire_dialog_action_get_property; @@ -296,7 +296,7 @@ psppire_dialog_action_init (PsppireDialogAction *act) void psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act, - ContentsAreValid dialog_state_valid) + ContentsAreValid dialog_state_valid) { psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (act->dialog), dialog_state_valid, act); @@ -304,7 +304,7 @@ psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act, void psppire_dialog_action_set_refresh (PsppireDialogAction *pda, - PsppireDialogActionRefresh refresh) + PsppireDialogActionRefresh refresh) { g_signal_connect_swapped (pda->dialog, "refresh", G_CALLBACK (refresh), pda); } diff --git a/src/ui/gui/psppire-dialog-action.h b/src/ui/gui/psppire-dialog-action.h index 8f79acc4c0..480f940da3 100644 --- a/src/ui/gui/psppire-dialog-action.h +++ b/src/ui/gui/psppire-dialog-action.h @@ -41,25 +41,25 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_DIALOG_ACTION (psppire_dialog_action_get_type ()) -#define PSPPIRE_DIALOG_ACTION(obj) \ +#define PSPPIRE_DIALOG_ACTION(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION, PsppireDialogAction)) + PSPPIRE_TYPE_DIALOG_ACTION, PsppireDialogAction)) #define PSPPIRE_DIALOG_ACTION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_DIALOG_ACTION, \ + PSPPIRE_TYPE_DIALOG_ACTION, \ PsppireDialogActionClass)) #define PSPPIRE_IS_DIALOG_ACTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION)) #define PSPPIRE_IS_DIALOG_ACTION_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION)) #define PSPPIRE_DIALOG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_DIALOG_ACTION, \ - PsppireDialogActionClass)) + PSPPIRE_TYPE_DIALOG_ACTION, \ + PsppireDialogActionClass)) typedef struct _PsppireDialogAction PsppireDialogAction; typedef struct _PsppireDialogActionClass PsppireDialogActionClass; @@ -93,10 +93,10 @@ GType psppire_dialog_action_get_type (void) ; typedef void (*PsppireDialogActionRefresh) (PsppireDialogAction *) ; void psppire_dialog_action_set_refresh (PsppireDialogAction *pda, - PsppireDialogActionRefresh refresh); + PsppireDialogActionRefresh refresh); void psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act, - ContentsAreValid dialog_state_valid); + ContentsAreValid dialog_state_valid); GtkBuilder * psppire_dialog_action_get_xml (PsppireDialogAction *da); diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index d35fcd6021..e41879e362 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -67,9 +67,9 @@ enum static void psppire_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireDialog *dialog = PSPPIRE_DIALOG (object); @@ -89,9 +89,9 @@ psppire_dialog_get_property (GObject *object, static void psppire_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireDialog *dialog = PSPPIRE_DIALOG (object); @@ -122,17 +122,17 @@ psppire_dialog_class_init (PsppireDialogClass *class) 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_PARAM_READWRITE); + "Help Page", + "The section of the manual to load when the Help button is clicked", + NULL, + G_PARAM_READWRITE); sliding_spec = g_param_spec_boolean ("slidable", - "Slidable", - "Can the container be sized by the user", - FALSE, - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + "Slidable", + "Can the container be sized by the user", + FALSE, + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); object_class->set_property = psppire_dialog_set_property; object_class->get_property = psppire_dialog_get_property; @@ -148,49 +148,49 @@ psppire_dialog_class_init (PsppireDialogClass *class) signals [DIALOG_REFRESH] = g_signal_new ("refresh", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); signals [RESPONSE] = g_signal_new ("response", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); signals [VALIDITY_CHANGED] = g_signal_new ("validity-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, + G_TYPE_BOOLEAN); signals [DIALOG_HELP] = g_signal_new ("help", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); parent_class = g_type_class_peek_parent (class); } @@ -228,14 +228,14 @@ psppire_dialog_init (PsppireDialog *dialog) dialog->help_page = NULL; gtk_window_set_type_hint (GTK_WINDOW (dialog), - GDK_WINDOW_TYPE_HINT_DIALOG); + GDK_WINDOW_TYPE_HINT_DIALOG); g_signal_connect (dialog, "delete-event", - G_CALLBACK (delete_event_callback), - dialog); + G_CALLBACK (delete_event_callback), + dialog); gtk_window_set_type_hint (GTK_WINDOW (dialog), - GDK_WINDOW_TYPE_HINT_DIALOG); + GDK_WINDOW_TYPE_HINT_DIALOG); g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL); } @@ -246,7 +246,7 @@ psppire_dialog_new (void) PsppireDialog *dialog ; dialog = g_object_new (psppire_dialog_get_type (), - NULL); + NULL); return GTK_WIDGET (dialog) ; } @@ -277,8 +277,8 @@ connect_notify_signal (GtkWidget *w, gpointer data) if (GTK_IS_CONTAINER (w)) { gtk_container_foreach (GTK_CONTAINER (w), - connect_notify_signal, - dialog); + connect_notify_signal, + dialog); } /* It's unfortunate that GTK+ doesn't have a generic @@ -288,26 +288,26 @@ connect_notify_signal (GtkWidget *w, gpointer data) if (GTK_IS_DRAWING_AREA (w)) { g_signal_connect_swapped (w, "draw", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); } if (GTK_IS_TOGGLE_BUTTON (w)) { g_signal_connect_swapped (w, "toggled", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); } if (PSPPIRE_IS_SELECTOR (w)) { g_signal_connect_swapped (w, "selected", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); g_signal_connect_swapped (w, "de-selected", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); psppire_selector_update_subjects (PSPPIRE_SELECTOR (w)); } @@ -315,15 +315,15 @@ connect_notify_signal (GtkWidget *w, gpointer data) if (GTK_IS_EDITABLE (w)) { g_signal_connect_swapped (w, "changed", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); } if (GTK_IS_CELL_EDITABLE (w)) { g_signal_connect_swapped (w, "editing-done", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); } if (GTK_IS_TEXT_VIEW (w)) @@ -331,8 +331,8 @@ connect_notify_signal (GtkWidget *w, gpointer data) GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w)); g_signal_connect_swapped (buffer, "changed", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); } if (GTK_IS_TREE_VIEW (w)) @@ -340,43 +340,43 @@ connect_notify_signal (GtkWidget *w, gpointer data) gint i = 0; GtkTreeView *tv = GTK_TREE_VIEW (w); GtkTreeSelection *selection = - gtk_tree_view_get_selection (tv); + gtk_tree_view_get_selection (tv); GtkTreeViewColumn *col; GtkTreeModel *model = gtk_tree_view_get_model (tv); if (model) - { - g_signal_connect_swapped (model, "row-changed", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + { + g_signal_connect_swapped (model, "row-changed", + G_CALLBACK (psppire_dialog_notify_change), + dialog); - g_signal_connect_swapped (model, "row-deleted", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + g_signal_connect_swapped (model, "row-deleted", + G_CALLBACK (psppire_dialog_notify_change), + dialog); - g_signal_connect_swapped (model, "row-inserted", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + g_signal_connect_swapped (model, "row-inserted", + G_CALLBACK (psppire_dialog_notify_change), + dialog); - } + } g_signal_connect_swapped (selection, "changed", - G_CALLBACK (psppire_dialog_notify_change), - dialog); + G_CALLBACK (psppire_dialog_notify_change), + dialog); while ((col = gtk_tree_view_get_column (tv, i++))) - { - GList *renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); - GList *start = renderers; - while (renderers) - { - if (GTK_IS_CELL_RENDERER_TOGGLE (renderers->data)) - g_signal_connect_swapped (renderers->data, "toggled", - G_CALLBACK (psppire_dialog_notify_change), dialog); - renderers = renderers->next; - } - g_list_free (start); - } + { + GList *renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); + GList *start = renderers; + while (renderers) + { + if (GTK_IS_CELL_RENDERER_TOGGLE (renderers->data)) + g_signal_connect_swapped (renderers->data, "toggled", + G_CALLBACK (psppire_dialog_notify_change), dialog); + renderers = renderers->next; + } + g_list_free (start); + } } } @@ -392,8 +392,8 @@ psppire_dialog_run (PsppireDialog *dialog) if (dialog->contents_are_valid != NULL) gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child(GTK_BIN(dialog))), - connect_notify_signal, - dialog); + connect_notify_signal, + dialog); dialog->loop = g_main_loop_new (NULL, FALSE); @@ -437,8 +437,8 @@ psppire_dialog_help (PsppireDialog *dialog) disabled. */ void psppire_dialog_set_valid_predicate (PsppireDialog *dialog, - ContentsAreValid contents_are_valid, - gpointer data) + ContentsAreValid contents_are_valid, + gpointer data) { dialog->contents_are_valid = contents_are_valid; dialog->validity_data = data; diff --git a/src/ui/gui/psppire-dialog.h b/src/ui/gui/psppire-dialog.h index 2c353b3d99..f93cce0ee0 100644 --- a/src/ui/gui/psppire-dialog.h +++ b/src/ui/gui/psppire-dialog.h @@ -70,8 +70,8 @@ void psppire_dialog_help (PsppireDialog *); void psppire_dialog_close (PsppireDialog *); gint psppire_dialog_run (PsppireDialog *); void psppire_dialog_set_valid_predicate (PsppireDialog *, - ContentsAreValid, - gpointer); + ContentsAreValid, + gpointer); void psppire_dialog_set_accept_predicate (PsppireDialog *, ContentsAreValid, gpointer); diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index dbad71aa16..e5506acac6 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -64,7 +64,7 @@ enum { /* --- prototypes --- */ -static void psppire_dict_dispose (GObject *object); +static void psppire_dict_dispose (GObject *object); static void dictionary_tree_model_init (GtkTreeModelIface *iface); @@ -103,21 +103,21 @@ gi (GListModel *list, guint id) gtk_widget_set_tooltip_text (button, var_get_label (v)); { - PangoContext *context = gtk_widget_create_pango_context (button); - PangoLayout *layout = pango_layout_new (context); - PangoRectangle rect; + PangoContext *context = gtk_widget_create_pango_context (button); + PangoLayout *layout = pango_layout_new (context); + PangoRectangle rect; - pango_layout_set_text (layout, "M", 1); + pango_layout_set_text (layout, "M", 1); - pango_layout_get_extents (layout, NULL, &rect); + pango_layout_get_extents (layout, NULL, &rect); - g_object_unref (G_OBJECT (layout)); - g_object_unref (G_OBJECT (context)); + g_object_unref (G_OBJECT (layout)); + g_object_unref (G_OBJECT (context)); - gtk_widget_set_size_request (button, - (0.25 + var_get_display_width (v)) - * rect.width / PANGO_SCALE, - -1); + gtk_widget_set_size_request (button, + (0.25 + var_get_display_width (v)) + * rect.width / PANGO_SCALE, + -1); } } @@ -142,10 +142,10 @@ static guint signals [n_SIGNALS]; /* --- functions --- */ G_DEFINE_TYPE_WITH_CODE (PsppireDict, psppire_dict, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - dictionary_tree_model_init) - G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, - ssw_init_iface)) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + dictionary_tree_model_init) + G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, + ssw_init_iface)) static void psppire_dict_class_init (PsppireDictClass *class) @@ -158,95 +158,95 @@ psppire_dict_class_init (PsppireDictClass *class) signals [RESIZE_ITEM] = g_signal_new ("resize-item", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - psppire_marshal_BOOLEAN__INT_INT, - G_TYPE_BOOLEAN, - 2, - G_TYPE_INT, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + psppire_marshal_BOOLEAN__INT_INT, + G_TYPE_BOOLEAN, + 2, + G_TYPE_INT, + G_TYPE_INT); signals [VARIABLE_CHANGED] = g_signal_new ("variable-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__INT_UINT_POINTER, - G_TYPE_NONE, - 3, - G_TYPE_INT, - G_TYPE_UINT, - G_TYPE_POINTER); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + psppire_marshal_VOID__INT_UINT_POINTER, + G_TYPE_NONE, + 3, + G_TYPE_INT, + G_TYPE_UINT, + G_TYPE_POINTER); signals [VARIABLE_INSERTED] = g_signal_new ("variable-inserted", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); signals [VARIABLES_DELETED] = g_signal_new ("variables-deleted", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__INT_UINT, - G_TYPE_NONE, - 2, - G_TYPE_INT, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + psppire_marshal_VOID__INT_UINT, + G_TYPE_NONE, + 2, + G_TYPE_INT, G_TYPE_UINT); signals [VARIABLE_MOVED] = g_signal_new ("variable-moved", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__INT_INT, - G_TYPE_NONE, - 2, - G_TYPE_INT, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + psppire_marshal_VOID__INT_INT, + G_TYPE_NONE, + 2, + G_TYPE_INT, G_TYPE_INT); signals [WEIGHT_CHANGED] = g_signal_new ("weight-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); signals [FILTER_CHANGED] = g_signal_new ("filter-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, - G_TYPE_INT); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); signals [SPLIT_CHANGED] = g_signal_new ("split-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); } static void @@ -559,7 +559,7 @@ psppire_dict_clear (PsppireDict *d) */ gboolean psppire_dict_check_name (const PsppireDict *dict, - const gchar *name) + const gchar *name) { return (dict_id_is_valid (dict->dict, name, DC_ORDINARY) && !psppire_dict_lookup_var (dict, name)); @@ -574,32 +574,32 @@ static gint tree_model_n_columns (GtkTreeModel *model); static GType tree_model_column_type (GtkTreeModel *model, gint index); static gboolean tree_model_get_iter (GtkTreeModel *model, GtkTreeIter *iter, - GtkTreePath *path); + GtkTreePath *path); static gboolean tree_model_iter_next (GtkTreeModel *model, GtkTreeIter *iter); static GtkTreePath * tree_model_get_path (GtkTreeModel *model, - GtkTreeIter *iter); + GtkTreeIter *iter); static void tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, - gint column, GValue *value); + gint column, GValue *value); static gboolean tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter, - GtkTreeIter *parent, gint n); + GtkTreeIter *parent, gint n); static gint tree_model_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter); + GtkTreeIter *iter); static gboolean tree_model_iter_children (GtkTreeModel *, - GtkTreeIter *, - GtkTreeIter *); + GtkTreeIter *, + GtkTreeIter *); static gboolean tree_model_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child); + GtkTreeIter *iter, + GtkTreeIter *child); static gboolean tree_model_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter); + GtkTreeIter *iter); static void dictionary_tree_model_init (GtkTreeModelIface *iface) @@ -621,15 +621,15 @@ dictionary_tree_model_init (GtkTreeModelIface *iface) static gboolean tree_model_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { return FALSE; } static gboolean tree_model_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) + GtkTreeIter *iter, + GtkTreeIter *child) { return TRUE; } @@ -773,7 +773,7 @@ struct fmt_spec var_get_write_format (const struct variable *); static void tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, - gint column, GValue *value) + gint column, GValue *value) { struct variable *var; PsppireDict *dict = PSPPIRE_DICT (model); @@ -831,15 +831,15 @@ tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, static gboolean tree_model_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent) + GtkTreeIter *iter, + GtkTreeIter *parent) { return FALSE; } static gint tree_model_n_children (GtkTreeModel *model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireDict *dict = PSPPIRE_DICT (model); @@ -851,7 +851,7 @@ tree_model_n_children (GtkTreeModel *model, static gboolean tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter, - GtkTreeIter *parent, gint n) + GtkTreeIter *parent, gint n) { PsppireDict *dict; @@ -877,7 +877,7 @@ tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter, gboolean psppire_dict_rename_var (PsppireDict *dict, struct variable *v, - const gchar *name) + const gchar *name) { if (! dict_id_is_valid (dict->dict, name, DC_ORDINARY)) return FALSE; diff --git a/src/ui/gui/psppire-dict.h b/src/ui/gui/psppire-dict.h index 9d593a913f..836e24c54b 100644 --- a/src/ui/gui/psppire-dict.h +++ b/src/ui/gui/psppire-dict.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS /* --- typedefs & structures --- */ -typedef struct _PsppireDict PsppireDict; +typedef struct _PsppireDict PsppireDict; typedef struct _PsppireDictClass PsppireDictClass; enum {DICT_TVM_COL_NAME=0, @@ -109,7 +109,7 @@ gboolean psppire_dict_check_name (const PsppireDict *, const gchar *name); bool psppire_dict_generate_name (const PsppireDict *, char *name, size_t size); gboolean psppire_dict_rename_var (PsppireDict *dict, struct variable *v, - const gchar *text); + const gchar *text); void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *); diff --git a/src/ui/gui/psppire-dictview.c b/src/ui/gui/psppire-dictview.c index ae429ca1af..ff8af1b146 100644 --- a/src/ui/gui/psppire-dictview.c +++ b/src/ui/gui/psppire-dictview.c @@ -153,7 +153,7 @@ default_sort (GtkTreeModel *model, { int what = -1; psppire_conf_get_enum (psppire_conf_new (), "VariableLists", "sort-order", - PSPP_TYPE_OPTIONS_VAR_ORDER, &what); + PSPP_TYPE_OPTIONS_VAR_ORDER, &what); switch (what) { @@ -185,16 +185,16 @@ set_model (PsppireDictView *dict_view) 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_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); + GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); if (dict_view->predicate) { - model = gtk_tree_model_filter_new (dict_view->sorted_model, NULL); + model = gtk_tree_model_filter_new (dict_view->sorted_model, NULL); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model), - filter_variables, - dict_view->predicate, - NULL); + filter_variables, + dict_view->predicate, + NULL); } else { @@ -208,9 +208,9 @@ set_model (PsppireDictView *dict_view) static void psppire_dict_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object); @@ -224,12 +224,12 @@ psppire_dict_view_set_property (GObject *object, break; case PROP_SELECTION_MODE: { - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view)); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view)); - GtkSelectionMode mode = g_value_get_enum (value); + GtkSelectionMode mode = g_value_get_enum (value); - gtk_tree_selection_set_mode (selection, mode); + gtk_tree_selection_set_mode (selection, mode); } break; default: @@ -244,9 +244,9 @@ psppire_dict_view_set_property (GObject *object, static void psppire_dict_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object); @@ -260,10 +260,10 @@ psppire_dict_view_get_property (GObject *object, break; case PROP_SELECTION_MODE: { - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view)); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view)); - g_value_set_enum (value, gtk_tree_selection_get_mode (selection)); + g_value_set_enum (value, gtk_tree_selection_get_mode (selection)); } break; default: @@ -283,25 +283,25 @@ psppire_dict_view_class_init (PsppireDictViewClass *class) GParamSpec *predicate_spec = g_param_spec_pointer ("predicate", - "Predicate", - "A predicate function", - G_PARAM_READABLE | G_PARAM_WRITABLE); + "Predicate", + "A predicate function", + G_PARAM_READABLE | G_PARAM_WRITABLE); GParamSpec *selection_mode_spec = g_param_spec_enum ("selection-mode", - "Selection Mode", - "How many things can be selected", - GTK_TYPE_SELECTION_MODE, - GTK_SELECTION_MULTIPLE, - G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE); + "Selection Mode", + "How many things can be selected", + GTK_TYPE_SELECTION_MODE, + GTK_SELECTION_MULTIPLE, + G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE); object_class->set_property = psppire_dict_view_set_property; object_class->get_property = psppire_dict_view_get_property; g_object_class_override_property (object_class, - PROP_DICTIONARY, - "model"); + PROP_DICTIONARY, + "model"); g_object_class_install_property (object_class, PROP_PREDICATE, @@ -318,15 +318,15 @@ use_labels (PsppireDictView *dv) gboolean disp_labels = TRUE; if (gtk_check_menu_item_get_inconsistent (GTK_CHECK_MENU_ITEM - (dv->override_button))) + (dv->override_button))) { psppire_conf_get_boolean (psppire_conf_new (), - "VariableLists", "display-labels", &disp_labels); + "VariableLists", "display-labels", &disp_labels); } else { disp_labels = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM - (dv->override_button)); + (dv->override_button)); } return disp_labels; } @@ -336,10 +336,10 @@ use_labels (PsppireDictView *dv) variable */ static void var_description_cell_data_func (GtkTreeViewColumn *col, - GtkCellRenderer *cell, - GtkTreeModel *top_model, - GtkTreeIter *top_iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *top_model, + GtkTreeIter *top_iter, + gpointer data) { PsppireDictView *dv = PSPPIRE_DICT_VIEW (data); struct variable *var; @@ -349,13 +349,13 @@ var_description_cell_data_func (GtkTreeViewColumn *col, get_base_model (top_model, top_iter, &model, &iter); gtk_tree_model_get (model, - &iter, DICT_TVM_COL_VAR, &var, -1); + &iter, DICT_TVM_COL_VAR, &var, -1); if (var_has_label (var) && use_labels (dv)) { gchar *text = g_markup_printf_escaped ( - "%s", - var_get_label (var)); + "%s", + var_get_label (var)); g_object_set (cell, "markup", text, NULL); g_free (text); @@ -374,19 +374,19 @@ var_description_cell_data_func (GtkTreeViewColumn *col, of variable */ static void var_icon_cell_data_func (GtkTreeViewColumn *col, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer data) { struct variable *var; gtk_tree_model_get (model, iter, DICT_TVM_COL_VAR, &var, -1); g_object_set (cell, - "stock-size", GTK_ICON_SIZE_MENU, - "icon-name", get_var_measurement_stock_id (var_get_print_format (var).type, - var_get_measure (var)), + "stock-size", GTK_ICON_SIZE_MENU, + "icon-name", get_var_measurement_stock_id (var_get_print_format (var).type, + var_get_measure (var)), NULL); var_unref (var); @@ -399,13 +399,13 @@ get_var_measurement_stock_id (enum fmt_type type, enum measure measure) { case FMT_CAT_STRING: switch (measure) - { - case MEASURE_UNKNOWN: return "role-none"; - case MEASURE_NOMINAL: return "measure-string-nominal"; - case MEASURE_ORDINAL: return "measure-string-ordinal"; - case MEASURE_SCALE: return "role-none"; + { + case MEASURE_UNKNOWN: return "role-none"; + case MEASURE_NOMINAL: return "measure-string-nominal"; + case MEASURE_ORDINAL: return "measure-string-ordinal"; + case MEASURE_SCALE: return "role-none"; case n_MEASURES: break; - } + } break; case FMT_CAT_DATE: @@ -428,7 +428,7 @@ get_var_measurement_stock_id (enum fmt_type type, enum measure measure) case MEASURE_ORDINAL: return "measure-ordinal"; case MEASURE_SCALE: return "measure-scale"; case n_MEASURES: break; - } + } break; } @@ -440,11 +440,11 @@ get_var_measurement_stock_id (enum fmt_type type, enum measure measure) /* Sets the tooltip to be the name of the variable under the cursor */ static gboolean set_tooltip_for_variable (GtkTreeView *treeview, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip, - gpointer user_data) + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) { gint bx, by; GtkTreeIter iter; @@ -511,7 +511,7 @@ psppire_dict_view_iter_to_var (PsppireDictView *dict_view, g_assert (PSPPIRE_IS_DICT (model)); gtk_tree_model_get (model, - &iter, DICT_TVM_COL_VAR, &var, -1); + &iter, DICT_TVM_COL_VAR, &var, -1); return var; } @@ -552,7 +552,7 @@ toggle_label_preference (GtkCheckMenuItem *checkbox, gpointer data) gboolean global_setting = TRUE; psppire_conf_get_boolean (psppire_conf_new (), - "VariableLists", "display-labels", &global_setting); + "VariableLists", "display-labels", &global_setting); if (gtk_check_menu_item_get_inconsistent (checkbox)) gtk_check_menu_item_set_active (checkbox, !global_setting); @@ -672,14 +672,14 @@ psppire_dict_view_init (PsppireDictView *dict_view) gtk_tree_view_column_pack_start (col, renderer, FALSE); gtk_tree_view_column_set_cell_data_func (col, renderer, - var_icon_cell_data_func, - NULL, NULL); + var_icon_cell_data_func, + NULL, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (col, renderer, - var_description_cell_data_func, - dict_view, NULL); + var_description_cell_data_func, + dict_view, NULL); g_object_set (renderer, "ellipsize-set", TRUE, NULL); g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL); @@ -692,12 +692,12 @@ psppire_dict_view_init (PsppireDictView *dict_view) gtk_tree_view_append_column (GTK_TREE_VIEW (dict_view), col); g_object_set (dict_view, - "has-tooltip", TRUE, - "headers-visible", FALSE, - NULL); + "has-tooltip", TRUE, + "headers-visible", FALSE, + NULL); g_signal_connect (dict_view, "query-tooltip", - G_CALLBACK (set_tooltip_for_variable), NULL); + G_CALLBACK (set_tooltip_for_variable), NULL); dict_view->menu = gtk_menu_new (); @@ -708,10 +708,10 @@ psppire_dict_view_init (PsppireDictView *dict_view) dict_view->override_button = item; gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (item), - TRUE); + TRUE); g_signal_connect (item, "toggled", - G_CALLBACK (toggle_label_preference), dict_view); + G_CALLBACK (toggle_label_preference), dict_view); gtk_menu_shell_append (GTK_MENU_SHELL (dict_view->menu), item); @@ -751,7 +751,7 @@ psppire_dict_view_init (PsppireDictView *dict_view) gtk_widget_show_all (dict_view->menu); g_signal_connect (dict_view, "button-press-event", - G_CALLBACK (show_menu), NULL); + G_CALLBACK (show_menu), NULL); } struct get_vars_aux diff --git a/src/ui/gui/psppire-import-assistant.c b/src/ui/gui/psppire-import-assistant.c index 472db49d6d..a812f8490c 100644 --- a/src/ui/gui/psppire-import-assistant.c +++ b/src/ui/gui/psppire-import-assistant.c @@ -65,9 +65,9 @@ enum static void psppire_import_assistant_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { // PsppireImportAssistant *act = PSPPIRE_IMPORT_ASSISTANT (object); @@ -82,9 +82,9 @@ psppire_import_assistant_set_property (GObject *object, static void psppire_import_assistant_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { // PsppireImportAssistant *assistant = PSPPIRE_IMPORT_ASSISTANT (object); @@ -256,23 +256,23 @@ on_chosen (PsppireImportAssistant *ia, GtkWidget *page) gtk_assistant_set_page_complete (GTK_ASSISTANT(ia), GTK_WIDGET (fc), TRUE); if (ia->spreadsheet) - spreadsheet_unref (ia->spreadsheet); + spreadsheet_unref (ia->spreadsheet); ia->spreadsheet = gnumeric_probe (f, FALSE); if (!ia->spreadsheet) - ia->spreadsheet = ods_probe (f, FALSE); + ia->spreadsheet = ods_probe (f, FALSE); if (ia->spreadsheet) - { - sheet_spec_page_create (ia); - } + { + sheet_spec_page_create (ia); + } else - { - intro_page_create (ia); - first_line_page_create (ia); - separators_page_create (ia); - } + { + intro_page_create (ia); + first_line_page_create (ia); + separators_page_create (ia); + } formats_page_create (ia); } @@ -326,7 +326,7 @@ chooser_page_leave (PsppireImportAssistant *ia, GtkWidget *page, enum IMPORT_ASS gchar *encoding = psppire_encoding_selector_get_encoding (ia->encoding_selector); ia->text_file = psppire_text_file_new (ia->file_name, encoding); gtk_tree_view_set_model (GTK_TREE_VIEW (ia->first_line_tree_view), - GTK_TREE_MODEL (ia->text_file)); + GTK_TREE_MODEL (ia->text_file)); g_free (encoding); } @@ -419,7 +419,7 @@ chooser_page_create (PsppireImportAssistant *ia) gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (chooser), ia->encoding_selector); add_page_to_assistant (ia, chooser, - GTK_ASSISTANT_PAGE_INTRO, _("Select File to Import")); + GTK_ASSISTANT_PAGE_INTRO, _("Select File to Import")); g_signal_connect_swapped (chooser, "selection-changed", G_CALLBACK (on_chosen), ia); g_signal_connect_swapped (chooser, "map", G_CALLBACK (on_map), ia); @@ -476,7 +476,7 @@ psppire_import_assistant_init (PsppireImportAssistant *ia) that represents the page. */ GtkWidget * add_page_to_assistant (PsppireImportAssistant *ia, - GtkWidget *page, GtkAssistantPageType type, const gchar *title) + GtkWidget *page, GtkAssistantPageType type, const gchar *title) { GtkWidget *content = page; @@ -493,12 +493,12 @@ GtkWidget * psppire_import_assistant_new (GtkWindow *toplevel) { return GTK_WIDGET (g_object_new (PSPPIRE_TYPE_IMPORT_ASSISTANT, - /* Some window managers (notably ratpoison) - ignore the maximise command when a window is - transient. This causes problems for this - window. */ - /* "transient-for", toplevel, */ - NULL)); + /* Some window managers (notably ratpoison) + ignore the maximise command when a window is + transient. This causes problems for this + window. */ + /* "transient-for", toplevel, */ + NULL)); } @@ -520,10 +520,10 @@ prepare_formats_page (PsppireImportAssistant *ia) /* Show half-half the data sheet and the variable sheet. */ gint pmax; g_object_get (get_widget_assert (ia->text_builder, "vpaned1"), - "max-position", &pmax, NULL); + "max-position", &pmax, NULL); g_object_set (get_widget_assert (ia->text_builder, "vpaned1"), - "position", pmax / 2, NULL); + "position", pmax / 2, NULL); gtk_widget_show (ia->paste_button); } @@ -541,7 +541,7 @@ formats_page_create (PsppireImportAssistant *ia) ia->var_sheet = get_widget_assert (builder, "variable-sheet"); add_page_to_assistant (ia, w, - GTK_ASSISTANT_PAGE_CONFIRM, _("Adjust Variable Formats")); + GTK_ASSISTANT_PAGE_CONFIRM, _("Adjust Variable Formats")); } @@ -565,25 +565,25 @@ sheet_spec_gen_syntax (PsppireImportAssistant *ia, struct string *s) else g_object_get (ia->text_file, "file-name", &filename, NULL); syntax_gen_pspp (s, - "GET DATA" - "\n /TYPE=%ss" - "\n /FILE=%sq" - "\n /SHEET=index %d" - "\n /READNAMES=%ss", - ia->spreadsheet->type, - filename, - sheet_index, - read_names ? "ON" : "OFF"); + "GET DATA" + "\n /TYPE=%ss" + "\n /FILE=%sq" + "\n /SHEET=index %d" + "\n /READNAMES=%ss", + ia->spreadsheet->type, + filename, + sheet_index, + read_names ? "ON" : "OFF"); if (range && 0 != strcmp ("", range)) { syntax_gen_pspp (s, - "\n /CELLRANGE=RANGE %sq", range); + "\n /CELLRANGE=RANGE %sq", range); } else { syntax_gen_pspp (s, - "\n /CELLRANGE=FULL"); + "\n /CELLRANGE=FULL"); } diff --git a/src/ui/gui/psppire-import-assistant.h b/src/ui/gui/psppire-import-assistant.h index deec75c878..7f3c4f19ea 100644 --- a/src/ui/gui/psppire-import-assistant.h +++ b/src/ui/gui/psppire-import-assistant.h @@ -37,25 +37,25 @@ struct spreadsheet; #define PSPPIRE_TYPE_IMPORT_ASSISTANT (psppire_import_assistant_get_type ()) -#define PSPPIRE_IMPORT_ASSISTANT(obj) \ +#define PSPPIRE_IMPORT_ASSISTANT(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_IMPORT_ASSISTANT, PsppireImportAssistant)) + PSPPIRE_TYPE_IMPORT_ASSISTANT, PsppireImportAssistant)) #define PSPPIRE_IMPORT_ASSISTANT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_IMPORT_ASSISTANT, \ + PSPPIRE_TYPE_IMPORT_ASSISTANT, \ PsppireImportAssistantClass)) #define PSPPIRE_IS_IMPORT_ASSISTANT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_IMPORT_ASSISTANT)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_IMPORT_ASSISTANT)) #define PSPPIRE_IS_IMPORT_ASSISTANT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_IMPORT_ASSISTANT)) #define PSPPIRE_IMPORT_ASSISTANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_IMPORT_ASSISTANT, \ - PsppireImportAssistantClass)) + PSPPIRE_TYPE_IMPORT_ASSISTANT, \ + PsppireImportAssistantClass)) typedef struct _PsppireImportAssistant PsppireImportAssistant; typedef struct _PsppireImportAssistantClass PsppireImportAssistantClass; diff --git a/src/ui/gui/psppire-import-spreadsheet.c b/src/ui/gui/psppire-import-spreadsheet.c index 7d3db81081..a000c1aa88 100644 --- a/src/ui/gui/psppire-import-spreadsheet.c +++ b/src/ui/gui/psppire-import-spreadsheet.c @@ -350,7 +350,7 @@ sheet_spec_page_create (PsppireImportAssistant *ia) ia->preview_sheet = get_widget_assert (builder, "preview-sheet"); g_signal_connect (ia->preview_sheet, "selection-changed", - G_CALLBACK (on_preview_selection_changed), ia); + G_CALLBACK (on_preview_selection_changed), ia); gtk_widget_show (ia->preview_sheet); @@ -360,8 +360,8 @@ sheet_spec_page_create (PsppireImportAssistant *ia) gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box)); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "text", 0, - NULL); + "text", 0, + NULL); g_signal_connect (combo_box, "changed", G_CALLBACK (on_sheet_combo_changed), ia); } @@ -382,7 +382,7 @@ sheet_spec_page_create (PsppireImportAssistant *ia) add_page_to_assistant (ia, page, - GTK_ASSISTANT_PAGE_CONTENT, _("Importing Spreadsheet Data")); + GTK_ASSISTANT_PAGE_CONTENT, _("Importing Spreadsheet Data")); g_object_set_data (G_OBJECT (page), "on-entering", prepare_sheet_spec_page); g_object_set_data (G_OBJECT (page), "on-reset", reset_page); diff --git a/src/ui/gui/psppire-import-textfile.c b/src/ui/gui/psppire-import-textfile.c index 167c04ccea..237b240e41 100644 --- a/src/ui/gui/psppire-import-textfile.c +++ b/src/ui/gui/psppire-import-textfile.c @@ -77,9 +77,9 @@ revise_fields_preview (PsppireImportAssistant *ia) const struct separator *s = &separators[i]; GtkWidget *button = get_widget_assert (ia->text_builder, s->name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - { - delimiters = g_slist_prepend (delimiters, GINT_TO_POINTER (s->c)); - } + { + delimiters = g_slist_prepend (delimiters, GINT_TO_POINTER (s->c)); + } } g_object_set (ia->delimiters_model, @@ -114,28 +114,28 @@ repopulate_delimiter_columns (PsppireImportAssistant *ia) const gchar *title = NULL; if (f == 0) - title = _("line"); + title = _("line"); else - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->variable_names_cb))) - { - title = - psppire_delimited_text_get_header_title - (PSPPIRE_DELIMITED_TEXT (ia->delimiters_model), f - 1); - } - if (title == NULL) - title = _("var"); - } + { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->variable_names_cb))) + { + title = + psppire_delimited_text_get_header_title + (PSPPIRE_DELIMITED_TEXT (ia->delimiters_model), f - 1); + } + if (title == NULL) + title = _("var"); + } GtkTreeViewColumn *column = - gtk_tree_view_column_new_with_attributes (title, - renderer, - "text", f, - NULL); + gtk_tree_view_column_new_with_attributes (title, + renderer, + "text", f, + NULL); g_object_set (column, - "resizable", TRUE, - "sizing", GTK_TREE_VIEW_COLUMN_AUTOSIZE, - NULL); + "resizable", TRUE, + "sizing", GTK_TREE_VIEW_COLUMN_AUTOSIZE, + NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (ia->fields_tree_view), column); } @@ -177,10 +177,10 @@ static void on_intro_amount_changed (PsppireImportAssistant *ia) { gtk_widget_set_sensitive (ia->n_cases_spin, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->n_cases_button))); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->n_cases_button))); gtk_widget_set_sensitive (ia->percent_spin, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->percent_button))); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->percent_button))); } static void @@ -200,19 +200,19 @@ on_treeview_selection_change (PsppireImportAssistant *ia) gtk_tree_path_free (path); g_object_get (model, "maximum-lines", &max_lines, NULL); gtk_widget_set_sensitive (ia->variable_names_cb, - (n > 0 && n < max_lines)); + (n > 0 && n < max_lines)); ia->delimiters_model = - psppire_delimited_text_new (GTK_TREE_MODEL (ia->text_file)); + psppire_delimited_text_new (GTK_TREE_MODEL (ia->text_file)); g_object_set (ia->delimiters_model, "first-line", n, NULL); } } static void render_text_preview_line (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) { /* Set the text to a "insensitive" state if the row @@ -248,7 +248,7 @@ first_line_page_create (PsppireImportAssistant *ia) g_object_set_data (G_OBJECT (w), "on-reset", reset_first_line_page); add_page_to_assistant (ia, w, - GTK_ASSISTANT_PAGE_CONTENT, _("Select the First Line")); + GTK_ASSISTANT_PAGE_CONTENT, _("Select the First Line")); GtkWidget *scrolled_window = get_widget_assert (ia->text_builder, "first-line-scroller"); @@ -261,8 +261,8 @@ first_line_page_create (PsppireImportAssistant *ia) GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (_("Line"), renderer, - "text", 0, - NULL); + "text", 0, + NULL); gtk_tree_view_column_set_cell_data_func (column, renderer, render_text_preview_line, ia, 0); gtk_tree_view_append_column (GTK_TREE_VIEW (ia->first_line_tree_view), column); @@ -274,7 +274,7 @@ first_line_page_create (PsppireImportAssistant *ia) gtk_tree_view_append_column (GTK_TREE_VIEW (ia->first_line_tree_view), column); g_signal_connect_swapped (ia->first_line_tree_view, "cursor-changed", - G_CALLBACK (on_treeview_selection_change), ia); + G_CALLBACK (on_treeview_selection_change), ia); gtk_container_add (GTK_CONTAINER (scrolled_window), ia->first_line_tree_view); } @@ -327,30 +327,30 @@ intro_on_enter (PsppireImportAssistant *ia, GtkWidget *page, enum IMPORT_ASSISTA if (ia->text_file) { if (ia->text_file->total_is_exact) - { - ds_put_format ( - &s, ngettext ("The selected file contains %'lu line of text. ", - "The selected file contains %'lu lines of text. ", - ia->text_file->total_lines), - ia->text_file->total_lines); - } + { + ds_put_format ( + &s, ngettext ("The selected file contains %'lu line of text. ", + "The selected file contains %'lu lines of text. ", + ia->text_file->total_lines), + ia->text_file->total_lines); + } else if (ia->text_file->total_lines > 0) - { - ds_put_format ( - &s, ngettext ( - "The selected file contains approximately %'lu line of text. ", - "The selected file contains approximately %'lu lines of text. ", - ia->text_file->total_lines), - ia->text_file->total_lines); - ds_put_format ( - &s, ngettext ( - "Only the first %zu line of the file will be shown for " - "preview purposes in the following screens. ", - "Only the first %zu lines of the file will be shown for " - "preview purposes in the following screens. ", - ia->text_file->n_lines), - ia->text_file->n_lines); - } + { + ds_put_format ( + &s, ngettext ( + "The selected file contains approximately %'lu line of text. ", + "The selected file contains approximately %'lu lines of text. ", + ia->text_file->total_lines), + ia->text_file->total_lines); + ds_put_format ( + &s, ngettext ( + "Only the first %zu line of the file will be shown for " + "preview purposes in the following screens. ", + "Only the first %zu lines of the file will be shown for " + "preview purposes in the following screens. ", + ia->text_file->n_lines), + ia->text_file->n_lines); + } } ds_put_cstr (&s, _("You may choose below how much of the file should " @@ -364,8 +364,8 @@ intro_on_enter (PsppireImportAssistant *ia, GtkWidget *page, enum IMPORT_ASSISTA { GtkWidget *hbox_n_cases = psppire_scanf_new (_("Only the first %4d cases"), &ia->n_cases_spin); gtk_grid_attach (GTK_GRID (table), hbox_n_cases, - 1, 1, - 1, 1); + 1, 1, + 1, 1); } GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ia->n_cases_spin)); @@ -374,11 +374,11 @@ intro_on_enter (PsppireImportAssistant *ia, GtkWidget *page, enum IMPORT_ASSISTA if (gtk_grid_get_child_at (GTK_GRID (table), 1, 2) == NULL) { GtkWidget *hbox_percent = psppire_scanf_new (_("Only the first %3d %% of file (approximately)"), - &ia->percent_spin); + &ia->percent_spin); gtk_grid_attach (GTK_GRID (table), hbox_percent, - 1, 2, - 1, 1); + 1, 2, + 1, 1); } gtk_widget_show_all (table); @@ -408,11 +408,11 @@ intro_page_create (PsppireImportAssistant *ia) ia->percent_button = get_widget_assert (builder, "import-percent"); g_signal_connect_swapped (ia->all_cases_button, "toggled", - G_CALLBACK (on_intro_amount_changed), ia); + G_CALLBACK (on_intro_amount_changed), ia); g_signal_connect_swapped (ia->n_cases_button, "toggled", - G_CALLBACK (on_intro_amount_changed), ia); + G_CALLBACK (on_intro_amount_changed), ia); g_signal_connect_swapped (ia->percent_button, "toggled", - G_CALLBACK (on_intro_amount_changed), ia); + G_CALLBACK (on_intro_amount_changed), ia); g_object_set_data (G_OBJECT (w), "on-leaving", intro_on_leave); g_object_set_data (G_OBJECT (w), "on-entering", intro_on_enter); @@ -441,9 +441,9 @@ choose_column_names (PsppireImportAssistant *ia) const gchar *candidate_name = NULL; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->variable_names_cb))) - { - candidate_name = psppire_delimited_text_get_header_title (PSPPIRE_DELIMITED_TEXT (ia->delimiters_model), i); - } + { + candidate_name = psppire_delimited_text_get_header_title (PSPPIRE_DELIMITED_TEXT (ia->delimiters_model), i); + } dict_create_var_with_unique_name (ia->dict, candidate_name, 0); } @@ -531,10 +531,10 @@ prepare_separators_page (PsppireImportAssistant *ia, GtkWidget *new_page, enum I return; gtk_tree_view_set_model (GTK_TREE_VIEW (ia->fields_tree_view), - GTK_TREE_MODEL (ia->delimiters_model)); + GTK_TREE_MODEL (ia->delimiters_model)); g_signal_connect_swapped (GTK_TREE_MODEL (ia->delimiters_model), "notify::delimiters", - G_CALLBACK (reset_tree_view_model), ia); + G_CALLBACK (reset_tree_view_model), ia); reset_separators_page (ia); @@ -565,7 +565,7 @@ separators_page_create (PsppireImportAssistant *ia) ia->quote_custom_entry = get_widget_assert (builder, "quote-custom-entry"); gtk_widget_set_sensitive (ia->custom_entry, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->custom_cb))); + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->custom_cb))); gtk_entry_set_max_length (GTK_ENTRY (ia->quote_custom_entry), 1); @@ -615,33 +615,33 @@ my_read (struct casereader *reader, void *aux, casenumber idx) c = case_create (proto); int i; for (i = 0 ; i < caseproto_get_n_widths (proto); ++i) - { - GValue value = {0}; - gtk_tree_model_get_value (tm, &iter, i + 1, &value); - - const struct variable *var = dict_get_var (ia->casereader_dict, i); - - const gchar *ss = g_value_get_string (&value); - if (ss) - { - union value *v = case_data_rw (c, var); - /* In this reader we derive the union value from the - string in the tree_model. We retrieve the width and format - from a dictionary which is stored directly after - the reader creation. Changes in ia->dict in the - variable window are not reflected here and therefore - this is always compatible with the width in the - caseproto. See bug #58298 */ - char *xx = data_in (ss_cstr (ss), - "UTF-8", - var_get_write_format (var).type, + { + GValue value = {0}; + gtk_tree_model_get_value (tm, &iter, i + 1, &value); + + const struct variable *var = dict_get_var (ia->casereader_dict, i); + + const gchar *ss = g_value_get_string (&value); + if (ss) + { + union value *v = case_data_rw (c, var); + /* In this reader we derive the union value from the + string in the tree_model. We retrieve the width and format + from a dictionary which is stored directly after + the reader creation. Changes in ia->dict in the + variable window are not reflected here and therefore + this is always compatible with the width in the + caseproto. See bug #58298 */ + char *xx = data_in (ss_cstr (ss), + "UTF-8", + var_get_write_format (var).type, settings_get_fmt_settings (), - v, var_get_width (var), "UTF-8"); + v, var_get_width (var), "UTF-8"); - free (xx); - } - g_value_unset (&value); - } + free (xx); + } + g_value_unset (&value); + } } gtk_tree_path_free (tp); @@ -683,13 +683,13 @@ textfile_create_reader (PsppireImportAssistant *ia) ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (ia->delimiters_model), &iter)) { for (i = 0 ; i < n_vars; ++i) - { - gchar *s = NULL; - gtk_tree_model_get (GTK_TREE_MODEL (ia->delimiters_model), &iter, i+1, &s, -1); - if (s) - fmt_guesser_add (fg[i], ss_cstr (s)); - free (s); - } + { + gchar *s = NULL; + gtk_tree_model_get (GTK_TREE_MODEL (ia->delimiters_model), &iter, i+1, &s, -1); + if (s) + fmt_guesser_add (fg[i], ss_cstr (s)); + free (s); + } } struct caseproto *proto = caseproto_create (); @@ -704,7 +704,7 @@ textfile_create_reader (PsppireImportAssistant *ia) int width = fmt_var_width (fs); var_set_width_and_formats (var, width, - &fs, &fs); + &fs, &fs); proto = caseproto_add_width (proto, width); fmt_guesser_destroy (fg[i]); @@ -732,7 +732,7 @@ textfile_create_reader (PsppireImportAssistant *ia) the string information. */ static void ia_variable_changed_cb (GObject *obj, gint var_num, guint what, - const struct variable *oldvar, gpointer data) + const struct variable *oldvar, gpointer data) { PsppireImportAssistant *ia = PSPPIRE_IMPORT_ASSISTANT (data); @@ -750,7 +750,7 @@ ia_variable_changed_cb (GObject *obj, gint var_num, guint what, g_object_get (ia->data_sheet, "data-model", &store, NULL); struct casereader *cr = casereader_create_random (proto, n_rows, - &my_casereader_class, ia); + &my_casereader_class, ia); psppire_data_store_set_reader (store, cr); dict_unref (ia->casereader_dict); ia->casereader_dict = dict_clone (ia->dict); @@ -876,10 +876,10 @@ intro_append_syntax (const PsppireImportAssistant *ia, struct string *s) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->n_cases_button))) ds_put_format (s, "SELECT IF ($CASENUM <= %d).\n", - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ia->n_cases_spin)) - first_line); + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ia->n_cases_spin)) - first_line); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->percent_button))) ds_put_format (s, "SAMPLE %.4g.\n", - gtk_spin_button_get_value (GTK_SPIN_BUTTON (ia->percent_spin)) / 100.0); + gtk_spin_button_get_value (GTK_SPIN_BUTTON (ia->percent_spin)) / 100.0); } @@ -897,8 +897,8 @@ formats_append_syntax (const PsppireImportAssistant *ia, struct string *s) char format_string[FMT_STRING_LEN_MAX + 1]; fmt_to_string (var_get_print_format (var), format_string); ds_put_format (s, " %s %s%s\n", - var_get_name (var), format_string, - i == n_vars - 1 ? "." : ""); + var_get_name (var), format_string, + i == n_vars - 1 ? "." : ""); } } @@ -916,12 +916,12 @@ separators_append_syntax (const PsppireImportAssistant *ia, struct string *s) const struct separator *seps = &separators[i]; GtkWidget *button = get_widget_assert (ia->text_builder, seps->name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - { - if (seps->c == '\t') - continue; + { + if (seps->c == '\t') + continue; - ds_put_byte (s, seps->c); - } + ds_put_byte (s, seps->c); + } } ds_put_cstr (s, "\"\n"); diff --git a/src/ui/gui/psppire-keypad.c b/src/ui/gui/psppire-keypad.c index c394e219b9..4ecf7bc73f 100644 --- a/src/ui/gui/psppire-keypad.c +++ b/src/ui/gui/psppire-keypad.c @@ -70,24 +70,24 @@ psppire_keypad_class_init (PsppireKeypadClass *klass) gobject_class->finalize = psppire_keypad_finalize; keypad_signals[INSERT_SYNTAX] = g_signal_new ("insert-syntax", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (PsppireKeypadClass, - keypad), + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (PsppireKeypadClass, + keypad), NULL, NULL, - g_cclosure_marshal_VOID__STRING, + g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, - G_TYPE_STRING); + G_TYPE_STRING); keypad_signals[ERASE] = g_signal_new ("erase", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (PsppireKeypadClass, - keypad), + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (PsppireKeypadClass, + keypad), NULL, NULL, - g_cclosure_marshal_VOID__VOID, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } @@ -131,22 +131,22 @@ static const gint rows = 5; botton-right corner at X2,Y2 */ static void add_button (PsppireKeypad *kp, GtkWidget **button, - gint x1, gint x2, - gint y1, gint y2) + gint x1, gint x2, + gint y1, gint y2) { g_object_set (G_OBJECT (*button), "focus-on-click", FALSE, NULL); gtk_grid_attach (GTK_GRID(kp->table), *button, x1, y1, x2 - x1, y2 - y1); gtk_widget_set_size_request (*button, - 30 * rows / (float) cols, - 30 * cols / (float) rows); + 30 * rows / (float) cols, + 30 * cols / (float) rows); g_hash_table_insert (kp->frag_table, *button, - (void *) keypad_insert_text[(button - &kp->digit[0])]); + (void *) keypad_insert_text[(button - &kp->digit[0])]); g_signal_connect (*button, "clicked", - G_CALLBACK (button_click), kp); + G_CALLBACK (button_click), kp); gtk_widget_show (*button); } @@ -185,8 +185,8 @@ enter_leave_notify (GtkWidget *widget, static gboolean key_release_callback (GtkWidget *widget, - GdkEventKey *event, - gpointer user_data) + GdkEventKey *event, + gpointer user_data) { if (! gtk_widget_has_focus (widget)) return FALSE; @@ -289,13 +289,13 @@ psppire_keypad_init (PsppireKeypad *kp) kp->dispose_has_run = FALSE; g_signal_connect (kp, "enter-notify-event", G_CALLBACK (enter_leave_notify), - NULL); + NULL); g_signal_connect (kp, "leave-notify-event", G_CALLBACK (enter_leave_notify), - NULL); + NULL); g_signal_connect (kp, "key-release-event", G_CALLBACK (key_release_callback), - NULL); + NULL); kp->frag_table = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -310,23 +310,23 @@ psppire_keypad_init (PsppireKeypad *kp) kp->digit[i] = gtk_button_new_with_label (buf); if (i == 0) - add_button (kp, &kp->digit[i], - digit_hoffset + 0, digit_hoffset + 2, - digit_voffset + 3, digit_voffset + 4); + add_button (kp, &kp->digit[i], + digit_hoffset + 0, digit_hoffset + 2, + digit_voffset + 3, digit_voffset + 4); else - add_button (kp, &kp->digit[i], - digit_hoffset + j % 3, digit_hoffset + j % 3 + 1, - digit_voffset + 2 - (j / 3), - digit_voffset + 2 - (j / 3) + 1); + add_button (kp, &kp->digit[i], + digit_hoffset + j % 3, digit_hoffset + j % 3 + 1, + digit_voffset + 2 - (j / 3), + digit_voffset + 2 - (j / 3) + 1); } /* ... all the other buttons */ kp->dot = button_new_from_unicode (0xB7); /* MIDDLE DOT */ add_button (kp, &kp->dot, digit_hoffset + 2, - digit_hoffset + 3, - digit_voffset + 3, - digit_voffset + 4); + digit_hoffset + 3, + digit_voffset + 3, + digit_voffset + 4); kp->plus = gtk_button_new_with_label ("+"); gtk_widget_set_tooltip_text (kp->plus, _("add")); @@ -415,9 +415,9 @@ psppire_keypad_init (PsppireKeypad *kp) gtk_widget_show (kp->table); gtk_widget_add_events (GTK_WIDGET (kp), - GDK_KEY_RELEASE_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_ENTER_NOTIFY_MASK | + GDK_KEY_RELEASE_MASK | + GDK_LEAVE_NOTIFY_MASK | + GDK_ENTER_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK); } diff --git a/src/ui/gui/psppire-keypad.h b/src/ui/gui/psppire-keypad.h index 89ae6b7d31..2a1a348435 100644 --- a/src/ui/gui/psppire-keypad.h +++ b/src/ui/gui/psppire-keypad.h @@ -19,20 +19,20 @@ below: +---+---+---+---+---+ - | | + | | | + < 7 8 9 | - + + - | | + + + + | | | - > 4 5 6 | - + + - | | + + + + | | | * <= 1 2 3 | - + + - | | - | / >= 0 . | - + + + + + + | | + | / >= 0 . | + + + | y != = () | - |x | + |x | +---+---+---+---+---+ It's intended for dialog boxes which produce PSPP syntax. Thus, diff --git a/src/ui/gui/psppire-means-layer.c b/src/ui/gui/psppire-means-layer.c index 255dc6dfe7..f60ad728b3 100644 --- a/src/ui/gui/psppire-means-layer.c +++ b/src/ui/gui/psppire-means-layer.c @@ -93,7 +93,7 @@ psppire_means_layer_update (PsppireMeansLayer *ml) return; l = g_strdup_printf (_("Layer %d of %d"), - ml->current_layer + 1, ml->n_layers); + ml->current_layer + 1, ml->n_layers); gtk_label_set_text (GTK_LABEL (ml->label), l); g_free (l); @@ -107,7 +107,7 @@ psppire_means_layer_update (PsppireMeansLayer *ml) g_return_if_fail (GTK_IS_TREE_MODEL (tm)); gtk_widget_set_sensitive (ml->forward, - gtk_tree_model_get_iter_first (tm, &dummy)); + gtk_tree_model_get_iter_first (tm, &dummy)); } } @@ -172,16 +172,16 @@ psppire_means_layer_init (PsppireMeansLayer *ml) ml->label = gtk_label_new (""); g_signal_connect_swapped (ml->forward, "clicked", G_CALLBACK (on_forward), - ml); + ml); g_signal_connect_swapped (ml->back, "clicked", G_CALLBACK (on_back), ml); g_object_set (ml->var_view, "headers-visible", FALSE, NULL); g_object_set (sw, - "shadow-type", GTK_SHADOW_ETCHED_IN, - "hscrollbar-policy", GTK_POLICY_AUTOMATIC, - NULL); + "shadow-type", GTK_SHADOW_ETCHED_IN, + "hscrollbar-policy", GTK_POLICY_AUTOMATIC, + NULL); g_signal_connect_swapped (ml->var_view, "notify::model", G_CALLBACK (psppire_means_layer_update), ml); diff --git a/src/ui/gui/psppire-output-view.c b/src/ui/gui/psppire-output-view.c index 4f6aa03dc5..06418fae15 100644 --- a/src/ui/gui/psppire-output-view.c +++ b/src/ui/gui/psppire-output-view.c @@ -86,9 +86,9 @@ enum static GtkTargetList *build_target_list (const struct output_item *item); static void clipboard_get_cb (GtkClipboard *clipboard, - GtkSelectionData *selection_data, - guint info, - gpointer data); + GtkSelectionData *selection_data, + guint info, + gpointer data); /* Draws a white background on the GtkLayout to match the white background of each of the output items. */ @@ -115,7 +115,7 @@ draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data) which can be selected or not selected */ GtkStyleContext *context = gtk_widget_get_style_context (widget); gtk_render_background (context, cr, clip.x, clip.y, - clip.x + clip.width, clip.y + clip.height); + clip.x + clip.width, clip.y + clip.height); /* Select the default foreground color based on current style and state of the widget */ GtkStateFlags state = gtk_widget_get_state_flags (widget); @@ -186,10 +186,10 @@ find_selected_item (struct psppire_output_view *view) GtkWidget *widget = GTK_WIDGET (item->drawing_area); if (GTK_IS_WIDGET (widget)) { - GtkStateFlags state = gtk_widget_get_state_flags (widget); - if (state & GTK_STATE_FLAG_SELECTED) - return item; - } + GtkStateFlags state = gtk_widget_get_state_flags (widget); + if (state & GTK_STATE_FLAG_SELECTED) + return item; + } } return NULL; } @@ -197,14 +197,14 @@ find_selected_item (struct psppire_output_view *view) static void set_copy_action (struct psppire_output_view *view, - gboolean state) + gboolean state) { GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view->output)); GAction *copy_action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), - "copy"); + "copy"); g_object_set (copy_action, - "enabled", state, - NULL); + "enabled", state, + NULL); } static void @@ -226,8 +226,8 @@ clear_selection (struct psppire_output_view *view) static gboolean off_item_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - struct psppire_output_view *view) + GdkEventButton *event, + struct psppire_output_view *view) { /* buttontime is set by button_press_event_cb If our event->time is equal to the time from the @@ -241,8 +241,8 @@ off_item_button_press_event_cb (GtkWidget *widget, static gboolean button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - struct psppire_output_view *view) + GdkEventButton *event, + struct psppire_output_view *view) { view->buttontime = event->time; clear_selection (view); @@ -254,9 +254,9 @@ button_press_event_cb (GtkWidget *widget, static void drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, - GtkSelectionData *selection_data, - guint target_type, guint time, - struct psppire_output_view *view) + GtkSelectionData *selection_data, + guint target_type, guint time, + struct psppire_output_view *view) { view->selected_item = find_selected_item (view); clipboard_get_cb (NULL, selection_data, target_type, view); @@ -270,7 +270,7 @@ create_drawing_area (struct psppire_output_view *view, g_object_set_data_full (G_OBJECT (drawing_area), "fsm", r, free_fsm); g_signal_connect (drawing_area, "button-press-event", - G_CALLBACK (button_press_event_cb), view); + G_CALLBACK (button_press_event_cb), view); gtk_widget_add_events (drawing_area, GDK_BUTTON_PRESS_MASK); { /* Drag and Drop */ @@ -280,11 +280,11 @@ create_drawing_area (struct psppire_output_view *view, gtk_drag_source_set_target_list (drawing_area, tl); gtk_target_list_unref (tl); g_signal_connect (drawing_area, "drag-data-get", - G_CALLBACK (drag_data_get_cb), view); + G_CALLBACK (drag_data_get_cb), view); } GtkStyleContext *context = gtk_widget_get_style_context (drawing_area); gtk_style_context_add_class (context, - GTK_STYLE_CLASS_VIEW); + GTK_STYLE_CLASS_VIEW); g_signal_connect (drawing_area, "draw", G_CALLBACK (draw_callback), view); @@ -356,15 +356,15 @@ rerender (struct psppire_output_view *view) item->item->table->notes); { - gint minw; - gint minh; - /* This code probably doesn't bring us anthing, but Gtk - shows warnings if get_preferred_width/height is not - called before the size_allocate below is called. */ - gtk_widget_get_preferred_width (item->drawing_area, &minw, NULL); - gtk_widget_get_preferred_height (item->drawing_area, &minh, NULL); - if (th > minh) th = minh; - if (tw > minw) tw = minw; + gint minw; + gint minh; + /* This code probably doesn't bring us anthing, but Gtk + shows warnings if get_preferred_width/height is not + called before the size_allocate below is called. */ + gtk_widget_get_preferred_width (item->drawing_area, &minw, NULL); + gtk_widget_get_preferred_height (item->drawing_area, &minh, NULL); + if (th > minh) th = minh; + if (tw > minw) tw = minw; } alloc.x = xpos; alloc.y = view->y; @@ -412,13 +412,13 @@ init_output_view_item (struct output_view_item *view_item, struct xr_fsm *r = xr_fsm_create_for_scrolling (item, view->style, cr); if (r == NULL) - { - gdk_window_end_draw_frame (win, ctx); - cairo_region_destroy (region); + { + gdk_window_end_draw_frame (win, ctx); + cairo_region_destroy (region); output_item_unref (view_item->item); - return false; - } + return false; + } xr_fsm_measure (r, cr, &view_item->width, &view_item->height); view_item->drawing_area = gtk_drawing_area_new (); @@ -473,7 +473,7 @@ psppire_output_view_put__ (struct psppire_output_view *view, gtk_tree_store_set (store, &iter, COL_LABEL, output_item_get_label (item), - COL_ADDR, item, + COL_ADDR, item, COL_Y, view->y, -1); @@ -576,9 +576,9 @@ clear_rectangle (cairo_surface_t *surface, static void clipboard_get_cb (GtkClipboard *clipboard, - GtkSelectionData *selection_data, - guint info, - gpointer data) + GtkSelectionData *selection_data, + guint info, + gpointer data) { struct psppire_output_view *view = data; @@ -677,15 +677,15 @@ clipboard_get_cb (GtkClipboard *clipboard, { driver = output_driver_create (&options); if (driver == NULL) - goto finish; + goto finish; driver->class->submit (driver, view->selected_item->item); if (driver->class->flush) - driver->class->flush (driver); + driver->class->flush (driver); /* Some drivers (eg: the odt one) don't write anything until they - are closed */ + are closed */ output_driver_destroy (driver); driver = NULL; } @@ -710,7 +710,7 @@ clipboard_get_cb (GtkClipboard *clipboard, static void clipboard_clear_cb (GtkClipboard *clipboard, - gpointer data) + gpointer data) { } @@ -808,10 +808,10 @@ on_realize (GtkWidget *overview, GObject *view) GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (overview)); GAction *copy_action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), - "copy"); + "copy"); GAction *select_all_action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), - "select-all"); + "select-all"); g_object_set (copy_action, "enabled", FALSE, NULL); g_object_set (select_all_action, "enabled", FALSE, NULL); @@ -841,10 +841,10 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview) gtk_widget_add_events (GTK_WIDGET (output), GDK_BUTTON_PRESS_MASK); g_signal_connect (output, "button-press-event", - G_CALLBACK (off_item_button_press_event_cb), view); + G_CALLBACK (off_item_button_press_event_cb), view); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (output)), - GTK_STYLE_CLASS_VIEW); + GTK_STYLE_CLASS_VIEW); if (overview) { @@ -991,8 +991,8 @@ create_xr_print_driver (GtkPrintContext *context, struct psppire_output_view *vi static gboolean paginate (GtkPrintOperation *operation, - GtkPrintContext *context, - struct psppire_output_view *view) + GtkPrintContext *context, + struct psppire_output_view *view) { if (view->paginated) { @@ -1030,8 +1030,8 @@ paginate (GtkPrintOperation *operation, static void begin_print (GtkPrintOperation *operation, - GtkPrintContext *context, - struct psppire_output_view *view) + GtkPrintContext *context, + struct psppire_output_view *view) { create_xr_print_driver (context, view); @@ -1042,8 +1042,8 @@ begin_print (GtkPrintOperation *operation, static void end_print (GtkPrintOperation *operation, - GtkPrintContext *context, - struct psppire_output_view *view) + GtkPrintContext *context, + struct psppire_output_view *view) { xr_pager_destroy (view->pager); view->pager = NULL; @@ -1052,9 +1052,9 @@ end_print (GtkPrintOperation *operation, static void draw_page (GtkPrintOperation *operation, - GtkPrintContext *context, - gint page_number, - struct psppire_output_view *view) + GtkPrintContext *context, + gint page_number, + struct psppire_output_view *view) { xr_pager_add_page (view->pager, get_cairo_context_from_print_context (context)); diff --git a/src/ui/gui/psppire-output-view.h b/src/ui/gui/psppire-output-view.h index 25cdcd59ff..37b3665496 100644 --- a/src/ui/gui/psppire-output-view.h +++ b/src/ui/gui/psppire-output-view.h @@ -24,7 +24,7 @@ struct output_item; struct string_map; struct psppire_output_view *psppire_output_view_new (GtkLayout *output, - GtkTreeView *overview); + GtkTreeView *overview); void psppire_output_view_destroy (struct psppire_output_view *); diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index a5f66fab6b..a485c6d173 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -115,7 +115,7 @@ psppire_output_submit (struct output_driver *this, pod->window = PSPPIRE_OUTPUT_WINDOW (psppire_output_window_new ()); GApplication *app = g_application_get_default (); gtk_application_add_window (GTK_APPLICATION (app), - GTK_WINDOW (pod->window)); + GTK_WINDOW (pod->window)); pod->window->driver = pod; } @@ -136,21 +136,21 @@ psppire_output_submit (struct output_driver *this, { gboolean status = true; psppire_conf_get_boolean (conf, "OutputWindowAction", "alert", - &status); + &status); gtk_window_set_urgency_hint (GTK_WINDOW (pod->window), status); } { gboolean status ; if (psppire_conf_get_boolean (conf, "OutputWindowAction", "maximize", - &status) && status) + &status) && status) gtk_window_maximize (GTK_WINDOW (pod->window)); } { gboolean status ; if (psppire_conf_get_boolean (conf, "OutputWindowAction", "raise", - &status) && status) + &status) && status) gtk_window_present (GTK_WINDOW (pod->window)); } } @@ -265,13 +265,13 @@ on_combo_change (GtkFileChooser *chooser) if (fn != NULL && file_type == FT_AUTO) { for (gint i = 1 ; i < n_FT ; ++i) - { - if (g_str_has_suffix (fn, ft[i].ext)) - { - sensitive = TRUE; - break; - } - } + { + if (g_str_has_suffix (fn, ft[i].ext)) + { + sensitive = TRUE; + break; + } + } } else sensitive = (fn != NULL); @@ -293,9 +293,9 @@ create_file_type_list (void) { gtk_list_store_append (list, &iter); gtk_list_store_set (list, &iter, - 0, gettext (ft[i].label), - 1, ft[i].ext, - -1); + 0, gettext (ft[i].label), + 1, ft[i].ext, + -1); } return list; @@ -354,20 +354,20 @@ psppire_output_window_export (PsppireOutputWindow *window) g_return_if_fail (filename); if (file_type == FT_AUTO) - { + { /* If the "Infer file type from extension" option was chosen, search for the respective type in the list. (It's a O(n) search, but fortunately n is small). */ - gint i; - for (i = 1 ; i < n_FT ; ++i) - { - if (g_str_has_suffix (filename, ft[i].ext)) - { - file_type = i; - break; - } - } - } + gint i; + for (i = 1 ; i < n_FT ; ++i) + { + if (g_str_has_suffix (filename, ft[i].ext)) + { + file_type = i; + break; + } + } + } else if (! g_str_has_suffix (filename, ft[file_type].ext)) { /* If an explicit document format was chosen, and if the chosen @@ -384,43 +384,43 @@ psppire_output_window_export (PsppireOutputWindow *window) string_map_insert (&options, "output-file", filename); switch (file_type) - { + { case FT_SPV: export_output (window, &options, "spv"); break; - case FT_PDF: + case FT_PDF: export_output (window, &options, "pdf"); - break; - case FT_HTML: + break; + case FT_HTML: export_output (window, &options, "html"); - break; - case FT_ODT: + break; + case FT_ODT: export_output (window, &options, "odt"); - break; - case FT_PS: + break; + case FT_PS: export_output (window, &options, "ps"); - break; - case FT_CSV: + break; + case FT_CSV: export_output (window, &options, "csv"); - break; - case FT_PNG: + break; + case FT_PNG: export_output (window, &options, "png"); - break; - case FT_SVG: + break; + case FT_SVG: export_output (window, &options, "svg"); - break; + break; - case FT_TXT: + case FT_TXT: string_map_insert (&options, "box", "unicode"); - /* Fall through */ + /* Fall through */ - case FT_ASCII: + case FT_ASCII: string_map_insert (&options, "charts", "none"); export_output (window, &options, "txt"); - break; - default: - g_assert_not_reached (); - } + break; + default: + g_assert_not_reached (); + } string_map_destroy (&options); @@ -447,9 +447,9 @@ psppire_output_window_init (PsppireOutputWindow *window) GTK_TREE_VIEW (get_widget_assert (xml, "overview"))); g_signal_connect (window, - "focus-in-event", - G_CALLBACK (cancel_urgency), - NULL); + "focus-in-event", + G_CALLBACK (cancel_urgency), + NULL); GObject *menu = get_object_assert (xml, "output-window-menu", G_TYPE_MENU); GtkWidget *menubar = gtk_menu_bar_new_from_model (G_MENU_MODEL (menu)); @@ -457,10 +457,10 @@ psppire_output_window_init (PsppireOutputWindow *window) gtk_box_pack_start (GTK_BOX (box), paned, TRUE, TRUE, 0); gtk_menu_shell_append (GTK_MENU_SHELL (menubar), - create_windows_menu (GTK_WINDOW (window))); + create_windows_menu (GTK_WINDOW (window))); gtk_menu_shell_append (GTK_MENU_SHELL (menubar), - create_help_menu (GTK_WINDOW (window))); + create_help_menu (GTK_WINDOW (window))); { GSimpleAction *print = g_simple_action_new ("print", NULL); @@ -470,8 +470,8 @@ psppire_output_window_init (PsppireOutputWindow *window) const gchar *accels[2] = { "P", NULL}; gtk_application_set_accels_for_action (app, - "win.print", - accels); + "win.print", + accels); } @@ -501,15 +501,15 @@ psppire_output_window_init (PsppireOutputWindow *window) const gchar *accels[2] = { "C", NULL}; gtk_application_set_accels_for_action (app, - "win.copy", - accels); + "win.copy", + accels); } g_object_unref (xml); g_signal_connect (window, "delete-event", - G_CALLBACK (on_delete), window); + G_CALLBACK (on_delete), window); } @@ -517,10 +517,10 @@ GtkWidget* psppire_output_window_new (void) { return GTK_WIDGET (g_object_new (psppire_output_window_get_type (), - /* TRANSLATORS: This will be part of a filename. Please avoid whitespace. */ - "filename", _("Output"), - "description", _("Output Viewer"), - NULL)); + /* TRANSLATORS: This will be part of a filename. Please avoid whitespace. */ + "filename", _("Output"), + "description", _("Output Viewer"), + NULL)); } static void diff --git a/src/ui/gui/psppire-scanf.c b/src/ui/gui/psppire-scanf.c index 88128a3090..a131595ff7 100644 --- a/src/ui/gui/psppire-scanf.c +++ b/src/ui/gui/psppire-scanf.c @@ -49,7 +49,7 @@ enum */ static void ship_label (PsppireScanf *box, const char **s, - const char_directives *dirs, size_t dir_idx) + const char_directives *dirs, size_t dir_idx) { GtkWidget *label ; GString *str = g_string_new (*s); @@ -60,18 +60,18 @@ ship_label (PsppireScanf *box, const char **s, int n = 0; while (dir_idx < dirs->count && dir.conversion == '%') - { - g_string_erase (str, dir.dir_start - *s, 1); - dir = dirs->dir[++dir_idx]; - n++; - } + { + g_string_erase (str, dir.dir_start - *s, 1); + dir = dirs->dir[++dir_idx]; + n++; + } g_string_truncate (str, dir.dir_start - *s - n); if (dir_idx >= dirs->count) - *s = NULL; + *s = NULL; else - *s = dir.dir_end; + *s = dir.dir_end; } label = gtk_label_new (str->str); @@ -107,36 +107,36 @@ guts (PsppireScanf *scanf) int width = 0; if (dir.precision_start && dir.precision_end) - precision = g_ascii_strtoll (dir.precision_start + 1, - (char **) &dir.precision_end, 10); + precision = g_ascii_strtoll (dir.precision_start + 1, + (char **) &dir.precision_end, 10); if (dir.width_start && dir.width_end) - width = g_ascii_strtoll (dir.width_start, (char **) &dir.width_end, 10); + width = g_ascii_strtoll (dir.width_start, (char **) &dir.width_end, 10); if (dir.dir_start > s) - ship_label (scanf, &s, &scanf->d, i); + ship_label (scanf, &s, &scanf->d, i); if (dir.conversion == '%') - { - if (s) s++; - continue; - } + { + if (s) s++; + continue; + } w = &scanf->widgets [dir.arg_index]; switch (dir.conversion) - { - case 'd': - case 'i': - case 'f': - { - *w = gtk_spin_button_new_with_range (0, 100.0, 1.0); - g_object_set (*w, "digits", precision, NULL); - } - break; - case 's': - *w = gtk_entry_new (); - break; - }; + { + case 'd': + case 'i': + case 'f': + { + *w = gtk_spin_button_new_with_range (0, 100.0, 1.0); + g_object_set (*w, "digits", precision, NULL); + } + break; + case 's': + *w = gtk_entry_new (); + break; + }; g_object_set (*w, "width-chars", width, NULL); gtk_box_pack_start (GTK_BOX (scanf), *w, FALSE, FALSE, 0); gtk_widget_show (*w); @@ -155,31 +155,31 @@ set_mnemonic (PsppireScanf *scanf) { GList *l = gtk_container_get_children (GTK_CONTAINER (scanf)); while (l) - { - if (GTK_IS_LABEL (l->data)) - { - const gchar *t = gtk_label_get_label (l->data); - if (g_strstr_len (t, -1, "_")) - { - g_object_set (l->data, - "use-underline", TRUE, - "mnemonic-widget", scanf->mnemonic_widget, - NULL); - - break; - } - } - l = l->next; - } + { + if (GTK_IS_LABEL (l->data)) + { + const gchar *t = gtk_label_get_label (l->data); + if (g_strstr_len (t, -1, "_")) + { + g_object_set (l->data, + "use-underline", TRUE, + "mnemonic-widget", scanf->mnemonic_widget, + NULL); + + break; + } + } + l = l->next; + } g_list_free (l); } } static void psppire_scanf_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireScanf *scanf = PSPPIRE_SCANF (object); @@ -206,9 +206,9 @@ psppire_scanf_set_property (GObject *object, static void psppire_scanf_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireScanf *scanf = PSPPIRE_SCANF (object); @@ -272,33 +272,33 @@ psppire_scanf_class_init (PsppireScanfClass *class) GParamSpec *format_spec = g_param_spec_string ("format", - "Format", - "A Scanf style format string", - NULL, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + "Format", + "A Scanf style format string", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); GParamSpec *nconv_spec = g_param_spec_int ("n-conv", - "Conversions", - "The number of conversions in the format string", - 0, G_MAXINT, 0, - G_PARAM_READABLE); + "Conversions", + "The number of conversions in the format string", + 0, G_MAXINT, 0, + G_PARAM_READABLE); GParamSpec *use_underline_spec = g_param_spec_boolean ("use-underline", - "Use Underline", - "If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key", - FALSE, - G_PARAM_READWRITE); + "Use Underline", + "If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key", + FALSE, + G_PARAM_READWRITE); GParamSpec *mnemonic_widget_spec = g_param_spec_object ("mnemonic-widget", - "Mnemonic widget", - "The widget which is to be activated when the Scanf's mnemonic key is pressed. Has no effect if use-underline is false.", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE); + "Mnemonic widget", + "The widget which is to be activated when the Scanf's mnemonic key is pressed. Has no effect if use-underline is false.", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE); parent_class = g_type_class_peek_parent (class); @@ -367,7 +367,7 @@ psppire_scanf_new (const gchar *fmt, ...) va_list ap; GtkWidget *w = GTK_WIDGET (g_object_new (psppire_scanf_get_type (), - "format", fmt, NULL)); + "format", fmt, NULL)); g_object_get (w, "n-conv", &n, NULL); @@ -378,7 +378,7 @@ psppire_scanf_new (const gchar *fmt, ...) GtkWidget **field; if (psppire_get_conversion_char (PSPPIRE_SCANF (w), i) == '%') - continue; + continue; field = va_arg (ap, GtkWidget **); diff --git a/src/ui/gui/psppire-search-dialog.c b/src/ui/gui/psppire-search-dialog.c index 8a42ab578c..67a2f9118d 100644 --- a/src/ui/gui/psppire-search-dialog.c +++ b/src/ui/gui/psppire-search-dialog.c @@ -51,9 +51,9 @@ G_DEFINE_TYPE (PsppireSearchDialog, psppire_search_dialog, PSPPIRE_TYPE_DIALOG); static void psppire_search_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { // PsppireSearchDialog *dialog = PSPPIRE_SEARCH_DIALOG (object); @@ -67,9 +67,9 @@ psppire_search_dialog_get_property (GObject *object, static void psppire_search_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { // PsppireSearchDialog *dialog = PSPPIRE_SEARCH_DIALOG (object); @@ -94,14 +94,14 @@ psppire_search_dialog_class_init (PsppireSearchDialogClass *class) signals [FIND] = g_signal_new ("find", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, + G_TYPE_BOOLEAN); parent_class = g_type_class_peek_parent (class); } diff --git a/src/ui/gui/psppire-select-dest.c b/src/ui/gui/psppire-select-dest.c index c585851f9a..e308b2984c 100644 --- a/src/ui/gui/psppire-select-dest.c +++ b/src/ui/gui/psppire-select-dest.c @@ -29,20 +29,20 @@ psppire_select_dest_widget_get_type (void) const GTypeInfo dest_widget_info = { sizeof (PsppireSelectDestWidgetIface), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL, - NULL /* value_table */ + NULL, /* base_init */ + NULL, /* base_finalize */ + NULL, + NULL, /* class_finalize */ + NULL, /* class_data */ + 0, + 0, /* n_preallocs */ + NULL, + NULL /* value_table */ }; dest_widget_type = - g_type_register_static (G_TYPE_INTERFACE, "PsppireSelectDestWidget", - &dest_widget_info, 0); + g_type_register_static (G_TYPE_INTERFACE, "PsppireSelectDestWidget", + &dest_widget_info, 0); g_type_interface_add_prerequisite (dest_widget_type, GTK_TYPE_WIDGET); } diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c index 678c2a749f..d0ab6e3d52 100644 --- a/src/ui/gui/psppire-selector.c +++ b/src/ui/gui/psppire-selector.c @@ -26,26 +26,26 @@ +----------------------------------------------------------+ - | | - | Source Widget Dest Widget | - | +----------------+ +----------------+ | - | | Variable0 | | Variable2 | | - | | Variable1 | | | | - | | Variable3 | | | | - | | | Selector | | | - | | | | | | - | | | +------+ | | | - | | | | |\ | | | | - | | | | | \ | | | | - | | | | | / | | | | - | | | | |/ | | | | - | | | +------+ | | | - | | | | | | - | | | | | | - | | | | | | - | | | | | | - | +----------------+ +----------------+ | - | | + | | + | Source Widget Dest Widget | + | +----------------+ +----------------+ | + | | Variable0 | | Variable2 | | + | | Variable1 | | | | + | | Variable3 | | | | + | | | Selector | | | + | | | | | | + | | | +------+ | | | + | | | | |\ | | | | + | | | | | \ | | | | + | | | | | / | | | | + | | | | |/ | | | | + | | | +------+ | | | + | | | | | | + | | | | | | + | | | | | | + | | | | | | + | +----------------+ +----------------+ | + | | +----------------------------------------------------------+ The Source Widget is always a GtkTreeView. The Dest Widget may be a @@ -150,9 +150,9 @@ psppire_selector_dispose (GObject *obj) GList *newlist = g_list_remove_link (list, sel->source_litem); g_list_free (sel->source_litem); if (newlist == NULL) - g_hash_table_remove (class->source_hash, sel->source); + g_hash_table_remove (class->source_hash, sel->source); else - g_hash_table_replace (class->source_hash, sel->source, newlist); + g_hash_table_replace (class->source_hash, sel->source, newlist); sel->source_litem = NULL; } @@ -185,9 +185,9 @@ static void on_realize (GtkWidget *selector); static void psppire_selector_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireSelector *selector = PSPPIRE_SELECTOR (object); @@ -218,9 +218,9 @@ psppire_selector_set_property (GObject *object, static void psppire_selector_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireSelector *selector = PSPPIRE_SELECTOR (object); @@ -249,34 +249,34 @@ psppire_selector_class_init (PsppireSelectorClass *class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GParamSpec *orientation_spec = g_param_spec_enum ("orientation", - "Orientation", - "Where the selector is relative to its subjects", - PSPPIRE_TYPE_SELECTOR_ORIENTATION, - PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */, - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + "Orientation", + "Where the selector is relative to its subjects", + PSPPIRE_TYPE_SELECTOR_ORIENTATION, + PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */, + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); /* Meaningfull only if more than one selector shares this selectors source */ GParamSpec *primary_spec = g_param_spec_boolean ("primary", - "Primary", - "Whether this selector should be the primary selector for the source", - FALSE, - G_PARAM_READWRITE); + "Primary", + "Whether this selector should be the primary selector for the source", + FALSE, + G_PARAM_READWRITE); 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); + "Source Widget", + "The widget to be used as the source for this selector", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE); GParamSpec *dest_widget_spec = g_param_spec_object ("dest-widget", - "Destination Widget", - "The widget to be used as the destination for this selector", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE); + "Destination Widget", + "The widget to be used as the destination for this selector", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE); button_class->clicked = on_click; @@ -306,23 +306,23 @@ psppire_selector_class_init (PsppireSelectorClass *class) signals [SELECTED] = g_signal_new ("selected", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); signals [DE_SELECTED] = g_signal_new ("de-selected", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); object_class->dispose = psppire_selector_dispose; @@ -334,9 +334,9 @@ psppire_selector_class_init (PsppireSelectorClass *class) /* Callback for when the source treeview is activated (double clicked) */ static void on_row_activate (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) + GtkTreePath *path, + GtkTreeViewColumn *column, + gpointer data) { on_click (GTK_BUTTON (data)); } @@ -352,13 +352,13 @@ on_source_select (GtkTreeSelection *treeselection, gpointer data) if (selector->allow_selection) { gtk_widget_set_sensitive (GTK_WIDGET (selector), - selector->allow_selection (selector->source, selector->dest)); + selector->allow_selection (selector->source, selector->dest)); } else if (GTK_IS_ENTRY (selector->dest)) { gtk_widget_set_sensitive (GTK_WIDGET (selector), - gtk_tree_selection_count_selected_rows - (treeselection) <= 1); + gtk_tree_selection_count_selected_rows + (treeselection) <= 1); } } @@ -381,10 +381,10 @@ on_realize (GtkWidget *w) if (g_list_first (list)->data == selector) { if (selector->row_activate_id) - g_signal_handler_disconnect (selector->source, selector->row_activate_id); + g_signal_handler_disconnect (selector->source, selector->row_activate_id); selector->row_activate_id = - g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector); + g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector); } selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source)); @@ -443,44 +443,44 @@ set_direction (PsppireSelector *selector, enum psppire_selector_dir d) if (d == PSPPIRE_SELECTOR_SOURCE_TO_DEST) { switch (selector->orientation) - { - case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: - g_object_set (selector->arrow, "icon-name", "pan-end-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_AFTER_DEST: - g_object_set (selector->arrow, "icon-name", "pan-start-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: - g_object_set (selector->arrow, "icon-name", "pan-down-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_BELOW_DEST: - g_object_set (selector->arrow, "icon-name", "pan-up-symbolic", NULL); - break; - default: - g_assert_not_reached (); - break; - }; + { + case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: + g_object_set (selector->arrow, "icon-name", "pan-end-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_AFTER_DEST: + g_object_set (selector->arrow, "icon-name", "pan-start-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: + g_object_set (selector->arrow, "icon-name", "pan-down-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_BELOW_DEST: + g_object_set (selector->arrow, "icon-name", "pan-up-symbolic", NULL); + break; + default: + g_assert_not_reached (); + break; + }; } else { switch (selector->orientation) - { - case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: - g_object_set (selector->arrow, "icon-name", "pan-start-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_AFTER_DEST: - g_object_set (selector->arrow, "icon-name", "pan-end-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: - g_object_set (selector->arrow, "icon-name", "pan-up-symbolic", NULL); - break; - case PSPPIRE_SELECT_SOURCE_BELOW_DEST: - g_object_set (selector->arrow, "icon-name", "pan-down-symbolic", NULL); - break; - default: - g_assert_not_reached (); - break; - }; + { + case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: + g_object_set (selector->arrow, "icon-name", "pan-start-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_AFTER_DEST: + g_object_set (selector->arrow, "icon-name", "pan-end-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: + g_object_set (selector->arrow, "icon-name", "pan-up-symbolic", NULL); + break; + case PSPPIRE_SELECT_SOURCE_BELOW_DEST: + g_object_set (selector->arrow, "icon-name", "pan-down-symbolic", NULL); + break; + default: + g_assert_not_reached (); + break; + }; } } @@ -655,12 +655,12 @@ select_selection (PsppireSelector *selector) gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), - &child_iter, &iter); + &child_iter, &iter); selector->select_items (child_iter, - selector->dest, - childmodel, - selector->select_user_data - ); + selector->dest, + childmodel, + selector->select_user_data + ); } g_list_foreach (selected_rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL); @@ -709,10 +709,10 @@ is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *select if (GTK_IS_TREE_MODEL_FILTER (model)) { source_model = gtk_tree_model_filter_get_model - (GTK_TREE_MODEL_FILTER (model)); + (GTK_TREE_MODEL_FILTER (model)); gtk_tree_model_filter_convert_iter_to_child_iter - (GTK_TREE_MODEL_FILTER (model), &source_iter, iter); + (GTK_TREE_MODEL_FILTER (model), &source_iter, iter); } else { @@ -723,7 +723,7 @@ is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *select gtk_tree_model_get_value (source_model, &source_iter, DICT_TVM_COL_VAR, &value); result = psppire_select_dest_widget_contains_var (PSPPIRE_SELECT_DEST_WIDGET (selector->dest), - &value); + &value); g_value_unset (&value); @@ -737,7 +737,7 @@ is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *select are visible */ static gboolean is_source_item_visible (GtkTreeModel *childmodel, - GtkTreeIter *iter, gpointer data) + GtkTreeIter *iter, gpointer data) { PsppireSelector *selector = data; PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE); @@ -751,7 +751,7 @@ is_source_item_visible (GtkTreeModel *childmodel, PsppireSelector *selector = list->data; if (selector->filter && selector->filter (childmodel, iter, selector)) - return FALSE; + return FALSE; list = list->next; } @@ -771,8 +771,8 @@ set_tree_view_source (PsppireSelector *selector) if (! (list = g_hash_table_lookup (class->source_hash, selector->source))) { /* 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 */ + any selector. Create a hash entry and make this selector + the first selector in the list */ list = g_list_append (list, selector); g_hash_table_insert (class->source_hash, selector->source, list); @@ -782,22 +782,22 @@ set_tree_view_source (PsppireSelector *selector) } else { /* Append this selector to the list and push the - pair onto the hash table */ + pair onto the hash table */ if (NULL == g_list_find (list, selector)) - { - if (selector->primary_requested) - { - list = g_list_prepend (list, selector); - selector->source_litem = list; - } - else - { - list = g_list_append (list, selector); - selector->source_litem = g_list_last (list); - } - g_hash_table_replace (class->source_hash, selector->source, list); - } + { + if (selector->primary_requested) + { + list = g_list_prepend (list, selector); + selector->source_litem = list; + } + else + { + list = g_list_append (list, selector); + selector->source_litem = g_list_last (list); + } + g_hash_table_replace (class->source_hash, selector->source, list); + } } } @@ -833,12 +833,12 @@ update_model ( NULL); g_signal_connect_swapped (new_model, - "row-deleted", - G_CALLBACK (on_row_deleted), selector); + "row-deleted", + G_CALLBACK (on_row_deleted), selector); g_signal_connect_swapped (new_model, - "row-inserted", - G_CALLBACK (on_row_inserted), selector); + "row-inserted", + G_CALLBACK (on_row_inserted), selector); g_object_unref (new_model); } @@ -851,9 +851,9 @@ update_model ( */ static void on_dest_data_change (GtkTreeModel *tree_model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) { PsppireSelector *selector = user_data; @@ -865,8 +865,8 @@ on_dest_data_change (GtkTreeModel *tree_model, static void on_dest_data_delete (GtkTreeModel *tree_model, - GtkTreePath *path, - gpointer user_data) + GtkTreePath *path, + gpointer user_data) { PsppireSelector *selector = user_data; @@ -891,10 +891,10 @@ on_dest_model_changed (PsppireSelector *selector) return; g_signal_connect (model, "row-changed", G_CALLBACK (on_dest_data_change), - selector); + selector); g_signal_connect (model, "row-deleted", G_CALLBACK (on_dest_data_delete), - selector); + selector); g_signal_connect (selector, "destroy", G_CALLBACK (remove_selector_handlers), model); @@ -906,7 +906,7 @@ on_dest_model_changed (PsppireSelector *selector) /* Set the destination widget to DEST */ static void set_tree_view_dest (PsppireSelector *selector, - GtkTreeView *dest) + GtkTreeView *dest) { GtkTreeSelection* selection = gtk_tree_view_get_selection (dest); @@ -914,16 +914,16 @@ set_tree_view_dest (PsppireSelector *selector, gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); g_signal_connect (selection, "changed", G_CALLBACK (on_dest_treeview_select), - selector); + selector); on_dest_model_changed (selector); g_signal_connect_swapped (dest, "notify::model", - G_CALLBACK (on_dest_model_changed), selector); + G_CALLBACK (on_dest_model_changed), selector); } static void set_layer_dest (PsppireSelector *selector, - PsppireMeansLayer *dest) + PsppireMeansLayer *dest) { GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dest->var_view)); @@ -931,7 +931,7 @@ set_layer_dest (PsppireSelector *selector, g_signal_connect (selection, "changed", G_CALLBACK (on_dest_treeview_select), - selector); + selector); } @@ -952,19 +952,19 @@ on_entry_dest_select (GtkWidget *widget, GdkEventFocus *event, gpointer data) /* Set DEST to be the destination GtkEntry widget */ static void set_entry_dest (PsppireSelector *selector, - GtkEntry *dest) + GtkEntry *dest) { g_signal_connect_swapped (dest, "activate", G_CALLBACK (refilter), - selector); + selector); g_signal_connect_swapped (dest, "changed", G_CALLBACK (refilter), - selector); + selector); g_signal_connect (dest, "focus-in-event", G_CALLBACK (on_entry_dest_select), - selector); + selector); g_signal_connect_swapped (dest, "focus-out-event", G_CALLBACK (refilter), - selector); + selector); } @@ -975,7 +975,7 @@ set_default_filter (PsppireSelector *selector) if (selector->filter == NULL) { if (GTK_IS_TREE_VIEW (selector->dest)) - selector->filter = is_item_in_dest; + selector->filter = is_item_in_dest; } } @@ -1031,11 +1031,11 @@ psppire_selector_update_subjects (PsppireSelector *selector) GType type = G_OBJECT_TYPE (selector->dest); SelectItemsFunc *func = - g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type); + g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type); if (func) - psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector), - func, NULL); + psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector), + func, NULL); } } @@ -1056,7 +1056,7 @@ psppire_selector_set_default_selection_func (GType type, SelectItemsFunc *func) /* Set FILTER_FUNC for this selector */ void psppire_selector_set_filter_func (PsppireSelector *selector, - FilterItemsFunc *filter_func) + FilterItemsFunc *filter_func) { selector->filter = filter_func ; } @@ -1065,8 +1065,8 @@ psppire_selector_set_filter_func (PsppireSelector *selector, /* Set SELECT_FUNC for this selector */ void psppire_selector_set_select_func (PsppireSelector *selector, - SelectItemsFunc *select_func, - gpointer user_data) + SelectItemsFunc *select_func, + gpointer user_data) { selector->select_user_data = user_data; selector->select_items = select_func; @@ -1088,13 +1088,13 @@ psppire_selector_orientation_get_type (void) if (etype == 0) { static const GEnumValue values[] = - { - { PSPPIRE_SELECT_SOURCE_BEFORE_DEST, "PSPPIRE_SELECT_SOURCE_BEFORE_DEST", "source before destination" }, - { PSPPIRE_SELECT_SOURCE_AFTER_DEST, "PSPPIRE_SELECT_SOURCE_AFTER_DEST", "source after destination" }, - { PSPPIRE_SELECT_SOURCE_ABOVE_DEST, "PSPPIRE_SELECT_SOURCE_ABOVE_DEST", "source above destination" }, - { PSPPIRE_SELECT_SOURCE_BELOW_DEST, "PSPPIRE_SELECT_SOURCE_BELOW_DEST", "source below destination" }, - { 0, NULL, NULL } - }; + { + { PSPPIRE_SELECT_SOURCE_BEFORE_DEST, "PSPPIRE_SELECT_SOURCE_BEFORE_DEST", "source before destination" }, + { PSPPIRE_SELECT_SOURCE_AFTER_DEST, "PSPPIRE_SELECT_SOURCE_AFTER_DEST", "source after destination" }, + { PSPPIRE_SELECT_SOURCE_ABOVE_DEST, "PSPPIRE_SELECT_SOURCE_ABOVE_DEST", "source above destination" }, + { PSPPIRE_SELECT_SOURCE_BELOW_DEST, "PSPPIRE_SELECT_SOURCE_BELOW_DEST", "source below destination" }, + { 0, NULL, NULL } + }; etype = g_enum_register_static (g_intern_static_string ("PsppireSelectorOrientation"), values); } return etype; diff --git a/src/ui/gui/psppire-selector.h b/src/ui/gui/psppire-selector.h index c4990c9229..acceb19c77 100644 --- a/src/ui/gui/psppire-selector.h +++ b/src/ui/gui/psppire-selector.h @@ -41,9 +41,9 @@ typedef struct _PsppireSelectorClass PsppireSelectorClass; /* Function for appending selected items to the destination widget */ typedef void SelectItemsFunc (GtkTreeIter iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data); + GtkWidget *dest, + GtkTreeModel *source_model, + gpointer data); /* Function to determine if items may be selected */ typedef gboolean AllowSelectionFunc (GtkWidget *src, GtkWidget *dest); @@ -55,8 +55,8 @@ typedef gboolean AllowSelectionFunc (GtkWidget *src, GtkWidget *dest); Returns TRUE if the item is currently selected, FALSE otherwise. */ typedef gboolean FilterItemsFunc (GtkTreeModel *model, - GtkTreeIter *iter, - PsppireSelector *selector); + GtkTreeIter *iter, + PsppireSelector *selector); enum psppire_selector_dir { @@ -119,12 +119,12 @@ GtkWidget* psppire_selector_new (void); /* Set FILTER_FUNC for this selector */ void psppire_selector_set_filter_func (PsppireSelector *selector, - FilterItemsFunc *filter_func); + FilterItemsFunc *filter_func); /* Set SELECT_FUNC for this selector */ void psppire_selector_set_select_func (PsppireSelector *selector, - SelectItemsFunc *select_func, - gpointer user_data); + SelectItemsFunc *select_func, + gpointer user_data); /* Force the selector to update its dest and source widgets */ void psppire_selector_update_subjects (PsppireSelector *selector); diff --git a/src/ui/gui/psppire-spreadsheet-data-model.c b/src/ui/gui/psppire-spreadsheet-data-model.c index 1d0fbc1558..73a281bb01 100644 --- a/src/ui/gui/psppire-spreadsheet-data-model.c +++ b/src/ui/gui/psppire-spreadsheet-data-model.c @@ -47,10 +47,10 @@ enum static guint signals [n_SIGNALS]; G_DEFINE_TYPE_WITH_CODE (PsppireSpreadsheetDataModel,\ - psppire_spreadsheet_data_model,\ - G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - spreadsheet_tree_model_init)) + psppire_spreadsheet_data_model,\ + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + spreadsheet_tree_model_init)) /* Properties */ enum @@ -158,16 +158,16 @@ psppire_spreadsheet_data_model_class_init (PsppireSpreadsheetDataModelClass * cl signals [ITEMS_CHANGED] = g_signal_new ("items-changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__UINT_UINT_UINT, - G_TYPE_NONE, - 3, - G_TYPE_UINT, /* Index of the start of the change */ - G_TYPE_UINT, /* The number of items deleted */ - G_TYPE_UINT); /* The number of items inserted */ + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + psppire_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, + 3, + G_TYPE_UINT, /* Index of the start of the change */ + G_TYPE_UINT, /* The number of items deleted */ + G_TYPE_UINT); /* The number of items inserted */ diff --git a/src/ui/gui/psppire-spreadsheet-data-model.h b/src/ui/gui/psppire-spreadsheet-data-model.h index c06418b3e1..ae634d810a 100644 --- a/src/ui/gui/psppire-spreadsheet-data-model.h +++ b/src/ui/gui/psppire-spreadsheet-data-model.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL (psppire_spreadsheet_data_model_get_type ()) -#define PSPPIRE_SPREADSHEET_DATA_MODEL(obj) \ +#define PSPPIRE_SPREADSHEET_DATA_MODEL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, PsppireSpreadsheetDataModel)) + PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, PsppireSpreadsheetDataModel)) #define PSPPIRE_SPREADSHEET_DATA_MODEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, \ + PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, \ PsppireSpreadsheetDataModelClass)) #define PSPPIRE_IS_SPREADSHEET_DATA_MODEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL)) #define PSPPIRE_IS_SPREADSHEET_DATA_MODEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL)) #define PSPPIRE_SPREADSHEET_DATA_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, \ - PsppireSpreadsheetDataModelClass)) + PSPPIRE_TYPE_SPREADSHEET_DATA_MODEL, \ + PsppireSpreadsheetDataModelClass)) typedef struct _PsppireSpreadsheetDataModel PsppireSpreadsheetDataModel; typedef struct _PsppireSpreadsheetDataModelClass PsppireSpreadsheetDataModelClass; diff --git a/src/ui/gui/psppire-spreadsheet-model.c b/src/ui/gui/psppire-spreadsheet-model.c index 26c803f3a6..2331857c19 100644 --- a/src/ui/gui/psppire-spreadsheet-model.c +++ b/src/ui/gui/psppire-spreadsheet-model.c @@ -41,10 +41,10 @@ static GObjectClass *parent_class = NULL; static void spreadsheet_tree_model_init (GtkTreeModelIface * iface); G_DEFINE_TYPE_WITH_CODE (PsppireSpreadsheetModel,\ - psppire_spreadsheet_model,\ - G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - spreadsheet_tree_model_init)) + psppire_spreadsheet_model,\ + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + spreadsheet_tree_model_init)) /* Properties */ enum @@ -67,10 +67,10 @@ psppire_spreadsheet_model_set_property (GObject * object, { case PROP_SPREADSHEET: { - struct spreadsheet *old = spreadsheetModel->spreadsheet; - spreadsheetModel->spreadsheet = spreadsheet_ref (g_value_get_pointer (value)); - if (old) - spreadsheet_unref (old); + struct spreadsheet *old = spreadsheetModel->spreadsheet; + spreadsheetModel->spreadsheet = spreadsheet_ref (g_value_get_pointer (value)); + if (old) + spreadsheet_unref (old); } break; default: @@ -243,8 +243,8 @@ tree_model_get_value (GtkTreeModel * model, GtkTreeIter * iter, spreadsheet_get_sheet_range (spreadsheetModel->spreadsheet, (intptr_t) iter->user_data); - g_value_set_string (value, x ? x : _("(empty)")); - g_free (x); + g_value_set_string (value, x ? x : _("(empty)")); + g_free (x); } break; case PSPPIRE_SPREADSHEET_MODEL_COL_SHEET_ROWS: @@ -269,7 +269,7 @@ tree_model_get_value (GtkTreeModel * model, GtkTreeIter * iter, break; default: g_error ("%s:%d Invalid column in spreadsheet model", - __FILE__, __LINE__); + __FILE__, __LINE__); break; } } diff --git a/src/ui/gui/psppire-spreadsheet-model.h b/src/ui/gui/psppire-spreadsheet-model.h index e60e3fa99c..dae7a02657 100644 --- a/src/ui/gui/psppire-spreadsheet-model.h +++ b/src/ui/gui/psppire-spreadsheet-model.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_SPREADSHEET_MODEL (psppire_spreadsheet_model_get_type ()) -#define PSPPIRE_SPREADSHEET_MODEL(obj) \ +#define PSPPIRE_SPREADSHEET_MODEL(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_SPREADSHEET_MODEL, PsppireSpreadsheetModel)) + PSPPIRE_TYPE_SPREADSHEET_MODEL, PsppireSpreadsheetModel)) #define PSPPIRE_SPREADSHEET_MODEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_SPREADSHEET_MODEL, \ + PSPPIRE_TYPE_SPREADSHEET_MODEL, \ PsppireSpreadsheetModelClass)) #define PSPPIRE_IS_SPREADSHEET_MODEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_SPREADSHEET_MODEL)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_SPREADSHEET_MODEL)) #define PSPPIRE_IS_SPREADSHEET_MODEL_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_SPREADSHEET_MODEL)) #define PSPPIRE_SPREADSHEET_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_SPREADSHEET_MODEL, \ - PsppireSpreadsheetModelClass)) + PSPPIRE_TYPE_SPREADSHEET_MODEL, \ + PsppireSpreadsheetModelClass)) typedef struct _PsppireSpreadsheetModel PsppireSpreadsheetModel; typedef struct _PsppireSpreadsheetModelClass PsppireSpreadsheetModelClass; diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 302940d931..8939a33c77 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -179,8 +179,8 @@ psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class) null_if_empty_param ("encoding", "Character encoding", "IANA character encoding in this syntax file", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); parent_class = g_type_class_peek_parent (class); @@ -196,7 +196,7 @@ psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class) static void editor_execute_syntax (const PsppireSyntaxWindow *sw, GtkTextIter start, - GtkTextIter stop) + GtkTextIter stop) { PsppireWindow *win = PSPPIRE_WINDOW (sw); struct lex_reader *reader = lex_reader_for_gtk_text_buffer ( @@ -306,22 +306,22 @@ selection_changed (PsppireSyntaxWindow *sw) /* The callback which runs when something request clipboard data */ static void clipboard_get_cb (GtkClipboard *clipboard, - GtkSelectionData *selection_data, - guint info, - gpointer data) + GtkSelectionData *selection_data, + guint info, + gpointer data) { PsppireSyntaxWindow *sw = data; g_assert (info == SELECT_FMT_TEXT); gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), - 8, - (const guchar *) sw->cliptext, strlen (sw->cliptext)); + 8, + (const guchar *) sw->cliptext, strlen (sw->cliptext)); } static void clipboard_clear_cb (GtkClipboard *clipboard, - gpointer data) + gpointer data) { PsppireSyntaxWindow *sw = data; g_free (sw->cliptext); @@ -366,9 +366,9 @@ set_clip (PsppireSyntaxWindow *sw, GtkTextIter *begin, GtkTextIter *end) gtk_widget_get_clipboard (GTK_WIDGET (sw), GDK_SELECTION_CLIPBOARD); if (!gtk_clipboard_set_with_owner (clipboard, targets, - G_N_ELEMENTS (targets), - clipboard_get_cb, clipboard_clear_cb, - G_OBJECT (sw))) + G_N_ELEMENTS (targets), + clipboard_get_cb, clipboard_clear_cb, + G_OBJECT (sw))) clipboard_clear_cb (clipboard, sw); return TRUE; @@ -416,10 +416,10 @@ set_paste_sensitivity (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer { GdkAtom atom = gdk_atom_intern (targets[i].target, TRUE); if (gtk_clipboard_wait_is_target_available (clip, atom)) - { - compatible_target = TRUE; - break; - } + { + compatible_target = TRUE; + break; + } } g_object_set (sw->edit_paste, "enabled", compatible_target, NULL); @@ -611,8 +611,8 @@ append_suffix (const gchar *filename) */ static gboolean save_editor_to_file (PsppireSyntaxWindow *se, - const gchar *filename, - GError **err) + const gchar *filename, + GError **err) { GtkTextBuffer *buffer = GTK_TEXT_BUFFER (se->buffer); struct substring text_locale; @@ -664,11 +664,11 @@ syntax_pick_filename (PsppireWindow *window) GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Save Syntax"), - GTK_WINDOW (se), - GTK_FILE_CHOOSER_ACTION_SAVE, - _("Cancel"), GTK_RESPONSE_CANCEL, - _("Save"), GTK_RESPONSE_ACCEPT, - NULL); + GTK_WINDOW (se), + GTK_FILE_CHOOSER_ACTION_SAVE, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("Save"), GTK_RESPONSE_ACCEPT, + NULL); g_object_set (dialog, "local-only", FALSE, NULL); @@ -684,7 +684,7 @@ syntax_pick_filename (PsppireWindow *window) gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), - TRUE); + TRUE); default_encoding = se->encoding != NULL ? se->encoding : locale_charset (); gtk_file_chooser_set_extra_widget ( @@ -823,16 +823,16 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), GTK_TEXT_BUFFER (window->buffer)); g_object_set (window->buffer, - "highlight-matching-brackets", TRUE, - NULL); + "highlight-matching-brackets", TRUE, + NULL); g_object_set (text_view, - "show-line-numbers", TRUE, - "show-line-marks", TRUE, - "auto-indent", TRUE, - "indent-width", 4, - "highlight-current-line", TRUE, - NULL); + "show-line-numbers", TRUE, + "show-line-marks", TRUE, + "auto-indent", TRUE, + "indent-width", 4, + "highlight-current-line", TRUE, + NULL); window->encoding = NULL; window->syntax_mode = SEG_MODE_AUTO; @@ -863,39 +863,39 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) window->text_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->sb), "Text Context"); g_signal_connect (window->buffer, "changed", - G_CALLBACK (on_text_changed), window); + G_CALLBACK (on_text_changed), window); g_signal_connect (window->buffer, "modified-changed", - G_CALLBACK (on_modified_changed), window); + 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_CALLBACK (psppire_syntax_window_print), window); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (print)); } g_signal_connect_swapped (window->undo_menuitem, - "activate", - G_CALLBACK (undo_last_edit), - window); + "activate", + G_CALLBACK (undo_last_edit), + window); g_signal_connect_swapped (window->redo_menuitem, - "activate", + "activate", G_CALLBACK (redo_last_edit), - window); + window); undo_redo_update (window); window->sel_handler = g_signal_connect_swapped (clip_primary, "owner-change", - G_CALLBACK (selection_changed), window); + G_CALLBACK (selection_changed), window); window->ps_handler = g_signal_connect (clip_selection, "owner-change", - G_CALLBACK (set_paste_sensitivity), window); + G_CALLBACK (set_paste_sensitivity), window); gtk_container_add (GTK_CONTAINER (window), box); @@ -917,9 +917,9 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (open)); g_signal_connect_swapped (open, - "activate", - G_CALLBACK (psppire_window_open), - window); + "activate", + G_CALLBACK (psppire_window_open), + window); } { @@ -928,14 +928,14 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (save)); g_signal_connect_swapped (save, - "activate", - G_CALLBACK (psppire_window_save), - window); + "activate", + G_CALLBACK (psppire_window_save), + window); const gchar *accels[2] = { "S", NULL}; gtk_application_set_accels_for_action (app, - "win.save", - accels); + "win.save", + accels); } @@ -945,50 +945,50 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) 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), - window); + "activate", + G_CALLBACK (psppire_window_save_as), + window); const gchar *accels[2] = { "S", NULL}; gtk_application_set_accels_for_action (app, - "win.save_as", - accels); + "win.save_as", + accels); } g_signal_connect_swapped (window->edit_delete, - "activate", - G_CALLBACK (on_edit_delete), - window); + "activate", + G_CALLBACK (on_edit_delete), + window); g_signal_connect_swapped (window->edit_copy, - "activate", - G_CALLBACK (on_edit_copy), - window); + "activate", + G_CALLBACK (on_edit_copy), + window); g_signal_connect_swapped (window->edit_cut, - "activate", - G_CALLBACK (on_edit_cut), - window); + "activate", + G_CALLBACK (on_edit_cut), + window); g_signal_connect_swapped (window->edit_paste, - "activate", - G_CALLBACK (on_edit_paste), - window); + "activate", + G_CALLBACK (on_edit_paste), + window); g_signal_connect_swapped (window->edit_find, - "activate", - G_CALLBACK (on_edit_find), - window); + "activate", + G_CALLBACK (on_edit_find), + window); { GSimpleAction *run_all = g_simple_action_new ("run-all", NULL); g_signal_connect_swapped (run_all, "activate", - G_CALLBACK (on_run_all), window); + G_CALLBACK (on_run_all), window); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_all)); } @@ -997,38 +997,38 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) GSimpleAction *run_selection = g_simple_action_new ("run-selection", NULL); g_signal_connect_swapped (run_selection, "activate", - G_CALLBACK (on_run_selection), window); + G_CALLBACK (on_run_selection), window); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_selection)); GtkApplication *app = GTK_APPLICATION (g_application_get_default ()); const gchar *accels[2] = { "R", NULL}; gtk_application_set_accels_for_action (app, - "win.run-selection", - accels); + "win.run-selection", + accels); } { 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_CALLBACK (on_run_to_end), window); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_to_end)); } { GSimpleAction *act_syntax = g_simple_action_new_stateful ("syntax", G_VARIANT_TYPE_STRING, - g_variant_new_string ("auto")); + g_variant_new_string ("auto")); g_signal_connect (act_syntax, "activate", G_CALLBACK (on_syntax), window); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (act_syntax)); } gtk_menu_shell_append (GTK_MENU_SHELL (menubar), - create_windows_menu (GTK_WINDOW (window))); + create_windows_menu (GTK_WINDOW (window))); gtk_menu_shell_append (GTK_MENU_SHELL (menubar), - create_help_menu (GTK_WINDOW (window))); + create_help_menu (GTK_WINDOW (window))); g_object_unref (xml); } @@ -1041,9 +1041,9 @@ GtkWidget * psppire_syntax_window_new (const char *encoding) { GObject *sw = g_object_new (psppire_syntax_window_get_type (), - "description", _("Syntax Editor"), - "encoding", encoding, - NULL); + "description", _("Syntax Editor"), + "encoding", encoding, + NULL); GApplication *app = g_application_get_default (); gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (sw)); @@ -1058,18 +1058,18 @@ error_dialog (GtkWindow *w, const gchar *filename, GError *err) GtkWidget *dialog = gtk_message_dialog_new (w, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Cannot load syntax file `%s'"), - fn); + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Cannot load syntax file `%s'"), + fn); g_free (fn); g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", err->message); + "%s", err->message); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -1161,10 +1161,10 @@ static void undo_redo_update (PsppireSyntaxWindow *window) { g_object_set (window->undo_menuitem, "enabled", - gtk_source_buffer_can_undo (window->buffer), NULL); + gtk_source_buffer_can_undo (window->buffer), NULL); g_object_set (window->redo_menuitem, "enabled", - gtk_source_buffer_can_redo (window->buffer), NULL); + gtk_source_buffer_can_redo (window->buffer), NULL); } static void @@ -1230,8 +1230,8 @@ draw_page (GtkPrintOperation *operation, PsppireSyntaxWindow *window) { gtk_source_print_compositor_draw_page (window->compositor, - context, - page_nr); + context, + page_nr); } diff --git a/src/ui/gui/psppire-text-file.c b/src/ui/gui/psppire-text-file.c index be66a2873e..1871de94d2 100644 --- a/src/ui/gui/psppire-text-file.c +++ b/src/ui/gui/psppire-text-file.c @@ -53,77 +53,77 @@ read_lines (PsppireTextFile *tf) struct line_reader *reader = line_reader_for_file (tf->encoding, tf->file_name, O_RDONLY); if (reader == NULL) - { - msg_error (errno, _("Could not open `%s'"), tf->file_name); - return; - } + { + msg_error (errno, _("Could not open `%s'"), tf->file_name); + return; + } struct string input; ds_init_empty (&input); for (tf->n_lines = 0; tf->n_lines < MAX_PREVIEW_LINES; tf->n_lines++) - { - ds_clear (&input); - if (!line_reader_read (reader, &input, MAX_LINE_LEN + 1) - || ds_length (&input) > MAX_LINE_LEN) - { - int i; - if (line_reader_eof (reader)) - break; - else if (line_reader_error (reader)) - msg (ME, _("Error reading `%s': %s"), - tf->file_name, strerror (line_reader_error (reader))); - else - msg (ME, _("Failed to read `%s', because it contains a line " - "over %d bytes long and therefore appears not to be " - "a text file."), - tf->file_name, MAX_LINE_LEN); - line_reader_close (reader); - for (i = 0; i < tf->n_lines; i++) + { + ds_clear (&input); + if (!line_reader_read (reader, &input, MAX_LINE_LEN + 1) + || ds_length (&input) > MAX_LINE_LEN) + { + int i; + if (line_reader_eof (reader)) + break; + else if (line_reader_error (reader)) + msg (ME, _("Error reading `%s': %s"), + tf->file_name, strerror (line_reader_error (reader))); + else + msg (ME, _("Failed to read `%s', because it contains a line " + "over %d bytes long and therefore appears not to be " + "a text file."), + tf->file_name, MAX_LINE_LEN); + line_reader_close (reader); + for (i = 0; i < tf->n_lines; i++) g_free (tf->lines[i].string); - tf->n_lines = 0; - ds_destroy (&input); - return; - } - - tf->lines[tf->n_lines] - = recode_substring_pool ("UTF-8", - line_reader_get_encoding (reader), - input.ss, NULL); + tf->n_lines = 0; + ds_destroy (&input); + return; + } + + tf->lines[tf->n_lines] + = recode_substring_pool ("UTF-8", + line_reader_get_encoding (reader), + input.ss, NULL); } ds_destroy (&input); if (tf->n_lines == 0) - { - int i; - msg (ME, _("`%s' is empty."), tf->file_name); - line_reader_close (reader); - for (i = 0; i < tf->n_lines; i++) - g_free (tf->lines[i].string); - tf->n_lines = 0; - goto done; - } + { + int i; + msg (ME, _("`%s' is empty."), tf->file_name); + line_reader_close (reader); + for (i = 0; i < tf->n_lines; i++) + g_free (tf->lines[i].string); + tf->n_lines = 0; + goto done; + } if (tf->n_lines < MAX_PREVIEW_LINES) - { - tf->total_lines = tf->n_lines; - tf->total_is_exact = true; - } + { + tf->total_lines = tf->n_lines; + tf->total_is_exact = true; + } else - { - /* Estimate the number of lines in the file. */ - struct stat s; - off_t position = line_reader_tell (reader); - if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0) - { - tf->total_lines = (double) tf->n_lines / position * s.st_size; - tf->total_is_exact = false; - } - else - { - tf->total_lines = 0; - tf->total_is_exact = true; - } - } + { + /* Estimate the number of lines in the file. */ + struct stat s; + off_t position = line_reader_tell (reader); + if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0) + { + tf->total_lines = (double) tf->n_lines / position * s.st_size; + tf->total_is_exact = false; + } + else + { + tf->total_lines = 0; + tf->total_is_exact = true; + } + } done: line_reader_close (reader); } @@ -131,9 +131,9 @@ read_lines (PsppireTextFile *tf) static void psppire_text_file_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireTextFile *tf = PSPPIRE_TEXT_FILE (object); @@ -160,9 +160,9 @@ psppire_text_file_set_property (GObject *object, static void psppire_text_file_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireTextFile *text_file = PSPPIRE_TEXT_FILE (object); @@ -193,8 +193,8 @@ static GObjectClass *parent_class = NULL; static gboolean __tree_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path) + GtkTreeIter *iter, + GtkTreePath *path) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); @@ -217,7 +217,7 @@ __tree_get_iter (GtkTreeModel *tree_model, static gboolean __tree_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); g_return_val_if_fail (file->stamp == iter->stamp, FALSE); @@ -235,7 +235,7 @@ __tree_iter_next (GtkTreeModel *tree_model, static GType __tree_get_column_type (GtkTreeModel *tree_model, - gint index) + gint index) { if (index == 0) return G_TYPE_INT; @@ -245,7 +245,7 @@ __tree_get_column_type (GtkTreeModel *tree_model, static gboolean __iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { return 0; } @@ -253,15 +253,15 @@ __iter_has_child (GtkTreeModel *tree_model, static gboolean __iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) + GtkTreeIter *iter, + GtkTreeIter *child) { return 0; } static GtkTreePath * __tree_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); g_return_val_if_fail (file->stamp == iter->stamp, FALSE); @@ -283,7 +283,7 @@ __iter_children (GtkTreeModel *tree_model, static gint __tree_model_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); g_assert (iter == NULL); @@ -307,9 +307,9 @@ __tree_model_get_n_columns (GtkTreeModel *tree_model) static gboolean __iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n) + GtkTreeIter *iter, + GtkTreeIter *parent, + gint n) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); @@ -333,9 +333,9 @@ __iter_nth_child (GtkTreeModel *tree_model, static void __get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value) + GtkTreeIter *iter, + gint column, + GValue *value) { PsppireTextFile *file = PSPPIRE_TEXT_FILE (tree_model); @@ -385,8 +385,8 @@ __tree_model_init (GtkTreeModelIface *iface) } G_DEFINE_TYPE_WITH_CODE (PsppireTextFile, psppire_text_file, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, - __tree_model_init)) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + __tree_model_init)) static void psppire_text_file_class_init (PsppireTextFileClass *class) @@ -398,31 +398,31 @@ psppire_text_file_class_init (PsppireTextFileClass *class) GParamSpec *maximum_lines_spec = g_param_spec_int ("maximum-lines", - "Maximum Lines", - P_("An upper limit on the number of lines to consider"), - 0, G_MAXINT, G_MAXINT, - G_PARAM_READWRITE); + "Maximum Lines", + P_("An upper limit on the number of lines to consider"), + 0, G_MAXINT, G_MAXINT, + G_PARAM_READWRITE); GParamSpec *line_count_spec = g_param_spec_int ("line-count", - "Line Count", - P_("The number of lines in the file"), - 0, G_MAXINT, G_MAXINT, - G_PARAM_READABLE); + "Line Count", + P_("The number of lines in the file"), + 0, G_MAXINT, G_MAXINT, + G_PARAM_READABLE); GParamSpec *file_name_spec = g_param_spec_string ("file-name", - "File Name", - P_("The name of the file from which this object was constructed"), - NULL, - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + "File Name", + P_("The name of the file from which this object was constructed"), + NULL, + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); GParamSpec *encoding_spec = g_param_spec_string ("encoding", - "Character Encoding", - P_("The character encoding of the file from which this object was constructed"), - "unset", - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + "Character Encoding", + P_("The character encoding of the file from which this object was constructed"), + "unset", + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); object_class->set_property = psppire_text_file_set_property; object_class->get_property = psppire_text_file_get_property; @@ -463,9 +463,9 @@ psppire_text_file_new (const gchar *file_name, const gchar *encoding) { PsppireTextFile *retval = g_object_new (PSPPIRE_TYPE_TEXT_FILE, - "file-name", file_name, - "encoding", encoding, - NULL); + "file-name", file_name, + "encoding", encoding, + NULL); return retval; } diff --git a/src/ui/gui/psppire-text-file.h b/src/ui/gui/psppire-text-file.h index 320b621b18..e4785f15d3 100644 --- a/src/ui/gui/psppire-text-file.h +++ b/src/ui/gui/psppire-text-file.h @@ -25,9 +25,9 @@ G_BEGIN_DECLS -#define PSPPIRE_TYPE_TEXT_FILE (psppire_text_file_get_type ()) +#define PSPPIRE_TYPE_TEXT_FILE (psppire_text_file_get_type ()) -#define PSPPIRE_TEXT_FILE(obj) \ +#define PSPPIRE_TEXT_FILE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ PSPPIRE_TYPE_TEXT_FILE, PsppireTextFile)) diff --git a/src/ui/gui/psppire-val-chooser.c b/src/ui/gui/psppire-val-chooser.c index 95f193ec0d..2c284c83db 100644 --- a/src/ui/gui/psppire-val-chooser.c +++ b/src/ui/gui/psppire-val-chooser.c @@ -64,9 +64,9 @@ enum static void psppire_val_chooser_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireValChooser *vr = PSPPIRE_VAL_CHOOSER (object); @@ -74,9 +74,9 @@ psppire_val_chooser_set_property (GObject *object, { case PROP_SHOW_ELSE: { - gboolean x = g_value_get_boolean (value); - gtk_widget_set_visible (GTK_WIDGET (vr->rw[VC_ELSE].rb), x); - gtk_widget_set_visible (GTK_WIDGET (vr->rw[VC_ELSE].label), x); + gboolean x = g_value_get_boolean (value); + gtk_widget_set_visible (GTK_WIDGET (vr->rw[VC_ELSE].rb), x); + gtk_widget_set_visible (GTK_WIDGET (vr->rw[VC_ELSE].label), x); } break; case PROP_IS_STRING: @@ -96,9 +96,9 @@ psppire_val_chooser_set_property (GObject *object, static void psppire_val_chooser_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireValChooser *vr = PSPPIRE_VAL_CHOOSER (object); @@ -106,9 +106,9 @@ psppire_val_chooser_get_property (GObject *object, { case PROP_SHOW_ELSE: { - gboolean x = - gtk_widget_get_visible (GTK_WIDGET (vr->rw[VC_ELSE].rb)); - g_value_set_boolean (value, x); + gboolean x = + gtk_widget_get_visible (GTK_WIDGET (vr->rw[VC_ELSE].rb)); + g_value_set_boolean (value, x); } break; case PROP_IS_STRING: @@ -133,17 +133,17 @@ psppire_val_chooser_class_init (PsppireValChooserClass *class) GParamSpec *is_string_spec = g_param_spec_boolean ("is-string", - "String Value", - "Should the value range be a string value", - FALSE, - G_PARAM_READWRITE); + "String Value", + "Should the value range be a string value", + FALSE, + G_PARAM_READWRITE); GParamSpec *show_else_spec = g_param_spec_boolean ("show-else", - "Show Else", - "Should the \"All other values\" item be visible", - TRUE, - G_PARAM_READWRITE); + "Show Else", + "Should the \"All other values\" item be visible", + TRUE, + G_PARAM_READWRITE); parent_class = g_type_class_peek_parent (class); @@ -258,9 +258,9 @@ static GtkWidget * range_entry (struct layout *l, struct range_widgets *rw) rw->e2 = GTK_ENTRY (entryhi); g_object_set (G_OBJECT (label), - "valign", GTK_ALIGN_CENTER, - "halign", GTK_ALIGN_START, - NULL); + "valign", GTK_ALIGN_CENTER, + "halign", GTK_ALIGN_START, + NULL); g_signal_connect (vbox, "notify::sensitive", G_CALLBACK (focus_follows_sensitivity), entrylo); @@ -302,9 +302,9 @@ psppire_val_chooser_init (PsppireValChooser *vr) gint row = 0; g_object_set (G_OBJECT (grid), - "margin-start", 5, - "margin-end", 5, - NULL); + "margin-start", 5, + "margin-end", 5, + NULL); vr->input_var_is_string = FALSE; @@ -317,21 +317,21 @@ psppire_val_chooser_init (PsppireValChooser *vr) gtk_label_set_mnemonic_widget (vr->rw[i].label, GTK_WIDGET (vr->rw[i].rb)); g_object_set (G_OBJECT (vr->rw[i].label), - "valign", GTK_ALIGN_CENTER, - "halign", GTK_ALIGN_START, - NULL); + "valign", GTK_ALIGN_CENTER, + "halign", GTK_ALIGN_START, + NULL); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (vr->rw[i].rb)); /* Attach the buttons */ gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (vr->rw[i].rb), - 0, row, 1, 1); + 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); + 1, row, 1, 1); gtk_widget_set_hexpand (GTK_WIDGET (vr->rw[i].label), TRUE); @@ -339,19 +339,19 @@ psppire_val_chooser_init (PsppireValChooser *vr) ++row; if (l->fill) - { - GtkWidget *fill = l->fill (l, &vr->rw[i]); + { + GtkWidget *fill = l->fill (l, &vr->rw[i]); - gtk_widget_set_sensitive (fill, FALSE); + gtk_widget_set_sensitive (fill, FALSE); - gtk_grid_attach (GTK_GRID (grid), fill, 1, row, 1, 1); + gtk_grid_attach (GTK_GRID (grid), fill, 1, row, 1, 1); - gtk_widget_set_hexpand (fill, TRUE); + gtk_widget_set_hexpand (fill, TRUE); - ++row; + ++row; - g_signal_connect (vr->rw[i].rb, "toggled", G_CALLBACK (set_sensitivity_from_toggle), fill); - } + g_signal_connect (vr->rw[i].rb, "toggled", G_CALLBACK (set_sensitivity_from_toggle), fill); + } } gtk_frame_set_shadow_type (GTK_FRAME (vr), GTK_SHADOW_ETCHED_IN); @@ -409,9 +409,9 @@ old_value_to_string (const GValue *src, GValue *dest) { case OV_NUMERIC: { - gchar *text = g_strdup_printf ("%.*g", DBL_DIG + 1, ov->v.v); - g_value_set_string (dest, text); - g_free (text); + gchar *text = g_strdup_printf ("%.*g", DBL_DIG + 1, ov->v.v); + g_value_set_string (dest, text); + g_free (text); } break; case OV_STRING: @@ -428,47 +428,47 @@ old_value_to_string (const GValue *src, GValue *dest) break; case OV_RANGE: { - gchar *text; - char en_dash[6] = {0,0,0,0,0,0}; + gchar *text; + char en_dash[6] = {0,0,0,0,0,0}; - g_unichar_to_utf8 (0x2013, en_dash); + g_unichar_to_utf8 (0x2013, en_dash); - text = g_strdup_printf ("%.*g %s %.*g", + text = g_strdup_printf ("%.*g %s %.*g", DBL_DIG + 1, ov->v.range[0], en_dash, DBL_DIG + 1, ov->v.range[1]); - g_value_set_string (dest, text); - g_free (text); + g_value_set_string (dest, text); + g_free (text); } break; case OV_LOW_UP: { - gchar *text; - char en_dash[6] = {0,0,0,0,0,0}; + gchar *text; + char en_dash[6] = {0,0,0,0,0,0}; - g_unichar_to_utf8 (0x2013, en_dash); + g_unichar_to_utf8 (0x2013, en_dash); - text = g_strdup_printf ("LOWEST %s %.*g", - en_dash, - DBL_DIG + 1, ov->v.range[1]); + text = g_strdup_printf ("LOWEST %s %.*g", + en_dash, + DBL_DIG + 1, ov->v.range[1]); - g_value_set_string (dest, text); - g_free (text); + g_value_set_string (dest, text); + g_free (text); } break; case OV_HIGH_DOWN: { - gchar *text; - char en_dash[6] = {0,0,0,0,0,0}; + gchar *text; + char en_dash[6] = {0,0,0,0,0,0}; - g_unichar_to_utf8 (0x2013, en_dash); + g_unichar_to_utf8 (0x2013, en_dash); - text = g_strdup_printf ("%.*g %s HIGHEST", - DBL_DIG + 1, ov->v.range[0], - en_dash); + text = g_strdup_printf ("%.*g %s HIGHEST", + DBL_DIG + 1, ov->v.range[0], + en_dash); - g_value_set_string (dest, text); - g_free (text); + g_value_set_string (dest, text); + g_free (text); } break; default: @@ -486,11 +486,11 @@ old_value_get_type (void) if (t == 0) { t = g_boxed_type_register_static ("psppire-recode-old-values", - (GBoxedCopyFunc) old_value_copy, - (GBoxedFreeFunc) old_value_free); + (GBoxedCopyFunc) old_value_copy, + (GBoxedFreeFunc) old_value_free); g_value_register_transform_func (t, G_TYPE_STRING, - old_value_to_string); + old_value_to_string); } return t; @@ -509,10 +509,10 @@ old_value_append_syntax (struct string *str, const struct old_value *ov) break; case OV_STRING: { - struct string ds = DS_EMPTY_INITIALIZER; - syntax_gen_string (&ds, ss_cstr (ov->v.s)); - ds_put_cstr (str, ds_cstr (&ds)); - ds_destroy (&ds); + struct string ds = DS_EMPTY_INITIALIZER; + syntax_gen_string (&ds, ss_cstr (ov->v.s)); + ds_put_cstr (str, ds_cstr (&ds)); + ds_destroy (&ds); } break; case OV_MISSING: @@ -555,10 +555,10 @@ psppire_val_chooser_get_status (PsppireValChooser *vr, struct old_value *ov) for (i = 0; i < n_VAL_CHOOSER_BUTTONS; ++i) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (vr->rw[i].rb))) - { - range_opt[i].set (vr, ov, &vr->rw[i]); - break; - } + { + range_opt[i].set (vr, ov, &vr->rw[i]); + break; + } } } @@ -583,10 +583,10 @@ psppire_val_chooser_set_status (PsppireValChooser *vr, const struct old_value *o for (i = 0; i < n_VAL_CHOOSER_BUTTONS; ++i) { if (vr->rw[i].e1) - gtk_entry_set_text (vr->rw[i].e1, ""); + gtk_entry_set_text (vr->rw[i].e1, ""); if (vr->rw[i].e2) - gtk_entry_set_text (vr->rw[i].e2, ""); + gtk_entry_set_text (vr->rw[i].e2, ""); } switch (ov->type) @@ -598,66 +598,66 @@ psppire_val_chooser_set_status (PsppireValChooser *vr, const struct old_value *o case OV_NUMERIC: { - gchar *str; - gtk_toggle_button_set_active (vr->rw[0].rb, TRUE); + gchar *str; + gtk_toggle_button_set_active (vr->rw[0].rb, TRUE); - str = num_to_string (ov->v.v); + str = num_to_string (ov->v.v); - gtk_entry_set_text (vr->rw[0].e1, str); - g_free (str); + gtk_entry_set_text (vr->rw[0].e1, str); + g_free (str); } break; case OV_SYSMIS: - gtk_toggle_button_set_active (vr->rw[VC_SYSMIS].rb, TRUE); - break; + gtk_toggle_button_set_active (vr->rw[VC_SYSMIS].rb, TRUE); + break; case OV_MISSING: - gtk_toggle_button_set_active (vr->rw[VC_MISSING].rb, TRUE); - break; + gtk_toggle_button_set_active (vr->rw[VC_MISSING].rb, TRUE); + break; case OV_RANGE: - { - gchar *str = num_to_string (ov->v.range[0]); - gtk_toggle_button_set_active (vr->rw[VC_RANGE].rb, TRUE); - gtk_entry_set_text (vr->rw[VC_RANGE].e1, str); + { + gchar *str = num_to_string (ov->v.range[0]); + gtk_toggle_button_set_active (vr->rw[VC_RANGE].rb, TRUE); + gtk_entry_set_text (vr->rw[VC_RANGE].e1, str); - g_free (str); + g_free (str); - str = num_to_string (ov->v.range[1]); - gtk_entry_set_text (vr->rw[VC_RANGE].e2, str); - g_free (str); - } - break; + str = num_to_string (ov->v.range[1]); + gtk_entry_set_text (vr->rw[VC_RANGE].e2, str); + g_free (str); + } + break; case OV_LOW_UP: - { - gchar *str = num_to_string (ov->v.range[1]); + { + gchar *str = num_to_string (ov->v.range[1]); - gtk_toggle_button_set_active (vr->rw[VC_LOW_UP].rb, TRUE); + gtk_toggle_button_set_active (vr->rw[VC_LOW_UP].rb, TRUE); - gtk_entry_set_text (vr->rw[VC_LOW_UP].e1, str); + gtk_entry_set_text (vr->rw[VC_LOW_UP].e1, str); - g_free (str); - } - break; + g_free (str); + } + break; case OV_HIGH_DOWN: - { - gchar *str = num_to_string (ov->v.range[0]); + { + gchar *str = num_to_string (ov->v.range[0]); - gtk_toggle_button_set_active (vr->rw[VC_HIGH_DOWN].rb, TRUE); + gtk_toggle_button_set_active (vr->rw[VC_HIGH_DOWN].rb, TRUE); - gtk_entry_set_text (vr->rw[VC_HIGH_DOWN].e1, str); + gtk_entry_set_text (vr->rw[VC_HIGH_DOWN].e1, str); - g_free (str); - } - break; + g_free (str); + } + break; case OV_ELSE: - gtk_toggle_button_set_active (vr->rw[VC_ELSE].rb, TRUE); - break; + gtk_toggle_button_set_active (vr->rw[VC_ELSE].rb, TRUE); + break; default: g_warning ("Unknown old value type"); diff --git a/src/ui/gui/psppire-value-entry.c b/src/ui/gui/psppire-value-entry.c index f3d7f99a8e..ae9f08c293 100644 --- a/src/ui/gui/psppire-value-entry.c +++ b/src/ui/gui/psppire-value-entry.c @@ -179,8 +179,8 @@ on_realize (GtkWidget *w) */ static GObject* my_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) + guint n_construct_properties, + GObjectConstructParam *construct_properties) { GObject *o = G_OBJECT_CLASS (psppire_value_entry_parent_class)->constructor @@ -263,13 +263,13 @@ psppire_value_entry_class_init (PsppireValueEntryClass *class) signals [EDIT_DONE] = g_signal_new ("edit-done", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); } static void diff --git a/src/ui/gui/psppire-var-ptr.c b/src/ui/gui/psppire-var-ptr.c index a5511ec31f..073ac2e6c4 100644 --- a/src/ui/gui/psppire-var-ptr.c +++ b/src/ui/gui/psppire-var-ptr.c @@ -45,7 +45,7 @@ variable_free (gpointer var) /* Convert to a string, by using the variable's name */ static void variable_to_string (const GValue *src, - GValue *dest) + GValue *dest) { const struct variable *v = g_value_get_boxed (src); @@ -59,7 +59,7 @@ variable_to_string (const GValue *src, /* Convert to an int, using the dictionary index. */ static void variable_to_int (const GValue *src, - GValue *dest) + GValue *dest) { const struct variable *v = g_value_get_boxed (src); @@ -80,14 +80,14 @@ psppire_var_ptr_get_type (void) if (t == 0) { t = g_boxed_type_register_static ("psppire-var-ptr", - (GBoxedCopyFunc) variable_copy, - (GBoxedFreeFunc) variable_free); + (GBoxedCopyFunc) variable_copy, + (GBoxedFreeFunc) variable_free); g_value_register_transform_func (t, G_TYPE_STRING, - variable_to_string); + variable_to_string); g_value_register_transform_func (t, G_TYPE_INT, - variable_to_int); + variable_to_int); } diff --git a/src/ui/gui/psppire-var-sheet-header.c b/src/ui/gui/psppire-var-sheet-header.c index c40b0aa381..144f841605 100644 --- a/src/ui/gui/psppire-var-sheet-header.c +++ b/src/ui/gui/psppire-var-sheet-header.c @@ -123,12 +123,12 @@ psppire_var_sheet_header_class_init (PsppireVarSheetHeaderClass *dc) /* This signal is never emitted. It is just to satisfy the interface. */ signals [CHANGED] = g_signal_new ("changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); } diff --git a/src/ui/gui/psppire-var-view.c b/src/ui/gui/psppire-var-view.c index 0a020008fb..4f3ffca4c7 100644 --- a/src/ui/gui/psppire-var-view.c +++ b/src/ui/gui/psppire-var-view.c @@ -50,7 +50,7 @@ var_view_contains_var (PsppireSelectDestWidget *sdm, const GValue *v) { const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter); if (var == g_value_get_boxed (v)) - return TRUE; + return TRUE; } return FALSE; @@ -97,10 +97,10 @@ enum */ static void display_cell_var_name (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *treemodel, - GtkTreeIter *iter, - gpointer data) + GtkCellRenderer *cell, + GtkTreeModel *treemodel, + GtkTreeIter *iter, + gpointer data) { struct variable *var; GValue value = {0}; @@ -122,9 +122,9 @@ display_cell_var_name (GtkTreeViewColumn *tree_column, static void psppire_var_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object); @@ -163,8 +163,8 @@ set_renderers (PsppireVarView *var_view) 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); + display_cell_var_name, + &var_view->nums[c], 0); gtk_tree_view_append_column (GTK_TREE_VIEW (var_view), col); } @@ -179,9 +179,9 @@ psppire_var_view_get_current_model (PsppireVarView *vv) static void psppire_var_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object); @@ -189,17 +189,17 @@ psppire_var_view_set_property (GObject *object, { case PROP_N_COLS: { - gint c; - var_view->n_cols = g_value_get_int (value); + gint c; + var_view->n_cols = g_value_get_int (value); - var_view->cols = g_realloc (var_view->cols, sizeof (GType) * var_view->n_cols); + var_view->cols = g_realloc (var_view->cols, sizeof (GType) * var_view->n_cols); - for (c = 0 ; c < var_view->n_cols; ++c) - var_view->cols[c] = PSPPIRE_VAR_PTR_TYPE; + for (c = 0 ; c < var_view->n_cols; ++c) + var_view->cols[c] = PSPPIRE_VAR_PTR_TYPE; - set_renderers (var_view); + set_renderers (var_view); - psppire_var_view_clear (var_view); + psppire_var_view_clear (var_view); } break; default: @@ -217,11 +217,11 @@ psppire_var_view_class_init (PsppireVarViewClass *class) GParamSpec *n_cols_spec = g_param_spec_int ("n-cols", - "Number of columns", - "The Number of Columns in the Variable View", - 1, 20, - 1, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE | G_PARAM_WRITABLE); + "Number of columns", + "The Number of Columns in the Variable View", + 1, 20, + 1, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE | G_PARAM_WRITABLE); object_class->set_property = psppire_var_view_set_property; @@ -275,7 +275,7 @@ psppire_var_view_get_var_from_model (GtkTreeModel *model, gint column, GtkTreeIt var = g_value_get_boxed (&value); else g_critical ("Unsupported type `%s', in variable name treeview.", - G_VALUE_TYPE_NAME (&value)); + G_VALUE_TYPE_NAME (&value)); g_value_unset (&value); @@ -304,13 +304,13 @@ psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string) if (psppire_var_view_get_iter_first (vv, &iter)) { do - { - const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); - g_string_append (string, " "); - g_string_append (string, var_get_name (var)); + { + const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); + g_string_append (string, " "); + g_string_append (string, var_get_name (var)); - n_vars++; - } + n_vars++; + } while (psppire_var_view_get_iter_next (vv, &iter)); } @@ -332,10 +332,10 @@ psppire_var_view_list_names (PsppireVarView *vv, gint column) if (psppire_var_view_get_iter_first (vv, &iter)) { do - { - const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); - list = g_slist_prepend (list, CONST_CAST (struct variable *, var)); - } + { + const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); + list = g_slist_prepend (list, CONST_CAST (struct variable *, var)); + } while (psppire_var_view_get_iter_next (vv, &iter)); } @@ -356,13 +356,13 @@ psppire_var_view_append_names_str (PsppireVarView *vv, gint column, struct strin if (psppire_var_view_get_iter_first (vv, &iter)) { do - { - const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); - ds_put_cstr (str, " "); - ds_put_cstr (str, var_get_name (var)); + { + const struct variable *var = psppire_var_view_get_variable (vv, column, &iter); + ds_put_cstr (str, " "); + ds_put_cstr (str, var_get_name (var)); - n_vars++; - } + n_vars++; + } while (psppire_var_view_get_iter_next (vv, &iter)); } diff --git a/src/ui/gui/psppire-variable-sheet.c b/src/ui/gui/psppire-variable-sheet.c index ffd6a167bd..5181b70d11 100644 --- a/src/ui/gui/psppire-variable-sheet.c +++ b/src/ui/gui/psppire-variable-sheet.c @@ -75,7 +75,7 @@ set_missing_values (PsppireVariableSheet *sheet) struct missing_values mv; if (GTK_RESPONSE_OK == psppire_missing_val_dialog_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sheet))), - var, &mv)) + var, &mv)) { var_set_missing_values (var, &mv); } @@ -114,12 +114,12 @@ create_spin_renderer (GType type) GtkCellRenderer *r = gtk_cell_renderer_spin_new (); GtkAdjustment *adj = gtk_adjustment_new (0, - 0, G_MAXDOUBLE, - 1, 1, - 0); + 0, G_MAXDOUBLE, + 1, 1, + 0); g_object_set (r, - "adjustment", adj, - NULL); + "adjustment", adj, + NULL); return r; } @@ -139,18 +139,18 @@ create_combo_renderer (GType type) gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, - 0, ev->value, - 1, gettext (ev->value_nick), - -1); + 0, ev->value, + 1, gettext (ev->value_nick), + -1); } GtkCellRenderer *r = gtk_cell_renderer_combo_new (); g_object_set (r, - "model", list_store, - "text-column", 1, - "has-entry", TRUE, - NULL); + "model", list_store, + "text-column", 1, + "has-entry", TRUE, + NULL); return r; } @@ -208,7 +208,7 @@ select_renderer_func (PsppireVariableSheet *sheet, gint col, gint row, GType typ static void show_variables_row_popup (SswSheet *sheet, int row, guint button, - guint state, gpointer p) + guint state, gpointer p) { PsppireVariableSheet *var_sheet = PSPPIRE_VARIABLE_SHEET (sheet); GListModel *vmodel = NULL; @@ -225,7 +225,7 @@ show_variables_row_popup (SswSheet *sheet, int row, guint button, return; g_object_set_data (G_OBJECT (var_sheet->row_popup), "item", - GINT_TO_POINTER (row)); + GINT_TO_POINTER (row)); gtk_menu_popup_at_pointer (GTK_MENU (var_sheet->row_popup), NULL); } @@ -234,8 +234,8 @@ static void insert_new_variable_var (PsppireVariableSheet *var_sheet) { gint item = GPOINTER_TO_INT (g_object_get_data - (G_OBJECT (var_sheet->row_popup), - "item")); + (G_OBJECT (var_sheet->row_popup), + "item")); PsppireDict *dict = NULL; g_object_get (var_sheet, "data-model", &dict, NULL); @@ -262,7 +262,7 @@ delete_variables (SswSheet *sheet) } psppire_dict_delete_variables (dict, range->start_y, - (range->end_y - range->start_y + 1)); + (range->end_y - range->start_y + 1)); gtk_widget_queue_draw (GTK_WIDGET (sheet)); } @@ -279,7 +279,7 @@ create_var_row_header_popup_menu (PsppireVariableSheet *var_sheet) GtkWidget *item = gtk_menu_item_new_with_mnemonic (_("_Insert Variable")); g_signal_connect_swapped (item, "activate", G_CALLBACK (insert_new_variable_var), - var_sheet); + var_sheet); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_separator_menu_item_new (); @@ -289,11 +289,11 @@ create_var_row_header_popup_menu (PsppireVariableSheet *var_sheet) gtk_menu_item_new_with_mnemonic (_("Cl_ear Variables")); g_signal_connect_swapped (var_sheet->clear_variables_menu_item, "activate", - G_CALLBACK (delete_variables), var_sheet); + G_CALLBACK (delete_variables), var_sheet); gtk_widget_set_sensitive (var_sheet->clear_variables_menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), - var_sheet->clear_variables_menu_item); + var_sheet->clear_variables_menu_item); gtk_widget_show_all (menu); return menu; @@ -308,10 +308,10 @@ set_var_popup_sensitivity (SswSheet *sheet, gpointer selection, gpointer p) gint width = gtk_tree_model_get_n_columns (sheet->data_model); gboolean whole_row_selected = (range->start_x == 0 && - range->end_x == width - 1 - 1); + range->end_x == width - 1 - 1); /* PsppireDict has an "extra" column: TVM_COL_VAR ^^^ */ gtk_widget_set_sensitive (var_sheet->clear_variables_menu_item, - whole_row_selected); + whole_row_selected); } @@ -338,9 +338,9 @@ change_var_property (PsppireVariableSheet *var_sheet, gint col, gint row, const { case DICT_TVM_COL_NAME: { - const char *name = g_value_get_string (value); - if (psppire_dict_check_name (dict, name)) - dict_rename_var (dict->dict, var, g_value_get_string (value)); + const char *name = g_value_get_string (value); + if (psppire_dict_check_name (dict, name)) + dict_rename_var (dict->dict, var, g_value_get_string (value)); } break; case DICT_TVM_COL_WIDTH: @@ -349,13 +349,13 @@ change_var_property (PsppireVariableSheet *var_sheet, gint col, gint row, const if (var_is_numeric (var)) { struct fmt_spec format = var_get_print_format (var); - fmt_change_width (&format, width, FMT_FOR_OUTPUT); + fmt_change_width (&format, width, FMT_FOR_OUTPUT); var_set_both_formats (var, format); } else - { - var_set_width (var, width); - } + { + var_set_width (var, width); + } } break; case DICT_TVM_COL_DECIMAL: @@ -364,7 +364,7 @@ change_var_property (PsppireVariableSheet *var_sheet, gint col, gint row, const if (decimals >= 0) { struct fmt_spec format = var_get_print_format (var); - fmt_change_decimals (&format, decimals, FMT_FOR_OUTPUT); + fmt_change_decimals (&format, decimals, FMT_FOR_OUTPUT); var_set_both_formats (var, format); } } @@ -386,14 +386,14 @@ change_var_property (PsppireVariableSheet *var_sheet, gint col, gint row, const break; default: g_warning ("Changing unknown column %d of variable sheet column not supported", - col); + col); break; } } static gchar * var_sheet_data_to_string (SswSheet *sheet, GtkTreeModel *m, - gint col, gint row, const GValue *in) + gint col, gint row, const GValue *in) { if (col >= n_DICT_COLS - 1) /* -1 because psppire-dict has an extra column */ return NULL; @@ -413,12 +413,12 @@ var_sheet_data_to_string (SswSheet *sheet, GtkTreeModel *m, { const struct val_labs *vls = var_get_value_labels (var); if (vls == NULL || val_labs_count (vls) == 0) - return strdup (_("None")); + return strdup (_("None")); const struct val_lab **labels = val_labs_sorted (vls); const struct val_lab *vl = labels[0]; gchar *vstr = value_to_text (vl->value, var); char *text = xasprintf (_("{%s, %s}..."), vstr, - val_lab_get_escaped_label (vl)); + val_lab_get_escaped_label (vl)); free (vstr); free (labels); return text; @@ -578,9 +578,9 @@ on_edit_start (GtkCellRenderer *renderer, { gtk_widget_grab_focus (GTK_WIDGET (editable)); g_signal_connect (editable, "key-press-event", - G_CALLBACK (on_key_press), user_data); + G_CALLBACK (on_key_press), user_data); g_signal_connect (editable, "button-press-event", - G_CALLBACK (on_button_press), user_data); + G_CALLBACK (on_button_press), user_data); } @@ -594,38 +594,38 @@ psppire_variable_sheet_init (PsppireVariableSheet *sheet) sheet->value_label_dispatch->sheet = sheet; sheet->value_label_dispatch->payload = set_value_labels; g_signal_connect_after (sheet->value_label_renderer, - "editing-started", G_CALLBACK (on_edit_start), - sheet->value_label_dispatch); + "editing-started", G_CALLBACK (on_edit_start), + sheet->value_label_dispatch); sheet->missing_values_renderer = gtk_cell_renderer_text_new (); sheet->missing_values_dispatch = g_malloc (sizeof *sheet->missing_values_dispatch); sheet->missing_values_dispatch->sheet = sheet; sheet->missing_values_dispatch->payload = set_missing_values; g_signal_connect_after (sheet->missing_values_renderer, - "editing-started", G_CALLBACK (on_edit_start), - sheet->missing_values_dispatch); + "editing-started", G_CALLBACK (on_edit_start), + sheet->missing_values_dispatch); sheet->var_type_renderer = gtk_cell_renderer_text_new (); sheet->var_type_dispatch = g_malloc (sizeof *sheet->var_type_dispatch); sheet->var_type_dispatch->sheet = sheet; sheet->var_type_dispatch->payload = set_var_type; g_signal_connect_after (sheet->var_type_renderer, - "editing-started", G_CALLBACK (on_edit_start), - sheet->var_type_dispatch); + "editing-started", G_CALLBACK (on_edit_start), + sheet->var_type_dispatch); sheet->row_popup = create_var_row_header_popup_menu (sheet); g_signal_connect (sheet, "selection-changed", - G_CALLBACK (set_var_popup_sensitivity), sheet); + G_CALLBACK (set_var_popup_sensitivity), sheet); g_signal_connect (sheet, "row-header-pressed", G_CALLBACK (show_variables_row_popup), sheet); g_signal_connect_swapped (sheet, "value-changed", - G_CALLBACK (change_var_property), sheet); + G_CALLBACK (change_var_property), sheet); g_signal_connect (sheet, "row-moved", - G_CALLBACK (move_variable), NULL); + G_CALLBACK (move_variable), NULL); PsppireVarSheetHeader *vsh = g_object_new (PSPPIRE_TYPE_VAR_SHEET_HEADER, NULL); diff --git a/src/ui/gui/psppire-window-register.c b/src/ui/gui/psppire-window-register.c index 2bf0c94ff7..f65ccec2d9 100644 --- a/src/ui/gui/psppire-window-register.c +++ b/src/ui/gui/psppire-window-register.c @@ -48,8 +48,8 @@ static PsppireWindowRegister *the_instance = NULL; static GObject* psppire_window_register_construct (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) + guint n_construct_params, + GObjectConstructParam *construct_params) { GObject *object; @@ -80,25 +80,25 @@ psppire_window_register_class_init (PsppireWindowRegisterClass *class) signals [INSERTED] = g_signal_new ("inserted", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); signals [REMOVED] = g_signal_new ("removed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); } static void @@ -130,7 +130,7 @@ psppire_window_register_lookup (PsppireWindowRegister *wr, const gchar *name) void psppire_window_register_foreach (PsppireWindowRegister *wr, - GHFunc func, gpointer data) + GHFunc func, gpointer data) { g_hash_table_foreach (wr->name_table, func, data); } diff --git a/src/ui/gui/psppire-window-register.h b/src/ui/gui/psppire-window-register.h index fdc6551926..43d0db31d2 100644 --- a/src/ui/gui/psppire-window-register.h +++ b/src/ui/gui/psppire-window-register.h @@ -28,26 +28,26 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_WINDOW_REGISTER (psppire_window_register_get_type ()) -#define PSPPIRE_WINDOW_REGISTER(obj) \ +#define PSPPIRE_WINDOW_REGISTER(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - PSPPIRE_TYPE_WINDOW_REGISTER, PsppireWindowRegister)) + PSPPIRE_TYPE_WINDOW_REGISTER, PsppireWindowRegister)) #define PSPPIRE_WINDOW_REGISTER_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ - PSPPIRE_TYPE_WINDOW_REGISTER, \ + PSPPIRE_TYPE_WINDOW_REGISTER, \ PsppireWindowRegisterClass)) #define PSPPIRE_IS_WINDOW_REGISTER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_WINDOW_REGISTER)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_WINDOW_REGISTER)) #define PSPPIRE_IS_WINDOW_REGISTER_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_WINDOW_REGISTER)) #define PSPPIRE_WINDOW_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - PSPPIRE_TYPE_WINDOW_REGISTER, \ - PsppireWindowRegisterClass)) + PSPPIRE_TYPE_WINDOW_REGISTER, \ + PsppireWindowRegisterClass)) typedef struct _PsppireWindowRegister PsppireWindowRegister; typedef struct _PsppireWindowRegisterClass PsppireWindowRegisterClass; @@ -73,7 +73,7 @@ GType psppire_window_register_get_type (void) G_GNUC_CONST; PsppireWindowRegister * psppire_window_register_new (void); void psppire_window_register_insert (PsppireWindowRegister *wr, PsppireWindow *window, - const gchar *name); + const gchar *name); void psppire_window_register_remove (PsppireWindowRegister *wr, const gchar *name); @@ -82,7 +82,7 @@ PsppireWindow *psppire_window_register_lookup (PsppireWindowRegister *wr, const void psppire_window_register_foreach (PsppireWindowRegister *wr, GHFunc func, - gpointer); + gpointer); gint psppire_window_register_n_items (PsppireWindowRegister *wr); diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index b636aa18e4..7a866cd5e4 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -147,9 +147,9 @@ psppire_window_name_changed (PsppireWindow *window) static void psppire_window_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { PsppireWindow *window = PSPPIRE_WINDOW (object); @@ -183,9 +183,9 @@ psppire_window_set_property (GObject *object, static void psppire_window_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { PsppireWindow *window = PSPPIRE_WINDOW (object); @@ -241,25 +241,25 @@ psppire_window_class_init (PsppireWindowClass *class) GParamSpec *description_spec = null_if_empty_param ("description", - "Description", - "A string describing the usage of the window", - NULL, /*Should be overridden by derived classes */ - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + "Description", + "A string describing the usage of the window", + NULL, /*Should be overridden by derived classes */ + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); GParamSpec *filename_spec = null_if_empty_param ("filename", - "File name", - "The name of the file associated with this window, if any", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + "File name", + "The name of the file associated with this window, if any", + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); GParamSpec *id_spec = null_if_empty_param ("id", "Identifier", "The PSPP language identifier for the data associated " "with this window (e.g. dataset name)", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); object_class->set_property = psppire_window_set_property; object_class->get_property = psppire_window_get_property; @@ -338,22 +338,22 @@ on_delete (PsppireWindow *w, GdkEvent *event, gpointer user_data) gint response = psppire_window_query_save (w); switch (response) - { - default: - case GTK_RESPONSE_CANCEL: - return TRUE; - break; - case GTK_RESPONSE_APPLY: - psppire_window_save (w); + { + default: + case GTK_RESPONSE_CANCEL: + return TRUE; + break; + case GTK_RESPONSE_APPLY: + psppire_window_save (w); if (w->edited != NULL) { /* Save failed, or user exited Save As dialog with Cancel. */ return TRUE; } - break; - case GTK_RESPONSE_REJECT: - break; - } + break; + case GTK_RESPONSE_REJECT: + break; + } } if (1 == psppire_window_register_n_items (reg)) @@ -381,14 +381,14 @@ psppire_window_init (PsppireWindow *window) PsppireWindowRegister *reg = psppire_window_register_new (); window->insert_handler = g_signal_connect (reg, - "inserted", - G_CALLBACK (insert_menuitem), - window); + "inserted", + G_CALLBACK (insert_menuitem), + window); window->remove_handler = g_signal_connect (reg, - "removed", - G_CALLBACK (remove_menuitem), - window); + "removed", + G_CALLBACK (remove_menuitem), + window); window->added_separator = FALSE; @@ -422,30 +422,30 @@ psppire_window_query_save (PsppireWindow *se) description = g_strdup (se->description); dialog = gtk_message_dialog_new (GTK_WINDOW (se), - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_NONE, - _("Save the changes to `%s' before closing?"), - description); + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_NONE, + _("Save the changes to `%s' before closing?"), + description); g_free (description); g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("If you don't save, changes from the last %ld seconds will be permanently lost."), - (long int) (timespan / G_TIME_SPAN_SECOND)); + _("If you don't save, changes from the last %ld seconds will be permanently lost."), + (long int) (timespan / G_TIME_SPAN_SECOND)); gtk_dialog_add_button (GTK_DIALOG (dialog), - _("Close _without saving"), - GTK_RESPONSE_REJECT); + _("Close _without saving"), + GTK_RESPONSE_REJECT); cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), - _("Cancel"), - GTK_RESPONSE_CANCEL); + _("Cancel"), + GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (dialog), - _("Save"), - GTK_RESPONSE_APPLY); + _("Save"), + GTK_RESPONSE_APPLY); gtk_widget_grab_focus (cancel_button); @@ -519,20 +519,20 @@ psppire_window_model_get_type (void) static const GTypeInfo window_model_info = { sizeof (PsppireWindowIface), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL, - NULL /* value_table */ + NULL, /* base_init */ + NULL, /* base_finalize */ + NULL, + NULL, /* class_finalize */ + NULL, /* class_data */ + 0, + 0, /* n_preallocs */ + NULL, + NULL /* value_table */ }; window_model_type = - g_type_register_static (G_TYPE_INTERFACE, "PsppireWindowModel", - &window_model_info, 0); + g_type_register_static (G_TYPE_INTERFACE, "PsppireWindowModel", + &window_model_info, 0); g_type_interface_add_prerequisite (window_model_type, G_TYPE_OBJECT); } @@ -621,11 +621,11 @@ psppire_window_file_chooser_dialog (PsppireWindow *toplevel) GtkFileFilter *filter = gtk_file_filter_new (); GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Open"), - GTK_WINDOW (toplevel), - GTK_FILE_CHOOSER_ACTION_OPEN, - _("Cancel"), GTK_RESPONSE_CANCEL, - _("Open"), GTK_RESPONSE_ACCEPT, - NULL); + GTK_WINDOW (toplevel), + GTK_FILE_CHOOSER_ACTION_OPEN, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("Open"), GTK_RESPONSE_ACCEPT, + NULL); g_object_set (dialog, "local-only", FALSE, NULL); @@ -726,21 +726,21 @@ psppire_window_open (PsppireWindow *de) { case GTK_RESPONSE_ACCEPT: { - gchar *name = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gchar *name = + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - const gchar **cs = NULL; - g_get_filename_charsets (&cs); + const gchar **cs = NULL; + g_get_filename_charsets (&cs); gchar *encoding = psppire_encoding_selector_get_encoding ( gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog))); - struct file_handle *fh = fh_create_file (NULL, name, cs[0], fh_default_properties ()); + struct file_handle *fh = fh_create_file (NULL, name, cs[0], fh_default_properties ()); int retval = any_reader_detect (fh, NULL); - if (retval == 1) + if (retval == 1) open_data_window (de, name, encoding, NULL); - else if (retval == 0) + else if (retval == 0) { char *error = spv_detect (name); if (!error) @@ -753,8 +753,8 @@ psppire_window_open (PsppireWindow *de) } g_free (encoding); - fh_unref (fh); - g_free (name); + fh_unref (fh); + g_free (name); } break; default: diff --git a/src/ui/gui/psppire-window.h b/src/ui/gui/psppire-window.h index e4422ecc74..ac326151f6 100644 --- a/src/ui/gui/psppire-window.h +++ b/src/ui/gui/psppire-window.h @@ -45,7 +45,7 @@ G_BEGIN_DECLS #define PSPPIRE_TYPE_WINDOW_MODEL (psppire_window_model_get_type ()) -#define PSPPIRE_IS_WINDOW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_WINDOW_MODEL)) +#define PSPPIRE_IS_WINDOW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_WINDOW_MODEL)) #define PSPPIRE_WINDOW_MODEL_GET_IFACE(obj) \ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PSPPIRE_TYPE_WINDOW_MODEL, PsppireWindowIface)) diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index e03a84b433..e77c449315 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -107,10 +107,10 @@ initialize (const struct init_source *is) break; case 8: if (! gtk_parse_args (is->argc, is->argv)) - { - perror ("Error parsing arguments"); - exit (1); - } + { + perror ("Error parsing arguments"); + exit (1); + } break; case 9: journal_init (); @@ -173,9 +173,9 @@ psppire_preload_file (const gchar *file, GtkWindow *victim) const gchar *local_encoding = "UTF-8"; struct file_handle *fh = fh_create_file (NULL, - file, - local_encoding, - fh_default_properties ()); + file, + local_encoding, + fh_default_properties ()); const char *filename = fh_get_file_name (fh); int retval = any_reader_detect (fh, NULL); diff --git a/src/ui/gui/spreadsheet-test.c b/src/ui/gui/spreadsheet-test.c index dfdd95c0ae..33a5719ed4 100644 --- a/src/ui/gui/spreadsheet-test.c +++ b/src/ui/gui/spreadsheet-test.c @@ -76,18 +76,18 @@ on_clicked (GtkButton *button, struct xxx *stuff) for (i = 0; i < nvals ; ++i) { - const int width = caseproto_get_width (proto, i); - const union value *val = case_data_idx (c, i); - if (0 == width) - printf ("%.*g ", DBL_DIG + 1, val->f); - else - { - char *ss = xzalloc (width + 1); + const int width = caseproto_get_width (proto, i); + const union value *val = case_data_idx (c, i); + if (0 == width) + printf ("%.*g ", DBL_DIG + 1, val->f); + else + { + char *ss = xzalloc (width + 1); memcpy (ss, val->s, width); - printf ("%s ", ss); - free (ss); - } + printf ("%s ", ss); + free (ss); + } } printf ("\n"); } @@ -154,8 +154,8 @@ main (int argc, char *argv[]) GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (stuff.combo_box), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (stuff.combo_box), renderer, - "text", 0, - NULL); + "text", 0, + NULL); } gtk_combo_box_set_model (GTK_COMBO_BOX (stuff.combo_box), tm); @@ -165,17 +165,17 @@ main (int argc, char *argv[]) treeview = gtk_tree_view_new_with_model (tm); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - 0, "sheet name", - gtk_cell_renderer_text_new (), - "text", 0, - NULL); + 0, "sheet name", + gtk_cell_renderer_text_new (), + "text", 0, + NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - 1, "range", - gtk_cell_renderer_text_new (), - "text", 1, - NULL); + 1, "range", + gtk_cell_renderer_text_new (), + "text", 1, + NULL); gtk_box_pack_start (GTK_BOX (hbox), treeview, TRUE, TRUE, 5); diff --git a/src/ui/gui/t-test-options.c b/src/ui/gui/t-test-options.c index 17d2d52508..d0818aec5d 100644 --- a/src/ui/gui/t-test-options.c +++ b/src/ui/gui/t-test-options.c @@ -65,9 +65,9 @@ tt_options_dialog_create (GtkWindow *parent) psppire_scanf_new (_("Con_fidence Interval: %2d %%"), &tto->conf_percent); g_object_set (tto->confidence, - "use-underline", TRUE, - "mnemonic-widget", psppire_scanf_get_child (PSPPIRE_SCANF (tto->confidence), 0), - NULL); + "use-underline", TRUE, + "mnemonic-widget", psppire_scanf_get_child (PSPPIRE_SCANF (tto->confidence), 0), + NULL); tto->dialog = get_widget_assert (tto->xml, "options-dialog"); @@ -120,9 +120,9 @@ tt_options_dialog_run (struct tt_options_dialog *tto) tto->confidence_interval = gtk_spin_button_get_value (tto->conf_percent); if (gtk_toggle_button_get_active (tto->analysis)) - tto->excl = EXCL_ANALYSIS; + tto->excl = EXCL_ANALYSIS; else - tto->excl = EXCL_LISTWISE; + tto->excl = EXCL_LISTWISE; } } @@ -140,7 +140,7 @@ tt_options_dialog_append_syntax (const struct tt_options_dialog *tto, GString *s ds_put_cstr (&dss, "LISTWISE"); ds_put_c_format (&dss, "\n\t/CRITERIA=CI(%g)", - tto->confidence_interval/100.0); + tto->confidence_interval/100.0); g_string_append (str, ds_cstr (&dss)); diff --git a/src/ui/gui/val-labs-dialog.c b/src/ui/gui/val-labs-dialog.c index 50e704630d..af9fcecef3 100644 --- a/src/ui/gui/val-labs-dialog.c +++ b/src/ui/gui/val-labs-dialog.c @@ -244,9 +244,9 @@ select_treeview_from_value (GtkTreeView *treeview, union value *val) v.f = g_value_get_double (&gvalue); if (0 == memcmp (&v, val, sizeof (union value))) - { - break; - } + { + break; + } } path = gtk_tree_model_get_path (model, &iter); @@ -274,7 +274,7 @@ on_value_entry_change (GtkEntry *entry, gpointer data) text_to_value__ (text, dialog->format, dialog->encoding, &v); g_signal_handler_block (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); gtk_entry_set_text (GTK_ENTRY (dialog->label_entry),""); @@ -293,7 +293,7 @@ on_value_entry_change (GtkEntry *entry, gpointer data) } g_signal_handler_unblock (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); value_destroy (&v, val_labs_get_width (dialog->labs)); } @@ -362,7 +362,7 @@ do_change (PsppireValLabsDialog *dialog) if (text_to_value__ (val_text, dialog->format, dialog->encoding, &v)) { val_labs_replace (dialog->labs, &v, - gtk_entry_get_text (GTK_ENTRY (dialog->label_entry))); + gtk_entry_get_text (GTK_ENTRY (dialog->label_entry))); gtk_widget_set_sensitive (dialog->change_button, FALSE); @@ -386,14 +386,14 @@ on_add (GtkWidget *w, gpointer data) if (text_to_value__ (text, dialog->format, dialog->encoding, &v)) { if (val_labs_add (dialog->labs, &v, - gtk_entry_get_text - (GTK_ENTRY (dialog->label_entry)))) - { - gtk_widget_set_sensitive (dialog->add_button, FALSE); + gtk_entry_get_text + (GTK_ENTRY (dialog->label_entry)))) + { + gtk_widget_set_sensitive (dialog->add_button, FALSE); - repopulate_dialog (dialog); - gtk_widget_grab_focus (dialog->value_entry); - } + repopulate_dialog (dialog); + gtk_widget_grab_focus (dialog->value_entry); + } value_destroy (&v, val_labs_get_width (dialog->labs)); } @@ -441,23 +441,23 @@ on_select_row (GtkTreeView *treeview, gpointer data) text = value_to_text__ (value, dialog->format, dialog->encoding); g_signal_handler_block (GTK_ENTRY (dialog->value_entry), - dialog->value_handler_id); + dialog->value_handler_id); gtk_entry_set_text (GTK_ENTRY (dialog->value_entry), text); g_signal_handler_unblock (GTK_ENTRY (dialog->value_entry), - dialog->value_handler_id); + dialog->value_handler_id); g_free (text); g_signal_handler_block (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); gtk_entry_set_text (GTK_ENTRY (dialog->label_entry), - label); + label); g_signal_handler_unblock (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); gtk_widget_set_sensitive (dialog->remove_button, TRUE); gtk_widget_set_sensitive (dialog->change_button, FALSE); @@ -486,7 +486,7 @@ psppire_val_labs_dialog_constructor (GType type, dialog = PSPPIRE_VAL_LABS_DIALOG (obj); g_object_set (dialog, "help-page", "VALUE-LABELS", - "title", _("Value Labels"), NULL); + "title", _("Value Labels"), NULL); content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog)); gtk_container_add (GTK_CONTAINER (content_area), @@ -506,40 +506,40 @@ psppire_val_labs_dialog_constructor (GType type, renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", - renderer, - "text", - 0, - NULL); + renderer, + "text", + 0, + NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->treeview), column); dialog->change_handler_id = g_signal_connect (dialog->label_entry, - "changed", - G_CALLBACK (on_label_entry_change), dialog); + "changed", + G_CALLBACK (on_label_entry_change), dialog); g_signal_connect (dialog->label_entry, "activate", G_CALLBACK (on_label_entry_activate), dialog); dialog->value_handler_id = g_signal_connect (dialog->value_entry, - "changed", - G_CALLBACK (on_value_entry_change), dialog); + "changed", + G_CALLBACK (on_value_entry_change), dialog); g_signal_connect (dialog->value_entry, "activate", G_CALLBACK (on_value_entry_activate), dialog); g_signal_connect (dialog->change_button, - "clicked", - G_CALLBACK (on_change), dialog); + "clicked", + G_CALLBACK (on_change), dialog); g_signal_connect (dialog->treeview, "cursor-changed", - G_CALLBACK (on_select_row), dialog); + G_CALLBACK (on_select_row), dialog); g_signal_connect (dialog->remove_button, "clicked", - G_CALLBACK (on_remove), dialog); + G_CALLBACK (on_remove), dialog); g_signal_connect (dialog->add_button, "clicked", - G_CALLBACK (on_add), dialog); + G_CALLBACK (on_add), dialog); /* dialog->labs must not be set here, because as a member of a singleton class its value persists "between" objects. */ @@ -563,21 +563,21 @@ repopulate_dialog (PsppireValLabsDialog *dialog) GtkTreeIter iter; GtkListStore *list_store = gtk_list_store_new (2, - G_TYPE_STRING, - G_TYPE_DOUBLE); + G_TYPE_STRING, + G_TYPE_DOUBLE); g_signal_handler_block (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); g_signal_handler_block (GTK_ENTRY (dialog->value_entry), - dialog->value_handler_id); + dialog->value_handler_id); gtk_entry_set_text (GTK_ENTRY (dialog->value_entry), ""); gtk_entry_set_text (GTK_ENTRY (dialog->label_entry), ""); g_signal_handler_unblock (GTK_ENTRY (dialog->value_entry), - dialog->value_handler_id); + dialog->value_handler_id); g_signal_handler_unblock (GTK_ENTRY (dialog->label_entry), - dialog->change_handler_id); + dialog->change_handler_id); labels = val_labs_sorted (dialog->labs); n_labels = val_labs_count (dialog->labs); @@ -594,8 +594,8 @@ repopulate_dialog (PsppireValLabsDialog *dialog) gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, 0, text, - 1, vl->value.f, - -1); + 1, vl->value.f, + -1); g_free (text); g_free (vstr); @@ -603,7 +603,7 @@ repopulate_dialog (PsppireValLabsDialog *dialog) free (labels); gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview), - GTK_TREE_MODEL (list_store)); + GTK_TREE_MODEL (list_store)); g_object_unref (list_store); } diff --git a/src/ui/gui/var-display.c b/src/ui/gui/var-display.c index 86a58da702..687b17e217 100644 --- a/src/ui/gui/var-display.c +++ b/src/ui/gui/var-display.c @@ -44,43 +44,43 @@ missing_values_to_string (const struct variable *pv, GError **err) { GString *gstr = g_string_sized_new (10); if (! mv_has_range (miss)) - { - const int n = mv_n_values (miss); - gchar *mv[4] = {0,0,0,0}; - gint i; - for (i = 0 ; i < n; ++i) - { - mv[i] = value_to_text (*mv_get_value (miss, i), pv); - if (i > 0) - g_string_append (gstr, ", "); - g_string_append (gstr, mv[i]); - g_free (mv[i]); - } - } + { + const int n = mv_n_values (miss); + gchar *mv[4] = {0,0,0,0}; + gint i; + for (i = 0 ; i < n; ++i) + { + mv[i] = value_to_text (*mv_get_value (miss, i), pv); + if (i > 0) + g_string_append (gstr, ", "); + g_string_append (gstr, mv[i]); + g_free (mv[i]); + } + } else - { - gchar *l, *h; - union value low, high; - mv_get_range (miss, &low.f, &high.f); + { + gchar *l, *h; + union value low, high; + mv_get_range (miss, &low.f, &high.f); - l = value_to_text (low, pv); - h = value_to_text (high, pv); + l = value_to_text (low, pv); + h = value_to_text (high, pv); - g_string_printf (gstr, "%s - %s", l, h); - g_free (l); - g_free (h); + g_string_printf (gstr, "%s - %s", l, h); + g_free (l); + g_free (h); - if (mv_has_value (miss)) - { - gchar *ss = NULL; + if (mv_has_value (miss)) + { + gchar *ss = NULL; - ss = value_to_text (*mv_get_value (miss, 0), pv); + ss = value_to_text (*mv_get_value (miss, 0), pv); - g_string_append (gstr, ", "); - g_string_append (gstr, ss); - free (ss); - } - } + g_string_append (gstr, ", "); + g_string_append (gstr, ss); + free (ss); + } + } return g_string_free_and_steal (gstr); } diff --git a/src/ui/gui/var-type-dialog.c b/src/ui/gui/var-type-dialog.c index 1f77eef442..d9f1739b25 100644 --- a/src/ui/gui/var-type-dialog.c +++ b/src/ui/gui/var-type-dialog.c @@ -91,7 +91,7 @@ static GObject *psppire_var_type_dialog_constructor (GType type, guint, static void psppire_var_type_dialog_set_state (PsppireVarTypeDialog *); static void psppire_var_type_dialog_set_format (PsppireVarTypeDialog *dialog, - struct fmt_spec format); + struct fmt_spec format); static int find_format (struct fmt_spec target, const struct fmt_spec formats[], int n_formats); @@ -541,7 +541,7 @@ psppire_var_type_dialog_constructor (GType type, dialog = PSPPIRE_VAR_TYPE_DIALOG (obj); g_object_set (dialog, "help-page", "Input-and-Output-Formats", - "title", _("Variable Type and Format"), NULL); + "title", _("Variable Type and Format"), NULL); xml = builder_new ("var-type-dialog.ui"); @@ -552,7 +552,7 @@ psppire_var_type_dialog_constructor (GType type, dialog->active_button = -1; g_signal_connect (dialog, "delete-event", - G_CALLBACK (gtk_widget_hide_on_delete), NULL); + G_CALLBACK (gtk_widget_hide_on_delete), NULL); dialog->radioButton[BUTTON_NUMERIC] = get_widget_assert (xml,"radiobutton1"); @@ -587,7 +587,7 @@ psppire_var_type_dialog_constructor (GType type, dialog->adj_width = gtk_spin_button_get_adjustment ( GTK_SPIN_BUTTON (dialog->entry_width)); dialog->custom_currency_hbox = get_widget_assert (xml, - "custom_currency_hbox"); + "custom_currency_hbox"); dialog->dollar_window = get_widget_assert (xml, "dollar_window"); dialog->dollar_treeview = @@ -612,7 +612,7 @@ psppire_var_type_dialog_constructor (GType type, GtkSizeGroup *sizeGroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); gtk_container_foreach (GTK_CONTAINER (get_widget_assert (xml, "middle_box")), - add_to_group, sizeGroup); + add_to_group, sizeGroup); for (i = 0 ; i < num_BUTTONS; ++i) @@ -621,18 +621,18 @@ psppire_var_type_dialog_constructor (GType type, /* Populate the date format tree view */ dialog->date_format_treeview = GTK_TREE_VIEW (get_widget_assert (xml, - "date_format_list_view")); + "date_format_list_view")); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", - renderer, - "text", - 0, - NULL); + renderer, + "text", + 0, + NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->date_format_treeview), - column); + column); list_store = gtk_list_store_new (1, G_TYPE_STRING); @@ -643,16 +643,16 @@ psppire_var_type_dialog_constructor (GType type, gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, 0, fmt_date_template (f.type, f.w), - -1); + -1); } gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->date_format_treeview), - GTK_TREE_MODEL (list_store)); + GTK_TREE_MODEL (list_store)); g_object_unref (list_store); g_signal_connect (dialog->date_format_treeview, "cursor-changed", - G_CALLBACK (set_date_format_from_treeview), dialog); + G_CALLBACK (set_date_format_from_treeview), dialog); /* populate the dollar treeview */ @@ -660,13 +660,13 @@ psppire_var_type_dialog_constructor (GType type, renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", - renderer, - "text", - 0, - NULL); + renderer, + "text", + 0, + NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->dollar_treeview), - column); + column); list_store = gtk_list_store_new (1, G_TYPE_STRING); @@ -677,22 +677,22 @@ psppire_var_type_dialog_constructor (GType type, gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, 0, template, - -1); + -1); free (template); } gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->dollar_treeview), - GTK_TREE_MODEL (list_store)); + GTK_TREE_MODEL (list_store)); g_object_unref (list_store); g_signal_connect (dialog->dollar_treeview, - "cursor-changed", - G_CALLBACK (set_dollar_format_from_treeview), dialog); + "cursor-changed", + G_CALLBACK (set_dollar_format_from_treeview), dialog); g_signal_connect_swapped (dialog->dollar_treeview, - "cursor-changed", - G_CALLBACK (update_width_decimals), dialog); + "cursor-changed", + G_CALLBACK (update_width_decimals), dialog); /* populate the custom treeview */ @@ -700,13 +700,13 @@ psppire_var_type_dialog_constructor (GType type, renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Title", - renderer, - "text", - 0, - NULL); + renderer, + "text", + 0, + NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->custom_treeview), - column); + column); list_store = gtk_list_store_new (1, G_TYPE_STRING); @@ -717,23 +717,23 @@ psppire_var_type_dialog_constructor (GType type, gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, 0, fmt_name (cc_fmts[i]), - -1); + -1); } gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->custom_treeview), - GTK_TREE_MODEL (list_store)); + GTK_TREE_MODEL (list_store)); g_object_unref (list_store); g_signal_connect (dialog->custom_treeview, - "cursor-changed", - G_CALLBACK (set_custom_format_from_treeview), dialog); + "cursor-changed", + G_CALLBACK (set_custom_format_from_treeview), dialog); g_signal_connect (dialog->custom_treeview, - "cursor-changed", - G_CALLBACK (preview_custom), dialog); + "cursor-changed", + G_CALLBACK (preview_custom), dialog); g_signal_connect (dialog->entry_width, "changed", @@ -742,13 +742,13 @@ psppire_var_type_dialog_constructor (GType type, G_CALLBACK (on_decimals_changed), dialog); g_signal_connect (dialog->entry_width, - "changed", - G_CALLBACK (preview_custom), dialog); + "changed", + G_CALLBACK (preview_custom), dialog); g_signal_connect (dialog->entry_decimals, - "changed", - G_CALLBACK (preview_custom), dialog); + "changed", + G_CALLBACK (preview_custom), dialog); } @@ -765,7 +765,7 @@ static void var_type_dialog_set_active_button (PsppireVarTypeDialog *dialog, gint b) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radioButton[b]), - TRUE); + TRUE); } diff --git a/src/ui/gui/widget-io.c b/src/ui/gui/widget-io.c index bd28597c11..21d29de02b 100644 --- a/src/ui/gui/widget-io.c +++ b/src/ui/gui/widget-io.c @@ -54,7 +54,7 @@ widget_printf (const gchar *fmt, ...) for (i = 0 ; i < d.count ; ++i) { if (d.dir[i].conversion != '%') - widgets[i] = va_arg (ap, GtkWidget *); + widgets[i] = va_arg (ap, GtkWidget *); } va_end (ap); @@ -70,16 +70,16 @@ widget_printf (const gchar *fmt, ...) const gchar *entry_text; if (dir.conversion == '%') - { - s++; - continue; - } + { + s++; + continue; + } w = widgets [dir.arg_index]; entry_text = gtk_entry_get_text (GTK_ENTRY (w)); if (dir.dir_start > s) - g_string_append_len (output, s, dir.dir_start - s); + g_string_append_len (output, s, dir.dir_start - s); s = dir.dir_end; diff --git a/src/ui/gui/windows-menu.c b/src/ui/gui/windows-menu.c index b6ae962b62..73438adbc4 100644 --- a/src/ui/gui/windows-menu.c +++ b/src/ui/gui/windows-menu.c @@ -63,7 +63,7 @@ add_menuitem (gpointer key, gpointer value, gpointer user_data) GtkWidget *mi = gtk_check_menu_item_new_with_label (key); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), - pw == g_object_get_data (G_OBJECT (menu), "toplevel")); + pw == g_object_get_data (G_OBJECT (menu), "toplevel")); g_signal_connect (mi, "toggled", G_CALLBACK (reset_check_state), pw); @@ -100,7 +100,7 @@ repopulate_windows_menu (GObject *inst, gchar *name, gpointer data) GtkWidget *split = gtk_check_menu_item_new_with_mnemonic (_("_Split")); gtk_menu_attach (GTK_MENU (menu), split, 0, 1, 1, 2); g_signal_connect_swapped (split, "toggled", - G_CALLBACK (toggle_split_window), toplevel); + G_CALLBACK (toggle_split_window), toplevel); } gtk_container_add (GTK_CONTAINER (menu), sep); diff --git a/src/ui/source-init-opts.c b/src/ui/source-init-opts.c index c5f5b4d457..c7963c0147 100644 --- a/src/ui/source-init-opts.c +++ b/src/ui/source-init-opts.c @@ -64,9 +64,9 @@ source_init_option_callback (int id, void *aux UNUSED) { case OPT_ALGORITHM: if (!strcmp (optarg, "compatible")) - settings_set_algorithm (COMPATIBLE); + settings_set_algorithm (COMPATIBLE); else if (!strcmp (optarg, "enhanced")) - settings_set_algorithm (ENHANCED); + settings_set_algorithm (ENHANCED); else error (1, 0, _("Algorithm must be either `%s' or `%s'."), "compatible", "enhanced"); @@ -89,9 +89,9 @@ source_init_option_callback (int id, void *aux UNUSED) case OPT_SYNTAX: if (!strcmp (optarg, "compatible")) - settings_set_syntax (COMPATIBLE); + settings_set_syntax (COMPATIBLE); else if (!strcmp (optarg, "enhanced")) - settings_set_syntax (ENHANCED); + settings_set_syntax (ENHANCED); else error (1, 0, _("Syntax must be either `%s' or `%s'."), "compatible", "enhanced"); diff --git a/src/ui/syntax-gen.c b/src/ui/syntax-gen.c index 4970f664a2..039a07d29b 100644 --- a/src/ui/syntax-gen.c +++ b/src/ui/syntax-gen.c @@ -168,7 +168,7 @@ syntax_gen_number (struct string *output, if (ok && v_out.f == number) { syntax_gen_string (output, ss_cstr (s)); - free (s); + free (s); return; } free (s); @@ -283,12 +283,12 @@ syntax_gen_pspp_valist (struct string *output, const char *format, break; case 'f': - case 'g': + case 'g': { - char conv[32]; + char conv[32]; double d = va_arg (args, double); int x = 0; - conv[x++] = '%'; + conv[x++] = '%'; conv[x] = '\0'; if (precision != -1) { @@ -296,8 +296,8 @@ syntax_gen_pspp_valist (struct string *output, const char *format, strcat (conv, qualifier); x += strlen (qualifier) + 1; } - conv[x++] = directive; - conv[x++] = '\0'; + conv[x++] = directive; + conv[x++] = '\0'; ds_put_c_format (output, conv, d); break; diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 60f9313840..95b8894bab 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -139,7 +139,7 @@ main (int argc, char **argv) int result = cmd_parse (lexer, session_active_dataset (the_session)); if (result == CMD_EOF || result == CMD_FINISH) - break; + break; else if (cmd_result_is_failure (result) && lex_token (lexer) != T_STOP) { switch (lex_get_error_mode (lexer)) diff --git a/src/ui/terminal/terminal-reader.c b/src/ui/terminal/terminal-reader.c index 3225678e87..f028def094 100644 --- a/src/ui/terminal/terminal-reader.c +++ b/src/ui/terminal/terminal-reader.c @@ -87,9 +87,9 @@ welcome (void) return; welcomed = true; fputs ("PSPP is free software and you are welcome to distribute copies of " - "it\nunder certain conditions; type \"show copying.\" to see the " - "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show " - "warranty.\" for details.\n", stdout); + "it\nunder certain conditions; type \"show copying.\" to see the " + "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show " + "warranty.\" for details.\n", stdout); puts (announced_version); journal_init (); } @@ -122,9 +122,9 @@ rl_echo_signal_char (int sig) cc_t c = t.c_cc[VINTR]; if (c >= 0 && c <= 'Z' - 'A') - fprintf (rl_outstream, "^%c", 'A' + c - 1); + fprintf (rl_outstream, "^%c", 'A' + c - 1); else - fprintf (rl_outstream, "%c", c); + fprintf (rl_outstream, "%c", c); } else #endif @@ -151,11 +151,11 @@ terminal_reader_read (struct lex_reader *r_, char *buf, size_t n, ss_dealloc (&r->s); if (! readline_read (&r->s, prompt_style)) - { + { *buf = '\n'; fprintf (rl_outstream, "\n"); - return 1; - } + return 1; + } r->offset = 0; r->eof = ss_is_empty (r->s); } @@ -267,21 +267,21 @@ interruptible_getc (FILE *fp) FD_SET (fd, &what); ret = select (max_fd + 1, &what, NULL, NULL, &timeout); if (ret == -1 && errno != EINTR) - { - perror ("Select failed"); - continue; - } + { + perror ("Select failed"); + continue; + } if (ret > 0) - { - if (FD_ISSET (pfd[0], &what)) - { - char dummy[1]; - read (pfd[0], dummy, 1); - sigint_received = true; - return EOF; - } - } + { + if (FD_ISSET (pfd[0], &what)) + { + char dummy[1]; + read (pfd[0], dummy, 1); + sigint_received = true; + return EOF; + } + } } while (ret <= 0); diff --git a/tests/data/datasheet-test.c b/tests/data/datasheet-test.c index 5ad31b2db8..20c226bf06 100644 --- a/tests/data/datasheet-test.c +++ b/tests/data/datasheet-test.c @@ -166,7 +166,7 @@ check_datasheet_casereader (struct mc *mc, struct casereader *reader, } } - case_unref (c); + case_unref (c); } c = casereader_read (reader); diff --git a/tests/data/spreadsheet-test.c b/tests/data/spreadsheet-test.c index e2533509e2..936686553a 100644 --- a/tests/data/spreadsheet-test.c +++ b/tests/data/spreadsheet-test.c @@ -58,9 +58,9 @@ main (int argc, char **argv) { switch (opt) { - case OPT_METADATA: - get_n_sheets = true; - break; + case OPT_METADATA: + get_n_sheets = true; + break; case OPT_REFCHECK: refcheck = true; break; @@ -110,7 +110,7 @@ main (int argc, char **argv) int r = reverse ? (rows - r_ - 1) : r_; for (int c_ = 0; c_ < columns; c_++) { - int c = reverse ? (columns - c_ - 1) : c_ ; + int c = reverse ? (columns - c_ - 1) : c_ ; char *s = spreadsheet_get_cell (ss, sheet, r, c); if (refcheck) { @@ -119,11 +119,11 @@ main (int argc, char **argv) assert (row == r); assert (col == c); } - else + else { fputs (s ? s : "", stdout); - if (c_ < columns - 1) - putchar ('\t'); + if (c_ < columns - 1) + putchar ('\t'); } @@ -131,7 +131,7 @@ main (int argc, char **argv) } if (!refcheck) { - putchar ('\n'); + putchar ('\n'); } } diff --git a/tests/libpspp/zip-test.c b/tests/libpspp/zip-test.c index 3556926d6c..1d6888063f 100644 --- a/tests/libpspp/zip-test.c +++ b/tests/libpspp/zip-test.c @@ -53,11 +53,11 @@ main (int argc, char **argv) int i; struct zip_writer *zw = zip_writer_create (argv[2]); for (i = 3; i < argc; ++i) - { - FILE *fp = fopen (argv[i], "rb"); - if (!fp) check_die (); - zip_writer_add (zw, fp, argv[i]); - } + { + FILE *fp = fopen (argv[i], "rb"); + if (!fp) check_die (); + zip_writer_add (zw, fp, argv[i]); + } zip_writer_close (zw); } else if (0 == strcmp ("r", argv[1])) @@ -68,45 +68,45 @@ main (int argc, char **argv) struct zip_reader *zr; char *error = zip_reader_create (argv[2], &zr); if (error) - { - fprintf (stderr, "Could not create zip reader: %s\n", error); - check_die (); - } + { + fprintf (stderr, "Could not create zip reader: %s\n", error); + check_die (); + } for (i = 3; i < argc; ++i) - { - int x = 0; - FILE *fp = fopen (argv[i], "wb"); - if (NULL == fp) - { - int e = errno; - fprintf (stderr, "Could not create file %s: %s\n", argv[i], strerror(e)); - check_die (); - } + { + int x = 0; + FILE *fp = fopen (argv[i], "wb"); + if (NULL == fp) + { + int e = errno; + fprintf (stderr, "Could not create file %s: %s\n", argv[i], strerror(e)); + check_die (); + } - struct zip_member *zm ; - char *error = zip_member_open (zr, argv[i], &zm); - if (error) - { - fprintf (stderr, "Could not open zip member %s from archive: %s\n", - argv[i], error); - check_die (); - } + struct zip_member *zm ; + char *error = zip_member_open (zr, argv[i], &zm); + if (error) + { + fprintf (stderr, "Could not open zip member %s from archive: %s\n", + argv[i], error); + check_die (); + } - while ((x = zip_member_read (zm, buf, BUFSIZE)) > 0) - { - fwrite (buf, x, 1, fp); - } + while ((x = zip_member_read (zm, buf, BUFSIZE)) > 0) + { + fwrite (buf, x, 1, fp); + } error = zip_member_steal_error (zm); zip_member_finish (zm); - fclose (fp); + fclose (fp); assert ((error != NULL) == (x < 0)); - if (x < 0) - { - fprintf (stderr, "Unzip failed: %s\n", error); - check_die (); - } - } + if (x < 0) + { + fprintf (stderr, "Unzip failed: %s\n", error); + check_die (); + } + } zip_reader_unref (zr); } else diff --git a/tests/math/chart-get-scale-test.c b/tests/math/chart-get-scale-test.c index ef7b6b0a91..a3d19a23a5 100644 --- a/tests/math/chart-get-scale-test.c +++ b/tests/math/chart-get-scale-test.c @@ -51,7 +51,7 @@ test_range (double low, double high) double lower; chart_get_scale (high, low, - &lower, &interval, &n_ticks); + &lower, &interval, &n_ticks); if ((high - low) < 10 * DBL_MIN){ assert (n_ticks == 0); @@ -65,7 +65,7 @@ test_range (double low, double high) #if 0 printf("%s: high: %lg, low %lg, interval: %lg, nticks: %d\n", - __FUNCTION__, high, low, interval, n_ticks); + __FUNCTION__, high, low, interval, n_ticks); dump_scale (lower, interval, n_ticks); #endif diff --git a/tests/math/chart-get-ticks-format-test.c b/tests/math/chart-get-ticks-format-test.c index 3dbeac6557..e83f0a0ddd 100644 --- a/tests/math/chart-get-ticks-format-test.c +++ b/tests/math/chart-get-ticks-format-test.c @@ -73,7 +73,7 @@ main (int argc UNUSED, char **argv UNUSED) nticks = tv[i].nticks; fs = chart_get_ticks_format (lower, interval, nticks, &scale); printf("lower: %lg, interval: %lg, nticks: %d, fs: %s, scale: %lg, ex: ", - lower, interval, nticks, fs, scale); + lower, interval, nticks, fs, scale); printf(fs,(lower + 3 * interval)*scale); printf(", ex 2: "); printf(fs,(lower + 4 * interval)*scale); diff --git a/utilities/pspp-convert.c b/utilities/pspp-convert.c index 0f77998044..cc7f668a2e 100644 --- a/utilities/pspp-convert.c +++ b/utilities/pspp-convert.c @@ -287,7 +287,7 @@ main (int argc, char *argv[]) ds_cstr (&alphabet), length, password_list)) goto exit; else - goto error; + goto error; } @@ -390,8 +390,8 @@ error: static bool decrypt_file (struct encrypted_file *enc, - const struct file_handle *ifh, - const struct file_handle *ofh, + const struct file_handle *ifh, + const struct file_handle *ofh, const char *password, const char *alphabet, int max_length, diff --git a/utilities/pspp-dump-sav.c b/utilities/pspp-dump-sav.c index 03f3a7c0dc..ce524eb20d 100644 --- a/utilities/pspp-dump-sav.c +++ b/utilities/pspp-dump-sav.c @@ -90,7 +90,7 @@ static void read_variable_attributes (struct sfm_reader *r, size_t size, size_t count); static void read_ncases64 (struct sfm_reader *, size_t size, size_t count); static void read_character_encoding (struct sfm_reader *r, - size_t size, size_t count); + size_t size, size_t count); static void read_long_string_value_labels (struct sfm_reader *r, size_t size, size_t count); static void read_long_string_missing_values (struct sfm_reader *r, @@ -1093,12 +1093,12 @@ read_long_string_value_labels (struct sfm_reader *r, size_t size, size_t count) /* Read values. */ for (i = 0; i < n_values; i++) - { + { char *value; int value_length; char *label; - int label_length; + int label_length; posn = ftello (r->file); @@ -1117,7 +1117,7 @@ read_long_string_value_labels (struct sfm_reader *r, size_t size, size_t count) free (value); free (label); - } + } } } @@ -1153,7 +1153,7 @@ read_long_string_missing_values (struct sfm_reader *r, /* Read values. */ for (int i = 0; i < n_missing_values; i++) - { + { posn = ftello (r->file); /* Read value. */ @@ -1163,7 +1163,7 @@ read_long_string_missing_values (struct sfm_reader *r, printf (" \"%s\"", value); free (value); - } + } printf ("\n"); } } -- 2.30.2