{
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);
#include <assert.h>
#include <math.h>
-#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
/* 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) <MM>
/* 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);
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;
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;
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: */
/*
* 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
*
*
* SYNOPSIS
*
- * #include <Rmath.h>
- * double qtukey(p, rr, cc, df, lower_tail, log_p);
+ * #include <Rmath.h>
+ * 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 <config.h>
#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)
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;
* 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
*
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;
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 */
/* 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 */
# 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
#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
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
- croak(SvPVx(GvSV(errgv), na));
+ croak(SvPVx(GvSV(errgv), na));
return 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
#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
#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
#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
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;
}
}
}
- }
+ }
}
}
}
}
}
}
- }
+ }
}
}
numtype |= IS_NUMBER_IN_UV;
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;
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) {
}
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.
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;
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) {
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). */
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) {
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.
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 *);
{
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;
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)
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;
}
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));
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;
as->first = first;
as->increment = increment;
return casereader_create_append_numeric (subreader, next_arithmetic,
- as, free);
+ as, free);
}
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));
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)
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--;
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)
*/
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));
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,
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 *
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 *,
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 */
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));
{
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;
{
char *error = parse_int (i, month, SIZE_MAX);
if (error != NULL)
- return error;
+ return error;
if (*month >= 1 && *month <= 12)
return NULL;
}
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));
if (number < 0)
integer = -integer;
output_binary_integer (integer, format.w,
- settings_get_output_integer_format (),
+ settings_get_output_integer_format (),
output);
}
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';
}
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);
}
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. */
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);
value_destroy (&src, old_width);
value_destroy (&dst, new_width);
if (lrow < n_rows)
- return false;
+ return false;
release_source (ds, old_col.source);
}
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. */
};
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. */
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 */
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;
*/
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;
/* 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;
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);
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);
struct dictionary *d = vardict->dict;
if (NULL == d)
- return;
+ return;
if (what & (VAR_TRAIT_WIDTH | VAR_TRAIT_POSITION))
invalidate_proto (d);
/* 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 *);
};
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. */
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. */
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)
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);
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;
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);
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);
}
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);
struct stat temp;
if (((stat (file, &temp) == 0) && (! S_ISDIR (temp.st_mode))))
- return file;
+ return file;
free (file);
}
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");
}
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);
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
path = xstrdup (home_dir);
for(i = 0; i < strlen (path); i++)
- if (path[i] == '\\') path[i] = '/';
+ if (path[i] == '\\') path[i] = '/';
}
return path;
case FMT_Z:
output.w++;
if (output.d > 0)
- output.w++;
+ output.w++;
break;
case FMT_F:
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)
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"
};
/* 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. */
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,
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);
}
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);
}
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);
}
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;
}
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))
struct gnumeric_reader *r = r_;
if (r == NULL)
- return ;
+ return ;
state_data_destroy (&r->rsd);
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;
*/
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);
errno = 0;
v->f = c_strtod (text, &endptr);
if (errno != 0 || endptr == text)
- v->f = SYSMIS;
+ v->f = SYSMIS;
}
else
{
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);
}
}
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;
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;
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
{
/* 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);
}
/* 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);
+ }
+ }
}
{
{
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);
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)
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)
{
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)
spreadsheet.
*/
while ((sd->state != STATE_INIT)
- && 1 == (ret = xmlTextReaderRead (sd->xtr)))
+ && 1 == (ret = xmlTextReaderRead (sd->xtr)))
{
process_node (r, sd);
}
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;
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;
}
*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;
}
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;
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;
{
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;
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;
}
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)
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
{
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:
/* 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);
}
}
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 ();
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;
}
*/
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);
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);
+ }
}
}
{
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);
}
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;
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;
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
{
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 */
{
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)
{
free (val_string);
free (type);
- }
+ }
}
/* Create the dictionary and populate it */
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);
}
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 */
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);
}
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);
}
{
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. */
};
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. */
};
/* `*' 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;
}
{
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);
}
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;
}
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)))
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);
{
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. */
int j;
if (n_labels == 0)
- continue;
+ continue;
buf_write (w, "D", 1);
write_int (w, 1);
for (i = 0; i < l ; ++i)
{
if (isprint (x[i]))
- printf ("%c ", x[i]);
+ printf ("%c ", x[i]);
else
- printf (" ");
+ printf (" ");
}
putchar ('\n');
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);
if (PQstatus (r->conn) != CONNECTION_OK)
{
msg (ME, _("Error opening psql source: %s."),
- PQerrorMessage (r->conn));
+ PQerrorMessage (r->conn));
goto error;
}
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;
}
}
#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 (
if (PQresultStatus (qres) != PGRES_COMMAND_OK)
{
msg (ME, _("Error from psql source: %s."),
- PQresultErrorMessage (qres));
+ PQresultErrorMessage (qres));
goto error;
}
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));
if (PQresultStatus (qres) != PGRES_TUPLES_OK)
{
msg (ME, _("Error from psql source: %s."),
- PQresultErrorMessage (qres));
+ PQresultErrorMessage (qres));
goto error;
}
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);
if (NULL == r->res || r->tuple >= r->cache_size)
{
if (! reload_cache (r))
- return false;
+ return false;
}
return set_value (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++;
/* 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;
}
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;
*/
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];
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;
{
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 */
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)))
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 *);
/* 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. */
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 *);
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);
/* 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. */
};
/* 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? */
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;
}
: 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);
}
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;
}
/* 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;
/* 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. */
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;
}
{
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;
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 *);
/* 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;
/* 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;
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
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. */
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;
*/
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 ());
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:
*/
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);
}
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 *);
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 *);
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 */
{
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. */
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;
{
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);
}
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;
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);
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;
/* 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. */
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 *);
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);
\f
/* Parsing. */
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))
/* 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;
/* 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. */
/* 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)
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,
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)
"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);
.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));
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);
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++)
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)
case AGRF_FIRST:
case AGRF_LAST:
break;
- }
+ }
}
}
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));
}
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));
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))
#define _(msgid) gettext (msgid)
static double calculate_binomial_internal (double n1, double n2,
- double p);
+ double p);
static void
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;
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);
}
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);
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
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;
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);
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;
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 "
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]));
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")));
freq_hmap_destroy (&freq_hash, var_get_width (var));
free (ff);
- }
+ }
}
else /* ranged == true */
{
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))
{
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 (
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);
}
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);
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;
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);
}
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;
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
/* 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
/* 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
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++)
if (!ok)
goto error;
- }
+ }
else if (command != COMB_UPDATE && lex_match_id (lexer, "FIRST"))
{
if (first_name != NULL)
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));
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));
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))
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)
{
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. */
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_);
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),
/* 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;
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);
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;
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"));
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);
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));
}
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",
}
}
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;
.vars = vars,
};
- n_all_vars += n_vars_total;
- }
+ n_all_vars += n_vars_total;
+ }
}
if (n_corrs == 0)
{
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);
/* 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. */
size_t n_values;
union
{
- struct num_value *num;
- char **str;
+ struct num_value *num;
+ char **str;
}
values;
};
/* 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)
{
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]))
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);
}
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);
}
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;
lex_match (lexer, T_COMMA);
if (lex_match (lexer, T_RPAREN))
- break;
+ break;
}
return true;
}
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)));
lex_match (lexer, T_COMMA);
if (lex_match (lexer, T_RPAREN))
- break;
+ break;
}
return true;
if (!memcmp (case_str (c, crit->vars[i]), *v,
var_get_width (crit->vars[i])))
{
- counter++;
+ counter++;
break;
}
}
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;
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;
{
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
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. */
/* 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 "
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;
&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);
};
hmap_insert (&proc->var_ranges, &vr->hmap_node,
hash_pointer (var, 0));
- }
+ }
if (lex_token (lexer) == T_SLASH)
- break;
+ break;
}
proc->mode = INTEGER;
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);
display_crosstabulation (proc, &x, table, crs_leaves);
if (proc->exclude == 0)
- delete_missing (&x);
+ delete_missing (&x);
if (chisq)
display_chisq (&x, chisq);
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);
}
}
{
struct symmetric_statistic *s = &ss[i];
if (s->v == SYSMIS)
- continue;
+ continue;
indexes[1] = i;
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,
for (size_t i = 0; i < N_DIRECTIONAL; i++)
{
if (direct_v[i] == SYSMIS)
- continue;
+ continue;
indexes[1] = i;
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. */
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);
{
double p = Pr (a + xt, b - xt, c - xt, d + xt);
if (p < pn1)
- *fisher2 += p;
+ *fisher2 += p;
}
}
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;
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;
/* 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)
}
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
}
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;
}
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);
}
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);
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);
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;
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);
/* 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)
/* 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)
/* 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++)
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);
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 *,
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,
"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"))
}
}
else
- {
+ {
lex_error_expecting (lexer, "FILE", "ENCODING", "RECORDS",
"SKIP", "END", "NOTABLE", "TABLE",
"FIXED", "FREE", "LIST");
- goto error;
- }
+ goto error;
+ }
}
if (!fh)
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;
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))
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);
/* 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). */
};
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;
}
/* 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,
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,
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;
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);
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 */
{
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). */
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_*. */
/* 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. */
{
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. */
/* 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);
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)
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"))
goto error;
}
if (!lex_force_match (lexer, T_RPAREN))
- goto error;
+ goto error;
}
}
else if (n_vars == 0)
{
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++)
lex_tokcstr (lexer));
lex_get (lexer);
if (!lex_force_match (lexer, T_RPAREN))
- goto error;
+ goto error;
}
}
}
{
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++)
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;
(*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);
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);
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;
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;
}
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;
{
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));
.src_var = dv->v,
.z_var = dst_var,
};
- }
+ }
}
add_transformation (ds, &descriptives_trns_class, t);
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
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);
chart_submit (npp);
chart_submit (dnpp);
}
- casereader_destroy (reader);
+ casereader_destroy (reader);
ds_destroy (&label);
}
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);
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);
}
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]));
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;
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);
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];
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)
{
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);
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)
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)
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);
}
}
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)
{
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)
{
stat->destroy (stat);
}
- casereader_destroy (es[v].sorted_reader);
- }
- }
+ casereader_destroy (es[v].sorted_reader);
+ }
+ }
}
}
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);
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);
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))
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"))
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"))
}
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"))
}
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"))
}
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"))
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
};
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;
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);
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;
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)
{
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");
}
}
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");
}
}
idata->n_extractions = i;
if (evali < factor->min_eigen)
- goto finish;
+ goto finish;
}
finish:
*/
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);
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;
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;
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);
{
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);
/* 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);
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);
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;
+ }
}
}
*/
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);
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))
}
}
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))
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)
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;
id->ai_cor = NULL;
matrix_material_uninit (&id->mm);
- }
+ }
idata_free (id);
}
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);
}
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;
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);
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;
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 (
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))
{
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));
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);
}
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)
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;
}
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;
}
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);
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);
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;
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);
}
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
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;
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);
}
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)
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;
}
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);
}
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;
}
{
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;
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. */
};
{
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
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];
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 *,
}
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)
{
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);
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]))
{
}
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"))
{
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;
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))
{
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))
{
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);
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);
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);
.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 */
*/
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);
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;
*/
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);
};
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
{
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;
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))
{
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);
{
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;
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
#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 *);
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;
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,
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;
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,
}
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);
{
lex_error (lexer, "%s", error);
free (error);
- goto error;
- }
+ goto error;
+ }
lex_get (lexer);
struct fmt_spec input, output;
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 ());
}
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;
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;
}
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);
}
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 *);
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;
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)
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
{
}
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)
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++;
+ }
}
}
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);
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);
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);
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);
{
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);
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);
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 (
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);
}
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);
}
{
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);
}
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);
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;
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;
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");
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];
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))
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);
{
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)
{
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;
}
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);
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);
}
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))
{
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"))
/* 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:
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);
/* 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. */
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);
{
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;
}
else if (x0 < x1)
{
usum += w0 * (grp1->cc - prev_cc1);
- case_unref (c1);
+ case_unref (c1);
break;
}
else
#else
usum += w0 * (grp1->cc - (prev_cc1 + cc1) / 2.0);
#endif
- case_unref (c1);
+ case_unref (c1);
break;
}
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;
/* 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);
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);
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
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;
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;
/* 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);
/* 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);
}
}
{
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);
}
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)));
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));
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
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);
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);
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);
}
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"));
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);
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
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 *);
*/
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;
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));
*/
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;
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);
*/
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;
*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);
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;
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);
}
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;
/* 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;
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);
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);
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;
}
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)
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"))
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))
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;
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);
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,
/* 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"));
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"));
/* 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"));
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;
}
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;
}
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)
{
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);
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);
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
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)
"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);
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);
}
}
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)
{
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);
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);
}
}
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);
}
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;
}
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"))
}
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))
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);
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;
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);
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");
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));
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);
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
/* 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) */
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;
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;
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]))
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.
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;
}
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);
/* 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)
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)
{
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);
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]));
/* 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);
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);
+ }
}
}
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]];
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);
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]];
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)
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;
}
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);
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);
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
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;
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);
}
/* 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)
{
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);
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;
}
/* 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)
{
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);
{
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;
}
}
- 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);
}
}
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.
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,
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);
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)
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);
}
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 =
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"));
{
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);
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]));
}
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);
{
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);
}
}
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)
miss = (var_is_value_missing (var, vv) & means->ctrl_exclude) != 0;
if (miss)
- break;
+ break;
}
return miss;
*/
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)
{
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;
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);
}
}
}
{
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++;
+ }
+ }
+ }
}
}
/* 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;
(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);
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
{
/* 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)
{
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);
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;
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);
}
}
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);
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);
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));
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
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;
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);
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)
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
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. */
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);
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))
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))
}
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;
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);
}
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)
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;
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;
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);
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;
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);
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;
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);
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;
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;
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;
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))
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);
+ }
+ }
}
}
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;
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;
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))
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)."),
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))
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);
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;
lex_get (lexer);
if (!lex_force_match (lexer, T_RPAREN))
- return false;
+ return false;
}
lex_match (lexer, T_EQUALS);
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;
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);
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;
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);
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;
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;
/* 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);
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);
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);
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;
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 *);
};
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;
/* 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)
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;
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;
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)
/* 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;
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);
}
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))
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++;
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);
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;
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;
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);
}
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);
{
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);
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);
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);
++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);
}
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,
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))
{
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)
pivot_table_put2 (table, indep_idx++, contrast_idx,
pivot_value_new_integer (coeffn->coeff));
- }
+ }
}
pivot_table_submit (table);
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]));
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
{
}
contrast_idx++;
- }
+ }
}
pivot_table_submit (table);
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,
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);
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)
{
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);
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
{
{
/* 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
{
/* 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))
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;
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;
};
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;
goto error;
if (lex_token (lexer) != T_ENDCMD)
- {
+ {
lex_error (lexer, _("Syntax error expecting end of command."));
goto error;
- }
+ }
}
else
expr = NULL;
/* 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? */
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. */
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
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,
tmp_pool, &record, &column,
which_formats));
if (!ok)
- return 0;
+ return 0;
lex_match (lexer, T_COMMA);
}
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)
{
{
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);
}
}
}
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;
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 *);
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;
/* 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++)
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++)
/* 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;
{
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);
/* 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;
{
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)
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);
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)
break;
if (!qc->update)
- break;
+ break;
}
}
{
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"));
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;
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;
}
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) {
}
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);
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);
}
/* 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? */
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)
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");
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",
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
{
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;
}
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);
/* 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;
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;
}
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;
}
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);
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);
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);
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);
{
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;
}
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;
{
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],
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;
}
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]));
pivot_value_new_user_text (entry, -1));
}
ds_destroy (&group_vars);
- }
- }
+ }
+ }
pivot_table_submit (table);
}
/* 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. */
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. */
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))
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;
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;
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;
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,
_("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;
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 ();
}
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,
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
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
{
}
}
- if (statistics)
- regression.stats = statistics;
+ if (statistics)
+ regression.stats = statistics;
}
else if (lex_match_id (lexer, "SAVE"))
{
*/
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);
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."));
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);
}
*/
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)),
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 (
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++)
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);
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);
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;
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;
"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)
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)
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))
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);
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);
reliability_statistics (reliability);
if (reliability->summary_total)
- reliability_summary_total (reliability);
+ reliability_summary_total (reliability);
}
bool ok = casegrouper_destroy (grouper);
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)
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)
{
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)
{
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);
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);
}
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"));
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);
/* 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,
/* 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)
{
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."));
"Dummy variable %s had %zu substitutions.",
dv->n_values),
dv->name.string, dv->n_values);
- goto error;
- }
+ goto error;
+ }
lex_match (lexer, T_SLASH);
}
/* 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);
}
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);
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);
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
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))
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))
*/
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 =
/* We don't want duplicates here */
if (cp == prev_cp)
- continue;
+ continue;
new_case = case_clone (cpc);
*/
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);
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;
*/
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);
}
/*
*/
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);
}
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);
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);
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);
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);
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));
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);
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)
{
pivot_table_put3 (table, 2, coord_idx, var_idx,
pivot_value_new_number (1 - sp));
coord_idx++;
- }
+ }
casereader_destroy (r);
}
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;
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;
{
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;
}
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);
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
/* 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. */
};
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;
}
for (;;)
{
if (lex_match_id (lexer, "OUTFILE"))
- {
+ {
outfile_start = lex_ofs (lexer) - 1;
if (handle != NULL)
{
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)
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)
{
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. */
}
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);
goto error;
if (!lex_match (lexer, T_SLASH))
- break;
+ break;
}
if (lex_end_of_command (lexer) != CMD_SUCCESS)
goto error;
/* 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;
{
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);
}
else
{
if (!lex_force_int_range (lexer, "LENGTH", 1, INT_MAX))
- return false;
+ return false;
page_length = lex_integer (lexer);
lex_get (lexer);
}
else
{
if (!lex_force_num (lexer))
- return false;
+ return false;
set_rng (lex_number (lexer));
lex_get (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);
}
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));
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"));
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;
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);
{
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);
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
/* 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;
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)
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;
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));
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);
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;
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);
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);
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);
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);
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);
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);
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);
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);
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
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;
"There are %zu new variable names.",
added_new),
added_new);
- goto done;
- }
+ goto done;
+ }
}
int end_ofs = lex_ofs (lexer) - 1;
/* 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);
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);
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));
var_set_alignment (v[i], align);
while (lex_token (lexer) == T_SLASH)
- lex_get (lexer);
+ lex_get (lexer);
free (v);
continue;
var_set_display_width (v[i], width);
while (lex_token (lexer) == T_SLASH)
- lex_get (lexer);
+ lex_get (lexer);
free (v);
continue;
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;
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);
}
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);
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)
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;
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++)
}
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));
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);
}
}
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);
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;
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);
}
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);
}
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));
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"));
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;
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
+ );
{
assert (op < e->ops + e->n_ops);
switch (op++->operation)
- {
+ {
case OP_number:
case OP_boolean:
*ns++ = op++->number;
#include "evaluate.inc"
- default:
- NOT_REACHED ();
- }
+ default:
+ NOT_REACHED ();
+ }
}
}
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)
{
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];
{
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:
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:
{
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;
}
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
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;
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;
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);
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;
{
int i;
for (i = 0; i < n_vars; i++)
- free (names[i]);
+ free (names[i]);
free (names);
*namesp = NULL;
*n_varsp = 0;
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;
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;
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);
\f
/* This variable parser supports the unusual situation where set of variables
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);
}
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);
}
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
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);
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
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,
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;
}
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;
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. <http://fsf.org/>\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"
" 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"
"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"
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;
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);
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);
}
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);
}
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:
HMAPX_FOR_EACH (cvtr, node, &map)
{
if (cvtr == NULL)
- continue;
+ continue;
free (cvtr->tocode);
free (cvtr->fromcode);
if (cvtr->conv != (iconv_t) -1)
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;
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,
/* 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,
};
for (i = 0; i < result; ++i)
{
if (buf[i] == ',')
- {
- buf[i] = '.';
- break;
- }
+ {
+ buf[i] = '.';
+ break;
+ }
}
return result;
/* 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. */
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. */
pool->blocks->prev->next = NULL;
for (cur = pool->blocks; cur; cur = next)
{
- next = cur->next;
- free (cur);
+ next = cur->next;
+ free (cur);
}
}
}
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. */
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);
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);
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
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. */
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;
}
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;
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;
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. */
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. */
: c >= 'a' && c <= 'z' ? c - 'a'
: -1);
if (digit < 0)
- return -1;
+ return -1;
assert (digit >= 0 && digit < RADIX);
result += (digit + (i > 0)) * multiplier;
{
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);
}
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));
}
}
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);
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);
\f
static inline struct substring
ss_empty (void)
{
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;
}
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;
}
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));
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)
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;
}
*/
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);
*/
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)
*/
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);
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;
#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
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;
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;
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);
*/
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);
*/
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);
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");
}
}
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;
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)
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;
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;
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] */
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);
{
/* 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);
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);
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);
*/
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,
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 *);
{
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)
{
{
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
{
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 *,
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;
}
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);
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;
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.
/*
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.
*/
*/
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;
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)
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);
+ }
}
}
{
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);
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);
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);
}
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 *);
{
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);
}
{
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);
}
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)
{
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)
{
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);
}
}
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);
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 *);
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:
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;
}
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;
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;
+ }
}
}
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
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;
*/
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, ...)
{
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;
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);
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;
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;
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)
{
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;
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);
/* 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);
}
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;
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);
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;
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
*/
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);
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,
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);
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));
}
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;
{
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);
{
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");
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);
}
*/
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;
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);
}
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);
}
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);
}
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);
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);
\f
/* This boilerplate for barchart, a subclass of chart, was
*/
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,
/* 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
/* 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);
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,
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;
}
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;
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,
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);
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);
}
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;
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;i<n_catvals && !value_equal (&catvals[i],val,byvar_width);i++);
- if (i == n_catvals) /* No entry found */
- {
- if (n_catvals < MAX_PLOT_CATS)
- {
- struct string label;
- ds_init_empty (&label);
- if (var_is_value_missing (spc->byvar,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;i<n_catvals && !value_equal (&catvals[i],val,byvar_width);i++);
+ if (i == n_catvals) /* No entry found */
+ {
+ if (n_catvals < MAX_PLOT_CATS)
+ {
+ struct string label;
+ ds_init_empty (&label);
+ if (var_is_value_missing (spc->byvar,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;
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);
/* 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);
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);
\f
/* This boilerplate for scatterplot_chart, a subclass of chart, was
autogenerated by mk-class-boilerplate. */
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;
if (html->css)
{
fputs ("<style>\n"
- "<!--\n"
- "body {\n"
- " background: white;\n"
- " color: black;\n"
- " padding: 0em 12em 0em 3em;\n"
- " margin: 0\n"
- "}\n"
- "body>p {\n"
- " margin: 0pt 0pt 0pt 0em\n"
- "}\n"
- "body>p + p {\n"
- " text-indent: 1.5em;\n"
- "}\n"
- "h1 {\n"
- " font-size: 150%;\n"
- " margin-left: -1.33em\n"
- "}\n"
- "h2 {\n"
- " font-size: 125%;\n"
- " font-weight: bold;\n"
- " margin-left: -.8em\n"
- "}\n"
- "h3 {\n"
- " font-size: 100%;\n"
- " font-weight: bold;\n"
- " margin-left: -.5em }\n"
- "h4 {\n"
- " font-size: 100%;\n"
- " margin-left: 0em\n"
- "}\n"
- "h1, h2, h3, h4, h5, h6 {\n"
- " font-family: sans-serif;\n"
- " color: blue\n"
- "}\n"
- "html {\n"
- " margin: 0\n"
- "}\n"
- "code {\n"
- " font-family: sans-serif\n"
- "}\n"
- "table {\n"
- " border-collapse: collapse;\n"
- " margin-bottom: 1em\n"
- "}\n"
- "caption {\n"
- " text-align: left\n"
- "}\n"
- "th { font-weight: normal }\n"
- "a:link {\n"
- " color: #1f00ff;\n"
- "}\n"
- "a:visited {\n"
- " color: #9900dd;\n"
- "}\n"
- "a:active {\n"
- " color: red;\n"
- "}\n"
- "-->\n"
- "</style>\n",
- html->file);
+ "<!--\n"
+ "body {\n"
+ " background: white;\n"
+ " color: black;\n"
+ " padding: 0em 12em 0em 3em;\n"
+ " margin: 0\n"
+ "}\n"
+ "body>p {\n"
+ " margin: 0pt 0pt 0pt 0em\n"
+ "}\n"
+ "body>p + p {\n"
+ " text-indent: 1.5em;\n"
+ "}\n"
+ "h1 {\n"
+ " font-size: 150%;\n"
+ " margin-left: -1.33em\n"
+ "}\n"
+ "h2 {\n"
+ " font-size: 125%;\n"
+ " font-weight: bold;\n"
+ " margin-left: -.8em\n"
+ "}\n"
+ "h3 {\n"
+ " font-size: 100%;\n"
+ " font-weight: bold;\n"
+ " margin-left: -.5em }\n"
+ "h4 {\n"
+ " font-size: 100%;\n"
+ " margin-left: 0em\n"
+ "}\n"
+ "h1, h2, h3, h4, h5, h6 {\n"
+ " font-family: sans-serif;\n"
+ " color: blue\n"
+ "}\n"
+ "html {\n"
+ " margin: 0\n"
+ "}\n"
+ "code {\n"
+ " font-family: sans-serif\n"
+ "}\n"
+ "table {\n"
+ " border-collapse: collapse;\n"
+ " margin-bottom: 1em\n"
+ "}\n"
+ "caption {\n"
+ " text-align: left\n"
+ "}\n"
+ "th { font-weight: normal }\n"
+ "a:link {\n"
+ " color: #1f00ff;\n"
+ "}\n"
+ "a:visited {\n"
+ " color: #9900dd;\n"
+ "}\n"
+ "a:active {\n"
+ " color: red;\n"
+ "}\n"
+ "-->\n"
+ "</style>\n",
+ html->file);
}
fputs ("</head>\n", html->file);
fputs ("<body>\n", html->file);
{
if (fwriteerror (journal.file))
msg_error (errno, _("error writing output file `%s'"),
- journal.file_name);
+ journal.file_name);
}
journal.file = NULL;
if (journal.file == NULL)
{
msg_error (errno, _("error opening output file `%s'"),
- journal_get_file_name ());
- journal_close ();
+ journal_get_file_name ());
+ journal_close ();
}
}
}
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));
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"));
{
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 */
}
{
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 */
}
{
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"));
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 */
/* 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"));
/* 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 */
/* Write all the columns */
for (int c = 0 ; c < body->n[H] ; ++c)
- {
+ {
struct table_cell cell;
table_get_cell (body, c, r, &cell);
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 */
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);
}
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);
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;
};
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;
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);
}
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);
/* */
void
set_sensitivity_from_toggle_invert (GtkToggleButton *togglebutton,
- GtkWidget *w)
+ GtkWidget *w)
{
gboolean active = gtk_toggle_button_get_active (togglebutton);
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
void
get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
- GtkTreeModel **model, GtkTreeIter *iter)
+ GtkTreeModel **model, GtkTreeIter *iter)
{
*model = top_model;
{
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;
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;
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));
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));
gboolean
is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
- PsppireSelector *selector)
+ PsppireSelector *selector)
{
gboolean result;
GtkTreeIter dict_iter;
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
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;
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);
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,
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);
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);
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.
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
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;
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");
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));
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];
}
}
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 */
};
enum string_cmp_flags flags;
bool (*compare) (const struct comparator *,
- const union value *);
+ const union value *);
void (*destroy) (struct comparator *);
};
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);
/* 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;
/* 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;
/* 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;
/* 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 =
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;
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);
/* 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);
}
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);
*/
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;
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:
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);
}
}
}
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")
);
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);
}
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);
*/
#include <config.h>
-#include <glib-object.h>
+#include <glib-object.h>
#include <glib.h>
#include "helper.h"
*/
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);
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;
}
}
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))
{
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);
{
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);
{
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
/* 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);
}
}
{
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);
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);
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))
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);
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);
}
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));
}
}
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");
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);
{
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);
}
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;
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);
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))
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);
}
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)
{
{
gboolean status;
if (psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "maximize",
- &status))
+ &status))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.maximize), status);
}
{
gboolean status;
if (psppire_conf_get_boolean (fd.conf, "OutputWindowAction", "raise",
- &status))
+ &status))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd.raise), status);
}
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);
This widget is a GtkBox which looks roughly like:
+-----------------------------+
- |+------------+ +----------+ |
- || Add | | | |
- |+------------+ | | |
- | | | |
- |+------------+ | | |
- || Edit | | | |
- |+------------+ | | |
- | | | |
- |+------------+ | | |
- || Remove | | | |
- |+------------+ +----------+ |
+ |+------------+ +----------+ |
+ || Add | | | |
+ |+------------+ | | |
+ | | | |
+ |+------------+ | | |
+ || Edit | | | |
+ |+------------+ | | |
+ | | | |
+ |+------------+ | | |
+ || Remove | | | |
+ |+------------+ +----------+ |
+-----------------------------+
*/
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
{
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);
}
GList *l=
gtk_tree_selection_get_selected_rows (acr->selection,
- &model);
+ &model);
GtkTreePath *path = l->data;
{
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);
}
GList *l=
gtk_tree_selection_get_selected_rows (acr->selection,
- &model);
+ &model);
GtkTreePath *path = l->data;
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);
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)
+ );
}
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
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));
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);
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);
}
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);
}
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;
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.
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);
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
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));
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);
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);
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);
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);
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;
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);
*/
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)
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);
}
};
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
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
{
if (conf->idle == 0)
conf->idle = g_idle_add_full (G_PRIORITY_LOW,
- (GSourceFunc) flush_conf, conf, NULL);
+ (GSourceFunc) flush_conf, conf, NULL);
}
static GObject*
psppire_conf_construct (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
{
GObject *object;
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)
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)
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)
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)
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)
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);
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);
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);
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);
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);
*/
void
psppire_conf_set_window_geometry (PsppireConf *conf,
- const gchar *base,
- GtkWindow *window)
+ const gchar *base,
+ GtkWindow *window)
{
gint height, width;
gint x, y;
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);
}
}
*/
void
psppire_conf_save_window_geometry (PsppireConf *conf,
- const gchar *base,
- GtkWindow *gtk_window)
+ const gchar *base,
+ GtkWindow *gtk_window)
{
gboolean maximized;
GdkWindow *w;
#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;
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
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);
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);
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;
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);
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);
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,
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,
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,
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,
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);
}
}
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);
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);
}
}
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));
}
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);
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);
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);
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);
GtkWidget*
psppire_data_editor_new (PsppireDict *dict,
- PsppireDataStore *data_store)
+ PsppireDataStore *data_store)
{
return g_object_new (PSPPIRE_DATA_EDITOR_TYPE,
"dictionary", dict,
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);
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);
}
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;
}
}
*/
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);
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);
}
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);
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);
}
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);
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));
}
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;
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);
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);
}
/* 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);
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);
}
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
}
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);
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 ();
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);
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);
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
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);
}
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;
static gint
__tree_model_iter_n_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (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);
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);
}
{
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");
}
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);
}
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)
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);
}
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);
void
psppire_data_store_set_reader (PsppireDataStore *ds,
- struct casereader *reader)
+ struct casereader *reader)
{
gint i;
gint old_n = 0;
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);
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;
{
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);
}
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]);
+ }
}
}
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);
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)
{
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);
*/
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);
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);
/* 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 ;
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;
/* 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;
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))
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);
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,
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);
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 ;
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));
}
\f
static void
transformation_change_callback (bool transformations_pending,
- gpointer data)
+ gpointer data)
{
PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
{
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), "");
}
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);
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);
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));
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);
}
{
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;
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);
{
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;
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:
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,
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)))
{
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
static void
on_recent_data_select (GtkMenuShell *menushell,
- PsppireWindow *window)
+ PsppireWindow *window)
{
gchar *file;
{
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:
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);
}
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;
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);
}
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);
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);
- }
+ }
}
}
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);
}
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));
}
}
gtk_menu_attach (GTK_MENU (menu), quit, 0, 1, 14, 15);
connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()),
- "quit", quit, "<Primary>Q");
+ "quit", quit, "<Primary>Q");
}
g_object_set (menuitem, "submenu", menu, NULL);
gtk_window_add_accel_group (GTK_WINDOW (dw), ag);
gtk_accelerator_parse ("<Primary>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 ("<Primary>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 ("<Primary>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;
{
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;
}
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);
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);
{
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));
}
{
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));
}
{
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));
}
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");
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");
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++);
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");
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");
{
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"));
{
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"));
{
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"));
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);
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);
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);
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)
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);
static GType
__tree_get_column_type (GtkTreeModel *tree_model,
- gint index)
+ gint index)
{
if (index == 0)
return G_TYPE_INT;
static gboolean
__iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
return 0;
}
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);
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);
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);
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);
}
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)
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",
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;
{
return
g_object_new (PSPPIRE_TYPE_DELIMITED_TEXT,
- "child", child,
- NULL);
+ "child", child,
+ NULL);
}
static void
-#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))
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;
#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;
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");
}
}
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;
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);
{
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);
}
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:
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;
}
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);
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);
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);
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);
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));
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);
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);
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, ")");
#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;
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);
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
{
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;
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);
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);
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);
}
#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;
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))))
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);
}
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;
}
{
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, ")");
{
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 ");
#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;
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;
}
#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;
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, ")");
}
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");
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);
#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;
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;
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);
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);
#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;
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)))
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");
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);
}
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);
gtk_widget_set_sensitive (cd->str_btn, TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cd->numeric_target),
- TRUE);
+ TRUE);
}
}
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);
*/
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;
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};
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);
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);
#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;
#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;
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))
{
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);
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))
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);
{
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));
#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;
#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) \
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));
}
}
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;
}
{
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;
{
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);
}
{
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");
#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;
#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;
{
gboolean toggled;
gtk_tree_model_get (scd->stats, &iter,
- CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+ CHECKBOX_COLUMN_SELECTED, &toggled, -1);
if (toggled)
selected |= 1u << i;
}
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);
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");
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);
#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;
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));
{
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;
}
}
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;
}
}
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;
}
}
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 &&
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=");
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");
#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;
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)
{
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");
}
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);
#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;
#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;
#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"))
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));
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));
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");
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");
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);
{
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");
#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;
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");
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda,
- dialog_state_valid);
+ dialog_state_valid);
return xml;
}
#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;
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);
}
(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;
}
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);
}
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);
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");
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));
}
}
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';
}
}
static void
set_group_criterion_type (GtkToggleButton *button,
- PsppireDialogActionIndepSamps *act)
+ PsppireDialogActionIndepSamps *act)
{
gboolean by_values = gtk_toggle_button_get_active (button);
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);
}
if (act->group_defn == GROUPS_VALUES)
- {
- g_string_append (str, ",");
+ {
+ g_string_append (str, ",");
{
struct string strx;
g_string_append (str, ds_cstr (&strx));
ds_destroy (&strx);
}
- }
+ }
g_string_append (str, ")");
}
#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;
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");
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;
for (i = 0; i < n_KIDS; ++i)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (kid->checkbutton[i]),
- FALSE);
+ FALSE);
}
}
{
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);
}
}
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);
#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;
psppire_dialog_action_set_refresh (pda, refresh);
g_object_set (pda->source,
- "predicate", var_is_numeric,
- NULL);
+ "predicate", var_is_numeric,
+ NULL);
return xml;
}
#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;
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");
#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;
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);
psppire_dialog_action_set_refresh (pda, refresh);
psppire_dialog_action_set_valid_predicate (pda,
- dialog_state_valid);
+ dialog_state_valid);
return xml;
}
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 =");
#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;
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");
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);
#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;
{
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)
{
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");
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);
/* 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;
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)
{
/* 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);
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");
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);
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));
{
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;
}
}\f
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);
}
#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;
/* 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);
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;
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);
{
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);
}
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);
}
}
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;
}
#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;
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))
{
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=");
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);
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);
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));
}
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);
#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;
return FALSE;
if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map),
- ¬_used))
+ ¬_used))
return FALSE;
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;
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);
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
{
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);
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);
}
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;
}
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)));
+ }
}
}
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);
+ }
}
}
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
#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;
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);
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;
}
#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;
{
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:
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;
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);
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);
}
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;
}
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));
}
GtkBuilder *
psppire_dialog_action_recode_pre_activate (PsppireDialogActionRecode *act,
- void (*populate_treeview) (PsppireDialogActionRecode *))
+ void (*populate_treeview) (PsppireDialogActionRecode *))
{
PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (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);
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;
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);
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 =
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;
}
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;
}
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))
{
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);
#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;
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
#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")) \
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;
}
}
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;
}
{
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)
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");
#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;
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");
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))));
}
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 *
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);
#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;
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
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;
}
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);
{
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");
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");
#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;
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;
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;
#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;
#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;
{
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;
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);
}
}
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);
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);
}
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);
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);
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);
}
}
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);
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)
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);
}
}
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");
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;
}
(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");
}
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)));
}
#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;
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, ".");
psppire_dialog_action_set_refresh (pda, reset);
psppire_dialog_action_set_valid_predicate (pda,
- dialog_state_valid);
+ dialog_state_valid);
return xml;
}
#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;
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);
}
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);
}
static void
on_off_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+ gpointer user_data)
{
PsppireDialogActionSplit *act = PSPPIRE_DIALOG_ACTION_SPLIT (user_data);
#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;
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=");
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");
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;
}
#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;
/* 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);
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;
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);
{
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);
}
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);
}
}
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;
}
#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;
#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;
struct variable **vars;
g_object_get (treeview, "model", &dict,
- NULL);
+ NULL);
psppire_dict_view_get_selected_variables (PSPPIRE_DICT_VIEW (treeview),
&vars, &n_vars);
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;
}
#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;
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;
}
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);
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);
#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;
}
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
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);
{
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:
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);
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)
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)
{
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;
+ }
}
}
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;
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);
void
psppire_dialog_action_set_refresh (PsppireDialogAction *pda,
- PsppireDialogActionRefresh refresh)
+ PsppireDialogActionRefresh refresh)
{
g_signal_connect_swapped (pda->dialog, "refresh", G_CALLBACK (refresh), pda);
}
#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;
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);
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);
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);
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;
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);
}
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);
}
PsppireDialog *dialog ;
dialog = g_object_new (psppire_dialog_get_type (),
- NULL);
+ NULL);
return GTK_WIDGET (dialog) ;
}
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
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));
}
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))
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))
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);
+ }
}
}
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);
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;
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);
/* --- prototypes --- */
-static void psppire_dict_dispose (GObject *object);
+static void psppire_dict_dispose (GObject *object);
static void dictionary_tree_model_init (GtkTreeModelIface *iface);
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);
}
}
/* --- 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)
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
*/
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));
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)
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;
}
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);
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);
static gboolean
tree_model_nth_child (GtkTreeModel *model, GtkTreeIter *iter,
- GtkTreeIter *parent, gint n)
+ GtkTreeIter *parent, gint n)
{
PsppireDict *dict;
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;
/* --- typedefs & structures --- */
-typedef struct _PsppireDict PsppireDict;
+typedef struct _PsppireDict PsppireDict;
typedef struct _PsppireDictClass PsppireDictClass;
enum {DICT_TVM_COL_NAME=0,
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 *);
{
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)
{
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
{
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);
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:
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);
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:
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,
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;
}
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;
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 (
- "<span stretch=\"condensed\">%s</span>",
- var_get_label (var));
+ "<span stretch=\"condensed\">%s</span>",
+ var_get_label (var));
g_object_set (cell, "markup", text, NULL);
g_free (text);
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);
{
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:
case MEASURE_ORDINAL: return "measure-ordinal";
case MEASURE_SCALE: return "measure-scale";
case n_MEASURES: break;
- }
+ }
break;
}
/* 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;
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;
}
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);
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);
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 ();
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);
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
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);
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);
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);
}
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);
}
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);
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;
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));
}
/* 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);
}
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"));
}
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");
}
#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;
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);
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);
}
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);
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,
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);
}
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
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
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");
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);
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);
}
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 "
{
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));
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);
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);
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);
}
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);
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);
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);
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 ();
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]);
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);
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);
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);
}
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 ? "." : "");
}
}
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");
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);
}
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);
}
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;
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);
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"));
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);
}
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,
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);
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));
}
}
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);
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. */
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);
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;
}
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
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
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);
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);
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 */
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);
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;
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 ();
gtk_tree_store_set (store, &iter,
COL_LABEL, output_item_get_label (item),
- COL_ADDR, item,
+ COL_ADDR, item,
COL_Y, view->y,
-1);
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;
{
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;
}
static void
clipboard_clear_cb (GtkClipboard *clipboard,
- gpointer data)
+ gpointer data)
{
}
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);
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)
{
static gboolean
paginate (GtkPrintOperation *operation,
- GtkPrintContext *context,
- struct psppire_output_view *view)
+ GtkPrintContext *context,
+ struct psppire_output_view *view)
{
if (view->paginated)
{
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);
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;
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));
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 *);
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;
}
{
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));
}
}
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);
{
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;
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
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);
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));
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);
const gchar *accels[2] = { "<Primary>P", NULL};
gtk_application_set_accels_for_action (app,
- "win.print",
- accels);
+ "win.print",
+ accels);
}
const gchar *accels[2] = { "<Primary>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);
}
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
*/
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);
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);
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);
{
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);
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);
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);
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);
GtkWidget **field;
if (psppire_get_conversion_char (PSPPIRE_SCANF (w), i) == '%')
- continue;
+ continue;
field = va_arg (ap, GtkWidget **);
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);
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);
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);
}
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);
}
+----------------------------------------------------------+
- | |
- | 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
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;
}
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);
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);
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;
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;
/* 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));
}
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);
}
}
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));
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;
+ };
}
}
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);
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
{
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);
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);
PsppireSelector *selector = list->data;
if (selector->filter && selector->filter (childmodel, iter, selector))
- return FALSE;
+ return FALSE;
list = list->next;
}
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);
}
else
{ /* Append this selector to the list and push the <source,list>
- 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);
+ }
}
}
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);
}
*/
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;
static void
on_dest_data_delete (GtkTreeModel *tree_model,
- GtkTreePath *path,
- gpointer user_data)
+ GtkTreePath *path,
+ gpointer user_data)
{
PsppireSelector *selector = user_data;
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);
/* 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);
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));
g_signal_connect (selection, "changed", G_CALLBACK (on_dest_treeview_select),
- selector);
+ selector);
}
/* 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);
}
if (selector->filter == NULL)
{
if (GTK_IS_TREE_VIEW (selector->dest))
- selector->filter = is_item_in_dest;
+ selector->filter = is_item_in_dest;
}
}
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);
}
}
/* Set FILTER_FUNC for this selector */
void
psppire_selector_set_filter_func (PsppireSelector *selector,
- FilterItemsFunc *filter_func)
+ FilterItemsFunc *filter_func)
{
selector->filter = 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)
{
selector->select_user_data = user_data;
selector->select_items = select_func;
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;
/* 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);
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
{
/* 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);
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
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 */
#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;
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
{
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:
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:
break;
default:
g_error ("%s:%d Invalid column in spreadsheet model",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
break;
}
}
#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;
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);
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 (
/* 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);
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;
{
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);
*/
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;
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);
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 (
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;
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);
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);
}
{
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] = { "<Primary>S", NULL};
gtk_application_set_accels_for_action (app,
- "win.save",
- accels);
+ "win.save",
+ accels);
}
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] = { "<Shift><Primary>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));
}
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] = { "<Primary>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);
}
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));
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));
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
PsppireSyntaxWindow *window)
{
gtk_source_print_compositor_draw_page (window->compositor,
- context,
- page_nr);
+ context,
+ page_nr);
}
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);
}
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);
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);
static gboolean
__tree_get_iter (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreePath *path)
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
PsppireTextFile *file = PSPPIRE_TEXT_FILE (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);
static GType
__tree_get_column_type (GtkTreeModel *tree_model,
- gint index)
+ gint index)
{
if (index == 0)
return G_TYPE_INT;
static gboolean
__iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
return 0;
}
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);
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);
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);
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);
}
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)
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;
{
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;
}
-#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))
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);
{
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:
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);
{
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:
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);
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);
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;
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);
++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);
{
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:
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:
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;
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:
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;
+ }
}
}
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)
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");
*/
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
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
/* 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);
/* 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);
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);
}
/* 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);
}
{
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;
*/
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};
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);
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);
}
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);
{
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:
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;
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);
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));
}
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));
}
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));
}
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);
}
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;
}
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;
}
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;
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);
}
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);
}
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));
}
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 ();
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;
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);
}
\f
{
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:
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:
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);
}
}
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;
{
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;
{
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);
}
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);
static GObject*
psppire_window_register_construct (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
{
GObject *object;
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
void
psppire_window_register_foreach (PsppireWindowRegister *wr,
- GHFunc func, gpointer data)
+ GHFunc func, gpointer data)
{
g_hash_table_foreach (wr->name_table, func, data);
}
#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;
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);
void psppire_window_register_foreach (PsppireWindowRegister *wr, GHFunc func,
- gpointer);
+ gpointer);
gint psppire_window_register_n_items (PsppireWindowRegister *wr);
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);
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);
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;
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))
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;
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);
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);
}
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);
{
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)
}
g_free (encoding);
- fh_unref (fh);
- g_free (name);
+ fh_unref (fh);
+ g_free (name);
}
break;
default:
#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))
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 ();
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);
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");
}
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);
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);
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");
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;
}
}
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));
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);
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),"");
}
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));
}
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);
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));
}
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);
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),
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. */
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);
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);
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);
}
{
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);
}
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);
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");
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");
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 =
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)
/* 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);
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 */
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);
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 */
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);
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",
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);
}
var_type_dialog_set_active_button (PsppireVarTypeDialog *dialog, gint b)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radioButton[b]),
- TRUE);
+ TRUE);
}
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);
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;
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);
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);
{
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");
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");
if (ok && v_out.f == number)
{
syntax_gen_string (output, ss_cstr (s));
- free (s);
+ free (s);
return;
}
free (s);
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)
{
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;
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))
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 ();
}
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
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);
}
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);
}
}
- case_unref (c);
+ case_unref (c);
}
c = casereader_read (reader);
{
switch (opt)
{
- case OPT_METADATA:
- get_n_sheets = true;
- break;
+ case OPT_METADATA:
+ get_n_sheets = true;
+ break;
case OPT_REFCHECK:
refcheck = true;
break;
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)
{
assert (row == r);
assert (col == c);
}
- else
+ else
{
fputs (s ? s : "", stdout);
- if (c_ < columns - 1)
- putchar ('\t');
+ if (c_ < columns - 1)
+ putchar ('\t');
}
}
if (!refcheck)
{
- putchar ('\n');
+ putchar ('\n');
}
}
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]))
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
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);
#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
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);
ds_cstr (&alphabet), length, password_list))
goto exit;
else
- goto error;
+ goto 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,
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,
/* 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);
free (value);
free (label);
- }
+ }
}
}
/* Read values. */
for (int i = 0; i < n_missing_values; i++)
- {
+ {
posn = ftello (r->file);
/* Read value. */
printf (" \"%s\"", value);
free (value);
- }
+ }
printf ("\n");
}
}