diff options
author | Karl Berry <karl@freefriends.org> | 2016-03-21 20:40:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-03-21 20:40:11 +0000 |
commit | 3e3758af644dc10891585599e86c2c1b78f83167 (patch) | |
tree | 44fe41ae74830bd07f4c3eda753088c14d57dcbc /Master/texmf-dist/source/latex/bibarts | |
parent | d97bf0fe1bbb340b51521ff231090de76e65e700 (diff) |
bibarts (21mar16)
git-svn-id: svn://tug.org/texlive/trunk@40096 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bibarts')
-rw-r--r-- | Master/texmf-dist/source/latex/bibarts/bibsort.c | 782 |
1 files changed, 586 insertions, 196 deletions
diff --git a/Master/texmf-dist/source/latex/bibarts/bibsort.c b/Master/texmf-dist/source/latex/bibarts/bibsort.c index bc606324e6e..98c95363c50 100644 --- a/Master/texmf-dist/source/latex/bibarts/bibsort.c +++ b/Master/texmf-dist/source/latex/bibarts/bibsort.c @@ -1,6 +1,5 @@ -/* BibArts 2.0 assists you to write LaTeX texts in arts and humanities. */ -/* This file BIBSORT.C, and BIBARTS.STY, are parts of BibArts 2.0. */ -/* Copyright (C) 2015 Timo Baumann bibarts[at]gmx.de (11-29-2015) */ +/* BibArts 2.1 assists you to write LaTeX texts in arts and humanities. */ +/* Copyright (C) 2016 Timo Baumann bibarts[at]gmx.de (2016/03/19) */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -17,24 +16,38 @@ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* The C-compiled binary of this file should now read LaTeX .AUX files. */ -/* It will not read .BAR files of BibArts versions 1.x. BIBARTS.STY in */ -/* Version 2.0 ONLY has an EMULATION for 1.3 texts: Keep copies of 1.x? */ - -/* Do not write into this file when you do not have a qualified text */ -/* editor - it contains control chars: '', '', '', '', | Are the */ -/* '', '', '', '', '', '', '', '', '', '', '', | |'s in */ -/* '', '', '', '', '', '', '', '', '', and ''. | a line? */ +/* + FILES OF THE PACKAGE AND DOCUMENTATION + CTAN mirrors > BibArts > bibarts.zip + bibarts.sty LaTeX style file + ba-short.pdf Short documentation (English) + ba-short.tex Source of ba-short.pdf + bibarts.pdf Full documentation (German) + bibarts.tex Source of bibarts.pdf + bibsort.exe Binary to create the lists + bibsort.c This file; source of bibsort.exe + COPYING The license of the package + */ /* -I have tested BIBSORT.C with several C compilers. I had problems with -the DEVCPP.EXE editor (Dev-Cpp_5.4.0_TDM-GCC_x64_4.7.1). Sucessful was: -"C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe" -O2 -c bibsort.c -o bibsort.o -"C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe" bibsort.o -o bibsort.exe -*/ + COMPATIBILITY + I have tested bibsort.c with several C compilers. I had problems with + the devcpp.exe EDITOR (Dev-Cpp_5.4.0_TDM-GCC_x64_4.7.1). Sucessful was: + "C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe" -O2 -c bibsort.c -o bibsort.o + "C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe" bibsort.o -o bibsort.exe + + Do NOT change this file when you do not have a qualified text + editor - it contains control chars: '', '', '', '', | Are the + '', '', '', '', '', '', '', '', '', '', '', | |'s in + '', '', '', '', '', '', '', '', '', and ''. | a line? + + The C-compiled binary of this file is reading LaTeX .aux files. + It can NOT read the .bar files, which BibArts did use before 2.0. + BibArts 2.1 ONLY has an EMULATION for 1.3 texts: Keep copies of 1.x? + */ @@ -53,7 +66,16 @@ the DEVCPP.EXE editor (Dev-Cpp_5.4.0_TDM-GCC_x64_4.7.1). Sucessful was: #define MAXFILES 128 #define MAXFILENAMLEN 256 -#define LEVE_OPEN 1 +#define AUX_SUFFIX ".aux" +#define VLI_SUFFIX ".vli" +#define VQU_SUFFIX ".vqu" +#define VKC_SUFFIX ".vkc" +#define ABK_SUFFIX ".abk" +#define PER_SUFFIX ".per" +#define ARQ_SUFFIX ".arq" +#define GRR_SUFFIX ".grr" +#define PRR_SUFFIX ".prr" +#define SRR_SUFFIX ".srr" #define IKILLNAME "\\Ikillname{}" /* -K: Damit wird ARG1 und ARG2 einer */ /* Zeile ersetzt, falls diese in der */ @@ -89,6 +111,7 @@ the DEVCPP.EXE editor (Dev-Cpp_5.4.0_TDM-GCC_x64_4.7.1). Sucessful was: #define NUMLEN 16 int ignorespaces = 0; + int kill = NOKILLAUTHORS; int registpoints = 0; char *lineptr[MAXLINES]; @@ -162,6 +185,7 @@ const char bareststr[] = "{}{}[][]()"; #define LINECOL 4 #define OLDBIGROMAN "\\uppercase" #define NEWFNSYMBOL "\\ensuremath" +#define TOMFNSYMBOL "\\TextOrMath" #define TEXFILELINE "\\line@ba" #define BALOOPSPACE "\\ " @@ -189,9 +213,22 @@ int german = 0; int nogsty = 0; int encode = 0; int EinlROEMseiten = 0; +#define BA_FALSE 0 +#define BA_TRUE 1 + int get_R_pg = BA_FALSE; + int get_A_pg = BA_FALSE; + int get_r_pg = BA_FALSE; + int get_a_pg = BA_FALSE; int ALPHmpfootnotes = 0; + int get_R_fn = BA_FALSE; + int get_A_fn = BA_FALSE; + int get_r_fn = BA_FALSE; + int get_a_fn = BA_FALSE; int igleichj = 0; +char *soptarg = NULL; +char *foptarg = NULL; + void print_two(int line, int left, int right); char *mydefault = ""; @@ -232,12 +269,31 @@ char *strnmalloc(const char *q, int len) /*--------------------------------------------------------------------------*/ +char *getmyname(char *p, int max) +{ + char *m = p; + int pos = strlen(p); + + if (pos > max) + while(*p != '\0') + { + if (*p == '/' || *p == '\\') + { + m = p+1; + if (pos <= max) break; + } + ++p; --pos; + } + return m; +} + + void licenseinfo(void) { - printf("%%%% I guess that I am a bin-compilation of BIBSORT.C. My job is to read\n"); - printf("%%%% entries in LaTeX .AUX files which are made by BIBARTS.STY. Use e.g.\n"); + printf("%%%% I guess that I am a bin-compilation of bibsort.c. My job is to read\n"); + printf("%%%% entries in LaTeX %s files which are made by bibarts.sty. Use e.g.\n", AUX_SUFFIX); printf("%%%% \\vli{FirstName}{FamilyName}{BookTitle, Year} and \\printvli in your\n"); - printf("%%%% .TEX file. For usage, see BA-SHORT.PDF (engl) or BIBARTS.PDF (ger).\n"); + printf("%%%% .tex file. For usage, see ba-short.pdf (engl) or bibarts.pdf (ger).\n"); printf("%%%%\n"); printf("%%%% This program is free software; you can redistribute it and/or modify\n"); printf("%%%% it under the terms of the GNU General Public License as published by\n"); @@ -258,47 +314,47 @@ void licenseinfo(void) void moreinfo(void) { - printf("%%%% The \\printnum... cmds in your LaTeX file will print your entrys with\n"); - printf("%%%% page and footnote numbers (where they\'re used) as index: 2-5, 7$^{2}$.\n"); - printf("%%%% I provide the page and footnote numbers ALWAYS in the following order:\n"); - printf("%%%% - fnsymbol - roman - arabic - letter (z=26, aa=27, ab=28) - TEXT\n"); - printf("%%%% Default: *small roman page numbers* are page numbers of introduction;\n"); - printf("%%%% *capital letter page numbers* are page numbers of appendix;\n"); - printf("%%%% *small letter footnote marks* are footnote marks in minipages.\n"); - printf("%%%% Numbers, which I cound not evaluate, are typed %sTEXT%s.\n", TEXTSYMBOPEN[0], TEXTSYMBCLOSE[0]); - printf("%%%%\n"); - printf("%%%% BIBSORT <LaTeXFile> [<OutFile>] [-s1] [-f1] [-c] [-t1] [-i=j] [-m]\n"); - printf("%%%%\n"); - printf("%%%% -s1 Page numbers: EVALUATE capital roman nums before capital letters.\n"); - printf("%%%% -f1 Footnote marks: EVALUATE small roman nums before small letters.\n"); - printf("%%%% -c I type TEXT numbers as %sTEXT%s.\n", TEXTSYMBOPEN[1], TEXTSYMBCLOSE[1]); - printf("%%%% -t1 You use [T1]{fontenc} and NO [...]{inputenc}: I sort ASCIIs > 127\n"); - printf("%%%% (default: I do not expect ASCIIs > 127 in your .AUX file).\n"); - printf("%%%% -i=j I sort \'i\' as \'j\' (prussian instructions).\n"); - printf("%%%% -m Write into files the meta args which I use to sort your lines.\n"); + printf("%%%% -i=j Sorting of entries: I sort \'i\' as \'j\' (Prussian instructions).\n"); + printf("%%%% -t1 You use [T1]{fontenc} and NO [...]{inputenc}: I sort ASCIIs > 127.\n"); + printf("%%%% -m Write into files the meta arguments which I use to sort lines.\n"); + printf("%%%% \\printnumvkc etc. print your lists with an INDEX TO PAGES/FOOTNOTES:\n"); + printf("%%%% On default, OR with -s1 or -f1, I sort page and footnote numbers ALWAYS:\n"); + printf("%%%% * fnsymbol ** r/Roman * arabic ** a/Alph (z=26, aa=27, ab=28) * TEXT\n"); + printf("%%%% DEFAULT: *lower roman page numbers* are page numbers of introduction;\n"); + printf("%%%% *capital Alph page numbers* are page numbers of appendix;\n"); + printf("%%%% *lower alph footnote numbers* are footnote marks of minipages.\n"); + printf("%%%% Numbers, which I could not evaluate, are typed %sTEXT%s.\n", TEXTSYMBOPEN[0], TEXTSYMBCLOSE[0]); + printf("%%%% -s1 Page style: EVALUATE capital Roman numbers before capital Alphs.\n"); + printf("%%%% -f1 Footnote style: EVALUATE lower roman numbers before lower alphs.\n"); + printf("%%%% NON-DEFAULT sorting order (with an evaluation affixed to that order):\n"); + printf("%%%% -s2 xxxx Page number style: -f2 xxxx Footnote mark style:\n"); + printf("%%%% xxxx is a permutation of 4 letters out of nRrAas in your order\n"); + printf("%%%% (a=alph, A=Alph, n=arabic, R=Roman, r=roman, s=fnsymbol);\n"); + printf("%%%% in xxxx, you (still) have to use n, s, R *or* A, and r *or* a.\n"); + printf("%%%% -c Numbers, which I could not evaluate, are typed %sTEXT%s.\n", TEXTSYMBOPEN[1], TEXTSYMBCLOSE[1]); printf("%%%%\n"); } -void info(void) +void maininfo(char *myname) { - printf("%%%% I read a LaTeX .AUX file (follow \\@input), and I write my output in files\n"); - printf("%%%% .VLI literature .VQU published sources .GRR geographic index\n"); - printf("%%%% .VKC short titles .ARQ unpublished sources .PRR person index\n"); - printf("%%%% .PER periodicals .ABK abbreviations .SRR subject index\n"); + printf("%%%% I read a LaTeX %s file (follow \\@input), and I write my output in files\n", AUX_SUFFIX); + printf("%%%% %s Literature %s Published sources %s Geographic index\n", VLI_SUFFIX, VQU_SUFFIX, GRR_SUFFIX); + printf("%%%% %s Short titles %s Unpublished sources %s Person index\n", VKC_SUFFIX, ARQ_SUFFIX, PRR_SUFFIX); + printf("%%%% %s Periodicals %s Abbreviations %s Subject index\n", PER_SUFFIX, ABK_SUFFIX, SRR_SUFFIX); printf("%%%%\n"); - printf("%%%% BIBSORT <LaTeXFile> [<OutFile>] [-g1/2] [-x] [-l] [-p] [-k] [-d]\n"); + printf("%%%% %s <LaTeXFile> [-o <OutFile>] [-g1/-g2] [-x] [-l] [-p] [-k] [-d]\n", getmyname(myname, 13)); printf("%%%%\n"); printf("%%%% DefaultSort: 0, .., 9, (A a), (B b), .., (s \\ss S), .., (Z z) and\n"); /* udtable */ printf("%%%% (a [\\.\\'\\`\\^\\\"\\=\\~]a \\aa=\\r{a} [\\b\\c\\k\\d\\H\\t\\u\\v]{a} \\ae), b, ..\n"); printf("%%%% -g1/2 GermanSort: (a A), .., (z Z), 0, .., 9; and (\\\" or active \"):\n"); printf("%%%% -g1 GermanTelefonebookStyle: \"a = \\\"a = ae, ..., \"s = \\ss = ss;\n"); /* gweight */ printf("%%%% -g2 ModernGermanDictionary: \"a = \\\"a = a, ..., \"s = \\ss = ss.\n"); /* mweight */ - printf("%%%% -x DoNotExpectGERMAN.STY: Active \"-characters do NOT produce umlauts.\n"); - printf("%%%% -l IgnoreSpaces. -p Point: Sort \"P.S.\" before \"Peter\".\n"); - printf("%%%% -k Kill: Idemize multiple used authors on list of literature.\n"); - printf("%%%% -d Dos: Use '\\' instead of '/' in path(s) of include-files.\n"); - printf("%%%% -\?\? More options: -s1 -f1 -c -t1 -i=j -m\n"); + printf("%%%% -x DoNotExpectgerman.sty: Active \"-characters do NOT produce umlauts.\n"); + printf("%%%% -l Ignore spaces (leer). -p Sort \"P.S.\" before \"Peter\" (point).\n"); + printf("%%%% -k Idemize multiple used authors in the %s and %s lists (kill).\n", VLI_SUFFIX, VQU_SUFFIX); + printf("%%%% -d Change your '/' with '\\' in paths on my %s files task list (dos).\n", AUX_SUFFIX); + printf("%%%% -\?\? Read about options: -s1 -f1 -s2 xxxx -f2 xxxx -c -t1 -i=j -m\n"); printf("%%%% -r Read informations about my license and documentation files.\n"); printf("%%%%\n"); } @@ -307,6 +363,25 @@ void info(void) /*--------------------------------------------------------------------------*/ +int nextbracket(const char *p, const char opench, const char closech) +{ + int c = 0, r = 0; + + while (*p != '\0') + { + if (*p == '\\' && *(p+1) != '\0') { ++p; ++r; } + else if (*p == opench) ++c; + else if (*p == closech) --c; + ++p; ++r; + if (c == 0) break; + } + + if (c != 0) r = -r; + + return r; +} + + int artithmetic_overflow(const char *cc) { printf("%%%%\n%%%%> Warning: Arithmetic overflow num=%s.\n", cc); @@ -475,6 +550,18 @@ int endnumberline(const char *p, int r) /* "\ensuremath {\dagger \dagger }" */ /* 8 */ /* "\ensuremath {\ddagger \ddagger }" */ /* 9 */ +/* NOCH NEUER */ +/* \TextOrMath {\textasteriskcentered }{*} */ /* 1 */ +/* \TextOrMath {\textdagger }{\dagger } */ /* 2 */ +/* \TextOrMath {\textdaggerdbl }{\ddagger } */ /* 3 */ +/* \TextOrMath {\textsection }{\mathsection } */ /* 4 */ +/* \TextOrMath {\textparagraph }{\mathparagraph } */ /* 5 */ +/* \TextOrMath {\textbardbl }{\delimiter "026B30D } */ /* 6 */ +/* \TextOrMath {\textasteriskcentered \textasteriskcentered }{**} */ /* 7 */ +/* \TextOrMath {\textdagger \textdagger }{\dagger \dagger } */ /* 8 */ +/* \TextOrMath {\textdaggerdbl \textdaggerdbl }{\ddagger \ddagger } */ /* 9 */ + + int nextsymbolnum(int oldnum, int beginnum) { @@ -483,13 +570,46 @@ int nextsymbolnum(int oldnum, int beginnum) } -int evalsymbol(const char *p, const int job) +int len_tom(const char *p) +{ + int len, r = 0; + + if (lcmdcmp(p, TOMFNSYMBOL) == 0) + { + p += (r=strlen(TOMFNSYMBOL)); + + while (*p == ' ') { ++p; ++r; } + + if (*p == '{') + { + /* erstes Arg von NOCH NEUER */ + len = nextbracket(p, '{', '}'); + if (len > 1) + { r += len; + } + else r = 0; + } + else r = 0; + } + + return r; +} + + +int evalsymbol(int pg, const char *p, const int job) { int r = BADNUM, num = 0, len, cmdtyp = 0, cmd = 0, vor = 1; const char *mem; while (*p == ' ') ++p; - if (lcmdcmp(p, NEWFNSYMBOL) == 0) p += strlen(NEWFNSYMBOL); + + if (pg == 1) + { + if (lcmdcmp(p, NEWFNSYMBOL) == 0) + p += strlen(NEWFNSYMBOL); + else p += len_tom(p); + } + while (*p == ' ') ++p; if (*p == '{') ++p; mem = p; @@ -780,12 +900,14 @@ int isinstr(const char *p, const char *s) #define UNUSED 1 /* muss anfuehren (kleinster Wert)! */ #define NOFOOTNOTE 2 #define EMPTYNUM 3 /* Alph, alph, Roman, roman, symbol < 1 */ -#define SYMBOL 4 -#define SMALLROMAN 5 -#define BIGROMAN 6 -#define ARABIC 7 -#define SMALLLETTER 8 -#define BIGLETTER 9 +#define BEGINWEIGHT 4 +int pg_symbol = 4, fn_symbol = 4; +int pg_smallroman = 5, fn_smallroman = 5; +int pg_bigroman = 6, fn_bigroman = 6; +int pg_arabic = 7, fn_arabic = 7; +int pg_smallletter = 8, fn_smallletter = 8; +int pg_bigletter = 9, fn_bigletter = 9; +#define ENDWEIGHT 10 #define TEXT 10 #define MISSNUM 11 /* Beschaedigte Zeile */ #define OVERFLOW 12 @@ -795,6 +917,26 @@ int pgnumberweight(const char *p) int r = INTERNALERR; /* primaer i, ii, ..., 1, 2, ..., A, B, *C*, ... */ + if ( get_R_pg == BA_TRUE + || get_A_pg == BA_TRUE + || get_a_pg == BA_TRUE + || get_r_pg == BA_TRUE + ) + { + if (p == unused) r = UNUSED; + else if (p == mydefault) r = MISSNUM; + else if (p == nofnt) r = INTERNALERR; + else if (*p == '\0') r = EMPTYNUM; + else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic; + else if (get_R_pg == BA_TRUE && evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman; + else if (get_A_pg == BA_TRUE && evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter; + else if (get_a_pg == BA_TRUE && evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter; + else if (get_r_pg == BA_TRUE && evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman; + else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol; + else r = TEXT; + } + else if (EinlROEMseiten == 1) { if (p == unused) r = UNUSED; @@ -802,12 +944,12 @@ int pgnumberweight(const char *p) else if (p == nofnt) r = INTERNALERR; else if (*p == '\0') r = EMPTYNUM; else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; - else if (evalarabic(p, CHECKNUM) == GOODNUM) r = ARABIC; - else if (evalRoman (p, CHECKNUM) == GOODNUM) r = BIGROMAN; - else if (evalLetter(p, CHECKNUM) == GOODNUM) r = BIGLETTER; - else if (evalletter(p, CHECKNUM) == GOODNUM) r = SMALLLETTER; - else if (evalroman (p, CHECKNUM) == GOODNUM) r = SMALLROMAN; - else if (evalsymbol(p, CHECKNUM) == GOODNUM) r = SYMBOL; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic; + else if (evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman; + else if (evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter; + else if (evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter; + else if (evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman; + else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol; else r = TEXT; } else @@ -817,17 +959,17 @@ int pgnumberweight(const char *p) else if (p == nofnt) r = INTERNALERR; else if (*p == '\0') r = EMPTYNUM; else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; - else if (evalarabic(p, CHECKNUM) == GOODNUM) r = ARABIC; - else if (evalroman (p, CHECKNUM) == GOODNUM) r = SMALLROMAN; - else if (evalletter(p, CHECKNUM) == GOODNUM) r = SMALLLETTER; - else if (evalLetter(p, CHECKNUM) == GOODNUM) r = BIGLETTER; - else if (evalRoman (p, CHECKNUM) == GOODNUM) r = BIGROMAN; - else if (evalsymbol(p, CHECKNUM) == GOODNUM) r = SYMBOL; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic; + else if (evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman; + else if (evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter; + else if (evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter; + else if (evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman; + else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol; else r = TEXT; } - /* OLDBIGROMAN + " {}" */ - if (r == BIGROMAN && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM; + /* OLDBIGROMAN + " {}" */ + if (r == pg_bigroman && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM; return r; } @@ -838,6 +980,26 @@ int fntnumberweight(const char *p) int r = INTERNALERR; /* primaer I, II, ..., 1, 2, ..., a, b, *c*, ... */ + if ( get_R_fn == BA_TRUE + || get_A_fn == BA_TRUE + || get_a_fn == BA_TRUE + || get_r_fn == BA_TRUE + ) + { + if (p == mydefault) r = MISSNUM; + else if (p == nofnt) r = NOFOOTNOTE; + else if (p == unused) r = INTERNALERR; + else if (*p == '\0') r = EMPTYNUM; + else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic; + else if (get_r_fn == BA_TRUE && evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman; + else if (get_a_fn == BA_TRUE && evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter; + else if (get_A_fn == BA_TRUE && evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter; + else if (get_R_fn == BA_TRUE && evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman; + else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol; + else r = TEXT; + } + else if (ALPHmpfootnotes == 1) { if (p == mydefault) r = MISSNUM; @@ -845,12 +1007,12 @@ int fntnumberweight(const char *p) else if (p == unused) r = INTERNALERR; else if (*p == '\0') r = EMPTYNUM; else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; - else if (evalarabic(p, CHECKNUM) == GOODNUM) r = ARABIC; - else if (evalroman (p, CHECKNUM) == GOODNUM) r = SMALLROMAN; - else if (evalletter(p, CHECKNUM) == GOODNUM) r = SMALLLETTER; - else if (evalLetter(p, CHECKNUM) == GOODNUM) r = BIGLETTER; - else if (evalRoman (p, CHECKNUM) == GOODNUM) r = BIGROMAN; - else if (evalsymbol(p, CHECKNUM) == GOODNUM) r = SYMBOL; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic; + else if (evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman; + else if (evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter; + else if (evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter; + else if (evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman; + else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol; else r = TEXT; } else @@ -860,18 +1022,17 @@ int fntnumberweight(const char *p) else if (p == unused) r = INTERNALERR; else if (*p == '\0') r = EMPTYNUM; else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW; - else if (evalarabic(p, CHECKNUM) == GOODNUM) r = ARABIC; - else if (evalRoman (p, CHECKNUM) == GOODNUM) r = BIGROMAN; - else if (evalLetter(p, CHECKNUM) == GOODNUM) r = BIGLETTER; - else if (evalletter(p, CHECKNUM) == GOODNUM) r = SMALLLETTER; - else if (evalroman (p, CHECKNUM) == GOODNUM) r = SMALLROMAN; - else if (evalsymbol(p, CHECKNUM) == GOODNUM) r = SYMBOL; + else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic; + else if (evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman; + else if (evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter; + else if (evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter; + else if (evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman; + else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol; else r = TEXT; } /* OLDBIGROMAN + " {}" */ - if (r == BIGROMAN && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM; - + if (r == fn_bigroman && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM; return r; } @@ -1114,19 +1275,25 @@ int igspstrcmp(const char *p, const char *q) } -int numcmp(const int w, const char *p, const char *q) +int numcmp(const int pg, const int w, const char *p, const char *q) { - int j; + int j = 0; if (w == EMPTYNUM) j = 0; else if (w == NOFOOTNOTE) j = 0; else if (w == UNUSED) j = 0; - else if (w == SMALLROMAN) j = evalroman (p, ANALYZENUM) - evalroman (q, ANALYZENUM); - else if (w == BIGROMAN) j = evalRoman (p, ANALYZENUM) - evalRoman (q, ANALYZENUM); - else if (w == ARABIC) j = evalarabic(p, ANALYZENUM) - evalarabic(q, ANALYZENUM); - else if (w == SMALLLETTER) j = evalletter(p, ANALYZENUM) - evalletter(q, ANALYZENUM); - else if (w == BIGLETTER) j = evalLetter(p, ANALYZENUM) - evalLetter(q, ANALYZENUM); - else if (w == SYMBOL) j = evalsymbol(p, ANALYZENUM) - evalsymbol(q, ANALYZENUM); + else if (pg == 1 && w == pg_smallroman) j = evalroman (p, ANALYZENUM) - evalroman (q, ANALYZENUM); + else if (pg == 0 && w == fn_smallroman) j = evalroman (p, ANALYZENUM) - evalroman (q, ANALYZENUM); + else if (pg == 1 && w == pg_bigroman) j = evalRoman (p, ANALYZENUM) - evalRoman (q, ANALYZENUM); + else if (pg == 0 && w == fn_bigroman) j = evalRoman (p, ANALYZENUM) - evalRoman (q, ANALYZENUM); + else if (pg == 1 && w == pg_arabic) j = evalarabic(p, ANALYZENUM) - evalarabic(q, ANALYZENUM); + else if (pg == 0 && w == fn_arabic) j = evalarabic(p, ANALYZENUM) - evalarabic(q, ANALYZENUM); + else if (pg == 1 && w == pg_smallletter) j = evalletter(p, ANALYZENUM) - evalletter(q, ANALYZENUM); + else if (pg == 0 && w == fn_smallletter) j = evalletter(p, ANALYZENUM) - evalletter(q, ANALYZENUM); + else if (pg == 1 && w == pg_bigletter) j = evalLetter(p, ANALYZENUM) - evalLetter(q, ANALYZENUM); + else if (pg == 0 && w == fn_bigletter) j = evalLetter(p, ANALYZENUM) - evalLetter(q, ANALYZENUM); + else if (pg == 1 && w == pg_symbol) j = evalsymbol(1, p, ANALYZENUM) - evalsymbol(1, q, ANALYZENUM); + else if (pg == 0 && w == fn_symbol) j = evalsymbol(0, p, ANALYZENUM) - evalsymbol(0, q, ANALYZENUM); else if (w == TEXT) j = igspstrcmp(p, q); else if (w == MISSNUM) j = 0; else if (w == OVERFLOW) j = 0; @@ -1169,13 +1336,13 @@ void QQsort(int left, int right, const int deep, const int deepsort) j = pagewgt[i] - pagewgt[left]; if (j == 0) /* pagewgt[i] == pagewgt[left] */ - j = numcmp(pagewgt[i], subRptr[PAGECOL][i], subRptr[PAGECOL][left]); + j = numcmp(1, pagewgt[i], subRptr[PAGECOL][i], subRptr[PAGECOL][left]); if (j == 0) j = fntwgt[i] - fntwgt[left]; if (j == 0) /* fntwgt[i] == fntwgt[left] */ - j = numcmp( fntwgt[i], subRptr[FNTCOL][i], subRptr[FNTCOL][left]); + j = numcmp(0, fntwgt[i], subRptr[FNTCOL][i], subRptr[FNTCOL][left]); if (j == 0) j = firstoverlettergan(subRptr[LINECOL][i]) - firstoverlettergan(subRptr[LINECOL][left]); @@ -1322,25 +1489,6 @@ int ignFRONTSPACESgetline(char s[], int lim) /*--------------------------------------------------------------------------*/ -int nextbracket(const char *p, const char opench, const char closech) -{ - int c = 0, r = 0; - - while (*p != '\0') - { - if (*p == '\\' && *(p+1) != '\0') { ++p; ++r; } - else if (*p == opench) ++c; - else if (*p == closech) --c; - ++p; ++r; - if (c == 0) break; - } - - if (c != 0) r = -r; - - return r; -} - - void loesche_arg(char *s, char *p, const char *com, const int comlen, const char op, const char cl) { int len; @@ -1531,10 +1679,16 @@ char *setptrtofirstbracket(char *p) void ignoreadditionaltext(const char *p, const char *i, const char *f) { + int ll; + while(*p == ' ') ++p; if (*p != '\0' && *p != '%') - { printf("%%%%\n%%%%> Warning: Ignore additional text \"%.*s\"\n", 40, p); - printf("%%%% after \"%s\" -> \"%.*s\".\n", i, 58-strlen(i), f); + { + if (strlen(i) > 58) + ll = 0; + else ll = 58 - strlen(i); + printf("%%%%\n%%%%> Warning: Ignore additional text \"%.*s\"\n", 40, p); + printf("%%%% after \"%s\" -> \"%.*s\".\n", i, ll, f); if (*p == '\\') printf("%%%% ** I grap only one \\cmd per line! Fix that, and start me again! **\n"); } @@ -1608,8 +1762,8 @@ int over_fonts(char *p, int start) const char *fonts[] = { - NEWFNSYMBOL, /* start == 0 */ - "\\rmfamily", /* start == 1 */ + NEWFNSYMBOL, /* start == 0 : footnote = $^{x}$ */ + "\\rmfamily", /* start == 1 : else = text mode */ "\\sffamily", "\\ttfamily", "\\mdseries", @@ -1660,7 +1814,9 @@ int over_fonts(char *p, int start) i = start; l = 0; while (i < FONTC && lcmdcmp(p, fonts[i]) != 0) ++i; - if (i < FONTC && lcmdcmp(p, fonts[i]) == 0 && (l=strlen(fonts[i])) > 0) + if( (i < FONTC && lcmdcmp(p, fonts[i]) == 0 && (l=strlen(fonts[i])) > 0) + || (start == 0 && (l=len_tom(p)) > 0) + ) { p+=l; neu+=l; @@ -1678,7 +1834,8 @@ void set_inner_number_on_subRptr(char *p, int len, int col, int line, int start) { int neu; - neu = over_fonts(p, start); /* start==0: $^{\ensuremath {f}}$ unnoetig */ + /* start==0: in $^{x}$ kein \ensuremath oder \TextOrMath noetig! */ + neu = over_fonts(p, start); len -= neu; p += neu; @@ -1772,7 +1929,7 @@ void getbrackets(int linec, int alllines, const char *ident, int deep, int filen } if (*(p+1) != '}' && *(p+1) != HASFNTCH && *(p+1) != HASUNUCH) { printf("%%%%\n%%%%> %s warning (part 3 of arg %d):\n", ident, deep+2); - printf("%%%% Get no {} or {%c} or {%s}!\n", HASFNTCH, HASUNUCH); + printf("%%%% Get no {} or {%c} or {%c}!\n", HASFNTCH, HASUNUCH); } p += len; while (*p == ' ') ++p; @@ -1897,23 +2054,33 @@ const char *weighttable[][2] = { { "\\textwon\t", "W" }, /* | */ { "\\textyen\t", "Y" }, /* / */ { "\\alpha\t", "a" }, /* 28 */ + { "\\Alpha\t", "A" }, /* bibarts.sty; new in 2.1 */ { "\\beta\t", "b" }, + { "\\Beta\t", "B" }, /* bibarts.sty; new in 2.1 */ { "\\chi\t", "ch" }, + { "\\Chi\t", "Ch" }, /* bibarts.sty; new in 2.1 */ { "\\delta\t", "d" }, { "\\Delta\t", "D" }, { "\\epsilon\t", "e" }, + { "\\Epsilon\t", "E" }, /* bibarts.sty; new in 2.1 */ { "\\varepsilon\t", "e" }, /* 29 */ { "\\eta\t", "e" }, /* 30 */ + { "\\Eta\t", "E" }, /* bibarts.sty; new in 2.1 */ { "\\gamma\t", "g" }, { "\\Gamma\t", "G" }, { "\\iota\t", "i" }, + { "\\Iota\t", "I" }, /* bibarts.sty; new in 2.1 */ { "\\kappa\t", "k" }, + { "\\Kappa\t", "K" }, /* bibarts.sty; new in 2.1 */ { "\\varkappa\t", "k" }, { "\\lambda\t", "l" }, { "\\Lambda\t", "L" }, { "\\mu\t", "m" }, + { "\\Mu\t", "M" }, /* bibarts.sty; new in 2.1 */ { "\\nu\t", "n" }, - { "\\omicron\t", "o" }, /* existiert in *LaTeX* nicht */ + { "\\Nu\t", "N" }, /* bibarts.sty; new in 2.1 */ + { "\\omicron\t", "o" }, /* bibarts.sty */ + { "\\Omicron\t", "O" }, /* bibarts.sty; new in 2.1 */ { "\\omega\t", "o" }, { "\\Omega\t", "O" }, { "\\pi\t", "p" }, @@ -1925,11 +2092,13 @@ const char *weighttable[][2] = { { "\\psi\t", "ps" }, { "\\Psi\t", "Ps" }, { "\\rho\t", "r" }, + { "\\Rho\t", "R" }, /* bibarts.sty; new in 2.1 */ { "\\varrho\t", "r" }, { "\\sigma\t", "s" }, { "\\Sigma\t", "S" }, { "\\varsigma\t", "s" }, { "\\tau\t", "t" }, + { "\\Tau\t", "T" }, /* bibarts.sty; new in 2.1 */ { "\\theta\t", "th" }, { "\\Theta\t", "Th" }, { "\\vartheta\t", "th" }, @@ -1938,8 +2107,9 @@ const char *weighttable[][2] = { { "\\upsilon\t", "y" }, { "\\Upsilon\t", "Y" }, { "\\zeta\t", "z" }, + { "\\Zeta\t", "Z" }, /* bibarts.sty; new in 2.1 */ { NULL, NULL }}; -#define NLATEX 117 +#define NLATEX 130 const char *udtable[][2] = { @@ -1951,10 +2121,12 @@ const char *udtable[][2] = { { "\\\"U", "U" }, /* | \"U */ { "\\ss\t", "s" }, /* \ss */ { "\\SS\t", "SS" }, /* \SS */ + { "\\sz\t", "s" }, /* \sz */ /* new in 2.1 */ + { "\\SZ\t", "S" }, /* \SZ */ /* new in 2.1 */ { "\\\"", "" }, /* / \" */ { "\\3", "s" }, /* \3 */ { NULL, NULL }}; -#define NUMTEX 10 +#define NUMTEX 12 const char *gstylist[][2] = { { "\"a", NULL }, /* \ "a */ @@ -1965,9 +2137,11 @@ const char *gstylist[][2] = { { "\"U", NULL }, /* | "U */ { "\"s", NULL }, /* "s */ { "\"S", NULL }, /* "S */ + { "\"z", NULL }, /* "z */ /* new in 2.1 */ + { "\"Z", NULL }, /* "Z */ /* new in 2.1 */ { "\"", NULL }, /* / " */ { NULL, NULL }}; -#define NUMGER 9 +#define NUMGER 11 const char *gweight[][2] = { @@ -1979,6 +2153,8 @@ const char *gweight[][2] = { { NULL, "Ue" }, /* | \"U "U */ { NULL, "ss" }, /* \ss "s */ { NULL, "SS" }, /* \SS "S */ + { NULL, "ss" }, /* \sz "z */ /* new in 2.1 */ + { NULL, "SS" }, /* \SZ "Z */ /* new in 2.1 */ { NULL, "" }, /* / \" " */ { NULL, "ss" }, /* \3 [] */ { NULL, NULL }}; @@ -1992,6 +2168,8 @@ const char *mweight[][2] = { { NULL, "U" }, /* | \"U "U */ { NULL, "ss" }, /* \ss "s */ { NULL, "SS" }, /* \SS "S */ + { NULL, "ss" }, /* \sz "z */ /* new in 2.1 */ + { NULL, "SS" }, /* \SZ "Z */ /* new in 2.1 */ { NULL, "" }, /* / \" " */ { NULL, "ss" }, /* \3 [] */ { NULL, NULL }}; @@ -2825,7 +3003,7 @@ void dofourtharg(int line) { fprintf(outfile, " %.*s\n %%%% <- Your extra-command(s)", l, p); if (notfirstaccepted(line) == 0) - fprintf(outfile, " before the 1st item", l, p); + fprintf(outfile, " before the 1st item"); fprintf(outfile, ".\n"); } } @@ -2894,7 +3072,7 @@ int printipagefnt(const char *arraysep, int begin, int end, int lasti, int cloop if ( lasti > -1 && pagewgt[begin] == pagewgt[lasti] - && numcmp(pagewgt[begin], subRptr[PAGECOL][lasti], subRptr[PAGECOL][begin]) == 0 + && numcmp(1, pagewgt[begin], subRptr[PAGECOL][lasti], subRptr[PAGECOL][begin]) == 0 ) { fprintf(outfile, "$^{,}$"); @@ -2914,8 +3092,8 @@ int printipagefnt(const char *arraysep, int begin, int end, int lasti, int cloop if (end > begin) { - fnc = numcmp( fntwgt[begin], subRptr[FNTCOL][end], subRptr[FNTCOL][begin]); - pnc = numcmp(pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]); + fnc = numcmp(0, fntwgt[begin], subRptr[FNTCOL][end], subRptr[FNTCOL][begin]); + pnc = numcmp(1, pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]); if (fnc == 1) { if (pnc > 0) fprintf(outfile, "$^{%s}$,", subRptr[FNTCOL][begin]); @@ -2962,7 +3140,7 @@ int printipage(const char *arraysep, int begin, int end, int cloop) if (end > begin) { - pnc = numcmp(pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]); + pnc = numcmp(1, pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]); if (pnc == 1) { fprintf(outfile, ","); @@ -3012,7 +3190,7 @@ void makeipagefnt(int i, int line, int end) && pagewgt[i] != MISSNUM && pagewgt[i] == pagewgt[i+1] && (pagewgt[i] != TEXT || strcmp(subRptr[PAGECOL][i], subRptr[PAGECOL][i+1]) == 0) - && (pagewgt[i] == TEXT || (j=numcmp(pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || j == 1) + && (pagewgt[i] == TEXT || (j=numcmp(1, pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || j == 1) ) ++i; else break; } @@ -3027,11 +3205,11 @@ void makeipagefnt(int i, int line, int end) && pagewgt[i] != MISSNUM && pagewgt[i] == pagewgt[i+1] && (pagewgt[i] != TEXT || strcmp(subRptr[PAGECOL][i], subRptr[PAGECOL][i+1]) == 0) - && (pagewgt[i] == TEXT || (j=numcmp(pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || j == 1) + && (pagewgt[i] == TEXT || (j=numcmp(1, pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || j == 1) && fntwgt[i] != MISSNUM && fntwgt[i] == fntwgt[i+1] && ( fntwgt[i] != TEXT || strcmp(subRptr[ FNTCOL][i], subRptr[ FNTCOL][i+1]) == 0) - && ( fntwgt[i] == TEXT || (j=numcmp( fntwgt[i], subRptr[ FNTCOL][i+1], subRptr[ FNTCOL][i])) == 0 || j == 1) + && ( fntwgt[i] == TEXT || (j=numcmp(0, fntwgt[i], subRptr[ FNTCOL][i+1], subRptr[ FNTCOL][i])) == 0 || j == 1) ) ++i; else break; } @@ -3236,12 +3414,12 @@ static void timestamp (FILE *file) } -void printfilelist(FILE *file, int filec, int cc, int kill, const char *vor, const char *nach) +void printfilelist(FILE *file, int filec, int cc, const char *vor, const char *nach) { int i = 0; if (cc == 1) - fprintf(file, "\n%%%% BibArts 2.0 (C) Timo Baumann 2015 [%s]\n", __DATE__); + fprintf(file, "\n%%%% BibArts 2.1 (C) Timo Baumann 2016 [%s]\n", __DATE__); fprintf(file, "%%%%\n"); timestamp(file); @@ -3256,6 +3434,16 @@ void printfilelist(FILE *file, int filec, int cc, int kill, const char *vor, con if (kill == DOKILLAUTHORS) fprintf(file, " -k"); if (EinlROEMseiten == 1) fprintf(file, " -s1"); if (ALPHmpfootnotes == 1) fprintf(file, " -f1"); + if ( get_R_pg == BA_TRUE + || get_A_pg == BA_TRUE + || get_a_pg == BA_TRUE + || get_r_pg == BA_TRUE + ) fprintf(file, " -s2 %s", soptarg); + if ( get_R_fn == BA_TRUE + || get_A_fn == BA_TRUE + || get_a_fn == BA_TRUE + || get_r_fn == BA_TRUE + ) fprintf(file, " -f2 %s", foptarg); if (igleichj == 1) fprintf(file, " -i=j"); if (notext == 1) fprintf(file, " -c"); @@ -3267,10 +3455,13 @@ void printfilelist(FILE *file, int filec, int cc, int kill, const char *vor, con && kill != DOKILLAUTHORS && EinlROEMseiten == 0 && ALPHmpfootnotes == 0 + && (get_R_fn == BA_FALSE && get_A_fn == BA_FALSE && get_a_fn == BA_FALSE && get_r_fn == BA_FALSE) + && (get_R_pg == BA_FALSE && get_A_pg == BA_FALSE && get_a_pg == BA_FALSE && get_r_pg == BA_FALSE) && igleichj == 0 && notext == 0 ) fprintf(file, " Default"); fprintf(file, "%s\n", nach); + fprintf(file, "%%%%> Input file list:\n"); if (filec == 1) @@ -3288,11 +3479,11 @@ void printfilelist(FILE *file, int filec, int cc, int kill, const char *vor, con } -int writelines(int nlines, const int dqcol, const int lancol, const int commentANDignlines, const int deepsort, int filec, int kill, int printsort) +int writelines(int nlines, const int dqcol, const int lancol, const int commentANDignlines, const int deepsort, int filec, int printsort) { int i = 0, dqcat, lancat = 0, lancatbuf, extralines = 0, didsetorig, nerr = 0; - printfilelist(outfile, filec, 1, kill, "\\gdef\\bibsortargs{", " }"); + printfilelist(outfile, filec, 1, "\\gdef\\bibsortargs{", " }"); while (i < nlines && leval[i] != ACCEPTLINE) { @@ -3309,18 +3500,18 @@ int writelines(int nlines, const int dqcol, const int lancol, const int commentA if (dqcol > -1 && nogsty == 0) { dqcat = getarabicnum(subRptr[dqcol][i]); if (dqcat == TeXACTIVE) - { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [BIBSORT] Begin list setting \\string%s. }}\\fi\n", TeXPASSIVE, GERMANTEX, GERMANTEX); + { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [bibsort] Begin list setting \\string%s. }}\\fi\n", TeXPASSIVE, GERMANTEX, GERMANTEX); ++extralines; } else if (dqcat == TeXPASSIVE) - { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [BIBSORT] Begin list setting \\string%s. }}\\fi\n", TeXACTIVE, ORIGINALTEX, ORIGINALTEX); + { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [bibsort] Begin list setting \\string%s. }}\\fi\n", TeXACTIVE, ORIGINALTEX, ORIGINALTEX); ++extralines; } } if (lancol > -1) { lancat = getarabicnum(subRptr[lancol][i]); - fprintf(outfile, " \\ifnum\\language=%d\\else%s%d\\message{ [BIBSORT] Begin list setting hyphenation %d. }\\fi\n", lancat, HYPHENATION, lancat, lancat); + fprintf(outfile, " \\ifnum\\language=%d\\else%s%d\\message{ [bibsort] Begin list setting hyphenation %d. }\\fi\n", lancat, HYPHENATION, lancat, lancat); ++extralines; } @@ -3330,7 +3521,7 @@ int writelines(int nlines, const int dqcol, const int lancol, const int commentA ++i; } - else if (nlines > 0) allerrorout("BIBSORT did reject all your entries."); + else if (nlines > 0) allerrorout("bibsort did reject all your entries."); while (i < nlines) @@ -3339,12 +3530,12 @@ int writelines(int nlines, const int dqcol, const int lancol, const int commentA if (dqcol > -1 && nogsty == 0 && leval[i] == ACCEPTLINE) { if (dqcat == TeXACTIVE && (dqcat = getarabicnum(subRptr[dqcol][i])) == TeXPASSIVE) - { fprintf(outfile, " %s{\\message{ [BIBSORT] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", ORIGINALTEX, ORIGINALTEX, TEXFILELINE, RELAX); + { fprintf(outfile, " %s{\\message{ [bibsort] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", ORIGINALTEX, ORIGINALTEX, TEXFILELINE, RELAX); ++extralines; didsetorig = 0; } else if (dqcat == TeXPASSIVE && (dqcat = getarabicnum(subRptr[dqcol][i])) == TeXACTIVE) - { fprintf(outfile, " %s{\\message{ [BIBSORT] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", GERMANTEX, GERMANTEX, TEXFILELINE, RELAX); + { fprintf(outfile, " %s{\\message{ [bibsort] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", GERMANTEX, GERMANTEX, TEXFILELINE, RELAX); ++extralines; didsetorig = 1; } @@ -3355,7 +3546,7 @@ int writelines(int nlines, const int dqcol, const int lancol, const int commentA || didsetorig != -1 ) { lancat = lancatbuf; - fprintf(outfile, " %s%d\\message{ [BIBSORT] Reproduce hyphenation %d in line %s \\space of BibArts file. }%s\n", HYPHENATION, lancat, lancat, TEXFILELINE, RELAX); + fprintf(outfile, " %s%d\\message{ [bibsort] Reproduce hyphenation %d in line %s \\space of BibArts file. }%s\n", HYPHENATION, lancat, lancat, TEXFILELINE, RELAX); ++extralines; } } @@ -3505,13 +3696,18 @@ int findFEmale(const char *s) } +void baaddx_error(void) +{ + printf("%%%% baaddx-error\n"); +} + + int insertfalse(const char *p, char a[], int i) { int n; - const char *err = "%%%% baaddx-error\n"; while (*p == ' ') ++p; - n = nextbracket(p, '{', '}'); if (n < 2) printf(err); + n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error(); while (n-- > 0 && i < MAXLEN) a[i++] = *p++; while (*p == ' ') ++p; @@ -3519,11 +3715,11 @@ int insertfalse(const char *p, char a[], int i) { a[i++] = *p++; while (*p == ' ') ++p; - n = nextbracket(p, '{', '}'); if (n < 2) printf(err); + n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error(); while (n-- > 0 && i < MAXLEN) a[i++] = *p++; while (*p == ' ') ++p; - n = nextbracket(p, '{', '}'); if (n < 2) printf(err); + n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error(); while (n-- > 0) p++; if (i + strlen(BAFALSE) < MAXLEN) @@ -3531,7 +3727,7 @@ int insertfalse(const char *p, char a[], int i) a[i] = '\0'; strcat(a, BAFALSE); i += strlen(BAFALSE); } } - else printf(err); + else baaddx_error(); while (*p != '\0' && i < MAXLEN) a[i++] = *p++; @@ -4914,6 +5110,49 @@ int single_option(int argc, char *argv[], char a[], char b[]) } +char *arg_option(int argc, char *argv[], char a[], char b[], char *info) +{ + + int l = 1, c, found = 0; + char *p = NULL; + + if (argc > 1 && (strcmp(argv[argc-1], a) == 0 || strcmp(argv[argc-1], b) == 0)) + { + printf("%%%%\n%%%%> Error: %s is not followed by an argument %s.\n", b, info); + announceexit("get an arg option without arg"); + exit(1); + } + + while (l < argc-1) + { + if (strcmp(argv[l], a) == 0 || strcmp(argv[l], b) == 0) + { + /* myfree(argv[l]); */ + p = argv[l+1]; + ++found; + argc -= 2; + c = l; + while (c < argc) + { + argv[c] = argv[c+2]; + ++c; + } + --l; + } + ++l; + } + + if (found > 1) + { + printf("%%%%\n%%%%> Error: %s [arg] setted %d times.\n", a, found); + announceexit("do not accept multiple defined arg options"); + exit(1); + } + + return p; +} + + /*--------------------------------------------------------------------------*/ /* Erkennt unbekannte Optionen. */ @@ -4921,12 +5160,10 @@ int single_option(int argc, char *argv[], char a[], char b[]) int surp_option(int argc, char *argv[]) { int l = 1, c; - char a[2]; while (l < argc) { - strncpy(a, argv[l], 1); - if (a[0] == '-') + if (*argv[l] == '-') { printf("%%%%\n%%%%> Error: Get unknown option \"%s\"!\n", argv[l]); /* myfree(argv[l]); */ --argc; @@ -5074,14 +5311,14 @@ void freeall(int nlines, int deep, int deepsort) } -void prepareoutput(const char *entry, const char *suffix, int deep, int deepsort, int filec, char *argv[], int argc, int kill, const char *cmdA, const char *cmdB, const char *cmdC, const char *cmdD, int ventry, int printsort) +void prepareoutput(const char *entry, const char *suffix, int deep, int deepsort, int filec, char *arg_i, char *arg_o, int prep_kill, const char *cmdA, const char *cmdB, const char *cmdC, const char *cmdD, int ventry, int printsort) { int nlines = 0, i = 0, extralines = 0, commentANDignlines = 0; int filenum = -1; char *outname = mydefault; - if (argc == 2) outname = makename(argv[1], suffix); - if (argc > 2) outname = makename(argv[2], suffix); + if (arg_o == NULL) outname = makename(arg_i, suffix); + else outname = makename(arg_o, suffix); while (i < filec) @@ -5104,32 +5341,32 @@ void prepareoutput(const char *entry, const char *suffix, int deep, int deepsort QQsort(0, nlines-1, deep, deepsort); - if (kill == DOKILLAUTHORS && nlines > 1) + if (prep_kill == DOKILLAUTHORS && nlines > 1) { printf("%%%%> -k: Search multiply used authors ...\n"); printf("%%%% -k: Authors in %d line(s) IDEMized [identical full-titles included].\n", doubleauthor(entry, nlines)); commentANDignlines = count_rejected(nlines); } else - if (kill == DOKILLABBREVS && nlines > 0) + if (prep_kill == DOKILLABBREVS && nlines > 0) { printf("%%%% Search multiply used or empty abbreviations ...\n"); commentANDignlines = double_or_empty_abbreviation(nlines, deepsort, deep); } else - if (kill == DOKILLREGISTS && nlines > 0) + if (prep_kill == DOKILLREGISTS && nlines > 0) { printf("%%%% Search multiply used or empty entries ...\n"); if (*suffix == '.') commentANDignlines = double_or_empty_arqperregisters(nlines, ventry, suffix+1, deepsort, deep); else printf("%%%%\n%%%%> INTERNAL ERROR with \\fill...\n"); } else - if (kill == DOKILLK && nlines > 0) + if (prep_kill == DOKILLK && nlines > 0) { printf("%%%% Search multiply used short-titles ...\n"); commentANDignlines = double_k(nlines, deepsort); } else commentANDignlines = count_rejected(nlines); - if (kill == DOKILLAUTHORS || kill == NOKILLAUTHORS) + if (prep_kill == DOKILLAUTHORS || prep_kill == NOKILLAUTHORS) { if (deep == VCOLS && ventry == IS_V) commentANDignlines = commentANDignlines + doubleventries(nlines, deepsort); @@ -5144,7 +5381,7 @@ void prepareoutput(const char *entry, const char *suffix, int deep, int deepsort } else { printf("%%%%> Write %d item(s) to file \"%s\".\n", nlines-commentANDignlines, outname); - if ((extralines = writelines(nlines, DQCOL, LANCOL, commentANDignlines, deepsort, filec, kill, printsort)) > 0) + if ((extralines = writelines(nlines, DQCOL, LANCOL, commentANDignlines, deepsort, filec, printsort)) > 0) printf("%%%% (Have added %d line(s) containing commands for LaTeX.)\n", extralines); } @@ -5175,39 +5412,136 @@ void prepareoutput(const char *entry, const char *suffix, int deep, int deepsort } -char *getmyname(char *p, int max) +#define ALLWEIGHT ENDWEIGHT-2 +void setnewweight(const int pg, const char *p, const char *opt) { - char *m = p; - int pos = strlen(p); + int lauf = BEGINWEIGHT; /* 4 ... 7+2 */ + int have_n = 0; + int have_R = 0, typed_R = 0; + int have_r = 0, typed_r = 0; + int have_A = 0, typed_A = 0; + int have_a = 0, typed_a = 0; + int have_s = 0; + int wrong_letter = 0; + const char *q = p; - if (pos > max) - while(*p != '\0') + while(*p != '\0' && lauf < ALLWEIGHT) { - if (*p == '/' || *p == '\\') + if (*p == 'n') { if (pg == 1) { pg_arabic = lauf; } else { fn_arabic = lauf; } ++have_n; } + else if (*p == 'R') { if (pg == 1) { pg_bigroman = lauf; get_R_pg = BA_TRUE; } else { fn_bigroman = lauf; get_R_fn = BA_TRUE; } ++have_R; ++have_A; ++typed_R; } + else if (*p == 'r') { if (pg == 1) { pg_smallroman = lauf; get_r_pg = BA_TRUE; } else { fn_smallroman = lauf; get_r_fn = BA_TRUE; } ++have_r; ++have_a; ++typed_r; } + else if (*p == 'A') { if (pg == 1) { pg_bigletter = lauf; get_A_pg = BA_TRUE; } else { fn_bigletter = lauf; get_A_fn = BA_TRUE; } ++have_A; ++have_R; ++typed_A; } + else if (*p == 'a') { if (pg == 1) { pg_smallletter = lauf; get_a_pg = BA_TRUE; } else { fn_smallletter = lauf; get_a_fn = BA_TRUE; } ++have_a; ++have_r; ++typed_a; } + else if (*p == 's') { if (pg == 1) { pg_symbol = lauf; } else { fn_symbol = lauf; } ++have_s; } + else { ++wrong_letter; break; } + ++lauf; ++p; + } + + + if ( *p != '\0' + || lauf != ALLWEIGHT + || have_n != 1 + || have_R != 1 + || have_r != 1 + || have_A != 1 + || have_a != 1 + || have_s != 1 + ) + { + printf("%%%%\n%%%%> Error: Not the %d expected letters in \"%s %.29s\".\n", ALLWEIGHT-BEGINWEIGHT, opt, q); + if (strlen(q) <= ALLWEIGHT-BEGINWEIGHT) { - m = p+1; - if (pos <= max) break; + printf("%%%% Missing:"); + if ( have_n == 0) printf(" [n]"); + if ( have_s == 0) printf(" [s]"); + if (typed_R == 0 && typed_A == 0) printf(" [R *or* A]"); + if (typed_r == 0 && typed_a == 0) printf(" [r *or* a]"); } - ++p; --pos; + else + { + printf("%%%% Error: More than %d letters", ALLWEIGHT-BEGINWEIGHT); + } + printf(". E.g.: snRa, nArs, Rrns, naAs.\n"); + if ( have_n > 1 + || have_s > 1 + || typed_R > 1 + || typed_A > 1 + || typed_r > 1 + || typed_a > 1 + ) + { + printf("%%%% Error: You have setted"); + if (typed_A > 1) printf(" [A]"); + if (typed_a > 1) printf(" [a]"); + if ( have_n > 1) printf(" [n]"); + if (typed_R > 1) printf(" [R]"); + if (typed_r > 1) printf(" [r]"); + if ( have_s > 1) printf(" [s]"); + printf(" more than once.\n"); + } + if ( (typed_A > 0 && typed_R > 0) + || (typed_a > 0 && typed_r > 0) + ) + { + printf("%%%% Error: You have setted"); + if (typed_A > 0 && typed_R > 0) printf(" [R] *and* [A]"); + if (typed_A > 0 && typed_R > 0 && typed_a > 0 && typed_r > 0) + printf(", and "); + if (typed_a > 0 && typed_r > 0) printf(" [r] *and* [a]"); + printf(".\n"); + if ( (typed_a > 0 && typed_r > 0) + || (typed_A > 0 && typed_R > 0) + ) + { + printf("%%%% ** A number like 'i' could mean 9 (alph), and 1 (roman). In xxxx,\n"); + printf("%%%% ** you can only choose R and a, or R and r, or A and a, or A and r.\n"); + } + } + if (wrong_letter > 0) printf("%%%% Break: Unexpected character \'%c\'.\n", *p); + announceexit("did not get 4 out of nRrAas (R or A, r or a)"); + exit(1); } - return m; + + + if (pg == 1) + { + if (get_r_pg == BA_FALSE) pg_smallroman = ++lauf; + if (get_R_pg == BA_FALSE) pg_bigroman = ++lauf; + if (get_a_pg == BA_FALSE) pg_smallletter = ++lauf; + if (get_A_pg == BA_FALSE) pg_bigletter = ++lauf; + } + else + { + if (get_r_fn == BA_FALSE) fn_smallroman = ++lauf; + if (get_R_fn == BA_FALSE) fn_bigroman = ++lauf; + if (get_a_fn == BA_FALSE) fn_smallletter = ++lauf; + if (get_A_fn == BA_FALSE) fn_bigletter = ++lauf; + } + + if ((pg == 0 || pg == 1) && lauf == ENDWEIGHT); + else printf("%%%%\n%%%%> INTERNAL ERROR: setnewweight.\n"); +} + + +void print_arg_list(char *argv[], int argc) +{ + int l = 1; + while (l < argc) printf("%%%% %d: \"%s\"\n", l, argv[l++]); } int main(int argc, char *argv[]) { - int nlines=0; - int i; - int kill = NOKILLAUTHORS; + int nlines = 0; int usedospath = 0; - int filec; + int filec = 0; int get_g = 0; int printsort = 0; - char *inname = mydefault; + char *inname = mydefault, *arg_i = NULL, *arg_o = NULL; - printf("\n%%%%> This is BIBSORT 2.0 (for help: %s -\?)\n", getmyname(argv[0], 37)); - fprintf(stderr, "%%%% BIBSORT is part of BibArts 2.0 (C) Timo Baumann 2015.\n"); + printf("\n%%%%> This is bibsort 2.1 (for help: %s -\?)\n", getmyname(argv[0], 37)); + fprintf(stderr, "%%%% bibsort 2.1 is part of BibArts 2.1 (C) Timo Baumann 2016.\n"); argc = single_option(argc, argv, "-c", "-C"); @@ -5216,16 +5550,54 @@ int main(int argc, char *argv[]) notext = 1; } + soptarg = arg_option(argc, argv, "-S2", "-s2", "[sorting key: 4 out of nRrAas]"); + if (soptarg != NULL) + { + argc -= 2; + setnewweight(1, soptarg, "-s2"); + } + argc = single_option(argc, argv, "-S1", "-s1"); if (argc < 0) { argc = -argc; - EinlROEMseiten = 1; + if ( get_R_pg == BA_FALSE + && get_A_pg == BA_FALSE + && get_a_pg == BA_FALSE + && get_r_pg == BA_FALSE + ) + { + EinlROEMseiten = 1; + } + else + { + announceexit("get opt -s1 *and* -s2"); + exit(1); + } + } + + foptarg = arg_option(argc, argv, "-F2", "-f2", "[sorting key: 4 out of nRrAas]"); + if (foptarg != NULL) + { + argc -= 2; + setnewweight(0, foptarg, "-f2"); } argc = single_option(argc, argv, "-F1", "-f1"); if (argc < 0) { argc = -argc; - ALPHmpfootnotes = 1; + if ( get_R_fn == BA_FALSE + && get_A_fn == BA_FALSE + && get_a_fn == BA_FALSE + && get_r_fn == BA_FALSE + ) + { + ALPHmpfootnotes = 1; + } + else + { + announceexit("get opt -f1 *and* -f2"); + exit(1); + } } argc = single_option(argc, argv, "-i=j", "-I=J"); @@ -5300,7 +5672,7 @@ int main(int argc, char *argv[]) if (argc < 0) { argc = -argc; - info(); + maininfo(argv[0]); announceexit("get your question for help"); exit(1); } @@ -5324,10 +5696,22 @@ int main(int argc, char *argv[]) } if (argc < 2) - { if (argc == 1) info(); + { if (argc == 1) maininfo(argv[0]); announceexit("get no <FileNamePrefix> of an auxiliary file"); exit(1); } + + arg_i = arg_option(argc, argv, "-I", "-i", "<InputFilenamePrefix>"); + if (arg_i != NULL) + { + argc -= 2; + } + + arg_o = arg_option(argc, argv, "-O", "-o", "<OutputFilenamesPrefix>"); + if (arg_o != NULL) + { + argc -= 2; + } if (argc != surp_option(argc, argv)) { @@ -5336,13 +5720,19 @@ int main(int argc, char *argv[]) } - if (argc == 2 || argc == 3) - { inname = makename(argv[1], ".aux"); + if ( (argc == 2 && arg_i == NULL) + || (argc == 1 && arg_i != NULL) + ) + { + if (argc == 2) { arg_i = argv[1]; --argc; } + inname = makename(arg_i, AUX_SUFFIX); infile = fopen(inname, "r"); } else - { printf("%%%%\n%%%%> Error: Too many arguments.\n"); - announceexit("get too many file names in command line"); + { printf("%%%%\n%%%%> Error: Too many arguments:\n"); + print_arg_list(argv, argc); + printf("%%%% Since vers 2.1, you have to use -o <OutputFileNamesPrefix>.\n"); + announceexit("get more than one file name in command line"); exit(1); } @@ -5381,19 +5771,19 @@ int main(int argc, char *argv[]) if (infile != NULL) fclose(infile); - printfilelist( stdout, filec, 0, kill, "%% ", ""); + printfilelist( stdout, filec, 0, "%% ", ""); - prepareoutput("%\\literentry", ".vli", VCOLS, VCOLS, filec, argv, argc, kill, "\\onlykurz", "\\onlyhere", "\\onlyvoll", "\\onlyout", IS_V, printsort); - prepareoutput("%\\quellentry", ".vqu", VCOLS, VCOLS, filec, argv, argc, kill, "\\onlykurz", "\\onlyhere", "\\onlyvoll", "\\onlyout", IS_V, printsort); - prepareoutput("%\\vkcitentry", ".vkc", KCOLS, KCOLS, filec, argv, argc, DOKILLK, "\\onlyvoll", "\\onlyhere", "\\onlykurz", "\\onlyout", NO_V, printsort); + prepareoutput("%\\literentry", VLI_SUFFIX, VCOLS, VCOLS, filec, arg_i, arg_o, kill, "\\onlykurz", "\\onlyhere", "\\onlyvoll", "\\onlyout", IS_V, printsort); + prepareoutput("%\\quellentry", VQU_SUFFIX, VCOLS, VCOLS, filec, arg_i, arg_o, kill, "\\onlykurz", "\\onlyhere", "\\onlyvoll", "\\onlyout", IS_V, printsort); + prepareoutput("%\\vkcitentry", VKC_SUFFIX, KCOLS, KCOLS, filec, arg_i, arg_o, DOKILLK, "\\onlyvoll", "\\onlyhere", "\\onlykurz", "\\onlyout", NO_V, printsort); - prepareoutput("%\\abkrzentry", ".abk", ACOLS, ACOLSSORT, filec, argv, argc, DOKILLABBREVS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); - prepareoutput("%\\perioentry", ".per", PCOLS, PCOLSSORT, filec, argv, argc, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); - prepareoutput("%\\archqentry", ".arq", PCOLS, PCOLSSORT, filec, argv, argc, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", IS_Q, printsort); + prepareoutput("%\\abkrzentry", ABK_SUFFIX, ACOLS, ACOLSSORT, filec, arg_i, arg_o, DOKILLABBREVS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); + prepareoutput("%\\perioentry", PER_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); + prepareoutput("%\\archqentry", ARQ_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", IS_Q, printsort); - prepareoutput("%\\geogrentry", ".grr", PCOLS, PCOLSSORT, filec, argv, argc, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); - prepareoutput("%\\persrentry", ".prr", PCOLS, PCOLSSORT, filec, argv, argc, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); - prepareoutput("%\\subjrentry", ".srr", PCOLS, PCOLSSORT, filec, argv, argc, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); + prepareoutput("%\\geogrentry", GRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); + prepareoutput("%\\persrentry", PRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); + prepareoutput("%\\subjrentry", SRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "", "\\onlyhere", "", "\\onlyout", NO_V, printsort); if (upperascii < 0) { |