From 50c40ff41b83169b6fb7137aeba8baeeaeaa97ab Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 31 Mar 2019 21:42:07 +0000 Subject: bibexport (31mar19) git-svn-id: svn://tug.org/texlive/trunk@50677 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/bibtex/bibexport/bibexport.dtx | 107 ++++++++++++++------- .../source/bibtex/bibexport/bibexport.ins | 2 +- 2 files changed, 72 insertions(+), 37 deletions(-) (limited to 'Master/texmf-dist/source/bibtex') diff --git a/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx b/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx index 8a29a06b750..8ba3261bdcf 100644 --- a/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx +++ b/Master/texmf-dist/source/bibtex/bibexport/bibexport.dtx @@ -16,8 +16,8 @@ %%%\AtBeginDocument{\CodelineIndex\EnableCrossrefs} %%%\AtEndDocument{\PrintIndex} \begin{document} - \def\docdate{2016/03/02} - \def\fileversion{3.02} + \def\docdate{2019/03/30} + \def\fileversion{3.03} %%% Please also change date at the beginning of the script %%% %%% (VERSION and VDATE below) %%% \DocInput{bibexport.dtx} @@ -25,7 +25,7 @@ % % % \fi -% \CheckSum{41} +% \CheckSum{45} %% \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 @@ -149,7 +149,7 @@ % % \subsection{Exporting extra fields} % -% By~default, \script{bibexport.sh} exports only "standard" fields +% By~default, \script{bibexport} exports only "standard" fields % (those defined and used in \bst{plain}), as~well as a few % others. It~is very easy to modify it in order to export other fields: % it~suffices to modify \bst{export} as follows: @@ -169,8 +169,9 @@ % \end{itemize} % % \subsection*{Acknowledgements} -% I thank \'Eric Colin de Verdi\`ere, Richard Mathar, Harald Hanche-Olsen -% and Damien Pollet for suggesting several improvements or corrections. +% I thank \'Eric Colin de Verdi\`ere, Richard Mathar, Harald Hanche-Olsen, +% Damien Pollet, and Caner Kazanci for suggesting several improvements +% or corrections. % % \section{The code} % \subsection{The shell script} @@ -208,6 +209,8 @@ Basic options: -------------- -a, --all export the entire .bib files -o bib, --output-file bib write output to file [default: bibexport.bib] + -ns, --nosave overwrite output file without keeping a copy + -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 @@ -220,7 +223,6 @@ Advanced options: -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) - -p, --preamble 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; @@ -236,8 +238,8 @@ exit 0; %<*script> function opttoolate() { -if [ ${TOOLATE} -ne 0 ]; then - echo "No option is allowed after the input files"; +if [ ! -z "${TOOLATE}" ]; then + echo "No options are allowed after the input files"; exit 0; fi } @@ -259,6 +261,7 @@ fi %\begin{macro}{BST} %\begin{macro}{TERSE} %\begin{macro}{BANNER} +%\begin{macro}{NOSAVE} %\begin{macro}{ARGS} %\begin{macro}{TOOLATE} % We define the default value of some variables: @@ -280,6 +283,7 @@ fi % \item \var{BST}: the \ext{bst} file to be used; % \item \var{TERSE}: run silently; % \item \var{BANNER}: don't print the initial comment; +% \item \var{NOSAVE}: don't keep a copy if overwriting output file; % \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. @@ -288,12 +292,12 @@ fi % \begin{macrocode} %<*script> ## Version number -VERSION="3.02"; +VERSION="3.03"; ## Release date -VDATE="2016/03/02"; +VDATE="2019/03/30"; # ALL is a flag set to 1 when '-a' is given -ALL="0"; +ALL=""; # 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') @@ -304,15 +308,17 @@ EXTRA=""; EXTRABIB=""; # REPLACEBIB ('-r') is set to 1 when the \bibdata of the .aux input file # must be ignores (then '-e' must be used) -REPLACEBIB="0"; +REPLACEBIB=""; # 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=""; +# NOSAVE if no need to save file before overwriting it +NOSAVE="" # BANNER is used to turn on or off the preamble informations in the output -BANNER="false"; +BANNER=""; # CREF is the number of citations of crossrefs from which the crossref'd entry # must be included. CREF="0"; @@ -320,7 +326,7 @@ CREF="0"; # SPACE will be either ' ' or ',' SPACE=""; # TOOLATE is used to prevent extra options after the main file -TOOLATE="0"; +TOOLATE=""; # DEBUG is used to create files but not run BibTeX. DEBUG=""; @@ -344,6 +350,7 @@ ARGS=$@; %\end{macro} %\end{macro} %\end{macro} +%\end{macro} % % \subsubsection{Handling arguments} % @@ -375,7 +382,7 @@ while [ $# != 0 ]; do ## - export all entries in the input file(s) ## - the input files are BibTeX files opttoolate; - EXT=""; SPACE=""; ALL=1; + EXT=""; SPACE=""; ALL="a"; shift ;; % % \end{macrocode} @@ -405,7 +412,7 @@ while [ $# != 0 ]; do ## - debug mode: we create files but do not run bibtex ## - instead, we print what we would have done... opttoolate; - DEBUG="echo"; + DEBUG="a"; shift ;; % % \end{macrocode} @@ -420,7 +427,7 @@ while [ $# != 0 ]; do ## - 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. + ## 'file.bib.bib', to avoid complaints. opttoolate; if [ "`dirname $2`" = "." ]; then DOLLARTWO="`basename $2 .bib`"; @@ -520,7 +527,7 @@ while [ $# != 0 ]; do ## - to replace the file(s) given in \bibdata in the .aux file with ## (a) new one(s). opttoolate; - REPLACEBIB="1"; + REPLACEBIB="a"; if [ "`dirname $2`" = "." ]; then DOLLARTWO="`basename $2 .bib`"; else @@ -537,12 +544,21 @@ while [ $# != 0 ]; do echo "This is bibexport v${VERSION} (released ${VDATE})"; exit 0;; % % \end{macrocode} +%\item \verb+-ns+ or \verb+--nosave+ for not keeping a copy +% of the output file if we overwrite it: +% \begin{macrocode} +%<*script> + -ns|--nosave|--no-save) + NOSAVE="a"; + shift ;; +% +% \end{macrocode} %\item \verb+-p+ or \verb+--preamble+ for inserting some informations % at the beginning of the output file: % \begin{macrocode} %<*script> -p|--preamble|--with-preamble) - BANNER="true"; + BANNER="a"; shift ;; % % \end{macrocode} @@ -568,17 +584,17 @@ while [ $# != 0 ]; do *) ## - list of input files ## - we ensure that no extra option is given later... - TOOLATE="1"; + TOOLATE="a"; 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 + if [ -z "${ALL}" ]; then SPACE=" "; + else + SPACE=","; fi; shift;; % @@ -640,11 +656,11 @@ EOF EOF fi else ## we only export entries listed in the given .aux file: - if [ ! "x${REPLACEBIB}" = "x1" ]; then + if [ -z "${REPLACEBIB}" ]; 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; + -e "s|bibdata{.*}|bibdata{${EXTRA}${NEWBIB%,}${EXTRABIB}}|" > ${TMPFILE}.aux; fi fi % @@ -657,14 +673,18 @@ fi %<*script> if [ -z "$DEBUG" ]; then bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE}; - if [ -e ${FINALFILE} ]; then + if [ -e ${FINALFILE} ] && [ -z "${NOSAVE}" ]; then mv ${FINALFILE} ${FINALFILE}-save-`date "+%Y.%m.%d:%H.%M.%S"` fi echo "" > ${FINALFILE} else echo "bibtex -min-crossrefs=${CREF} ${TERSE} ${TMPFILE};" + if [ -e ${FINALFILE} ] && [ -z "${NOSAVE}" ]; then + echo "mv ${FINALFILE} ${FINALFILE}-save-`date \"+%Y.%m.%d:%H.%M.%S\"`" + fi + echo "echo \"\" > ${FINALFILE}" fi -if [ ! "${BANNER}" = "false" ]; then +if [ ! -z "${BANNER}" ]; then ## list of cited entries if [ -z "$DEBUG" ]; then sed -i -e "s/\\\bibstyle{.*}/\\\bibstyle{expcites}/" ${TMPFILE}.aux @@ -677,8 +697,8 @@ if [ ! "${BANNER}" = "false" ]; 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}; + #echo -ne " bibexport-version:\tv${VERSION} (${VDATE})\n" >> ${FINALFILE}; + #echo -ne " bibexport-maintainer:\tNicolas Markey \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 @@ -807,7 +827,7 @@ FUNCTION{or} %<*expcites> INTEGERS{left.length right.length} STRINGS{ s t } -INTEGERS{bool} +INTEGERS{bool cpt} FUNCTION{space.complete} { 'left.length := @@ -854,6 +874,7 @@ FUNCTION{split.string} %\begin{macro}{init.cited.keys} %\begin{macro}{write.cited.keys} %\begin{macro}{write.cited.keys.last} +%\begin{macro}{write.nbkeys} %\begin{macro}{cited.keys} %\begin{macro}{end.cited.keys} % \begin{macrocode} @@ -862,12 +883,13 @@ FUNCTION{init.cited.keys} { left.delim 's := #0 'bool := + #0 'cpt := } FUNCTION{write.cited.keys} { bool {"" left.width space.complete swap$} - {" cited keys: " left.width space.complete swap$ + {" list of keys: " left.width space.complete swap$ #1 'bool :=} if$ {duplicate$ text.length$ right.width >} @@ -884,14 +906,14 @@ FUNCTION{write.cited.keys.last} { bool {"" left.width space.complete swap$} - {" cited keys: " left.width space.complete swap$ + {" list of 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 * + right.delim * "," * {duplicate$ "" = not} { right.width split.string 't := @@ -902,8 +924,15 @@ FUNCTION{write.cited.keys.last} while$ pop$ pop$ } +FUNCTION{write.nbkeys} +{ + " number of entries: " left.width space.complete + " " * + cpt int.to.str$ * "," * write$ newline$ +} FUNCTION{cited.keys} { + cpt #1 + 'cpt := s cite$ ", " * * 's := s text.length$ #4000 > {s write.cited.keys 's :=} @@ -913,6 +942,7 @@ FUNCTION{cited.keys} FUNCTION{end.cited.keys} { s write.cited.keys.last + write.nbkeys } % % \end{macrocode} @@ -921,6 +951,7 @@ FUNCTION{end.cited.keys} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \subsubsection{Now, we export...} % @@ -1013,16 +1044,18 @@ ENTRY{ type volume year -% Special (but still somewhat standard) fields (natbib, germbib, ...): +% Special (but still somewhat standard) fields (natbib, germbib, DBLP, ...): abstract acronym annote biburl + bibsource doi eid isbn issn language + timestamp url urn }{}{} @@ -1414,11 +1447,13 @@ FUNCTION{entry.export.extra} "acronym" acronym field.export "annote" annote field.export "biburl" biburl url.export + "bibsource" bibsource field.export "doi" doi field.export "eid" eid field.export "isbn" isbn field.export "issn" issn field.export "language" language field.export + "timestamp" timestamp field.export "url" url url.export "urn" urn url.export } @@ -1477,7 +1512,7 @@ FUNCTION{header} { %"** This file has been automatically generated by bibexport **" %write$ newline$ -%"** See http://www.lsv.ens-cachan.fr/~markey/bibla.php **" +%"** See http://people.irisa.fr/Nicolas.Markey/latex.php **" %write$ newline$ %"** for more informations about bibexport. **" %write$ newline$ diff --git a/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins b/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins index a29005d0d10..507dd87c07f 100644 --- a/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins +++ b/Master/texmf-dist/source/bibtex/bibexport/bibexport.ins @@ -1,6 +1,6 @@ %\NeedsTeXFormat{LaTeX2e}[1996/12/01] \input docstrip -\def\filedate{2016/03/02} +\def\filedate{2019/03/30} {\catcode`\#=12 \gdef\DoubleSharp{##} -- cgit v1.2.3