diff options
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/bibexport/bibexport.sh | 353 | ||||
-rw-r--r-- | Master/texmf-dist/bibtex/bst/bibexport/expcites.bst | 182 | ||||
-rw-r--r-- | Master/texmf-dist/bibtex/bst/bibexport/expkeys.bst | 18 | ||||
-rw-r--r-- | Master/texmf-dist/bibtex/bst/bibexport/export.bst | 18 | ||||
-rw-r--r-- | Master/texmf-dist/doc/bibtex/bibexport/README | 45 | ||||
-rw-r--r-- | Master/texmf-dist/doc/bibtex/bibexport/bibexport.pdf | bin | 153962 -> 254622 bytes | |||
-rwxr-xr-x | Master/texmf-dist/scripts/bibexport/bibexport.sh | 353 | ||||
-rw-r--r-- | Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx | 691 | ||||
-rw-r--r-- | Master/texmf-dist/source/bibtex/bibexport/bibexport.ins | 46 |
9 files changed, 1312 insertions, 394 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/bibexport/bibexport.sh b/Build/source/texk/texlive/linked_scripts/bibexport/bibexport.sh index 07ae9bc2d8e..657e713c006 100755 --- a/Build/source/texk/texlive/linked_scripts/bibexport/bibexport.sh +++ b/Build/source/texk/texlive/linked_scripts/bibexport/bibexport.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ## ## This is file `bibexport.sh', ## generated with the docstrip utility. @@ -7,18 +7,20 @@ ## ## bibexport.dtx (with options: `script') ## -## (c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -## All rights reserved. +## (c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> ## -## This work may be distributed and/or modified under the conditions of -## the LaTeX Project Public License, either version 1.3 of this license -## or (at your option) any later version. The latest version of the +## This work may be distributed and/or modified under the conditions of +## the LaTeX Project Public License, either version 1.3 of this license +## or (at your option) any later version. The latest version of this ## license is in ## -## http://www.latex-project.org/lppl.txt +## http://www.latex-project.org/lppl.txt ## -## and version 1.3 or later is part of all distributions of LaTeX -## version 2003/12/01 or later. +## and version 1.3 or later is part of all distributions of LaTeX version +## 2005/12/01 or later. +## +## This work has the LPPL maintenance status `maintained'. +## The Current Maintainer of this work is Nicolas Markey. ## ## \CharacterTable ## {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -39,106 +41,218 @@ function usage() { echo "bibexport: a tool to extract BibTeX entries out of .bib files. -usage: $0 [-h|v] [-n] [-b bst] [-a [-e file]...] [-o file] file... - -a, --all export the entire .bib files - -b, --bst specifies the .bst style file [default: export.bst] - -c, --crossref include entries that are crossref'd [default: yes] - -e file, --extra file extra .bib files to be used (for crossrefs) - -n, --no-crossref don't include crossref'd entries [default: no] - -o file write output to file [default: bibexport.bib] - -p, --preamble write a preamble at beginning of output - -t, --terse operate silently - -h, --help print this message and exit - -v, --version print version number and exit"; +usage: $0 [-h|v|n|c|a|d|s|t] [-b|e|es|ec|o|r file] file... + +Basic options: +-------------- + -a, --all export the entire .bib files + -o bib, --output-file bib write output to file [default: bibexport.bib] + -t, --terse operate silently + -h, --help print this message and exit + -v, --version print version number and exit + +Advanced options: +----------------- + -b bst, --bst bst specifies the .bst style file [default: export.bst] + -c, --crossref preserve crossref field [default: no] + -n, --no-crossref remove crossref'd entries [default: no] + -e bib, --extra bib extra .bib file to be used (crossrefs and strings) + -es bib, --extras bib extra .bib file to be used (for strings) + -ec bib, --extrac bib extra .bib file to be used (for crossrefs) + -s, --no-preamble don't write a preamble at beginning of output + -r bib, --replace bib replace .bib file(s) in the .aux file + -d, --debug create intermediate files but don't run BibTeX"; exit 0; } -VERSION="2.20"; -VDATE="2009/10/11"; -CROSSREF="1"; +function opttolate() +{ +if [ ${TOOLATE} -ne 0 ]; then + echo "No option is allowed after the input files"; + exit 0; +fi +} +## Version number +VERSION="3.00"; +## Release date +VDATE="2011/11/19"; + +# ALL is a flag set to 1 when '-a' is given +ALL="0"; +# FILE will be the main input file(s) (.aux or .bib, depending on '-a') FILE=""; +# EXT is the extension of the input file(s) (.aux, or .bib if '-a') EXT=".aux"; +# EXTRA and EXTRABIB are two copies of the extra files ('-e'), used to +# include crossref'd entries and @string's EXTRA=""; EXTRABIB=""; -SPACE=" "; +# REPLACEBIB ('-r') is set to 1 when the \bibdata of the .aux input file +# must be ignores (then '-e' must be used) +REPLACEBIB="0"; +# NEWBIB will contain the argument given to -r +NEWBIB=""; +# BST is the .bst file to be used (default to export.bst) BST="export"; +# TERSE will be set to '-terse' if '-t' is given TERSE=""; -NOBANNER="true"; +# BANNER is used to turn on or off the preamble informations in the output +BANNER="true"; +# CREF is the number of citations of crossrefs from which the crossref'd entry +# must be included. +CREF="0"; + +# SPACE will be either ' ' or ',' +SPACE=""; +# TOOLATE is used to prevent extra options after the main file +TOOLATE="0"; +# DEBUG is used to create files but not run BibTeX. +DEBUG=""; + ARGS=$@; if [ $# -eq 0 ]; then usage; fi while [ $# != 0 ]; do - case $1 in - -a|--all) - EXT=""; SPACE=""; - shift ;; - -b|--bst) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bst`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bst`"; - fi - BST="${DOLLARTWO}"; - shift 2;; - -e|--extra) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - EXTRA="${EXTRA}${DOLLARTWO},"; - EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; - shift 2;; - -o|--output-file) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - OUTPUT="${DOLLARTWO}.bib"; - shift 2 ;; - -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) - CREF="1" ; - shift ;; - -n|--no-crossref|--without-crossref) - CREF="20000" ; - shift ;; - -v|--version) - echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; - -p|--preamble) - NOBANNER="false"; - shift ;; - -t|--terse) - TERSE=" -terse "; - shift ;; - -*) - usage;; - *) - if [ "`dirname $1`" = "." ]; then - DOLLARONE="`basename $1 ${EXT}`"; - else - DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; - fi - FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; - if [ -z "${SPACE}" ]; then - SPACE=","; - fi; - shift;; - esac + case $1 in + -a|--all) + ## - export all entries in the input file(s) + ## - the input files are BibTeX files + opttolate; + EXT=""; SPACE=""; + shift ;; + -b|--bst) + ## - specifies the .bst file to use (default to 'export.bst') + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bst`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bst`"; + fi + BST="${DOLLARTWO}"; + shift 2;; + -d|--debug) + ## - debug mode: we create files but do not run bibtex + ## - instead, we print what we would have done... + opttoolate; + DEBUG="echo"; + shift ;; + -e|--extra) + ## - extra input files (containing crossrefs or strings) + ## - they will be included twice: once before the main file(s) + ## (for @string's), once after (for crossrefs). We fool BibTeX + ## by naming the first one 'file.bib' and the second one + ## 'file.bib.bib', to avoid complains. + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; + -es|--extras) + ## - extra input files (containing strings) + ## - will be included *before* the main files (hence not suitable + ## for crossrefs) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + shift 2;; + -ec|--extrac) + ## - extra input files (containing crossrefs) + ## - will be included only *after* the main files (hence not + ## suitable for @string's) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; + -o|--output-file) + ## - name of the output file + ## - we force it to end with '.bib' + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + OUTPUT="${DOLLARTWO}.bib"; + shift 2 ;; + -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) + ## - whether or not to preserve 'crossref' keys. + ## - by default, they are removed, but crossref'd entries are + ## included. + ## - crossrefs are *always* expanded anyway. + opttolate; + CREF="1" ; + shift ;; + -n|--no-crossref|--without-crossref|--no-crossrefs|--without-crossrefs) + ## - to remove crossref'd entries (hence remove 'crossref' keys). + opttolate; + CREF="20000" ; + shift ;; + -r|--replace) + ## - to replace the file(s) given in \bibdata in the .aux file with + ## (a) new one(s). + opttolate; + REPLACEBIB="1"; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + NEWBIB="${NEWBIB}${DOLLARTWO}.bib,"; + shift 2;; + -v|--version) + echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; + -s|--no-preamble|--without-preamble) + NOBANNER="false"; + shift ;; + -t|--terse|--silent) + TERSE=" -terse "; + shift ;; + -*) + usage;; + *) + ## - list of input files + ## - we ensure that no extra option is given later... + TOOLATE="1"; + if [ "`dirname $1`" = "." ]; then + DOLLARONE="`basename $1 ${EXT}`"; + else + DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; + fi + FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; + if [ ${ALL} -eq 1 ]; then + SPACE=","; + else +SPACE=" "; + fi; + shift;; + esac done FINALFILE=${OUTPUT}; if [ ! "${FINALFILE}" ]; then FINALFILE="bibexport.bib"; fi TMPFILE="bibexp.`date +%s`"; -if [ -z "${EXT}" ]; then - if [ -z "${EXTRA}" ]; then +if [ -z "${EXT}" ]; then ## we export all entries + if [ -z "${EXTRA}" ]; then ## we have no extra files cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} \bibstyle{${BST}} EOF - else + else ## we have extra files (e.g. for crossrefs) but want all entries from ${FILE} + ## we first extract the keys to be used: cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} @@ -146,33 +260,68 @@ EOF EOF bibtex -min-crossrefs=${CREF} -terse ${TMPFILE}; mv -f ${TMPFILE}.bbl ${TMPFILE}.aux; +## and then prepare the .aux file for exporting: cat >> ${TMPFILE}.aux <<EOF \bibdata{${EXTRA}${FILE}${EXTRABIB}} \bibstyle{${BST}} EOF fi -else +else ## we only export entries listed in the given .aux file: + if [ ! "x${REPLACEBIB}" = "x1" ]; then cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" > ${TMPFILE}.aux; + else + cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" \ + -e "s/bibdata{.*}/bibdata{${EXTRA}${NEWBIB%,}${EXTRABIB}}/" > ${TMPFILE}.aux; + fi +fi +if [ -z "$DEBUG" ]; then + bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE}; + if [ -e ${FINALFILE} ]; then +mv ${FINALFILE} ${FINALFILE}-save-`date "+%Y.%m.%d:%H.%M.%S"` + fi + echo "" > ${FINALFILE} +else + echo "bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE};" +fi +if [ ! "${BANNER}" = "false" ]; then + ## list of cited entries + if [ -z "$DEBUG" ]; then +sed -i -e "s/\\\bibstyle{.*}/\\\bibstyle{expcites}/" ${TMPFILE}.aux +mv ${TMPFILE}.aux ${TMPFILE}-cites.aux +bibtex -terse -min-crossrefs=${CREF} ${TMPFILE}-cites +echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; +echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; +echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; +if [ -z "${EXT}" ]; then + echo -ne " source files:\t\t${FILETAB}\t\t\t${EXTRABIBTAB}\n" >> ${FINALFILE}; \ +fi +cat ${TMPFILE}-cites.bbl >> ${FINALFILE}; +echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; +echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; +sed -i -e "s/}/)/g" ${FINALFILE}; +echo -n -e "}\n\n\n" >> ${FINALFILE}; +rm -f ${TMPFILE}-cites.bbl ${TMPFILE}-cites.aux ${TMPFILE}-cites.blg + fi fi -bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE} -echo "" > ${FINALFILE} -if [ ! "${NOBANNER}" = "true" ]; then - echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; - echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; - echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; - echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; - echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; - sed -ie "s/}/)/g" ${FINALFILE}; - echo -ne "}\n\n\n" >> ${FINALFILE}; +if [ ${CREF} -ne 1 ]; then + if [ -z "$DEBUG" ]; then +egrep -iv '^ *crossref *= *[^,]+,?$' \ + ${TMPFILE}.bbl >> ${FINALFILE}; + else +echo "egrep -iv '^ *crossref *= *[^,]+,?$' ${TMPFILE}.bbl >> ${FINALFILE};" + fi +else + if [ -z "$DEBUG" ]; then +cat ${TMPFILE}.bbl >> ${FINALFILE}; + else +echo "cat ${TMPFILE}.bbl >> ${FINALFILE};" + fi fi -if [ ! "x${CREF}" = "x1" ]; then - sed -r -e \ - "/^ *[cC][rR][oO][sS][sS][rR][eE][fF] *= *[^,]+,?$/d" \ - ${TMPFILE}.bbl >> ${FINALFILE}; +if [ -z "$DEBUG" ]; then + rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg; else - cat ${TMPFILE}.bbl >> ${FINALFILE}; + echo "rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg"; fi -rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg ## ## ## End of file `bibexport.sh'. diff --git a/Master/texmf-dist/bibtex/bst/bibexport/expcites.bst b/Master/texmf-dist/bibtex/bst/bibexport/expcites.bst new file mode 100644 index 00000000000..d2d09a0eb2d --- /dev/null +++ b/Master/texmf-dist/bibtex/bst/bibexport/expcites.bst @@ -0,0 +1,182 @@ +%% +%% This is file `expcites.bst', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bibexport.dtx (with options: `expcites') +%% +%% (c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> +%% +%% This work may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this +%% license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Nicolas Markey. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +FUNCTION{left.width}{#23} +FUNCTION{right.width}{#55} +FUNCTION{url.right.width}{#61} +FUNCTION{left.short.width}{#10} %% for @preamble +FUNCTION{right.long.width}{#63} +FUNCTION{left.delim}{quote$} +FUNCTION{right.delim}{quote$} +ENTRY{dummy}{}{} +FUNCTION{not} +{ + {#0} + {#1} + if$ +} +FUNCTION{and} +{ + 'skip$ + {pop$ #0} + if$ +} +FUNCTION{or} +{ + {pop$ #1} + 'skip$ + if$ +} +INTEGERS{left.length right.length} +STRINGS{ s t } +INTEGERS{bool} +FUNCTION{space.complete} +{ + 'left.length := + duplicate$ text.length$ left.length swap$ - + {duplicate$ #0 >} + { + swap$ " " * swap$ #1 - + } + while$ + pop$ +} +FUNCTION{split.string} +{ + 'right.length := + duplicate$ right.length #1 + #1 substring$ "" = + {""} + { + 's := + right.length + {duplicate$ duplicate$ s swap$ #1 substring$ " " = not and} + {#1 -} + while$ + duplicate$ #2 < + { + pop$ " " s * "" + } + { + duplicate$ s swap$ #1 swap$ substring$ + swap$ + s swap$ global.max$ substring$ + } + if$ + } + if$ +} +FUNCTION{init.cited.keys} +{ + left.delim 's := + #0 'bool := +} +FUNCTION{write.cited.keys} +{ + bool + {"" left.width space.complete swap$} + {" cited keys: " left.width space.complete swap$ + #1 'bool :=} + if$ + {duplicate$ text.length$ right.width >} + { + right.width split.string 't := + * + write$ newline$ + "" left.width space.complete t + } + while$ + pop$ pop$ t +} +FUNCTION{write.cited.keys.last} +{ + bool + {"" left.width space.complete swap$} + {" cited keys: " left.width space.complete swap$ + #1 'bool :=} + if$ + {duplicate$ duplicate$ text.length$ #1 substring$ "," = not} + {duplicate$ text.length$ #1 - #1 swap$ substring$} + while$ + duplicate$ text.length$ #1 - #1 swap$ substring$ + right.delim * + {duplicate$ "" = not} + { + right.width split.string 't := + * + write$ newline$ + "" left.width space.complete t + } + while$ + pop$ pop$ +} +FUNCTION{cited.keys} +{ + s cite$ ", " * * 's := + s text.length$ #4000 > + {s write.cited.keys 's :=} + 'skip$ + if$ +} +FUNCTION{end.cited.keys} +{ + s write.cited.keys.last +} +FUNCTION{article}{cited.keys} +FUNCTION{book}{cited.keys} +FUNCTION{booklet}{cited.keys} +FUNCTION{conference}{cited.keys} +FUNCTION{habthesis}{cited.keys} +FUNCTION{inbook}{cited.keys} +FUNCTION{incollection}{cited.keys} +FUNCTION{inproceedings}{cited.keys} +FUNCTION{journals}{cited.keys} +FUNCTION{manual}{cited.keys} +FUNCTION{mastersthesis}{cited.keys} +FUNCTION{misc}{cited.keys} +FUNCTION{phdthesis}{cited.keys} +FUNCTION{proceedings}{cited.keys} +FUNCTION{techreport}{cited.keys} +FUNCTION{unpublished}{cited.keys} +READ +EXECUTE{init.cited.keys} +ITERATE{cited.keys} +EXECUTE{end.cited.keys} +%% +%% +%% End of file `expcites.bst'. diff --git a/Master/texmf-dist/bibtex/bst/bibexport/expkeys.bst b/Master/texmf-dist/bibtex/bst/bibexport/expkeys.bst index 4c7c2ae6299..536e68d352c 100644 --- a/Master/texmf-dist/bibtex/bst/bibexport/expkeys.bst +++ b/Master/texmf-dist/bibtex/bst/bibexport/expkeys.bst @@ -6,18 +6,20 @@ %% %% bibexport.dtx (with options: `expkeys') %% -%% (c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -%% All rights reserved. +%% (c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> %% -%% This work may be distributed and/or modified under the conditions of -%% the LaTeX Project Public License, either version 1.3 of this license -%% or (at your option) any later version. The latest version of the +%% This work may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this %% license is in %% -%% http://www.latex-project.org/lppl.txt +%% http://www.latex-project.org/lppl.txt %% -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2003/12/01 or later. +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Nicolas Markey. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z diff --git a/Master/texmf-dist/bibtex/bst/bibexport/export.bst b/Master/texmf-dist/bibtex/bst/bibexport/export.bst index 11e3de2b995..2034f29f382 100644 --- a/Master/texmf-dist/bibtex/bst/bibexport/export.bst +++ b/Master/texmf-dist/bibtex/bst/bibexport/export.bst @@ -6,18 +6,20 @@ %% %% bibexport.dtx (with options: `export') %% -%% (c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -%% All rights reserved. +%% (c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> %% -%% This work may be distributed and/or modified under the conditions of -%% the LaTeX Project Public License, either version 1.3 of this license -%% or (at your option) any later version. The latest version of the +%% This work may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this %% license is in %% -%% http://www.latex-project.org/lppl.txt +%% http://www.latex-project.org/lppl.txt %% -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2003/12/01 or later. +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Nicolas Markey. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z diff --git a/Master/texmf-dist/doc/bibtex/bibexport/README b/Master/texmf-dist/doc/bibtex/bibexport/README index 66f286ff05f..989292e874b 100644 --- a/Master/texmf-dist/doc/bibtex/bibexport/README +++ b/Master/texmf-dist/doc/bibtex/bibexport/README @@ -1,24 +1,27 @@ -bibexport.sh -- extract BibTeX entries out of .bib file(s). - (N. Markey -- <markey(at)lsv.ens-cachan.fr>) - version 2.20 -- 2009/10/11 - -This is a shell script using BibTeX to extract .bib entries -that are \cite'd in a document. It also permits to expand a -BibTeX file, i.e. to develop abbreviations (except standard -ones) and crossrefs. - - ------------------------------------------------------------ - -This work may be distributed and/or modified under the -conditions of the LaTeX Project Public License, either -version 1.3 of this license or (at your option) any later -version. The latest version of this license is in - http://www.latex-project.org/lppl.txt -and version 1.3 or later is part of all distributions of -LaTeX version 2003/12/01 or later. -This work has the LPPL status "maintained". -The current maintainer of this work is Nicolas Markey. + bibexport.sh -- extract BibTeX entries out of .bib file(s). + (N. Markey -- <markey(at)lsv.ens-cachan.fr>) + version 3.00 -- 2011/11/19 + +This is a shell script using BibTeX to extract .bib entries that are +\cite'd in a document. It also permits to expand a BibTeX file, +i.e. to develop abbreviations (except standard ones) and crossrefs. + + +---------------------------------------------------------------------- + +(c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> + +This work may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3 of this license +or (at your option) any later version. The latest version of this +license is in + http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of LaTeX version +2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. +The Current Maintainer of this work is Nicolas Markey. + diff --git a/Master/texmf-dist/doc/bibtex/bibexport/bibexport.pdf b/Master/texmf-dist/doc/bibtex/bibexport/bibexport.pdf Binary files differindex 1689a31b05c..e30323758d9 100644 --- a/Master/texmf-dist/doc/bibtex/bibexport/bibexport.pdf +++ b/Master/texmf-dist/doc/bibtex/bibexport/bibexport.pdf diff --git a/Master/texmf-dist/scripts/bibexport/bibexport.sh b/Master/texmf-dist/scripts/bibexport/bibexport.sh index 07ae9bc2d8e..657e713c006 100755 --- a/Master/texmf-dist/scripts/bibexport/bibexport.sh +++ b/Master/texmf-dist/scripts/bibexport/bibexport.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ## ## This is file `bibexport.sh', ## generated with the docstrip utility. @@ -7,18 +7,20 @@ ## ## bibexport.dtx (with options: `script') ## -## (c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -## All rights reserved. +## (c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> ## -## This work may be distributed and/or modified under the conditions of -## the LaTeX Project Public License, either version 1.3 of this license -## or (at your option) any later version. The latest version of the +## This work may be distributed and/or modified under the conditions of +## the LaTeX Project Public License, either version 1.3 of this license +## or (at your option) any later version. The latest version of this ## license is in ## -## http://www.latex-project.org/lppl.txt +## http://www.latex-project.org/lppl.txt ## -## and version 1.3 or later is part of all distributions of LaTeX -## version 2003/12/01 or later. +## and version 1.3 or later is part of all distributions of LaTeX version +## 2005/12/01 or later. +## +## This work has the LPPL maintenance status `maintained'. +## The Current Maintainer of this work is Nicolas Markey. ## ## \CharacterTable ## {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -39,106 +41,218 @@ function usage() { echo "bibexport: a tool to extract BibTeX entries out of .bib files. -usage: $0 [-h|v] [-n] [-b bst] [-a [-e file]...] [-o file] file... - -a, --all export the entire .bib files - -b, --bst specifies the .bst style file [default: export.bst] - -c, --crossref include entries that are crossref'd [default: yes] - -e file, --extra file extra .bib files to be used (for crossrefs) - -n, --no-crossref don't include crossref'd entries [default: no] - -o file write output to file [default: bibexport.bib] - -p, --preamble write a preamble at beginning of output - -t, --terse operate silently - -h, --help print this message and exit - -v, --version print version number and exit"; +usage: $0 [-h|v|n|c|a|d|s|t] [-b|e|es|ec|o|r file] file... + +Basic options: +-------------- + -a, --all export the entire .bib files + -o bib, --output-file bib write output to file [default: bibexport.bib] + -t, --terse operate silently + -h, --help print this message and exit + -v, --version print version number and exit + +Advanced options: +----------------- + -b bst, --bst bst specifies the .bst style file [default: export.bst] + -c, --crossref preserve crossref field [default: no] + -n, --no-crossref remove crossref'd entries [default: no] + -e bib, --extra bib extra .bib file to be used (crossrefs and strings) + -es bib, --extras bib extra .bib file to be used (for strings) + -ec bib, --extrac bib extra .bib file to be used (for crossrefs) + -s, --no-preamble don't write a preamble at beginning of output + -r bib, --replace bib replace .bib file(s) in the .aux file + -d, --debug create intermediate files but don't run BibTeX"; exit 0; } -VERSION="2.20"; -VDATE="2009/10/11"; -CROSSREF="1"; +function opttolate() +{ +if [ ${TOOLATE} -ne 0 ]; then + echo "No option is allowed after the input files"; + exit 0; +fi +} +## Version number +VERSION="3.00"; +## Release date +VDATE="2011/11/19"; + +# ALL is a flag set to 1 when '-a' is given +ALL="0"; +# FILE will be the main input file(s) (.aux or .bib, depending on '-a') FILE=""; +# EXT is the extension of the input file(s) (.aux, or .bib if '-a') EXT=".aux"; +# EXTRA and EXTRABIB are two copies of the extra files ('-e'), used to +# include crossref'd entries and @string's EXTRA=""; EXTRABIB=""; -SPACE=" "; +# REPLACEBIB ('-r') is set to 1 when the \bibdata of the .aux input file +# must be ignores (then '-e' must be used) +REPLACEBIB="0"; +# NEWBIB will contain the argument given to -r +NEWBIB=""; +# BST is the .bst file to be used (default to export.bst) BST="export"; +# TERSE will be set to '-terse' if '-t' is given TERSE=""; -NOBANNER="true"; +# BANNER is used to turn on or off the preamble informations in the output +BANNER="true"; +# CREF is the number of citations of crossrefs from which the crossref'd entry +# must be included. +CREF="0"; + +# SPACE will be either ' ' or ',' +SPACE=""; +# TOOLATE is used to prevent extra options after the main file +TOOLATE="0"; +# DEBUG is used to create files but not run BibTeX. +DEBUG=""; + ARGS=$@; if [ $# -eq 0 ]; then usage; fi while [ $# != 0 ]; do - case $1 in - -a|--all) - EXT=""; SPACE=""; - shift ;; - -b|--bst) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bst`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bst`"; - fi - BST="${DOLLARTWO}"; - shift 2;; - -e|--extra) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - EXTRA="${EXTRA}${DOLLARTWO},"; - EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; - shift 2;; - -o|--output-file) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - OUTPUT="${DOLLARTWO}.bib"; - shift 2 ;; - -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) - CREF="1" ; - shift ;; - -n|--no-crossref|--without-crossref) - CREF="20000" ; - shift ;; - -v|--version) - echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; - -p|--preamble) - NOBANNER="false"; - shift ;; - -t|--terse) - TERSE=" -terse "; - shift ;; - -*) - usage;; - *) - if [ "`dirname $1`" = "." ]; then - DOLLARONE="`basename $1 ${EXT}`"; - else - DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; - fi - FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; - if [ -z "${SPACE}" ]; then - SPACE=","; - fi; - shift;; - esac + case $1 in + -a|--all) + ## - export all entries in the input file(s) + ## - the input files are BibTeX files + opttolate; + EXT=""; SPACE=""; + shift ;; + -b|--bst) + ## - specifies the .bst file to use (default to 'export.bst') + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bst`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bst`"; + fi + BST="${DOLLARTWO}"; + shift 2;; + -d|--debug) + ## - debug mode: we create files but do not run bibtex + ## - instead, we print what we would have done... + opttoolate; + DEBUG="echo"; + shift ;; + -e|--extra) + ## - extra input files (containing crossrefs or strings) + ## - they will be included twice: once before the main file(s) + ## (for @string's), once after (for crossrefs). We fool BibTeX + ## by naming the first one 'file.bib' and the second one + ## 'file.bib.bib', to avoid complains. + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; + -es|--extras) + ## - extra input files (containing strings) + ## - will be included *before* the main files (hence not suitable + ## for crossrefs) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + shift 2;; + -ec|--extrac) + ## - extra input files (containing crossrefs) + ## - will be included only *after* the main files (hence not + ## suitable for @string's) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; + -o|--output-file) + ## - name of the output file + ## - we force it to end with '.bib' + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + OUTPUT="${DOLLARTWO}.bib"; + shift 2 ;; + -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) + ## - whether or not to preserve 'crossref' keys. + ## - by default, they are removed, but crossref'd entries are + ## included. + ## - crossrefs are *always* expanded anyway. + opttolate; + CREF="1" ; + shift ;; + -n|--no-crossref|--without-crossref|--no-crossrefs|--without-crossrefs) + ## - to remove crossref'd entries (hence remove 'crossref' keys). + opttolate; + CREF="20000" ; + shift ;; + -r|--replace) + ## - to replace the file(s) given in \bibdata in the .aux file with + ## (a) new one(s). + opttolate; + REPLACEBIB="1"; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + NEWBIB="${NEWBIB}${DOLLARTWO}.bib,"; + shift 2;; + -v|--version) + echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; + -s|--no-preamble|--without-preamble) + NOBANNER="false"; + shift ;; + -t|--terse|--silent) + TERSE=" -terse "; + shift ;; + -*) + usage;; + *) + ## - list of input files + ## - we ensure that no extra option is given later... + TOOLATE="1"; + if [ "`dirname $1`" = "." ]; then + DOLLARONE="`basename $1 ${EXT}`"; + else + DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; + fi + FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; + if [ ${ALL} -eq 1 ]; then + SPACE=","; + else +SPACE=" "; + fi; + shift;; + esac done FINALFILE=${OUTPUT}; if [ ! "${FINALFILE}" ]; then FINALFILE="bibexport.bib"; fi TMPFILE="bibexp.`date +%s`"; -if [ -z "${EXT}" ]; then - if [ -z "${EXTRA}" ]; then +if [ -z "${EXT}" ]; then ## we export all entries + if [ -z "${EXTRA}" ]; then ## we have no extra files cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} \bibstyle{${BST}} EOF - else + else ## we have extra files (e.g. for crossrefs) but want all entries from ${FILE} + ## we first extract the keys to be used: cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} @@ -146,33 +260,68 @@ EOF EOF bibtex -min-crossrefs=${CREF} -terse ${TMPFILE}; mv -f ${TMPFILE}.bbl ${TMPFILE}.aux; +## and then prepare the .aux file for exporting: cat >> ${TMPFILE}.aux <<EOF \bibdata{${EXTRA}${FILE}${EXTRABIB}} \bibstyle{${BST}} EOF fi -else +else ## we only export entries listed in the given .aux file: + if [ ! "x${REPLACEBIB}" = "x1" ]; then cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" > ${TMPFILE}.aux; + else + cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" \ + -e "s/bibdata{.*}/bibdata{${EXTRA}${NEWBIB%,}${EXTRABIB}}/" > ${TMPFILE}.aux; + fi +fi +if [ -z "$DEBUG" ]; then + bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE}; + if [ -e ${FINALFILE} ]; then +mv ${FINALFILE} ${FINALFILE}-save-`date "+%Y.%m.%d:%H.%M.%S"` + fi + echo "" > ${FINALFILE} +else + echo "bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE};" +fi +if [ ! "${BANNER}" = "false" ]; then + ## list of cited entries + if [ -z "$DEBUG" ]; then +sed -i -e "s/\\\bibstyle{.*}/\\\bibstyle{expcites}/" ${TMPFILE}.aux +mv ${TMPFILE}.aux ${TMPFILE}-cites.aux +bibtex -terse -min-crossrefs=${CREF} ${TMPFILE}-cites +echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; +echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; +echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; +if [ -z "${EXT}" ]; then + echo -ne " source files:\t\t${FILETAB}\t\t\t${EXTRABIBTAB}\n" >> ${FINALFILE}; \ +fi +cat ${TMPFILE}-cites.bbl >> ${FINALFILE}; +echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; +echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; +sed -i -e "s/}/)/g" ${FINALFILE}; +echo -n -e "}\n\n\n" >> ${FINALFILE}; +rm -f ${TMPFILE}-cites.bbl ${TMPFILE}-cites.aux ${TMPFILE}-cites.blg + fi fi -bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE} -echo "" > ${FINALFILE} -if [ ! "${NOBANNER}" = "true" ]; then - echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; - echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; - echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; - echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; - echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; - sed -ie "s/}/)/g" ${FINALFILE}; - echo -ne "}\n\n\n" >> ${FINALFILE}; +if [ ${CREF} -ne 1 ]; then + if [ -z "$DEBUG" ]; then +egrep -iv '^ *crossref *= *[^,]+,?$' \ + ${TMPFILE}.bbl >> ${FINALFILE}; + else +echo "egrep -iv '^ *crossref *= *[^,]+,?$' ${TMPFILE}.bbl >> ${FINALFILE};" + fi +else + if [ -z "$DEBUG" ]; then +cat ${TMPFILE}.bbl >> ${FINALFILE}; + else +echo "cat ${TMPFILE}.bbl >> ${FINALFILE};" + fi fi -if [ ! "x${CREF}" = "x1" ]; then - sed -r -e \ - "/^ *[cC][rR][oO][sS][sS][rR][eE][fF] *= *[^,]+,?$/d" \ - ${TMPFILE}.bbl >> ${FINALFILE}; +if [ -z "$DEBUG" ]; then + rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg; else - cat ${TMPFILE}.bbl >> ${FINALFILE}; + echo "rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg"; fi -rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg ## ## ## End of file `bibexport.sh'. diff --git a/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx b/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx index d1530fcb7d6..30ef645455c 100644 --- a/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx +++ b/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx @@ -16,15 +16,15 @@ %%%\AtBeginDocument{\CodelineIndex\EnableCrossrefs} %%%\AtEndDocument{\PrintIndex} \begin{document} - \def\docdate{2009/10/11} - \def\fileversion{2.20} - \def\filedate{2009/10/11} + \def\docdate{2011/11/19} + \def\fileversion{3.00} + \def\filedate{2011/11/19} \DocInput{bibexport.dtx} \end{document} %</driver> % % \fi -% \CheckSum{26} +% \CheckSum{41} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -50,10 +50,10 @@ % % \begin{abstract} % \script{bibexport.sh} is a small shell script, relying on \BibTeX, that -% extracts entries of one or several \ext{bib} file(s). It will expand +% extracts entries of one or several \ext{bib} file(s). It~will expand % abbreviations and cross-references, except standard month and journal % abbreviations. The output is indented as neatly as possible, yielding a -% readable \ext{bib} file even if the original one was not. +% readable \ext{bib} file even if the original file is~not. % \end{abstract} % % @@ -64,8 +64,8 @@ % \BibTeX{} aims at allowing for the use of one single \ext{bib} file, % containing many entries, from which \BibTeX{} extracts only the % \verb+\cite+d ones. When sending a document to someone else, this -% requires either to send the whole file, or to extract some entries -% from the \ext{bib} file. +% requires either sending the whole file, or extracting the \verb+\cite+d +% entries from the \ext{bib} file. % % \BibTeX{} also has a mechanism for using abbreviations and % cross-references. When extracting entries of a large \ext{bib} file, @@ -86,16 +86,16 @@ % "properly", \emph{i.e.} in the same way as they will be handled when cited in % a \LaTeX{} document; %\item[$=$] \BibTeX{} has some strict limitations (especially "no more than 78 consecutive -% non-space characters") that we must be aware of. On the other hand, any such +% non-space characters") that we must be aware~of. On~the other hand, any such % problem occuring within the script would also occur when compiling a % document; %\item[$-$] abbreviations and cross-references will \emph{always} be -% developped. It could be argued that this is also a positive point, but -% having the choice would have been better. +% developped. It~could be argued that this is also a positive point, but +% having the choice would be better. %\item[$-$] Many people seem to find \BibTeX's internal language clumsy, and thus % the script could be difficult to adapt to special needs. However, this is -% \emph{really} not that difficult, as will be explained later on. And please, -% don't hesitate to ask for improvements. +% not \emph{that} difficult, as will be explained later~on. In the present case, +% adding more fields to be exported is quite easy. % \end{itemize} % % \subsection{Related scripts} @@ -107,12 +107,11 @@ % files. It does not expand anything, but includes all the necessary % definitions and entries. %\item \verb+bibextract.sh+, by Nelson Beebe. This script uses \lang{awk} for -% extracting some entries out of a \ext{bib} file. It is said to be -% noncompliant with cross-references. +% extracting some entries out of a \ext{bib} file. It~is said not to be +% compliant with cross-references. %\item \bst{subset}, by David Kotz. \bst{export} develops the same ideas (but -% I discovered that only later on). \bst{subset} does not handle +% I discovered that only later~on). \bst{subset} does not handle % \entry{preamble}, neither does it "protect" standard abbreviations. -%\item Probalby some others... % \end{itemize} % % \subsection{Some examples} @@ -121,20 +120,20 @@ %\item extracting \verb+\cite+d references of a document, also including % cross-references: %\begin{center} -% \ttfamily bibexport -o {\itshape <result>}.bib {\itshape <file>}.aux +% \ttfamily bibexport.sh -o {\itshape <result>}.bib {\itshape <file>}.aux %\end{center} %\item extracting \verb+\cite+d references of a document, without crossrefs, % and using a special \ext{bst} file: %\begin{center} -% \ttfamily bibexport -b {\itshape <style>}.bst -o {\itshape <result>}.bib {\itshape <file>}.aux +% \ttfamily bibexport.sh -b {\itshape <style>}.bst -o {\itshape <result>}.bib {\itshape <file>}.aux %\end{center} %\item export all the entries of two \ext{bib} files (including crossrefed entries): %\begin{center} -% \ttfamily bibexport -a -o {\itshape <result>}.bib {\itshape <file1>}.bib {\itshape <file2>}.bib +% \ttfamily bibexport.sh -a -o {\itshape <result>}.bib {\itshape <file1>}.bib {\itshape <file2>}.bib %\end{center} %\item export all the entries of two \ext{bib} files (without crossrefs): %\begin{center} -% \ttfamily bibexport -a -n -o {\itshape <result>}.bib {\itshape <file1>}.bib +% \ttfamily bibexport.sh -a -n -o {\itshape <result>}.bib {\itshape <file1>}.bib % {\itshape <file2>}.bib %\end{center} % In fact, the only difference between this and the previous one is that @@ -142,7 +141,7 @@ %\item export all the entries of two \ext{bib} files, using an extra file % containing cross-referenced entries (which should not be included): %\begin{center} -% \ttfamily bibexport -a -e {\itshape <crossref>}.bib -n -o {\itshape +% \ttfamily bibexport.sh -a -e {\itshape <crossref>}.bib -n -o {\itshape % <result>}.bib \textbackslash\par {\itshape <file1>}.bib {\itshape <file2>}.bib %\end{center} %\end{itemize} @@ -169,77 +168,142 @@ % \end{itemize} % % \subsection*{Acknowledgements} -% I thank \'Eric Colin de Verdi\`ere and Richard Mathar -% for suggesting several improvements or corrections. +% I thank \'Eric Colin de Verdi\`ere, Richard Mathar, Harald Hanche-Olsen +% and Damien Pollet for suggesting several improvements or corrections. % % \section{The code} % \subsection{The shell script} % \subsubsection{Initialization} % -%\begin{macro}{usage()} +%\begin{macro}{usage} % We first define how the script should be used: % \begin{macrocode} %<*script> function usage() { echo "bibexport: a tool to extract BibTeX entries out of .bib files. -usage: $0 [-h|v] [-n] [-b bst] [-a [-e file]...] [-o file] file... - -a, --all export the entire .bib files - -b, --bst specifies the .bst style file [default: export.bst] - -c, --crossref include entries that are crossref'd [default: yes] - -e file, --extra file extra .bib files to be used (for crossrefs) - -n, --no-crossref don't include crossref'd entries [default: no] - -o file write output to file [default: bibexport.bib] - -p, --preamble write a preamble at beginning of output - -t, --terse operate silently - -h, --help print this message and exit - -v, --version print version number and exit"; +usage: $0 [-h|v|n|c|a|d|s|t] [-b|e|es|ec|o|r file] file... + +Basic options: +-------------- + -a, --all export the entire .bib files + -o bib, --output-file bib write output to file [default: bibexport.bib] + -t, --terse operate silently + -h, --help print this message and exit + -v, --version print version number and exit + +Advanced options: +----------------- + -b bst, --bst bst specifies the .bst style file [default: export.bst] + -c, --crossref preserve crossref field [default: no] + -n, --no-crossref remove crossref'd entries [default: no] + -e bib, --extra bib extra .bib file to be used (crossrefs and strings) + -es bib, --extras bib extra .bib file to be used (for strings) + -ec bib, --extrac bib extra .bib file to be used (for crossrefs) + -s, --no-preamble don't write a preamble at beginning of output + -r bib, --replace bib replace .bib file(s) in the .aux file + -d, --debug create intermediate files but don't run BibTeX"; exit 0; } %</script> % \end{macrocode} %\end{macro} % +%\begin{macro}{toolate} +% We also have a function to warn if extra options are given after +% the names of input files, which is not allowed. +% \begin{macrocode} +%<*script> +function opttolate() +{ +if [ ${TOOLATE} -ne 0 ]; then + echo "No option is allowed after the input files"; + exit 0; +fi +} +%</script> +% \end{macrocode} +%\end{macro} %\begin{macro}{VERSION} %\begin{macro}{VDATE} +%\begin{macro}{ALL} %\begin{macro}{CREF} +%\begin{macro}{DEBUG} %\begin{macro}{FILE} %\begin{macro}{EXT} %\begin{macro}{EXTRA} %\begin{macro}{EXTRABIB} +%\begin{macro}{REPLACEBIB} +%\begin{macro}{NEWBIB} %\begin{macro}{SPACE} %\begin{macro}{BST} %\begin{macro}{TERSE} %\begin{macro}{NOBANNER} %\begin{macro}{ARGS} +%\begin{macro}{TOOLATE} % We define the default value of some variables: % \begin{itemize} -% \item \var{VERSION}: the version number, -% \item \var{VDATE}: the release date, -% \item \var{CREF}: the value of \verb+-min-crossrefs+, -% \item \var{FILE}: the input file(s), -% \item \var{EXT}: the extension (\ext{aux} or \ext{bib}) of input files, -% \item \var{EXTRA}: list of possible extra \ext{bib} files without extension, -% \item \var{EXTRABIB}: list of possible extra \ext{bib} files with extension, -% \item \var{SPACE}: file name separator (can be \textvisiblespace, comma or empty), -% \item \var{BST}: the \ext{bst} file to be used, -% \item \var{TERSE}: tells \BibTeX{} to run silently, -% \item \var{NOBANNER}: don't print the initial comment, -% \item \var{ARGS}: the list of aruments passed to \texttt{bibexport.sh}. +% \item \var{VERSION}: the version number; +% \item \var{VDATE}: the release date; +% \item \var{ALL}: a flag indicating that all entries of the given (\ext{bib}) +% file are to be exported; +% \item \var{CREF}: the value of \verb+-min-crossrefs+; +% \item \var{FILE}: the input file(s); +% \item \var{EXT}: the extension (\ext{aux} or \ext{bib}) of input files; +% \item \var{EXTRA}: list of possible extra \ext{bib} files without extension; +% \item \var{EXTRABIB}: list of possible extra \ext{bib} files with extension; +% \item \var{REPLACEBIB}: flag indicating that we will replace the \ext{bib} +% file given in the \ext{aux} file with a new one; +% \item \var{NEWBIB}: new \ext{bib} file to replace that fiven in the +% \ext{aux} file; +% \item \var{SPACE}: file name separator (can be \textvisiblespace, comma or empty); +% \item \var{BST}: the \ext{bst} file to be used; +% \item \var{TERSE}: run silently; +% \item \var{NOBANNER}: don't print the initial comment; +% \item \var{ARGS}: the list of aruments passed to \texttt{bibexport.sh}; +% \item \var{TOOLATE}: options are not allowed once we have encountered the +% first non-option argument. +% \item \var{DEBUG}: create intermediate files but do not run BibTeX. % \end{itemize} % \begin{macrocode} %<*script> -VERSION="2.20"; -VDATE="2009/10/11"; -CROSSREF="1"; +## Version number +VERSION="3.00"; +## Release date +VDATE="2011/11/19"; + +# ALL is a flag set to 1 when '-a' is given +ALL="0"; +# FILE will be the main input file(s) (.aux or .bib, depending on '-a') FILE=""; +# EXT is the extension of the input file(s) (.aux, or .bib if '-a') EXT=".aux"; +# EXTRA and EXTRABIB are two copies of the extra files ('-e'), used to +# include crossref'd entries and @string's EXTRA=""; EXTRABIB=""; -SPACE=" "; +# REPLACEBIB ('-r') is set to 1 when the \bibdata of the .aux input file +# must be ignores (then '-e' must be used) +REPLACEBIB="0"; +# NEWBIB will contain the argument given to -r +NEWBIB=""; +# BST is the .bst file to be used (default to export.bst) BST="export"; +# TERSE will be set to '-terse' if '-t' is given TERSE=""; -NOBANNER="true"; +# BANNER is used to turn on or off the preamble informations in the output +BANNER="true"; +# CREF is the number of citations of crossrefs from which the crossref'd entry +# must be included. +CREF="0"; + +# SPACE will be either ' ' or ',' +SPACE=""; +# TOOLATE is used to prevent extra options after the main file +TOOLATE="0"; +# DEBUG is used to create files but not run BibTeX. +DEBUG=""; + ARGS=$@; %</script> % \end{macrocode} @@ -255,10 +319,15 @@ ARGS=$@; %\end{macro} %\end{macro} %\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} % % \subsubsection{Handling arguments} % -% If no argument have been supplied, we call \script{usage()}. +% If no argument have been supplied, we call \script{usage}. % % \begin{macrocode} %<*script> @@ -272,7 +341,7 @@ fi % \begin{macrocode} %<*script> while [ $# != 0 ]; do - case $1 in + case $1 in %</script> % \end{macrocode} %\begin{itemize} @@ -280,9 +349,12 @@ while [ $# != 0 ]; do % means that we input \ext{bib} files. % \begin{macrocode} %<*script> - -a|--all) - EXT=""; SPACE=""; - shift ;; + -a|--all) + ## - export all entries in the input file(s) + ## - the input files are BibTeX files + opttolate; + EXT=""; SPACE=""; + shift ;; %</script> % \end{macrocode} %\item \verb+-b+ or \verb+--bst+: specifies the style file. It seems @@ -290,14 +362,29 @@ while [ $# != 0 ]; do % syntax, and we have to handle that case separately. % \begin{macrocode} %<*script> - -b|--bst) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bst`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bst`"; - fi - BST="${DOLLARTWO}"; - shift 2;; + -b|--bst) + ## - specifies the .bst file to use (default to 'export.bst') + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bst`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bst`"; + fi + BST="${DOLLARTWO}"; + shift 2;; +%</script> +% \end{macrocode} +%\item \verb+-d+ or \verb+--debug+: only creates (and preserves) the +% intermediate files. This can help finding problems with the script or +% \ext{bst} files. +% \begin{macrocode} +%<*script> + -d|--debug) + ## - debug mode: we create files but do not run bibtex + ## - instead, we print what we would have done... + opttoolate; + DEBUG="echo"; + shift ;; %</script> % \end{macrocode} %\item \verb+-e+ or \verb+--extra+: when we want to export all the @@ -306,28 +393,74 @@ while [ $# != 0 ]; do % are needed, \emph{e.g.} for crossrefs. % \begin{macrocode} %<*script> - -e|--extra) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - EXTRA="${EXTRA}${DOLLARTWO},"; - EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; - shift 2;; + -e|--extra) + ## - extra input files (containing crossrefs or strings) + ## - they will be included twice: once before the main file(s) + ## (for @string's), once after (for crossrefs). We fool BibTeX + ## by naming the first one 'file.bib' and the second one + ## 'file.bib.bib', to avoid complains. + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; +%</script> +% \end{macrocode} +%\item \verb+-es+ or \verb+--extras+: if, for some reason, including extra +% files twice is not possible, this options provides a way of including extra +% \ext{bib} files only before the main \ext{bib} file(s). +% \begin{macrocode} +%<*script> + -es|--extras) + ## - extra input files (containing strings) + ## - will be included *before* the main files (hence not suitable + ## for crossrefs) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRA="${EXTRA}${DOLLARTWO},"; + shift 2;; +%</script> +% \end{macrocode} +%\item \verb+-ec+ or \verb+--extrac+: similar to te previous one, but for +% file(s) included after the main \ext{bib} file(s). +% \begin{macrocode} +%<*script> + -ec|--extrac) + ## - extra input files (containing crossrefs) + ## - will be included only *after* the main files (hence not + ## suitable for @string's) + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + EXTRABIB="${EXTRABIB},${DOLLARTWO}.bib"; + shift 2;; %</script> % \end{macrocode} %\item \verb+-o+ or \verb+--output+: the name of the output file. % \begin{macrocode} %<*script> - -o|--output-file) - if [ "`dirname $2`" = "." ]; then - DOLLARTWO="`basename $2 .bib`"; - else - DOLLARTWO="`dirname $2`/`basename $2 .bib`"; - fi - OUTPUT="${DOLLARTWO}.bib"; - shift 2 ;; + -o|--output-file) + ## - name of the output file + ## - we force it to end with '.bib' + opttolate; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + OUTPUT="${DOLLARTWO}.bib"; + shift 2 ;; %</script> % \end{macrocode} %\item \verb+-c+ or \verb+--crossref+ (or others): this options means @@ -335,73 +468,104 @@ while [ $# != 0 ]; do % field inheritage will be performed. % \begin{macrocode} %<*script> - -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) - CREF="1" ; - shift ;; + -c|--crossref|--crossrefs|--with-crossref|--with-crossrefs) + ## - whether or not to preserve 'crossref' keys. + ## - by default, they are removed, but crossref'd entries are + ## included. + ## - crossrefs are *always* expanded anyway. + opttolate; + CREF="1" ; + shift ;; %</script> % \end{macrocode} %\item \verb+-n+ or \verb+--no-crossref+: don't include crossref'ed % entries. % \begin{macrocode} %<*script> - -n|--no-crossref|--without-crossref) - CREF="20000" ; - shift ;; + -n|--no-crossref|--without-crossref|--no-crossrefs|--without-crossrefs) + ## - to remove crossref'd entries (hence remove 'crossref' keys). + opttolate; + CREF="20000" ; + shift ;; +%</script> +% \end{macrocode} +%\item \verb+-r+ or \verb+--replace+: this provides a way of replacing the +% \ext{bib} files given by \cmd{bibdata} in the \ext{aux} file with (a) new +% one(s). +% \begin{macrocode} +%<*script> + -r|--replace) + ## - to replace the file(s) given in \bibdata in the .aux file with + ## (a) new one(s). + opttolate; + REPLACEBIB="1"; + if [ "`dirname $2`" = "." ]; then + DOLLARTWO="`basename $2 .bib`"; + else + DOLLARTWO="`dirname $2`/`basename $2 .bib`"; + fi + NEWBIB="${NEWBIB}${DOLLARTWO}.bib,"; + shift 2;; %</script> % \end{macrocode} %\item \verb+-v+ or \verb+--version+ for version number: % \begin{macrocode} %<*script> - -v|--version) - echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; + -v|--version) + echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; %</script> % \end{macrocode} -%\item \verb+-p+ or \verb+--preamble+ for inserting some informations +%\item \verb+-s+ or \verb+--no-preamble+ for inserting some informations % at the beginning of the output file: % \begin{macrocode} %<*script> - -p|--preamble) - NOBANNER="false"; - shift ;; + -s|--no-preamble|--without-preamble) + NOBANNER="false"; + shift ;; %</script> % \end{macrocode} %\item \verb+-t+ or \verb+--terse+ for asking \BibTeX{} to run silently: % \begin{macrocode} %<*script> - -t|--terse) - TERSE=" -terse "; - shift ;; + -t|--terse|--silent) + TERSE=" -terse "; + shift ;; %</script> % \end{macrocode} %\item other dash-options are erroneous (except \verb+-h+, but...): % \begin{macrocode} %<*script> - -*) - usage;; + -*) + usage;; %</script> % \end{macrocode} %\item there should only remain file names: we add those names to the % list of files. % \begin{macrocode} %<*script> - *) - if [ "`dirname $1`" = "." ]; then - DOLLARONE="`basename $1 ${EXT}`"; - else - DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; - fi - FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; - if [ -z "${SPACE}" ]; then - SPACE=","; - fi; - shift;; + *) + ## - list of input files + ## - we ensure that no extra option is given later... + TOOLATE="1"; + if [ "`dirname $1`" = "." ]; then + DOLLARONE="`basename $1 ${EXT}`"; + else + DOLLARONE="`dirname $1`/`basename $1 ${EXT}`"; + fi + FILE="${FILE}${SPACE}${DOLLARONE}${EXT}"; + if [ ${ALL} -eq 1 ]; then + SPACE=","; + else + SPACE=" "; + fi; + shift;; %</script> % \end{macrocode} % \end{itemize} % That's all folks: % \begin{macrocode} %<*script> - esac + esac done %</script> % \end{macrocode} @@ -430,14 +594,15 @@ TMPFILE="bibexp.`date +%s`"; % % \begin{macrocode} %<*script> -if [ -z "${EXT}" ]; then - if [ -z "${EXTRA}" ]; then +if [ -z "${EXT}" ]; then ## we export all entries + if [ -z "${EXTRA}" ]; then ## we have no extra files cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} \bibstyle{${BST}} EOF - else + else ## we have extra files (e.g. for crossrefs) but want all entries from ${FILE} + ## we first extract the keys to be used: cat > ${TMPFILE}.aux <<EOF \citation{*} \bibdata{${FILE}} @@ -445,13 +610,19 @@ EOF EOF bibtex -min-crossrefs=${CREF} -terse ${TMPFILE}; mv -f ${TMPFILE}.bbl ${TMPFILE}.aux; + ## and then prepare the .aux file for exporting: cat >> ${TMPFILE}.aux <<EOF \bibdata{${EXTRA}${FILE}${EXTRABIB}} \bibstyle{${BST}} EOF fi -else +else ## we only export entries listed in the given .aux file: + if [ ! "x${REPLACEBIB}" = "x1" ]; then cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" > ${TMPFILE}.aux; + else + cat ${FILE} | sed -e "s/bibstyle{.*}/bibstyle{${BST}}/" \ + -e "s/bibdata{.*}/bibdata{${EXTRA}${NEWBIB%,}${EXTRABIB}}/" > ${TMPFILE}.aux; + fi fi %</script> % \end{macrocode} @@ -461,25 +632,54 @@ fi % % \begin{macrocode} %<*script> -bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE} -echo "" > ${FINALFILE} -if [ ! "${NOBANNER}" = "true" ]; then - echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; - echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; - echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; - echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; - echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; - sed -ie "s/}/)/g" ${FINALFILE}; - echo -ne "}\n\n\n" >> ${FINALFILE}; +if [ -z "$DEBUG" ]; then + bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE}; + if [ -e ${FINALFILE} ]; then + mv ${FINALFILE} ${FINALFILE}-save-`date "+%Y.%m.%d:%H.%M.%S"` + fi + echo "" > ${FINALFILE} +else + echo "bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE};" +fi +if [ ! "${BANNER}" = "false" ]; then + ## list of cited entries + if [ -z "$DEBUG" ]; then + sed -i -e "s/\\\bibstyle{.*}/\\\bibstyle{expcites}/" ${TMPFILE}.aux + mv ${TMPFILE}.aux ${TMPFILE}-cites.aux + bibtex -terse -min-crossrefs=${CREF} ${TMPFILE}-cites + echo -ne "@comment{generated using bibexport:\n" >> ${FINALFILE}; + echo -ne " creation date:\t`date +\"%c\"`\n" >> ${FINALFILE}; + echo -ne " command:\t\t$0 ${ARGS}\n" >> ${FINALFILE}; + if [ -z "${EXT}" ]; then + echo -ne " source files:\t\t${FILETAB}\t\t\t${EXTRABIBTAB}\n" >> ${FINALFILE}; \ + fi + cat ${TMPFILE}-cites.bbl >> ${FINALFILE}; + echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; + echo -ne " bibexport-maintainer:\tmarkey(at)lsv.ens-cachan.fr\n" >> ${FINALFILE}; + sed -i -e "s/}/)/g" ${FINALFILE}; + echo -n -e "}\n\n\n" >> ${FINALFILE}; + rm -f ${TMPFILE}-cites.bbl ${TMPFILE}-cites.aux ${TMPFILE}-cites.blg + fi +fi +if [ ${CREF} -ne 1 ]; then + if [ -z "$DEBUG" ]; then + egrep -iv '^ *crossref *= *[^,]+,?$' \ + ${TMPFILE}.bbl >> ${FINALFILE}; + else + echo "egrep -iv '^ *crossref *= *[^,]+,?$' ${TMPFILE}.bbl >> ${FINALFILE};" + fi +else + if [ -z "$DEBUG" ]; then + cat ${TMPFILE}.bbl >> ${FINALFILE}; + else + echo "cat ${TMPFILE}.bbl >> ${FINALFILE};" + fi fi -if [ ! "x${CREF}" = "x1" ]; then - sed -r -e \ - "/^ *[cC][rR][oO][sS][sS][rR][eE][fF] *= *[^,]+,?$/d" \ - ${TMPFILE}.bbl >> ${FINALFILE}; +if [ -z "$DEBUG" ]; then + rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg; else - cat ${TMPFILE}.bbl >> ${FINALFILE}; + echo "rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg"; fi -rm -f ${TMPFILE}.bbl ${TMPFILE}.aux ${TMPFILE}.blg %</script> % \end{macrocode} % @@ -502,6 +702,231 @@ ITERATE{export.key} %</expkeys> % \end{macrocode} % +% \subsection{The \bst{expcites} file} +% +% This file is used for exporting and formating the list of \verb+\cite+d entries. +% We begin with some parameters defining the margins +% \subsubsection{Some configuration values} +% \begin{macro}{left.width} +% \begin{macro}{right.width} +% \begin{macro}{url.right.width} +% \begin{macro}{left.short.width} +% \begin{macro}{right.short.width} +% \begin{macro}{left.delim} +% \begin{macro}{right.delim} +% \begin{macrocode} +%<*expcites> +FUNCTION{left.width}{#23} +FUNCTION{right.width}{#55} +FUNCTION{url.right.width}{#61} +FUNCTION{left.short.width}{#10} %% for @preamble +FUNCTION{right.long.width}{#63} +FUNCTION{left.delim}{quote$} +FUNCTION{right.delim}{quote$} +%</expcites> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Entries} +% We only want to export \verb+\cite+d keys, so we won't use any field. +% \begin{macro}{ENTRY} +% \begin{macrocode} +%<*expcites> +ENTRY{dummy}{}{} +%</expcites> +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Basic functions} +% +%\begin{macro}{or} +%\begin{macro}{and} +%\begin{macro}{not} +% \begin{macrocode} +%<*expcites> +FUNCTION{not} +{ + {#0} + {#1} + if$ +} +FUNCTION{and} +{ + 'skip$ + {pop$ #0} + if$ +} +FUNCTION{or} +{ + {pop$ #1} + 'skip$ + if$ +} +%</expcites> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Splitting strings} +% +% We design functions for splitting strings, so that the final +% \ext{bib} file will be cleanly indented. +% \begin{macro}{space.complete} +% \begin{macro}{split.string} +% \begin{macrocode} +%<*expcites> +INTEGERS{left.length right.length} +STRINGS{ s t } +INTEGERS{bool} +FUNCTION{space.complete} +{ + 'left.length := + duplicate$ text.length$ left.length swap$ - + {duplicate$ #0 >} + { + swap$ " " * swap$ #1 - + } + while$ + pop$ +} +FUNCTION{split.string} +{ + 'right.length := + duplicate$ right.length #1 + #1 substring$ "" = + {""} + { + 's := + right.length + {duplicate$ duplicate$ s swap$ #1 substring$ " " = not and} + {#1 -} + while$ + duplicate$ #2 < + { + pop$ " " s * "" + } + { + duplicate$ s swap$ #1 swap$ substring$ + swap$ + s swap$ global.max$ substring$ + } + if$ + } + if$ +} +%</expcites> +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsubsection{Exporting cited entries} +% +% Now we initialize, and export \verb+\cite+d entries. +%\begin{macro}{init.cited.keys} +%\begin{macro}{write.cited.keys} +%\begin{macro}{write.cited.keys.last} +%\begin{macro}{cited.keys} +%\begin{macro}{end.cited.keys} +% \begin{macrocode} +%<*expcites> +FUNCTION{init.cited.keys} +{ + left.delim 's := + #0 'bool := +} +FUNCTION{write.cited.keys} +{ + bool + {"" left.width space.complete swap$} + {" cited keys: " left.width space.complete swap$ + #1 'bool :=} + if$ + {duplicate$ text.length$ right.width >} + { + right.width split.string 't := + * + write$ newline$ + "" left.width space.complete t + } + while$ + pop$ pop$ t +} +FUNCTION{write.cited.keys.last} +{ + bool + {"" left.width space.complete swap$} + {" cited keys: " left.width space.complete swap$ + #1 'bool :=} + if$ + {duplicate$ duplicate$ text.length$ #1 substring$ "," = not} + {duplicate$ text.length$ #1 - #1 swap$ substring$} + while$ + duplicate$ text.length$ #1 - #1 swap$ substring$ + right.delim * + {duplicate$ "" = not} + { + right.width split.string 't := + * + write$ newline$ + "" left.width space.complete t + } + while$ + pop$ pop$ +} +FUNCTION{cited.keys} +{ + s cite$ ", " * * 's := + s text.length$ #4000 > + {s write.cited.keys 's :=} + 'skip$ + if$ +} +FUNCTION{end.cited.keys} +{ + s write.cited.keys.last +} +%</expcites> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Now, we export...} +% +% We now export everything... +% \begin{macrocode} +%<*expcites> +FUNCTION{article}{cited.keys} +FUNCTION{book}{cited.keys} +FUNCTION{booklet}{cited.keys} +FUNCTION{conference}{cited.keys} +FUNCTION{habthesis}{cited.keys} +FUNCTION{inbook}{cited.keys} +FUNCTION{incollection}{cited.keys} +FUNCTION{inproceedings}{cited.keys} +FUNCTION{journals}{cited.keys} +FUNCTION{manual}{cited.keys} +FUNCTION{mastersthesis}{cited.keys} +FUNCTION{misc}{cited.keys} +FUNCTION{phdthesis}{cited.keys} +FUNCTION{proceedings}{cited.keys} +FUNCTION{techreport}{cited.keys} +FUNCTION{unpublished}{cited.keys} +READ +EXECUTE{init.cited.keys} +ITERATE{cited.keys} +EXECUTE{end.cited.keys} +%</expcites> +% \end{macrocode} +% % \subsection{The \bst{export} file} % % \subsubsection{Some configuration values} @@ -616,7 +1041,7 @@ FUNCTION{or} % \begin{macro}{space.complete} % \begin{macro}{split.string} % \begin{macro}{split.url} -% \begin{macro}{split name} +% \begin{macro}{split.name} % \begin{macrocode} %<*export> INTEGERS{left.length right.length} diff --git a/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins b/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins index 084404ffb29..a8f8d05a917 100644 --- a/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins +++ b/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins @@ -1,4 +1,4 @@ -\NeedsTeXFormat{LaTeX2e}[1996/12/01] +%\NeedsTeXFormat{LaTeX2e}[1996/12/01] \input docstrip {\catcode`\#=12 @@ -8,18 +8,20 @@ \let\MetaPrefix\DoubleSharp \preamble -(c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -All rights reserved. +(c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -This work may be distributed and/or modified under the conditions of -the LaTeX Project Public License, either version 1.3 of this license -or (at your option) any later version. The latest version of the +This work may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3 of this license +or (at your option) any later version. The latest version of this license is in - http://www.latex-project.org/lppl.txt + http://www.latex-project.org/lppl.txt -and version 1.3 or later is part of all distributions of LaTeX -version 2003/12/01 or later. +and version 1.3 or later is part of all distributions of LaTeX version +2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. +The Current Maintainer of this work is Nicolas Markey. \endpreamble \postamble @@ -27,7 +29,7 @@ version 2003/12/01 or later. {\catcode`\#=12\relax \let\olddefaultpreamble\defaultpreamble \xdef\defaultpreamble{% - #!/bin/sh^^J% + #!/bin/bash^^J% \olddefaultpreamble} } \generate{\file{bibexport.sh}{\from{bibexport.dtx}{script}}} @@ -39,31 +41,35 @@ version 2003/12/01 or later. \let\MetaPrefix\DoubleperCent \preamble -(c) 2005/02/27 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -All rights reserved. +(c) 2011/11/19 Nicolas Markey <markey at lsv dot ens-cachan dot fr> -This work may be distributed and/or modified under the conditions of -the LaTeX Project Public License, either version 1.3 of this license -or (at your option) any later version. The latest version of the +This work may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3 of this license +or (at your option) any later version. The latest version of this license is in - http://www.latex-project.org/lppl.txt + http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of LaTeX version +2005/12/01 or later. -and version 1.3 or later is part of all distributions of LaTeX -version 2003/12/01 or later. +This work has the LPPL maintenance status `maintained'. +The Current Maintainer of this work is Nicolas Markey. \endpreamble \postamble \endpostamble \generate{\file{expkeys.bst}{\from{bibexport.dtx}{expkeys}}% + \file{expcites.bst}{\from{bibexport.dtx}{expcites}}% \file{export.bst}{\from{bibexport.dtx}{export}}} %% %% %% -\Msg{** To finish the installation, put both .bst files in a } -\Msg{** place where BibTeX can find them, put the shell script} +\Msg{** To finish the installation, put all three .bst files in} +\Msg{** a place where BibTeX can find them, put the shell script} \Msg{** where your shell can find it, and make it executable.} +\Msg{** Run ``pdflatex bibexport.dtx'' to compile the documentation.} \end |