From a41f6868a27b0582f1d4c1d67071952106cd95f0 Mon Sep 17 00:00:00 2001 From: Zeping Lee Date: Sat, 8 May 2021 15:02:38 +0800 Subject: [PATCH] Fix missing year when only date is presented in article (#299) --- CHANGELOG.md | 1 + ustcthesis-authoryear.bst | 98 ++++++++++++++++++--------------------- ustcthesis-bachelor.bst | 98 ++++++++++++++++++--------------------- ustcthesis-numerical.bst | 98 ++++++++++++++++++--------------------- 4 files changed, 136 insertions(+), 159 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc4b68..c8b6b95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 修正了与 `chapterbib` 宏包的兼容性。 - 去掉 `notoccite` 宏包,防止造成 PDF 书签中页码的错误(#293)。 - 修正了表题的字体(#295)。 +- 修正了 `article` 只有 `date` 时年份缺失的问题(#299)。 ## [v3.3.0] - 2021-03-18 diff --git a/ustcthesis-authoryear.bst b/ustcthesis-authoryear.bst index 6b76c2d..6f8d681 100644 --- a/ustcthesis-authoryear.bst +++ b/ustcthesis-authoryear.bst @@ -4,13 +4,13 @@ %% %% The original source files were: %% -%% gbt7714.dtx (with options: `ustc,2015,authoryear') +%% gbt7714.dtx (with options: `2015,ustc,authoryear') %% ------------------------------------------------------------------- %% GB/T 7714—2015 BibTeX Style %% https://github.com/CTeX-org/gbt7714-bibtex-style -%% Version: 2020/12/17 v2.1 +%% Version: 2021/04/03 v2.1.1 %% ------------------------------------------------------------------- -%% Copyright (C) 2016-2021 by Zeping Lee +%% Copyright (C) 2016—2021 by Zeping Lee %% ------------------------------------------------------------------- %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3c @@ -18,7 +18,7 @@ %% The latest version of this license is in %% https://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. +%% version 2008 or later. %% ------------------------------------------------------------------- INTEGERS { citation.et.al.min @@ -250,6 +250,22 @@ FUNCTION {or} if$ } +STRINGS { x y } + +FUNCTION {contains} +{ 'y := + 'x := + y text.length$ 'len := + x text.length$ len - #1 + 'charptr := + { charptr #0 > + x charptr len substring$ y = not + and + } + { charptr #1 - 'charptr := } + while$ + charptr #0 > +} + STRINGS { s t } FUNCTION {output.nonnull} @@ -713,17 +729,13 @@ FUNCTION {output.bibitem} "\bibitem[" write$ label ")" * make.full.names duplicate$ short.list = - { pop$ } - { * } - if$ - 's := - s text.length$ 'charptr := - { charptr #0 > s charptr #1 substring$ "[" = not and } - { charptr #1 - 'charptr := } - while$ - charptr #0 > - { "{" s * "}" * } - { s } + { pop$ } + { duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ + * + } if$ "]{" * write$ cite$ write$ @@ -1186,21 +1198,6 @@ FUNCTION {extract.after.dash} if$ } -FUNCTION {contains.dash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {extract.before.slash} { duplicate$ empty$ { pop$ "" } @@ -1245,23 +1242,6 @@ FUNCTION {extract.after.slash} if$ } -FUNCTION {contains.slash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - s #1 #1 substring$ "/" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {format.year} { year empty$ not { year extract.before.slash extra.label * } @@ -1302,11 +1282,16 @@ FUNCTION {format.periodical.year} } FUNCTION {format.date} -{ type$ "patent" = type$ "newspaper" = or - date empty$ not and - { date } - { year field.or.null - extra.label * +{ date empty$ not + { type$ "patent" = type$ "newspaper" = or + { date } + { format.year } + if$ + } + { year empty$ not + { format.year } + { "" } + if$ } if$ } @@ -2222,7 +2207,10 @@ FUNCTION {calc.short.authors} FUNCTION {calc.label} { calc.short.authors - short.list + short.list "]" contains + { "{" short.list * "}" * } + { short.list } + if$ "(" * format.year duplicate$ empty$ @@ -2230,6 +2218,10 @@ FUNCTION {calc.label} { pop$ "" } 'skip$ if$ + duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ * 'label := short.label diff --git a/ustcthesis-bachelor.bst b/ustcthesis-bachelor.bst index b6bc122..69cb931 100644 --- a/ustcthesis-bachelor.bst +++ b/ustcthesis-bachelor.bst @@ -4,13 +4,13 @@ %% %% The original source files were: %% -%% gbt7714.dtx (with options: `ustc,2015,numerical,nouppercase,nomark,italicjournal') +%% gbt7714.dtx (with options: `2015,ustc,numerical,nouppercase,nomark,italicjournal') %% ------------------------------------------------------------------- %% GB/T 7714—2015 BibTeX Style %% https://github.com/CTeX-org/gbt7714-bibtex-style -%% Version: 2020/12/17 v2.1 +%% Version: 2021/04/03 v2.1.1 %% ------------------------------------------------------------------- -%% Copyright (C) 2016-2021 by Zeping Lee +%% Copyright (C) 2016—2021 by Zeping Lee %% ------------------------------------------------------------------- %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3c @@ -18,7 +18,7 @@ %% The latest version of this license is in %% https://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. +%% version 2008 or later. %% ------------------------------------------------------------------- INTEGERS { citation.et.al.min @@ -240,6 +240,22 @@ FUNCTION {or} if$ } +STRINGS { x y } + +FUNCTION {contains} +{ 'y := + 'x := + y text.length$ 'len := + x text.length$ len - #1 + 'charptr := + { charptr #0 > + x charptr len substring$ y = not + and + } + { charptr #1 - 'charptr := } + while$ + charptr #0 > +} + STRINGS { s t } FUNCTION {output.nonnull} @@ -703,17 +719,13 @@ FUNCTION {output.bibitem} "\bibitem[" write$ label ")" * make.full.names duplicate$ short.list = - { pop$ } - { * } - if$ - 's := - s text.length$ 'charptr := - { charptr #0 > s charptr #1 substring$ "[" = not and } - { charptr #1 - 'charptr := } - while$ - charptr #0 > - { "{" s * "}" * } - { s } + { pop$ } + { duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ + * + } if$ "]{" * write$ cite$ write$ @@ -1176,21 +1188,6 @@ FUNCTION {extract.after.dash} if$ } -FUNCTION {contains.dash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {extract.before.slash} { duplicate$ empty$ { pop$ "" } @@ -1235,23 +1232,6 @@ FUNCTION {extract.after.slash} if$ } -FUNCTION {contains.slash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - s #1 #1 substring$ "/" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {format.year} { year empty$ not { year extract.before.slash extra.label * } @@ -1292,11 +1272,16 @@ FUNCTION {format.periodical.year} } FUNCTION {format.date} -{ type$ "patent" = type$ "newspaper" = or - date empty$ not and - { date } - { year field.or.null - extra.label * +{ date empty$ not + { type$ "patent" = type$ "newspaper" = or + { date } + { format.year } + if$ + } + { year empty$ not + { format.year } + { "" } + if$ } if$ } @@ -2212,7 +2197,10 @@ FUNCTION {calc.short.authors} FUNCTION {calc.label} { calc.short.authors - short.list + short.list "]" contains + { "{" short.list * "}" * } + { short.list } + if$ "(" * format.year duplicate$ empty$ @@ -2220,6 +2208,10 @@ FUNCTION {calc.label} { pop$ "" } 'skip$ if$ + duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ * 'label := short.label diff --git a/ustcthesis-numerical.bst b/ustcthesis-numerical.bst index cfabb41..1ae5b2d 100644 --- a/ustcthesis-numerical.bst +++ b/ustcthesis-numerical.bst @@ -4,13 +4,13 @@ %% %% The original source files were: %% -%% gbt7714.dtx (with options: `ustc,2015,numerical') +%% gbt7714.dtx (with options: `2015,ustc,numerical') %% ------------------------------------------------------------------- %% GB/T 7714—2015 BibTeX Style %% https://github.com/CTeX-org/gbt7714-bibtex-style -%% Version: 2020/12/17 v2.1 +%% Version: 2021/04/03 v2.1.1 %% ------------------------------------------------------------------- -%% Copyright (C) 2016-2021 by Zeping Lee +%% Copyright (C) 2016—2021 by Zeping Lee %% ------------------------------------------------------------------- %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3c @@ -18,7 +18,7 @@ %% The latest version of this license is in %% https://www.latex-project.org/lppl.txt %% and version 1.3c or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. +%% version 2008 or later. %% ------------------------------------------------------------------- INTEGERS { citation.et.al.min @@ -240,6 +240,22 @@ FUNCTION {or} if$ } +STRINGS { x y } + +FUNCTION {contains} +{ 'y := + 'x := + y text.length$ 'len := + x text.length$ len - #1 + 'charptr := + { charptr #0 > + x charptr len substring$ y = not + and + } + { charptr #1 - 'charptr := } + while$ + charptr #0 > +} + STRINGS { s t } FUNCTION {output.nonnull} @@ -703,17 +719,13 @@ FUNCTION {output.bibitem} "\bibitem[" write$ label ")" * make.full.names duplicate$ short.list = - { pop$ } - { * } - if$ - 's := - s text.length$ 'charptr := - { charptr #0 > s charptr #1 substring$ "[" = not and } - { charptr #1 - 'charptr := } - while$ - charptr #0 > - { "{" s * "}" * } - { s } + { pop$ } + { duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ + * + } if$ "]{" * write$ cite$ write$ @@ -1176,21 +1188,6 @@ FUNCTION {extract.after.dash} if$ } -FUNCTION {contains.dash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {extract.before.slash} { duplicate$ empty$ { pop$ "" } @@ -1235,23 +1232,6 @@ FUNCTION {extract.after.slash} if$ } -FUNCTION {contains.slash} -{ duplicate$ empty$ - { pop$ #0 } - { 's := - { s empty$ not - s #1 #1 substring$ "-" = not - and - s #1 #1 substring$ "/" = not - and - } - { s #2 global.max$ substring$ 's := } - while$ - s empty$ not - } - if$ -} - FUNCTION {format.year} { year empty$ not { year extract.before.slash extra.label * } @@ -1292,11 +1272,16 @@ FUNCTION {format.periodical.year} } FUNCTION {format.date} -{ type$ "patent" = type$ "newspaper" = or - date empty$ not and - { date } - { year field.or.null - extra.label * +{ date empty$ not + { type$ "patent" = type$ "newspaper" = or + { date } + { format.year } + if$ + } + { year empty$ not + { format.year } + { "" } + if$ } if$ } @@ -2212,7 +2197,10 @@ FUNCTION {calc.short.authors} FUNCTION {calc.label} { calc.short.authors - short.list + short.list "]" contains + { "{" short.list * "}" * } + { short.list } + if$ "(" * format.year duplicate$ empty$ @@ -2220,6 +2208,10 @@ FUNCTION {calc.label} { pop$ "" } 'skip$ if$ + duplicate$ "]" contains + { "{" swap$ * "}" * } + 'skip$ + if$ * 'label := short.label