From 7dc203206d3f3172474a4ec0f4dcab5364f4ce26 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 14 Mar 2005 06:54:40 +0000 Subject: [PATCH] First phase of making SORT CASES stable (PR 12035). Clean-ups. More AGGREGATE fixes. --- po/en_GB.po | 262 ++++++++++++++++++++++++---------------------- po/pspp.pot | 262 ++++++++++++++++++++++++---------------------- src/ChangeLog | 50 +++++++++ src/aggregate.c | 24 ++--- src/casefile.c | 16 ++- src/casefile.h | 2 + src/data-list.c | 3 +- src/dictionary.c | 24 +++++ src/dictionary.h | 2 + src/file-handle.q | 2 +- src/file-type.c | 2 +- src/flip.c | 11 +- src/get.c | 4 +- src/inpt-pgm.c | 6 +- src/matrix-data.c | 5 +- src/sort.c | 74 +++++++------ src/vfm.c | 55 ++-------- src/vfm.h | 10 +- 18 files changed, 442 insertions(+), 372 deletions(-) diff --git a/po/en_GB.po b/po/en_GB.po index c73d71ea..ec8fd66d 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.3.1\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-03-13 09:00+0800\n" +"POT-Creation-Date: 2005-03-13 22:49-0800\n" "PO-Revision-Date: 2004-01-23 13:04+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -16,56 +16,62 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n!=1);\n" -#: src/aggregate.c:180 src/aggregate.c:213 src/data-list.c:1424 -#: src/data-list.c:1459 src/data-list.c:1472 src/data-list.c:1485 -#: src/data-list.c:1518 -#, c-format -msgid "%s subcommand given multiple times." +#: src/aggregate.c:193 +msgid "while expecting COLUMNWISE" msgstr "" -#: src/aggregate.c:198 -msgid "while expecting COLUMNWISE" +#: src/aggregate.c:225 +msgid "expecting BREAK" msgstr "" -#: src/aggregate.c:236 -msgid "BREAK subcommand not specified." +#: src/aggregate.c:230 +msgid "" +"When PRESORTED is specified, specifying sorting directions with (A) or (D) " +"has no effect. Output data will be sorted the same way as the input data." msgstr "" -#: src/aggregate.c:390 +#: src/aggregate.c:387 msgid "expecting aggregation function" msgstr "" -#: src/aggregate.c:406 +#: src/aggregate.c:403 #, c-format msgid "Unknown aggregation function %s." msgstr "" -#: src/aggregate.c:421 +#: src/aggregate.c:418 msgid "expecting `('" msgstr "" -#: src/aggregate.c:458 +#: src/aggregate.c:455 #, c-format msgid "Missing argument %d to %s." msgstr "" -#: src/aggregate.c:466 +#: src/aggregate.c:463 #, c-format msgid "Arguments to %s must be of same type as source variables." msgstr "" -#: src/aggregate.c:476 +#: src/aggregate.c:473 msgid "expecting `)'" msgstr "" -#: src/aggregate.c:488 +#: src/aggregate.c:485 #, c-format msgid "" "Number of source variables (%d) does not match number of target variables (%" "d)." msgstr "" -#: src/aggregate.c:556 +#: src/aggregate.c:502 +#, c-format +msgid "" +"The value arguments passed to the %s function are out-of-order. They will " +"be treated as if they had been specified in the correct order." +msgstr "" + +#: src/aggregate.c:570 #, c-format msgid "" "Variable name %s is not unique within the aggregate file dictionary, which " @@ -227,7 +233,7 @@ msgid "Source variable count (%d) does not match target variable count (%d)." msgstr "" #: src/autorecode.c:139 src/command.c:791 src/compute.c:277 -#: src/data-list.c:410 src/data-list.c:900 src/data-list.c:1751 +#: src/data-list.c:409 src/data-list.c:899 src/data-list.c:1750 #: src/do-if.c:253 src/get.c:406 src/lexer.c:420 src/loop.c:241 #: src/matrix-data.c:527 src/print.c:335 src/print.c:1045 src/recode.c:405 #: src/sel-if.c:54 src/sel-if.c:131 src/vector.c:193 src/file-handle.q:140 @@ -651,254 +657,260 @@ msgstr "" msgid "Only one of FIXED, FREE, or LIST may be specified." msgstr "" -#: src/data-list.c:357 src/print.c:296 +#: src/data-list.c:356 src/print.c:296 #, c-format msgid "" "The record number specified, %ld, is before the previous record, %d. Data " "fields must be listed in order of increasing record number." msgstr "" -#: src/data-list.c:386 src/data-list.c:1740 +#: src/data-list.c:385 src/data-list.c:1739 msgid "" "SPSS-like or FORTRAN-like format specification expected after variable names." msgstr "" -#: src/data-list.c:397 +#: src/data-list.c:396 msgid "At least one variable must be specified." msgstr "" -#: src/data-list.c:402 src/print.c:328 +#: src/data-list.c:401 src/print.c:328 msgid "" "Variables are specified on records that should not exist according to " "RECORDS subcommand." msgstr "" -#: src/data-list.c:440 src/data-list.c:454 src/print.c:520 src/print.c:533 +#: src/data-list.c:439 src/data-list.c:453 src/print.c:520 src/print.c:533 msgid "Column positions for fields must be positive." msgstr "" -#: src/data-list.c:459 +#: src/data-list.c:458 msgid "The ending column for a field must be greater than the starting column." msgstr "" -#: src/data-list.c:473 src/print.c:610 +#: src/data-list.c:472 src/print.c:610 #, c-format msgid "The %d columns %d-%d can't be evenly divided into %d fields." msgstr "" -#: src/data-list.c:493 src/print.c:561 +#: src/data-list.c:492 src/print.c:561 msgid "A format specifier on this line has extra characters on the end." msgstr "" -#: src/data-list.c:508 src/print.c:577 +#: src/data-list.c:507 src/print.c:577 msgid "The value for number of decimal places must be at least 1." msgstr "" -#: src/data-list.c:522 src/print.c:590 +#: src/data-list.c:521 src/print.c:590 #, c-format msgid "Input format %s doesn't accept decimal places." msgstr "" -#: src/data-list.c:569 src/data-list.c:665 src/data-list.c:879 +#: src/data-list.c:568 src/data-list.c:664 src/data-list.c:878 #, c-format msgid "%s is a duplicate variable name." msgstr "" -#: src/data-list.c:574 +#: src/data-list.c:573 #, c-format msgid "There is already a variable %s of a different type." msgstr "" -#: src/data-list.c:581 +#: src/data-list.c:580 #, c-format msgid "There is already a string variable %s of a different width." msgstr "" -#: src/data-list.c:656 +#: src/data-list.c:655 msgid "" "The number of format specifications exceeds the given number of variable " "names." msgstr "" -#: src/data-list.c:769 src/print.c:765 +#: src/data-list.c:768 src/print.c:765 msgid "" "There aren't enough format specifications to match the number of variable " "names given." msgstr "" -#: src/data-list.c:796 src/data-list.c:922 src/descript.c:880 src/print.c:796 -#: src/sysfile-info.c:134 src/sysfile-info.c:367 src/vfm.c:873 +#: src/data-list.c:795 src/data-list.c:921 src/descript.c:880 src/print.c:796 +#: src/sysfile-info.c:134 src/sysfile-info.c:367 src/vfm.c:830 msgid "Variable" msgstr "" -#: src/data-list.c:797 src/print.c:797 +#: src/data-list.c:796 src/print.c:797 msgid "Record" msgstr "" -#: src/data-list.c:798 src/print.c:798 +#: src/data-list.c:797 src/print.c:798 msgid "Columns" msgstr "" -#: src/data-list.c:799 src/data-list.c:923 src/print.c:799 +#: src/data-list.c:798 src/data-list.c:922 src/print.c:799 msgid "Format" msgstr "" -#: src/data-list.c:815 +#: src/data-list.c:814 #, c-format msgid "Reading %d record from file %s." msgid_plural "Reading %d records from file %s." msgstr[0] "" msgstr[1] "" -#: src/data-list.c:819 +#: src/data-list.c:818 #, c-format msgid "Reading %d record from the command file." msgid_plural "Reading %d records from the command file." msgstr[0] "" msgstr[1] "" -#: src/data-list.c:939 +#: src/data-list.c:938 #, c-format msgid "Reading free-form data from file %s." msgstr "" -#: src/data-list.c:942 +#: src/data-list.c:941 msgid "Reading free-form data from the command file." msgstr "" -#: src/data-list.c:993 +#: src/data-list.c:992 #, c-format msgid "Quoted string missing terminating `%c'." msgstr "" -#: src/data-list.c:1102 +#: src/data-list.c:1101 #, c-format msgid "Partial case of %d of %d records discarded." msgstr "" -#: src/data-list.c:1156 +#: src/data-list.c:1155 #, c-format msgid "Partial case discarded. The first variable missing was %s." msgstr "" -#: src/data-list.c:1200 +#: src/data-list.c:1199 #, c-format msgid "" "Missing value(s) for all variables from %s onward. These will be filled " "with the system-missing value or blanks, as appropriate." msgstr "" -#: src/data-list.c:1278 +#: src/data-list.c:1277 msgid "Attempt to read past end of file." msgstr "" -#: src/data-list.c:1414 +#: src/data-list.c:1413 msgid "" "REPEATING DATA must use the same file as its corresponding DATA LIST or FILE " "TYPE." msgstr "" -#: src/data-list.c:1448 +#: src/data-list.c:1423 src/data-list.c:1458 src/data-list.c:1471 +#: src/data-list.c:1484 src/data-list.c:1517 +#, c-format +msgid "%s subcommand given multiple times." +msgstr "" + +#: src/data-list.c:1447 #, c-format msgid "STARTS beginning column (%d) exceeds STARTS ending column (%d)." msgstr "" -#: src/data-list.c:1504 +#: src/data-list.c:1503 #, c-format msgid "CONTINUED beginning column (%d) exceeds CONTINUED ending column (%d)." msgstr "" -#: src/data-list.c:1527 +#: src/data-list.c:1526 #, c-format msgid "ID beginning column (%ld) must be positive." msgstr "" -#: src/data-list.c:1542 +#: src/data-list.c:1541 #, c-format msgid "ID ending column (%ld) must be positive." msgstr "" -#: src/data-list.c:1548 +#: src/data-list.c:1547 #, c-format msgid "ID ending column (%ld) cannot be less than ID beginning column (%d)." msgstr "" -#: src/data-list.c:1588 +#: src/data-list.c:1587 msgid "Missing required specification STARTS." msgstr "" -#: src/data-list.c:1590 +#: src/data-list.c:1589 msgid "Missing required specification OCCURS." msgstr "" -#: src/data-list.c:1597 +#: src/data-list.c:1596 msgid "ID specified without CONTINUED." msgstr "" -#: src/data-list.c:1689 +#: src/data-list.c:1688 msgid "String variable not allowed here." msgstr "" -#: src/data-list.c:1699 +#: src/data-list.c:1698 #, c-format msgid "%s (%d) must be at least 1." msgstr "" -#: src/data-list.c:1705 +#: src/data-list.c:1704 #, c-format msgid "Variable or integer expected for %s." msgstr "" -#: src/data-list.c:1843 +#: src/data-list.c:1842 #, c-format msgid "Encountered mismatched record ID \"%s\" expecting \"%s\"." msgstr "" -#: src/data-list.c:1875 +#: src/data-list.c:1874 #, c-format msgid "" "Variable %s starting in column %d extends beyond physical record length of %" "d." msgstr "" -#: src/data-list.c:1943 +#: src/data-list.c:1942 #, c-format msgid "Invalid value %d for OCCURS." msgstr "" -#: src/data-list.c:1949 +#: src/data-list.c:1948 #, c-format msgid "Beginning column for STARTS (%d) must be at least 1." msgstr "" -#: src/data-list.c:1957 +#: src/data-list.c:1956 #, c-format msgid "Ending column for STARTS (%d) is less than beginning column (%d)." msgstr "" -#: src/data-list.c:1965 +#: src/data-list.c:1964 #, c-format msgid "Invalid value %d for LENGTH." msgstr "" -#: src/data-list.c:1972 +#: src/data-list.c:1971 #, c-format msgid "Beginning column for CONTINUED (%d) must be at least 1." msgstr "" -#: src/data-list.c:1980 +#: src/data-list.c:1979 #, c-format msgid "Ending column for CONTINUED (%d) is less than beginning column (%d)." msgstr "" -#: src/data-list.c:2012 +#: src/data-list.c:2011 #, c-format msgid "" "Number of repetitions specified on OCCURS (%d) exceed number of repetitions " "available in space on STARTS (%d), and CONTINUED not specified." msgstr "" -#: src/data-list.c:2030 +#: src/data-list.c:2029 #, c-format msgid "Unexpected end of file with %d repetitions remaining out of %d." msgstr "" @@ -1209,25 +1221,6 @@ msgstr "" msgid "installation error" msgstr "" -#: src/filename.c:221 -#, c-format -msgid "Searching for `%s'..." -msgstr "" - -#: src/filename.c:229 src/filename.c:261 -msgid "Search unsuccessful!" -msgstr "" - -#: src/filename.c:254 -#, c-format -msgid "Found `%s'." -msgstr "" - -#: src/filename.c:686 -#, c-format -msgid "Not opening pipe file `%s' because SAFER option set." -msgstr "" - #: src/file-type.c:129 msgid "MIXED, GROUPED, or NESTED expected." msgstr "" @@ -1366,64 +1359,83 @@ msgstr "" msgid "Unknown record type %g." msgstr "" -#: src/flip.c:81 +#: src/filename.c:221 +#, c-format +msgid "Searching for `%s'..." +msgstr "" + +#: src/filename.c:229 src/filename.c:261 +msgid "Search unsuccessful!" +msgstr "" + +#: src/filename.c:254 +#, c-format +msgid "Found `%s'." +msgstr "" + +#: src/filename.c:686 +#, c-format +msgid "Not opening pipe file `%s' because SAFER option set." +msgstr "" + +#: src/flip.c:82 msgid "" "FLIP ignores TEMPORARY. Temporary transformations will be made permanent." msgstr "" -#: src/flip.c:221 +#: src/flip.c:224 #, c-format msgid "Could not create acceptable variant for variable %s." msgstr "" -#: src/flip.c:237 +#: src/flip.c:240 msgid "Cannot create more than 99999 variable names." msgstr "" -#: src/flip.c:281 +#: src/flip.c:284 msgid "Could not create temporary file for FLIP." msgstr "" -#: src/flip.c:288 src/flip.c:356 +#: src/flip.c:291 src/flip.c:359 #, c-format msgid "Error writing FLIP file: %s." msgstr "" -#: src/flip.c:398 +#: src/flip.c:401 #, c-format msgid "Error rewinding FLIP file: %s." msgstr "" -#: src/flip.c:402 +#: src/flip.c:405 msgid "Error creating FLIP source file." msgstr "" -#: src/flip.c:411 +#: src/flip.c:414 #, c-format msgid "Error reading FLIP file: %s." msgstr "" -#: src/flip.c:432 +#: src/flip.c:435 #, c-format msgid "Error seeking FLIP source file: %s." msgstr "" -#: src/flip.c:437 +#: src/flip.c:440 #, c-format msgid "Error writing FLIP source file: %s." msgstr "" -#: src/flip.c:448 +#: src/flip.c:451 #, c-format msgid "Error rewind FLIP source file: %s." msgstr "" -#: src/flip.c:500 +#: src/flip.c:503 #, c-format msgid "Error reading FLIP temporary file: %s." msgstr "" -#: src/flip.c:503 +#: src/flip.c:506 msgid "Unexpected end of file reading FLIP temporary file." msgstr "" @@ -1828,27 +1840,27 @@ msgstr "" msgid "expecting filename" msgstr "" -#: src/inpt-pgm.c:82 +#: src/inpt-pgm.c:81 msgid "No matching INPUT PROGRAM command." msgstr "" -#: src/inpt-pgm.c:87 +#: src/inpt-pgm.c:86 msgid "" "No data-input or transformation commands specified between INPUT PROGRAM and " "END INPUT PROGRAM." msgstr "" -#: src/inpt-pgm.c:288 src/inpt-pgm.c:416 +#: src/inpt-pgm.c:284 src/inpt-pgm.c:412 msgid "" "This command may only be executed between INPUT PROGRAM and END INPUT " "PROGRAM." msgstr "" -#: src/inpt-pgm.c:338 +#: src/inpt-pgm.c:334 msgid "COLUMN subcommand multiply specified." msgstr "" -#: src/inpt-pgm.c:389 +#: src/inpt-pgm.c:385 msgid "" "REREAD: Column numbers must be positive finite numbers. Column set to 1." msgstr "" @@ -2116,69 +2128,69 @@ msgstr "" msgid "End of line expected %s while reading %s." msgstr "" -#: src/matrix-data.c:1106 +#: src/matrix-data.c:1105 #, c-format msgid "expecting value for %s %s" msgstr "" -#: src/matrix-data.c:1270 +#: src/matrix-data.c:1269 #, c-format msgid "Syntax error expecting SPLIT FILE value %s." msgstr "" -#: src/matrix-data.c:1279 +#: src/matrix-data.c:1278 #, c-format msgid "Expecting value %g for %s." msgstr "" -#: src/matrix-data.c:1320 src/matrix-data.c:1787 +#: src/matrix-data.c:1319 src/matrix-data.c:1786 #, c-format msgid "Syntax error expecting factor value %s." msgstr "" -#: src/matrix-data.c:1329 +#: src/matrix-data.c:1328 #, c-format msgid "Syntax error expecting value %g for %s %s." msgstr "" -#: src/matrix-data.c:1564 +#: src/matrix-data.c:1563 #, c-format msgid "Syntax error %s expecting SPLIT FILE value." msgstr "" -#: src/matrix-data.c:1694 +#: src/matrix-data.c:1693 #, c-format msgid "" "Expected %d lines of data for %s content; actually saw %d lines. No data " "will be output for this content." msgstr "" -#: src/matrix-data.c:1729 +#: src/matrix-data.c:1728 #, c-format msgid "Multiply specified ROWTYPE_ %s." msgstr "" -#: src/matrix-data.c:1734 +#: src/matrix-data.c:1733 #, c-format msgid "Syntax error %s expecting ROWTYPE_ string." msgstr "" -#: src/matrix-data.c:1754 +#: src/matrix-data.c:1753 #, c-format msgid "Syntax error %s." msgstr "" -#: src/matrix-data.c:1904 +#: src/matrix-data.c:1903 #, c-format msgid "Duplicate specification for %s." msgstr "" -#: src/matrix-data.c:1916 +#: src/matrix-data.c:1915 #, c-format msgid "Too many rows of matrix data for %s." msgstr "" -#: src/matrix-data.c:1964 +#: src/matrix-data.c:1963 #, c-format msgid "Syntax error expecting value for %s %s." msgstr "" @@ -3338,15 +3350,15 @@ msgstr "" msgid "%s: Writing system file: %s." msgstr "" -#: src/sort.c:197 +#: src/sort.c:203 msgid "`A' or `D' expected inside parentheses." msgstr "" -#: src/sort.c:202 +#: src/sort.c:208 msgid "`)' expected." msgstr "" -#: src/sort.c:552 src/sort.c:730 +#: src/sort.c:572 src/sort.c:750 #, c-format msgid "" "Out of memory. Could not allocate room for minimum of %d cases of %d bytes " @@ -3454,7 +3466,7 @@ msgstr "" msgid "Documents in the active file:" msgstr "" -#: src/sysfile-info.c:374 src/sysfile-info.c:532 src/vfm.c:875 +#: src/sysfile-info.c:374 src/sysfile-info.c:532 src/vfm.c:832 msgid "Label" msgstr "" @@ -3477,7 +3489,7 @@ msgstr "" msgid "Missing Values: " msgstr "" -#: src/sysfile-info.c:531 src/vfm.c:874 src/crosstabs.q:1099 +#: src/sysfile-info.c:531 src/vfm.c:831 src/crosstabs.q:1099 #: src/crosstabs.q:1126 src/crosstabs.q:1146 src/crosstabs.q:1168 #: src/examine.q:1129 src/frequencies.q:1138 src/frequencies.q:1259 msgid "Value" diff --git a/po/pspp.pot b/po/pspp.pot index 2f803f66..8aadfe56 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-03-13 09:00+0800\n" +"POT-Creation-Date: 2005-03-13 22:49-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,56 +17,62 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: src/aggregate.c:180 src/aggregate.c:213 src/data-list.c:1424 -#: src/data-list.c:1459 src/data-list.c:1472 src/data-list.c:1485 -#: src/data-list.c:1518 -#, c-format -msgid "%s subcommand given multiple times." +#: src/aggregate.c:193 +msgid "while expecting COLUMNWISE" msgstr "" -#: src/aggregate.c:198 -msgid "while expecting COLUMNWISE" +#: src/aggregate.c:225 +msgid "expecting BREAK" msgstr "" -#: src/aggregate.c:236 -msgid "BREAK subcommand not specified." +#: src/aggregate.c:230 +msgid "" +"When PRESORTED is specified, specifying sorting directions with (A) or (D) " +"has no effect. Output data will be sorted the same way as the input data." msgstr "" -#: src/aggregate.c:390 +#: src/aggregate.c:387 msgid "expecting aggregation function" msgstr "" -#: src/aggregate.c:406 +#: src/aggregate.c:403 #, c-format msgid "Unknown aggregation function %s." msgstr "" -#: src/aggregate.c:421 +#: src/aggregate.c:418 msgid "expecting `('" msgstr "" -#: src/aggregate.c:458 +#: src/aggregate.c:455 #, c-format msgid "Missing argument %d to %s." msgstr "" -#: src/aggregate.c:466 +#: src/aggregate.c:463 #, c-format msgid "Arguments to %s must be of same type as source variables." msgstr "" -#: src/aggregate.c:476 +#: src/aggregate.c:473 msgid "expecting `)'" msgstr "" -#: src/aggregate.c:488 +#: src/aggregate.c:485 #, c-format msgid "" "Number of source variables (%d) does not match number of target variables (%" "d)." msgstr "" -#: src/aggregate.c:556 +#: src/aggregate.c:502 +#, c-format +msgid "" +"The value arguments passed to the %s function are out-of-order. They will " +"be treated as if they had been specified in the correct order." +msgstr "" + +#: src/aggregate.c:570 #, c-format msgid "" "Variable name %s is not unique within the aggregate file dictionary, which " @@ -228,7 +234,7 @@ msgid "Source variable count (%d) does not match target variable count (%d)." msgstr "" #: src/autorecode.c:139 src/command.c:791 src/compute.c:277 -#: src/data-list.c:410 src/data-list.c:900 src/data-list.c:1751 +#: src/data-list.c:409 src/data-list.c:899 src/data-list.c:1750 #: src/do-if.c:253 src/get.c:406 src/lexer.c:420 src/loop.c:241 #: src/matrix-data.c:527 src/print.c:335 src/print.c:1045 src/recode.c:405 #: src/sel-if.c:54 src/sel-if.c:131 src/vector.c:193 src/file-handle.q:140 @@ -652,254 +658,260 @@ msgstr "" msgid "Only one of FIXED, FREE, or LIST may be specified." msgstr "" -#: src/data-list.c:357 src/print.c:296 +#: src/data-list.c:356 src/print.c:296 #, c-format msgid "" "The record number specified, %ld, is before the previous record, %d. Data " "fields must be listed in order of increasing record number." msgstr "" -#: src/data-list.c:386 src/data-list.c:1740 +#: src/data-list.c:385 src/data-list.c:1739 msgid "" "SPSS-like or FORTRAN-like format specification expected after variable names." msgstr "" -#: src/data-list.c:397 +#: src/data-list.c:396 msgid "At least one variable must be specified." msgstr "" -#: src/data-list.c:402 src/print.c:328 +#: src/data-list.c:401 src/print.c:328 msgid "" "Variables are specified on records that should not exist according to " "RECORDS subcommand." msgstr "" -#: src/data-list.c:440 src/data-list.c:454 src/print.c:520 src/print.c:533 +#: src/data-list.c:439 src/data-list.c:453 src/print.c:520 src/print.c:533 msgid "Column positions for fields must be positive." msgstr "" -#: src/data-list.c:459 +#: src/data-list.c:458 msgid "The ending column for a field must be greater than the starting column." msgstr "" -#: src/data-list.c:473 src/print.c:610 +#: src/data-list.c:472 src/print.c:610 #, c-format msgid "The %d columns %d-%d can't be evenly divided into %d fields." msgstr "" -#: src/data-list.c:493 src/print.c:561 +#: src/data-list.c:492 src/print.c:561 msgid "A format specifier on this line has extra characters on the end." msgstr "" -#: src/data-list.c:508 src/print.c:577 +#: src/data-list.c:507 src/print.c:577 msgid "The value for number of decimal places must be at least 1." msgstr "" -#: src/data-list.c:522 src/print.c:590 +#: src/data-list.c:521 src/print.c:590 #, c-format msgid "Input format %s doesn't accept decimal places." msgstr "" -#: src/data-list.c:569 src/data-list.c:665 src/data-list.c:879 +#: src/data-list.c:568 src/data-list.c:664 src/data-list.c:878 #, c-format msgid "%s is a duplicate variable name." msgstr "" -#: src/data-list.c:574 +#: src/data-list.c:573 #, c-format msgid "There is already a variable %s of a different type." msgstr "" -#: src/data-list.c:581 +#: src/data-list.c:580 #, c-format msgid "There is already a string variable %s of a different width." msgstr "" -#: src/data-list.c:656 +#: src/data-list.c:655 msgid "" "The number of format specifications exceeds the given number of variable " "names." msgstr "" -#: src/data-list.c:769 src/print.c:765 +#: src/data-list.c:768 src/print.c:765 msgid "" "There aren't enough format specifications to match the number of variable " "names given." msgstr "" -#: src/data-list.c:796 src/data-list.c:922 src/descript.c:880 src/print.c:796 -#: src/sysfile-info.c:134 src/sysfile-info.c:367 src/vfm.c:873 +#: src/data-list.c:795 src/data-list.c:921 src/descript.c:880 src/print.c:796 +#: src/sysfile-info.c:134 src/sysfile-info.c:367 src/vfm.c:830 msgid "Variable" msgstr "" -#: src/data-list.c:797 src/print.c:797 +#: src/data-list.c:796 src/print.c:797 msgid "Record" msgstr "" -#: src/data-list.c:798 src/print.c:798 +#: src/data-list.c:797 src/print.c:798 msgid "Columns" msgstr "" -#: src/data-list.c:799 src/data-list.c:923 src/print.c:799 +#: src/data-list.c:798 src/data-list.c:922 src/print.c:799 msgid "Format" msgstr "" -#: src/data-list.c:815 +#: src/data-list.c:814 #, c-format msgid "Reading %d record from file %s." msgid_plural "Reading %d records from file %s." msgstr[0] "" msgstr[1] "" -#: src/data-list.c:819 +#: src/data-list.c:818 #, c-format msgid "Reading %d record from the command file." msgid_plural "Reading %d records from the command file." msgstr[0] "" msgstr[1] "" -#: src/data-list.c:939 +#: src/data-list.c:938 #, c-format msgid "Reading free-form data from file %s." msgstr "" -#: src/data-list.c:942 +#: src/data-list.c:941 msgid "Reading free-form data from the command file." msgstr "" -#: src/data-list.c:993 +#: src/data-list.c:992 #, c-format msgid "Quoted string missing terminating `%c'." msgstr "" -#: src/data-list.c:1102 +#: src/data-list.c:1101 #, c-format msgid "Partial case of %d of %d records discarded." msgstr "" -#: src/data-list.c:1156 +#: src/data-list.c:1155 #, c-format msgid "Partial case discarded. The first variable missing was %s." msgstr "" -#: src/data-list.c:1200 +#: src/data-list.c:1199 #, c-format msgid "" "Missing value(s) for all variables from %s onward. These will be filled " "with the system-missing value or blanks, as appropriate." msgstr "" -#: src/data-list.c:1278 +#: src/data-list.c:1277 msgid "Attempt to read past end of file." msgstr "" -#: src/data-list.c:1414 +#: src/data-list.c:1413 msgid "" "REPEATING DATA must use the same file as its corresponding DATA LIST or FILE " "TYPE." msgstr "" -#: src/data-list.c:1448 +#: src/data-list.c:1423 src/data-list.c:1458 src/data-list.c:1471 +#: src/data-list.c:1484 src/data-list.c:1517 +#, c-format +msgid "%s subcommand given multiple times." +msgstr "" + +#: src/data-list.c:1447 #, c-format msgid "STARTS beginning column (%d) exceeds STARTS ending column (%d)." msgstr "" -#: src/data-list.c:1504 +#: src/data-list.c:1503 #, c-format msgid "CONTINUED beginning column (%d) exceeds CONTINUED ending column (%d)." msgstr "" -#: src/data-list.c:1527 +#: src/data-list.c:1526 #, c-format msgid "ID beginning column (%ld) must be positive." msgstr "" -#: src/data-list.c:1542 +#: src/data-list.c:1541 #, c-format msgid "ID ending column (%ld) must be positive." msgstr "" -#: src/data-list.c:1548 +#: src/data-list.c:1547 #, c-format msgid "ID ending column (%ld) cannot be less than ID beginning column (%d)." msgstr "" -#: src/data-list.c:1588 +#: src/data-list.c:1587 msgid "Missing required specification STARTS." msgstr "" -#: src/data-list.c:1590 +#: src/data-list.c:1589 msgid "Missing required specification OCCURS." msgstr "" -#: src/data-list.c:1597 +#: src/data-list.c:1596 msgid "ID specified without CONTINUED." msgstr "" -#: src/data-list.c:1689 +#: src/data-list.c:1688 msgid "String variable not allowed here." msgstr "" -#: src/data-list.c:1699 +#: src/data-list.c:1698 #, c-format msgid "%s (%d) must be at least 1." msgstr "" -#: src/data-list.c:1705 +#: src/data-list.c:1704 #, c-format msgid "Variable or integer expected for %s." msgstr "" -#: src/data-list.c:1843 +#: src/data-list.c:1842 #, c-format msgid "Encountered mismatched record ID \"%s\" expecting \"%s\"." msgstr "" -#: src/data-list.c:1875 +#: src/data-list.c:1874 #, c-format msgid "" "Variable %s starting in column %d extends beyond physical record length of %" "d." msgstr "" -#: src/data-list.c:1943 +#: src/data-list.c:1942 #, c-format msgid "Invalid value %d for OCCURS." msgstr "" -#: src/data-list.c:1949 +#: src/data-list.c:1948 #, c-format msgid "Beginning column for STARTS (%d) must be at least 1." msgstr "" -#: src/data-list.c:1957 +#: src/data-list.c:1956 #, c-format msgid "Ending column for STARTS (%d) is less than beginning column (%d)." msgstr "" -#: src/data-list.c:1965 +#: src/data-list.c:1964 #, c-format msgid "Invalid value %d for LENGTH." msgstr "" -#: src/data-list.c:1972 +#: src/data-list.c:1971 #, c-format msgid "Beginning column for CONTINUED (%d) must be at least 1." msgstr "" -#: src/data-list.c:1980 +#: src/data-list.c:1979 #, c-format msgid "Ending column for CONTINUED (%d) is less than beginning column (%d)." msgstr "" -#: src/data-list.c:2012 +#: src/data-list.c:2011 #, c-format msgid "" "Number of repetitions specified on OCCURS (%d) exceed number of repetitions " "available in space on STARTS (%d), and CONTINUED not specified." msgstr "" -#: src/data-list.c:2030 +#: src/data-list.c:2029 #, c-format msgid "Unexpected end of file with %d repetitions remaining out of %d." msgstr "" @@ -1210,25 +1222,6 @@ msgstr "" msgid "installation error" msgstr "" -#: src/filename.c:221 -#, c-format -msgid "Searching for `%s'..." -msgstr "" - -#: src/filename.c:229 src/filename.c:261 -msgid "Search unsuccessful!" -msgstr "" - -#: src/filename.c:254 -#, c-format -msgid "Found `%s'." -msgstr "" - -#: src/filename.c:686 -#, c-format -msgid "Not opening pipe file `%s' because SAFER option set." -msgstr "" - #: src/file-type.c:129 msgid "MIXED, GROUPED, or NESTED expected." msgstr "" @@ -1367,64 +1360,83 @@ msgstr "" msgid "Unknown record type %g." msgstr "" -#: src/flip.c:81 +#: src/filename.c:221 +#, c-format +msgid "Searching for `%s'..." +msgstr "" + +#: src/filename.c:229 src/filename.c:261 +msgid "Search unsuccessful!" +msgstr "" + +#: src/filename.c:254 +#, c-format +msgid "Found `%s'." +msgstr "" + +#: src/filename.c:686 +#, c-format +msgid "Not opening pipe file `%s' because SAFER option set." +msgstr "" + +#: src/flip.c:82 msgid "" "FLIP ignores TEMPORARY. Temporary transformations will be made permanent." msgstr "" -#: src/flip.c:221 +#: src/flip.c:224 #, c-format msgid "Could not create acceptable variant for variable %s." msgstr "" -#: src/flip.c:237 +#: src/flip.c:240 msgid "Cannot create more than 99999 variable names." msgstr "" -#: src/flip.c:281 +#: src/flip.c:284 msgid "Could not create temporary file for FLIP." msgstr "" -#: src/flip.c:288 src/flip.c:356 +#: src/flip.c:291 src/flip.c:359 #, c-format msgid "Error writing FLIP file: %s." msgstr "" -#: src/flip.c:398 +#: src/flip.c:401 #, c-format msgid "Error rewinding FLIP file: %s." msgstr "" -#: src/flip.c:402 +#: src/flip.c:405 msgid "Error creating FLIP source file." msgstr "" -#: src/flip.c:411 +#: src/flip.c:414 #, c-format msgid "Error reading FLIP file: %s." msgstr "" -#: src/flip.c:432 +#: src/flip.c:435 #, c-format msgid "Error seeking FLIP source file: %s." msgstr "" -#: src/flip.c:437 +#: src/flip.c:440 #, c-format msgid "Error writing FLIP source file: %s." msgstr "" -#: src/flip.c:448 +#: src/flip.c:451 #, c-format msgid "Error rewind FLIP source file: %s." msgstr "" -#: src/flip.c:500 +#: src/flip.c:503 #, c-format msgid "Error reading FLIP temporary file: %s." msgstr "" -#: src/flip.c:503 +#: src/flip.c:506 msgid "Unexpected end of file reading FLIP temporary file." msgstr "" @@ -1829,27 +1841,27 @@ msgstr "" msgid "expecting filename" msgstr "" -#: src/inpt-pgm.c:82 +#: src/inpt-pgm.c:81 msgid "No matching INPUT PROGRAM command." msgstr "" -#: src/inpt-pgm.c:87 +#: src/inpt-pgm.c:86 msgid "" "No data-input or transformation commands specified between INPUT PROGRAM and " "END INPUT PROGRAM." msgstr "" -#: src/inpt-pgm.c:288 src/inpt-pgm.c:416 +#: src/inpt-pgm.c:284 src/inpt-pgm.c:412 msgid "" "This command may only be executed between INPUT PROGRAM and END INPUT " "PROGRAM." msgstr "" -#: src/inpt-pgm.c:338 +#: src/inpt-pgm.c:334 msgid "COLUMN subcommand multiply specified." msgstr "" -#: src/inpt-pgm.c:389 +#: src/inpt-pgm.c:385 msgid "" "REREAD: Column numbers must be positive finite numbers. Column set to 1." msgstr "" @@ -2117,69 +2129,69 @@ msgstr "" msgid "End of line expected %s while reading %s." msgstr "" -#: src/matrix-data.c:1106 +#: src/matrix-data.c:1105 #, c-format msgid "expecting value for %s %s" msgstr "" -#: src/matrix-data.c:1270 +#: src/matrix-data.c:1269 #, c-format msgid "Syntax error expecting SPLIT FILE value %s." msgstr "" -#: src/matrix-data.c:1279 +#: src/matrix-data.c:1278 #, c-format msgid "Expecting value %g for %s." msgstr "" -#: src/matrix-data.c:1320 src/matrix-data.c:1787 +#: src/matrix-data.c:1319 src/matrix-data.c:1786 #, c-format msgid "Syntax error expecting factor value %s." msgstr "" -#: src/matrix-data.c:1329 +#: src/matrix-data.c:1328 #, c-format msgid "Syntax error expecting value %g for %s %s." msgstr "" -#: src/matrix-data.c:1564 +#: src/matrix-data.c:1563 #, c-format msgid "Syntax error %s expecting SPLIT FILE value." msgstr "" -#: src/matrix-data.c:1694 +#: src/matrix-data.c:1693 #, c-format msgid "" "Expected %d lines of data for %s content; actually saw %d lines. No data " "will be output for this content." msgstr "" -#: src/matrix-data.c:1729 +#: src/matrix-data.c:1728 #, c-format msgid "Multiply specified ROWTYPE_ %s." msgstr "" -#: src/matrix-data.c:1734 +#: src/matrix-data.c:1733 #, c-format msgid "Syntax error %s expecting ROWTYPE_ string." msgstr "" -#: src/matrix-data.c:1754 +#: src/matrix-data.c:1753 #, c-format msgid "Syntax error %s." msgstr "" -#: src/matrix-data.c:1904 +#: src/matrix-data.c:1903 #, c-format msgid "Duplicate specification for %s." msgstr "" -#: src/matrix-data.c:1916 +#: src/matrix-data.c:1915 #, c-format msgid "Too many rows of matrix data for %s." msgstr "" -#: src/matrix-data.c:1964 +#: src/matrix-data.c:1963 #, c-format msgid "Syntax error expecting value for %s %s." msgstr "" @@ -3339,15 +3351,15 @@ msgstr "" msgid "%s: Writing system file: %s." msgstr "" -#: src/sort.c:197 +#: src/sort.c:203 msgid "`A' or `D' expected inside parentheses." msgstr "" -#: src/sort.c:202 +#: src/sort.c:208 msgid "`)' expected." msgstr "" -#: src/sort.c:552 src/sort.c:730 +#: src/sort.c:572 src/sort.c:750 #, c-format msgid "" "Out of memory. Could not allocate room for minimum of %d cases of %d bytes " @@ -3455,7 +3467,7 @@ msgstr "" msgid "Documents in the active file:" msgstr "" -#: src/sysfile-info.c:374 src/sysfile-info.c:532 src/vfm.c:875 +#: src/sysfile-info.c:374 src/sysfile-info.c:532 src/vfm.c:832 msgid "Label" msgstr "" @@ -3478,7 +3490,7 @@ msgstr "" msgid "Missing Values: " msgstr "" -#: src/sysfile-info.c:531 src/vfm.c:874 src/crosstabs.q:1099 +#: src/sysfile-info.c:531 src/vfm.c:831 src/crosstabs.q:1099 #: src/crosstabs.q:1126 src/crosstabs.q:1146 src/crosstabs.q:1168 #: src/examine.q:1129 src/frequencies.q:1138 src/frequencies.q:1259 msgid "Value" diff --git a/src/ChangeLog b/src/ChangeLog index c559d6ad..727e6b09 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,53 @@ +Sun Mar 13 22:52:05 2005 Ben Pfaff + + * file-handle.q: (struct file_handle) `open_mode' should not be + const. + +Sun Mar 13 22:40:54 2005 Ben Pfaff + + First phase of making SORT CASES stable (PR 12035). + + * sort.c: (struct indexed_case) New structure. + (do_internal_sort) Rewrite to make internal sorting stable. + (compare_case_dblptrs) Removed. + (compare_indexed_cases) New function. + +Sun Mar 13 22:38:40 2005 Ben Pfaff + + Clean-ups. + + * casefile.c: (casereader_read_xfer_assert) New function. + + * dictionary.c: (dict_compact_case) New function. + + * flip.c: (struct flip_pgm) New member idx_to_fv. + (cmd_flip) Initialize idx_to_fv member. + (destroy_flip_pgm) Free idx_to_fv member. + (flip_sink_write) Use struct flip_pgm member instead of case_sink + member. + (flip_sink_write) Ditto. + + * vfm.c: (write_case) Use dict_compact_case() instead of + compact_case(). + (compact_case) Removed. + (storage_source_create) Removed `dict' parameter. All references + updated. + + * vfm.h: (struct case_source) Removed `value_cnt' member. All + references removed. + (struct case_sink) Removed `dict', `idx_to_fv' members. All + references removed. + +Sun Mar 13 22:35:55 2005 Ben Pfaff + + More AGGREGATE fixes. + + * aggregate.c: (accumulate_aggregate_info) Implement NMISS and + NUMISS for strings. Fix FOUT, POUT, FGT, FLT, FIN, FOUT for + strings. + (initialize_aggregate_info) Fix initialization for MIN, MAX for + strings. + Sat Mar 12 23:26:21 2005 Ben Pfaff Start work on testing and debugging AGGREGATE. diff --git a/src/aggregate.c b/src/aggregate.c index 9d925707..f56a2160 100644 --- a/src/aggregate.c +++ b/src/aggregate.c @@ -817,9 +817,11 @@ accumulate_aggregate_info (struct agr_proc *agr, switch (iter->function) { case NMISS: + case NMISS | FSTRING: iter->dbl[0] += weight; break; case NUMISS: + case NUMISS | FSTRING: iter->int1++; break; } @@ -904,7 +906,7 @@ accumulate_aggregate_info (struct agr_proc *agr, case FOUT | FSTRING: case POUT | FSTRING: if (memcmp (iter->arg[0].c, v->s, iter->src->width) > 0 - && memcmp (iter->arg[1].c, v->s, iter->src->width) < 0) + || memcmp (iter->arg[1].c, v->s, iter->src->width) < 0) iter->dbl[0] += weight; iter->dbl[1] += weight; break; @@ -1033,16 +1035,14 @@ dump_aggregate_info (struct agr_proc *agr, struct ccase *output) else memset (v->s, ' ', i->dest->width); break; - case FGT | FSTRING: - case FLT | FSTRING: - case FIN | FSTRING: - case FOUT | FSTRING: - v->f = i->int2 ? (double) i->int1 / (double) i->int2 : SYSMIS; - break; case FGT: + case FGT | FSTRING: case FLT: + case FLT | FSTRING: case FIN: + case FIN | FSTRING: case FOUT: + case FOUT | FSTRING: v->f = i->dbl[1] ? i->dbl[0] / i->dbl[1] : SYSMIS; break; case PGT: @@ -1104,18 +1104,18 @@ initialize_aggregate_info (struct agr_proc *agr) for (iter = agr->agr_vars; iter; iter = iter->next) { iter->missing = 0; + iter->dbl[0] = iter->dbl[1] = iter->dbl[2] = 0.0; + iter->int1 = iter->int2 = 0; switch (iter->function) { case MIN: iter->dbl[0] = DBL_MAX; - iter->int1 = 0; break; case MIN | FSTRING: memset (iter->string, 255, iter->src->width); break; case MAX: iter->dbl[0] = -DBL_MAX; - iter->int1 = 0; break; case MAX | FSTRING: memset (iter->string, 0, iter->src->width); @@ -1126,10 +1126,8 @@ initialize_aggregate_info (struct agr_proc *agr) else moments1_clear (iter->moments); break; - default: - iter->dbl[0] = iter->dbl[1] = iter->dbl[2] = 0.0; - iter->int1 = iter->int2 = 0; - break; + default: + break; } } } diff --git a/src/casefile.c b/src/casefile.c index 97929c57..689e2b13 100644 --- a/src/casefile.c +++ b/src/casefile.c @@ -535,7 +535,8 @@ casereader_get_casefile (const struct casereader *reader) } /* Reads a copy of the next case from READER into C. - Caller is responsible for destroying C. */ + Caller is responsible for destroying C. + Returns true if successful, false at end of file. */ int casereader_read (struct casereader *reader, struct ccase *c) { @@ -572,7 +573,8 @@ casereader_read (struct casereader *reader, struct ccase *c) } /* Reads the next case from READER into C and transfers ownership - to the caller. Caller is responsible for destroying C. */ + to the caller. Caller is responsible for destroying C. + Returns true if successful, false at end of file. */ int casereader_read_xfer (struct casereader *reader, struct ccase *c) { @@ -594,6 +596,16 @@ casereader_read_xfer (struct casereader *reader, struct ccase *c) } } +/* Reads the next case from READER into C and transfers ownership + to the caller. Caller is responsible for destroying C. + Assert-fails at end of file. */ +void +casereader_read_xfer_assert (struct casereader *reader, struct ccase *c) +{ + bool success = casereader_read_xfer (reader, c); + assert (success); +} + /* Destroys READER. */ void casereader_destroy (struct casereader *reader) diff --git a/src/casefile.h b/src/casefile.h index a074cb36..b368c31c 100644 --- a/src/casefile.h +++ b/src/casefile.h @@ -21,6 +21,7 @@ #define HEADER_CASEFILE #include +#include "bool.h" struct ccase; struct casefile; @@ -46,6 +47,7 @@ struct casereader *casefile_get_destructive_reader (struct casefile *); const struct casefile *casereader_get_casefile (const struct casereader *); int casereader_read (struct casereader *, struct ccase *); int casereader_read_xfer (struct casereader *, struct ccase *); +void casereader_read_xfer_assert (struct casereader *, struct ccase *); void casereader_destroy (struct casereader *); unsigned long casereader_cnum(const struct casereader *); diff --git a/src/data-list.c b/src/data-list.c index 9fc3f9de..4d7a315d 100644 --- a/src/data-list.c +++ b/src/data-list.c @@ -278,8 +278,7 @@ cmd_data_list (void) add_transformation (&new_pgm->h); } else - vfm_source = create_case_source (&data_list_source_class, - default_dict, dls); + vfm_source = create_case_source (&data_list_source_class, dls); return CMD_SUCCESS; diff --git a/src/dictionary.c b/src/dictionary.c index 3e864d3e..177987b5 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -701,6 +701,30 @@ dict_compact_values (struct dictionary *d) } } +/* Copies values from SRC, which represents a case arranged + according to dictionary D, to DST, which represents a case + arranged according to the dictionary that will be produced by + dict_compact_values(D). */ +void +dict_compact_case (const struct dictionary *d, + struct ccase *dst, const struct ccase *src) +{ + size_t i; + size_t value_idx; + + value_idx = 0; + for (i = 0; i < d->var_cnt; i++) + { + struct variable *v = d->var[i]; + + if (dict_class_from_id (v->name) != DC_SCRATCH) + { + case_copy (dst, value_idx, src, v->fv, v->nv); + value_idx += v->nv; + } + } +} + /* Returns the number of values that would be used by a case if dict_compact_values() were called. */ size_t diff --git a/src/dictionary.h b/src/dictionary.h index abe1bb7f..f375ecc6 100644 --- a/src/dictionary.h +++ b/src/dictionary.h @@ -74,6 +74,8 @@ int dict_get_next_value_idx (const struct dictionary *); size_t dict_get_case_size (const struct dictionary *); void dict_compact_values (struct dictionary *); +void dict_compact_case (const struct dictionary *, + struct ccase *, const struct ccase *); size_t dict_get_compacted_value_cnt (const struct dictionary *); int *dict_get_compacted_idx_to_fv (const struct dictionary *); diff --git a/src/file-handle.q b/src/file-handle.q index 99e5d0d7..5c480079 100644 --- a/src/file-handle.q +++ b/src/file-handle.q @@ -48,7 +48,7 @@ struct file_handle int open_cnt; /* 0=not open, otherwise # of openers. */ const char *type; /* If open, type of file. */ - const char open_mode[3]; /* "[rw][se]". */ + char open_mode[3]; /* "[rw][se]". */ void *aux; /* Aux data pointer for owner if any. */ }; diff --git a/src/file-type.c b/src/file-type.c index cf0a3725..a4940c23 100644 --- a/src/file-type.c +++ b/src/file-type.c @@ -280,7 +280,7 @@ cmd_file_type (void) create_col_var (&fty->record); if (fty->case_sbc.name[0]) create_col_var (&fty->case_sbc); - vfm_source = create_case_source (&file_type_source_class, default_dict, fty); + vfm_source = create_case_source (&file_type_source_class, fty); return CMD_SUCCESS; diff --git a/src/flip.c b/src/flip.c index 7113c8e8..f14338da 100644 --- a/src/flip.c +++ b/src/flip.c @@ -50,6 +50,7 @@ struct varname struct flip_pgm { struct variable **var; /* Variables to transpose. */ + int *idx_to_fv; /* var[]->index to compacted sink case fv. */ int var_cnt; /* Number of elements in `var'. */ int case_cnt; /* Pre-flip case count. */ size_t case_size; /* Post-flip bytes per case. */ @@ -85,6 +86,7 @@ cmd_flip (void) flip = xmalloc (sizeof *flip); flip->var = NULL; + flip->idx_to_fv = dict_get_compacted_idx_to_fv (default_dict); flip->var_cnt = 0; flip->case_cnt = 0; flip->new_names = NULL; @@ -163,6 +165,7 @@ destroy_flip_pgm (struct flip_pgm *flip) struct varname *iter, *next; free (flip->var); + free (flip->idx_to_fv); for (iter = flip->new_names_head; iter != NULL; iter = next) { next = iter->next; @@ -308,7 +311,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) v->next = NULL; if (flip->new_names->type == NUMERIC) { - double f = case_num (c, sink->idx_to_fv[flip->new_names->index]); + double f = case_num (c, flip->idx_to_fv[flip->new_names->index]); if (f == SYSMIS) strcpy (v->name, "VSYSMIS"); @@ -327,7 +330,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) else { int width = min (flip->new_names->width, 8); - memcpy (v->name, case_str (c, sink->idx_to_fv[flip->new_names->index]), + memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]), width); v->name[width] = 0; } @@ -345,7 +348,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) double out; if (flip->var[i]->type == NUMERIC) - out = case_num (c, sink->idx_to_fv[flip->var[i]->index]); + out = case_num (c, flip->idx_to_fv[flip->var[i]->index]); else out = SYSMIS; info->output_buf[i].f = out; @@ -474,7 +477,7 @@ static const struct case_sink_class flip_sink_class = static struct case_source * flip_source_create (struct flip_pgm *pgm) { - return create_case_source (&flip_source_class, default_dict, pgm); + return create_case_source (&flip_source_class, pgm); } /* Reads the FLIP stream. Copies each case into C and calls diff --git a/src/get.c b/src/get.c index 7fcb1f25..057b5072 100644 --- a/src/get.c +++ b/src/get.c @@ -106,7 +106,7 @@ cmd_get (void) dict_destroy (default_dict); default_dict = dict; - vfm_source = create_case_source (&get_source_class, default_dict, pgm); + vfm_source = create_case_source (&get_source_class, pgm); return CMD_SUCCESS; @@ -1495,7 +1495,7 @@ cmd_import (void) dict_destroy (default_dict); default_dict = dict; - vfm_source = create_case_source (&import_source_class, default_dict, pgm); + vfm_source = create_case_source (&import_source_class, pgm); return CMD_SUCCESS; diff --git a/src/inpt-pgm.c b/src/inpt-pgm.c index 004fe2c4..4bef8caa 100644 --- a/src/inpt-pgm.c +++ b/src/inpt-pgm.c @@ -65,8 +65,7 @@ cmd_input_program (void) /* FIXME: we shouldn't do this here, but I'm afraid that other code will check the class of vfm_source. */ - vfm_source = create_case_source (&input_program_source_class, - default_dict, NULL); + vfm_source = create_case_source (&input_program_source_class, NULL); return lex_end_of_command (); } @@ -116,9 +115,6 @@ cmd_end_input_program (void) /* Put inp into vfm_source for later use. */ vfm_source->aux = inp; - /* FIXME: we should use create_case_source() here. */ - vfm_source->value_cnt = dict_get_next_value_idx (default_dict); - return lex_end_of_command (); } diff --git a/src/matrix-data.c b/src/matrix-data.c index e7747a89..29e92376 100644 --- a/src/matrix-data.c +++ b/src/matrix-data.c @@ -963,8 +963,7 @@ read_matrices_without_rowtype (struct matrix_data_pgm *mx) nr.split_values = xmalloc (sizeof *nr.split_values * dict_get_split_cnt (default_dict)); - vfm_source = create_case_source (&matrix_data_without_rowtype_source_class, - default_dict, &nr); + vfm_source = create_case_source (&matrix_data_without_rowtype_source_class, &nr); procedure (NULL, NULL); @@ -1495,7 +1494,7 @@ read_matrices_with_rowtype (struct matrix_data_pgm *mx) mx->cells = 0; vfm_source = create_case_source (&matrix_data_with_rowtype_source_class, - default_dict, &wr); + &wr); procedure (NULL, NULL); free (wr.split_values); diff --git a/src/sort.c b/src/sort.c index 6e518bef..c2f48d0b 100644 --- a/src/sort.c +++ b/src/sort.c @@ -75,7 +75,6 @@ struct sort_criteria size_t crit_cnt; }; -static int compare_case_dblptrs (const void *, const void *, void *); static int compare_record (const struct ccase *, const struct ccase *, const struct sort_criteria *); static struct casefile *do_internal_sort (struct casereader *, @@ -134,7 +133,7 @@ sort_active_file_in_place (const struct sort_criteria *criteria) if (dst == NULL) return 0; - vfm_source = storage_source_create (dst, default_dict); + vfm_source = storage_source_create (dst); return 1; } @@ -262,6 +261,15 @@ sort_execute (struct casereader *reader, const struct sort_criteria *criteria) return output; } +/* A case and its index. */ +struct indexed_case + { + struct ccase c; /* Case. */ + unsigned long idx; /* Index to allow for stable sorting. */ + }; + +static int compare_indexed_cases (const void *, const void *, void *); + /* If the data is in memory, do an internal sort and return a new casefile for the data. */ static struct casefile * @@ -270,7 +278,6 @@ do_internal_sort (struct casereader *reader, { const struct casefile *src; struct casefile *dst; - struct ccase *cases, **case_ptrs; unsigned long case_cnt; src = casereader_get_casefile (reader); @@ -278,47 +285,52 @@ do_internal_sort (struct casereader *reader, return NULL; case_cnt = casefile_get_case_cnt (src); - cases = malloc (sizeof *cases * case_cnt); - case_ptrs = malloc (sizeof *case_ptrs * case_cnt); - if ((cases != NULL && case_ptrs != NULL) || case_cnt == 0) + dst = casefile_create (casefile_get_value_cnt (src)); + if (case_cnt != 0) { - unsigned long case_idx; + struct indexed_case *cases = malloc (sizeof *cases * case_cnt); + if (cases != NULL) + { + unsigned long i; + + for (i = 0; i < case_cnt; i++) + { + casereader_read_xfer_assert (reader, &cases[i].c); + cases[i].idx = i; + } + + sort (cases, case_cnt, sizeof *cases, compare_indexed_cases, + (void *) criteria); - for (case_idx = 0; case_idx < case_cnt; case_idx++) + for (i = 0; i < case_cnt; i++) + casefile_append_xfer (dst, &cases[i].c); + + free (cases); + } + else { - int success = casereader_read_xfer (reader, &cases[case_idx]); - assert (success); - case_ptrs[case_idx] = &cases[case_idx]; + /* Failure. */ + casefile_destroy (dst); + dst = NULL; } - - sort (case_ptrs, case_cnt, sizeof *case_ptrs, compare_case_dblptrs, - (void *) criteria); - - dst = casefile_create (casefile_get_value_cnt (src)); - for (case_idx = 0; case_idx < case_cnt; case_idx++) - casefile_append_xfer (dst, case_ptrs[case_idx]); } - else - dst = NULL; - - free (case_ptrs); - free (cases); return dst; } /* Compares the variables specified by CRITERIA between the cases - at A and B, and returns a strcmp()-type result. */ + at A and B, with a "last resort" comparison for stability, and + returns a strcmp()-type result. */ static int -compare_case_dblptrs (const void *a_, const void *b_, void *criteria_) +compare_indexed_cases (const void *a_, const void *b_, void *criteria_) { struct sort_criteria *criteria = criteria_; - struct ccase *const *pa = a_; - struct ccase *const *pb = b_; - struct ccase *a = *pa; - struct ccase *b = *pb; - - return compare_record (a, b, criteria); + const struct indexed_case *a = a_; + const struct indexed_case *b = b_; + int result = compare_record (&a->c, &b->c, criteria); + if (result == 0) + result = a->idx < b->idx ? -1 : a->idx > b->idx; + return result; } /* External sort. */ diff --git a/src/vfm.c b/src/vfm.c index 8e939277..344f94b9 100644 --- a/src/vfm.c +++ b/src/vfm.c @@ -95,7 +95,6 @@ static int execute_transformations (struct ccase *c, int case_num); static int filter_case (const struct ccase *c, int case_num); static void lag_case (const struct ccase *c); -static void compact_case (struct ccase *dest, const struct ccase *src); static void clear_case (struct ccase *c); static void close_active_file (void); @@ -260,7 +259,7 @@ write_case (struct write_case_data *wc_data) { if (compaction_necessary) { - compact_case (&wc_data->sink_case, &wc_data->trns_case); + dict_compact_case (temp_dict, &wc_data->sink_case, &wc_data->trns_case); vfm_sink->class->write (vfm_sink, &wc_data->sink_case); } else @@ -357,43 +356,6 @@ lag_case (const struct ccase *c) lag_head = 0; } -/* Copies case SRC to case DEST, compacting it in the process. */ -static void -compact_case (struct ccase *dest, const struct ccase *src) -{ - int i; - int nval = 0; - size_t var_cnt; - - assert (compaction_necessary); - - /* Copy all the variables except scratch variables from SRC to - DEST. */ - /* FIXME: this should be temp_dict not default_dict I guess. */ - var_cnt = dict_get_var_cnt (default_dict); - for (i = 0; i < var_cnt; i++) - { - struct variable *v = dict_get_var (default_dict, i); - - if (dict_class_from_id (v->name) == DC_SCRATCH) - continue; - - if (v->type == NUMERIC) - { - case_data_rw (dest, nval)->f = case_num (src, v->fv); - nval++; - } - else - { - int w = DIV_RND_UP (v->width, sizeof (union value)); - - memcpy (case_data_rw (dest, nval), case_str (src, v->fv), - w * sizeof (union value)); - nval += w; - } - } -} - /* Clears the variables in C that need to be cleared between processing cases. */ static void @@ -518,7 +480,7 @@ static struct case_source * storage_sink_make_source (struct case_sink *sink) { struct case_source *source - = create_case_source (&storage_source_class, sink->dict, sink->aux); + = create_case_source (&storage_source_class, sink->aux); sink->aux = NULL; return source; } @@ -594,14 +556,14 @@ storage_source_get_casefile (struct case_source *source) } struct case_source * -storage_source_create (struct casefile *cf, const struct dictionary *dict) +storage_source_create (struct casefile *cf) { struct storage_stream_info *info; info = xmalloc (sizeof *info); info->casefile = cf; - return create_case_source (&storage_source_class, dict, info); + return create_case_source (&storage_source_class, info); } /* Null sink. Used by a few procedures that keep track of output @@ -670,12 +632,10 @@ cancel_transformations (void) and based on dictionary DICT. */ struct case_source * create_case_source (const struct case_source_class *class, - const struct dictionary *dict, void *aux) { struct case_source *source = xmalloc (sizeof *source); source->class = class; - source->value_cnt = dict_get_next_value_idx (dict); source->aux = aux; return source; } @@ -709,8 +669,8 @@ case_source_is_class (const struct case_source *source, return source != NULL && source->class == class; } -/* Creates a case sink with class CLASS and auxiliary data - AUX. */ +/* Creates a case sink to accept cases from the given DICT with + class CLASS and auxiliary data AUX. */ struct case_sink * create_case_sink (const struct case_sink_class *class, const struct dictionary *dict, @@ -718,8 +678,6 @@ create_case_sink (const struct case_sink_class *class, { struct case_sink *sink = xmalloc (sizeof *sink); sink->class = class; - sink->dict = dict; - sink->idx_to_fv = dict_get_compacted_idx_to_fv (dict); sink->value_cnt = dict_get_compacted_value_cnt (dict); sink->aux = aux; return sink; @@ -733,7 +691,6 @@ free_case_sink (struct case_sink *sink) { if (sink->class->destroy != NULL) sink->class->destroy (sink); - free (sink->idx_to_fv); free (sink); } } diff --git a/src/vfm.h b/src/vfm.h index 9b577ed8..d1ef8830 100644 --- a/src/vfm.h +++ b/src/vfm.h @@ -36,7 +36,6 @@ extern struct case_source *vfm_source; struct case_source { const struct case_source_class *class; /* Class. */ - size_t value_cnt; /* Number of `union value's in case. */ void *aux; /* Auxiliary data. */ }; @@ -69,7 +68,6 @@ extern const struct case_source_class sort_source_class; struct dictionary; struct case_source *create_case_source (const struct case_source_class *, - const struct dictionary *, void *); void free_case_source (struct case_source *); @@ -78,8 +76,7 @@ int case_source_is_class (const struct case_source *, const struct case_source_class *); struct casefile *storage_source_get_casefile (struct case_source *); -struct case_source *storage_source_create (struct casefile *, - const struct dictionary *); +struct case_source *storage_source_create (struct casefile *); /* The replacement active file, to which cases are written. */ extern struct case_sink *vfm_sink; @@ -89,11 +86,6 @@ struct case_sink { const struct case_sink_class *class; /* Class. */ void *aux; /* Auxiliary data. */ - - /* Cases written to a case sink belong to a dictionary, but - their data is compacted to drop scratch variables. */ - const struct dictionary *dict; /* Dictionary for cases. */ - int *idx_to_fv; /* `dict' index -> case `data' index. */ size_t value_cnt; /* Number of `union value's in case. */ }; -- 2.30.2