From 8c11929786758c4e64fc7825f54fef4b7a39f4e2 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 22 Dec 2013 11:10:49 -0800 Subject: [PATCH] DISPLAY DICTIONARY: Add "Label: " prefix for variable labels in output. Bug #40864. --- perl-module/t/Pspp.t | 6 ++--- src/language/dictionary/sys-file-info.c | 6 ++++- tests/data/sys-file-reader.at | 14 ++++++------ tests/data/sys-file.at | 2 +- tests/language/stats/rank.at | 14 ++++++------ tests/perl-module.at | 30 ++++++++++++------------- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/perl-module/t/Pspp.t b/perl-module/t/Pspp.t index a2d4288989..e3ee08def8 100644 --- a/perl-module/t/Pspp.t +++ b/perl-module/t/Pspp.t @@ -250,7 +250,7 @@ GET FILE='$tempfile'. DISPLAY DICTIONARY. SYNTAX Variable,Description,,Position -integer,My Integer,,1 +integer,Label: My Integer,,1 ,Format: F8.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -259,7 +259,7 @@ integer,My Integer,,1 ,0,Zero, ,1,Unity, ,2,Duality, -string,My String,,2 +string,Label: My String,,2 ,Format: A8,, ,Measure: Nominal,, ,Display Alignment: Left,, @@ -267,7 +267,7 @@ string,My String,,2 ,"Missing Values: ""this ""; ""that """,, ,xx ,foo, ,yy ,bar, -longstring,My Long String,,3 +longstring,Label: My Long String,,3 ,Format: A9,, ,Measure: Nominal,, ,Display Alignment: Left,, diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index c7f326f3be..d26c236e8f 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -481,7 +481,11 @@ describe_variable (const struct variable *v, struct tab_table *t, int r, if (flags & DF_VARIABLE_LABELS && var_has_label (v)) { - tab_joint_text (t, 1, r, 2, r, TAB_LEFT, var_get_label (v)); + if (flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS)) + tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT, + _("Label: %s"), var_get_label (v)); + else + tab_joint_text (t, 1, r, 2, r, TAB_LEFT, var_get_label (v)); r++; } diff --git a/tests/data/sys-file-reader.at b/tests/data/sys-file-reader.at index 8a700ad92b..60d5ff7054 100644 --- a/tests/data/sys-file-reader.at +++ b/tests/data/sys-file-reader.at @@ -140,11 +140,11 @@ File label: PSPP synthetic test file: ôõöø Variable,Description,,Position num1,Format: F8.0,,1 -num2,Numeric variable 2's label (ùúû),,2 +num2,Label: Numeric variable 2's label (ùúû),,2 ,Format: F8.0,, num3,Format: F8.0,,3 ,Missing Values: 1,, -num4,Another numeric variable label,,4 +num4,Label: Another numeric variable label,,4 ,Format: F8.0,, ,Missing Values: 1,, num5,Format: F8.0,,5 @@ -160,11 +160,11 @@ num9,Format: F8.0,,9 numàèìñò,Format: F8.0,,10 ,Missing Values: LOWEST THRU 1; 5,, str1,Format: A4,,11 -str2,String variable 2's label,,12 +str2,Label: String variable 2's label,,12 ,Format: A4,, str3,Format: A4,,13 ,"Missing Values: ""MISS""",, -str4,Another string variable label,,14 +str4,Label: Another string variable label,,14 ,Format: A4,, ,"Missing Values: ""OTHR""",, str5,Format: A4,,15 @@ -179,7 +179,7 @@ str9,Format: A10,,19 ,"Missing Values: ""abcdefgh""; ""01234567""",, str10,Format: A11,,20 ,"Missing Values: ""abcdefgh""; ""01234567""; ""0 """,, -str11,25-byte string,,21 +str11,Label: 25-byte string,,21 ,Format: A25,, Table: Data List @@ -232,7 +232,7 @@ LIST. AT_CHECK([grep -v Measure pspp.csv | grep -v Display], [0], [dnl Variable,Description,,Position num1,Format: F8.0,,1 -num2,Numeric variable 2's label,,2 +num2,Label: Numeric variable 2's label,,2 ,Format: F8.0,, Table: Data List @@ -288,7 +288,7 @@ LIST. AT_CHECK([grep -v Measure pspp.csv | grep -v Display], [0], [dnl Variable,Description,,Position num1,Format: F8.0,,1 -num2,Numeric variable 2's label,,2 +num2,Label: Numeric variable 2's label,,2 ,Format: F8.0,, Table: Data List diff --git a/tests/data/sys-file.at b/tests/data/sys-file.at index 9b8986d589..033a7da9af 100644 --- a/tests/data/sys-file.at +++ b/tests/data/sys-file.at @@ -502,7 +502,7 @@ Variable,Description,,Position ,1.00,éclair élan, ,Custom attributes:,, ,Atatürk,Düsseldorf Gewürztraminer, -roué,Provençal soupçon,,2 +roué,Label: Provençal soupçon,,2 ,Format: A9,, ,Measure: Nominal,, ,Display Alignment: Left,, diff --git a/tests/language/stats/rank.at b/tests/language/stats/rank.at index f47d23e861..d29e2e8df6 100644 --- a/tests/language/stats/rank.at +++ b/tests/language/stats/rank.at @@ -126,32 +126,32 @@ b,Format: F8.2,,2 ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -Ra,RANK of a,,3 +Ra,Label: RANK of a,,3 ,Format: F9.3,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -RFR001,RFRACTION of a,,4 +RFR001,Label: RFRACTION of a,,4 ,Format: F6.4,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -count,N of a,,5 +count,Label: N of a,,5 ,Format: F6.0,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -Rb,RANK of b,,6 +Rb,Label: RANK of b,,6 ,Format: F9.3,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -RFR002,RFRACTION of b,,7 +RFR002,Label: RFRACTION of b,,7 ,Format: F6.4,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -Nb,N of b,,8 +Nb,Label: N of b,,8 ,Format: F6.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -543,7 +543,7 @@ ran003,Format: F8.2,,3 ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -RAN001,RANK of foo,,4 +RAN001,Label: RANK of foo,,4 ,Format: F9.3,, ,Measure: Scale,, ,Display Alignment: Right,, diff --git a/tests/perl-module.at b/tests/perl-module.at index eee9ac9947..0ddd8fd5ff 100644 --- a/tests/perl-module.at +++ b/tests/perl-module.at @@ -237,7 +237,7 @@ DISPLAY DICTIONARY. ]) AT_CHECK([pspp -O format=csv dump-dict.sps], [0], [Variable,Description,,Position -integer,My Integer,,1 +integer,Label: My Integer,,1 ,Format: F8.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -246,7 +246,7 @@ integer,My Integer,,1 ,0,Zero, ,1,Unity, ,2,Duality, -string,My String,,2 +string,Label: My String,,2 ,Format: A8,, ,Measure: Nominal,, ,Display Alignment: Left,, @@ -254,7 +254,7 @@ string,My String,,2 ,"Missing Values: ""this ""; ""that """,, ,xx ,foo, ,yy ,bar, -longstring,My Long String,,3 +longstring,Label: My Long String,,3 ,Format: A9,, ,Measure: Nominal,, ,Display Alignment: Left,, @@ -457,7 +457,7 @@ LIST. ]) AT_CHECK([pspp -O format=csv dump-dicts.sps], [0], [[Variable,Description,,Position -string,A Short String Variable,,1 +string,Label: A Short String Variable,,1 ,Format: A8,, ,Measure: Nominal,, ,Display Alignment: Left,, @@ -466,12 +466,12 @@ string,A Short String Variable,,1 ,1111 ,ones, ,2222 ,twos, ,3333 ,threes, -longstring,A Long String Variable,,2 +longstring,Label: A Long String Variable,,2 ,Format: A12,, ,Measure: Nominal,, ,Display Alignment: Left,, ,Display Width: 12,, -numeric,A Numeric Variable,,3 +numeric,Label: A Numeric Variable,,3 ,Format: F10.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -486,17 +486,17 @@ numeric,A Numeric Variable,,3 ,colour[3],violet, ,nationality,foreign, ,size,large, -date,A Date Variable,,4 +date,Label: A Date Variable,,4 ,Format: DATE11,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -dollar,A Dollar Variable,,5 +dollar,Label: A Dollar Variable,,5 ,Format: DOLLAR11.2,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -datetime,A Datetime Variable,,6 +datetime,Label: A Datetime Variable,,6 ,Format: DATETIME17.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -511,7 +511,7 @@ string,longstring,numeric,date,dollar,datetime 5555 ,Five ,5,05-MAY-2005,$5.00,05-MAY-2005 05:05 Variable,Description,,Position -string,A Short String Variable,,1 +string,Label: A Short String Variable,,1 ,Format: A8,, ,Measure: Nominal,, ,Display Alignment: Left,, @@ -520,12 +520,12 @@ string,A Short String Variable,,1 ,1111 ,ones, ,2222 ,twos, ,3333 ,threes, -longstring,A Long String Variable,,2 +longstring,Label: A Long String Variable,,2 ,Format: A12,, ,Measure: Nominal,, ,Display Alignment: Left,, ,Display Width: 12,, -numeric,A Numeric Variable,,3 +numeric,Label: A Numeric Variable,,3 ,Format: F10.0,, ,Measure: Scale,, ,Display Alignment: Right,, @@ -540,17 +540,17 @@ numeric,A Numeric Variable,,3 ,colour[3],violet, ,nationality,foreign, ,size,large, -date,A Date Variable,,4 +date,Label: A Date Variable,,4 ,Format: DATE11,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -dollar,A Dollar Variable,,5 +dollar,Label: A Dollar Variable,,5 ,Format: DOLLAR11.2,, ,Measure: Scale,, ,Display Alignment: Right,, ,Display Width: 8,, -datetime,A Datetime Variable,,6 +datetime,Label: A Datetime Variable,,6 ,Format: DATETIME17.0,, ,Measure: Scale,, ,Display Alignment: Right,, -- 2.30.2