Debian Codegraph @

texmf-dist/source/latex/bibarts/bibsort.c

raw
1 /* BibArts 2.6 assists you to write LaTeX texts in arts and humanities. */
2 /* Copyright (C) 2023 Timo Baumann bibarts[at]gmx.de (2023/06/18) */
3
4 /* This program is free software; you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation; either version 2 of the License, or */
7 /* (at your option) any later version. */
8
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program; if not, write to the Free Software */
16 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18
19
20 /*
21 FILES OF THE PACKAGE AND DOCUMENTATION
22 CTAN mirrors > BibArts > bibarts.zip
23 README.txt Version history since 1.3
24 bibarts.sty LaTeX style file
25 ba-short.pdf Short documentation (English)
26 ba-short.tex Source of ba-short.pdf
27 bibarts.pdf Full documentation (German)
28 bibarts.tex Source of bibarts.pdf
29 bibsort.exe bibarts-bin to create the lists
30 bibsort.c This file; source of bibsort.exe
31 COPYING The license of the package
32 */
33
34
35
36 /*
37 COMPATIBILITY
38
39 For my tests on Windows 10, I compiled bibsort.c 2.6 with MinGW, and with
40 MS VisualStudio C/C++; I typed gcc ..., or cl ..., TO THE COMMAND PROMPT.
41
42 Do NOT change this file when you do not have a qualified text
43 editor - it contains control chars: '', '', '', '', | Are the
44 '', '', '', ' ', ' ', '', '', '', '', '', '', | |'s in
45 '', '', '', '', '', '', '', '', '', '', and ''| a line?
46
47 The C-compiled binary of this file is reading LaTeX .aux files.
48 It can NOT read the .bar files, which BibArts 1.x did use.
49 BibArts 2.6 ONLY has an EMULATION for 1.3 texts: Keep copies of 1.x?
50 */
51
52
53
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <string.h>
57 #include <ctype.h>
58 #include <limits.h>
59 #include <time.h>
60
61
62
63
64 #define MAXLINES 65536
65 #define MAXLEN 4096
66 #define MAXFILES 128
67 #define MAXFILENAMLEN 1024
68
69 #define AUX_SUFFIX ".aux"
70 #define VLI_SUFFIX ".vli"
71 #define VQU_SUFFIX ".vqu"
72 #define VKC_SUFFIX ".vkc"
73 #define ABK_SUFFIX ".abk"
74 #define PER_SUFFIX ".per"
75 #define ARQ_SUFFIX ".arq"
76 #define GRR_SUFFIX ".grr"
77 #define PRR_SUFFIX ".prr"
78 #define SRR_SUFFIX ".srr"
79
80 #define IKILLNAME "\\Ikillname{}" /* -K: Damit wird ARG1 und ARG2 einer */
81 /* Zeile ersetzt, falls diese in der */
82 /* vorausgehenden Zeile gleich sind; */
83 #define NKILLNAME "\\killname{}" /* ... und weitere gleiche Namen. */
84 #define PLURALCHAR 'P' /* "\\Pkillname{}" */
85 #define MALE "\\male"
86 #define FEMALE "\\female"
87 #define NOTDOT "\\banotdot"
88 #define HASDOT "\\bahasdot"
89 #define RELAX "\\relax" /* Auch um folgende spaces zu ignorieren */
90 #define TeXITEM "\\item"
91 #define TYPEOUT "\\typeout@ba"
92 #define IeC "\\IeC\t"
93 #define PREPARESPACE "\\bibsortpreparespace"
94 #define PREPAREXSPACE "\\bibsortpreparexspace"
95 #define PREPAREHEAD "\\bibsortpreparehead"
96
97 #define ABKDEF "\\abkdef"
98
99 #define BAFALSE "{false}"
100
101
102 #define NOKILLAUTHORS 0
103 #define DOKILLAUTHORS 1
104 #define DOKILLABBREVS 2
105 #define DOKILLREGISTS 3
106 #define DOKILLK 4
107
108 #define NOTEXCHANGENAMES 0
109 #define EXCHANGENAMES 1
110
111 #define OPENB "\'{\'"
112 #define NUMLEN 16
113
114 int ignorespaces = 0;
115 int hy_as_space = 0;
116 int kill = NOKILLAUTHORS;
117 int ex_n = NOTEXCHANGENAMES;
118 int registpoints = 0;
119 char *lineptr[MAXLINES];
120
121 int FntIndexOverPages = 1; /* new in 2.2 */
122
123 #define PCOLS 2
124 #define PCOLSSORT 1
125 #define ACOLS 2
126 #define ACOLSSORT 1
127 #define KCOLS 4
128 #define VCOLS 4
129 #define IS_Q 2
130 #define IS_V 1
131 #define NO_V 0
132 #define MAXBACOLS 4
133 char *subAptr[MAXBACOLS][MAXLINES];
134 char *subBptr[MAXBACOLS][MAXLINES];
135 char *subCptr[MAXBACOLS][MAXLINES];
136
137 #define PROTECT "\\protect"
138 #define KTIT "\\ktit"
139 #define KTITCMD "\\ktit\t"
140 #define KTITINARG "{\\ktit}"
141 #define ANNOUNCEKTIT "\\announcektit"
142 #define KURZ "\\kurz"
143 #define KURZCMD "\\outkurz\t"
144 #define KTITMISS "\?\?" /* "\t|" before 2.5 */
145 #define KTITEMPTY "\?\?" /* "\t>" before 2.5 */
146 #define KTITBEG "{"
147 #define KTITEND "}"
148 #define KTITOP '{'
149 #define KTITCL '}'
150 int ktiterr = -1; /* otherktiterr before 2.5 */
151
152 #define ACCEPTLINE 0
153 #define REJECTLINE 1
154 #define DOUBLELINE 2 /* \ */
155 #define DIFFERLINE 3 /* Erst ***nach*** */
156 #define UNDEFILINE 4 /* QQsort vergeben */
157 #define ABBREVLINE 5 /* / */
158 #define REDEF1LINE 6
159 #define REDEF2LINE 7
160 int leval[MAXLINES];
161
162 /* new errmsgs in 2.5: */
163 #define NOINERR 0
164 #define KTIT_SEV_ERR 1
165 #define KTIT_EMP_BAS 2
166 #define KTIT_EMP_ERR 3
167 #define KTIT_MIS_BAS 5
168 #define KTIT_MIS_ERR 6
169 #define KTIT_DBL_BAS 11
170 #define KTIT_DBL_ERR 12
171 #define OARG_IRR_BAS 23
172 #define OARG_IRR_ERR 24
173 #define OARG_BRA_BAS 47
174 #define OARG_BRA_ERR 48
175 #define KTIT_OPE_BAS 95
176 #define KTIT_OPE_ERR 96
177 int inerr[MAXLINES]; /* new in 2.5 */
178
179 #define BARESTCOLS 5
180 #define PAGEFNTCOL 1
181 #define PAGECOL BARESTCOLS
182 #define FNTCOL (BARESTCOLS+1)
183 #define BAALLRCOLS (BARESTCOLS+2)
184 char *subRptr[BAALLRCOLS][MAXLINES];
185 int pagewgt[MAXLINES];
186 int fntwgt[MAXLINES];
187
188 #define STUFFRCOL 0
189 #define KENTRY 0
190 #define VENTRY 1
191 #define ERRENTRY 2
192 #define VENTRYCH 'v'
193 #define KENTRYCH 'k'
194
195 #define ERRINPUTLINENO "line \?\?"
196 #define ERRINPUTLINENOLEN 7
197
198 #define OVERFLOWTXT "Counter too large"
199 /* vgl. -> "\\errmessage\t" */
200 #define MISSINGSYMB "\\erri@ba"
201 #define MISSINGERMS "??"
202 #define OVERFLOWSYMB "()"
203 #define EMPTYSYMB "[]"
204 char *TEXTSYMBOPEN[] = { "\\{{", "{", NULL };
205 char *TEXTSYMBCLOSE[] = { "\\/}\\}", "\\/}", NULL };
206 int notext = 0;
207
208 int dqsort[MAXLINES];
209 #define MINCATCODE 0
210 #define MAXCATCODE 15
211 #define ERRCATCODE MINCATCODE-1
212 const char bareststr[] = "{}{}[][]()";
213 #define DQCOL 2
214 #define TeXACTIVE 13
215 #define TeXPASSIVE 12
216 #define LANCOL 3
217 #define GERMANTEX "\\bagermanTeX" /* err-def ist \bagermanTeX#1{} */
218 #define ORIGINALTEX "\\baoriginalTeX" /* err-def ist \baoriginalTeX#1{} */
219 #define HYPHENATION "\\language="
220 #define LINECOL 4
221 #define OLDBIGROMAN "\\uppercase"
222 #define NEWFNSYMBOL "\\ensuremath"
223 #define TOMFNSYMBOL "\\TextOrMath"
224 #define TEXFILELINE "\\line@ba"
225
226 #define BS_SPACE "\\ "
227 #define BANCOMMA ", "
228 #define BAINDEXFIRS " \\first@baidx{"
229 #define BAINDEXFOLL " \\follo@baidx{"
230 #define BAINDEXEND "}\n"
231 #define CLOOPASTART -1
232 #define CLOOPBSTART 0
233 #define BAINDEXLEN 45
234
235
236 #define BADNUM 0
237 #define GOODNUM 1
238 #define CHECKNUM 0
239 #define ANALYZENUM 1
240 #define HASOFLOW 0
241 #define HASNOOFLOW 1
242
243 #define MAXMESSN 10
244 #define MAXINFO 10
245
246 FILE *infile, *outfile;
247 char *filelist[MAXFILES];
248
249 int get_jobs = 0;
250 int lastupperascii = 0;
251 int thisupperascii = 0;
252 #define UTF_EIGHT_MAXLEN 4
253 #define UTF_EIGHT_MAXERR 20
254 char err_utf_eight[UTF_EIGHT_MAXERR][UTF_EIGHT_MAXLEN+1];
255 int utf_err_c = 0;
256 char emp_utf_eight[UTF_EIGHT_MAXERR][UTF_EIGHT_MAXLEN+1];
257 int utf_emp_c = 0;
258 char this_emp_utf_eight[UTF_EIGHT_MAXLEN+1];
259 char this_err_utf_eight[UTF_EIGHT_MAXLEN+1];
260
261 #define IS_BASE_ENC 0
262 #define IS_TONE_ENC 1
263 #define IS_UTFE_ENC 2
264 int encode = IS_BASE_ENC;
265
266 int german = 0;
267 int nogsty = 0;
268
269 int EinlROEMseiten = 0;
270 #define BA_FALSE 0
271 #define BA_TRUE 1
272 int get_R_pg = BA_FALSE;
273 int get_A_pg = BA_FALSE;
274 int get_r_pg = BA_FALSE;
275 int get_a_pg = BA_FALSE;
276 int ALPHmpfootnotes = 0;
277 int get_R_fn = BA_FALSE;
278 int get_A_fn = BA_FALSE;
279 int get_r_fn = BA_FALSE;
280 int get_a_fn = BA_FALSE;
281 int igleichj = 0;
282
283 #define METALINEHEAD "%%%%META%%%%"
284
285
286 int bago = 0; /* new in 2.2 */
287 #define BAGOCMD "\\bago"
288
289 char *soptarg = NULL;
290 char *foptarg = NULL;
291
292 char *mydefault = "";
293 char *nofnt = "(nofnt)"; /* nur "" wuerde Fehler machen */
294 char *unused = "(unused)";
295 void myfree(char *p) { if (p != mydefault && p != nofnt && p != unused && p != NULL) free(p); }
296
297
298
299 /* Begin prototypes ... */
300
301 void print_two(int line, int left, int right);
302 int isLaTeXcmdletter(char a);
303 int entkerne_IeC(char buf[], const char *s);
304 int isinstr(const char *p, const char *s);
305 int lcmdcmp(const char *s, const char *p);
306 void swap(int i, int j);
307 int vergleich(const char *a, const char *b);
308 int Vergleich(const char *a, const char *b);
309 int llstrlen(const char *s);
310 int do_only(char ret[], const char form[], const char in[]);
311 int userusesdq(int deepsort, int linec);
312 int texcmp(const char *s, const char *p, int dqcats, int dqcatp);
313 int subdoubleauthors(int found, int addtxt, char a[], int remi, int i, const char *q, const char *p, int qline, int pline, int fe, char xx[]);
314
315 /* ... end prototypes. */
316
317
318
319 void openfailed(const char *s)
320 {
321 fprintf(stderr, "%%%% == Failed to open \"%s\". ==\n", s);
322 }
323
324
325 void intern_err(int n)
326 {
327 printf("%%%%\n%%%%> INTERNAL ERROR %d\n", n);
328 }
329
330
331 void announceexit(const char *s)
332 {
333 fprintf(stderr, "%%%%> I give up my job, because I %s.\n", s);
334 }
335
336
337 int mystrncpy(char *p, const char *s, int len)
338 {
339 int l = 0, ll;
340
341 while(*s != '\0' && l < len)
342 {
343 *p++ = *s++;
344 ++l;
345 }
346
347 *p = '\0'; /* handle error: len < 0 */
348
349 ll = l;
350 while (ll <= len)
351 {
352 *p++ = '\0';
353 ++ll;
354 }
355
356 return l;
357 }
358
359
360 char *strnmalloc(const char *q, int len)
361 { char *p = mydefault;
362 int l = 0;
363 if (len < 1) { intern_err(0); len = 1; } /* mallocError len */
364 p = (char *) malloc(len);
365 if (p == NULL)
366 {
367 printf("%%%%\n%%%%> Error: Not enough memory.\n");
368 announceexit("could not alloc enough memory");
369 exit(1);
370 }
371 else l = mystrncpy(p, q, len-1);
372 if (l != len-1) intern_err(1); /* alloc len l != len-1 */
373 return p;
374 }
375 #define HASFNTCH '@'
376 #define HASUNUCH '-'
377
378
379 /*--------------------------------------------------------------------------*/
380
381
382 const char *getmyname(const char *p, int max)
383 {
384 const char *m = p;
385 int pos = strlen(p);
386
387 if (pos > max)
388 while(*p != '\0')
389 {
390 if (*p == '/' || *p == '\\')
391 {
392 m = p+1;
393 if (pos <= max) break;
394 }
395 ++p; --pos;
396 }
397 return m;
398 }
399
400
401 const char *authortable[][2] = {
402 { "\\vauthor\t", "\\vauthor" },
403 { "\\midvauthor\t", "\\midvauthor" },
404 {NULL, NULL}};
405 #define NAUTHOR 2
406
407
408
409 void licenseinfo(void)
410 {
411 printf("%%%% I guess that I am a bin-compilation of bibsort.c. My job is to read\n");
412 printf("%%%% entries in LaTeX %s files which are made by bibarts.sty. Use e.g.\n", AUX_SUFFIX);
413 printf("%%%% \\vli{FirstName}{FamilyName}{BookTitle, Year} and \\printvli in your\n");
414 printf("%%%% .tex file. For usage, see ba-short.pdf (engl) or bibarts.pdf (ger).\n");
415 printf("%%%%\n");
416 printf("%%%% This program is free software; you can redistribute it and/or modify\n");
417 printf("%%%% it under the terms of the GNU General Public License as published by\n");
418 printf("%%%% the Free Software Foundation; either version 2 of the License, or\n");
419 printf("%%%% (at your option) any later version.\n");
420 printf("%%%%\n");
421 printf("%%%% This program is distributed in the hope that it will be useful,\n");
422 printf("%%%% but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
423 printf("%%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
424 printf("%%%% GNU General Public License for more details.\n");
425 printf("%%%%\n");
426 printf("%%%% You should have received a copy of the GNU General Public License\n");
427 printf("%%%% along with this program; if not, write to the Free Software\n");
428 printf("%%%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n");
429 printf("%%%%\n");
430 }
431
432
433 void moremoreinfo(const char *myname)
434 {
435 printf("%%%% CODEPAGES\n");
436 printf("%%%% LaTeX will write ASCIIs > 127 in your %s-file(s), if you use\n", AUX_SUFFIX);
437 printf("%%%% \\usepackage[utf8]{inputenc} (today the default). With option\n");
438 printf("%%%% -utf8 I expect characters as definded in utf8enc.dfu 2022/06/07 v1.3c,\n");
439 printf("%%%% except those, which execute \\cyr...- or \\CYR...-cmds. I report\n");
440 printf("%%%% every unknown utf8 character only once.\n");
441 printf("%%%% -t1 You set \\UseRawInputEncoding, and ASCIIs > 127, which you use in\n");
442 printf("%%%% your .tex-file(s), reach the %s-file(s); I interpret them.\n", AUX_SUFFIX);
443 printf("%%%% **For apparently all other codepages, LaTeX writes \\cmds.**\n");
444 printf("%%%% PRINTING OF CO-AUTHORS\n");
445 printf("%%%% To introduce a book with two authors, type e.g. in a footnote:\n");
446 printf("%%%% \\xvli{John}{Smith} *{\\vauthor{Peter}{Young}} {... [Title] ...}\n");
447 printf("%%%% Use %s{}{} in front of %s{}{} for further authors.\n", authortable[1][1], authortable[0][1]);
448 printf("%%%% Starting %s with default, \\printvli will print the list as:\n", getmyname(myname, 18));
449 printf("%%%% Smith, John / Peter Young: ... [Title] ...\n");
450 printf("%%%% -e Exchanges the args of %s (and of %s). \\printvli:\n", authortable[0][1], authortable[1][1]);
451 printf("%%%% Smith, John / Young, Peter: ... [Title] ...\n");
452 printf("%%%% In BOTH cases, the entry is sorted as: Smith John Young Peter\n");
453 printf("%%%%\n");
454 }
455
456
457 void moreinfo(const char *myname)
458 {
459 printf("%%%% -utf8 See %s -\?\?\?\n", getmyname(myname, 40));
460 printf("%%%% -m Print the strings which I internally use for sorting (meta-lines).\n");
461 printf("%%%% -b If %s is in an argument, I will begin the comparison at %s.\n", BAGOCMD, BAGOCMD);
462 printf("%%%% -n1 You reset fnt counters (no fnt-block-indexing over several pages).\n");
463 printf("%%%% INDEX TO PAGE AND FOOTNOTE NUMBERS (num-lists like \\printnumvkc):\n");
464 printf("%%%% (1) DEFAULT SORTING ORDER of page and footnote numbers:\n");
465 printf("%%%% fnsymbol r/Roman arabic a/Alph (z=26, aa=27, ab=28)\n");
466 printf("%%%% You may change the EVALUATION ORDER (r/Roman versus a/Alph):\n");
467 printf("%%%% / introduction = *lower roman page numbers*\n");
468 printf("%%%% DEFAULT < appendix = *capital Alph page numbers*\n");
469 printf("%%%% \\ minipages = *lower alph footnote numbers*\n");
470 printf("%%%% -s1 EVALUATE \'I\' as 1 in pages (intro Roman, appendix alph).\n");
471 printf("%%%% -f1 EVALUATE \'i\' as 1 in fnts (evaluate on roman before alph).\n");
472 printf("%%%% (2) NON-DEFAULT SORTING ORDER with an EVALUATION affixed to that order:\n");
473 printf("%%%% -s2 <xxxx> Page number style: -f2 <xxxx> Footnote mark style:\n");
474 printf("%%%% with a permutation of 4 letters out of nRrAas in free order\n");
475 printf("%%%% (a=alph, A=Alph, n=arabic, R=Roman, r=roman, s=fnsymbol);\n");
476 printf("%%%% but in <xxxx>, there must be n, s, and R *or* A, and r *or* a.\n");
477 printf("%%%%\n");
478 }
479
480
481 void maininfo(const char *myname)
482 {
483 printf("%%%% I read a LaTeX %s file (follow \\@input), and I write my output in files\n", AUX_SUFFIX);
484 printf("%%%% %s Literature %s Published sources %s Geographic index\n", VLI_SUFFIX, VQU_SUFFIX, GRR_SUFFIX);
485 printf("%%%% %s Short titles %s Unpublished sources %s Person index\n", VKC_SUFFIX, ARQ_SUFFIX, PRR_SUFFIX);
486 printf("%%%% %s Periodicals %s Abbreviations %s Subject index\n", PER_SUFFIX, ABK_SUFFIX, SRR_SUFFIX);
487 printf("%%%%\n");
488 printf("%%%% %s <LaTeXFile> [-o <OutFile>] [-g1 [OR] -g2] [-utf8] [-e] [...]\n", getmyname(myname, 13));
489 printf("%%%%\n");
490 printf("%%%% DefaultSort: 0, .., 9, (A a), (B b), .., (s \\ss S), .., (Z z) and\n"); /* udtable */
491 printf("%%%% (a [\\.\\'\\`\\^\\\"\\=\\~]a \\aa=\\r{a} [\\b\\c\\k\\d\\H\\t\\u\\v]{a} \\ae), b, ..\n");
492 printf("%%%% -g<n> GermanSort: (a A), .., (z Z), 0, .., 9; and (\\\" or active \"):\n");
493 printf("%%%% -g1 GermanTelefonebookStyle: \"a = \\\"a = ae, ..., \"s = \\ss = ss;\n"); /* gweight */
494 printf("%%%% -g2 ModernGermanDictionary: \"a = \\\"a = a, ..., \"s = \\ss = ss.\n"); /* mweight */
495 printf("%%%% -x DoNotExpect german.sty: Active \"-characters do NOT produce umlauts.\n");
496 printf("%%%% -k Idemize ~ multiple used authors in the %s and %s lists (kill).\n", VLI_SUFFIX, VQU_SUFFIX);
497 printf("%%%% -d \\include{ / is \\ } (dos). -h Sort a hyphen as a space.\n");
498 printf("%%%% -i=j Sort \'i\' as \'j\'. -p Sort \"P.S.\" before \"Peter\" (point).\n");
499 printf("%%%% -l Ignore spaces (leer). -c Don\'t set bad page/fnt nums in {}.\n"); /* TEXTSYMBOPEN[0], TEXTSYMBCLOSE[0] */
500 printf("%%%% -r Typeout license (read). -\?\? -\?\?\? More or more more options.\n");
501 printf("%%%%\n");
502 }
503
504
505 /*--------------------------------------------------------------------------*/
506
507
508 int isexactlcmd(const char *p, const char *s)
509 {
510 while(*p == *s && *s != '\t' && *s != '\0' ) { ++p; ++s; }
511 if (*s == '\t' && isLaTeXcmdletter(*p) == 0) return 0;
512 return 1;
513 }
514
515
516 int num_of_cmds_in_str(const char *p, const char *s)
517 {
518 int r = 0;
519
520 while (*p != '\0')
521 {
522 if (*p == '\\')
523 {
524 if (*(p+1) == '\\') ++p;
525 else
526 if (isexactlcmd(p, s) == 0) ++r;
527 }
528 ++p;
529 }
530
531 return r;
532 }
533
534
535 int nextbracket(const char *p, const char opench, const char closech)
536 {
537 int c = 0, r = 0;
538
539 while (*p != '\0')
540 {
541 if (*p == '\\' && *(p+1) != '\0') { ++p; ++r; }
542 else if (*p == opench) ++c;
543 else if (*p == closech) --c;
544 ++p; ++r;
545 if (c == 0) break;
546 }
547
548 if (c != 0) r = -r;
549
550 return r;
551 }
552
553
554 int artithmetic_overflow(const char *p, const char *cc)
555 {
556 printf("%%%%\n%%%%> Warning: Arithmetic overflow %s-eval \"%s\".\n", p, cc);
557
558 return INT_MAX;
559 }
560
561
562 int getarabicnum(const char *p)
563 {
564 int num = 0, vor = 1;
565 const char *mem;
566
567 while (*p == ' ') ++p; mem = p;
568
569 if (*p == '-') { vor = -1; ++p; }
570
571 while (*p >= '0' && *p <= '9' && num >= 0)
572 num = (10 * num) + (*p++ - '0');
573
574 if (num < 0) num = artithmetic_overflow("arabic", mem);
575
576 return num * vor;
577 }
578
579
580 int firstoverlettergan(const char *p)
581 {
582 while (*p == ' ' || isalpha(*p) != 0) ++p;
583
584 return getarabicnum(p);
585 }
586
587
588 int secondoverlettergan(const char *p)
589 {
590 while (*p == ' ' || isalpha(*p) != 0) ++p;
591 while (*p >= '0' && *p <= '9') ++p;
592 while (*p == ' ' || isalpha(*p) != 0) ++p;
593
594 return getarabicnum(p);
595 }
596
597
598 int getLetterletternum(const char *p)
599 {
600 int num = 0, vor = 1;
601 const char *mem;
602
603 while (*p == ' ') ++p; mem = p;
604
605 if (*p == '-') { vor = -1; ++p; }
606
607 while (num >= 0)
608 {
609 if (*p >= 'A' && *p <= 'Z') num = (26 * num) + (*p++ - 'A' + 1);
610 else if (*p >= 'a' && *p <= 'z') num = (26 * num) + (*p++ - 'a' + 1);
611 else break;
612 }
613
614 if (num < 0) num = artithmetic_overflow("a/Alph", mem);
615
616 return num * vor;
617 }
618
619
620 int getRomanromannum(const char *p)
621 {
622 int val = 0, nextval, num = 0, vor = 1;
623 const char *mem;
624
625 while (*p == ' ') ++p; mem = p;
626
627 if (*p == '-') { vor = -1; ++p; }
628
629 while (*p != '\0' && num >= 0)
630 {
631 if (*p == 'i' || *p == 'I') val = 1;
632 else if (*p == 'v' || *p == 'V') val = 5;
633 else if (*p == 'x' || *p == 'X') val = 10;
634 else if (*p == 'l' || *p == 'L') val = 50;
635 else if (*p == 'c' || *p == 'C') val = 100;
636 else if (*p == 'd' || *p == 'D') val = 500;
637 else if (*p == 'm' || *p == 'M') val = 1000;
638 else break;
639
640 if (*(p+1) == '\0') nextval = 0;
641 else if (*(p+1) == 'i' || *(p+1) == 'I') nextval = 1;
642 else if (*(p+1) == 'v' || *(p+1) == 'V') nextval = 5;
643 else if (*(p+1) == 'x' || *(p+1) == 'X') nextval = 10;
644 else if (*(p+1) == 'l' || *(p+1) == 'L') nextval = 50;
645 else if (*(p+1) == 'c' || *(p+1) == 'C') nextval = 100;
646 else if (*(p+1) == 'd' || *(p+1) == 'D') nextval = 500;
647 else if (*(p+1) == 'm' || *(p+1) == 'M') nextval = 1000;
648 else nextval = 0;
649
650 if (nextval > val) { num = num - val + nextval; ++p; }
651 else num = num + val;
652
653 ++p;
654 }
655
656 if (num < 0) num = artithmetic_overflow("r/Roman", mem);
657
658 return num * vor;
659 }
660
661 /*--------------------------------------------------------------------------*/
662
663
664 int has_o_flow(const char *p)
665 {
666 int r = HASNOOFLOW;
667
668 if (isinstr(p, OVERFLOWTXT) == 1) r = HASOFLOW;
669
670 return r;
671 }
672
673
674 int endnumberline(const char *p, int r)
675 {
676 int len = strlen(RELAX);
677
678 while (*p == ' ') ++p;
679 if (*p == '}') ++p;
680 while (strncmp(p, RELAX, len) == 0) p+=len;
681 while (*p == ' ') ++p;
682
683 if (*p != '\0') r = BADNUM;
684
685 return r;
686 }
687
688
689 /* ALT */
690 /* "*\relax " */ /* 1 */
691 /* "\dagger \relax " */ /* 2 */
692 /* "\ddagger \relax " */ /* 3 */
693 /* "\mathchar "278\relax " */ /* 4 */
694 /* "\mathchar "27B\relax " */ /* 5 */
695 /* "\delimiter "26B30D \relax " */ /* 6 */
696 /* "**\relax " */ /* 7 */
697 /* "\dagger \dagger \relax " */ /* 8 */
698 /* "\ddagger \ddagger \relax " */ /* 9 */
699
700 /* NEU */
701 /* "*" */ /* 1 */
702 /* "\dagger " */ /* 2 */
703 /* "\ddagger " */ /* 3 */
704 /* "\mathchar "278" */ /* 4 */
705 /* "\mathchar "27B" */ /* 5 */
706 /* "\delimiter "026B30D " */ /* 6 */
707 /* "**" */ /* 7 */
708 /* "\dagger \dagger " */ /* 8 */
709 /* "\ddagger \ddagger " */ /* 9 */
710
711 /* GANZ NEU */
712 /* "\ensuremath {*}" */ /* 1 */
713 /* "\ensuremath {\dagger }" */ /* 2 */
714 /* "\ensuremath {\ddagger }" */ /* 3 */
715 /* "\ensuremath {\mathsection }" */ /* 4 */
716 /* "\ensuremath {\mathparagraph }" */ /* 5 */
717 /* "\ensuremath {\delimiter "026B30D }" */ /* 6 */
718 /* "\ensuremath {**}" */ /* 7 */
719 /* "\ensuremath {\dagger \dagger }" */ /* 8 */
720 /* "\ensuremath {\ddagger \ddagger }" */ /* 9 */
721
722 /* NOCH NEUER */
723 /* \TextOrMath {\textasteriskcentered }{*} */ /* 1 */
724 /* \TextOrMath {\textdagger }{\dagger } */ /* 2 */
725 /* \TextOrMath {\textdaggerdbl }{\ddagger } */ /* 3 */
726 /* \TextOrMath {\textsection }{\mathsection } */ /* 4 */
727 /* \TextOrMath {\textparagraph }{\mathparagraph } */ /* 5 */
728 /* \TextOrMath {\textbardbl }{\delimiter "026B30D } */ /* 6 */
729 /* \TextOrMath {\textasteriskcentered \textasteriskcentered }{**} */ /* 7 */
730 /* \TextOrMath {\textdagger \textdagger }{\dagger \dagger } */ /* 8 */
731 /* \TextOrMath {\textdaggerdbl \textdaggerdbl }{\ddagger \ddagger } */ /* 9 */
732
733 /* 2021 vorgefunden (parallel zu BibArts 2.3) */
734 /* \TextOrMath {\textasteriskcentered }{*} */ /* 1 */
735 /* \TextOrMath {\textdagger }{\dagger } */ /* 2 */
736 /* \TextOrMath {\textdaggerdbl }{\ddagger } */ /* 3 */
737 /* \TextOrMath {\textsection }{\mathsection } */ /* 4 */
738 /* \TextOrMath {\textparagraph }{\mathparagraph } */ /* 5 */
739 /* \TextOrMath {\textbardbl }{\|} */ /* 6 */
740 /* \TextOrMath {\textasteriskcentered \textasteriskcentered }{**} */ /* 7 */
741 /* \TextOrMath {\textdagger \textdagger }{\dagger \dagger } */ /* 8 */
742 /* \TextOrMath {\textdaggerdbl \textdaggerdbl }{\ddagger \ddagger } */ /* 9 */
743
744
745
746 int nextsymbolnum(int oldnum, int beginnum)
747 {
748 if (oldnum == 0) return beginnum;
749 else return oldnum + 6;
750 }
751
752
753 int len_tom(const char *p)
754 {
755 int len, r = 0;
756
757 if (lcmdcmp(p, TOMFNSYMBOL) == 0)
758 {
759 p += (r=strlen(TOMFNSYMBOL));
760
761 while (*p == ' ') { ++p; ++r; }
762
763 if (*p == '{')
764 {
765 /* erstes Arg von NOCH NEUER */
766 len = nextbracket(p, '{', '}');
767 if (len > 1)
768 { r += len;
769 }
770 else r = 0;
771 }
772 else r = 0;
773 }
774
775 return r;
776 }
777
778
779 int evalsymbol(int pg, const char *p, const int job)
780 {
781 int r = BADNUM, num = 0, len, cmdtyp = 0, cmd = 0, vor = 1;
782 const char *mem;
783
784 while (*p == ' ') ++p;
785
786 if (pg == 1)
787 {
788 if (lcmdcmp(p, NEWFNSYMBOL) == 0)
789 p += strlen(NEWFNSYMBOL);
790 else p += len_tom(p);
791 }
792
793 while (*p == ' ') ++p;
794 if (*p == '{') ++p;
795 mem = p;
796
797 if (*p == '-') { vor = -1; ++p; }
798
799 while (num >= 0)
800 {
801 if ((cmd == 0 || cmd == 6) && cmdtyp < 2 && strncmp(p, "\\|", (len=strlen("\\|"))) == 0) /* new in 2.3 */
802 {
803 r = GOODNUM;
804 num = nextsymbolnum(num, (cmd = 6));
805 cmdtyp = 1;
806 }
807 else if ((cmd == 0 || cmd == 6) && cmdtyp < 2 && strncmp(p, "\\delimiter", (len=strlen("\\delimiter"))) == 0)
808 {
809 r = BADNUM; /* folgen muessen \"26B30D oder \"026B30D */
810 cmdtyp = 2; /* cmd == 6 cmd == 6 */
811 }
812 else if ((cmd == 0 || cmd == 6) && cmdtyp == 2 && strncmp(p, "\"26B30D", (len=strlen("\"26B30D"))) == 0)
813 {
814 r = GOODNUM;
815 num = nextsymbolnum(num, (cmd = 6));
816 cmdtyp = 1;
817 }
818 else if ((cmd == 0 || cmd == 6) && cmdtyp == 2 && strncmp(p, "\"026B30D", (len=strlen("\"026B30D"))) == 0)
819 {
820 r = GOODNUM;
821 num = nextsymbolnum(num, (cmd = 6)); /* ebenfalls */
822 cmdtyp = 1;
823 }
824 else if ((cmd == 0 || cmd == 4 || cmd == 5) && cmdtyp < 2 && strncmp(p, "\\mathchar", (len=strlen("\\mathchar"))) == 0)
825 {
826 r = BADNUM; /* folgen muessen \"27B oder \"278 */
827 cmdtyp = 3; /* cmd == 5 cmd == 4 */
828 }
829 else if ((cmd == 0 || cmd == 5) && cmdtyp == 3 && strncmp(p, "\"27B", (len=strlen("\"27B"))) == 0)
830 {
831 r = GOODNUM;
832 num = nextsymbolnum(num, (cmd = 5));
833 cmdtyp = 1;
834 }
835 else if ((cmd == 0 || cmd == 5) && cmdtyp < 2 && strncmp(p, "\\mathparagraph", (len=strlen("\\mathparagraph"))) == 0)
836 {
837 r = GOODNUM;
838 num = nextsymbolnum(num, (cmd = 5));
839 cmdtyp = 1;
840 }
841 else if ((cmd == 0 || cmd == 4) && cmdtyp == 3 && strncmp(p, "\"278", (len=strlen("\"278"))) == 0)
842 {
843 r = GOODNUM;
844 num = nextsymbolnum(num, (cmd = 4));
845 cmdtyp = 1;
846 }
847 else if ((cmd == 0 || cmd == 4) && cmdtyp < 2 && strncmp(p, "\\mathsection", (len=strlen("\\mathsection"))) == 0)
848 {
849 r = GOODNUM;
850 num = nextsymbolnum(num, (cmd = 4));
851 cmdtyp = 1;
852 }
853 else if ((cmd == 0 || cmd == 3) && cmdtyp < 2 && strncmp(p, "\\ddagger", (len=strlen("\\ddagger"))) == 0)
854 {
855 r = GOODNUM;
856 num = nextsymbolnum(num, (cmd = 3));
857 cmdtyp = 1;
858 }
859 else if ((cmd == 0 || cmd == 2) && cmdtyp < 2 && strncmp(p, "\\dagger", (len=strlen("\\dagger"))) == 0)
860 {
861 r = GOODNUM;
862 num = nextsymbolnum(num, (cmd = 2));
863 cmdtyp = 1;
864 }
865 else if ((cmd == 0 || cmd == 1) && cmdtyp < 2 && strncmp(p, "*", (len=strlen("*"))) == 0)
866 {
867 r = GOODNUM;
868 num = nextsymbolnum(num, (cmd = 1));
869 cmdtyp = 0;
870 }
871 else if (cmdtyp > 0 && *p == ' ') len=1;
872 else break;
873
874 p += len;
875 }
876
877 if (num < 0) num = artithmetic_overflow("fnsymbol", mem);
878
879 r = endnumberline(p, r);
880
881 if (job == CHECKNUM) return r;
882 else return num * vor;
883 }
884
885
886 int evalroman(const char *p, const int job)
887 {
888 int r = BADNUM, num = 0;
889 const char *mem;
890
891 while (*p == ' ') ++p; mem = p;
892
893 if (*p == '-') ++p;
894
895 while (*p != '\0')
896 {
897 if ( *p == 'i'
898 || *p == 'v'
899 || *p == 'x'
900 || *p == 'l'
901 || *p == 'c'
902 || *p == 'd'
903 || *p == 'm'
904 )
905 { ++p;
906 r = GOODNUM;
907 }
908 else break;
909 }
910
911 r = endnumberline(p, r);
912
913 if (job != CHECKNUM && r == GOODNUM) num = getRomanromannum(mem);
914
915 if (job == CHECKNUM) return r;
916 else return num;
917 }
918
919
920 int evalRoman(const char *p, const int job)
921 {
922 int r = BADNUM, num = 0, len = strlen(OLDBIGROMAN), vor = 1;
923 const char *mem;
924
925 while (*p == ' ') ++p; mem = p;
926
927 if ( strncmp(p, OLDBIGROMAN, len) == 0
928 || (*p == '-' && strncmp((p+1), OLDBIGROMAN, len) == 0)
929 )
930 {
931 if (*p == '-') { vor = -1; ++p; }
932 p += len;
933 while (*p == ' ') ++p;
934 if (*p == '{')
935 { ++p; /* kleine roem. Zahl, die gross gedruckt wird */
936 if (*p == '}') r = GOODNUM; /* OLDBIGROMAN + " {}" */
937 else
938 r = evalroman(p, CHECKNUM); /* Der job ist in jedem Fall checken */
939 if (vor < 0 && (*p == ' ' || *p == '-')) r = BADNUM;
940 mem = p;
941 }
942 else r = BADNUM;
943 }
944 else
945 {
946 if (*p == '-') ++p;
947
948 while (*p != '\0')
949 {
950 if ( *p == 'I'
951 || *p == 'V'
952 || *p == 'X'
953 || *p == 'L'
954 || *p == 'C'
955 || *p == 'D'
956 || *p == 'M'
957 )
958 { ++p;
959 r = GOODNUM;
960 }
961 else break;
962 }
963
964 r = endnumberline(p, r);
965 }
966
967 if (job != CHECKNUM && r == GOODNUM)
968 { num = getRomanromannum(mem);
969 if (num < 0 && vor < 0) r = BADNUM;
970 }
971
972 if (job == CHECKNUM) return r;
973 else return num * vor; /* vor == -1 von OLDBIGROMAN */
974 }
975
976
977 int evalarabic(const char *p, const int job)
978 {
979 int r = BADNUM, num = 0;
980 const char *mem;
981
982 while (*p == ' ') ++p; mem = p;
983
984 if (*p == '-') ++p;
985
986 while (*p != '\0')
987 {
988 if ( *p >= '0'
989 && *p <= '9'
990 )
991 { ++p;
992 r = GOODNUM;
993 }
994 else break;
995 }
996
997 r = endnumberline(p, r);
998
999 if (job != CHECKNUM && r == GOODNUM) num = getarabicnum(mem);
1000
1001 if (job == CHECKNUM) return r;
1002 else return num;
1003 }
1004
1005
1006 int evalletter(const char *p, const int job)
1007 {
1008 int r = BADNUM, num = 0;
1009 const char *mem;
1010
1011 while (*p == ' ') ++p; mem = p;
1012
1013 if (*p == '-') ++p;
1014
1015 while (*p != '\0')
1016 {
1017 if ( *p >= 'a'
1018 && *p <= 'z'
1019 )
1020 { ++p;
1021 r = GOODNUM;
1022 }
1023 else break;
1024 }
1025
1026 r = endnumberline(p, r);
1027
1028 if (job != CHECKNUM && r == GOODNUM) num = getLetterletternum(mem);
1029
1030 if (job == CHECKNUM) return r;
1031 else return num;
1032 }
1033
1034
1035 int evalLetter(const char *p, const int job)
1036 {
1037 int r = BADNUM, num = 0;
1038 const char *mem;
1039
1040 while (*p == ' ') ++p; mem = p;
1041
1042 if (*p == '-') ++p;
1043
1044 while (*p != '\0')
1045 {
1046 if ( *p >= 'A'
1047 && *p <= 'Z'
1048 )
1049 { ++p;
1050 r = GOODNUM;
1051 }
1052 else break;
1053 }
1054
1055 r = endnumberline(p, r);
1056
1057 if (job != CHECKNUM && r == GOODNUM) num = getLetterletternum(mem);
1058
1059 if (job == CHECKNUM) return r;
1060 else return num;
1061 }
1062
1063
1064 int isinstr(const char *p, const char *s)
1065 {
1066 const char *pp, *ss;
1067
1068 while (*p != '\0')
1069 {
1070 pp = p; ss = s;
1071 while (*pp == *ss && *pp != '\0') { ++pp; ++ss; }
1072 if (*ss == '\0') return 1;
1073 ++p;
1074 }
1075
1076 return 0;
1077 }
1078
1079
1080 /* Typen-Gewichtung nicht mit Abpruef-Reihenfolge verwechseln! */
1081 /* Zahl fuer Typen-Gewichtung ist gleichzeitig Typen-Identifizierer. */
1082 /* Abpruef-Reihenfolge legen pgnumberweight + fntnumberweight fest, */
1083 /* die auch entscheiden, ob etwa DC=600 oder DC=4*3=12 gesehen wird. */
1084 /* !! \uppercase{xx} = OLDBIGROMAN gilt NIE als Buchstabenzaehler !! */
1085 #define INTERNALERR 0
1086 #define UNUSED 1 /* muss anfuehren (kleinster Wert)! */
1087 #define NOFOOTNOTE 2
1088 #define EMPTYNUM 3 /* Alph, alph, Roman, roman, symbol < 1 */
1089 #define BEGINWEIGHT 4
1090 int pg_symbol = 4, fn_symbol = 4;
1091 int pg_smallroman = 5, fn_smallroman = 5;
1092 int pg_bigroman = 6, fn_bigroman = 6;
1093 int pg_arabic = 7, fn_arabic = 7;
1094 int pg_smallletter = 8, fn_smallletter = 8;
1095 int pg_bigletter = 9, fn_bigletter = 9;
1096 #define ENDWEIGHT 10
1097 #define TEXT 10
1098 #define MISSNUM 11 /* Beschaedigte Zeile */
1099 #define OVERFLOW 12
1100
1101 int pgnumberweight(const char *p)
1102 {
1103 int r = INTERNALERR; /* primaer i, ii, ..., 1, 2, ..., A, B, *C*, ... */
1104
1105
1106 if ( get_R_pg == BA_TRUE
1107 || get_A_pg == BA_TRUE
1108 || get_a_pg == BA_TRUE
1109 || get_r_pg == BA_TRUE
1110 )
1111 {
1112 if (p == unused) r = UNUSED;
1113 else if (p == mydefault) r = MISSNUM;
1114 else if (p == nofnt) r = INTERNALERR;
1115 else if (*p == '\0') r = EMPTYNUM;
1116 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1117 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic;
1118 else if (get_R_pg == BA_TRUE && evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman;
1119 else if (get_A_pg == BA_TRUE && evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter;
1120 else if (get_a_pg == BA_TRUE && evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter;
1121 else if (get_r_pg == BA_TRUE && evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman;
1122 else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol;
1123 else r = TEXT;
1124 }
1125 else
1126 if (EinlROEMseiten == 1)
1127 {
1128 if (p == unused) r = UNUSED;
1129 else if (p == mydefault) r = MISSNUM;
1130 else if (p == nofnt) r = INTERNALERR;
1131 else if (*p == '\0') r = EMPTYNUM;
1132 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1133 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic;
1134 else if (evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman;
1135 else if (evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter;
1136 else if (evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter;
1137 else if (evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman;
1138 else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol;
1139 else r = TEXT;
1140 }
1141 else
1142 {
1143 if (p == unused) r = UNUSED;
1144 else if (p == mydefault) r = MISSNUM;
1145 else if (p == nofnt) r = INTERNALERR;
1146 else if (*p == '\0') r = EMPTYNUM;
1147 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1148 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = pg_arabic;
1149 else if (evalroman (p, CHECKNUM) == GOODNUM) r = pg_smallroman;
1150 else if (evalletter(p, CHECKNUM) == GOODNUM) r = pg_smallletter;
1151 else if (evalLetter(p, CHECKNUM) == GOODNUM) r = pg_bigletter;
1152 else if (evalRoman (p, CHECKNUM) == GOODNUM) r = pg_bigroman;
1153 else if (evalsymbol(1, p, CHECKNUM) == GOODNUM) r = pg_symbol;
1154 else r = TEXT;
1155 }
1156
1157 /* OLDBIGROMAN + " {}" */
1158 if (r == pg_bigroman && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM;
1159
1160 return r;
1161 }
1162
1163
1164 int fntnumberweight(const char *p)
1165 {
1166 int r = INTERNALERR; /* primaer I, II, ..., 1, 2, ..., a, b, *c*, ... */
1167
1168
1169 if ( get_R_fn == BA_TRUE
1170 || get_A_fn == BA_TRUE
1171 || get_a_fn == BA_TRUE
1172 || get_r_fn == BA_TRUE
1173 )
1174 {
1175 if (p == mydefault) r = MISSNUM;
1176 else if (p == nofnt) r = NOFOOTNOTE;
1177 else if (p == unused) r = INTERNALERR;
1178 else if (*p == '\0') r = EMPTYNUM;
1179 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1180 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic;
1181 else if (get_r_fn == BA_TRUE && evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman;
1182 else if (get_a_fn == BA_TRUE && evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter;
1183 else if (get_A_fn == BA_TRUE && evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter;
1184 else if (get_R_fn == BA_TRUE && evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman;
1185 else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol;
1186 else r = TEXT;
1187 }
1188 else
1189 if (ALPHmpfootnotes == 1)
1190 {
1191 if (p == mydefault) r = MISSNUM;
1192 else if (p == nofnt) r = NOFOOTNOTE;
1193 else if (p == unused) r = INTERNALERR;
1194 else if (*p == '\0') r = EMPTYNUM;
1195 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1196 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic;
1197 else if (evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman;
1198 else if (evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter;
1199 else if (evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter;
1200 else if (evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman;
1201 else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol;
1202 else r = TEXT;
1203 }
1204 else
1205 {
1206 if (p == mydefault) r = MISSNUM;
1207 else if (p == nofnt) r = NOFOOTNOTE;
1208 else if (p == unused) r = INTERNALERR;
1209 else if (*p == '\0') r = EMPTYNUM;
1210 else if (has_o_flow(p) == HASOFLOW) r = OVERFLOW;
1211 else if (evalarabic(p, CHECKNUM) == GOODNUM) r = fn_arabic;
1212 else if (evalRoman (p, CHECKNUM) == GOODNUM) r = fn_bigroman;
1213 else if (evalLetter(p, CHECKNUM) == GOODNUM) r = fn_bigletter;
1214 else if (evalletter(p, CHECKNUM) == GOODNUM) r = fn_smallletter;
1215 else if (evalroman (p, CHECKNUM) == GOODNUM) r = fn_smallroman;
1216 else if (evalsymbol(0, p, CHECKNUM) == GOODNUM) r = fn_symbol;
1217 else r = TEXT;
1218 }
1219
1220 /* OLDBIGROMAN + " {}" */
1221 if (r == fn_bigroman && evalRoman (p, ANALYZENUM) == 0) r = EMPTYNUM;
1222
1223 return r;
1224 }
1225
1226
1227 /*--------------------------------------------------------------------------*/
1228
1229
1230 int issonder(const char p)
1231 {
1232 if (p > '\0' && p < ' ') return 1;
1233 return 0;
1234 }
1235
1236
1237 /* Neugewichtung der ASCII-Zeichen 33 und 48 bis 126. */
1238
1239 /* Im Deutschen werden Zeichen vor Buchstaben und */
1240 /* Buchstaben vor Zahlen einsortiert. */
1241 /* Im Konfliktfall stehen Kleinbuchstaben vor grossen. */
1242
1243 int bewerten(char zz)
1244 {
1245 switch(zz)
1246 {
1247 case '\0': return 0;
1248
1249 case ' ': return 32; /* ASCII 32 \ / normales Leerzeichen */
1250 case '~': return 33; /* ASCII 126 / \ geschuetztes Leereichen */
1251
1252 case '!': return 48; /* ASCII 33 \ */
1253 case ':': return 49; /* ASCII 58 | */
1254 case ';': return 50; /* ASCII 59 | */
1255 case '<': return 51; /* ASCII 60 | */
1256 case '=': return 52; /* ASCII 61 | */
1257 case '>': return 53; /* ASCII 62 | */
1258 case '\?':return 54; /* ASCII 63 | */
1259 case '@': return 55; /* ASCII 64 | */
1260 case '[': return 56; /* ASCII 91 \ */
1261 case ']': return 57; /* ASCII 93 > Zeichen vor Buchstaben */
1262 /* / */
1263 case '^': return 58; /* ASCII 94 | */
1264 case '_': return 59; /* ASCII 95 | */
1265 case '`': return 60; /* ASCII 96 | */
1266 /* | */
1267 case '{': return 61; /* ASCII 123 | */
1268 case '|': return 62; /* ASCII 124 | */
1269 case '}': return 63; /* ASCII 125 / */
1270
1271 case 'a': return 64; /* ASCII 97 \ */
1272 case 'A': return 65; /* ASCII 65 | */
1273 case 'b': return 66; /* ASCII 98 | */
1274 case 'B': return 67; /* ASCII 66 | */
1275 case 'c': return 68; /* ASCII 99 | */
1276 case 'C': return 69; /* ASCII 67 | */
1277 case 'd': return 70; /* ASCII 100 | */
1278 case 'D': return 71; /* ASCII 68 | */
1279 case 'e': return 72; /* ASCII 101 | */
1280 case 'E': return 73; /* ASCII 69 | */
1281 case 'f': return 74; /* ASCII 102 | */
1282 case 'F': return 75; /* ASCII 70 | */
1283 case 'g': return 76; /* ASCII 103 | */
1284 case 'G': return 77; /* ASCII 71 | */
1285 case 'h': return 78; /* ASCII 104 | */
1286 case 'H': return 79; /* ASCII 72 | */
1287 case 'i': return 80; /* ASCII 105 | */
1288 case 'I': return 81; /* ASCII 73 | */
1289 case 'j': return 82; /* ASCII 106 | */
1290 case 'J': return 83; /* ASCII 74 | */
1291 case 'k': return 84; /* ASCII 107 | */
1292 case 'K': return 85; /* ASCII 75 | */
1293 case 'l': return 86; /* ASCII 108 | */
1294 case 'L': return 87; /* ASCII 76 | */
1295 case 'm': return 88; /* ASCII 109 | */
1296 case 'M': return 89; /* ASCII 77 | */
1297 case 'n': return 90; /* ASCII 110 | */
1298 case 'N': return 91; /* ASCII 78 | */
1299 case 'o': return 92; /* ASCII 111 | */
1300 case 'O': return 93; /* ASCII 79 | */
1301 case 'p': return 94; /* ASCII 112 \ */
1302 case 'P': return 95; /* ASCII 80 > Buchstaben: a, A, ... */
1303 case 'q': return 96; /* ASCII 113 / */
1304 case 'Q': return 97; /* ASCII 81 | */
1305 case 'r': return 98; /* ASCII 114 | */
1306 case 'R': return 99; /* ASCII 82 | */
1307 case 's': return 100; /* ASCII 115 | */
1308 case 'S': return 101; /* ASCII 83 | */
1309 case 't': return 102; /* ASCII 116 | */
1310 case 'T': return 103; /* ASCII 84 | */
1311 case 'u': return 104; /* ASCII 117 | */
1312 case 'U': return 105; /* ASCII 85 | */
1313 case 'v': return 106; /* ASCII 118 | */
1314 case 'V': return 107; /* ASCII 86 | */
1315 case 'w': return 108; /* ASCII 119 | */
1316 case 'W': return 109; /* ASCII 87 | */
1317 case 'x': return 110; /* ASCII 120 | */
1318 case 'X': return 111; /* ASCII 88 | */
1319 case 'y': return 112; /* ASCII 121 | */
1320 case 'Y': return 113; /* ASCII 89 | */
1321 case 'z': return 114; /* ASCII 122 | */
1322 case 'Z': return 115; /* ASCII 90 / */
1323
1324 case '0': return 116; /* ASCII 48 \ */
1325 case '1': return 117; /* ASCII 49 | */
1326 case '2': return 118; /* ASCII 50 | */
1327 case '3': return 119; /* ASCII 51 | */
1328 case '4': return 120; /* ASCII 52 \ */
1329 case '5': return 121; /* ASCII 53 > Zahlen */
1330 case '6': return 122; /* ASCII 54 / */
1331 case '7': return 123; /* ASCII 55 | */
1332 case '8': return 124; /* ASCII 56 | */
1333 case '9': return 125; /* ASCII 57 / */
1334
1335 case '\\':return 126; /* ASCII 92 > Unbekannter Akzent? */
1336
1337 default : if (issonder(zz) == 1) return zz + 256;
1338 return zz;
1339 }
1340 }
1341
1342
1343
1344 /* Im Defaultfall werden Zeichen vor Zahlen und */
1345 /* Zahlen vor Buchstaben einsortiert. */
1346 /* Im Konfliktfall stehen Grossbuchstaben vor kleinen. */
1347
1348 int dcompare(char zz)
1349 {
1350 switch(zz)
1351 {
1352 case '\0': return 0;
1353
1354 case ' ': return 32; /* ASCII 32 \ / normales Leerzeichen */
1355 case '~': return 33; /* ASCII 126 / \ geschuetztes Leereichen */
1356
1357 case '!': return 48; /* ASCII 33 \ */
1358 case ':': return 49; /* ASCII 58 | */
1359 case ';': return 50; /* ASCII 59 | */
1360 case '<': return 51; /* ASCII 60 | */
1361 case '=': return 52; /* ASCII 61 | */
1362 case '>': return 53; /* ASCII 62 | */
1363 case '\?':return 54; /* ASCII 63 | */
1364 case '@': return 55; /* ASCII 64 | */
1365 case '[': return 56; /* ASCII 91 \ */
1366 case ']': return 57; /* ASCII 93 > Zeichen vor Zahlen */
1367 /* / */
1368 case '^': return 58; /* ASCII 94 | */
1369 case '_': return 59; /* ASCII 95 | */
1370 case '`': return 60; /* ASCII 96 | */
1371 /* | */
1372 case '{': return 61; /* ASCII 123 | */
1373 case '|': return 62; /* ASCII 124 | */
1374 case '}': return 63; /* ASCII 125 / */
1375
1376 case '0': return 64; /* ASCII 48 \ */
1377 case '1': return 65; /* ASCII 49 | */
1378 case '2': return 66; /* ASCII 50 | */
1379 case '3': return 67; /* ASCII 51 | */
1380 case '4': return 68; /* ASCII 52 \ */
1381 case '5': return 69; /* ASCII 53 > Zahlen vor Buchstaben */
1382 case '6': return 70; /* ASCII 54 / */
1383 case '7': return 71; /* ASCII 55 | */
1384 case '8': return 72; /* ASCII 56 | */
1385 case '9': return 73; /* ASCII 57 / */
1386
1387 case 'A': return 74; /* ASCII 65 \ */
1388 case 'a': return 75; /* ASCII 97 | */
1389 case 'B': return 76; /* ASCII 66 | */
1390 case 'b': return 77; /* ASCII 98 | */
1391 case 'C': return 78; /* ASCII 67 | */
1392 case 'c': return 79; /* ASCII 99 | */
1393 case 'D': return 80; /* ASCII 68 | */
1394 case 'd': return 81; /* ASCII 100 | */
1395 case 'E': return 82; /* ASCII 69 | */
1396 case 'e': return 83; /* ASCII 101 | */
1397 case 'F': return 84; /* ASCII 70 | */
1398 case 'f': return 85; /* ASCII 102 | */
1399 case 'G': return 86; /* ASCII 71 | */
1400 case 'g': return 87; /* ASCII 103 | */
1401 case 'H': return 88; /* ASCII 72 | */
1402 case 'h': return 89; /* ASCII 104 | */
1403 case 'I': return 90; /* ASCII 73 | */
1404 case 'i': return 91; /* ASCII 105 | */
1405 case 'J': return 92; /* ASCII 74 | */
1406 case 'j': return 93; /* ASCII 106 | */
1407 case 'K': return 94; /* ASCII 75 | */
1408 case 'k': return 95; /* ASCII 107 | */
1409 case 'L': return 96; /* ASCII 76 | */
1410 case 'l': return 97; /* ASCII 108 | */
1411 case 'M': return 98; /* ASCII 77 | */
1412 case 'm': return 99; /* ASCII 109 | */
1413 case 'N': return 100; /* ASCII 78 | */
1414 case 'n': return 101; /* ASCII 110 | */
1415 case 'O': return 102; /* ASCII 79 | */
1416 case 'o': return 103; /* ASCII 111 \ */
1417 case 'P': return 104; /* ASCII 80 > Buchstaben: A, a, ... */
1418 case 'p': return 105; /* ASCII 112 / */
1419 case 'Q': return 106; /* ASCII 81 | */
1420 case 'q': return 107; /* ASCII 113 | */
1421 case 'R': return 108; /* ASCII 82 | */
1422 case 'r': return 109; /* ASCII 114 | */
1423 case 'S': return 110; /* ASCII 83 | */
1424 case 's': return 111; /* ASCII 115 | */
1425 case 'T': return 112; /* ASCII 84 | */
1426 case 't': return 113; /* ASCII 116 | */
1427 case 'U': return 114; /* ASCII 85 | */
1428 case 'u': return 115; /* ASCII 117 | */
1429 case 'V': return 116; /* ASCII 86 | */
1430 case 'v': return 117; /* ASCII 118 | */
1431 case 'W': return 118; /* ASCII 87 | */
1432 case 'w': return 119; /* ASCII 119 | */
1433 case 'X': return 120; /* ASCII 88 | */
1434 case 'x': return 121; /* ASCII 120 | */
1435 case 'Y': return 122; /* ASCII 89 | */
1436 case 'y': return 123; /* ASCII 121 | */
1437 case 'Z': return 124; /* ASCII 90 | */
1438 case 'z': return 125; /* ASCII 122 / */
1439
1440 case '\\':return 126; /* ASCII 92 > Unbekannter Akzent? */
1441
1442 default : if (issonder(zz) == 1) return zz + 256;
1443 return zz;
1444 }
1445 }
1446
1447
1448 /*--------------------------------------------------------------------------*/
1449
1450
1451 int igspstrcmp(const char *p, const char *q)
1452 {
1453 while (1)
1454 {
1455 while (*p == ' ') ++p;
1456 while (*q == ' ') ++q;
1457 if (*p == *q && *p != '\0') { ++p; ++q; } else break;
1458 }
1459
1460 return bewerten(*p) - bewerten(*q);
1461 }
1462
1463
1464 int numcmp(const int pg, const int w, const char *p, const char *q)
1465 {
1466 int j = 0;
1467
1468 if (w == EMPTYNUM) j = 0;
1469 else if (w == NOFOOTNOTE) j = 0;
1470 else if (w == UNUSED) j = 0;
1471 else if (pg == 1 && w == pg_smallroman) j = evalroman (p, ANALYZENUM) - evalroman (q, ANALYZENUM);
1472 else if (pg == 0 && w == fn_smallroman) j = evalroman (p, ANALYZENUM) - evalroman (q, ANALYZENUM);
1473 else if (pg == 1 && w == pg_bigroman) j = evalRoman (p, ANALYZENUM) - evalRoman (q, ANALYZENUM);
1474 else if (pg == 0 && w == fn_bigroman) j = evalRoman (p, ANALYZENUM) - evalRoman (q, ANALYZENUM);
1475 else if (pg == 1 && w == pg_arabic) j = evalarabic(p, ANALYZENUM) - evalarabic(q, ANALYZENUM);
1476 else if (pg == 0 && w == fn_arabic) j = evalarabic(p, ANALYZENUM) - evalarabic(q, ANALYZENUM);
1477 else if (pg == 1 && w == pg_smallletter) j = evalletter(p, ANALYZENUM) - evalletter(q, ANALYZENUM);
1478 else if (pg == 0 && w == fn_smallletter) j = evalletter(p, ANALYZENUM) - evalletter(q, ANALYZENUM);
1479 else if (pg == 1 && w == pg_bigletter) j = evalLetter(p, ANALYZENUM) - evalLetter(q, ANALYZENUM);
1480 else if (pg == 0 && w == fn_bigletter) j = evalLetter(p, ANALYZENUM) - evalLetter(q, ANALYZENUM);
1481 else if (pg == 1 && w == pg_symbol) j = evalsymbol(1, p, ANALYZENUM) - evalsymbol(1, q, ANALYZENUM);
1482 else if (pg == 0 && w == fn_symbol) j = evalsymbol(0, p, ANALYZENUM) - evalsymbol(0, q, ANALYZENUM);
1483 else if (w == TEXT) j = igspstrcmp(p, q);
1484 else if (w == MISSNUM) j = 0;
1485 else if (w == OVERFLOW) j = 0;
1486 else intern_err(2); /* UNKNOWN PAGE-WEIGHT NUMBER */
1487
1488
1489 return j;
1490 }
1491
1492
1493 void QQsort(int left, int right, const int deep, const int deepsort)
1494 {
1495 int i, last, j, l;
1496
1497 if (left >= right) return;
1498 swap(left, (left + right)/2);
1499 last = left;
1500
1501 for (i = left + 1; i <= right; i++)
1502 {
1503 j = 0; l = 0;
1504 while (l < deepsort)
1505 {
1506 if ((j=vergleich(subCptr[l][i], subCptr[l][left])) != 0) break;
1507 if (*subAptr[l][i] == '\0' && *subAptr[l][left] != '\0') { j = -1; break; } /* new in 2.3 */
1508 if (*subAptr[l][i] != '\0' && *subAptr[l][left] == '\0') { j = 1; break; } /* new in 2.3 */
1509 if ((j=Vergleich(subBptr[l][i], subBptr[l][left])) != 0) break;
1510 if (*subBptr[l][i] == '\0' && *subBptr[l][left] == '\0') /* M */ /* new in 2.3 */
1511 {
1512 if ((j=vergleich(subAptr[l][i], subAptr[l][left])) != 0) break; /* new in 2.3 */
1513 }
1514 else
1515 if ((j=vergleich(subBptr[l][i], subBptr[l][left])) != 0) break;
1516 ++l;
1517 }
1518
1519
1520 if (j == 0)
1521 {
1522 l = 0;
1523 while (l < deepsort)
1524 {
1525 if (*subBptr[l][i] != '\0' || *subBptr[l][left] != '\0') /* M */ /* new in 2.3 */
1526 {
1527 if ((j=vergleich(subAptr[l][i], subAptr[l][left])) != 0) break;
1528 }
1529 ++l;
1530 }
1531 }
1532
1533
1534 if (j == 0) /* Completely */
1535 j = dqsort[i] - dqsort[left]; /* new in 2.6 */
1536
1537 if (j == 0)
1538 j = leval[i] - leval[left];
1539
1540 if (j == 0)
1541 j = pagewgt[i] - pagewgt[left];
1542
1543 if (j == 0) /* pagewgt[i] == pagewgt[left] */
1544 j = numcmp(1, pagewgt[i], subRptr[PAGECOL][i], subRptr[PAGECOL][left]);
1545
1546 if (j == 0)
1547 j = fntwgt[i] - fntwgt[left];
1548
1549 if (j == 0) /* fntwgt[i] == fntwgt[left] */
1550 j = numcmp(0, fntwgt[i], subRptr[FNTCOL][i], subRptr[FNTCOL][left]);
1551
1552 if (j == 0)
1553 j = firstoverlettergan(subRptr[LINECOL][i]) - firstoverlettergan(subRptr[LINECOL][left]);
1554
1555 if (j == 0)
1556 j = secondoverlettergan(subRptr[LINECOL][i]) - secondoverlettergan(subRptr[LINECOL][left]);
1557
1558 if (j == 0)
1559 {
1560 l = deepsort;
1561 while (l < deep)
1562 {
1563 if ((j=vergleich(subAptr[l][i], subAptr[l][left])) != 0) break;
1564 ++l;
1565 }
1566 }
1567
1568
1569 if (j < 0) swap(++last, i);
1570 }
1571
1572
1573 swap(left, last);
1574 QQsort(left, last - 1, deep, deepsort);
1575 QQsort(last + 1, right, deep, deepsort);
1576 }
1577
1578
1579 /*--------------------------------------------------------------------------*/
1580
1581
1582 void swap(int i, int j)
1583 {
1584 char *temp;
1585 int l, temi;
1586
1587 temp = lineptr[i];
1588 lineptr[i] = lineptr[j];
1589 lineptr[j] = temp;
1590
1591 temi = pagewgt[i];
1592 pagewgt[i] = pagewgt[j];
1593 pagewgt[j] = temi;
1594
1595 temi = fntwgt[i];
1596 fntwgt[i] = fntwgt[j];
1597 fntwgt[j] = temi;
1598
1599 temi = dqsort[i];
1600 dqsort[i] = dqsort[j];
1601 dqsort[j] = temi;
1602
1603 temi = leval[i];
1604 leval[i] = leval[j];
1605 leval[j] = temi;
1606
1607 temi = inerr[i]; /* new in 2.5 */
1608 inerr[i] = inerr[j];
1609 inerr[j] = temi;
1610
1611 l = 0;
1612 while (l < MAXBACOLS)
1613 {
1614 temp = subAptr[l][i];
1615 subAptr[l][i] = subAptr[l][j];
1616 subAptr[l][j] = temp;
1617 ++l;
1618 }
1619
1620 l = 0;
1621 while (l < MAXBACOLS)
1622 {
1623 temp = subBptr[l][i];
1624 subBptr[l][i] = subBptr[l][j];
1625 subBptr[l][j] = temp;
1626 ++l;
1627 }
1628
1629 l = 0;
1630 while (l < MAXBACOLS)
1631 {
1632 temp = subCptr[l][i];
1633 subCptr[l][i] = subCptr[l][j];
1634 subCptr[l][j] = temp;
1635 ++l;
1636 }
1637
1638 l = 0;
1639 while (l < BAALLRCOLS)
1640 {
1641 temp = subRptr[l][i];
1642 subRptr[l][i] = subRptr[l][j];
1643 subRptr[l][j] = temp;
1644 ++l;
1645 }
1646 }
1647
1648
1649 /*--------------------------------------------------------------------------*/
1650
1651
1652 int vergleich(const char *a, const char *b)
1653 {
1654 while (*a != '\0' && *a == *b) { ++a; ++b; }
1655
1656 if (german > 0) return bewerten(*a) - bewerten(*b);
1657 else return dcompare(*a) - dcompare(*b);
1658 }
1659
1660
1661 int Vergleich(const char *a, const char *b)
1662 {
1663 while (1)
1664 {
1665 while (issonder(*a) == 1) ++a;
1666 while (issonder(*b) == 1) ++b;
1667 if (*a == '\0' || *a != *b) break;
1668 ++a; ++b;
1669 }
1670
1671 if (german > 0) return bewerten(*a) - bewerten(*b);
1672 else return dcompare(*a) - dcompare(*b);
1673 }
1674
1675
1676 /*--------------------------------------------------------------------------*/
1677
1678
1679 int myfgetc(void)
1680 {
1681 int c = fgetc(infile);
1682
1683 if (c == '\t') c = ' ';
1684
1685 return c;
1686 }
1687
1688
1689 int ignFRONTSPACESgetline(char s[], int lim)
1690 {
1691 int c,i;
1692 i=0;
1693 while( (c=myfgetc()) == ' ');
1694 if (--lim > 0 && c != EOF && c != '\n')
1695 s[i++] = c;
1696 while(--lim > 0 && (c=myfgetc()) != EOF && c != '\n')
1697 s[i++] = c;
1698 if (c == '\n') s[i++] = c;
1699 s[i] = '\0';
1700 return i;
1701 }
1702
1703
1704 /*--------------------------------------------------------------------------*/
1705
1706
1707 int LaTeXcmp_endlen(const char *p, const char *s)
1708 {
1709 int len = 0;
1710
1711 while (*s != '\0' && *s != '\t' && *s == *p)
1712 {
1713 ++s; ++p; ++len;
1714 }
1715
1716 if (*s == '\t' && isLaTeXcmdletter(*p) == 0)
1717 {
1718 while (*p == ' ') { ++p; ++len; }
1719 }
1720 else len = 0;
1721
1722 return len;
1723 }
1724
1725
1726 int loesche_arg(char s[], const char *p, const char *com, const char op, const char cl)
1727 {
1728 int len, r = 0, reallen;
1729
1730 while (*p != '\0')
1731 {
1732 if (*p == '\\')
1733 {
1734 if (*(p+1) == '\\')
1735 {
1736 s[r++] = *p++;
1737 s[r++] = *p++;
1738 }
1739 else
1740 if ((reallen = LaTeXcmp_endlen(p, com)) > 0)
1741 {
1742 p += reallen;
1743
1744 if (*p == '\0') break;
1745
1746 if (*p == op && (len = nextbracket(p, op, cl)) > 1)
1747 {
1748 p += len;
1749 }
1750 else
1751 {
1752 if (*p == '\\')
1753 {
1754 ++p;
1755 if (isLaTeXcmdletter(*p) != 0)
1756 {
1757 while (isLaTeXcmdletter(*p) != 0) ++p;
1758 while (*p == ' ') ++p;
1759 }
1760 else if (*p != '\0') ++p;
1761 }
1762 else
1763 {
1764 ++p; /* ungeklammerten Einzelbuchstaben loeschen */
1765 }
1766 }
1767 }
1768 else
1769 {
1770 s[r++] = *p++;
1771 }
1772 }
1773 else
1774 {
1775 s[r++] = *p++;
1776 }
1777 }
1778
1779 s[r] = '\0';
1780
1781 return r;
1782 }
1783
1784
1785 int entkerne_arg(char s[], const char *p, const char *com, const char op, const char cl)
1786 {
1787 int l, r = 0, reallen;
1788
1789 while (*p != '\0')
1790 {
1791 if (*p == '\\')
1792 {
1793 if (*(p+1) == '\\')
1794 {
1795 s[r++] = *p++;
1796 s[r++] = *p++;
1797 }
1798 else
1799 if ((reallen = LaTeXcmp_endlen(p, com)) > 0)
1800 {
1801 p += reallen;
1802
1803 if (*p == '\0') break;
1804
1805 if (*p == op && (l = nextbracket(p, op, cl)) > 1)
1806 {
1807 ++p;
1808 if (*p == ' ')
1809 {
1810 if (r > 1 && s[r-1] == ' ' && s[r-2] == ' ') --r;
1811 s[r++] = '\\';
1812 }
1813 while (--l > 1) { s[r++] = *p++; }
1814 ++p;
1815 }
1816 else
1817 {
1818 s[r++] = *p++;
1819 }
1820 }
1821 else
1822 {
1823 s[r++] = *p++;
1824 }
1825 }
1826 else
1827 {
1828 s[r++] = *p++;
1829 }
1830 }
1831
1832 s[r] = '\0';
1833
1834 return r;
1835 }
1836
1837
1838 void print_not_tightly_err(const char *p, const char c)
1839 {
1840 int len = strlen(p), sw = 0;
1841
1842 printf("%%%%\n%%%%> Warning: \'%c\' does not fit tightly after \"", c);
1843
1844 if (len > 2 && *(p+(len-1)) == c)
1845 {
1846 ++p; len -= 2;
1847 }
1848
1849 while (len > 27) { --len; ++p; ++sw; }
1850
1851 if (sw > 0) printf("...");
1852 printf("%.*s\".\n", len, p);
1853 }
1854
1855
1856 char *fillsubAptr(const char *p, int len, const char c)
1857 {
1858 char buf[MAXLEN];
1859 int i;
1860
1861 ++p; len -= 2;
1862 while (*p == ' ') { ++p; --len; }
1863 strcpy(buf, p);
1864
1865 buf[len] = '\0';
1866 if (len > 0 && buf[len-1] == ' ')
1867 { i = 2;
1868 while (len-i >= 0 && buf[len-i] == ' ') ++i;
1869 while (len-i >= 0 && isLaTeXcmdletter(buf[len-i]) != 0) ++i;
1870 if (len-i < 0 || buf[len-i] != '\\') print_not_tightly_err(buf, c);
1871 }
1872 while (len > 0 && buf[len-1] == ' ') --len;
1873
1874 return strnmalloc(buf, len+1);
1875 }
1876
1877
1878 int form_only(char buf[], char forml, const char *onlycmdp, const char *p)
1879 {
1880 int len;
1881
1882 if (forml == 'l')
1883 {
1884 len = loesche_arg(buf, p, onlycmdp, '{', '}');
1885 }
1886 else
1887 if (forml == 'e')
1888 {
1889 len = entkerne_arg(buf, p, onlycmdp, '{', '}');
1890 }
1891 else
1892 {
1893 strcpy(buf, p);
1894 len = strlen(buf);
1895 if (forml != 'X') intern_err(3); /* unexpected forml in khvo */
1896 }
1897
1898 return len;
1899 }
1900
1901
1902 int innerentry(const char *p, const char *icmdlist[][2], const int num)
1903 {
1904 int l = 0;
1905
1906 while (l < num)
1907 {
1908 if (LaTeXcmp_endlen(p, icmdlist[l][0]) > 0) break;
1909 ++l;
1910 }
1911
1912 if (l >= num) l = -1;
1913 return l;
1914 }
1915
1916 #define DELSTARARG '='
1917 #define DELNORMARG '_'
1918
1919 int endofbracks(const char *p, const char fmt[])
1920 {
1921 int l = 0, len = 0, pos;
1922
1923 while (1)
1924 {
1925 if (fmt[l] == '\0' || fmt[l+1] == '\0' || fmt[l+2] == '\0') break;
1926
1927 while (*p == ' ') { ++p; ++len; }
1928 if (fmt[l] == '*' && *p != '*') { l += 3; continue; }
1929 if (fmt[l] == '*' && *p == '*') { ++p; ++len; }
1930 if (fmt[l] == DELSTARARG && *p != '*') { l += 3; continue; }
1931 if (fmt[l] == DELSTARARG && *p == '*') { ++p; ++len; }
1932 while (*p == ' ') { ++p; ++len; }
1933
1934 if ((pos=nextbracket(p, fmt[l+1], fmt[l+2])) > 1)
1935 {
1936 p += pos;
1937 len += pos;
1938 }
1939
1940 l += 3;
1941 }
1942
1943 return len;
1944 }
1945
1946
1947 void maxprint(int len, const char *s)
1948 {
1949 char buf[MAXLEN];
1950 int buflen = entkerne_IeC(buf, s);
1951
1952 if (len > 4 && buflen > len) printf("%.*s....", len-4, buf);
1953 else printf("%s", buf);
1954 }
1955
1956
1957 void print_msg_line(int line)
1958 {
1959 if (line < 0)
1960 {
1961 intern_err(39);
1962 }
1963 else
1964 {
1965 printf(" in *inner v-cmd*:\n%%%% ");
1966 maxprint(65, lineptr[line]);
1967 printf("\n");
1968 }
1969 }
1970
1971
1972 const char *innerVcmd[][2] = {
1973 { "\\printonlyvli\t", "+[]_{}:{}*{}!{}" },
1974 { "\\printonlyvqu\t", "+[]_{}:{}*{}!{}" },
1975 { "\\xprintonlyvli\t", "+[]_{}:{}*{}!{}" },
1976 { "\\xprintonlyvqu\t", "+[]_{}:{}*{}!{}" },
1977 { "\\vli\t", "+[]_{}:{}*{}!{}" }, /* wegen der */
1978 { "\\vqu\t", "+[]_{}:{}*{}!{}" }, /* Fehler- */
1979 { "\\xvli\t", "+[]_{}:{}*{}!{}" }, /* behandlung */
1980 { "\\xvqu\t", "+[]_{}:{}*{}!{}" }, /* von KTIT */
1981 { "\\shadowv\t", "_[]_{}_{}={}_{}" },
1982 { "\\addtovli\t", "_[]_{}_{}={}_{}" },
1983 { "\\addtovqu\t", "_[]_{}_{}={}_{}" },
1984 { "\\xaddtovli\t", "_[]_{}_{}={}_{}" },
1985 { "\\xaddtovqu\t", "_[]_{}_{}={}_{}" },
1986 { NULL, NULL }};
1987 const char *exkv[] = {
1988 "\\printonlykli",
1989 "\\printonlykqu",
1990 "\\xprintonlykli",
1991 "\\xprintonlykqu",
1992 "\\printonlykli",
1993 "\\printonlykqu",
1994 "\\xprintonlykli",
1995 "\\xprintonlykqu",
1996 "\\@shadowba{}",
1997 "\\@shadowba{}",
1998 "\\@shadowba{}",
1999 "\\@shadowba{}",
2000 "\\@shadowba{}",
2001 NULL };
2002 #define XVNUM 8
2003 #define AVNUM 13
2004
2005
2006 const char *starlist[][2] =
2007 {
2008 { "\\vauthor\t", ":{}:{}" },
2009 { "\\midvauthor\t", ":{}:{}" },
2010 { NULL, NULL }};
2011 const char *exlist[] =
2012 {
2013 "\\kauthor",
2014 "\\midkauthor",
2015 NULL
2016 };
2017 #define VKNUM 2
2018
2019
2020 #define INNERLASTARGNO 5
2021 #define INNERSTARARGNO 4
2022 #define INNERLNARGNO 3
2023 #define INNERFNARGNO 2
2024 #define INNEROPARGNO 1
2025
2026 int get_ktit(char oldktit[], const char *p, const char *com, const char op, const char cl, const int line, int found, const int argno)
2027 {
2028 int l, reallen, r = 0, ll, llen, b = 0, oldfound = found, invauthorfound = 0;
2029 char buf[MAXLEN], newktit[MAXLEN];
2030
2031
2032 while (*p != '\0')
2033 {
2034 if (*p == '\\')
2035 {
2036 if (*(p+1) == '\\')
2037 {
2038 buf[b++] = *p++; buf[b++] = *p++;
2039 }
2040 else
2041 if ((ll=innerentry(p, innerVcmd, AVNUM)) > -1)
2042 {
2043 /* inner-inner-v-cmd ueberspringen: dort darf weiteres \\ktit stehen */
2044 llen = LaTeXcmp_endlen(p, innerVcmd[ll][0]);
2045 p += llen;
2046 llen = endofbracks(p, innerVcmd[ll][1]);
2047 p += llen;
2048 buf[b++] = '<'; buf[b++] = '#'; buf[b++] = '>';
2049 }
2050 else
2051 if ((reallen = LaTeXcmp_endlen(p, com)) > 0)
2052 {
2053 while (reallen-- > 0) buf[b++] = *p++;
2054 ++found;
2055
2056 if (*p == '\0') break;
2057
2058 if ((l = nextbracket(p, op, cl)) > 0)
2059 {
2060 r = 0; /* <= Copy only arg of last \\ktit */
2061 if (l == 1)
2062 {
2063 newktit[r++] = op;
2064 newktit[r++] = *p; buf[b++] = *p++;
2065 newktit[r++] = cl;
2066 }
2067 else
2068 if (l == 2 && *p == '\\' && *(p+1) != '\0')
2069 {
2070 if (isLaTeXcmdletter(*(p+1)) == 0);
2071 else
2072 while (isLaTeXcmdletter(*(p+l)) != 0) ++l;
2073 newktit[r++] = op;
2074 while (l-- > 0) { newktit[r++] = *p; buf[b++] = *p++; }
2075 newktit[r++] = cl;
2076 }
2077 else
2078 {
2079 while (l-- > 0)
2080 {
2081 newktit[r++] = *p; buf[b++] = *p++;
2082 }
2083 }
2084 }
2085 }
2086 else buf[b++] = *p++;
2087 }
2088 else buf[b++] = *p++;
2089 }
2090
2091 newktit[r] = '\0';
2092 buf[b] = '\0';
2093
2094 if (strcmp(newktit, KTITINARG) == 0)
2095 {
2096 printf("%%%%\n%%%%> Error: %s follows %s", KTIT, KTIT);
2097 print_msg_line(line-1);
2098 inerr[line-1] += KTIT_DBL_ERR; /* new in 2.5 */
2099 }
2100
2101 if (r > 2 && newktit[r-1] == cl && newktit[r-2] == ' ')
2102 {
2103 l = 3;
2104 while (r-l > 1 && newktit[r-l] == ' ') ++l;
2105 while (r-l > 1 && isLaTeXcmdletter(newktit[r-l]) != 0) ++l;
2106 if (newktit[r-l] != '\\') print_not_tightly_err(newktit, cl);
2107 }
2108
2109
2110 if (newktit[0] == op)
2111 {
2112 l = 1; while (newktit[l] == ' ') ++l;
2113 if (newktit[l] == cl) newktit[0] = '\0'; /* new in 2.5 */
2114 }
2115
2116
2117 if (found > oldfound)
2118 {
2119 strcpy(oldktit, newktit);
2120 }
2121
2122
2123 if (argno == INNERLASTARGNO && oldktit[0] == '\0')
2124 {
2125 if ( strlen(KTITBEG)
2126 + strlen(KTITMISS)
2127 + strlen(KTITEMPTY)
2128 + strlen(KTITEND)
2129 > MAXLEN-2
2130 )
2131 {
2132 intern_err(29);
2133 }
2134 else
2135 {
2136 strcpy(oldktit, KTITBEG);
2137 printf("%%%%\n%%%%> ");
2138
2139
2140 if (found == 0)
2141 {
2142 printf("Error: Missing");
2143 strcat(oldktit, KTITMISS);
2144 inerr[line-1] += KTIT_MIS_ERR; /* new in 2.5 */
2145 }
2146 else
2147 {
2148 printf("Warning: Empty");
2149 strcat(oldktit, KTITEMPTY);
2150 inerr[line-1] += KTIT_EMP_ERR; /* new in 2.5 */
2151 }
2152
2153 printf(" %s", KTIT);
2154 print_msg_line(line-1);
2155 strcat(oldktit, KTITEND);
2156 }
2157 }
2158
2159
2160 if (argno == INNERLASTARGNO && found > 1)
2161 {
2162 printf("%%%%\n%%%%> Warning: %s used %d times", KTIT, found);
2163 print_msg_line(line-1);
2164 inerr[line-1] += KTIT_SEV_ERR; /* new in 2.5 */
2165 }
2166
2167
2168 return found;
2169 }
2170
2171
2172 void do_innerVstarArg(char ret[], const char *p)
2173 {
2174 int r = 0, l, len, end;
2175
2176
2177 strcpy(ret, p);
2178
2179 while (*p != '\0')
2180 {
2181 if (*p == '\\')
2182 {
2183 if (*(p+1) == '\\')
2184 {
2185 p += 2; r += 2;
2186 }
2187 else
2188 if ((l=innerentry(p, starlist, VKNUM)) > -1)
2189 {
2190 len = LaTeXcmp_endlen(p, starlist[l][0]);
2191 p += len;
2192 end = nextbracket(p, *(starlist[l][1]+1), *(starlist[l][1]+2));
2193 if (end == 2 && *p == '\\' && *(p+1) != '\0')
2194 {
2195 if (isLaTeXcmdletter(*(p+1)) == 0);
2196 else
2197 while (isLaTeXcmdletter(*(p+end)) != 0) ++end;
2198 }
2199 p += end;
2200 ret[r] = '\0';
2201 strcat(ret, exlist[l]);
2202 end = llstrlen(exlist[l]);
2203 r += end;
2204
2205 while (*p == ' ') ++p;
2206 end = nextbracket(p, *(starlist[l][1]+4), *(starlist[l][1]+5));
2207 if (end == 1)
2208 {
2209 ret[r++] = *(starlist[l][1]+4);
2210 ret[r++] = *p++;
2211 ret[r++] = *(starlist[l][1]+5);
2212 }
2213 else
2214 if (end == 2 && *p == '\\' && *(p+1) != '\0')
2215 {
2216 if (isLaTeXcmdletter(*(p+1)) == 0);
2217 else
2218 while (isLaTeXcmdletter(*(p+end)) != 0) ++end;
2219 ret[r++] = *(starlist[l][1]+4);
2220 while (end-- > 0) { ret[r++] = *p++; }
2221 ret[r++] = *(starlist[l][1]+5);
2222 while (*p == ' ') ++p;
2223 }
2224 else
2225 {
2226 while (end-- > 0)
2227 {
2228 ret[r++] = *p++;
2229 }
2230 }
2231 ret[r] = '\0';
2232 strcat(ret, p);
2233 }
2234 else
2235 {
2236 ++p; ++r;
2237 }
2238 }
2239 else
2240 {
2241 ++p; ++r;
2242 }
2243 }
2244 }
2245
2246
2247 #define OPTARG_FMT_UNDEF '\0'
2248
2249 int dobracks(char buf[], const char *p, const char fmt[], const int line)
2250 {
2251 int l = 0, len = 0, pos, i, found = 0, oldfound, optfound = 0;
2252 char ibuf[MAXLEN], obuf[MAXLEN], kbuf[MAXLEN], optarg_fmt = OPTARG_FMT_UNDEF;
2253
2254 buf[0] = '\0'; kbuf[0] = '\0';
2255
2256 while (1)
2257 {
2258 if (fmt[l] == '\0' || fmt[l+1] == '\0' || fmt[l+2] == '\0') break;
2259
2260 while (*p == ' ') { ++p; ++len; }
2261 if (fmt[l] == '*' && *p != '*') { l += 3; continue; }
2262 if (fmt[l] == '*' && *p == '*') { ++p; ++len; }
2263 if (fmt[l] == DELSTARARG && *p != '*') { l += 3; continue; }
2264 if (fmt[l] == DELSTARARG && *p == '*') { ++p; ++len; }
2265 while (*p == ' ') { ++p; ++len; }
2266
2267 if ((pos=nextbracket(p, fmt[l+1], fmt[l+2])) > 1)
2268 {
2269 if (fmt[l] == '+')
2270 {
2271 /* [OptArg] */
2272 oldfound = found;
2273 mystrncpy(ibuf, p, pos);
2274 found = get_ktit(kbuf, ibuf, KTITCMD, KTITOP, KTITCL, line, found, INNEROPARGNO);
2275 optfound = found;
2276
2277 if ( *(p+1) == 'p'
2278 || *(p+1) == 'm'
2279 || *(p+1) == 'f'
2280 || *(p+1) == ']'
2281 )
2282 {
2283 i = 2; while (*(p+i) == ' ') ++i;
2284 if (*(p+1) != ']' && oldfound == found && *(p+i) == '{')
2285 {
2286 optarg_fmt = *(p+1);
2287 }
2288 if (*(p+i) != '{' && *(p+i) != ']' && *(p+i) != '\0')
2289 {
2290 printf("%%%%\n%%%%> Error: ");
2291 maxprint(14, ibuf);
2292 printf(" without brackets like [%c{...}]", *(p+1));
2293 print_msg_line(line-1);
2294 inerr[line-1] += OARG_BRA_ERR; /* new in 2.5 */
2295 }
2296 }
2297 else
2298 {
2299 printf("%%%%\n%%%%> Error: ");
2300 maxprint(14, ibuf);
2301 printf(" begins with \'%c\' instead f/m/p", *(p+1));
2302 print_msg_line(line-1);
2303 inerr[line-1] += OARG_IRR_ERR; /* new in 2.5 */
2304 }
2305 found -= optfound;
2306 }
2307 else
2308 if (fmt[l] == '!')
2309 {
2310 /* {Rest} superior to fmt[l] == '*' */
2311 mystrncpy(ibuf, p, pos);
2312 found = get_ktit(kbuf, ibuf, KTITCMD, KTITOP, KTITCL, line, found, INNERLASTARGNO);
2313 strcat(buf, kbuf);
2314 }
2315 else
2316 if (fmt[l] == '*')
2317 {
2318 oldfound = found;
2319 mystrncpy(ibuf, p, pos);
2320 found = get_ktit(kbuf, ibuf, KTITCMD, KTITOP, KTITCL, line, found, INNERSTARARGNO);
2321 do_innerVstarArg(obuf, ibuf);
2322 strcat(buf, "*"); /* keep fmt[l] */
2323 strcat(buf, obuf);
2324 if (optfound == 0 && oldfound != found && optarg_fmt != OPTARG_FMT_UNDEF)
2325 {
2326 printf("%%%%\n%%%%> Error: [%c{..}] without %s overwrites %c{..%s..}", optarg_fmt, KTIT, fmt[l], KTIT);
2327 print_msg_line(line-1);
2328 inerr[line-1] += KTIT_OPE_ERR; /* new in 2.5 */
2329 }
2330 }
2331 else
2332 if (fmt[l] == DELNORMARG || fmt[l] == DELSTARARG)
2333 {
2334 mystrncpy(ibuf, p, pos);
2335 found = get_ktit(kbuf, ibuf, KTITCMD, KTITOP, KTITCL, line, found, INNERLNARGNO);
2336 }
2337 else
2338 {
2339 /* FN */
2340 mystrncpy(ibuf, p, pos);
2341 found = get_ktit(kbuf, ibuf, KTITCMD, KTITOP, KTITCL, line, found, INNERFNARGNO);
2342 strcat(buf, ibuf);
2343 }
2344
2345 p += pos;
2346 len += pos;
2347 }
2348
2349 l += 3;
2350 }
2351
2352 return len;
2353 }
2354
2355
2356 int do_innercmd(char ret[], const char *p, const char *icmdlist[][2], const int num, const char *form)
2357 {
2358 char buf[MAXLEN], cbuf[MAXLEN];
2359 int r = 0, l, len, end;
2360
2361 strcpy(ret, p);
2362
2363 while (*p != '\0')
2364 {
2365 if (*p == '\\')
2366 {
2367 if (*(p+1) == '\\')
2368 {
2369 p += 2; r += 2;
2370 }
2371 else
2372 if ((l=innerentry(p, icmdlist, num)) > -1)
2373 {
2374 len = LaTeXcmp_endlen(p, icmdlist[l][0]);
2375 p += len; r += len;
2376 end = endofbracks(p, icmdlist[l][1]);
2377 mystrncpy(buf, p, end);
2378 p += end;
2379 end = do_only(cbuf, form, buf);
2380 ret[r] = '\0';
2381 strncat(ret, cbuf, end);
2382 strcat(ret, p);
2383 r += end;
2384 }
2385 else
2386 {
2387 ++p; ++r;
2388 }
2389 }
2390 else
2391 {
2392 ++p; ++r;
2393 }
2394 }
2395
2396 return r;
2397 }
2398
2399
2400 int do_innerVcmd(char ret[], const char *p, const char *icmdlist[][2], const int num, const int line)
2401 {
2402 char buf[MAXLEN], cbuf[MAXLEN];
2403 const char *err = p;
2404 int l, len, end, pos = 0;
2405
2406 strcpy(ret, p);
2407
2408 while (*p != '\0')
2409 {
2410 if (*p == '\\')
2411 {
2412 if (*(p+1) == '\\')
2413 {
2414 p += 2; pos += 2;
2415 }
2416 else
2417 if ((l=innerentry(p, icmdlist, num)) > -1)
2418 {
2419 len = LaTeXcmp_endlen(p, icmdlist[l][0]);
2420 p += len;
2421 ret[pos] = '\0';
2422 if (strlen(ret) + strlen(exkv[l]) < MAXLEN)
2423 strcat(ret, exkv[l]); /* Exchange v-cmd => k-cmd; */
2424 else { intern_err(4); break; }
2425 pos += strlen(exkv[l]);
2426 end = dobracks(buf, p, icmdlist[l][1], line);
2427 p += end;
2428 if (strlen(ret) + strlen(buf) < MAXLEN)
2429 strcat(ret, buf);
2430 else { intern_err(5); break; }
2431 pos += strlen(buf);
2432 if (strlen(ret) + strlen(p) < MAXLEN)
2433 strcat(ret, p);
2434 else { intern_err(6); break; }
2435 }
2436 else
2437 {
2438 ++p; ++pos;
2439 }
2440 }
2441 else
2442 {
2443 ++p; ++pos;
2444 }
2445 }
2446
2447 return pos;
2448 }
2449
2450
2451 int do_only(char ret[], const char form[], const char in[])
2452 {
2453 int l = 0, len = 0;
2454 char buf[MAXLEN];
2455 const char *onlycmd[] = { "\\onlykurz\t",
2456 "\\onlyhere\t",
2457 "\\onlyvoll\t",
2458 "\\onlyout\t",
2459 KTITCMD,
2460 NULL
2461 };
2462 #define KHVONUM 5 /* KTITCMD added in 2.5 */
2463
2464
2465 if (form[0] == '\0' || strlen(form) != KHVONUM)
2466 {
2467 intern_err(7); /* len of khvo */
2468 strcpy(ret, in);
2469 len = strlen(ret);
2470 }
2471 else
2472 {
2473 len = form_only(buf, form[l], onlycmd[l], in);
2474 ++l;
2475 if (l == KHVONUM) strcpy(ret, buf);
2476
2477 while (l < KHVONUM)
2478 {
2479 len = form_only(ret, form[l], onlycmd[l], buf);
2480 ++l;
2481 if (l == KHVONUM) break;
2482
2483 len = form_only(buf, form[l], onlycmd[l], ret);
2484 ++l;
2485 if (l == KHVONUM) strcpy(ret, buf);
2486 }
2487 }
2488
2489 return len;
2490 }
2491
2492
2493 /*--------------------------------------------------------------------------*/
2494
2495
2496 char *standardnum(char a[], char *p)
2497 {
2498 int j, beforenum = 0;
2499 char *top = p;
2500
2501 j = 0; while (j < NUMLEN-1) a[j++] = '0'; a[j] = '\0';
2502
2503 while (beforenum < NUMLEN-1 && isdigit(*p) != 0)
2504 {
2505 j = 1; while (j < NUMLEN-1) { a[j-1] = a[j]; ++j; }
2506 a[NUMLEN-2] = *p;
2507 ++beforenum;
2508 ++p;
2509
2510 if (german == 0)
2511 {
2512 if ((*p == ',' || *p == ' ') && isdigit(*(p+1)) != 0 && isdigit(*(p+2)) != 0 && isdigit(*(p+3)) != 0 && isdigit(*(p+4)) == 0) ++p;
2513 }
2514 else
2515 {
2516 if ((*p == '.' || *p == ' ') && isdigit(*(p+1)) != 0 && isdigit(*(p+2)) != 0 && isdigit(*(p+3)) != 0 && isdigit(*(p+4)) == 0) ++p;
2517 }
2518 }
2519
2520 if (german == 0)
2521 {
2522 if (*p == '.' && isdigit(*(p+1)) != 0)
2523 {
2524 j = NUMLEN-1; while (j < 2*NUMLEN-1 && isdigit(*(p+1)) != 0) { ++p; a[j++] = *p; }
2525 ++p; a[j] = '\0';
2526 }
2527 }
2528 else
2529 {
2530 if (*p == ',' && isdigit(*(p+1)) != 0)
2531 {
2532 j = NUMLEN-1; while (j < 2*NUMLEN-1 && isdigit(*(p+1)) != 0) { ++p; a[j++] = *p; }
2533 ++p; a[j] = '\0';
2534 }
2535 }
2536
2537 if (isdigit(*p) != 0)
2538 {
2539 printf("%%%%\n%%%%> Warning: Can\'t sort too long number \"%.*s...\".\n", 30, top);
2540 while (isdigit(*p) != 0) ++p;
2541 }
2542
2543 return p;
2544 }
2545
2546
2547 int isLaTeXcmdletter(char a)
2548 {
2549 if (isalpha(a) != 0 || a == '@')
2550 return 1;
2551 return 0;
2552 }
2553
2554
2555 char *setptrtofirstbracket(char *p)
2556 {
2557 while (*p != '\0')
2558 {
2559 if (*p == '\\' && *(p+1) != '\0') ++p;
2560 ++p;
2561 if (*p == '{') break;
2562 }
2563 return p;
2564 }
2565
2566
2567 void ignoreadditionaltext(const char *p, const char *i, const char *f)
2568 {
2569 int ll;
2570
2571 while(*p == ' ') ++p;
2572 if (*p != '\0' && *p != '%')
2573 {
2574 if (strlen(i) > 58)
2575 ll = 0;
2576 else ll = 58 - strlen(i);
2577 printf("%%%%\n%%%%> Warning: Ignore additional text \"%.*s\"\n", 40, p);
2578 printf("%%%% after \"%s\" -> \"%.*s\".\n", i, ll, f);
2579 if (*p == '\\')
2580 printf("%%%% ** I grap only one \\cmd per line! Fix that, and start me again! **\n");
2581 }
2582 }
2583
2584
2585 void telldefault(int rest)
2586 {
2587 printf("%%%% ** Missing %d argument(s). The \'%%\' remains in my output.\n", rest);
2588 }
2589
2590
2591 const char *inner_K_cmd[][2] = {
2592 { "\\printonlykli\t", ":[]:{}*{}:{}" },
2593 { "\\printonlykqu\t", ":[]:{}*{}:{}" },
2594 { "\\xprintonlykli\t", ":[]:{}*{}:{}" },
2595 { "\\xprintonlykqu\t", ":[]:{}*{}:{}" },
2596 { "\\printonlyper\t", ":{}" },
2597 { "\\printonlyarq\t", ":[]:{}:{}" },
2598 { NULL, NULL }};
2599 #define INNERTITLES 4 /* 6 changed to 4 in 2.5 */
2600
2601 const char *inner_PER_ARQ_ABK_cmd[][2] = {
2602 { "\\printonlyper\t", ":{}" },
2603 { "\\printonlyarq\t", ":[]:{}:{}" },
2604 { "\\printonlydefabk\t", ":{}:{}" },
2605 { "\\printonlyabkdef\t", ":{}:{}" },
2606 { "\\printonlyabk\t", ":{}" },
2607 { NULL, NULL }};
2608 #define INNERPAA 5 /* new in 2.5 */
2609
2610
2611 int do_inneronly(char ret[], const char in[], const char *vf, const char *kf, const char *paaf)
2612 {
2613 char buf[MAXLEN];
2614 int len;
2615
2616 len = do_innercmd(buf, in, innerVcmd, XVNUM, vf); /* AVNUM unnecessary */
2617 len = do_innercmd(ret, buf, inner_K_cmd, INNERTITLES, kf); /* 2.5: XKPANUM changed to INNERTITLES */
2618 len = do_innercmd(buf, ret, inner_PER_ARQ_ABK_cmd, INNERPAA, paaf); /* new in 2.5 */
2619 strcpy(ret, buf); /* new in 2.5 */
2620
2621 return len;
2622 }
2623
2624
2625 char *makeAR(char *p, int cols, int rest, char bb, char eb, const char *ident, int linec, int i, char schalt, const char *formO, int ventry)
2626 {
2627 int len, alen;
2628 char ibuf[MAXLEN], cbuf[MAXLEN];
2629
2630 while (*p == ' ') ++p;
2631
2632 if (*p != bb)
2633 { printf("%%%%\n%%%%> %s error in arg %d: Missing \'%c\'.\n", ident, i+cols, bb);
2634 telldefault(rest-i);
2635 return NULL;
2636 }
2637 else
2638 {
2639 if ((len = nextbracket(p, bb, eb)) < 0)
2640 { printf("%%%%\n%%%%> %s error in arg %d: Missing \'%c\' after \"%.*s\".\n", ident, i+cols, eb, -len, p);
2641 telldefault(rest-i);
2642 return NULL;
2643 }
2644
2645 if (schalt == 'A')
2646 {
2647 /* new in 2.2: Evaluate inner v-cmds in rest of v-cmds as k-cmds! */
2648 if (ventry != IS_V && i == VCOLS-1)
2649 {
2650 /* alloc {li} or {qu} as 4th arg of k-cmds: */
2651 alen = mystrncpy(cbuf, p, len);
2652 }
2653 else
2654 {
2655 mystrncpy(cbuf, p, len);
2656
2657 /* new in 2.5 for k-cmds: "elleX": */
2658 /* changed in 2.5: "eell" to "eeXXX" */
2659
2660 if (ventry == IS_V) /* MARKX */
2661 {
2662 alen = do_inneronly(ibuf, cbuf, "eeXXX", "elleX", "leelX");
2663 }
2664 else /* new in 2.5: ventry == NO_V || ventry == IS_Q */
2665 {
2666 alen = do_inneronly(ibuf, cbuf, "leelX", "elleX", "leelX");
2667 }
2668 /* moved in 2.5: do_only */
2669
2670 if (ventry == IS_V && i == VCOLS-1)
2671 {
2672 alen = do_innerVcmd(cbuf, ibuf, innerVcmd, AVNUM, linec+1);
2673 }
2674 else
2675 {
2676 strcpy(cbuf, ibuf);
2677 }
2678
2679 /* get_add_ktit del in 2.5 */
2680
2681 if (ventry == IS_V) /* MARKX */
2682 {
2683 /* inner v-cmds are k-cmds here / new in 2.5: */
2684 /* e == \ktit{x} => x */
2685 alen = do_innercmd(ibuf, cbuf, inner_K_cmd, INNERTITLES, "XXlle");
2686 }
2687 else
2688 {
2689 strcpy(ibuf, cbuf);
2690 }
2691
2692 alen = do_only(cbuf, formO, ibuf);
2693 }
2694
2695 subAptr[i][linec] = fillsubAptr(cbuf, alen, eb);
2696 }
2697 else
2698 if (schalt == 'R') subRptr[i][linec] = strnmalloc(p+1, len-1);
2699 else intern_err(8); /* INTERNAL ERROR (A, R) */
2700
2701 p += len;
2702 }
2703
2704 return p;
2705 }
2706
2707
2708 void dodqdeepsort(int linec, int alllines, int deepsort)
2709 {
2710 int num;
2711
2712 while(linec < alllines)
2713 {
2714 if ( nogsty == 0
2715 && userusesdq(deepsort, linec) == 1
2716 && (num = getarabicnum(subRptr[DQCOL][linec])) >= MINCATCODE
2717 && num <= MAXCATCODE
2718 ) dqsort[linec] = num;
2719 else dqsort[linec] = ERRCATCODE;
2720 ++linec;
2721 }
2722 }
2723
2724
2725 void dopgfntnumberweight(int linec, int alllines)
2726 {
2727 while(linec < alllines)
2728 {
2729 pagewgt[linec] = pgnumberweight(subRptr[PAGECOL][linec]);
2730 fntwgt[linec] = fntnumberweight(subRptr[FNTCOL][linec]);
2731 ++linec;
2732 }
2733 }
2734
2735
2736 int over_fonts(char *p, int start)
2737 {
2738 int i, l, neu = 0;
2739
2740 const char *fonts[] =
2741 {
2742 NEWFNSYMBOL, /* start == 0 : footnote = $^{x}$ */
2743 "\\rmfamily", /* start == 1 : else = text mode */
2744 "\\sffamily",
2745 "\\ttfamily",
2746 "\\mdseries",
2747 "\\bfseries",
2748 "\\upshape",
2749 "\\itshape",
2750 "\\slshape",
2751 "\\scshape",
2752 "\\em",
2753 "\\normalfont",
2754 "\\textrm",
2755 "\\rm",
2756 "\\textsf",
2757 "\\sf",
2758 "\\texttt",
2759 "\\tt",
2760 "\\textmd",
2761 "\\textbf",
2762 "\\bf",
2763 "\\textup",
2764 "\\textit",
2765 "\\it",
2766 "\\textsl",
2767 "\\sl",
2768 "\\textsc",
2769 "\\sc",
2770 "\\emph",
2771 "\\textnormal",
2772 "\\bapageframe",
2773 "\\pbapageframe",
2774 "\\bafootnoteframe",
2775 "\\pbafootnoteframe",
2776 RELAX,
2777 NULL,
2778 };
2779 #define FONTC 35
2780
2781
2782 while(*p == '{' && *(p+1) == '}')
2783 {
2784 p += 2; neu += 2;
2785 while (*p == ' ') { ++p; ++neu; }
2786 }
2787
2788
2789 while(*p == '\\')
2790 {
2791 i = start;
2792 l = 0;
2793 while (i < FONTC && lcmdcmp(p, fonts[i]) != 0) ++i;
2794 if( (i < FONTC && lcmdcmp(p, fonts[i]) == 0 && (l=strlen(fonts[i])) > 0)
2795 || (start == 0 && (l=len_tom(p)) > 0)
2796 )
2797 {
2798 p+=l;
2799 neu+=l;
2800 while (*p == ' ') { ++p; ++neu; }
2801 }
2802 else if (l == 0) break;
2803 }
2804
2805 return neu;
2806 }
2807
2808
2809
2810 void set_inner_number_on_subRptr(char *p, int len, int col, int line, int start)
2811 {
2812 int neu;
2813
2814 /* start==0: in $^{x}$ kein \ensuremath oder \TextOrMath noetig! */
2815 neu = over_fonts(p, start);
2816 len -= neu;
2817 p += neu;
2818
2819 while (*p == '{' && len > 2 && nextbracket(p, '{', '}') == len-1)
2820 {
2821 ++p; len -= 2;
2822
2823 while (*p == ' ') { ++p; --len; }
2824
2825 neu = over_fonts(p, start);
2826 len -= neu;
2827 p += neu;
2828 }
2829
2830 subRptr[col][line] = strnmalloc(p, len);
2831 }
2832
2833
2834 void getbrackets(int linec, int alllines, const char *ident, int deep, int filenum, const char *formO, int ventry)
2835 {
2836 char *p, buf[MAXLEN];
2837 int len, i;
2838
2839 while(linec < alllines)
2840 {
2841 i = 0; while (i < MAXBACOLS) subAptr[i++][linec] = mydefault;
2842 i = 0; while (i < BAALLRCOLS) subRptr[i++][linec] = mydefault;
2843 leval[linec] = ACCEPTLINE;
2844 inerr[linec] = NOINERR; /* new in 2.5 */
2845
2846 p = lineptr[linec];
2847 p = setptrtofirstbracket(p);
2848
2849 i = 0;
2850 while (i < deep)
2851 {
2852 if ((p = makeAR(p, 1, deep+BARESTCOLS, '{', '}', ident, linec, i, 'A', formO, ventry)) == NULL)
2853 {
2854 leval[linec] = REJECTLINE;
2855 break;
2856 }
2857 ++i;
2858 }
2859
2860 if (i == deep)
2861 {
2862 i = 0;
2863 while (i < BARESTCOLS)
2864 {
2865 if ((p = makeAR(p, BARESTCOLS, BARESTCOLS, bareststr[2*i], bareststr[2*i+1], ident, linec, i, 'R', "", ventry)) == NULL)
2866 {
2867 leval[linec] = REJECTLINE;
2868 break;
2869 }
2870 ++i;
2871 }
2872 if (p != NULL) ignoreadditionaltext(p, ident, subAptr[0][linec]);
2873
2874 p = subRptr[PAGEFNTCOL][linec];
2875 while (*p == ' ') ++p;
2876 if (*p == '{' && (len = nextbracket(p, '{', '}')) > 1)
2877 {
2878 while (*(p+1) == ' ') { ++p; --len; }
2879
2880 set_inner_number_on_subRptr(p+1, len-1, PAGECOL, linec, 1);
2881
2882 p += len;
2883 while (*p == ' ') ++p;
2884 if (*p == '{' && (len = nextbracket(p, '{', '}')) > 1)
2885 {
2886 while (*(p+1) == ' ') { ++p; --len; }
2887
2888 set_inner_number_on_subRptr(p+1, len-1, FNTCOL, linec, 0);
2889
2890 p += len;
2891 while (*p == ' ') ++p;
2892 if (*p == '{' && (len = nextbracket(p, '{', '}')) > 1)
2893 {
2894 while (*(p+1) == ' ') { ++p; --len; }
2895 if (*(p+1) == HASUNUCH)
2896 {
2897 myfree(subRptr[PAGECOL][linec]);
2898 subRptr[PAGECOL][linec] = unused; /* UNUSED */
2899 }
2900 if (*(p+1) != HASFNTCH)
2901 {
2902 if (*subRptr[FNTCOL][linec] != '\0')
2903 printf("%%%%\n%%%%> Warning: Ignore unexpected FNT-num \"%s\".\n", subRptr[FNTCOL][linec]);
2904 myfree(subRptr[FNTCOL][linec]);
2905 subRptr[FNTCOL][linec] = nofnt; /* NOFOOTNOTE */
2906 }
2907 if (*(p+1) != '}' && *(p+1) != HASFNTCH && *(p+1) != HASUNUCH)
2908 { printf("%%%%\n%%%%> %s warning (part 3 of arg %d):\n", ident, deep+2);
2909 printf("%%%% Get no {} or {%c} or {%c}!\n", HASFNTCH, HASUNUCH);
2910 }
2911 p += len;
2912 while (*p == ' ') ++p;
2913 if (*p != '\0')
2914 { printf("%%%%\n%%%%> %s warning (parts of arg %d):\n", ident, deep+2);
2915 printf("%%%% Unexpected text after {page}{footnote}{} number!\n");
2916 }
2917 }
2918 else
2919 { printf("%%%%\n%%%%> %s warning (part 3 of arg %d):\n", ident, deep+2);
2920 printf("%%%% Get no {} or {%c}!\n", HASFNTCH);
2921 }
2922 }
2923 else
2924 { printf("%%%%\n%%%%> %s warning (part 2 of arg %d):\n", ident, deep+2);
2925 printf("%%%% Get no {footnote} number!\n");
2926 }
2927 }
2928 else
2929 { printf("%%%%\n%%%%> %s warning (all 3 parts of arg %d):\n", ident, deep+2);
2930 printf("%%%% Get no {page}{footnote}{} number!\n");
2931 }
2932 }
2933
2934 if (filenum > -1)
2935 {
2936 sprintf(buf, "file %d ", filenum);
2937
2938 if (firstoverlettergan(subRptr[LINECOL][linec]) > 0)
2939 {
2940 strncat(buf, subRptr[LINECOL][linec], MAXLEN-strlen(buf)-strlen(subRptr[LINECOL][linec])-1);
2941 }
2942 else
2943 {
2944 printf("%%%%\n%%%%> %s error in last arg: No line-number!\n", ident);
2945 strncat(buf, ERRINPUTLINENO, MAXLEN-strlen(buf)-ERRINPUTLINENOLEN-1);
2946 }
2947
2948 myfree(subRptr[LINECOL][linec]);
2949 subRptr[LINECOL][linec] = strnmalloc(buf, strlen(buf)+1);
2950 }
2951
2952 ++linec;
2953 }
2954 }
2955
2956
2957 /* Accents \b \c \k \d \H \t have no equivalent in MathMode. */
2958 /* 2.3: control-characters are now doublettes (CTL+G or [Esc] added). */
2959 /* 2.5: \t added behind \\. \\\' \\` \\^ \\= \\~ ( \.X = \. X ).
2960 I sort \a. \a' \a` \a^ \a"X \a= \a~ and
2961 \a{r} \a{b} \a{c} \a{k} \a{d} \a{H} \a{t} \a{u} \a{v}
2962 as     X ... ;
2963 other \protect\a X will EXECUTE/PRINT \X , BUT will be
2964 SORTED as X (e.g. \protect\a{textdollar} as textdollar).
2965 */
2966 const char *weighttable[][2] = {
2967 { "\\.\t", "" }, /* CTL+A + Ctl+G */ /* MARK_POINT */
2968 { "\\@tabacckludge\t.\t", "" }, /* new in 2.5 */
2969 { "\\a\t.\t", "" }, /* new in 2.5 */
2970 { "\\dot\t", "" },
2971 { "\\capitaldotaccent\t", "" }, /* new in 2.5 = \. */
2972 { "\\\'\t", "" }, /* CTL+B */
2973 { "\\@tabacckludge\t\'\t", "" }, /* new in 2.3, changed in 2.5 */
2974 { "\\a\t\'\t", "" }, /* new in 2.3, changed in 2.5 */
2975 { "\\acute\t", "" },
2976 { "\\capitalacute\t", "" }, /* new in 2.5 = \@tabacckludge' */
2977 { "\\`\t", "" }, /* CTL+C */
2978 { "\\@tabacckludge\t`\t", "" }, /* new in 2.3, changed in 2.5 */
2979 { "\\a\t`\t", "" }, /* new in 2.3, changed in 2.5 */
2980 { "\\grave\t", "" },
2981 { "\\capitalgrave\t", "" }, /* new in 2.5 = \@tabacckludge` */
2982 { "\\^\t", "" }, /* CTL+D */
2983 { "\\@tabacckludge\t^\t", "" }, /* new in 2.5 */
2984 { "\\a\t^\t", "" }, /* new in 2.5 */
2985 { "\\hat\t", "" },
2986 { "\\capitalcircumflex\t", "" }, /* new in 2.5 = \^ */
2987 { "\\ddot\t", "" }, /* CTL+E math-dieresis != umlaut */
2988 { "\\=\t", "" }, /* CTL+F */
2989 { "\\@tabacckludge\t=\t", "" }, /* new in 2.3, changed in 2.5 */
2990 { "\\a\t=\t", "" }, /* new in 2.3, changed in 2.5 */
2991 { "\\bar\t", "" },
2992 { "\\capitalmacron\t", "" }, /* new in 2.5 = \@tabacckludge= */
2993 { "\\vec\t", "" }, /* CTL+F + [ESC] changed in 2.3 */
2994 { "\\~\t", " " }, /* CTL+K */ /* MARK_TILDE */
2995 { "\\@tabacckludge\t~\t", " " }, /* new in 2.5 */
2996 { "\\a\t~\t", " " }, /* new in 2.5 */
2997 { "\\tilde\t", " " },
2998 { "\\capitaltilde\t", " " }, /* new in 2.5 = \~ */
2999 { "\\aa\t", " a" }, /* CTL+L */ /* \\r a \\r A */
3000 { "\\AA\t", " A" },
3001 { "\\r\t", " " }, /* \\AA \\aa */
3002 { "\\@tabacckludge\tr\t", " " }, /* new in 2.5 */
3003 { "\\a\tr\t", " " }, /* new in 2.5 */
3004 { "\\mathring\t", " " },
3005 { "\\capitalring\t", " " }, /* new in 2.5 = \r */
3006 { "\\b\t", "" }, /* CTL+N */
3007 { "\\@tabacckludge\tb\t", "" }, /* new in 2.5 */
3008 { "\\a\tb\t", "" }, /* new in 2.5 */
3009 { "\\c\t", "" }, /* CTL+O + CTL+G */
3010 { "\\@tabacckludge\tc\t", "" }, /* new in 2.5 */
3011 { "\\a\tc\t", "" }, /* new in 2.5 */
3012 { "\\capitalcedilla\t", "" }, /* new in 2.5 = \c */
3013 { "\\textcommabelow\t", "" }, /* CTL+O + [ESC] new in 2.3 */
3014 { "\\textogonekcentered\t","" }, /* new in 2.5 = \k */
3015 { "\\capitalogonek\t", "" }, /* new in 2.5 = \k */
3016 { "\\k\t", "" }, /* CTL+P */ /* rechte Tilde */
3017 { "\\@tabacckludge\tk\t", "" }, /* new in 2.5 */
3018 { "\\a\tk\t", "" }, /* new in 2.5 */
3019 { "\\d\t", "" }, /* CTL+Q */
3020 { "\\@tabacckludge\td\t", "" }, /* new in 2.5 */
3021 { "\\a\td\t", "" }, /* new in 2.5 */
3022 { "\\H\t", "" }, /* CTL+R */
3023 { "\\@tabacckludge\tH\t", "" }, /* new in 2.5 */
3024 { "\\a\tH\t", "" }, /* new in 2.5 */
3025 { "\\capitalhungarumlaut\t","" }, /* new in 2.5 = \H */
3026 { "\\newtie\t", "" }, /* new in 2.5 = \t */
3027 { "\\capitalnewtie\t", "" }, /* new in 2.5 = \t */
3028 { "\\t\t", "" }, /* CTL+S */
3029 { "\\@tabacckludge\tt\t", "" }, /* new in 2.5 */
3030 { "\\a\tt\t", "" }, /* new in 2.5 */
3031 { "\\capitaltie\t", "" }, /* new in 2.5 = \t */
3032 { "\\u\t", "" }, /* CTL+T */
3033 { "\\@tabacckludge\tu\t", "" }, /* new in 2.5 */
3034 { "\\a\tu\t", "" }, /* new in 2.5 */
3035 { "\\breve\t", "" },
3036 { "\\capitalbreve\t", "" }, /* new in 2.5 = \u */
3037 { "\\v\t", "" }, /* changed in 2.3 */
3038 { "\\@tabacckludge\tv\t", "" }, /* new in 2.5 */
3039 { "\\a\tv\t", "" }, /* new in 2.5 */
3040 { "\\check\t", "" }, /* changed in 2.3 */
3041 { "\\capitalcaron\t", "" }, /* new in 2.5 = \v */
3042 { "\\textblank\t", "b" }, /* CTL+U \ new in 2.3; */
3043 { "\\textbaht\t", "B" }, /* | new in 2.3 */
3044 { "\\textcent\t", "c" }, /* S | changed in 2.3 */
3045 { "\\textcentoldstyle\t", "c" }, /* T | changed in 2.3 */
3046 { "\\textcolonmonetary\t", "C" }, /* R | new in 2.3 */
3047 { "\\dj\t", "d" }, /* 0 | changed in 2.3 */
3048 { "\\dh\t", "d" }, /* K | changed in 2.3 (! \textsc{\dh} is like \DH) */
3049 { "\\DJ\t", "D" }, /* E | changed in 2.3 */
3050 { "\\DH\t", "D" }, /* =\\DJ | changed in 2.3 */
3051 { "\\hbar\t", "h" }, /* h-quer | new in 2.3 */
3052 { "\\l\t", "l" }, /* | changed in 2.3 */
3053 { "\\L\t", "L" }, /* S | changed in 2.3 */
3054 { "\\textnaira\t", "N" }, /* T | new in 2.3 */
3055 { "\\o\t", "o" }, /* R | changed in 2.3 */
3056 { "\\O\t", "O" }, /* O | changed in 2.3 */
3057 { "\\textrecipe\t", "R" }, /* K | new in 2.3 */
3058 { "\\textpeso\t", "P" }, /* E | new in 2.3 */
3059 { "\\textwon\t", "W" }, /* | changed in 2.3 */
3060 { "\\textyen\t", "Y" }, /* / changed in 2.3 */
3061 { "\\st\t", "" }, /* CTL+V */ /* NEW in 2.2 */
3062 { "\\textst\t", "" }, /* NEW in 2.2 */
3063 { "\\underbar\t", "" }, /* CTL+W + CTL+G */
3064 { "\\underline\t", "" }, /* CTL+W + [ESC] changed in 2.3 */
3065 { "\\ul\t", "" }, /* changed in 2.3 */
3066 { "\\textul\t", "" }, /* changed in 2.3; NEW in 2.2 */
3067 { "\\,", " " },
3068 { "\\space\t", " " }, /* if you say \protect\space */
3069 { "\\nobreakspace\t", " " }, /* new in 2.3 */ /* MARK_TILDE */
3070 { "\\textvisiblespace\t", " " }, /* new in 2.3 */
3071 { "\\teskip\t", " " }, /* new in 2.3 */
3072 { "\\pteskip\t", " " }, /* 1\te 000 NEW in 2.2 */
3073 { "\\te\t", ". " }, /* != 1000 NEW in 2.2 */
3074 { "\\textflorin\t", "f" }, /* changed in 2.3 */
3075 { "\\i\t", "i" },
3076 { "\\imath\t", "i" },
3077 { "\\j\t", "j" },
3078 { "\\jmath\t", "j" },
3079 { "\\ae\t", "ae" }, /* \ changed in 2.3 */
3080 { "\\AE\t", "Ae" }, /* | <=> \\Oe changed in 2.3 */
3081 { "\\BibArts\t", "BibArts" }, /* | changed in 2.3 */
3082 { "\\pBibArts\t", "BibArts" }, /* | changed in 2.3 */
3083 { "\\textdong\t", "d" }, /* CTL_X new in 2.3 (not really \\b{\\dj}) */
3084 { "\\textestimated\t", "e" }, /* | new in 2.3 */
3085 { "\\ell\t", "l" }, /* | changed in 2.3 */
3086 { "\\ij\t", "i" }, /* | changed in 2.3 */
3087 { "\\IJ\t", "I" }, /* | changed in 2.3 */
3088 { "\\Im\t", "I" }, /* | <=> \\Re */
3089 { "\\LaTeX\t", "LaTeX" }, /* | changed in 2.3 */
3090 { "\\textnumero\t", "N" }, /* | new in 2.3 */
3091 { "\\oe\t", "oe" }, /* | changed in 2.3 */
3092 { "\\OE\t", "Oe" }, /* | changed in 2.3 */
3093 { "\\TeX\t", "TeX" }, /* / changed in 2.3 */
3094 { "\\textdollaroldstyle\t","D" }, /* \ new in 2.5 */
3095 { "\\texteuro\t", "E" }, /* | */
3096 { "\\textlira\t", "L" }, /* | new in 2.3 */
3097 { "\\ng\t", "n" }, /* | changed in 2.3 */
3098 { "\\NG\t", "N" }, /* CTL_Y changed in 2.3 */
3099 { "\\textsterling\t", "P" }, /* | changed in 2.3 */
3100 { "\\ppounds\t", "P" }, /* | changed in 2.3 */
3101 { "\\pounds\t", "P" }, /* | changed in 2.3 */
3102 { "\\mathsterling\t", "P" }, /* | new in 2.5 */
3103 { "\\th\t", "th" }, /* | */
3104 { "\\Re\t", "R" }, /* | <=> \\Im */
3105 { "\\TH\t", "Th" }, /* / */
3106 { "\\copyright\t", "C" }, /* \ */
3107 { "\\textcopyright\t", "C" }, /* | siehe */
3108 { "\\pcopyright\t", "C" }, /* | \\ss */
3109 { "\\textcircledP\t", "P" }, /* | = ss */
3110 { "\\textregistered\t", "R" }, /* / */
3111 { "\\textcelsius\t", "C" }, /* \ changed in 2.5 */
3112 { "\\textdegree\t", "" }, /* / DEG{X} new in 2.5 */
3113 { "\\alpha\t", "a" }, /* 28 */
3114 { "\\Alpha\t", "A" }, /* bibarts.sty; new in 2.1 */
3115 { "\\beta\t", "b" },
3116 { "\\Beta\t", "B" }, /* bibarts.sty; new in 2.1 */
3117 { "\\chi\t", "ch" },
3118 { "\\Chi\t", "Ch" }, /* bibarts.sty; new in 2.1 */
3119 { "\\delta\t", "d" },
3120 { "\\Delta\t", "D" },
3121 { "\\epsilon\t", "e" },
3122 { "\\Epsilon\t", "E" }, /* bibarts.sty; new in 2.1 */
3123 { "\\varepsilon\t", "e" }, /* changed in 2.3 */
3124 { "\\eta\t", "e" }, /* 29 */
3125 { "\\Eta\t", "E" }, /* bibarts.sty; new in 2.1 */
3126 { "\\gamma\t", "g" },
3127 { "\\Gamma\t", "G" },
3128 { "\\iota\t", "i" },
3129 { "\\Iota\t", "I" }, /* bibarts.sty; new in 2.1 */
3130 { "\\kappa\t", "k" },
3131 { "\\Kappa\t", "K" }, /* bibarts.sty; new in 2.1 */
3132 { "\\varkappa\t", "k" }, /* changed in 2.3 */
3133 { "\\lambda\t", "l" },
3134 { "\\Lambda\t", "L" },
3135 { "\\mu\t", "m" },
3136 { "\\textmu\t", "m" }, /* new in 2.3 */
3137 { "\\Mu\t", "M" }, /* bibarts.sty; new in 2.1 */
3138 { "\\nu\t", "n" },
3139 { "\\Nu\t", "N" }, /* bibarts.sty; new in 2.1 */
3140 { "\\omicron\t", "o" }, /* bibarts.sty */
3141 { "\\Omicron\t", "O" }, /* bibarts.sty; new in 2.1 */
3142 { "\\omega\t", "o" }, /* changed in 2.3 */
3143 { "\\Omega\t", "O" }, /* changed in 2.3 */
3144 { "\\textohm\t", "O" }, /* new in 2.3 */
3145 { "\\textmho\t", "O" }, /* new in 2.3 */
3146 { "\\pi\t", "p" },
3147 { "\\Pi\t", "P" },
3148 { "\\varpi\t", "p" }, /* changed in 2.3 */
3149 { "\\phi\t", "ph" }, /* changed in 2.3 */
3150 { "\\Phi\t", "Ph" }, /* changed in 2.3 */
3151 { "\\varphi\t", "ph" }, /* changed in 2.3 */
3152 { "\\psi\t", "ps" }, /* 30 */ /* changed in 2.3 */
3153 { "\\Psi\t", "Ps" }, /* changed in 2.3 */
3154 { "\\rho\t", "r" },
3155 { "\\Rho\t", "R" }, /* bibarts.sty; new in 2.1 */
3156 { "\\varrho\t", "r" }, /* changed in 2.3 */
3157 { "\\sigma\t", "s" },
3158 { "\\Sigma\t", "S" },
3159 { "\\varsigma\t", "s" }, /* changed in 2.3 */
3160 { "\\tau\t", "t" },
3161 { "\\Tau\t", "T" }, /* bibarts.sty; new in 2.1 */
3162 { "\\theta\t", "th" }, /* changed in 2.3 */
3163 { "\\Theta\t", "Th" }, /* changed in 2.3 */
3164 { "\\vartheta\t", "th" }, /* changed in 2.3 */
3165 { "\\xi\t", "x" },
3166 { "\\Xi\t", "X" },
3167 { "\\upsilon\t", "y" },
3168 { "\\Upsilon\t", "Y" },
3169 { "\\zeta\t", "z" },
3170 { "\\Zeta\t", "Z" }, /* bibarts.sty; new in 2.1 */
3171 { "\\textendash\t", "--" }, /* new in 2.3 */
3172 { "\\textemdash\t", "---" }, /* new in 2.3 */
3173 { "\\textellipsis\t", "..." }, /* new in 2.3 "-p" */
3174 { "\\dots\t", "..." }, /* new in 2.3 "-p" */
3175 { "\\textonesuperior\t", "{1} " }, /* new in 2.3 */
3176 { "\\texttwosuperior\t", "{2} " }, /* new in 2.3 */
3177 { "\\textthreesuperior\t", "{3} " }, /* new in 2.3 */
3178 { "\\textonequarter\t", "{1} {4} " }, /* new in 2.3 */
3179 { "\\textonehalf\t", "{1} {2} " }, /* new in 2.3 */
3180 { "\\textthreequarters\t", "{3} {4} " }, /* new in 2.3 */
3181 { "\\textoneoldstyle\t", "1" }, /* new in 2.3 */
3182 { "\\texttwooldstyle\t", "2" }, /* new in 2.3 */
3183 { "\\textthreeoldstyle\t", "3" }, /* new in 2.3 */
3184 { "\\textfouroldstyle\t", "4" }, /* new in 2.3 */
3185 { "\\textfiveoldstyle\t", "5" }, /* new in 2.3 */
3186 { "\\textsixoldstyle\t", "6" }, /* new in 2.3 */
3187 { "\\textsevenoldstyle\t", "7" }, /* new in 2.3 */
3188 { "\\texteightoldstyle\t", "8" }, /* new in 2.3 */
3189 { "\\textnineoldstyle\t", "9" }, /* new in 2.3 */
3190 { "\\textzerooldstyle\t", "0" }, /* new in 2.3 */
3191 { NULL, NULL }};
3192 #define NLATEX 224
3193
3194
3195 const char *udtable[][2] = {
3196 { "\\\"\ta", "a" }, /* \ \"a */ /* changend in 2.5*/
3197 { "\\\"\to", "o" }, /* | \"o */ /* changend in 2.5*/
3198 { "\\\"\tu", "u" }, /* CTL+E \"u */ /* changend in 2.5*/
3199 { "\\\"\tA", "A" }, /* | \"A */ /* changend in 2.5*/
3200 { "\\\"\tO", "O" }, /* | \"O */ /* changend in 2.5*/
3201 { "\\\"\tU", "U" }, /* | \"U */ /* changend in 2.5*/
3202 { "\\ss\t", "s" }, /* \ss */
3203 { "\\SS\t", "SS" }, /* \SS */
3204 { "\\sz\t", "s" }, /* \sz */ /* new in 2.1 */
3205 { "\\SZ\t", "S" }, /* \SZ */ /* new in 2.1 */
3206 { "\\flqq\t", "" }, /* \flqq */ /* new in 2.2 */
3207 { "\\frqq\t", "" }, /* \frqq */ /* new in 2.2 */
3208 { "\\glqq\t", "" }, /* \glqq */ /* new in 2.2 */
3209 { "\\grqq\t", "" }, /* \grqq */ /* new in 2.2 */
3210 { "\\/", "" }, /* \/ */ /* new in 2.2 */
3211 { "\\-", "" }, /* \- */ /* new in 2.2 */
3212 { "\\oldhyc\t", "c" }, /* [c-] */ /* \ */
3213 { "\\OLDHYC\t", "C" }, /* [C-] */ /* | */
3214 { "\\oldhyl\t", "l" }, /* [l-] */ /* | */
3215 { "\\OLDHYL\t", "L" }, /* [L-] */ /* | */
3216 { "\\oldhym\t", "m" }, /* [m-] */ /* | */
3217 { "\\OLDHYM\t", "M" }, /* [M-] */ /* | */
3218 { "\\oldhyn\t", "n" }, /* [n-] */ /* | new */
3219 { "\\OLDHYN\t", "N" }, /* [N-] */ /* | in */
3220 { "\\oldhyp\t", "p" }, /* [p-] */ /* | 2.2 */
3221 { "\\OLDHYP\t", "P" }, /* [P-] */ /* | */
3222 { "\\oldhyr\t", "r" }, /* [r-] */ /* | */
3223 { "\\OLDHYR\t", "R" }, /* [R-] */ /* | */
3224 { "\\oldhyt\t", "t" }, /* [t-] */ /* | */
3225 { "\\OLDHYT\t", "T" }, /* [T-] */ /* | */
3226 { "\\oldhyf\t", "f" }, /* [f-] */ /* | */
3227 { "\\OLDHYF\t", "F" }, /* [F-] */ /* / */
3228 { "\\hy\t", "-" }, /* MINUS \hy */ /* new in 2.2 */
3229 { "\\fhy\t", "-" }, /* MINUS \fhy*/ /* new in 2.2 */
3230 { "\\\"e", "e" }, /* \"e */ /* new in 2.6 */
3231 { "\\\"E", "E" }, /* \"E */ /* new in 2.6 */
3232 { "\\\"i", "i" }, /* \"i */ /* new in 2.6 */
3233 { "\\\"I", "I" }, /* \"I */ /* new in 2.6 */
3234 { "\\\"\t", "" }, /* / \" */ /* changend in 2.5*/
3235 { "\\3", "s" }, /* \3 */
3236 { "\\ck\t", "ck" }, /* [c-k] */ /* new in 2.2 */
3237 { "\\CK\t", "CK" }, /* [C-K] */ /* new in 2.2 */
3238 { "\\oldhyss\t", "s" }, /* [s-s] */ /* \ */
3239 { "\\OLDHYSS\t", "SS" }, /* [S-S] */ /* | new */
3240 { "\\newhyss\t", "s" }, /* [-ss] */ /* | in */
3241 { "\\NEWHYSS\t", "SS" }, /* [-SS] */ /* | 2.2 */
3242 { "\\hyss\t", "s" }, /* [s-s/-ss] */ /* | */
3243 { "\\HYSS\t", "SS" }, /* [S-S/-SS] */ /* / */
3244 { "\\capitaldieresis\ta", "a" }, /* new in 2.5 = \"a */
3245 { "\\@tabacckludge\t\"\ta","a" }, /* new in 2.5 = \"a */
3246 { "\\a\t\"\ta", "a" }, /* new in 2.5 = \"a */
3247 { "\\capitaldieresis\to", "o" }, /* new in 2.5 = \"o */
3248 { "\\@tabacckludge\t\"\to","o" }, /* new in 2.5 = \"o */
3249 { "\\a\t\"\to", "o" }, /* new in 2.5 = \"o */
3250 { "\\capitaldieresis\tu", "u" }, /* new in 2.5 = \"u */
3251 { "\\@tabacckludge\t\"\tu","u" }, /* new in 2.5 = \"u */
3252 { "\\a\t\"\tu", "u" }, /* new in 2.5 = \"u */
3253 { "\\capitaldieresis\tA", "A" }, /* new in 2.5 = \"A */
3254 { "\\@tabacckludge\t\"\tA","A" }, /* new in 2.5 = \"A */
3255 { "\\a\t\"\tA", "A" }, /* new in 2.5 = \"A */
3256 { "\\capitaldieresis\tO", "O" }, /* new in 2.5 = \"O */
3257 { "\\@tabacckludge\t\"\tO","O" }, /* new in 2.5 = \"O */
3258 { "\\a\t\"\tO", "O" }, /* new in 2.5 = \"O */
3259 { "\\capitaldieresis\tU", "U" }, /* new in 2.5 = \"U */
3260 { "\\@tabacckludge\t\"\tU","U" }, /* new in 2.5 = \"U */
3261 { "\\a\t\"\tU", "U" }, /* new in 2.5 = \"U */
3262 { "\\capitaldieresis\t", "" }, /* new in 2.5 = \" */
3263 { "\\@tabacckludge\t\"\t", "" }, /* new in 2.5 = \" */
3264 { "\\a\t\"\t", "" }, /* new in 2.5 = \" */
3265 { NULL, NULL }};
3266 #define NUMTEX 69
3267
3268
3269 /* \" changed to \"\t in 2.5 */
3270 const char *gstylist[][2] = {
3271 { "\"\ta", NULL }, /* \ "a */
3272 { "\"\to", NULL }, /* | "o */
3273 { "\"\tu", NULL }, /* CTL+E "u */
3274 { "\"\tA", NULL }, /* | "A */
3275 { "\"\tO", NULL }, /* | "O */
3276 { "\"\tU", NULL }, /* | "U */
3277 { "\"\ts", NULL }, /* "s */
3278 { "\"\tS", NULL }, /* "S */
3279 { "\"\tz", NULL }, /* "z */ /* new in 2.1 */
3280 { "\"\tZ", NULL }, /* "Z */ /* new in 2.1 */
3281 { "\"\t<", NULL }, /* "` */ /* new in 2.2 */
3282 { "\"\t>", NULL }, /* "' */ /* new in 2.2 */
3283 { "\"\t`", NULL }, /* "` */ /* new in 2.2 */
3284 { "\"\t\'", NULL }, /* "' */ /* new in 2.2 */
3285 { "\"\t|", NULL }, /* "| */ /* new in 2.2 */
3286 { "\"\t-", NULL }, /* "- */ /* new in 2.2 */
3287 { "\"\tc", NULL }, /* [c-] */ /* \ */
3288 { "\"\tC", NULL }, /* [C-] */ /* | */
3289 { "\"\tl", NULL }, /* [l-] */ /* | */
3290 { "\"\tL", NULL }, /* [L-] */ /* | */
3291 { "\"\tm", NULL }, /* [m-] */ /* | */
3292 { "\"\tM", NULL }, /* [M-] */ /* | */
3293 { "\"\tn", NULL }, /* [n-] */ /* | new */
3294 { "\"\tN", NULL }, /* [N-] */ /* | in */
3295 { "\"\tp", NULL }, /* [p-] */ /* | 2.2 */
3296 { "\"\tP", NULL }, /* [P-] */ /* | */
3297 { "\"\tr", NULL }, /* [r-] */ /* | */
3298 { "\"\tR", NULL }, /* [R-] */ /* | */
3299 { "\"\tt", NULL }, /* [t-] */ /* | */
3300 { "\"\tT", NULL }, /* [T-] */ /* | */
3301 { "\"\tf", NULL }, /* [f-] */ /* | */
3302 { "\"\tF", NULL }, /* [F-] */ /* | */
3303 { "\"\t=", NULL }, /* MINUS "= */ /* new in 2.2 */
3304 { "\"\t~", NULL }, /* MINUS "~ */ /* new in 2.2 */
3305 { "\"\te", NULL }, /* \ "e */ /* new in 2.6 */
3306 { "\"\tE", NULL }, /* \ "E */ /* new in 2.6 */
3307 { "\"\ti", NULL }, /* \ "i */ /* new in 2.6 */
3308 { "\"\tI", NULL }, /* \ "I */ /* new in 2.6 */
3309 { "\"\t", NULL }, /* / " */ /* OFF in 2.6 */
3310 { NULL, NULL }};
3311 #define NUMGER 38
3312 /* 39 if you want "b=\"b, "y=\"y, etc. <= "\"\t" OFF in 2.6 */
3313
3314
3315 const char *gweight[][2] = {
3316 { NULL, "ae" }, /* \ \"a "a */
3317 { NULL, "oe" }, /* | \"o "o */
3318 { NULL, "ue" }, /* CTL+E \"u "u */
3319 { NULL, "Ae" }, /* | \"A "A */
3320 { NULL, "Oe" }, /* | \"O "O */
3321 { NULL, "Ue" }, /* | \"U "U */
3322 { NULL, "ss" }, /* \ss "s */
3323 { NULL, "SS" }, /* \SS "S */
3324 { NULL, "ss" }, /* \sz "z */ /* new in 2.1 */
3325 { NULL, "SS" }, /* \SZ "Z */ /* new in 2.1 */
3326 { NULL, "" }, /* \flqq "< */ /* new in 2.2 */
3327 { NULL, "" }, /* \frqq "> */ /* new in 2.2 */
3328 { NULL, "" }, /* \glqq "` */ /* new in 2.2 */
3329 { NULL, "" }, /* \grqq "' */ /* new in 2.2 */
3330 { NULL, "" }, /* \/ "| */ /* new in 2.2 */
3331 { NULL, "" }, /* \- "- */ /* new in 2.2 */
3332 { NULL, "c" }, /* [c-] "c */ /* \ */
3333 { NULL, "C" }, /* [C-] "C */ /* | */
3334 { NULL, "l" }, /* [l-] "l */ /* | */
3335 { NULL, "L" }, /* [L-] "L */ /* | */
3336 { NULL, "m" }, /* [m-] "m */ /* | */
3337 { NULL, "M" }, /* [M-] "M */ /* | */
3338 { NULL, "n" }, /* [n-] "n */ /* | new */
3339 { NULL, "N" }, /* [N-] "N */ /* | in */
3340 { NULL, "p" }, /* [p-] "p */ /* | 2.2 */
3341 { NULL, "P" }, /* [P-] "P */ /* | */
3342 { NULL, "r" }, /* [r-] "r */ /* | */
3343 { NULL, "R" }, /* [R-] "R */ /* | */
3344 { NULL, "t" }, /* [t-] "t */ /* | */
3345 { NULL, "T" }, /* [T-] "T */ /* | */
3346 { NULL, "f" }, /* [f-] "f */ /* | */
3347 { NULL, "F" }, /* [F-] "F */ /* / */
3348 { NULL, "-" }, /* MINUS \hy "= */ /* new in 2.2 */
3349 { NULL, "-" }, /* MINUS \fhy "~ */ /* new in 2.2 */
3350 { NULL, "e" }, /* \ \"e */ /* new in 2.6 */
3351 { NULL, "E" }, /* \ \"E */ /* new in 2.6 */
3352 { NULL, "i" }, /* \ \"i */ /* new in 2.6 */
3353 { NULL, "I" }, /* \ \"I */ /* new in 2.6 */
3354 { NULL, "" }, /* / \" (" OFF in 2.6) */
3355 { NULL, "ss" }, /* \3 [] */
3356 { NULL, "ck" }, /* \ck */ /* new in 2.2 */
3357 { NULL, "CK" }, /* \CK */ /* new in 2.2 */
3358 { NULL, "ss" }, /* [s-s] */ /* \ */
3359 { NULL, "SS" }, /* [S-S] */ /* | new */
3360 { NULL, "ss" }, /* [-ss] */ /* | in */
3361 { NULL, "SS" }, /* [-SS] */ /* | 2.2 */
3362 { NULL, "ss" }, /* [s-s/-ss] */ /* | */
3363 { NULL, "SS" }, /* [S-S/-SS] */ /* / */
3364 { NULL, "ae" }, /* new in 2.5 = \capitaldieresis a */
3365 { NULL, "ae" }, /* new in 2.5 = \@tabacckludge " a */
3366 { NULL, "ae" }, /* new in 2.5 = \a " a */
3367 { NULL, "oe" }, /* new in 2.5 = \capitaldieresis o */
3368 { NULL, "oe" }, /* new in 2.5 = \@tabacckludge " o */
3369 { NULL, "oe" }, /* new in 2.5 = \a " o */
3370 { NULL, "ue" }, /* new in 2.5 = \capitaldieresis u */
3371 { NULL, "ue" }, /* new in 2.5 = \@tabacckludge " u */
3372 { NULL, "ue" }, /* new in 2.5 = \a " u */
3373 { NULL, "Ae" }, /* new in 2.5 = \capitaldieresis A */
3374 { NULL, "Ae" }, /* new in 2.5 = \@tabacckludge " A */
3375 { NULL, "Ae" }, /* new in 2.5 = \a " A */
3376 { NULL, "Oe" }, /* new in 2.5 = \capitaldieresis O */
3377 { NULL, "Oe" }, /* new in 2.5 = \@tabacckludge " O */
3378 { NULL, "Oe" }, /* new in 2.5 = \a " O */
3379 { NULL, "Ue" }, /* new in 2.5 = \capitaldieresis U */
3380 { NULL, "Ue" }, /* new in 2.5 = \@tabacckludge " U */
3381 { NULL, "Ue" }, /* new in 2.5 = \a " U */
3382 { NULL, "" }, /* new in 2.5 = \capitaldieresis */
3383 { NULL, "" }, /* new in 2.5 = \@tabacckludge " */
3384 { NULL, "" }, /* new in 2.5 = \a " */
3385 { NULL, NULL }};
3386
3387
3388 const char *mweight[][2] = {
3389 { NULL, "a" }, /* \ \"a "a */
3390 { NULL, "o" }, /* | \"o "o */
3391 { NULL, "u" }, /* CTL+E \"u "u */
3392 { NULL, "A" }, /* | \"A "A */
3393 { NULL, "O" }, /* | \"O "O */
3394 { NULL, "U" }, /* | \"U "U */
3395 { NULL, "ss" }, /* \ss "s */
3396 { NULL, "SS" }, /* \SS "S */
3397 { NULL, "ss" }, /* \sz "z */ /* new in 2.1 */
3398 { NULL, "SS" }, /* \SZ "Z */ /* new in 2.1 */
3399 { NULL, "" }, /* \flqq "< */ /* new in 2.2 */
3400 { NULL, "" }, /* \frqq "> */ /* new in 2.2 */
3401 { NULL, "" }, /* \glqq "` */ /* new in 2.2 */
3402 { NULL, "" }, /* \grqq "' */ /* new in 2.2 */
3403 { NULL, "" }, /* \/ "| */ /* new in 2.2 */
3404 { NULL, "" }, /* \- "- */ /* new in 2.2 */
3405 { NULL, "c" }, /* [c-] "c */ /* \ */
3406 { NULL, "C" }, /* [C-] "C */ /* | */
3407 { NULL, "l" }, /* [l-] "l */ /* | */
3408 { NULL, "L" }, /* [L-] "L */ /* | */
3409 { NULL, "m" }, /* [m-] "m */ /* | */
3410 { NULL, "M" }, /* [M-] "M */ /* | */
3411 { NULL, "n" }, /* [n-] "n */ /* | new */
3412 { NULL, "N" }, /* [N-] "N */ /* | in */
3413 { NULL, "p" }, /* [p-] "p */ /* | 2.2 */
3414 { NULL, "P" }, /* [P-] "P */ /* | */
3415 { NULL, "r" }, /* [r-] "r */ /* | */
3416 { NULL, "R" }, /* [R-] "R */ /* | */
3417 { NULL, "t" }, /* [t-] "t */ /* | */
3418 { NULL, "T" }, /* [T-] "T */ /* | */
3419 { NULL, "f" }, /* [f-] "f */ /* | */
3420 { NULL, "F" }, /* [F-] "F */ /* / */
3421 { NULL, "-" }, /* \hy "= */ /* new in 2.2 */
3422 { NULL, "-" }, /* \fhy "~ */ /* new in 2.2 */
3423 { NULL, "e" }, /* \"e */ /* new in 2.6 */
3424 { NULL, "E" }, /* \"E */ /* new in 2.6 */
3425 { NULL, "i" }, /* \"i */ /* new in 2.6 */
3426 { NULL, "I" }, /* \"I */ /* new in 2.6 */
3427 { NULL, "" }, /* \" (" OFF in 2.6) */
3428 { NULL, "ss" }, /* \3 [] */
3429 { NULL, "ck" }, /* \ck */ /* new in 2.2 */
3430 { NULL, "CK" }, /* \CK */ /* new in 2.2 */
3431 { NULL, "ss" }, /* [s-s] */ /* \ */
3432 { NULL, "SS" }, /* [S-S] */ /* | new */
3433 { NULL, "ss" }, /* [-ss] */ /* | in */
3434 { NULL, "SS" }, /* [-SS] */ /* | 2.2 */
3435 { NULL, "ss" }, /* [s-s/-ss] */ /* | */
3436 { NULL, "SS" }, /* [S-S/-SS] */ /* / */
3437 { NULL, "a" }, /* new in 2.5 = \capitaldieresis a */
3438 { NULL, "a" }, /* new in 2.5 = \@tabacckludge " a */
3439 { NULL, "a" }, /* new in 2.5 = \a " a */
3440 { NULL, "o" }, /* new in 2.5 = \capitaldieresis o */
3441 { NULL, "o" }, /* new in 2.5 = \@tabacckludge " o */
3442 { NULL, "o" }, /* new in 2.5 = \a " o */
3443 { NULL, "u" }, /* new in 2.5 = \capitaldieresis u */
3444 { NULL, "u" }, /* new in 2.5 = \@tabacckludge " u */
3445 { NULL, "u" }, /* new in 2.5 = \a " u */
3446 { NULL, "A" }, /* new in 2.5 = \capitaldieresis A */
3447 { NULL, "A" }, /* new in 2.5 = \@tabacckludge " A */
3448 { NULL, "A" }, /* new in 2.5 = \a " A */
3449 { NULL, "O" }, /* new in 2.5 = \capitaldieresis O */
3450 { NULL, "O" }, /* new in 2.5 = \@tabacckludge " O */
3451 { NULL, "O" }, /* new in 2.5 = \a " O */
3452 { NULL, "U" }, /* new in 2.5 = \capitaldieresis U */
3453 { NULL, "U" }, /* new in 2.5 = \@tabacckludge " U */
3454 { NULL, "U" }, /* new in 2.5 = \a " U */
3455 { NULL, "" }, /* new in 2.5 = \capitaldieresis */
3456 { NULL, "" }, /* new in 2.5 = \@tabacckludge " */
3457 { NULL, "" }, /* new in 2.5 = \a " */
3458 { NULL, NULL }};
3459
3460
3461 int lenofMATCHaftertab(const char *t, const char *line)
3462 {
3463 int r = 0;
3464
3465 if (*t == '\t')
3466 {
3467 if (*(t+1) != '\0')
3468 {
3469 if (*(t+2) == '\0' || *(t+2) == '\t')
3470 {
3471 if (*(t+1) == *line) r = 1;
3472 else
3473 if (*line == '{' && *(t+1) == *(line+1) && *(line+2) == '}') r = 3;
3474 }
3475 else intern_err(34);
3476 }
3477 }
3478
3479 if (r > 0 && *(t+2) == '\t')
3480 {
3481 while (*(line+r) == ' ') ++r;
3482
3483 if(*(t+3) != '\0')
3484 {
3485 if (*(t+4) == '\0')
3486 {
3487 if (*(t+3) == *(line+r)) r += 1;
3488 else
3489 if (*(line+r) == '{' && *(t+3) == *(line+r+1) && *(line+r+2) == '}') r += 3;
3490 else
3491 r = 0;
3492 }
3493 else intern_err(37);
3494 }
3495 }
3496
3497 return r;
3498 }
3499
3500
3501 int texlistnum(const char *p, int n, const char *list[][2])
3502 {
3503 const char *entry, *line;
3504 int i = 0, len, atlen;
3505
3506 while (i < n)
3507 {
3508 entry = list[i][0];
3509 line = p; len = 0;
3510
3511
3512 while (*line == *entry && *entry != '\0' && *entry != '\t')
3513 {
3514 ++line; ++entry; ++len;
3515 }
3516
3517
3518 if (*entry == '\0')
3519 break;
3520
3521
3522 if (*entry == '\t' && ((len == 1 && *p == '\"') || (len == 2 && *p == '\\' && isLaTeXcmdletter(*(p+1)) == 0) || isLaTeXcmdletter(*line) == 0))
3523 {
3524 /* moved in 2.6: also "y etc. (not only as in 2.5: " y) */
3525 if (*(entry+1) == '\0')
3526 break;
3527
3528 while (*line == ' ') ++line; /* now, isLaTeXcmdletter(*line) != 0 */
3529
3530 /* new in 2.3, changed in 2.5 */
3531 if ((atlen=lenofMATCHaftertab(entry, line)) > 0) /* atlen=1,3 !! */
3532 break;
3533 }
3534
3535 ++i;
3536 }
3537
3538 if (i == n) return -1;
3539 else return i;
3540 }
3541
3542
3543 int insposmaxstr(char s[], const char *p, int pos, int max)
3544 {
3545 while(*p != '\0' && pos < max) s[pos++] = *p++;
3546 s[pos] = '\0';
3547 return pos;
3548 }
3549
3550
3551 int llstrlen(const char *s)
3552 {
3553 int len = 0;
3554
3555 while (*s != '\0' && *s != '\t') { ++s; ++len; }
3556
3557 return len;
3558 }
3559
3560
3561 char *overspacesafterlettercmd(int len, const char *q, char *p)
3562 {
3563 int atlen;
3564
3565 /* if (isLaTeXcmdletter(*(q+1)) != 0) deleted in 2.5 !! */
3566
3567 if (len > 0)
3568 {
3569 if (*(q+len) == '\t' && ((len == 1 && *q == '\"') || (len == 2 && *q == '\\' && isLaTeXcmdletter(*(q+1)) == 0) || isLaTeXcmdletter(*p) == 0))
3570 {
3571 while (*p == ' ') ++p; /* now, isLaTeXcmdletter(*p) != 0 */
3572
3573 /* new in 2.5 because of \capitaldieresis{x} */
3574 if((atlen=lenofMATCHaftertab(q+len, p)) > 0)
3575 {
3576 p += atlen;
3577 }
3578 }
3579 }
3580
3581 return p;
3582 }
3583
3584
3585 int insertweight(char in[], int i, int pos, int max)
3586 {
3587 if (german == 1) pos = insposmaxstr(in, gweight[i][1], pos, max);
3588 else if (german == 2) pos = insposmaxstr(in, mweight[i][1], pos, max);
3589 else pos = insposmaxstr(in, udtable[i][1], pos, max);
3590
3591 return pos;
3592 }
3593
3594
3595 int nichtvorziehen(char a)
3596 {
3597 if (issonder(a) == 1 && a != '')
3598 return 1; /* 31 */
3599 return 0;
3600 }
3601
3602
3603 int isinitial(char a)
3604 {
3605 if (a == '' || a == '')
3606 return 1;
3607 return 0;
3608 }
3609
3610
3611 void nzvorziehen(char in[], char *p)
3612 {
3613 int pos = 0, l;
3614 char mem;
3615
3616 while (*p != '\0')
3617 {
3618 if (nichtvorziehen(*p) == 1)
3619 {
3620 if (isinitial(*(p+1)) == 1)
3621 {
3622 l = pos;
3623 while (nichtvorziehen(*p) && isinitial(*(p+1)) == 1)
3624 { in[l++] = *p++; in[l++] = *p++; }
3625 mem = in[l-1];
3626 in[l-1] = in[pos+1];
3627 in[pos+1] = mem;
3628 mem = in[l-2];
3629 in[l-2] = in[pos];
3630 in[pos] = mem;
3631 pos = l;
3632 }
3633 else { ++p; intern_err(35); }
3634 }
3635 else
3636 {
3637 if (isinitial(*(p+1)) == 1) { ++p; intern_err(36); }
3638 else
3639 in[pos++] = *p++;
3640 }
3641 }
3642
3643 in[pos] = '\0';
3644 }
3645
3646
3647 char *austauschen(char in[], char *p, int dqcat)
3648 {
3649 int pos = 0, i, len;
3650
3651 while (*p != '\0' && pos < MAXLEN-1)
3652 {
3653 if (*p == '\\') /* "\\\\" ist schon ' ' */
3654 {
3655 if ((i=texlistnum(p, NUMTEX, udtable)) > -1)
3656 { p += (len=llstrlen( udtable[i][0]));
3657 pos = insertweight(in, i, pos, MAXLEN-1);
3658 p = overspacesafterlettercmd(len, udtable[i][0], p);
3659 }
3660 else if ((i=texlistnum(p, NLATEX, weighttable)) > -1)
3661 { p += (len=llstrlen( weighttable[i][0]));
3662 pos = insposmaxstr(in, weighttable[i][1], pos, MAXLEN-1);
3663 p = overspacesafterlettercmd(len, weighttable[i][0], p);
3664 }
3665 else if (*(p+1) == '~') p += 2; /* falls \~ nicht in weighttable */
3666 else if (isLaTeXcmdletter(*(p+1)) != 0)
3667 { ++p; while (isLaTeXcmdletter(*p) != 0) ++p;
3668 while (*p == ' ') ++p;
3669 }
3670 else
3671 {
3672 if (issonder(*p) == 0) in[pos++] = *p;
3673 ++p;
3674 }
3675 }
3676 else
3677 if (*p == '\"' && dqcat == TeXACTIVE) /* nogsty == 0 */
3678 {
3679 if (*(p+1) == '\"') p += 2; /* "" ist nicht in gstylist */
3680 else /* "~ muss in gstylist sein */
3681 if ( (i=texlistnum(p, NUMGER, gstylist)) > -1)
3682 { p += (len=llstrlen( gstylist[i][0]));
3683 pos = insertweight(in, i, pos, MAXLEN-1);
3684 p = overspacesafterlettercmd(len, gstylist[i][0], p); /* new in 2.5 */
3685 }
3686 else
3687 {
3688 if (issonder(*p) == 0) in[pos++] = *p;
3689 ++p;
3690 }
3691 }
3692 else if (*p == '~') /* MARK_TILDE */
3693 {
3694 in[pos++] = ' ';
3695 ++p;
3696 }
3697 else
3698 {
3699 if (issonder(*p) == 0) in[pos++] = *p;
3700 ++p;
3701 }
3702 }
3703
3704 in[pos] = '\0';
3705
3706 return in;
3707 }
3708
3709
3710 void kill_unnecessary_spaces(char *s, char *p)
3711 {
3712
3713 while (*p == ' ') ++p;
3714
3715 while (*p != '\0')
3716 {
3717 if (*p == ' ' && *(p+1) == ' ') ++p;
3718 else if (*p == ' ' && *(p+1) == '\0') break;
3719 else *s++ = *p++;
3720 }
3721
3722 *s = '\0';
3723 }
3724
3725
3726 void swapBCstrs(const int linec)
3727 {
3728 char *p;
3729
3730 p = subBptr[0][linec];
3731 subBptr[0][linec] = subBptr[1][linec];
3732 subBptr[1][linec] = p;
3733
3734 p = subCptr[0][linec];
3735 subCptr[0][linec] = subCptr[1][linec];
3736 subCptr[1][linec] = p;
3737 }
3738
3739
3740 static char *teinzerw[] = {
3741 "\\u{A}", /* 128 */
3742 "\\k{A}", /* 129 */
3743 "\\\'C", /* 130 */
3744 "\\v{C}", /* 131 */
3745 "\\v{D}", /* 132 */
3746 "\\v{E}", /* 133 */
3747 "\\k{E}", /* 134 */
3748 "\\u{G}", /* 135 */
3749 "\\\'L", /* 136 */
3750 "\\v{L}", /* 137 */
3751 "\\L{}", /* 138 */
3752 "\\\'N", /* 139 */
3753 "\\v{N}", /* 140 */
3754 "\\NG{}", /* 141 */
3755 "\\H{O}", /* 142 */
3756 "\\\'R", /* 143 */
3757 "\\v{R}", /* 144 */
3758 "\\\'S", /* 145 */
3759 "\\v{S}", /* 146 */
3760 "\\c{S}", /* 147 */
3761 "\\v{T}", /* 148 */
3762 "\\c{T}", /* 149 */
3763 "\\H{U}", /* 150 */
3764 "\\r{U}", /* 151 */
3765 "\\\"Y", /* 152 */
3766 "\\\'Z", /* 153 */
3767 "\\v{Z}", /* 154 */
3768 "\\.Z", /* 155 */
3769 "\\IJ{}", /* 156 */
3770 "\\.I", /* 157 */
3771 "\\dj{}", /* 158 */
3772 "\\S{}", /* 159 */ /* eigentl. "\\textsection{}" */
3773 "\\u{a}", /* 160 */
3774 "\\k{a}", /* 161 */
3775 "\\\'c", /* 162 */
3776 "\\v{c}", /* 163 */
3777 "\\v{d}", /* 164 */
3778 "\\v{e}", /* 165 */
3779 "\\k{e}", /* 166 */
3780 "\\u{g}", /* 167 */
3781 "\\\'l", /* 168 */
3782 "\\v{l}", /* 169 */
3783 "\\l{}", /* 170 */
3784 "\\\'n", /* 171 */
3785 "\\v{n}", /* 172 */
3786 "\\ng{}", /* 173 */
3787 "\\H{o}", /* 174 */
3788 "\\\'r", /* 175 */
3789 "\\v{r}", /* 176 */
3790 "\\\'s", /* 177 */
3791 "\\v{s}", /* 178 */
3792 "\\c{s}", /* 179 */
3793 "\\v{t}", /* 180 */
3794 "\\c{t}", /* 181 */
3795 "\\H{u}", /* 182 */
3796 "\\r{u}", /* 183 */
3797 "\\\"y", /* 184 */
3798 "\\\'z", /* 185 */
3799 "\\v{z}", /* 186 */
3800 "\\.z", /* 187 */
3801 "\\ij{}", /* 188 */
3802 "!`", /* 189 */ /* eigentl. "\\textexclamdown{}" */
3803 "\?`", /* 190 */ /* eigentl. "\\textquestiondown{}" */
3804 "\\pounds{}",/* 191 */ /* eigentl. "\\textsterling{}" */
3805 "\\`A", /* 192 */
3806 "\\\'A", /* 193 */
3807 "\\^A", /* 194 */
3808 "\\~A", /* 195 */
3809 "\\\"A", /* 196 */
3810 "\\r{A}", /* 197 */
3811 "\\AE{}", /* 198 */
3812 "\\c{C}", /* 199 */
3813 "\\`E", /* 200 */
3814 "\\\'E", /* 201 */
3815 "\\^E", /* 202 */
3816 "\\\"E", /* 203 */
3817 "\\`I", /* 204 */
3818 "\\\'I", /* 205 */
3819 "\\^I", /* 206 */
3820 "\\\"I", /* 207 */
3821 "\\DH{}", /* 208 "\\DJ{}", 208 */
3822 "\\~N", /* 209 */
3823 "\\`O", /* 210 */
3824 "\\\'O", /* 211 */
3825 "\\^O", /* 212 */
3826 "\\~O", /* 213 */
3827 "\\\"O", /* 214 */
3828 "\\OE{}", /* 215 */
3829 "\\O{}", /* 216 */
3830 "\\`U", /* 217 */
3831 "\\\'U", /* 218 */
3832 "\\^U", /* 219 */
3833 "\\\"U", /* 220 */
3834 "\\\'Y", /* 221 */
3835 "\\TH{}", /* 222 */
3836 "\\SS{}", /* 223 */
3837 "\\`a", /* 224 */
3838 "\\\'a", /* 225 */
3839 "\\^a", /* 226 */
3840 "\\~a", /* 227 */
3841 "\\\"a", /* 228 */
3842 "\\r{a}", /* 229 */
3843 "\\ae{}", /* 230 */
3844 "\\c{c}", /* 231 */
3845 "\\`e", /* 232 */
3846 "\\\'e", /* 233 */
3847 "\\^e", /* 234 */
3848 "\\\"e", /* 235 */
3849 "\\`\\i{}", /* 236 */
3850 "\\\'\\i{}", /* 237 */
3851 "\\^\\i{}", /* 238 */
3852 "\\\"\\i{}", /* 239 */
3853 "\\dh{}", /* 240 */
3854 "\\~n", /* 241 */
3855 "\\`o", /* 242 */
3856 "\\\'o", /* 243 */
3857 "\\^o", /* 244 */
3858 "\\~o", /* 245 */
3859 "\\\"o", /* 246 */
3860 "\\oe{}", /* 247 */
3861 "\\o{}", /* 248 */
3862 "\\`u", /* 249 */
3863 "\\\'u", /* 250 */
3864 "\\^u", /* 251 */
3865 "\\\"u", /* 252 */
3866 "\\\'y", /* 253 */
3867 "\\th{}", /* 254 */
3868 "\\ss{}"}; /* 255 */
3869
3870 char *getTONEenc(unsigned char c)
3871 {
3872 if (c >= 128 && c <= 255)
3873 return teinzerw[c-128];
3874 else return "";
3875 }
3876
3877
3878 /*--------------------------------------------------------------------------*/
3879
3880
3881 #define DOUBLETTES_BEGIN 194
3882 #define DOUBLETTES_END 223
3883
3884 #define TRIPLETTES_BEGIN 224
3885 #define TRIPLETTES_END 239
3886
3887 #define QUADRUPLES_BEGIN 240
3888 #define QUADRUPLES_END 244
3889
3890 #define UTF_BLOCK_BEGIN 128
3891 #define UTF_BLOCK_END 191
3892
3893 static char *ohninetyfour[] = {
3894 "", /* 194 128 <control> = U+0080 */
3895 "", /* 194 129 <control> */
3896 "", /* 194 130 <control> */
3897 "", /* 194 131 <control> */
3898 "", /* 194 132 <control> */
3899 "", /* 194 133 <control> */
3900 "", /* 194 134 <control> */
3901 "", /* 194 135 <control> */
3902 "", /* 194 136 <control> */
3903 "", /* 194 137 <control> */
3904 "", /* 194 138 <control> */
3905 "", /* 194 139 <control> */
3906 "", /* 194 140 <control> */
3907 "", /* 194 141 <control> */
3908 "", /* 194 142 <control> */
3909 "", /* 194 143 <control> */
3910 "", /* 194 144 <control> */
3911 "", /* 194 145 <control> */
3912 "", /* 194 146 <control> */
3913 "", /* 194 147 <control> */
3914 "", /* 194 148 <control> */
3915 "", /* 194 149 <control> */
3916 "", /* 194 150 <control> */
3917 "", /* 194 151 <control> */
3918 "", /* 194 152 <control> */
3919 "", /* 194 153 <control> */
3920 "", /* 194 154 <control> */
3921 "", /* 194 155 <control> */
3922 "", /* 194 156 <control> */
3923 "", /* 194 157 <control> */
3924 "", /* 194 158 <control> */
3925 "", /* 194 159 <control> */
3926 "{\\nobreakspace}", /* 194 160 ~ */
3927 "{\\textexclamdown}", /* 194 161 !` */
3928 "{\\textcent}", /* 194 162 */
3929 "{\\textsterling}", /* 194 163 */
3930 "{\\textcurrency}", /* 194 164 */
3931 "{\\textyen}", /* 194 165 */
3932 "{\\textbrokenbar}", /* 194 166 */
3933 "{\\textsection}", /* 194 167 */
3934 "{\\textasciidieresis}",/* 194 168 \\\"{} */
3935 "{\\textcopyright}", /* 194 169 */
3936 "{\\textordfeminine}", /* 194 170 */
3937 "{\\guillemetleft}", /* 194 171 {\\flqq}; before 2.5 / v1.3c: {\\guillemotleft} */
3938 "{\\textlnot}", /* 194 172 NOT SIGN */
3939 "{\\-}", /* 194 173 */
3940 "{\\textregistered}", /* 194 174 */
3941 "{\\textasciimacron}", /* 194 175 \\={} */
3942 "{\\textdegree}", /* 194 176 */
3943 "{\\textpm}", /* 194 177 aehnlich $\pm$ */
3944 "{\\texttwosuperior}", /* 194 178 ^{2} */
3945 "{\\textthreesuperior}",/* 194 179 ^{3} */
3946 "{\\textasciiacute}", /* 194 180 \\\'{} */
3947 "{\\textmu}", /* 194 181 MICRO SIGN */
3948 "{\\textparagraph}", /* 194 182 PILCROW SIGN */
3949 "{\\textperiodcentered}", /* 194 183 {\\cdot} */
3950 "{\\textasciicedilla}", /* 194 184 {\\c\\ } (\text... yet undefined) */
3951 "{\\textonesuperior}", /* 194 185 ^{1} */
3952 "{\\textordmasculine}", /* 194 186 */
3953 "{\\guillemetright}", /* 194 187 {\\frqq}; before 2.5 / v1.3c: {\\guillemotright} */
3954 "{\\textonequarter}", /* 194 188 \\frac{1}{4} */
3955 "{\\textonehalf}", /* 194 189 \\frac{1}{2} */
3956 "{\\textthreequarters}",/* 194 190 \\frac{3}{4} */
3957 "{\\textquestiondown}", /* 194 191 ?` */
3958 NULL };
3959
3960 #define OHNINETYFOUR 194
3961
3962 char *get_ohninetyfour(unsigned char c)
3963 {
3964 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
3965 return ohninetyfour[c-UTF_BLOCK_BEGIN];
3966 else return "";
3967 }
3968
3969
3970 static char *ohninetyfive[] = {
3971 "\\`A", /* 195 128 */
3972 "\\\'A", /* 195 129 */
3973 "\\^A", /* 195 130 */
3974 "\\~A", /* 195 131 */
3975 "\\\"A", /* 195 132 */
3976 "\\r{A}", /* 195 133 {\\AA} */
3977 "{\\AE}", /* 195 134 */
3978 "\\c{C}", /* 195 135 */
3979 "\\`E", /* 195 136 */
3980 "\\\'E", /* 195 137 */
3981 "\\^E", /* 195 138 */
3982 "\\\"E", /* 195 139 */
3983 "\\`I", /* 195 140 */
3984 "\\\'I", /* 195 141 */
3985 "\\^I", /* 195 142 */
3986 "\\\"I", /* 195 143 */
3987 "{\\DH}", /* 195 144 not OT1 */
3988 "\\~N", /* 195 145 */
3989 "\\`O", /* 195 146 */
3990 "\\\'O", /* 195 147 */
3991 "\\^O", /* 195 148 */
3992 "\\~O", /* 195 149 */
3993 "\\\"O", /* 195 150 */
3994 "{\\texttimes}", /* 195 151 */
3995 "{\\O}", /* 195 152 */
3996 "\\`U", /* 195 153 */
3997 "\\\'U", /* 195 154 */
3998 "\\^U", /* 195 155 */
3999 "\\\"U", /* 195 156 */
4000 "\\\'Y", /* 195 157 */
4001 "{\\TH}", /* 195 158 not OT1 */
4002 "{\\ss}", /* 195 159 */
4003 "\\`a", /* 195 160 */
4004 "\\\'a", /* 195 161 */
4005 "\\^a", /* 195 162 */
4006 "\\~a", /* 195 163 */
4007 "\\\"a", /* 195 164 */
4008 "\\r{a}", /* 195 165 {\\aa} */
4009 "{\\ae}", /* 195 166 */
4010 "\\c{c}", /* 195 167 */
4011 "\\`e", /* 195 168 */
4012 "\\\'e", /* 195 169 */
4013 "\\^e", /* 195 170 */
4014 "\\\"e", /* 195 171 */
4015 "\\`{\\i}", /* 195 172 */
4016 "\\\'{\\i}", /* 195 173 */
4017 "\\^{\\i}", /* 195 174 */
4018 "\\\"{\\i}", /* 195 175 */
4019 "{\\dh}", /* 195 176 not OT1 */
4020 "\\~n", /* 195 177 */
4021 "\\`o", /* 195 178 */
4022 "\\\'o", /* 195 179 */
4023 "\\^o", /* 195 180 */
4024 "\\~o", /* 195 181 */
4025 "\\\"o", /* 195 182 */
4026 "{\\textdiv}", /* 195 183 */
4027 "{\\o}", /* 195 184 */
4028 "\\`u", /* 195 185 */
4029 "\\\'u", /* 195 186 */
4030 "\\^u", /* 195 187 */
4031 "\\\"u", /* 195 188 */
4032 "\\\'y", /* 195 189 */
4033 "{\\th}", /* 195 190 not OT1 */
4034 "\\\"y", /* 195 191 */
4035 NULL };
4036
4037 #define OHNINETYFIVE 195
4038
4039 char *get_ohninetyfive(unsigned char c)
4040 {
4041 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4042 return ohninetyfive[c-UTF_BLOCK_BEGIN];
4043 else return "";
4044 }
4045
4046
4047 static char *ohninetysix[] = {
4048 "\\=A", /* 196 128 */
4049 "\\=a", /* 196 129 */
4050 "\\u{A}", /* 196 130 */
4051 "\\u{a}", /* 196 131 */
4052 "\\k{A}", /* 196 132 not OT1 */
4053 "\\k{a}", /* 196 133 not OT1 */
4054 "\\\'C", /* 196 134 */
4055 "\\\'c", /* 196 135 */
4056 "\\^C", /* 196 136 */
4057 "\\^c", /* 196 137 */
4058 "\\.C", /* 196 138 */
4059 "\\.c", /* 196 139 */
4060 "\\v{C}", /* 196 140 */
4061 "\\v{c}", /* 196 141 */
4062 "\\v{D}", /* 196 142 */
4063 "\\v{d}", /* 196 143 */
4064 "{\\DJ}", /* 196 144 not OT1 */
4065 "{\\dj}", /* 196 145 not OT1 */
4066 "\\=E", /* 196 146 */
4067 "\\=e", /* 196 147 */
4068 "\\u{E}", /* 196 148 */
4069 "\\u{e}", /* 196 149 */
4070 "\\.E", /* 196 150 */
4071 "\\.e", /* 196 151 */
4072 "\\k{E}", /* 196 152 not OT1 */
4073 "\\k{e}", /* 196 153 not OT1 */
4074 "\\v{E}", /* 196 154 */
4075 "\\v{e}", /* 196 155 */
4076 "\\^G", /* 196 156 */
4077 "\\^g", /* 196 157 */
4078 "\\u{G}", /* 196 158 */
4079 "\\u{g}", /* 196 159 */
4080 "\\.G", /* 196 160 */
4081 "\\.g", /* 196 161 */
4082 "\\c{G}", /* 196 162 */
4083 "\\c{g}", /* 196 163 */
4084 "\\^H", /* 196 164 */
4085 "\\^h", /* 196 165 */
4086 "", /* 196 166 H-quer (not v1.3c) */
4087 "", /* 196 167 {\\hbar} [?] (not v1.3c) */
4088 "\\~I", /* 196 168 */
4089 "\\~{\\i}", /* 196 169 */
4090 "\\=I", /* 196 170 */
4091 "\\={\\i}", /* 196 171 */
4092 "\\u{I}", /* 196 172 */
4093 "\\u{\\i}", /* 196 173 */
4094 "\\k{I}", /* 196 174 not OT1 */
4095 "\\k{i}", /* 196 175 not OT1 */
4096 "\\.I", /* 196 176 */
4097 "{\\i}", /* 196 177 */
4098 "{\\IJ}", /* 196 178 */
4099 "{\\ij}", /* 196 179 */
4100 "\\^J", /* 196 180 */
4101 "\\^{\\j}", /* 196 181 */
4102 "\\c{K}", /* 196 182 */
4103 "\\c{k}", /* 196 183 */
4104 "", /* 196 184 kra (not v1.3c) */
4105 "\\\'L", /* 196 185 */
4106 "\\\'l", /* 196 186 */
4107 "\\c{L}", /* 196 187 */
4108 "\\c{l}", /* 196 188 */
4109 "\\v{L}", /* 196 189 */
4110 "\\v{l}", /* 196 190 */
4111 "", /* 196 191 L* (not v1.3c) */
4112 NULL };
4113
4114 #define OHNINETYSIX 196
4115
4116 char *get_ohninetysix(unsigned char c)
4117 {
4118 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4119 return ohninetysix[c-UTF_BLOCK_BEGIN];
4120 else return "";
4121 }
4122
4123
4124 static char *ohninetyseven[] = {
4125 "", /* 197 128 l* (not v1.3c) */
4126 "{\\L}", /* 197 129 */
4127 "{\\l}", /* 197 130 */
4128 "\\\'N", /* 197 131 */
4129 "\\\'n", /* 197 132 */
4130 "\\c{N}", /* 197 133 */
4131 "\\c{n}", /* 197 134 */
4132 "\\v{N}", /* 197 135 */
4133 "\\v{n}", /* 197 136 */
4134 "", /* 197 137 'n (not v1.3c) */
4135 "{\\NG}", /* 197 138 */
4136 "{\\ng}", /* 197 139 */
4137 "\\=O", /* 197 140 */
4138 "\\=o", /* 197 141 */
4139 "\\u{O}", /* 197 142 */
4140 "\\u{o}", /* 197 143 */
4141 "\\H{O}", /* 197 144 */
4142 "\\H{o}", /* 197 145 */
4143 "{\\OE}", /* 197 146 */
4144 "{\\oe}", /* 197 147 */
4145 "\\\'R", /* 197 148 */
4146 "\\\'r", /* 197 149 */
4147 "\\c{R}", /* 197 150 */
4148 "\\c{r}", /* 197 151 */
4149 "\\v{R}", /* 197 152 */
4150 "\\v{r}", /* 197 153 */
4151 "\\\'S", /* 197 154 */
4152 "\\\'s", /* 197 155 */
4153 "\\^S", /* 197 156 */
4154 "\\^s", /* 197 157 */
4155 "\\c{S}", /* 197 158 */
4156 "\\c{s}", /* 197 159 */
4157 "\\v{S}", /* 197 160 */
4158 "\\v{s}", /* 197 161 */
4159 "\\c{T}", /* 197 162 */
4160 "\\c{t}", /* 197 163 */
4161 "\\v{T}", /* 197 164 */
4162 "\\v{t}", /* 197 165 */
4163 "", /* 197 166 T-quer (not v1.3c) */
4164 "", /* 197 167 t-quer (not v1.3c) */
4165 "\\~U", /* 197 168 */
4166 "\\~u", /* 197 169 */
4167 "\\=U", /* 197 170 */
4168 "\\=u", /* 197 171 */
4169 "\\u{U}", /* 197 172 */
4170 "\\u{u}", /* 197 173 */
4171 "\\r{U}", /* 197 174 */
4172 "\\r{u}", /* 197 175 */
4173 "\\H{U}", /* 197 176 */
4174 "\\H{u}", /* 197 177 */
4175 "\\k{U}", /* 197 178 */
4176 "\\k{u}", /* 197 179 */
4177 "\\^W", /* 197 180 */
4178 "\\^w", /* 197 181 */
4179 "\\^Y", /* 197 182 */
4180 "\\^y", /* 197 183 */
4181 "\\\"Y", /* 197 184 */
4182 "\\\'Z", /* 197 185 */
4183 "\\\'z", /* 197 186 */
4184 "\\.Z", /* 197 187 */
4185 "\\.z", /* 197 188 */
4186 "\\v{Z}", /* 197 189 */
4187 "\\v{z}", /* 197 190 */
4188 "", /* 197 191 Lang-s (not v1.3c) */
4189 NULL };
4190
4191 #define OHNINETYSEVEN 197
4192
4193 char *get_ohninetyseven(unsigned char c)
4194 {
4195 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4196 return ohninetyseven[c-UTF_BLOCK_BEGIN];
4197 else return "";
4198 }
4199
4200
4201 static char *ohninetynine[] = {
4202 "", /* 199 128 dental click (not v1.3c) */
4203 "", /* 199 129 lateral click (not v1.3c) */
4204 "", /* 199 130 alveolar click (not v1.3c) */
4205 "", /* 199 131 retroflex click (not v1.3c) */
4206 "D\\v{Z}", /* 199 132 new in 2.5 / v1.3c */
4207 "D\\v{z}", /* 199 133 new in 2.5 / v1.3c */
4208 "d\\v{z}", /* 199 134 new in 2.5 / v1.3c */
4209 "LJ", /* 199 135 new in 2.5 / v1.3c */
4210 "Lj", /* 199 136 new in 2.5 / v1.3c */
4211 "lj", /* 199 137 new in 2.5 / v1.3c */
4212 "NJ", /* 199 138 new in 2.5 / v1.3c */
4213 "Nj", /* 199 139 new in 2.5 / v1.3c */
4214 "nj", /* 199 140 new in 2.5 / v1.3c */
4215 "\\v{A}", /* 199 141 */
4216 "\\v{a}", /* 199 142 */
4217 "\\v{I}", /* 199 143 */
4218 "\\v{\\i}", /* 199 144 */
4219 "\\v{O}", /* 199 145 */
4220 "\\v{o}", /* 199 146 */
4221 "\\v{U}", /* 199 147 */
4222 "\\v{u}", /* 199 148 */
4223 "", /* 199 149 \\={\\\"U} (not v1.3c) */
4224 "", /* 199 150 \\={\\\"u} (not v1.3c) */
4225 "", /* 199 151 \\\'{\\\"U} (not v1.3c) */
4226 "", /* 199 152 \\\'{\\\"u} (not v1.3c) */
4227 "", /* 199 153 \\v{\\\"U} (not v1.3c) */
4228 "", /* 199 154 \\v{\\\"u} (not v1.3c) */
4229 "", /* 199 155 \\`{\\\"U} (not v1.3c) */
4230 "", /* 199 156 \\`{\\\"u} (not v1.3c) */
4231 "", /* 199 157 turned e (not v1.3c) */
4232 "", /* 199 158 \\={\\\"A} (not v1.3c) */
4233 "", /* 199 159 \\={\\\"a} (not v1.3c) */
4234 "", /* 199 160 \\={\\.A} (not v1.3c) */
4235 "", /* 199 161 \\={\\.a} (not v1.3c) */
4236 "\\={\\AE}", /* 199 162 */
4237 "\\={\\ae}", /* 199 163 */
4238 "", /* 199 164 G-quer (not v1.3c) */
4239 "", /* 199 165 g-quer (not v1.3c) */
4240 "\\v{G}", /* 199 166 */
4241 "\\v{g}", /* 199 167 */
4242 "\\v{K}", /* 199 168 */
4243 "\\v{k}", /* 199 169 */
4244 "\\k{O}", /* 199 170 */
4245 "\\k{o}", /* 199 171 */
4246 "", /* 199 172 \\k{\\=O} (not v1.3c) */
4247 "", /* 199 173 \\k{\\=o} (not v1.3c) */
4248 "", /* 199 174 EZH with \\v (not v1.3c) */
4249 "", /* 199 175 ezh with \\v (not v1.3c) */
4250 "\\v{\\j}", /* 199 176 */
4251 "", /* 199 177 DZ (not v1.3c) */
4252 "", /* 199 178 Dz (not v1.3c) */
4253 "", /* 199 179 dz (not v1.3c) */
4254 "\\\'G", /* 199 180 */
4255 "\\\'g", /* 199 181 */
4256 "", /* 199 182 HWAIR (not v1.3c) */
4257 "", /* 199 183 WYNN (not v1.3c) */
4258 "", /* 199 184 \\`N (not v1.3c) */
4259 "", /* 199 185 \\`n (not v1.3c) */
4260 "", /* 199 186 \\\'{\k{A}} (not v1.3c) */
4261 "", /* 199 187 \\\'{\k{a}} (not v1.3c) */
4262 "", /* 199 188 \\\'{\\AE} (not v1.3c) */
4263 "", /* 199 189 \\\'{\\ae} (not v1.3c) */
4264 "", /* 199 190 \\\'{\\O} (not v1.3c) */
4265 "", /* 199 191 \\\'{\\o} (not v1.3c) */
4266 NULL };
4267
4268 #define OHNINETYNINE 199
4269
4270 char *get_ohninetynine(unsigned char c)
4271 {
4272 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4273 return ohninetynine[c-UTF_BLOCK_BEGIN];
4274 else return "";
4275 }
4276
4277
4278 static char *thnullnull[] = {
4279 "", /* 200 128 A with double grave (not v1.3c) */
4280 "", /* 200 129 a with double grave (not v1.3c) */
4281 "", /* 200 130 A with inverted breve (not v1.3c) */
4282 "", /* 200 131 a with inverted breve (not v1.3c) */
4283 "", /* 200 132 E with double grave (not v1.3c) */
4284 "", /* 200 133 e with double grave (not v1.3c) */
4285 "", /* 200 134 E with inverted breve (not v1.3c) */
4286 "", /* 200 135 e with inverted breve (not v1.3c) */
4287 "", /* 200 136 I with double grave (not v1.3c) */
4288 "", /* 200 137 i with double grave (not v1.3c) */
4289 "", /* 200 138 I with inverted breve (not v1.3c) */
4290 "", /* 200 139 i with inverted breve (not v1.3c) */
4291 "", /* 200 140 O with double grave (not v1.3c) */
4292 "", /* 200 141 o with double grave (not v1.3c) */
4293 "", /* 200 142 O with inverted breve (not v1.3c) */
4294 "", /* 200 143 o with inverted breve (not v1.3c) */
4295 "", /* 200 144 R with double grave (not v1.3c) */
4296 "", /* 200 145 r with double grave (not v1.3c) */
4297 "", /* 200 146 R with inverted breve (not v1.3c) */
4298 "", /* 200 147 r with inverted breve (not v1.3c) */
4299 "", /* 200 148 U with double grave (not v1.3c) */
4300 "", /* 200 149 u with double grave (not v1.3c) */
4301 "", /* 200 150 U with inverted breve (not v1.3c) */
4302 "", /* 200 151 u with inverted breve (not v1.3c) */
4303 "\\textcommabelow{S}", /* 200 152 */
4304 "\\textcommabelow{s}", /* 200 153 */
4305 "\\textcommabelow{T}", /* 200 154 */
4306 "\\textcommabelow{t}", /* 200 155 */
4307 "", /* 200 156 YOGH (not v1.3c) */
4308 "", /* 200 157 yogh (not v1.3c) */
4309 "", /* 200 158 \\v{H} (not v1.3c) */
4310 "", /* 200 159 \\v{h} (not v1.3c) */
4311 "", /* 200 160 N with long right leg (not v1.3c) */
4312 "", /* 200 161 d with curl (not v1.3c) */
4313 "", /* 200 162 OU (not v1.3c) */
4314 "", /* 200 163 ou (not v1.3c) */
4315 "", /* 200 164 Z with hook (not v1.3c) */
4316 "", /* 200 165 z with hook (not v1.3c) */
4317 "", /* 200 166 \\.A (not v1.3c) */
4318 "", /* 200 167 \\.a (not v1.3c) */
4319 "", /* 200 168 \\c{E} (not v1.3c) */
4320 "", /* 200 169 \\c{e} (not v1.3c) */
4321 "", /* 200 170 \\={\\\"O} (not v1.3c) */
4322 "", /* 200 171 \\={\\\"o} (not v1.3c) */
4323 "", /* 200 172 \\={\\~O} (not v1.3c) */
4324 "", /* 200 173 \\={\\~o} (not v1.3c) */
4325 "", /* 200 174 \\.O (not v1.3c) */
4326 "", /* 200 175 \\.o (not v1.3c) */
4327 "", /* 200 176 [\\={\\.O}] (not v1.3c) */
4328 "", /* 200 177 [\\={\\.o}] (not v1.3c) */
4329 "\\=Y", /* 200 178 */
4330 "\\=y", /* 200 179 */
4331 "", /* 200 180 l with curl (not v1.3c) */
4332 "", /* 200 181 n with curl (not v1.3c) */
4333 "", /* 200 182 t with curl (not v1.3c) */
4334 "{\\j}", /* 200 183 */
4335 "", /* 200 184 db digraph (not v1.3c) */
4336 "", /* 200 185 qp digraph (not v1.3c) */
4337 "", /* 200 186 A with diagonal stroke (not v1.3c) */
4338 "", /* 200 187 C with diagonal stroke (not v1.3c) */
4339 "", /* 200 188 {\\textcentoldstyle} (not v1.3c) */
4340 "", /* 200 189 L-quer (not v1.3c) */
4341 "", /* 200 190 T with diagonal stroke (not v1.3c) */
4342 "", /* 200 191 s with swash tail (not v1.3c) */
4343 NULL };
4344
4345 #define THNULLNULL 200
4346
4347 char *get_thnullnull(unsigned char c)
4348 {
4349 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4350 return thnullnull[c-UTF_BLOCK_BEGIN];
4351 else return "";
4352 }
4353
4354
4355 #define THNULLTHREE 203
4356
4357 int ins_thnullthree(char in[], unsigned char c, int pos)
4358 {
4359 if (c == 134) /* 203 134 \\^{} */
4360 pos = insposmaxstr(in, "{\\textasciicircum}", pos, MAXLEN-1);
4361 else
4362 if (c == 135) /* 203 135 \\v{} */
4363 pos = insposmaxstr(in, "{\\textasciicaron}", pos, MAXLEN-1);
4364 else
4365 if (c == 152) /* 203 152 \\u{} */
4366 pos = insposmaxstr(in, "{\\textasciibreve}", pos, MAXLEN-1);
4367 else
4368 if (c == 153) /* 203 153 \\.{} (\text... yet undefined) */
4369 pos = insposmaxstr(in, "{\\textasciidotaccent}", pos, MAXLEN-1);
4370 else
4371 if (c == 155) /* 203 155 \\k{} (\text... yet undefined) */
4372 pos = insposmaxstr(in, "{\\textasciiogonek}", pos, MAXLEN-1);
4373 else
4374 if (c == 156) /* 203 156 \\~{} */
4375 pos = insposmaxstr(in, "{\\textasciitilde}", pos, MAXLEN-1);
4376 else
4377 if (c == 157) /* 203 157 \\H{} */
4378 pos = insposmaxstr(in, "{\\textacutedbl}", pos, MAXLEN-1);
4379
4380 return pos;
4381 }
4382
4383
4384 static char *thtwentyfive_oheightyfour[] = {
4385 "", /* 225 184 128 A with ring below (not v1.3c) */
4386 "", /* 225 184 129 a with ring below (not v1.3c) */
4387 "\\.B", /* 225 184 130 */
4388 "\\.b", /* 225 184 131 */
4389 "", /* 225 184 132 \\d{B} (not v1.3c) */
4390 "", /* 225 184 133 \\d{b} (not v1.3c) */
4391 "", /* 225 184 134 \\b{B} (not v1.3c) */
4392 "", /* 225 184 135 \\b{b} (not v1.3c) */
4393 "", /* 225 184 136 \\c{\\\'C} (not v1.3c) */
4394 "", /* 225 184 137 \\c{\\\'c} (not v1.3c) */
4395 "", /* 225 184 138 \\.D (not v1.3c) */
4396 "", /* 225 184 139 \\.d (not v1.3c) */
4397 "", /* 225 184 140 \\d{D} (not v1.3c) */
4398 "\\d{d}", /* 225 184 141 */
4399 "", /* 225 184 142 \\b{D} (not v1.3c) */
4400 "", /* 225 184 143 \\b{d} (not v1.3c) */
4401 "", /* 225 184 144 \\textcommabelow{D} (not v1.3c) */
4402 "", /* 225 184 145 \\textcommabelow{d} (not v1.3c) */
4403 "", /* 225 184 146 D with circumflex below (not v1.3c) */
4404 "", /* 225 184 147 d with circumflex below (not v1.3c) */
4405 "", /* 225 184 148 [\\`{\\=E}] (not v1.3c) */
4406 "", /* 225 184 149 [\\`{\\=e}] (not v1.3c) */
4407 "", /* 225 184 150 [\\\'{\\=E}] (not v1.3c) */
4408 "", /* 225 184 151 [\\\'{\\=e}] (not v1.3c) */
4409 "", /* 225 184 152 E with circumflex below (not v1.3c) */
4410 "", /* 225 184 153 e with circumflex below (not v1.3c) */
4411 "", /* 225 184 154 E with tilde below (not v1.3c) */
4412 "", /* 225 184 155 e with tilde below (not v1.3c) */
4413 "", /* 225 184 156 [\\u{\\c{E}}] (not v1.3c) */
4414 "", /* 225 184 157 [\\u{\\c{e}}] (not v1.3c) */
4415 "\\.F", /* 225 184 158 new in 2.4 / v1.2n */
4416 "\\.f", /* 225 184 159 new in 2.4 / v1.2n */
4417 "\\=G", /* 225 184 160 */
4418 "\\=g", /* 225 184 161 */
4419 "", /* 225 184 162 \\.H (not v1.3c) */
4420 "", /* 225 184 163 \\.h (not v1.3c) */
4421 "", /* 225 184 164 \\d{H} (not v1.3c) */
4422 "\\d{h}", /* 225 184 165 */
4423 "", /* 225 184 166 \\\"H (not v1.3c) */
4424 "", /* 225 184 167 \\\"h (not v1.3c) */
4425 "", /* 225 184 168 \\c{H} [?] (not v1.3c) */
4426 "", /* 225 184 169 \\c{h} [?] (not v1.3c) */
4427 "", /* 225 184 170 H with breve below (not v1.3c) */
4428 "", /* 225 184 171 h with breve below (not v1.3c) */
4429 "", /* 225 184 172 I with tilde below (not v1.3c) */
4430 "", /* 225 184 173 i with tilde below (not v1.3c) */
4431 "", /* 225 184 174 \\\'{\\\"I} (not v1.3c) */
4432 "", /* 225 184 175 \\\'{\\\"{\\i}} (not v1.3c) */
4433 "\\\'K", /* 225 184 176 new in 2.4 / v1.2n */
4434 "\\\'k", /* 225 184 177 new in 2.4 / v1.2n */
4435 "", /* 225 184 178 \\d{K} (not v1.3c) */
4436 "", /* 225 184 179 \\d{k} (not v1.3c) */
4437 "", /* 225 184 180 \\b{K} (not v1.3c) */
4438 "", /* 225 184 181 \\b{k} (not v1.3c) */
4439 "", /* 225 184 182 \\d{L} (not v1.3c) */
4440 "\\d{l}", /* 225 184 183 */
4441 "", /* 225 184 184 \\d{\\=L} (not v1.3c) */
4442 "", /* 225 184 185 \\d{\\=l} (not v1.3c) */
4443 "", /* 225 184 186 \\b{L} (not v1.3c) */
4444 "", /* 225 184 187 \\b{l} (not v1.3c) */
4445 "", /* 225 184 188 L with circumflex below (not v1.3c) */
4446 "", /* 225 184 189 l with circumflex below (not v1.3c) */
4447 "", /* 225 184 190 \\\'M (not v1.3c) */
4448 "", /* 225 184 191 \\\'m (not v1.3c) */
4449 NULL };
4450
4451 #define THTWENTYFIVE 225
4452 #define THTWENTYFIVE_OHEIGHTYFOUR 184
4453
4454 char *get_thtwentyfive_oheightyfour(unsigned char c)
4455 {
4456 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4457 return thtwentyfive_oheightyfour[c-UTF_BLOCK_BEGIN];
4458 else return "";
4459 }
4460
4461
4462 static char *thtwentyfive_oheightyfive[] = {
4463 "", /* 225 185 128 \\.M (not v1.3c) */
4464 "", /* 225 185 129 \\.m (not v1.3c) */
4465 "", /* 225 185 130 \\d{M} (not v1.3c) */
4466 "\\d{m}", /* 225 185 131 */
4467 "", /* 225 185 132 \\.N (not v1.3c) */
4468 "\\.n", /* 225 185 133 */
4469 "", /* 225 185 134 \\d{N} (not v1.3c) */
4470 "\\d{n}", /* 225 185 135 */
4471 "", /* 225 185 136 N with line below (not v1.3c) */
4472 "", /* 225 185 137 n with line below (not v1.3c) */
4473 "", /* 225 185 138 N with circumflex below (not v1.3c) */
4474 "", /* 225 185 139 n with circumflex below (not v1.3c) */
4475 "", /* 225 185 140 \\\'{\\~O} (not v1.3c) */
4476 "", /* 225 185 141 \\\'{\\~o} (not v1.3c) */
4477 "", /* 225 185 142 \\\"{\\~O} (not v1.3c) */
4478 "", /* 225 185 143 \\\"{\\~o} (not v1.3c) */
4479 "", /* 225 185 144 [\\`{\\=O}] (not v1.3c) */
4480 "", /* 225 185 145 [\\`{\\=o}] (not v1.3c) */
4481 "", /* 225 185 146 [\\\'{\\=O}] (not v1.3c) */
4482 "", /* 225 185 147 [\\\'{\\=o}] (not v1.3c) */
4483 "", /* 225 185 148 \\\'P (not v1.3c) */
4484 "", /* 225 185 149 \\\'p (not v1.3c) */
4485 "", /* 225 185 150 \\.P (not v1.3c) */
4486 "", /* 225 185 151 \\.p (not v1.3c) */
4487 "", /* 225 185 152 \\.R (not v1.3c) */
4488 "", /* 225 185 153 \\.r (not v1.3c) */
4489 "", /* 225 185 154 \\d{R} (not v1.3c) */
4490 "\\d{r}", /* 225 185 155 */
4491 "", /* 225 185 156 \\d{\\=R} (not v1.3c) */
4492 "", /* 225 185 157 \\d{\\=r} (not v1.3c) */
4493 "", /* 225 185 158 R with line below (not v1.3c) */
4494 "", /* 225 185 159 r with line below (not v1.3c) */
4495 "", /* 225 185 160 \\.S (not v1.3c) */
4496 "", /* 225 185 161 \\.s (not v1.3c) */
4497 "", /* 225 185 162 \\d{S} (not v1.3c) */
4498 "\\d{s}", /* 225 185 163 */
4499 "", /* 225 185 164 \\.{\\\'S} (not v1.3c) */
4500 "", /* 225 185 165 \\.{\\\'s} (not v1.3c) */
4501 "", /* 225 185 166 \\.{\\v{S}} (not v1.3c) */
4502 "", /* 225 185 167 \\.{\\v{s}} (not v1.3c) */
4503 "", /* 225 185 168 \\d{\\.S} (not v1.3c) */
4504 "", /* 225 185 169 \\d{\\.s} (not v1.3c) */
4505 "", /* 225 185 170 \\.T (not v1.3c) */
4506 "", /* 225 185 171 \\.t (not v1.3c) */
4507 "", /* 225 185 172 \\d{T} (not v1.3c) */
4508 "\\d{t}", /* 225 185 173 */
4509 "", /* 225 185 174 T with line below (not v1.3c) */
4510 "", /* 225 185 175 t with line below (not v1.3c) */
4511 "", /* 225 185 176 T with circumfelx below (not v1.3c) */
4512 "", /* 225 185 177 t with circumfelx below (not v1.3c) */
4513 "", /* 225 185 178 U with dieresis below (not v1.3c) */
4514 "", /* 225 185 179 u with dieresis below (not v1.3c) */
4515 "", /* 225 185 180 U with tilde below (not v1.3c) */
4516 "", /* 225 185 181 u with tilde below (not v1.3c) */
4517 "", /* 225 185 182 U with circumflex below (not v1.3c) */
4518 "", /* 225 185 183 u with circumflex below (not v1.3c) */
4519 "", /* 225 185 184 [\\\'{\\~U}] (not v1.3c) */
4520 "", /* 225 185 185 [\\\'{\\~u}] (not v1.3c) */
4521 "", /* 225 185 186 [\\\"{\\=U}] (not v1.3c) */
4522 "", /* 225 185 187 [\\\"{\\=u}] (not v1.3c) */
4523 "", /* 225 185 188 \\~V (not v1.3c) */
4524 "", /* 225 185 189 \\~v (not v1.3c) */
4525 "", /* 225 185 190 \\d{V} (not v1.3c) */
4526 "", /* 225 185 191 \\d{v} (not v1.3c) */
4527 NULL };
4528
4529 #define THTWENTYFIVE_OHEIGHTYFIVE 185
4530
4531 char *get_thtwentyfive_oheightyfive(unsigned char c)
4532 {
4533 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4534 return thtwentyfive_oheightyfive[c-UTF_BLOCK_BEGIN];
4535 else return "";
4536 }
4537
4538
4539 static char *thtwentyfive_oheightysix[] = { /* new in 2.4 */
4540 "", /* 225 186 128 \\`W (not v1.3c) */
4541 "", /* 225 186 129 \\`w (not v1.3c) */
4542 "", /* 225 186 130 \\\'W (not v1.3c) */
4543 "", /* 225 186 131 \\\'w (not v1.3c) */
4544 "", /* 225 186 132 \\\"W (not v1.3c) */
4545 "", /* 225 186 133 \\\"w (not v1.3c) */
4546 "", /* 225 186 134 \\.W (not v1.3c) */
4547 "", /* 225 186 135 \\.w (not v1.3c) */
4548 "", /* 225 186 136 \\d{W} (not v1.3c) */
4549 "", /* 225 186 137 \\d{w} (not v1.3c) */
4550 "", /* 225 186 138 \\.X (not v1.3c) */
4551 "", /* 225 186 139 \\.x (not v1.3c) */
4552 "", /* 225 186 140 \\\"X (not v1.3c) */
4553 "", /* 225 186 141 \\\"x (not v1.3c) */
4554 "\\.Y", /* 225 186 142 new in 2.4 / v1.2n */
4555 "\\.y", /* 225 186 143 new in 2.4 / v1.2n */
4556 "\\^Z", /* 225 186 144 new in 2.4 / v1.2n */
4557 "\\^z", /* 225 186 145 new in 2.4 / v1.2n */
4558 "", /* 225 186 146 \\d{Z} (not v1.3c) */
4559 "", /* 225 186 147 \\d{z} (not v1.3c) */
4560 "", /* 225 186 148 Z with line below (not v1.3c) */
4561 "", /* 225 186 149 z with line below (not v1.3c) */
4562 "", /* 225 186 150 h with line below (not v1.3c) */
4563 "", /* 225 186 151 \\\"t (not v1.3c) */
4564 "", /* 225 186 152 \\r{w} (not v1.3c) */
4565 "", /* 225 186 153 \\r{y} (not v1.3c) */
4566 "", /* 225 186 154 a with right half ring (not v1.3c) */
4567 "", /* 225 186 155 long s with dot above (not v1.3c) */
4568 "", /* 225 186 156 long s with diagonal stroke (not v1.3c) */
4569 "", /* 225 186 157 long s with high stroke (not v1.3c) */
4570 "{\\SS}", /* 225 186 158 */
4571 "", /* 225 186 159 \\delta (not v1.3c) */
4572 "", /* 225 186 160 \\d{A} (not v1.3c) */
4573 "", /* 225 186 161 \\d{a} (not v1.3c) */
4574 "", /* 225 186 162 A with hook above (not v1.3c) */
4575 "", /* 225 186 163 a with hook above (not v1.3c) */
4576 "", /* 225 186 164 A with circumflex-acute (not v1.3c) */
4577 "", /* 225 186 165 a with circumflex-acute (not v1.3c) */
4578 "", /* 225 186 166 A with circumflex-grave (not v1.3c) */
4579 "", /* 225 186 167 a with circumflex-grave (not v1.3c) */
4580 "", /* 225 186 168 A with circumflex-hook (not v1.3c) */
4581 "", /* 225 186 169 a with circumflex-hook (not v1.3c) */
4582 "", /* 225 186 170 \\~{\\^A} (not v1.3c) */
4583 "", /* 225 186 171 \\~{\\^a} (not v1.3c) */
4584 "", /* 225 186 172 \\d{\\^A} (not v1.3c) */
4585 "", /* 225 186 173 \\d{\\^a} (not v1.3c) */
4586 "", /* 225 186 174 A with breve-acute (not v1.3c) */
4587 "", /* 225 186 175 a with breve-acute (not v1.3c) */
4588 "", /* 225 186 176 A with breve-grave (not v1.3c) */
4589 "", /* 225 186 177 a with breve-grave (not v1.3c) */
4590 "", /* 225 186 178 A with breve-hook (not v1.3c) */
4591 "", /* 225 186 179 a with breve-hook (not v1.3c) */
4592 "", /* 225 186 180 A with breve-tilde (not v1.3c) */
4593 "", /* 225 186 181 a with breve-tilde (not v1.3c) */
4594 "", /* 225 186 182 \\d{\\u{A}} (not v1.3c) */
4595 "", /* 225 186 183 \\d{\\u{a}} (not v1.3c) */
4596 "", /* 225 186 184 \\d{E} (not v1.3c) */
4597 "", /* 225 186 185 \\d{e} (not v1.3c) */
4598 "", /* 225 186 186 E with hook above (not v1.3c) */
4599 "", /* 225 186 187 e with hook above (not v1.3c) */
4600 "", /* 225 186 188 \\~E (not v1.3c) */
4601 "", /* 225 186 189 \\~e (not v1.3c) */
4602 "", /* 225 186 190 E with circumflex-acute (not v1.3c) */
4603 "", /* 225 186 191 e with circumflex-acute (not v1.3c) */
4604 NULL };
4605
4606 #define THTWENTYFIVE_OHEIGHTYSIX 186
4607
4608 char *get_thtwentyfive_oheightysix(unsigned char c)
4609 {
4610 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4611 return thtwentyfive_oheightysix[c-UTF_BLOCK_BEGIN];
4612 else return "";
4613 }
4614
4615
4616 static char *thtwentysix_ohtwentyeight[] = {
4617 "", /* 226 128 128 en quad (not v1.3c) */
4618 "", /* 226 128 129 em quad (not v1.3c) */
4619 "", /* 226 128 130 en space (not v1.3c) */
4620 "", /* 226 128 131 em space (not v1.3c) */
4621 "", /* 226 128 132 three-per-em space (not v1.3c) */
4622 "", /* 226 128 133 four-per-em space (not v1.3c) */
4623 "", /* 226 128 134 six-per-em space (not v1.3c) */
4624 "", /* 226 128 135 figure space (not v1.3c) */
4625 "", /* 226 128 136 punctuation space (not v1.3c) */
4626 "", /* 226 128 137 thin space (not v1.3c) */
4627 "", /* 226 128 138 hair space (not v1.3c) */
4628 "", /* 226 128 139 zero width space (not v1.3c) */
4629 "{\\textcompwordmark}", /* 226 128 140 (LaTeX-Example: b\u{226-128-140}g) */
4630 "", /* 226 128 141 zero width joiner (not v1.3c) */
4631 "", /* 226 128 142 left-to-right mark (not v1.3c) */
4632 "", /* 226 128 143 right-to-left mark (not v1.3c) */
4633 "-", /* 226 128 144 */
4634 "\\mbox{-}", /* 226 128 145 - */
4635 "{\\textendash}", /* 226 128 146 -- */
4636 "{\\textendash}", /* 226 128 147 -- */
4637 "{\\textemdash}", /* 226 128 148 --- */
4638 "{\\textemdash}", /* 226 128 149 --- */
4639 "{\\textbardbl}", /* 226 128 150 */
4640 "", /* 226 128 151 double low line (not v1.3c) */
4641 "{\\textquoteleft}", /* 226 128 152 ` */
4642 "{\\textquoteright}", /* 226 128 153 \' */
4643 "{\\quotesinglbase}", /* 226 128 154 , */
4644 "", /* 226 128 155 single high-reversed-9 quotation mark (not v1.3c) */
4645 "{\\textquotedblleft}", /* 226 128 156 `` */
4646 "{\\textquotedblright}", /* 226 128 157 \'\' */
4647 "{\\quotedblbase}", /* 226 128 158 ,, */
4648 "", /* 226 128 159 double high-reversed-9 quotation mark (not v1.3c) */
4649 "{\\textdagger}", /* 226 128 160 {\\dag} */
4650 "{\\textdaggerdbl}", /* 226 128 161 {\\ddag} */
4651 "{\\textbullet}", /* 226 128 162 */
4652 "", /* 226 128 163 triangular bullet (not v1.3c) */
4653 "", /* 226 128 164 one dot leader (not v1.3c) */
4654 "", /* 226 128 165 two dot leader (not v1.3c) */
4655 "{\\textellipsis}", /* 226 128 166 {\\dots} */
4656 "", /* 226 128 167 hyphenation point (not v1.3c) */
4657 "", /* 226 128 168 line separator (not v1.3c) */
4658 "", /* 226 128 169 paragraph separator (not v1.3c) */
4659 "", /* 226 128 170 left-to-right embedding (not v1.3c) */
4660 "", /* 226 128 171 right-to-left embedding (not v1.3c) */
4661 "", /* 226 128 172 pop directional formatting (not v1.3c) */
4662 "", /* 226 128 173 left-to-right override (not v1.3c) */
4663 "", /* 226 128 174 right-to-left override (not v1.3c) */
4664 "", /* 226 128 175 narrow no-break space (not v1.3c) */
4665 "{\\textperthousand}", /* 226 128 176 */
4666 "{\\textpertenthousand}", /* 226 128 177 */
4667 "", /* 226 128 178 prime (not v1.3c) */
4668 "", /* 226 128 179 double prime (not v1.3c) */
4669 "", /* 226 128 180 triple prime (not v1.3c) */
4670 "", /* 226 128 181 reversed prime (not v1.3c) */
4671 "", /* 226 128 182 reversed double prime (not v1.3c) */
4672 "", /* 226 128 183 reversed triple prime (not v1.3c) */
4673 "", /* 226 128 184 caret (not v1.3c) */
4674 "{\\guilsinglleft}", /* 226 128 185 */
4675 "{\\guilsinglright}", /* 226 128 186 */
4676 "{\\textreferencemark}", /* 226 128 187 */
4677 "", /* 226 128 188 "!!" (double exclamation mark) (not v1.3c) */
4678 "{\\textinterrobang}", /* 226 128 189 */
4679 "", /* 226 128 190 overline (not v1.3c) */
4680 "", /* 226 128 191 undertie (not v1.3c) */
4681 NULL };
4682
4683 #define THTWENTYSIX 226
4684 #define THTWENTYSIX_OHTWENTYEIGHT 128
4685
4686 char *get_thtwentysix_ohtwentyeight(unsigned char c)
4687 {
4688 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4689 return thtwentysix_ohtwentyeight[c-UTF_BLOCK_BEGIN];
4690 else return "";
4691 }
4692
4693
4694 static char *thtwentysix_ohthirty[] = {
4695 "", /* 226 130 128 _0 (not v1.3c) */
4696 "", /* 226 130 129 _1 (not v1.3c) */
4697 "", /* 226 130 130 _2 (not v1.3c) */
4698 "", /* 226 130 131 _3 (not v1.3c) */
4699 "", /* 226 130 132 _4 (not v1.3c) */
4700 "", /* 226 130 133 _5 (not v1.3c) */
4701 "", /* 226 130 134 _6 (not v1.3c) */
4702 "", /* 226 130 135 _7 (not v1.3c) */
4703 "", /* 226 130 136 _8 (not v1.3c) */
4704 "", /* 226 130 137 _9 (not v1.3c) */
4705 "", /* 226 130 138 _+ (not v1.3c) */
4706 "", /* 226 130 139 _- (not v1.3c) */
4707 "", /* 226 130 140 _= (not v1.3c) */
4708 "", /* 226 130 141 _( (not v1.3c) */
4709 "", /* 226 130 142 _) (not v1.3c) */
4710 "", /* 226 130 143 [undefined] (not v1.3c) */
4711 "", /* 226 130 144 _a (not v1.3c) */
4712 "", /* 226 130 145 _e (not v1.3c) */
4713 "", /* 226 130 146 _o (not v1.3c) */
4714 "", /* 226 130 147 _x (not v1.3c) */
4715 "", /* 226 130 148 _{schwa} (not v1.3c) */
4716 "", /* 226 130 149 _h (not v1.3c) */
4717 "", /* 226 130 150 _k (not v1.3c) */
4718 "", /* 226 130 151 _l (not v1.3c) */
4719 "", /* 226 130 152 _m (not v1.3c) */
4720 "", /* 226 130 153 _n (not v1.3c) */
4721 "", /* 226 130 154 _p (not v1.3c) */
4722 "", /* 226 130 155 _s (not v1.3c) */
4723 "", /* 226 130 156 _t (not v1.3c) */
4724 "", /* 226 130 157 [undefined] (not v1.3c) */
4725 "", /* 226 130 158 [undefined] (not v1.3c) */
4726 "", /* 226 130 159 [undefined] (not v1.3c) */
4727 "", /* 226 130 160 euro-currency sign (not v1.3c) */
4728 "{\\textcolonmonetary}", /* 226 130 161 */
4729 "", /* 226 130 162 cruzeiro sign (not v1.3c) */
4730 "", /* 226 130 163 french franc sign (not v1.3c) */
4731 "{\\textlira}", /* 226 130 164 */
4732 "", /* 226 130 165 mill sign (not v1.3c) */
4733 "{\\textnaira}", /* 226 130 166 */
4734 "", /* 226 130 167 peseta sign (not v1.3c) */
4735 "", /* 226 130 168 rupee sign (not v1.3c) */
4736 "{\\textwon}", /* 226 130 169 */
4737 "", /* 226 130 170 new sheqel sign (not v1.3c) */
4738 "{\\textdong}", /* 226 130 171 */
4739 "{\\texteuro}", /* 226 130 172 */
4740 "", /* 226 130 173 kip sign (not v1.3c) */
4741 "", /* 226 130 174 tugrik sign (not v1.3c) */
4742 "", /* 226 130 175 drachma sign (not v1.3c) */
4743 "", /* 226 130 176 german penny sign (not v1.3c) */
4744 "{\\textpeso}", /* 226 130 177 */
4745 "", /* 226 130 178 guarani sign (not v1.3c) */
4746 "", /* 226 130 179 austral sign (not v1.3c) */
4747 "", /* 226 130 180 hryvnia sign (not v1.3c) */
4748 "", /* 226 130 181 cedi sign (not v1.3c) */
4749 "", /* 226 130 182 livre tournois sign (not v1.3c) */
4750 "", /* 226 130 183 spesmilo sign (not v1.3c) */
4751 "", /* 226 130 184 tenge sign (not v1.3c) */
4752 "", /* 226 130 185 indian rupee sign (not v1.3c) */
4753 "", /* 226 130 186 turkish lira sign (not v1.3c) */
4754 "", /* 226 130 187 nordic mark sign (not v1.3c) */
4755 "", /* 226 130 188 manat sign (not v1.3c) */
4756 "", /* 226 130 189 ruble sign (not v1.3c) */
4757 "", /* 226 130 190 lari sign (not v1.3c) */
4758 "", /* 226 130 191 bitcoin sign (not v1.3c) */
4759 NULL };
4760
4761 #define THTWENTYSIX_OHTHIRTY 130
4762
4763 char *get_thtwentysix_ohthirty(unsigned char c)
4764 {
4765 if (c >= UTF_BLOCK_BEGIN && c <= UTF_BLOCK_END) /* 128 ... 191 */
4766 return thtwentysix_ohthirty[c-UTF_BLOCK_BEGIN];
4767 else return "";
4768 }
4769
4770
4771 int ins_rest_thtwentysix(char in[], unsigned char a, unsigned char b, int pos)
4772 {
4773 if (a == 129 && b == 132) /* 226 129 132 not exactly "/" */
4774 pos = insposmaxstr(in, "{\\textfractionsolidus}", pos, MAXLEN-1);
4775 else
4776 if (a == 129 && b == 142) /* 226 129 142 */
4777 pos = insposmaxstr(in, "{\\textasteriskcentered}", pos, MAXLEN-1);
4778 else
4779 if (a == 129 && b == 146) /* 226 129 146 \\% */
4780 pos = insposmaxstr(in, "{\\textdiscount}", pos, MAXLEN-1);
4781 else
4782 if (a == 132 && b == 131) /* 226 132 131 not exactly {\\textdegree C} */
4783 pos = insposmaxstr(in, "{\\textcelsius}", pos, MAXLEN-1);
4784 else
4785 if (a == 132 && b == 150) /* 226 132 150 */
4786 pos = insposmaxstr(in, "{\\textnumero}", pos, MAXLEN-1);
4787 else
4788 if (a == 132 && b == 151) /* 226 132 151 */
4789 pos = insposmaxstr(in, "{\\textcircledP}", pos, MAXLEN-1);
4790 else
4791 if (a == 132 && b == 158) /* 226 132 158 */
4792 pos = insposmaxstr(in, "{\\textrecipe}", pos, MAXLEN-1);
4793 else
4794 if (a == 132 && b == 160) /* 226 132 160 */
4795 pos = insposmaxstr(in, "{\\textservicemark}", pos, MAXLEN-1);
4796 else
4797 if (a == 132 && b == 162) /* 226 132 162 */
4798 pos = insposmaxstr(in, "{\\texttrademark}", pos, MAXLEN-1);
4799 else
4800 if (a == 132 && b == 166) /* 226 132 166 {\\Omega} */
4801 pos = insposmaxstr(in, "{\\textohm}", pos, MAXLEN-1);
4802 else
4803 if (a == 132 && b == 167) /* 226 132 167 */
4804 pos = insposmaxstr(in, "{\\textmho}", pos, MAXLEN-1);
4805 else
4806 if (a == 132 && b == 174) /* 226 132 174 */
4807 pos = insposmaxstr(in, "{\\textestimated}", pos, MAXLEN-1);
4808 else
4809 if (a == 134 && b == 144) /* 226 134 144 {\\leftarrow} */
4810 pos = insposmaxstr(in, "{\\textleftarrow}", pos, MAXLEN-1);
4811 else
4812 if (a == 134 && b == 145) /* 226 134 145 {\\uparrow} */
4813 pos = insposmaxstr(in, "{\\textuparrow}", pos, MAXLEN-1);
4814 else
4815 if (a == 134 && b == 146) /* 226 134 146 {\\rightarrow} */
4816 pos = insposmaxstr(in, "{\\textrightarrow}", pos, MAXLEN-1);
4817 else
4818 if (a == 134 && b == 147) /* 226 134 147 {\\downarrow} */
4819 pos = insposmaxstr(in, "{\\textdownarrow}", pos, MAXLEN-1);
4820 else
4821 if (a == 140 && b == 169) /* 226 140 169 */
4822 pos = insposmaxstr(in, "{\\textlangle}", pos, MAXLEN-1);
4823 else
4824 if (a == 140 && b == 170) /* 226 140 170 */
4825 pos = insposmaxstr(in, "{\\textrangle}", pos, MAXLEN-1);
4826 else
4827 if (a == 144 && b == 162) /* 226 144 162 */
4828 pos = insposmaxstr(in, "{\\textblank}", pos, MAXLEN-1);
4829 else
4830 if (a == 144 && b == 163) /* 226 144 163 */
4831 pos = insposmaxstr(in, "{\\textvisiblespace}", pos, MAXLEN-1);
4832 else
4833 if (a == 151 && b == 166) /* 226 151 166 */
4834 pos = insposmaxstr(in, "{\\textopenbullet}", pos, MAXLEN-1);
4835 else
4836 if (a == 151 && b == 175) /* 226 151 175 */
4837 pos = insposmaxstr(in, "{\\textbigcircle}", pos, MAXLEN-1);
4838 else
4839 if (a == 153 && b == 170) /* 226 153 170 */
4840 pos = insposmaxstr(in, "{\\textmusicalnote}", pos, MAXLEN-1);
4841 else
4842 if (a == 159 && b == 168) /* 226 159 168 */
4843 pos = insposmaxstr(in, "{\\textlangle}", pos, MAXLEN-1);
4844 else
4845 if (a == 159 && b == 169) /* 226 159 169 */
4846 pos = insposmaxstr(in, "{\\textrangle}", pos, MAXLEN-1);
4847
4848 return pos;
4849 }
4850
4851
4852 #define THTWENTYSEVEN 227
4853
4854
4855 #define THTHIRTYNINE 239
4856
4857 int ins_ththirtynine(char in[], unsigned char b, unsigned char c, int pos)
4858 {
4859 if (b == 187 && c == 191) /* 239 187 191 */
4860 pos = insposmaxstr(in, "{\\ifhmode\\nobreak\\fi}", pos, MAXLEN-1);
4861 else
4862 if (b == 172 && c == 128) /* 239 172 128 */
4863 pos = insposmaxstr(in, "{ff}", pos, MAXLEN-1);
4864 else
4865 if (b == 172 && c == 129) /* 239 172 129 */
4866 pos = insposmaxstr(in, "{fi}", pos, MAXLEN-1);
4867 else
4868 if (b == 172 && c == 130) /* 239 172 130 */
4869 pos = insposmaxstr(in, "{fl}", pos, MAXLEN-1);
4870 else
4871 if (b == 172 && c == 131) /* 239 172 131 */
4872 pos = insposmaxstr(in, "{ffi}", pos, MAXLEN-1);
4873 else
4874 if (b == 172 && c == 132) /* 239 172 132 */
4875 pos = insposmaxstr(in, "{ffl}", pos, MAXLEN-1);
4876 else
4877 if (b == 172 && c == 133) /* 239 172 133 */
4878 pos = insposmaxstr(in, "{st}", pos, MAXLEN-1);
4879 else
4880 if (b == 172 && c == 134) /* 239 172 134 */
4881 pos = insposmaxstr(in, "{st}", pos, MAXLEN-1);
4882
4883 return pos;
4884 }
4885
4886
4887 int lenUTFacht(unsigned char a, unsigned char b, unsigned char c, unsigned char d)
4888 {
4889 int r = 1; /* einstelliges Zeichen, es sei denn: */
4890
4891 if ( a >= DOUBLETTES_BEGIN && a <= DOUBLETTES_END /* 194 ... 223 */
4892 && b >= UTF_BLOCK_BEGIN && b <= UTF_BLOCK_END /* 128 ... 191 */
4893 ) r = 2;
4894 else
4895 if ( a == TRIPLETTES_BEGIN /* 224 */
4896 && b >= 160 && b <= 191
4897 && c >= 128 && c <= 191
4898 ) r = 3;
4899 else
4900 if ( a >= 225 && a <= TRIPLETTES_END /* 239 */
4901 && b >= 128 && b <= 191
4902 && c >= 128 && c <= 191
4903 ) r = 3;
4904 else
4905 if ( a == QUADRUPLES_BEGIN /* 240 */
4906 && b >= 144 && b <= 191
4907 && c >= 128 && c <= 191
4908 && d >= 128 && d <= 191
4909 ) r = 4;
4910 else
4911 if ( a >= 241 && a <= 243
4912 && b >= 128 && b <= 191
4913 && c >= 128 && c <= 191
4914 && d >= 128 && d <= 191
4915 ) r = 4;
4916 else
4917 if ( a == QUADRUPLES_END /* 244 */
4918 && b >= 128 && b <= 143
4919 && c >= 128 && c <= 191
4920 && d >= 128 && d <= 191
4921 ) r = 4;
4922
4923 return r;
4924 }
4925
4926
4927 int signeless(unsigned char a)
4928 {
4929 return a;
4930 }
4931
4932
4933 int reg_utf_eight(int l, int val, char ch[UTF_EIGHT_MAXERR][UTF_EIGHT_MAXLEN+1], const char *p)
4934 {
4935 int i, entry = 0, found = 0;
4936 const char *q;
4937
4938 if (val < UTF_EIGHT_MAXERR)
4939 {
4940 while (entry < val)
4941 {
4942 i = 0;
4943 while (i < l && ch[entry][i] == *(p+i) && *(p+i) != '\0') ++i;
4944 if ( i > 0 /* i > 0 added in 2.4 */
4945 && ch[entry][i] == '\0'
4946 && (*(p+i) == '\0' || i == l) /* i == l added in 2.4 */
4947 )
4948 {
4949 found = 1;
4950 break;
4951 }
4952 ++entry;
4953 }
4954
4955 if (l <= UTF_EIGHT_MAXLEN)
4956 {
4957 if (found == 0)
4958 { /* gcc-troubles ch[val][i] = *(p+i++); */
4959 q = p; i = 0;
4960 while (i < l && *q != '\0') ch[val][i++] = *q++;
4961 while (i <= UTF_EIGHT_MAXLEN) ch[val][i++] = '\0';
4962 ++val;
4963 }
4964 }
4965 else intern_err(33);
4966 }
4967
4968 return val;
4969 }
4970
4971
4972 int utf_eight_err(const char *p)
4973 {
4974 int l = 1, c = ((unsigned char)*p), plen;
4975
4976 if (c >= DOUBLETTES_BEGIN && c <= DOUBLETTES_END) l = 2; /* 194 ... 223 */
4977 else
4978 if (c >= TRIPLETTES_BEGIN && c <= TRIPLETTES_END) l = 3; /* 224 ... 239 */
4979 else
4980 if (c >= QUADRUPLES_BEGIN && c <= QUADRUPLES_END) l = 4; /* 240 ... 244 */
4981
4982 /* l == 1 if \GenericError stays and the char is in its arguments */
4983 if (l >= 1)
4984 {
4985 utf_err_c = reg_utf_eight(l, utf_err_c, err_utf_eight, p);
4986 if (l <= UTF_EIGHT_MAXLEN) mystrncpy(this_err_utf_eight, p, l);
4987 if ((plen=strlen(p)) < l) l = plen;
4988 }
4989
4990 return l;
4991 }
4992
4993
4994 void utf_eight_emp(const char *p, int len, int pos, int oldpos)
4995 {
4996 if (pos == oldpos)
4997 {
4998 utf_emp_c = reg_utf_eight(len, utf_emp_c, emp_utf_eight, p);
4999 if (len <= UTF_EIGHT_MAXLEN) mystrncpy(this_emp_utf_eight, p, len);
5000 }
5001 }
5002
5003
5004 void get_utf_eight(char in[], const char *p)
5005 {
5006 int len, oldpos = 0, pos = 0, a;
5007
5008 if (*p < 0) lastupperascii = *p; /* invalid *(p+1) == '\0' */
5009
5010 while (*p != '\0' && *(p+1) != '\0' && pos < MAXLEN-1)
5011 {
5012 len = 1; /* einstelliges Zeichen, es sei denn: */
5013
5014 if (*p < 0)
5015 {
5016 lastupperascii = *p;
5017
5018 if (*(p+2) != '\0' && *(p+3) != '\0')
5019 {
5020 len = lenUTFacht(*p, *(p+1), *(p+2), *(p+3));
5021 }
5022 else
5023 if (*(p+2) != '\0')
5024 {
5025 len = lenUTFacht(*p, *(p+1), *(p+2), '\0');
5026 }
5027 else
5028 {
5029 len = lenUTFacht(*p, *(p+1), '\0', '\0');
5030 }
5031 }
5032
5033 a = signeless(*p);
5034
5035 if (len == 2)
5036 {
5037 if (a == OHNINETYFOUR)
5038 pos = insposmaxstr(in, get_ohninetyfour(*(p+1)), pos, MAXLEN-1);
5039 else
5040 if (a == OHNINETYFIVE)
5041 pos = insposmaxstr(in, get_ohninetyfive(*(p+1)), pos, MAXLEN-1);
5042 else
5043 if (a == OHNINETYSIX)
5044 pos = insposmaxstr(in, get_ohninetysix(*(p+1)), pos, MAXLEN-1);
5045 else
5046 if (a == OHNINETYSEVEN)
5047 pos = insposmaxstr(in, get_ohninetyseven(*(p+1)), pos, MAXLEN-1);
5048 else
5049 if (a == 198 && signeless(*(p+1)) == 146) /* 198 146 */
5050 pos = insposmaxstr(in, "{\\textflorin}", pos, MAXLEN-1);
5051 else
5052 if (a == OHNINETYNINE)
5053 pos = insposmaxstr(in, get_ohninetynine(*(p+1)), pos, MAXLEN-1);
5054 else
5055 if (a == THNULLNULL)
5056 pos = insposmaxstr(in, get_thnullnull(*(p+1)), pos, MAXLEN-1);
5057 else
5058 if (a == THNULLTHREE) pos = ins_thnullthree(in, *(p+1), pos);
5059
5060 utf_eight_emp(p, len, pos, oldpos);
5061 }
5062 else if (len == 3)
5063 {
5064 if (a == TRIPLETTES_BEGIN) /* 224 */
5065 {
5066 if (signeless(*(p+1)) == 184 && signeless(*(p+2)) == 191)
5067 pos = insposmaxstr(in, "{\\textbaht}", pos, MAXLEN-1); /* 224 184 191 */
5068 }
5069 else
5070 if (a == THTWENTYFIVE)
5071 {
5072 if (signeless(*(p+1)) == THTWENTYFIVE_OHEIGHTYFOUR)
5073 pos = insposmaxstr(in, get_thtwentyfive_oheightyfour(*(p+2)), pos, MAXLEN-1);
5074 else
5075 if (signeless(*(p+1)) == THTWENTYFIVE_OHEIGHTYFIVE)
5076 pos = insposmaxstr(in, get_thtwentyfive_oheightyfive(*(p+2)), pos, MAXLEN-1);
5077 else
5078 if (signeless(*(p+1)) == THTWENTYFIVE_OHEIGHTYSIX) /* new in 2.4 */
5079 pos = insposmaxstr(in, get_thtwentyfive_oheightysix(*(p+2)), pos, MAXLEN-1);
5080 else
5081 if (signeless(*(p+1)) == 187 && signeless(*(p+2)) == 178)
5082 pos = insposmaxstr(in, "\\`Y", pos, MAXLEN-1); /* 225 187 178 new in 2.4 / v1.2n */
5083 else
5084 if (signeless(*(p+1)) == 187 && signeless(*(p+2)) == 179)
5085 pos = insposmaxstr(in, "\\`y", pos, MAXLEN-1); /* 225 187 179 new in 2.4 / v1.2n */
5086 }
5087 else
5088 if (a == THTWENTYSIX)
5089 {
5090 if (signeless(*(p+1)) == THTWENTYSIX_OHTWENTYEIGHT)
5091 pos = insposmaxstr(in, get_thtwentysix_ohtwentyeight(*(p+2)), pos, MAXLEN-1);
5092 else
5093 if (signeless(*(p+1)) == THTWENTYSIX_OHTHIRTY)
5094 pos = insposmaxstr(in, get_thtwentysix_ohthirty(*(p+2)), pos, MAXLEN-1);
5095 else
5096 if (*(p+1) != '\0')
5097 pos = ins_rest_thtwentysix(in, *(p+1), *(p+2), pos);
5098 /* 226 129 ...; 226 132 ...; 226 134 ...; 226 140 ...;
5099 226 144 ...; 226 151 ...; 226 153 ...; 226 159 ... */
5100 }
5101 else
5102 if (a == THTWENTYSEVEN)
5103 {
5104 if (signeless(*(p+1)) == 128 && signeless(*(p+2)) == 136)
5105 pos = insposmaxstr(in, "{\\textlangle}", pos, MAXLEN-1); /* 227 128 136 new in 2.5 (v1.3c) */
5106 else
5107 if (signeless(*(p+1)) == 128 && signeless(*(p+2)) == 137)
5108 pos = insposmaxstr(in, "{\\textrangle}", pos, MAXLEN-1); /* 227 128 137 new in 2.5 (v1.3c) */
5109 }
5110 else
5111 if (a == THTHIRTYNINE) /* TRIPLETTES_END */
5112 {
5113 if (*(p+1) != '\0')
5114 pos = ins_ththirtynine(in, *(p+1), *(p+2), pos);
5115 /* 239 187 ...; 239 172 ... */
5116 }
5117
5118 utf_eight_emp(p, len, pos, oldpos);
5119 }
5120 else if (len == 4)
5121 {
5122 utf_eight_emp(p, len, pos, oldpos);
5123 }
5124 else if (len == 1)
5125 {
5126 if (*p < 0) len = utf_eight_err(p);
5127 else in[pos++] = *p;
5128 }
5129 else if (len > UTF_EIGHT_MAXLEN) { intern_err(32); len = 1; }
5130
5131 oldpos = pos;
5132
5133 p += len;
5134 }
5135
5136 while (*p != '\0' && pos < MAXLEN-1)
5137 {
5138 len = 1;
5139 if (*p < 0) len = utf_eight_err(p);
5140 else in[pos++] = *p;
5141
5142 p += len;
5143 }
5144
5145 in[pos] = '\0';
5146 }
5147
5148
5149 /*--------------------------------------------------------------------------*/
5150
5151
5152 void erweitert(char in[], const char *p)
5153 {
5154 int pos = 0, len;
5155
5156 if (encode == IS_TONE_ENC)
5157 {
5158 while (*p != '\0' && pos < MAXLEN-1)
5159 {
5160 if (*p < 0) pos = insposmaxstr(in, getTONEenc(lastupperascii = *p), pos, MAXLEN-1);
5161 else in[pos++] = *p;
5162 ++p;
5163 }
5164 }
5165 else
5166 {
5167 while (*p != '\0' && pos < MAXLEN-1)
5168 {
5169 if (*p > 0) in[pos++] = *p;
5170 else
5171 {
5172 lastupperascii = *p;
5173 thisupperascii = *p;
5174 }
5175 ++p;
5176 }
5177 }
5178 in[pos] = '\0';
5179 }
5180
5181
5182 const char *transformtable[][2] = {
5183 { "\\\\", "[]" },
5184 { "\\vspace\t", "{}" },
5185 { "\\hspace\t", "{}" },
5186 { "\\nosort\t", "{}" },
5187 { "\\index\t", "{}" },
5188 { "\\glossary\t", "{}" },
5189 { "\\label\t", "{}" },
5190 { "\\pbalabel\t", "{}" },
5191 { "\\balabel\t", "{}" },
5192 { "\\pageref\t", "{}" },
5193 { "\\pbaref\t", "[]{}" },
5194 { "\\baref\t", "[]{}" },
5195 { "\\ref\t", "{}" },
5196 { "\\linebreak\t", "[]" },
5197 { "\\nolinebreak\t", "[]" },
5198 { "\\pagebreak\t", "[]" },
5199 { "\\nopagebreak\t", "[]" },
5200 { "\\footnote\t", "[]{}" },
5201 { "\\footnotetext\t", "[]{}" },
5202 { "\\footnotemark\t", "[]" },
5203 { "\\framebox\t", "[][]" },
5204 { "\\makebox\t", "[][]" },
5205 { "\\parbox\t", "[]{}" },
5206 { "\\raisebox\t", "{}[][]" },
5207 { "\\rule\t", "[]{}{}" },
5208 { "\\printonlyvqu\t", "[]{}{}*{}{}" }, /* innerVcmd */
5209 { "\\vqu\t", "[]{}{}*{}{}" },
5210 { "\\printonlyvli\t", "[]{}{}*{}{}" }, /* olny */
5211 { "\\vli\t", "[]{}{}*{}{}" },
5212 { "\\xprintonlyvqu\t", "[]{}{}*{}{}" }, /* changes */
5213 { "\\xvqu\t", "[]{}{}*{}{}" },
5214 { "\\xprintonlyvli\t", "[]{}{}*{}{}" }, /* IS_V */
5215 { "\\xvli\t", "[]{}{}*{}{}" },
5216 { "\\@shadowba\t", "{}" }, /* new. in 2.2 */
5217 { "\\shadowv\t", "[]{}{}{}{}" },
5218 { "\\addtovli\t", "[]{}{}{}{}" },
5219 { "\\addtovqu\t", "[]{}{}{}{}" },
5220 { "\\xaddtovli\t", "[]{}{}{}{}" },
5221 { "\\xaddtovqu\t", "[]{}{}{}{}" },
5222 { "\\printonlykqu\t", "[]{}*{}{}" },
5223 { "\\printonlykli\t", "[]{}*{}{}" },
5224 { "\\xprintonlykqu\t", "[]{}*{}{}" },
5225 { "\\xprintonlykli\t", "[]{}*{}{}" },
5226 { "\\shadowk\t", "[]{}{}{}" },
5227 { "\\addtokli\t", "[]{}{}{}" },
5228 { "\\addtokqu\t", "[]{}{}{}" },
5229 { "\\xaddtokli\t", "[]{}{}{}" },
5230 { "\\xaddtokqu\t", "[]{}{}{}" },
5231 { "\\frac\t", "{}{}" },
5232 { "\\vauthor\t", "{}{}" },
5233 { "\\midvauthor\t", "{}{}" },
5234 { "\\kauthor\t", "{}" },
5235 { "\\midkauthor\t", "{}" },
5236 { "\\ersch\t", "{}[]{}{}" },
5237 { "\\persch\t", "{}[]{}{}" },
5238 { "\\printonlyper\t", "{}" },
5239 { "\\printonlyarq\t", "[]{}{}" }, /* new in 2.2 */
5240 { "\\printonlydefabk\t", "{}{}" }, /* new in 2.2 */
5241 { "\\printonlyabkdef\t", "{}{}" }, /* new in 2.2 */
5242 { "\\shadowo\t", "{}" },
5243 { "\\addtoper\t", "{}" },
5244 { "\\shadowt\t", "{}{}" },
5245 { "\\addtoarq\t", "{}{}" },
5246 { "\\shadowone\t", "{}" },
5247 { "\\addtoabk\t", "{}" },
5248 { "\\addtogrr\t", "{}" },
5249 { "\\addtoprr\t", "{}" },
5250 { "\\addtosrr\t", "{}" },
5251 { "\\shadowtwo\t", "{}{}" },
5252 { "\\fillper\t", "{}{}" },
5253 { "\\fillarq\t", "{}{}" },
5254 { "\\fillgrr\t", "{}{}" },
5255 { "\\fillprr\t", "{}{}" },
5256 { "\\fillsrr\t", "{}{}" },
5257 { "\\addtodefabk\t", "{}{}" },
5258 { "\\addtoabkdef\t", "{}{}" },
5259 { "\\errmessage\t", "{}" },
5260 { "\\GenericError\t", "{}{}{}{}" },
5261 { "\\message\t", "{}" },
5262 { "\\typeout\t", "{}" },
5263 { "\\mathhexbox\t", "{}{}{}" },
5264 { "\\phantom\t", "{}" },
5265 { "\\vphantom\t", "{}" },
5266 { "\\hphantom\t", "{}" },
5267 { "\\showhyphens\t", "{}" },
5268 { "\\sethyphenation\t", "{}" },
5269 { "\\selectlanguage\t", "{}" },
5270 { "\\discretionary\t", "{}{}" },
5271 { "\\pstressing\t", "{}" },
5272 { "\\stressing\t", "{}" },
5273 { "\\pxbibmark\t", "{}{}" }, /* Nur \\p... */
5274 { "\\pxbibref\t", "{}" }, /* bearbeiten! */
5275 { "\\pbibmark\t", "{}" },
5276 { "\\bibmark\t", "{}" },
5277 { KURZCMD, "{}" },
5278 { "\\delkurz\t", "{}" },
5279 { "\\begin\t", "{}" },
5280 { "\\end\t", "{}" },
5281 { "\\pfordinal\t", "{}" }, /* new in 2.2 */
5282 {"\\@inpenc@undefined@\t", "{}" }, /* new in 2.3 */
5283 {"\\G@refundefinedtrue\t", "{}" }, /* new in 2.3 */
5284 { "\\GenericWarning\t", "{}{}" }, /* new in 2.3 */
5285 { "\\shorthandon\t", "{}" }, /* new in 2.6 */
5286 { "\\shorthandoff\t", "{}" }, /* new in 2.6 */
5287 { "\\foreignlanguage\t", "[]{}" }, /* new in 2.6 */
5288 { "\\hyphenrules\t", "{}" }, /* new in 2.6 */
5289 { NULL, NULL }};
5290 #define NUMTRANSV 106
5291
5292
5293 /* Muessen im Bereich von issonder liegen: */
5294 #define WINGBR 25
5295 #define ANGUBR 24
5296 #define ROUNDBR 23
5297 #define OPTSTAR 22
5298
5299 char *bracketsformward(char *q, char c)
5300 {
5301 if (c == '}') *q = WINGBR;
5302 else if (c == ']') *q = ANGUBR;
5303 else if (c == ')') *q = ROUNDBR;
5304 else intern_err(9); /* BRACKETS LOST */
5305 return q;
5306 }
5307
5308
5309 int len_if_has_bra(const char *p, const char opench, const char closech)
5310 {
5311 int l, r = 0;
5312
5313 if (*p == opench && (l=nextbracket(p, opench, closech)) > 0) r = l;
5314
5315 return r;
5316 }
5317
5318
5319 void exchange_v(char *p, const char *bra, int num)
5320 {
5321 int l = 0, la = 0, i = 0, lb = 0, j = 0, k;
5322 char buf[MAXLEN], fub[MAXLEN], *lp = p, *anf = p;
5323
5324 while (*p == ' ') { ++p; ++la; }
5325 if ((l=len_if_has_bra(p, *(bra+(3*num+1)), *(bra+(3*num+2)))) > 0)
5326 {
5327 la += l; while (i < la) buf[i++] = *lp++;
5328 p += l;
5329 if (*(bra+(3*(num+1))) == '')
5330 {
5331 while (*p == ' ') { ++p; ++lb; }
5332 if ((l=len_if_has_bra(p, *(bra+(3*(num+1)+1)), *(bra+(3*(num+1)+2)))) > 0)
5333 {
5334 lb += l; while (j < lb) fub[j++] = *lp++;
5335 k = 0; while (k < j) *anf++ = fub[k++];
5336 k = 0; while (k < i) *anf++ = buf[k++];
5337 }
5338 }
5339 else intern_err(10); /* No formatter Strg+Q after Strg+P */
5340 }
5341 }
5342
5343
5344 int len_all_arg(const char *p, const char opench, const char closech)
5345 {
5346 int l = 0, r = 0;
5347
5348 if (*p == opench && (l=nextbracket(p, opench, closech)) > 0) r = l;
5349 else
5350 if ('{' == opench)
5351 {
5352 if (*p == '\\' && *(p+1) != '\0' && isLaTeXcmdletter(*(p+1)) == 0) r = 2;
5353 else
5354 if (*p == '\\' && *(p+1) != '\0' && isLaTeXcmdletter(*(p+1)) == 1)
5355 {
5356 r += 2; p += 2;
5357 while (*p != '\0' && isLaTeXcmdletter(*p) == 1) { ++r; ++p; }
5358 while (*p == ' ') { ++r; ++p; }
5359 }
5360 else
5361 if (*p != '{' && *p != '\0') r = 1;
5362 }
5363
5364 return r;
5365 }
5366
5367
5368 char *ins_bracket(char *s, const char opench, const char closech, int l)
5369 {
5370 char buf[MAXLEN] = { opench, '\0' }, b[2] = { closech, '\0' };
5371
5372 strncat(buf, s, l);
5373 strcat (buf, b);
5374 strcat(buf, s+l);
5375 strcpy(s, buf);
5376 return s;
5377 }
5378
5379
5380 char *over_handled_TeX_arg(char *s, char *q, const char left_ch, const char right_ch)
5381 {
5382 int l;
5383
5384 while (*q == ' ') ++q;
5385
5386 if ((l=len_if_has_bra(q, left_ch, right_ch)) < 2)
5387 {
5388 if ( (l=len_all_arg(q, left_ch, right_ch)) > 0
5389 && strlen(s) < MAXLEN-2
5390 )
5391 { /* ins_bracket inserts 2 characters: */
5392 q = ins_bracket(q, left_ch, right_ch, l);
5393 q += l+1;
5394 q = bracketsformward(q, right_ch);
5395 ++q;
5396 }
5397 }
5398 else
5399 {
5400 q += l-1;
5401 q = bracketsformward(q, right_ch);
5402 ++q;
5403 }
5404
5405 return q;
5406 }
5407
5408
5409 char *handletransformarg(char *s, char *p, const char *bra)
5410 {
5411 int l = 0, num = 0;
5412 char *q = p;
5413
5414 while (*(bra+(3*num)) != '\0' && *q != '\0')
5415 {
5416 if ('' == *(bra+(3*num)) || '' == *(bra+(3*num)))
5417 {
5418 while (*q == ' ') ++q;
5419 if ((l=len_all_arg(q, *(bra+(3*num+1)), *(bra+(3*num+2)))) < 1) l = 0; /* changed in 2.3 */
5420 q += l;
5421 if ('' == *(bra+(3*num)))
5422 {
5423 while (*q == ' ') ++q;
5424 }
5425 p = q;
5426 }
5427 else
5428 if ('' == *(bra+(3*num)))
5429 {
5430 if (*(bra+(3*num+1)) == '' && *(bra+(3*num+2)) == '')
5431 {
5432 if ((l=nextbracket(q, '(', ')')) < 2 && (l=nextbracket(q, '[', ']')) < 2) l = 0;
5433 }
5434 else
5435 if (*(bra+(3*num+1)) == '' && *(bra+(3*num+2)) == '')
5436 {
5437 if (*q == '_')
5438 {
5439 l = 1;
5440 while (*(q+l) != '_' && *(q+l) != '\0') ++l;
5441 if (*(q+l) == '_') ++l;
5442 else if (*(q+l) == '\0') l = 0;
5443 }
5444 else
5445 if (*q == '|')
5446 {
5447 l = 1;
5448 while (*(q+l) != '|' && *(q+l) != '\0') ++l;
5449 if (*(q+l) == '|') ++l;
5450 else if (*(q+l) == '\0') l = 0;
5451 }
5452 else l = 0;
5453 }
5454 else l = 0;
5455 q += l;
5456 p = q;
5457 }
5458 else
5459 if ('' == *(bra+(3*num)))
5460 {
5461 while (*q == ' ') ++q;
5462 if (*q == '*')
5463 {
5464 ++q;
5465 while (*q == ' ') ++q;
5466 if ((l=nextbracket(q, *(bra+(3*num+1)), *(bra+(3*num+2)))) < 2) l = 0;
5467 q += l;
5468 p = q;
5469 }
5470 }
5471 else
5472 if ('' == *(bra+(3*num)))
5473 {
5474 while (*q == ' ') ++q;
5475 if (*q == '*') ++q;
5476 while (*q == ' ') ++q;
5477 if (*q != *(bra+(3*num+1)) || (l=nextbracket(q, *(bra+(3*num+1)), *(bra+(3*num+2)))) < 2) l = 0;
5478 q += l;
5479 p = q;
5480 }
5481 else
5482 if ('' == *(bra+(3*num)))
5483 {
5484 q = over_handled_TeX_arg(s, q, *(bra+(3*num+1)), *(bra+(3*num+2))); /* changed in 2.3 */
5485 }
5486 else
5487 if ('' == *(bra+(3*num)) || '' == *(bra+(3*num)))
5488 {
5489 if ('' == *(bra+(3*num))) exchange_v(q, bra, num);
5490 q = over_handled_TeX_arg(s, q, *(bra+(3*num+1)), *(bra+(3*num+2))); /* changed in 2.3 */
5491 }
5492 else
5493 if ('*' == *(bra+(3*num)))
5494 {
5495 while (*q == ' ') ++q;
5496 if (*q == '*')
5497 { *q = OPTSTAR;
5498 ++q;
5499 q = over_handled_TeX_arg(s, q, *(bra+(3*num+1)), *(bra+(3*num+2))); /* changed in 2.3 */
5500 }
5501 }
5502 ++num;
5503 }
5504
5505 return p;
5506 }
5507
5508
5509 void transformline(char buf[], char *p)
5510 {
5511 int pos = 0, i, l;
5512 char *s = p;
5513
5514 while (*p != '\0' && pos < MAXLEN-2)
5515 {
5516 if (*p == '\\')
5517 {
5518 if ((i=texlistnum(p, NUMTRANSV, transformtable)) > -1)
5519 {
5520 if (*(p+1) == '\\') buf[pos++] = ' ';
5521 p += llstrlen(transformtable[i][0]);
5522 p = handletransformarg(s, p, transformtable[i][1]);
5523 }
5524 else buf[pos++] = *p++;
5525 }
5526 else
5527 if (issonder(*p) == 1)
5528 {
5529 if (*p == OPTSTAR);
5530 else
5531 {
5532 if (*p == WINGBR) buf[pos++] = '}';
5533 else if (*p == ANGUBR) buf[pos++] = ']';
5534 else if (*p == ROUNDBR) buf[pos++] = ')';
5535 else intern_err(11); /* unknown bracket symbol */
5536 buf[pos++] = ' ';
5537 }
5538 ++p;
5539 while (*p == ' ') ++p;
5540 }
5541 else buf[pos++] = *p++;
5542 }
5543
5544 buf[pos] = '\0';
5545
5546 /*
5547 if (pos > MAXLEN-4 && *p != '\0') printf("%%%%\n%%%%> Error: Can\'t sort ...\n");
5548 */
5549 }
5550
5551
5552 void nosondercpy(char *s, const char *p)
5553 {
5554 while (*p != '\0')
5555 { if (issonder(*p) == 0) *s++ = *p;
5556 ++p;
5557 }
5558 *s = '\0';
5559 }
5560
5561
5562 const char *overbago(const char *s)
5563 {
5564 const char *p = s;
5565 int got = 0;
5566
5567 if (bago > 0)
5568 {
5569 while (*p != '\0')
5570 {
5571 if (*p == '\\')
5572 {
5573 if (*(p+1) == '\\')
5574 {
5575 ++p;
5576 }
5577 else
5578 if (lcmdcmp(p, BAGOCMD) == 0)
5579 {
5580 p+=strlen(BAGOCMD);
5581 while (*p == ' ') ++p;
5582 got = 1;
5583 break;
5584 }
5585 }
5586 ++p;
5587 }
5588 }
5589
5590 if (got == 0) return s;
5591 return p;
5592 }
5593
5594
5595 void vorbereiten(int linec, int alllines, int deepsort, int ventry)
5596 {
5597 char *p, in[MAXLEN], out[MAXLEN], num[2*NUMLEN], last, buf[MAXLEN];
5598 int pos, i, l;
5599
5600 /* dqsort geht bis zur Tiefe deepsort, nicht deep */
5601
5602 while (linec < alllines)
5603 {
5604 i = 0; while (i < MAXBACOLS) subBptr[i++][linec] = mydefault;
5605 i = 0; while (i < MAXBACOLS) subCptr[i++][linec] = mydefault;
5606
5607 i = 0;
5608 while (i < deepsort)
5609 {
5610 nosondercpy ( in, overbago(subAptr[i][linec]));
5611 transformline(buf, in); /* veraendert zweites Arg! */
5612 if (encode == IS_UTFE_ENC)
5613 get_utf_eight ( in, buf);
5614 else erweitert ( in, buf);
5615 p = austauschen(buf, in, dqsort[linec]);
5616
5617
5618 pos = 0; last = '\0';
5619 while (*p != '\0' && pos < MAXLEN-1)
5620 {
5621 if ( isalpha (*p) != 0
5622 || issonder(*p) == 1
5623 || *p == ' '
5624 || *p == '-'
5625 || (*p == '.' && registpoints == 1) /* nur zusammen mit MARK_POINT */
5626 )
5627 {
5628 if (*p == ' ' && ignorespaces == 1)
5629 {
5630 if (pos > 0 && out[pos-1] == '') --pos;
5631 out[pos] = ''; /* 31 */
5632 }
5633 else
5634 if (*p == '-') /* MINUS */
5635 {
5636 out[pos] = ''; /* 31 */
5637 if (hy_as_space == 1 && pos < MAXLEN-2)
5638 out[++pos] = ' ';
5639 }
5640 else out[pos] = *p;
5641
5642 ++pos;
5643 }
5644 else
5645 if (isdigit(*p) != 0 && last != '\\')
5646 {
5647 p = standardnum(num, p);
5648 out[pos] = '\0';
5649 strncat(out, num, MAXLEN-strlen(out)-1);
5650 pos = strlen(out);
5651 --p;
5652 }
5653
5654 last = *p;
5655 ++p;
5656 }
5657
5658 out[pos] = '\0';
5659
5660 kill_unnecessary_spaces(in, out);
5661
5662 nzvorziehen(out, in);
5663
5664 subBptr[i][linec] = strnmalloc(out, strlen(out)+1);
5665
5666 pos = 0;
5667 l = 0;
5668 while (out[pos] != '\0')
5669 {
5670 if (issonder(out[pos]) == 0)
5671 {
5672 in[l] = toupper(out[pos]);
5673 if (igleichj == 1 && in[l] == 'I') in[l] = 'J';
5674 ++l;
5675 }
5676 ++pos;
5677 }
5678 subCptr[i][linec] = strnmalloc(in, l+1);
5679
5680 ++i;
5681 }
5682
5683 if (ventry == IS_V && *subAptr[0][linec] == '\0') swapBCstrs(linec);
5684
5685 ++linec;
5686 }
5687 }
5688
5689
5690 int isvintroduced(int i)
5691 {
5692 const char *p = subRptr[STUFFRCOL][i];
5693
5694 while (*p == ' ') ++p;
5695
5696 if (*p == '{')
5697 {
5698 p += nextbracket(p, '{', '}');
5699 while (*p == ' ') ++p;
5700
5701 if (*p == '{')
5702 {
5703 p += nextbracket(p, '{', '}');
5704 while (*p == ' ') ++p;
5705
5706 if (*p == '{')
5707 {
5708 ++p;
5709 while (*p == ' ') ++p;
5710
5711 if (*p == KENTRYCH)
5712 {
5713 ++p;
5714 while (*p == ' ') ++p;
5715
5716 if (*p == '}') return KENTRY;
5717 }
5718
5719 if (*p == VENTRYCH)
5720 {
5721 ++p;
5722 while (*p == ' ') ++p;
5723
5724 if (*p == '}') return VENTRY;
5725 }
5726 }
5727 }
5728 }
5729
5730 return ERRENTRY;
5731 }
5732
5733
5734 int getthirdnum(int i)
5735 {
5736 const char *p = subRptr[STUFFRCOL][i];
5737
5738 while (*p == ' ') ++p;
5739
5740 if (*p == '{')
5741 {
5742 p += nextbracket(p, '{', '}');
5743 while (*p == ' ') ++p;
5744
5745 if (*p == '{')
5746 {
5747 p += nextbracket(p, '{', '}');
5748 while (*p == ' ') ++p;
5749
5750 if (*p == '{')
5751 {
5752 ++p;
5753 while (*p == ' ') ++p;
5754
5755 return getarabicnum(p);
5756 }
5757 }
5758 }
5759
5760 return 0;
5761 }
5762
5763
5764 int notfirstaccepted(int line)
5765 {
5766 int r = 0, acceptbefore = 0;
5767
5768 while(r < line)
5769 { if (leval[r] == ACCEPTLINE) { ++acceptbefore; break; }
5770 ++r;
5771 }
5772
5773 return acceptbefore;
5774 }
5775
5776
5777 void dofourtharg(int line)
5778 {
5779 const char *p = subRptr[STUFFRCOL][line];
5780 int l = 0;
5781
5782 while (*p == ' ') ++p;
5783
5784 if (*p == '{')
5785 {
5786 p += nextbracket(p, '{', '}');
5787 while (*p == ' ') ++p;
5788
5789 if (*p == '{')
5790 {
5791 p += nextbracket(p, '{', '}');
5792 while (*p == ' ') ++p;
5793
5794 if (*p == '{')
5795 {
5796 p += nextbracket(p, '{', '}');
5797 while (*p == ' ') ++p;
5798
5799 if (*p == '{')
5800 {
5801 l = nextbracket(p, '{', '}');
5802
5803 if (l > 2)
5804 {
5805 ++p; l -= 2;
5806 while (*p == ' ') { ++p; --l; };
5807
5808 if (l > 0)
5809 {
5810 fprintf(outfile, " %.*s\n %%%% <- Your extra-command(s)", l, p);
5811 if (notfirstaccepted(line) == 0)
5812 fprintf(outfile, " before the 1st item");
5813 fprintf(outfile, ".\n");
5814 }
5815 }
5816 }
5817 }
5818 }
5819 }
5820
5821 }
5822
5823
5824 void getfirsttwoargs(char *s, const char *p)
5825 {
5826 int len;
5827
5828 while (*p == ' ') ++p;
5829
5830 if (*p == '{')
5831 {
5832 if ((len=nextbracket(p, '{', '}')) < MAXLEN-1)
5833 {
5834 while(len-- > 0) *s++ = *p++;
5835
5836 while (*p == ' ') ++p;
5837
5838 if (*p == '{')
5839 {
5840 if (len + (len=nextbracket(p, '{', '}')) < MAXLEN-1)
5841 {
5842 while(len-- > 0) *s++ = *p++;
5843 }
5844 }
5845 }
5846 }
5847 *s = '\0';
5848 }
5849
5850
5851 int baidxloop(int cloop, const char *p)
5852 {
5853 cloop += fprintf(outfile, "%s", p);
5854
5855 if (cloop > BAINDEXLEN)
5856 {
5857 fprintf(outfile, "%s", BAINDEXEND);
5858 fprintf(outfile, "%s", BAINDEXFOLL); /* neustart cloop */
5859 cloop = CLOOPBSTART;
5860 }
5861
5862 return cloop;
5863 }
5864
5865
5866 char *negnum(char *p)
5867 {
5868 if (*p == '-') return "\\,";
5869 return "";
5870 }
5871
5872
5873 int printipagefnt(const char *arraysep, int begin, int end, int lasti, int cloop)
5874 {
5875 int fnc, pnc;
5876
5877 if ( lasti > -1
5878 && pagewgt[begin] == pagewgt[lasti]
5879 && numcmp(1, pagewgt[begin], subRptr[PAGECOL][lasti], subRptr[PAGECOL][begin]) == 0
5880 )
5881 {
5882 cloop += fprintf(outfile, "$^{,}$");
5883 cloop = baidxloop(cloop, BS_SPACE);
5884 }
5885 else
5886 {
5887 cloop = baidxloop(cloop, arraysep);
5888 if (pagewgt[begin] == MISSNUM) cloop += fprintf(outfile, "{%s}", MISSINGSYMB);
5889 else if (pagewgt[begin] == EMPTYNUM) cloop += fprintf(outfile, "%s", EMPTYSYMB);
5890 else if (pagewgt[begin] == OVERFLOW) cloop += fprintf(outfile, "%s", OVERFLOWSYMB);
5891 else if (pagewgt[begin] == INTERNALERR) intern_err(12); /* Bad pageno */
5892 else if (pagewgt[begin] == UNUSED) intern_err(13); /* Unused pageno */
5893 else if (pagewgt[begin] == TEXT) cloop += fprintf(outfile, "%s%s%s", TEXTSYMBOPEN[notext], subRptr[PAGECOL][begin], TEXTSYMBCLOSE[notext]);
5894 else cloop += fprintf(outfile, "%s", subRptr[PAGECOL][begin]);
5895 }
5896
5897 if (end > begin)
5898 {
5899 fnc = numcmp(0, fntwgt[begin], subRptr[FNTCOL][end], subRptr[FNTCOL][begin]);
5900 pnc = numcmp(1, pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]);
5901
5902 if (fnc == 1)
5903 {
5904 if (pnc > 0)
5905 {
5906 cloop += fprintf(outfile, "$^{%s}$", subRptr[FNTCOL][begin]);
5907 cloop = baidxloop(cloop, BANCOMMA);
5908 }
5909 else
5910 {
5911 cloop += fprintf(outfile, "$^{%s}$$^{,}$", subRptr[FNTCOL][begin]);
5912 cloop = baidxloop(cloop, BS_SPACE);
5913 }
5914
5915 if (pnc > 0)
5916 {
5917 cloop += fprintf(outfile, "%s$^{", subRptr[PAGECOL][end]);
5918 }
5919 else
5920 {
5921 cloop += fprintf(outfile, "$^{");
5922 }
5923 }
5924 else
5925 if (fnc > 1)
5926 {
5927 if (pnc > 0)
5928 {
5929 cloop += fprintf(outfile, "$^{%s}$--%s%s$^{", subRptr[FNTCOL][begin], negnum(subRptr[PAGECOL][end]), subRptr[PAGECOL][end]);
5930 }
5931 else
5932 {
5933 cloop += fprintf(outfile, "$^{%s-", subRptr[FNTCOL][begin]);
5934 }
5935 }
5936 else
5937 if ( fntwgt[end] != INTERNALERR
5938 && fntwgt[end] != NOFOOTNOTE
5939 )
5940 cloop += fprintf(outfile, "$^{");
5941 }
5942 else cloop += fprintf(outfile, "$^{");
5943
5944 if ( fntwgt[end] == MISSNUM) cloop += fprintf(outfile, "%s}$", MISSINGSYMB);
5945 else if ( fntwgt[end] == EMPTYNUM) cloop += fprintf(outfile, "%s}$", EMPTYSYMB);
5946 else if ( fntwgt[end] == OVERFLOW) cloop += fprintf(outfile, "%s}$", OVERFLOWSYMB);
5947 else if ( fntwgt[end] == INTERNALERR) intern_err(14); /* Bad fntno */
5948 else if ( fntwgt[end] == NOFOOTNOTE) intern_err(15); /* That is not a footnote */
5949 else if ( fntwgt[end] == TEXT) cloop += fprintf(outfile, "%s%s%s}$", TEXTSYMBOPEN[notext], subRptr[FNTCOL][end], TEXTSYMBCLOSE[notext]);
5950 else cloop += fprintf(outfile, "%s%s}$", negnum(subRptr[FNTCOL][end]), subRptr[FNTCOL][end]);
5951
5952 return cloop;
5953 }
5954
5955
5956 int printipage(const char *arraysep, int begin, int end, int cloop)
5957 {
5958 int pnc;
5959
5960 cloop = baidxloop(cloop, arraysep);
5961 if (pagewgt[begin] == MISSNUM) cloop += fprintf(outfile, "{%s}", MISSINGSYMB);
5962 else if (pagewgt[begin] == EMPTYNUM) cloop += fprintf(outfile, "%s", EMPTYSYMB);
5963 else if (pagewgt[begin] == OVERFLOW) cloop += fprintf(outfile, "%s", OVERFLOWSYMB);
5964 else if (pagewgt[begin] == TEXT) cloop += fprintf(outfile, "%s%s%s", TEXTSYMBOPEN[notext], subRptr[PAGECOL][begin], TEXTSYMBCLOSE[notext]);
5965 else cloop += fprintf(outfile, "%s", subRptr[PAGECOL][begin]);
5966
5967 if (end > begin)
5968 {
5969 pnc = numcmp(1, pagewgt[begin], subRptr[PAGECOL][end], subRptr[PAGECOL][begin]);
5970 if (pnc == 1)
5971 {
5972 cloop = baidxloop(cloop, BANCOMMA);
5973 cloop += fprintf(outfile, "%s", subRptr[PAGECOL][end]);
5974 }
5975 else if (pnc > 1)
5976 {
5977 cloop += fprintf(outfile, "--%s%s", negnum(subRptr[PAGECOL][end]), subRptr[PAGECOL][end]);
5978 }
5979 }
5980
5981 return cloop;
5982 }
5983
5984
5985 void makeipagefnt(int i, int line, int end)
5986 {
5987 int begblock, lasti = -1, j, k, cloop = CLOOPASTART;
5988 char *asfirst = "";
5989 char *assecond = BANCOMMA;
5990 char *arraysep = asfirst;
5991
5992
5993 while (i <= end && pagewgt[i] == UNUSED) ++i;
5994
5995
5996 if (i <= end)
5997 {
5998
5999 while (i <= end)
6000 {
6001 if (cloop == CLOOPASTART)
6002 {
6003 fprintf(outfile, "%s", BAINDEXFIRS); /* Erststart cloop */
6004 cloop = CLOOPBSTART;
6005 }
6006 else
6007 if (cloop == CLOOPBSTART) intern_err(16);
6008
6009 begblock = i;
6010
6011 if (fntwgt[i] == NOFOOTNOTE) /* Seiten ohne FNTs */
6012 {
6013 while (i < end)
6014 {
6015 if ( fntwgt[i] == NOFOOTNOTE
6016 && fntwgt[i+1] == NOFOOTNOTE
6017 && pagewgt[i] != MISSNUM
6018 && pagewgt[i] == pagewgt[i+1]
6019 && ( (pagewgt[i] == TEXT && strcmp(subRptr[PAGECOL][i], subRptr[PAGECOL][i+1]) == 0)
6020 || (pagewgt[i] != TEXT && ((j=numcmp(1, pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || j == 1))
6021 )
6022 ) ++i;
6023 else break;
6024 }
6025 cloop = printipage(arraysep, begblock, i, cloop);
6026 lasti = -1;
6027 }
6028 else /* Seiten mit FNTs */
6029 {
6030 while (i < end)
6031 {
6032 k = -1;
6033 if ( fntwgt[i] != NOFOOTNOTE
6034 && pagewgt[i] != MISSNUM
6035 && pagewgt[i] == pagewgt[i+1]
6036 && ( (pagewgt[i] == TEXT && strcmp(subRptr[PAGECOL][i], subRptr[PAGECOL][i+1]) == 0)
6037 || (pagewgt[i] != TEXT && ((k=numcmp(1, pagewgt[i], subRptr[PAGECOL][i+1], subRptr[PAGECOL][i])) == 0 || (k == 1 && FntIndexOverPages == 1)))
6038 )
6039 && fntwgt[i] != MISSNUM
6040 && fntwgt[i] == fntwgt[i+1]
6041 && ( ( fntwgt[i] == TEXT && (k == 0 || pagewgt[i] == TEXT)
6042 && strcmp(subRptr[ FNTCOL][i], subRptr[ FNTCOL][i+1]) == 0)
6043 || ( fntwgt[i] != TEXT && (((j=numcmp(0, fntwgt[i], subRptr[ FNTCOL][i+1], subRptr[ FNTCOL][i])) == 0 && k == 0) || j == 1))
6044 )
6045 ) ++i;
6046 else break;
6047 }
6048 cloop = printipagefnt(arraysep, begblock, i, lasti, cloop);
6049 lasti = i;
6050 }
6051
6052 ++i;
6053 arraysep = assecond;
6054 }
6055
6056 fprintf(outfile, "%s", BAINDEXEND);
6057 }
6058 }
6059
6060
6061 void makeindex(const int nlines, const int line, const int deepsort)
6062 {
6063 int i, j, begin, end;
6064
6065 i = line;
6066 while (i > 0 && leval[i-1] != REJECTLINE)
6067 {
6068 j = 0;
6069 while (j < deepsort && texcmp(subAptr[j][i], subAptr[j][i-1], dqsort[i], dqsort[i-1]) == 0) ++j;
6070 if (j < deepsort) break;
6071 --i;
6072 }
6073 begin = i;
6074
6075 i = line;
6076 while (i < nlines-1 && leval[i+1] != REJECTLINE)
6077 {
6078 j = 0;
6079 while (j < deepsort && texcmp(subAptr[j][i], subAptr[j][i+1], dqsort[i], dqsort[i+1]) == 0) ++j;
6080 if (j < deepsort) break;
6081 ++i;
6082 }
6083 end = i;
6084
6085 makeipagefnt(begin, line, end);
6086 }
6087
6088
6089 void printsortline(int line, int deepsort)
6090 {
6091 int l = 0;
6092
6093 if (deepsort > 0)
6094 {
6095 fprintf(outfile, " %s", METALINEHEAD);
6096
6097 while (l < deepsort)
6098 {
6099 fprintf(outfile, " (%s)", subBptr[l][line]);
6100 ++l;
6101 }
6102
6103 fprintf(outfile, "\n");
6104 }
6105 }
6106
6107
6108 int findauthor(const char *s)
6109 {
6110 int r = 0;
6111
6112 while(*s != '\0')
6113 {
6114 if (*s == '\\')
6115 {
6116 if (*(s+1) == '\\')
6117 {
6118 ++s; ++r;
6119 }
6120 else if (texlistnum(s, NAUTHOR, authortable) > -1) break;
6121 }
6122 ++s; ++r;
6123 }
6124
6125 if (*s == '\0') r = -1;
6126
6127 return r;
6128 }
6129
6130
6131 int fprint_inner_ktit_err(int j, int err, int dif, const char *msgA, const char *msgB)
6132 {
6133 if (j >= err)
6134 {
6135 --j;
6136 fprintf(outfile, "%%%% <- Warning *inner v-cmd*: %s %s (reported No. %d).\n", msgA, msgB, ktiterr+1);
6137 ++ktiterr;
6138 }
6139
6140 if (j >= dif) j -= dif;
6141
6142 return j;
6143 }
6144
6145
6146 #define O_KTIT_UNINIT -2 /* init: mostoktitarg > -2 */
6147 #define O_KTIT_NOTUSED -1 /* used: mostoktitarg > -1 */
6148 #define O_KTIT_NOPREF 0 /* pref: mostoktitarg > 0 */
6149 #define MOST_O_KTIT_ARGONE 1
6150 #define MOST_O_KTIT_ARGTWO 2
6151 #define MOST_O_KTIT_ARGTHREE 3
6152 #define MOST_O_KTIT_ARGFOUR 4
6153
6154 void check_out_ktit(int line, int deepsort, int mostoktitarg)
6155 {
6156 int i = 0, j = 0, numalter = 0, num = -1, numall = 0;
6157
6158 if (mostoktitarg > O_KTIT_UNINIT) /* ventry == IS_V */
6159 {
6160 while (i < deepsort) /* assume: deep == deepsort */
6161 {
6162 num = num_of_cmds_in_str(subAptr[i][line], KTITCMD);
6163 if (num > 1)
6164 {
6165 fprintf(outfile, "%%%% <- Warning *outer v-cmd*: %s used %d times in arg %d (reported No. %d).\n", KTIT, num, i+1, ktiterr+1);
6166 ++ktiterr;
6167 }
6168 numalter = 0;
6169 if (num > 0)
6170 {
6171 j = i+1;
6172 while (j < deepsort)
6173 {
6174 if ((numalter = num_of_cmds_in_str(subAptr[j][line], KTITCMD)) > 0) break;
6175 ++j;
6176 }
6177 }
6178 if (num > 0 && numalter > 0)
6179 {
6180 /* use int j here! */
6181 fprintf(outfile, "%%%% <- Warning *outer v-cmd*: %s used in arg %d and in arg %d (reported No. %d).\n", KTIT, i+1, j+1, ktiterr+1);
6182 ++ktiterr;
6183 }
6184 if (num > 0 && mostoktitarg > O_KTIT_NOPREF && i+1 != mostoktitarg)
6185 {
6186 if (numalter == 0)
6187 {
6188 if ( i+1 == MOST_O_KTIT_ARGONE
6189 || i+1 == MOST_O_KTIT_ARGTWO
6190 || i+1 == MOST_O_KTIT_ARGTHREE
6191 || i+1 == MOST_O_KTIT_ARGFOUR
6192 );
6193 else intern_err(42);
6194
6195 fprintf(outfile, "%%%% <- Warning *outer v-cmd*: %s defined in arg %d; most entries use arg %d (reported No. %d).\n", KTIT, i+1, mostoktitarg, ktiterr+1);
6196 ++ktiterr;
6197 }
6198 }
6199 if (num > 0 && mostoktitarg == O_KTIT_NOPREF)
6200 {
6201 if (numalter == 0)
6202 {
6203 fprintf(outfile, "%%%% <- Warning *outer v-cmd*: %s is defined here in arg %d; sum of all entries shows no preference (reported No. %d).\n", KTIT, i+1, ktiterr+1);
6204 ++ktiterr;
6205 }
6206 }
6207 if (i == 0) { numall += num; }
6208 else if (i == 1) { numall += num; }
6209 else if (i == 2) { numall += num; }
6210 else if (i == 3) { numall += num; }
6211 else intern_err(41);
6212 ++i;
6213 }
6214
6215 if (numall == 0 && mostoktitarg > O_KTIT_NOTUSED)
6216 {
6217 fprintf(outfile, "%%%% <- Warning *outer v-cmd*: %s not used (or is masked); ", KTIT);
6218 if (mostoktitarg > O_KTIT_NOPREF) fprintf(outfile, "most other entries use arg %d ", mostoktitarg);
6219 if (mostoktitarg == O_KTIT_NOPREF) fprintf(outfile, "other entries show no preference ");
6220 fprintf(outfile, "(reported No. %d).\n", ktiterr+1);
6221 ++ktiterr;
6222 }
6223 }
6224 }
6225
6226
6227 int writetheline(char *p, const int nlines, const int line, const int deepsort, int filec, int printsort, int kandkused, int mostoktitarg)
6228 {
6229 int doprint = 0, pagenum = 0, fntnum = 0, uu = 0, tn = getthirdnum(line), j;
6230
6231 if (*p != '%')
6232 { if (leval[line] != ACCEPTLINE)
6233 *p = '%';
6234 intern_err(17); /* LINE WITHOUT \'%%\' */
6235 }
6236
6237
6238 if (leval[line] == ACCEPTLINE)
6239 {
6240 j = line-1;
6241 while (j > 0 && leval[j] != ACCEPTLINE) --j;
6242 if ( j < 0
6243 || (leval[j] == ACCEPTLINE && *subCptr[0][j] != *subCptr[0][line])
6244 || (leval[j] != ACCEPTLINE)
6245 )
6246 {
6247 if (leval[j] != ACCEPTLINE && j != 0) intern_err(18); /* misplaced PREPARESPACE/PREPAREHEAD */
6248
6249 if (isalpha(*subCptr[0][line]) != 0)
6250 {
6251 fprintf(outfile, "\n\n");
6252 if (line > 0 && leval[j] == ACCEPTLINE)
6253 fprintf(outfile, "%s\n", PREPARESPACE);
6254 fprintf(outfile, "%s{%c}\n\n", PREPAREHEAD, *subCptr[0][line]);
6255 }
6256 else if (line > 0 && isdigit(*subCptr[0][line]) != 0)
6257 {
6258 fprintf(outfile, "\n\n%s\n", PREPARESPACE);
6259 fprintf(outfile, "%s\n\n", PREPAREXSPACE);
6260 }
6261 }
6262 }
6263
6264
6265 if (leval[line] == ACCEPTLINE) { doprint = 1; ++p; }
6266 else if (leval[line] == REJECTLINE) { doprint = 2; }
6267 else if (leval[line] == DOUBLELINE) { doprint = 0; /* *p = '!'; */ }
6268 else if (leval[line] == DIFFERLINE) { doprint = 4; /* *p = ':'; */ }
6269 else if (leval[line] == UNDEFILINE) { doprint = 5; /* *p = '*'; */ }
6270 else if (leval[line] == REDEF1LINE) { doprint = 6; }
6271 else if (leval[line] == REDEF2LINE) { doprint = 7; }
6272 else if (leval[line] == ABBREVLINE) { doprint = 0; /* *p = '+'; */ }
6273 else intern_err(19); /* UNKNOWN WRITELINES-leval */
6274
6275 if (pagewgt[line] == EMPTYNUM) pagenum = 1;
6276 else if (pagewgt[line] == MISSNUM) pagenum = 2;
6277 else if (pagewgt[line] == TEXT) pagenum = 3;
6278 else if (pagewgt[line] == OVERFLOW) pagenum = 4;
6279
6280 if (pagewgt[line] == UNUSED) uu = 1;
6281
6282 if ( fntwgt[line] == EMPTYNUM) fntnum = 1;
6283 else if ( fntwgt[line] == MISSNUM) fntnum = 2;
6284 else if ( fntwgt[line] == TEXT) fntnum = 3;
6285 else if ( fntwgt[line] == OVERFLOW) fntnum = 4;
6286
6287
6288 if (tn > 0 && doprint == 1 && leval[line] == ACCEPTLINE) dofourtharg(line);
6289
6290 if (doprint == 2) fprintf(outfile, "%%%% *Reject entry* (syntax error or empty):\n");
6291
6292 if (doprint > 0 || pagenum > 0 || fntnum > 0 || uu > 0)
6293 {
6294 if (filec > 1) fprintf(outfile, "%%%% Entry from %s ...\n", subRptr[LINECOL][line]);
6295 if (printsort == 1 && doprint == 1) printsortline(line, deepsort);
6296 fprintf(outfile, "%s\n", p);
6297
6298 if (kandkused == 1 && num_of_cmds_in_str(p, KURZCMD) > 0)
6299 fprintf(outfile, "%%%% <- Warning: You have used %s here, but also %s here or elsewhere.\n", KURZ, KTIT);
6300
6301 check_out_ktit(line, deepsort, mostoktitarg);
6302
6303 /* get_add_ktit in 2.5 changed into: */
6304 j = inerr[line];
6305 j = fprint_inner_ktit_err(j, KTIT_OPE_ERR, KTIT_OPE_BAS, "[f{...}] or [m{...}] or [p{...}] overwrites but not replaces \'star\'", KTIT);
6306 j = fprint_inner_ktit_err(j, OARG_BRA_ERR, OARG_BRA_BAS, "[f/m/p TEXT]", "has TEXT not in {...}");
6307 j = fprint_inner_ktit_err(j, OARG_IRR_ERR, OARG_IRR_BAS, "First letter in [OptArg]", "is not f/m/p");
6308 j = fprint_inner_ktit_err(j, KTIT_DBL_ERR, KTIT_DBL_BAS, KTIT, KTIT); /* double */
6309 j = fprint_inner_ktit_err(j, KTIT_MIS_ERR, KTIT_MIS_BAS, KTIT, "is missing");
6310 j = fprint_inner_ktit_err(j, KTIT_EMP_ERR, KTIT_EMP_BAS, KTIT, "has empty arg");
6311 j = fprint_inner_ktit_err(j, KTIT_SEV_ERR, NOINERR, KTIT, "used several times");
6312 if (j != 0) intern_err(38);
6313 }
6314
6315
6316 if ( ex_n == EXCHANGENAMES
6317 && leval[line] != DOUBLELINE
6318 && (j=findauthor(p)) > -1
6319 ) fprintf(outfile, "%%%% <- Error: Can\'t exchange {FirstName} and {FamilyName} after cmd on pos %d (bad brackets).\n", j+1);
6320
6321
6322 if (doprint > 3) { fprintf(outfile, "%%%% <- TextArg-Warning");
6323 if (uu == 0) fprintf(outfile, " (NUMBERS of entry are not necessarily rejected)");
6324 fprintf(outfile, ":\n");
6325 }
6326 if (doprint == 4) fprintf(outfile, "%%%% HEAD is explained different now; that new explanation is ignored.\n");
6327 if (doprint == 5) fprintf(outfile, "%%%% HEAD is not (yet\?) explained.\n");
6328 if (doprint == 6) fprintf(outfile, "%%%% HEAD is explained again (short-title mismatch).\n");
6329 if (doprint == 7) fprintf(outfile, "%%%% HEAD is explained again (risky when open/close seps are different).\n");
6330
6331
6332 if (pagenum > 0 || fntnum > 0)
6333 fprintf(outfile, "%%%% <- Counter-Warning (TEXT of entry is not necessarily rejected):\n");
6334
6335 if (pagenum > 0) fprintf(outfile, "%%%% * Page-num ");
6336 if (pagenum == 1) fprintf(outfile, "empty.\n"); /* EMPTYNUM */
6337 if (pagenum == 2) fprintf(outfile, "missing.\n"); /* MISSNUM */
6338 if (pagenum == 3) fprintf(outfile, "not valid and SORTED as TEXT.\n");
6339 if (pagenum == 4) fprintf(outfile, "contains \"%s\" (guess Alph/alph/fnsymbol overflow).\n", OVERFLOWTXT);
6340
6341 if (tn == 0 && uu == 1) fprintf(outfile, "%%%% <- Def is in an {unused}-environment or is a \\fill...-cmd.\n");
6342 if (tn > 0 && uu == 1) fprintf(outfile, "%%%% <- List-internal heading (class %d).\n", tn);
6343
6344 if ( fntnum > 0) fprintf(outfile, "%%%% * Footnote-num ");
6345 if ( fntnum == 1) fprintf(outfile, "empty.\n"); /* EMPTYNUM */
6346 if ( fntnum == 2) fprintf(outfile, "missing.\n"); /* MISSNUM */
6347 if ( fntnum == 3) fprintf(outfile, "not valid and SORTED as TEXT.\n");
6348 if ( fntnum == 4) fprintf(outfile, "contains \"%s\" (guess Alph/alph/fnsymbol overflow).\n", OVERFLOWTXT);
6349
6350
6351 if (doprint == 1 && nlines > 0) makeindex(nlines, line, deepsort);
6352
6353 if (doprint >= 2 || pagenum > 0 || fntnum > 0 || (doprint == 1 && nlines > 0) || uu > 0)
6354 fprintf(outfile, "\n");
6355
6356
6357 if (pagenum > 0 && fntnum > 0) return 2;
6358 if (pagenum > 0 || fntnum > 0) return 1;
6359 return 0;
6360 }
6361
6362
6363 void allerrorout(const char *s)
6364 {
6365 fprintf(outfile, "%s %s\n", TeXITEM, s);
6366 fprintf(outfile, "%s{BibArts warning: %s}%s\n", TYPEOUT, s, RELAX);
6367 printf("%%%% -> %s\n", s);
6368 }
6369
6370
6371 static void timestamp (FILE *file)
6372 {
6373 time_t t;
6374 struct tm *tp;
6375
6376 if (time (&t) == -1) return;
6377
6378 tp = localtime(&t);
6379 if (german == 0)
6380 fprintf (file, "%%%%> Begin output (month-day-year) %.2d-%.2d-%.4d %.2d:%.2d:%.2d\n",
6381 1+tp->tm_mon, tp->tm_mday, 1900+tp->tm_year,
6382 tp->tm_hour, tp->tm_min, tp->tm_sec);
6383 else
6384 fprintf (file, "%%%%> Begin output (day.month.year) %.2d.%.2d.%.4d %.2d:%.2d:%.2d\n",
6385 tp->tm_mday, 1+tp->tm_mon, 1900+tp->tm_year,
6386 tp->tm_hour, tp->tm_min, tp->tm_sec);
6387 }
6388
6389
6390 void outhline(void)
6391 {
6392 printf("%%%% ======================================\n");
6393 }
6394
6395
6396 void fprintsquence(FILE *file, const char *utf)
6397 {
6398 while (*utf != '\0')
6399 {
6400 fprintf(file, "%d", ((unsigned char)*utf));
6401 if (*(utf+1) != '\0') fprintf(file, "-");
6402 ++utf;
6403 }
6404 }
6405
6406
6407 void fprint_utf_msg(FILE *file, const char utf[], int mod)
6408 {
6409 if (encode == IS_UTFE_ENC && utf[0] < 0)
6410 {
6411 fprintf(file, "%%%%\n%%%% -utf8 : Did not ");
6412 if (mod == 0) fprintf(file, "know the meaning of \'%s\' (", utf);
6413 else { fprintf(file, "interpret invalid utf8 sequences (like "); /* msg changed in 2.5 */
6414 if (utf[1] == '\0')
6415 fprintf(file, "the single octet "); /* msg changed in 2.5 */
6416 }
6417 fprintsquence(file, utf);
6418 fprintf(file, ").\n%%%% Only the last error is reported here; also see screen.\n%%%%\n");
6419 }
6420 }
6421
6422
6423 void printfilelist(FILE *file, int filec, int cc, const char *vor, const char *nach)
6424 {
6425 int i = 0;
6426
6427 if (cc == 1)
6428 {
6429 fprintf(file, "\n%%%% BibArts 2.6 (C) Timo Baumann 2023 [%s]\n", __DATE__);
6430 fprintf(file, "\\gdef\\@bibsortvers{2.6}\n"); /* new in 2.5 */
6431 }
6432
6433 fprintf(file, "%%%%\n");
6434 timestamp(file);
6435
6436 fprintf(file, "%%%% Sort arg(s):\n");
6437 fprintf(file, "%s", vor);
6438 if (german == 1) fprintf(file, " -g1");
6439 if (german == 2) fprintf(file, " -g2");
6440 if (nogsty == 1) fprintf(file, " -x");
6441 if (ignorespaces == 1) fprintf(file, " -l");
6442 if (hy_as_space == 1) fprintf(file, " -h");
6443 if (registpoints == 1) fprintf(file, " -p");
6444 if (encode == IS_TONE_ENC) fprintf(file, " -t1");
6445 if (encode == IS_UTFE_ENC) fprintf(file, " -utf8");
6446 if (kill == DOKILLAUTHORS) fprintf(file, " -k");
6447 if (ex_n == EXCHANGENAMES) fprintf(file, " -e");
6448 if (EinlROEMseiten == 1) fprintf(file, " -s1");
6449 if (ALPHmpfootnotes == 1) fprintf(file, " -f1");
6450 if ( get_R_pg == BA_TRUE
6451 || get_A_pg == BA_TRUE
6452 || get_a_pg == BA_TRUE
6453 || get_r_pg == BA_TRUE
6454 ) fprintf(file, " -s2 %s", soptarg);
6455 if ( get_R_fn == BA_TRUE
6456 || get_A_fn == BA_TRUE
6457 || get_a_fn == BA_TRUE
6458 || get_r_fn == BA_TRUE
6459 ) fprintf(file, " -f2 %s", foptarg);
6460 if (igleichj == 1) fprintf(file, " -i=j");
6461 if (bago == 1) fprintf(file, " -b");
6462 if (FntIndexOverPages == 0) fprintf(file, " -n1");
6463 if (notext == 1) fprintf(file, " -c");
6464
6465 if ( german == 0
6466 && nogsty == 0
6467 && ignorespaces == 0
6468 && hy_as_space == 0
6469 && registpoints == 0
6470 && encode == IS_BASE_ENC
6471 && kill != DOKILLAUTHORS
6472 && ex_n == NOTEXCHANGENAMES
6473 && EinlROEMseiten == 0
6474 && ALPHmpfootnotes == 0
6475 && (get_R_fn == BA_FALSE && get_A_fn == BA_FALSE && get_a_fn == BA_FALSE && get_r_fn == BA_FALSE)
6476 && (get_R_pg == BA_FALSE && get_A_pg == BA_FALSE && get_a_pg == BA_FALSE && get_r_pg == BA_FALSE)
6477 && igleichj == 0
6478 && bago == 0
6479 && FntIndexOverPages == 1
6480 && notext == 0
6481 ) fprintf(file, " Default");
6482 fprintf(file, "%s\n", nach);
6483
6484 if (encode == IS_BASE_ENC && thisupperascii < 0) fprintf(file, "%%%%\n%%%% *** Codepage error: ASCIIs > 127 like %d found, but you did not say -utf8 or -t1.\n%%%%\n", ((unsigned char)thisupperascii));
6485
6486 fprint_utf_msg(file, this_emp_utf_eight, 0);
6487 fprint_utf_msg(file, this_err_utf_eight, 1);
6488
6489 if (igleichj == 1 && cc == 1) fprintf(file, "%%%% \n%%%% Note, that you will not see i=j in %s lines here.\n", METALINEHEAD); /* "-m" + "-i=j" */
6490
6491 fprintf(file, "%%%%\n%%%%> Input file list:\n");
6492
6493 if (filec == 1)
6494 fprintf(file, "%%%% only \"%s\".\n", filelist[i]);
6495 else
6496 while (i < filec)
6497 {
6498 fprintf(file, "%%%% %.3d \"%s\".\n", i+1, filelist[i]);
6499 ++i;
6500 }
6501
6502 if (cc == 1)
6503 fprintf(file, "\n\n");
6504 else
6505 { printf("%%%%\n");
6506 outhline();
6507 }
6508 }
6509
6510
6511 int writelines(int nlines, const int dqcol, const int lancol, const int commentANDignlines, const int deepsort, int filec, int printsort, int kandkused, int mostoktitarg)
6512 {
6513 int i = 0, dqcat, lancat = 0, lancatbuf, extralines = 0, didsetorig, nerr = 0;
6514
6515 printfilelist(outfile, filec, 1, "\\gdef\\bibsortargs{", " }");
6516
6517 while (i < nlines && leval[i] != ACCEPTLINE)
6518 {
6519 nerr = nerr + writetheline(lineptr[i], 0, i, 0, filec, printsort, kandkused, mostoktitarg);
6520 ++i;
6521 }
6522
6523 /* Wegen 2. Arg von abk ist hier dqsort ungeeignet! */
6524
6525 if (nlines-commentANDignlines > 0)
6526 {
6527 if ((dqcol > -1 && nogsty == 0) || lancol > -1) fprintf(outfile, "\n");
6528
6529 if (dqcol > -1 && nogsty == 0)
6530 { dqcat = getarabicnum(subRptr[dqcol][i]);
6531 if (dqcat == TeXACTIVE)
6532 { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [bibsort] Begin list setting \\string%s. }}\\fi\n", TeXPASSIVE, GERMANTEX, GERMANTEX);
6533 ++extralines;
6534 }
6535 else if (dqcat == TeXPASSIVE)
6536 { fprintf(outfile, " \\ifnum\\catcode\\grave@ba\\\"=%d%s{\\message{ [bibsort] Begin list setting \\string%s. }}\\fi\n", TeXACTIVE, ORIGINALTEX, ORIGINALTEX);
6537 ++extralines;
6538 }
6539 }
6540
6541 if (lancol > -1)
6542 { lancat = getarabicnum(subRptr[lancol][i]);
6543 fprintf(outfile, " \\ifnum\\language=%d\\else%s%d\\message{ [bibsort] Begin list setting hyphenation %d. }\\fi\n", lancat, HYPHENATION, lancat, lancat);
6544 ++extralines;
6545 }
6546
6547 if ((dqcol > -1 && nogsty == 0) || lancol > -1) fprintf(outfile, "\n");
6548
6549 nerr = nerr + writetheline(lineptr[i], nlines, i, deepsort, filec, printsort, kandkused, mostoktitarg);
6550
6551 ++i;
6552 }
6553 else if (nlines > 0) allerrorout("bibsort did reject all your entries.");
6554
6555
6556 while (i < nlines)
6557 {
6558 didsetorig = -1;
6559 if (dqcol > -1 && nogsty == 0 && leval[i] == ACCEPTLINE)
6560 {
6561 if (dqcat == TeXACTIVE && (dqcat = getarabicnum(subRptr[dqcol][i])) == TeXPASSIVE)
6562 { fprintf(outfile, " %s{\\message{ [bibsort] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", ORIGINALTEX, ORIGINALTEX, TEXFILELINE, RELAX);
6563 ++extralines;
6564 didsetorig = 0;
6565 }
6566 else if (dqcat == TeXPASSIVE && (dqcat = getarabicnum(subRptr[dqcol][i])) == TeXACTIVE)
6567 { fprintf(outfile, " %s{\\message{ [bibsort] Set \\string%s \\space in line %s \\space of BibArts file. }}%s\n", GERMANTEX, GERMANTEX, TEXFILELINE, RELAX);
6568 ++extralines;
6569 didsetorig = 1;
6570 }
6571 }
6572
6573 if (lancol > -1 && leval[i] == ACCEPTLINE)
6574 { if ( lancat != (lancatbuf = getarabicnum(subRptr[lancol][i]))
6575 || didsetorig != -1
6576 )
6577 { lancat = lancatbuf;
6578 fprintf(outfile, " %s%d\\message{ [bibsort] Reproduce hyphenation %d in line %s \\space of BibArts file. }%s\n", HYPHENATION, lancat, lancat, TEXFILELINE, RELAX);
6579 ++extralines;
6580 }
6581 }
6582
6583 nerr = nerr + writetheline(lineptr[i], nlines, i, deepsort, filec, printsort, kandkused, mostoktitarg);
6584
6585 ++i;
6586 }
6587
6588 if (nerr > 0)
6589 {
6590 printf("%%%% !!!\n");
6591 printf("%%%% I\'ve marked %d page/footnote number(s)\n", nerr);
6592 printf("%%%% as \"%s\", \"%s\", \"%s\", and \"%s...%s\" for\n", OVERFLOWSYMB, EMPTYSYMB, MISSINGERMS, TEXTSYMBOPEN[notext], TEXTSYMBCLOSE[notext]);
6593 printf("%%%% counter overflow / empty / missing / invalid (TEXT).\n");
6594 if (notext == 0 && (strcmp(TEXTSYMBOPEN[0], TEXTSYMBOPEN[1]) != 0 || strcmp(TEXTSYMBCLOSE[0], TEXTSYMBCLOSE[1]) != 0))
6595 {
6596 printf("%%%% Use opt -c to set invalids ");
6597 if (*TEXTSYMBOPEN[1] != '\0' || *TEXTSYMBCLOSE[1] != '\0')
6598 printf("as \"%s...%s\"", TEXTSYMBOPEN[1], TEXTSYMBCLOSE[1]);
6599 else printf("naked");
6600 printf(".\n");
6601 }
6602 printf("%%%% !!!\n");
6603 }
6604
6605 return extralines;
6606 }
6607
6608
6609 /*--------------------------------------------------------------------------*/
6610
6611
6612 /* Autoren, die mehrfach vorkommen, werden genannt */
6613 /* und ab dann durch P|IKILLNAME/NKILLNAME ersetzt */
6614
6615
6616 int authorcmp(const char *s, const char *p, int dqcats, int dqcatp)
6617 {
6618 int mlen = strlen(MALE), flen = strlen(FEMALE), cont = 1;
6619 int hlen = strlen(HASDOT), nlen = strlen(NOTDOT);
6620
6621 while(1)
6622 {
6623 if (lcmdcmp(s, MALE) == 0) { s += mlen; while (*s == ' ') ++s; cont = 0; }
6624 if (lcmdcmp(s, FEMALE) == 0) { s += flen; while (*s == ' ') ++s; cont = 0; }
6625 if (lcmdcmp(s, HASDOT) == 0) { s += hlen; while (*s == ' ') ++s; cont = 0; }
6626 if (lcmdcmp(s, NOTDOT) == 0) { s += nlen; while (*s == ' ') ++s; cont = 0; }
6627 if (strncmp(s, "\\-", 2) == 0) { s += 2; cont = 0; }
6628
6629 if (lcmdcmp(p, MALE) == 0) { p += mlen; while (*p == ' ') ++p; cont = 0; }
6630 if (lcmdcmp(p, FEMALE) == 0) { p += flen; while (*p == ' ') ++p; cont = 0; }
6631 if (lcmdcmp(p, HASDOT) == 0) { p += hlen; while (*p == ' ') ++p; cont = 0; }
6632 if (lcmdcmp(p, NOTDOT) == 0) { p += nlen; while (*p == ' ') ++p; cont = 0; }
6633 if (strncmp(p, "\\-", 2) == 0) { p += 2; cont = 0; }
6634
6635 if (nogsty == 0)
6636 {
6637 if (dqcats == TeXACTIVE)
6638 {
6639 if (strncmp(s, "\"\"", 2) == 0) { s += 2; cont = 0; }
6640 if (strncmp(s, "\"-", 2) == 0) { s += 2; cont = 0; }
6641 }
6642 if (dqcatp == TeXACTIVE)
6643 {
6644 if (strncmp(p, "\"\"", 2) == 0) { p += 2; cont = 0; }
6645 if (strncmp(p, "\"-", 2) == 0) { p += 2; cont = 0; }
6646 }
6647 }
6648
6649 if (cont == 1)
6650 {
6651 if (*s != '\0' && *p == *s)
6652 {
6653 if (*s == '\\' && *(s+1) != '\0' && *(p+1) == *(s+1)) { ++p; ++s; }
6654 else
6655 if (*s == '\"' && dqcats != dqcatp) break;
6656 ++p; ++s;
6657 }
6658 else break;
6659 }
6660 else if (*s == '\0' || *p == '\0') break;
6661
6662 cont = 1;
6663 }
6664
6665 if (*p == '\0' && *s == '\0') return 0;
6666 return 1;
6667 }
6668
6669
6670 int texcmp(const char *s, const char *p, int dqcats, int dqcatp)
6671 {
6672 while(1)
6673 {
6674 if (*s != '\0' && *p == *s)
6675 {
6676 if (*s == '\\' && *(s+1) != '\0' && *(p+1) == *(s+1)) { ++p; ++s; }
6677 else
6678 if (*s == '\"' && dqcats != dqcatp) break;
6679 ++p; ++s;
6680 }
6681 else break;
6682 }
6683
6684 if (*p == '\0' && *s == '\0') return 0;
6685 return 1;
6686 }
6687
6688
6689 int lcmdcmp(const char *s, const char *p)
6690 {
6691 int r = 1;
6692
6693 while (*s != '\0')
6694 {
6695 if (*s == *p) { ++s; ++p; }
6696 else break;
6697
6698 if (*p == '\0' && isLaTeXcmdletter(*s) == 0)
6699 {
6700 r = 0;
6701 break;
6702 }
6703 }
6704
6705 return r;
6706 }
6707
6708
6709 int findFEmale(const char *s)
6710 {
6711 int r = 0;
6712
6713 while(*s != '\0')
6714 {
6715 if (*s == '\\')
6716 {
6717 if (*(s+1) == '\\') ++s;
6718 else
6719 if ( lcmdcmp(s, MALE) == 0
6720 || lcmdcmp(s, FEMALE) == 0
6721 )
6722 { r = 1;
6723 break;
6724 }
6725 }
6726 ++s;
6727 }
6728
6729 return r;
6730 }
6731
6732
6733 void baaddx_error(void)
6734 {
6735 printf("%%%% baaddx-error\n");
6736 }
6737
6738
6739 int insertfalse(const char *p, char a[], int i)
6740 {
6741 int n;
6742
6743 while (*p == ' ') ++p;
6744 n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error();
6745 while (n-- > 0 && i < MAXLEN) a[i++] = *p++;
6746
6747 while (*p == ' ') ++p;
6748 if (*p == '{' && i < MAXLEN)
6749 { a[i++] = *p++;
6750
6751 while (*p == ' ') ++p;
6752 n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error();
6753 while (n-- > 0 && i < MAXLEN) a[i++] = *p++;
6754
6755 while (*p == ' ') ++p;
6756 n = nextbracket(p, '{', '}'); if (n < 2) baaddx_error();
6757 while (n-- > 0) p++;
6758
6759 if (i + strlen(BAFALSE) < MAXLEN)
6760 {
6761 a[i] = '\0'; strcat(a, BAFALSE); i += strlen(BAFALSE);
6762 }
6763 }
6764 else baaddx_error();
6765
6766 while (*p != '\0' && i < MAXLEN) a[i++] = *p++;
6767
6768 return i;
6769 }
6770
6771
6772 int count_rejected(int nlines)
6773 {
6774 int ret = 0, i = 0;
6775
6776 while (i < nlines)
6777 {
6778 if (leval[i] == REJECTLINE)
6779 ++ret; /* parallel zu double_or_empty_abbreviation */
6780 ++i;
6781 }
6782
6783 return ret;
6784 }
6785
6786
6787 int checkifabbrisdefined(int nlines, int ret, char *Thead, const char *Thold, int Thint, int i)
6788 {
6789 int found = 2, pwgt, fwgt;
6790 char *pg, *fnt, *tline;
6791
6792 if ( leval[i] != REJECTLINE
6793 && *subAptr[1][i] == '\0'
6794 && ( *Thold == '\0'
6795 || texcmp(subAptr[0][i], Thead, dqsort[i], Thint) != 0
6796 )
6797 )
6798 {
6799 leval[i] = UNDEFILINE;
6800 ++ret;
6801 found = 0;
6802 }
6803
6804
6805 Thead = subAptr[0][i];
6806 Thint = dqsort[i];
6807 pg = subRptr[PAGECOL][i];
6808 fnt = subRptr[FNTCOL][i];
6809 tline = subRptr[LINECOL][i];
6810 pwgt = pagewgt[i];
6811 fwgt = fntwgt[i];
6812
6813 if (found == 0)
6814 {
6815 while (++i < nlines && texcmp(subAptr[0][i], Thead, dqsort[i], Thint) == 0)
6816 {
6817 if ( leval[i] != REJECTLINE
6818 && *subAptr[1][i] != '\0'
6819 )
6820 { found = 1;
6821 break;
6822 }
6823 }
6824 }
6825
6826 if (found == 0)
6827 { printf("%%%%\n%%%%> Warning: Abbreviation \"%s\" is NEVER defined!\n", Thead);
6828 printf("%%%% The entry (%s", tline);
6829 if (Thint > -1) printf(", \":%d", Thint);
6830 printf(") is rejected. Use %s\?\n", ABKDEF);
6831 }
6832
6833 if (found == 1 &&
6834 ( strcmp(tline, subRptr[LINECOL][i]) != 0
6835 || strcmp( fnt, subRptr[FNTCOL][i] ) != 0
6836 )
6837 )
6838 {
6839 printf("%%%%\n%%%%> Warning: Abbreviation \"%s\" is used in\n", Thead);
6840 printf("%%%% ");
6841 if (fnt != nofnt)
6842 { printf("A FNT ");
6843 if (fwgt != fntwgt[i] && subRptr[FNTCOL][i] != nofnt && strcmp(pg, subRptr[PAGECOL][i]) == 0)
6844 printf("T%d ", fwgt);
6845 }
6846 printf("%s and def in ", tline);
6847 if (subRptr[FNTCOL][i] != nofnt)
6848 {
6849 printf("A FNT ");
6850 if (fwgt != fntwgt[i] && fnt != nofnt && strcmp(pg, subRptr[PAGECOL][i]) == 0)
6851 printf("T%d ", fntwgt[i]);
6852 }
6853 printf("%s!\n", subRptr[LINECOL][i]);
6854 }
6855
6856 return ret;
6857 }
6858
6859
6860 int entkerne_IeC(char buf[], const char *s)
6861 {
6862 return entkerne_arg(buf, s, IeC, '{', '}');
6863 }
6864
6865
6866 void printdline(int len, const char *s)
6867 {
6868 printf("\"");
6869 maxprint(len, s);
6870 printf("\"");
6871 }
6872
6873
6874 void printD(const char *txt, const char *head, const char *Thold, const char *Trej, int i, int mem, int nmsg)
6875 {
6876 int prnlen = 0;
6877
6878 if (nmsg == 0)
6879 {
6880 printf("%%%%\n%%%%> Warning: Different %s ", txt);
6881 printdline(50 - strlen(txt), head);
6882 printf(":\n");
6883
6884 printf("%%%% *Accept ");
6885 if (mem > -1)
6886 {
6887 printf("%s ", subRptr[LINECOL][mem]);
6888 prnlen = 60 - strlen(subRptr[LINECOL][mem]);
6889 }
6890 printdline(prnlen, Thold);
6891 printf(";\n");
6892 }
6893
6894 printf("%%%% *Reject %s ", subRptr[LINECOL][i]);
6895
6896 if (strcmp(Thold, Trej) == 0)
6897 printf("(same string with other dq-catcode %d)", getarabicnum(subRptr[DQCOL][i]));
6898 else printdline(60 - strlen(subRptr[LINECOL][i]), Trej);
6899
6900 printf(".\n");
6901 }
6902
6903
6904 int twoargsSTUFFcmp(const char *txt, int i, int mem, int messn)
6905 {
6906 char a_buf[MAXLEN], b_buf[MAXLEN];
6907
6908 if (mem > -1)
6909 {
6910 getfirsttwoargs(a_buf, subRptr[STUFFRCOL][i]);
6911 getfirsttwoargs(b_buf, subRptr[STUFFRCOL][mem]);
6912
6913 if (texcmp(a_buf, b_buf, getarabicnum(subRptr[DQCOL][i]), getarabicnum(subRptr[DQCOL][mem])) != 0)
6914 {
6915 if (messn < MAXMESSN)
6916 {
6917 printD(txt, subAptr[0][i], b_buf, a_buf, i, mem, messn);
6918 }
6919 ++messn;
6920 }
6921 }
6922
6923 return messn;
6924 }
6925
6926
6927 int xstrcmp(const char *a, const char *b, int mem, int i)
6928 {
6929 if ( ( nogsty == 1
6930 || (mem > -1 && getarabicnum(subRptr[DQCOL][i]) == getarabicnum(subRptr[DQCOL][mem]))
6931 || userusesdq(PCOLS, i) == 0
6932 )
6933 && strcmp(a, b) == 0
6934 ) return 0;
6935 return 1;
6936 }
6937
6938
6939 void printT(int i)
6940 {
6941 printf("%%%% ");
6942 print_two(i, 0, 1);
6943 printf("\n");
6944 }
6945
6946
6947 void warnFEmaleT(int nlines)
6948 {
6949 int i = 0;
6950
6951 while (i < nlines)
6952 {
6953 if ( findFEmale(subAptr[0][i]) != 0
6954 || findFEmale(subAptr[1][i]) != 0
6955 )
6956 {
6957 printf("%%%%\n%%%%> Warning: %s or %s in entry %s:\n", FEMALE, MALE, subRptr[LINECOL][i]);
6958 printT(i);
6959 }
6960 ++i;
6961 }
6962 }
6963
6964
6965 void checkSTUFFblock(const char *msg, int i, const int nlines, const int deepsort, const int deep)
6966 {
6967 const int mem = i;
6968 const char *TheadA = subAptr[0][mem];
6969 const char *TheadB = subAptr[1][mem];
6970 const char *TheadC = subAptr[2][mem];
6971 const char *TheadD = subAptr[3][mem];
6972 const int Thint = dqsort[mem];
6973 int messn = 0;
6974
6975
6976 if ( deepsort != deep
6977 && deepsort != deep-1
6978 )
6979 {
6980 intern_err(20); /* deep/deepsort */
6981 }
6982 else
6983 {
6984 while (++i < nlines)
6985 {
6986 if (leval[i] == REJECTLINE);
6987 else
6988 if ( (deepsort > 0 && texcmp(subAptr[0][i], TheadA, dqsort[i], Thint) != 0)
6989 || (deepsort > 1 && texcmp(subAptr[1][i], TheadB, dqsort[i], Thint) != 0)
6990 || (deepsort > 2 && texcmp(subAptr[2][i], TheadC, dqsort[i], Thint) != 0)
6991 || (deepsort > 3 && texcmp(subAptr[3][i], TheadD, dqsort[i], Thint) != 0)
6992 )
6993 {
6994 break;
6995 }
6996 else if ( deepsort == deep
6997 || (*subAptr[deep-1][i] != '\0' && texcmp(subAptr[deep-1][i], subAptr[deep-1][mem], getarabicnum(subRptr[DQCOL][i]), getarabicnum(subRptr[DQCOL][mem])) == 0)
6998 )
6999 {
7000 messn = twoargsSTUFFcmp(msg, i, mem, messn);
7001 }
7002 }
7003
7004 if (messn > MAXMESSN) printf("%%%% *** Report the first %d different seps (of %d) for that entry. ***\n", MAXMESSN, messn);
7005 }
7006 }
7007
7008
7009 int double_or_empty_abbreviation(int nlines, int deepsort, int deep)
7010 {
7011 int i, ret = 0, Thint = -1, mem = -1;
7012 char *Thead = "", *Thold = "", *Thart = NULL, *oldmsg = NULL, *oldstuffA = NULL, *oldstuffB = NULL;
7013
7014 /* dqsort geht bis zur Tiefe deepsort, nicht deep */
7015
7016
7017 warnFEmaleT(nlines);
7018
7019
7020 i = 0; while (i < nlines)
7021 {
7022 if (leval[i] == REJECTLINE)
7023 {
7024 ++ret; /* Anzahl bereits auskommentierter Zeilen */
7025 }
7026 else
7027 if (*subAptr[0][i] == '\0')
7028 {
7029 leval[i] = REJECTLINE;
7030 printf("%%%%\n%%%%> Reject empty abbreviation in %s!\n", subRptr[LINECOL][i]);
7031 ++ret;
7032 }
7033 ++i;
7034 }
7035
7036
7037 ret = checkifabbrisdefined(nlines, ret, Thead, Thold, Thint, 0);
7038
7039 i = 1; while (i < nlines)
7040 {
7041 if ( leval[i-1] != REJECTLINE
7042 && *subAptr[0][i-1] != '\0'
7043 && *subAptr[1][i-1] != '\0'
7044 )
7045 {
7046 if ( *Thold == '\0'
7047 || texcmp(subAptr[0][i-1], Thead, dqsort[i-1], Thint) != 0
7048 )
7049 { Thold = subAptr[1][i-1];
7050 mem = i-1;
7051 Thart = subRptr[FNTCOL][i-1];
7052 }
7053 else
7054 if (Thart != nofnt && subRptr[FNTCOL][i-1] == nofnt)
7055 {
7056 Thart = subRptr[FNTCOL][i-1];
7057 }
7058 Thead = subAptr[0][i-1];
7059 Thint = dqsort[i-1];
7060 }
7061
7062 if ( leval[i] != REJECTLINE
7063 && *subAptr[0][i] != '\0'
7064 && *subAptr[1][i] == '\0'
7065 && Thart != NULL
7066 && Thart != nofnt
7067 && subRptr[FNTCOL][i] == nofnt
7068 && texcmp(subAptr[0][i], Thead, dqsort[i], Thint) == 0
7069 )
7070 {
7071 if (oldmsg == NULL || strcmp(oldmsg, subAptr[0][i]) != 0)
7072 printf("%%%%\n%%%%> Warning: Abbreviation \"%s\" is used in\n", subAptr[0][i]);
7073 printf("%%%% TEXT %s, whereas all foregoing defs were in FNTs!\n", subRptr[LINECOL][i]);
7074 oldmsg = subAptr[0][i];
7075 }
7076
7077 ret = checkifabbrisdefined(nlines, ret, Thead, Thold, Thint, i);
7078
7079 if ( leval[i] != REJECTLINE
7080 && *subAptr[1][i] == '\0'
7081 && *Thold != '\0'
7082 && texcmp(subAptr[0][i], Thead, dqsort[i], Thint) == 0
7083 )
7084 {
7085 leval[i] = ABBREVLINE;
7086 ++ret;
7087 }
7088
7089 if ( leval[i] != REJECTLINE
7090 && *subAptr[1][i] != '\0'
7091 && *Thead != '\0'
7092 && texcmp(subAptr[0][i], Thead, dqsort[i], Thint) == 0
7093 )
7094 {
7095 if (xstrcmp(Thold, subAptr[1][i], mem, i) != 0) /* leval[i] sagt nichts zu Arg2 */
7096 {
7097 printD("defs for abbreviation", subAptr[0][i], Thold, subAptr[1][i], i, mem, 0);
7098 leval[i] = DIFFERLINE;
7099 ++ret;
7100 }
7101 else
7102 {
7103 leval[i] = DOUBLELINE;
7104 ++ret;
7105 /* printf("%%%%\n%%%%> Reject repeated def for abbreviation \"%s\" -> \"%s\"!\n", subAptr[0][i], subAptr[1][i]);
7106 */
7107 if ( (oldstuffA == NULL && oldstuffB == NULL)
7108 || strcmp(oldstuffA, subAptr[0][mem]) != 0
7109 || strcmp(oldstuffB, subAptr[1][mem]) != 0
7110 )
7111 checkSTUFFblock("abkdef-open/-close seps after", mem, nlines, deepsort, deep);
7112 oldstuffA = subAptr[0][mem];
7113 oldstuffB = subAptr[1][mem];
7114 }
7115 }
7116 ++i;
7117 }
7118
7119 return ret;
7120 }
7121
7122
7123 void printcline(int len, const char *s)
7124 {
7125 printf("(");
7126 maxprint(len, s);
7127 printf(") ");
7128 }
7129
7130
7131
7132 #define LMAX 26
7133 #define RMAX 36
7134
7135 void print_two(int i, int e, int z)
7136 {
7137 char bufa[MAXLEN], bufb[MAXLEN];
7138 int llen, rlen;
7139
7140 llen = entkerne_IeC(bufa, subAptr[e][i]);
7141 rlen = entkerne_IeC(bufb, subAptr[z][i]);
7142
7143 if (llen > LMAX && rlen > RMAX)
7144 {
7145 rlen = RMAX;
7146 llen = LMAX;
7147 }
7148 else
7149 if (llen + rlen > LMAX + RMAX)
7150 {
7151 if (llen > LMAX) llen = LMAX+RMAX-rlen;
7152 if (rlen > RMAX) rlen = LMAX+RMAX-llen;
7153 }
7154
7155 printcline(llen, bufa);
7156 printcline(rlen, bufb);
7157 }
7158
7159
7160 #define LEFTMAX 16
7161 #define MIDMAX 18
7162 #define RIGHTMAX 24
7163
7164 void print_three(int i, int e, int z, int d)
7165 {
7166 char bufa[MAXLEN], bufb[MAXLEN], bufc[MAXLEN];
7167 int llen, mlen, rlen, vari;
7168
7169 llen = entkerne_IeC(bufa, subAptr[e][i]);
7170 mlen = entkerne_IeC(bufb, subAptr[z][i]);
7171 rlen = entkerne_IeC(bufc, subAptr[d][i]);
7172
7173 if (llen > LEFTMAX && mlen > MIDMAX && rlen > RIGHTMAX)
7174 {
7175 rlen = RIGHTMAX;
7176 mlen = MIDMAX;
7177 llen = LEFTMAX;
7178 }
7179 else
7180 if (llen + mlen + rlen > LEFTMAX + MIDMAX + RIGHTMAX)
7181 {
7182 if (rlen <= RIGHTMAX && mlen <= MIDMAX)
7183 {
7184 llen = LEFTMAX + RIGHTMAX-rlen + MIDMAX-mlen;
7185 }
7186 else
7187 if (mlen <= MIDMAX && llen <= LEFTMAX)
7188 {
7189 rlen = RIGHTMAX + MIDMAX-mlen + LEFTMAX-llen;
7190 }
7191 else
7192 if (rlen <= RIGHTMAX && llen <= LEFTMAX)
7193 {
7194 mlen = MIDMAX + RIGHTMAX-rlen + LEFTMAX-llen;
7195 }
7196 else
7197 if (rlen <= RIGHTMAX)
7198 {
7199 vari = RIGHTMAX-rlen;
7200 if (llen > LEFTMAX + vari && mlen > MIDMAX)
7201 {
7202 llen = LEFTMAX + vari;
7203 mlen = MIDMAX;
7204 }
7205 else
7206 if (mlen + llen > MIDMAX + LEFTMAX + vari)
7207 {
7208 if (llen > LEFTMAX+vari) llen = MIDMAX+ LEFTMAX+vari-mlen;
7209 if (mlen > MIDMAX) mlen = MIDMAX+ LEFTMAX+vari-llen;
7210 }
7211 }
7212 else
7213 if (llen <= LEFTMAX)
7214 {
7215 vari = LEFTMAX-llen;
7216 if (mlen > MIDMAX + vari && rlen > RIGHTMAX)
7217 {
7218 mlen = MIDMAX + vari;
7219 rlen = RIGHTMAX;
7220 }
7221 else
7222 if (mlen + rlen > MIDMAX + RIGHTMAX + vari)
7223 {
7224 if (mlen > MIDMAX+vari) mlen = MIDMAX+RIGHTMAX+vari-rlen;
7225 if (rlen > RIGHTMAX) rlen = MIDMAX+RIGHTMAX+vari-mlen;
7226 }
7227 }
7228 else
7229 if (mlen <= MIDMAX)
7230 {
7231 vari = MIDMAX-mlen;
7232 if (llen > LEFTMAX + vari && rlen > RIGHTMAX)
7233 {
7234 llen = LEFTMAX + vari;
7235 rlen = RIGHTMAX;
7236 }
7237 else
7238 if (rlen + llen > RIGHTMAX + LEFTMAX + vari)
7239 {
7240 if (llen > LEFTMAX+vari) llen = RIGHTMAX+LEFTMAX+vari-rlen;
7241 if (rlen > RIGHTMAX) rlen = RIGHTMAX+LEFTMAX+vari-llen;
7242 }
7243 }
7244 }
7245
7246 if (llen + mlen + rlen > LEFTMAX + MIDMAX + RIGHTMAX)
7247 intern_err(21); /* Bad screen print */
7248
7249 printcline(llen, bufa);
7250 printcline(mlen, bufb);
7251 printcline(rlen, bufc);
7252 }
7253
7254
7255 #define MAXA 12
7256 #define MAXB 8
7257 #define MAXC 16
7258 #define MAXD 18
7259 #define ALLMAX (MAXA+MAXB+MAXC+MAXD)
7260
7261 void print_four(int i)
7262 {
7263 char bufa[MAXLEN], bufb[MAXLEN], bufc[MAXLEN], bufd[MAXLEN];
7264 int lena, lenb, lenc, lend;
7265 int over, overa = 0, overb = 0, overc = 0, overd = 0;
7266
7267 lena = entkerne_IeC(bufa, subAptr[1][i]); /* (Vorname) */
7268 lenb = entkerne_IeC(bufb, subAptr[0][i]);
7269 lenc = entkerne_IeC(bufc, subAptr[2][i]);
7270 lend = entkerne_IeC(bufd, subAptr[3][i]);
7271
7272 if (lena + lenb + lenc + lend > ALLMAX)
7273 {
7274 if (lena < MAXA) overa = MAXA - lena;
7275 if (lenb < MAXB) overb = MAXB - lenb;
7276 if (lenc < MAXC) overc = MAXC - lenc;
7277 if (lend < MAXD) overd = MAXD - lend;
7278
7279 over = overa + overb + overc + overd;
7280 overa = 0; overb = 0; overc = 0; overd = 0;
7281
7282 while (over > 0)
7283 {
7284 if (lena-overa > MAXA && over > 0) { ++overa; --over; }
7285 if (lenb-overb > MAXB && over > 0) { ++overb; --over; }
7286 if (lenc-overc > MAXC && over > 0) { ++overc; --over; }
7287 if (lend-overd > MAXD && over > 0) { ++overd; --over; }
7288 }
7289
7290 over = overa + overb + overc + overd;
7291
7292 while(lena + lenb + lenc + lend + over > ALLMAX)
7293 {
7294 if (lena + lenb + lenc + lend + over > ALLMAX && lena > MAXA) --lena;
7295 if (lena + lenb + lenc + lend + over > ALLMAX && lenb > MAXB) --lenb;
7296 if (lena + lenb + lenc + lend + over > ALLMAX && lenc > MAXC) --lenc;
7297 if (lena + lenb + lenc + lend + over > ALLMAX && lend > MAXD) --lend;
7298 }
7299 }
7300
7301 printcline(lena+overa, bufa); /* (Vorname) */
7302 printcline(lenb+overb, bufb);
7303 printcline(lenc+overc, bufc);
7304 printcline(lend+overd, bufd);
7305 }
7306
7307
7308 void fitssingleentry(int i, int nlines, int arq, const char *suffix)
7309 {
7310 int l;
7311
7312 if ( leval[i] != REJECTLINE
7313 && *subAptr[1][i] != '\0'
7314 && (arq != IS_Q || getthirdnum(i) == 0)
7315 )
7316 {
7317 l = i;
7318 while (l > 0)
7319 {
7320 if (leval[l-1] == REJECTLINE);
7321 else if (texcmp(subAptr[0][l-1], subAptr[0][i], dqsort[l-1], dqsort[i]) != 0) break;
7322 else if (*subAptr[1][l-1] == '\0') { --l; break; }
7323 --l;
7324 }
7325
7326 if (leval[l] == REJECTLINE || *subAptr[1][l] != '\0')
7327 {
7328 while (l < nlines-1)
7329 {
7330 if (leval[l+1] == REJECTLINE);
7331 else if (texcmp(subAptr[0][l+1], subAptr[0][i], dqsort[l+1], dqsort[i]) != 0) break;
7332 else if (*subAptr[1][l+1] == '\0') { ++l; break; }
7333 ++l;
7334 }
7335 }
7336
7337 if (leval[l] == REJECTLINE || *subAptr[1][l] != '\0')
7338 {
7339 printf("%%%%\n%%%%> Info: \\fill%s in %s fits NO single entry:\n", suffix, subRptr[LINECOL][i]);
7340 printT(i);
7341 }
7342 }
7343 }
7344
7345
7346 void misplaced_heading(int heada, int line)
7347 {
7348 printf("%%%%\n%%%%> Warning: Misplaced %d-heading (from %s):\n", heada, subRptr[LINECOL][line]);
7349 printT(line);
7350 }
7351
7352
7353 int double_or_empty_arqperregisters(int nlines, int arq, const char *suffix, int deepsort, int deep)
7354 {
7355 int i, ret = 0, ThintA = -1, mem = -1, lastmem = mem, len, heada, headb;
7356 char *TheadA = "", *heredefault = "", *TheadB = heredefault, *oldstuffA = NULL, *oldstuffB = NULL;
7357
7358
7359 warnFEmaleT(nlines);
7360
7361
7362 i = 0; while (i < nlines)
7363 {
7364 if (leval[i] == REJECTLINE)
7365 {
7366 ++ret; /* Anzahl bereits auskommentierter Zeilen */
7367 }
7368 else
7369 if (*subAptr[0][i] == '\0')
7370 {
7371 printf("%%%%\n%%%%> Warning: Empty entry in %s", subRptr[LINECOL][i]);
7372 if (*subAptr[1][i] != '\0')
7373 {
7374 if (arq == IS_Q && (heada=getthirdnum(i)) > 0)
7375 printf(" (%d-heading)", heada);
7376 else printf(" (\\fill%s-cmd)", suffix);
7377 }
7378 printf(".\n");
7379 leval[i] = REJECTLINE;
7380 ++ret;
7381 }
7382 ++i;
7383 }
7384
7385
7386 fitssingleentry(0, nlines, arq, suffix);
7387
7388
7389 i = 1; while (i < nlines)
7390 {
7391 if ( leval[i-1] != REJECTLINE
7392 && *subAptr[0][i-1] != '\0'
7393 && texcmp(subAptr[0][i-1], TheadA, dqsort[i-1], ThintA) != 0
7394 )
7395 {
7396 TheadA = subAptr[0][i-1];
7397 ThintA = dqsort[i-1];
7398
7399 if (pagewgt[i-1] == UNUSED)
7400 {
7401 mem = i-1;
7402 TheadB = subAptr[1][i-1];
7403 }
7404 else
7405 {
7406 mem = -1;
7407 TheadB = heredefault;
7408 }
7409 }
7410
7411 /* da deepsort < deep wird subAptr[1][i] von dqsort nicht erfasst */
7412 if ( leval[i] != REJECTLINE
7413 && *TheadA != '\0'
7414 && texcmp(subAptr[0][i], TheadA, dqsort[i], ThintA) == 0
7415 )
7416 {
7417 if (*subAptr[1][i] == '\0')
7418 {
7419 leval[i] = DOUBLELINE;
7420 }
7421 else
7422 {
7423 if (xstrcmp(TheadB, subAptr[1][i], mem, i) == 0) /* leval[i] sagt nichts zu Arg2 */
7424 {
7425 leval[i] = REDEF2LINE;
7426 if ( (oldstuffA == NULL && oldstuffB == NULL)
7427 || strcmp(oldstuffA, subAptr[0][mem]) != 0
7428 || strcmp(oldstuffB, subAptr[1][mem]) != 0
7429 )
7430 checkSTUFFblock("open/close seps after", mem, nlines, deepsort, deep);
7431 oldstuffA = subAptr[0][mem];
7432 oldstuffB = subAptr[1][mem];
7433 }
7434 else
7435 {
7436 printD("fills for head", subAptr[0][i], TheadB, subAptr[1][i], i, mem, 0);
7437 if (arq == IS_Q && getthirdnum(i) == 1)
7438 printf("%%%% ... A list-internal heading is shadowed.\n");
7439 leval[i] = DIFFERLINE;
7440 }
7441 }
7442
7443 ++ret;
7444 }
7445
7446
7447 if ( arq == IS_Q
7448 && ( leval[i] == ACCEPTLINE
7449 || leval[i] == REDEF2LINE
7450 || leval[i] == DOUBLELINE
7451 )
7452 )
7453 {
7454 if ( mem > lastmem
7455 && (heada=getthirdnum(mem)) > 0
7456 )
7457 {
7458 len = strlen(TheadA);
7459 headb = getthirdnum(i);
7460 if ( strncmp(subAptr[0][i], TheadA, len) != 0
7461 || len >= strlen(subAptr[0][i])
7462 || (headb < heada && headb > 0)
7463 )
7464 {
7465 misplaced_heading(heada, mem);
7466 printf("%%%% ... That");
7467 if (texcmp(subAptr[0][i], TheadA, dqsort[i], ThintA) == 0)
7468 printf(" melts into ");
7469 else
7470 {
7471 printf("\'s before ");
7472 if (strcmp(subAptr[0][i], TheadA) == 0) printf("[\"!] ");
7473 }
7474 if (headb > 0)
7475 {
7476 printf("%d-heading", headb);
7477 printf(" (from %s):\n", subRptr[LINECOL][i]);
7478 printT(i);
7479 }
7480 else printf("list item (from %s).\n", subRptr[LINECOL][i]);
7481 }
7482 }
7483 lastmem = mem;
7484 }
7485
7486
7487 fitssingleentry(i, nlines, arq, suffix);
7488
7489 ++i;
7490 }
7491
7492
7493 return ret;
7494 }
7495
7496
7497 void printV(int i)
7498 {
7499 printf("%%%% ");
7500 if (dqsort[i] == TeXACTIVE)
7501 printf( "!\" ");
7502 else
7503 printf( " ");
7504
7505 if (*subAptr[2][i] == '\0')
7506 {
7507 print_three(i, 1, 0, 3); /* (Vorname) (Nachname) (Rest) */
7508 }
7509 else
7510 {
7511 print_four(i);
7512 }
7513 printf("\n");
7514 }
7515
7516
7517 void printK(int i)
7518 {
7519 printf("%%%% ");
7520 if (dqsort[i] == TeXACTIVE)
7521 printf( "!\" ");
7522 else
7523 printf( " ");
7524
7525 if (*subAptr[1][i] == '\0')
7526 {
7527 print_two(i, 0, 2);
7528 }
7529 else
7530 {
7531 print_three(i, 0, 1, 2);
7532 }
7533 printf("\n");
7534 }
7535
7536
7537 int checkifisfullcited(int i, int nlines, int ret)
7538 {
7539 char *TheadA = subAptr[0][i];
7540 char *TheadB = subAptr[1][i];
7541 char *TheadC = subAptr[2][i];
7542 char *TheadD = subAptr[3][i];
7543 int Thint = dqsort[i], mem = i, j = i, cnt = 0, rest = nlines;
7544
7545
7546
7547
7548 if ( leval[i] != REJECTLINE
7549 && isvintroduced(i) == KENTRY
7550 )
7551 {
7552 printf("%%%%\n%%%%> Info: Short-%s-title %s is NOT yet introduced.\n", subAptr[3][i], subRptr[LINECOL][i]);
7553 printK(i);
7554
7555
7556 while (++i < nlines)
7557 {
7558 if (leval[i] == REJECTLINE);
7559 else
7560 if ( texcmp(subAptr[0][i], TheadA, dqsort[i], Thint) != 0
7561 || texcmp(subAptr[1][i], TheadB, dqsort[i], Thint) != 0
7562 || texcmp(subAptr[2][i], TheadC, dqsort[i], Thint) != 0
7563 || texcmp(subAptr[3][i], TheadD, dqsort[i], Thint) != 0
7564 )
7565 break;
7566 else
7567 if (isvintroduced(i) == VENTRY)
7568 {
7569 if (subRptr[FNTCOL][j] != nofnt && subRptr[FNTCOL][i] != nofnt && fntwgt[j] != fntwgt[i] && strcmp(subRptr[PAGECOL][j], subRptr[PAGECOL][i]) == 0)
7570 printf("%%%% Full titel %s and short title in FNTs T%d T%d.\n", subRptr[LINECOL][i], fntwgt[i], fntwgt[j]);
7571 else
7572 printf("%%%% ... Exchange it with the full-title in %s.\n", subRptr[LINECOL][i]);
7573 mem = i;
7574
7575 leval[j] = DOUBLELINE;
7576 ++ret;
7577
7578 break;
7579 }
7580 else
7581 {
7582 leval[i] = DOUBLELINE;
7583 ++ret;
7584 }
7585 }
7586 if (mem == j)
7587 {
7588 if (findFEmale(subAptr[0][mem]) != 0 || findFEmale(subAptr[1][mem]) != 0 || findFEmale(subAptr[2][mem]) != 0)
7589 printf("%%%% ... Delete misplaced cmd %s or %s.\n", FEMALE, MALE);
7590 else
7591 printf("%%%% ... Change that short-title into missing full-title (%s)\?\n", KTIT);
7592 }
7593
7594 rest = i;
7595 }
7596
7597 i = mem;
7598 if ( leval[i] != REJECTLINE
7599 && isvintroduced(i) == VENTRY
7600 )
7601 {
7602 while (++i < nlines)
7603 {
7604 if (leval[i] == REJECTLINE);
7605 else
7606 if ( texcmp(subAptr[0][i], TheadA, dqsort[i], Thint) != 0
7607 || texcmp(subAptr[1][i], TheadB, dqsort[i], Thint) != 0
7608 || texcmp(subAptr[2][i], TheadC, dqsort[i], Thint) != 0
7609 || texcmp(subAptr[3][i], TheadD, dqsort[i], Thint) != 0
7610 )
7611 break;
7612 else
7613 if (isvintroduced(i) == VENTRY)
7614 {
7615 ++cnt;
7616 if (cnt == 1)
7617 printf("%%%%\n%%%%> Info: ");
7618 else if (cnt < MAXINFO)
7619 printf("%%%%> ");
7620 if (cnt < MAXINFO)
7621 {
7622 printf("Re-introduction of "); /* intro cnt+1 */
7623 if (cnt > 1) printf("that ");
7624 printf("short-%s-title in %s.\n", subAptr[3][i], subRptr[LINECOL][i]);
7625 }
7626 if (cnt == 1)
7627 {
7628 printK(i);
7629 printf("%%%% First introduction has been in %s (%s).\n", subRptr[LINECOL][mem], KTIT);
7630 }
7631
7632 leval[i] = REDEF1LINE;
7633 ++ret;
7634 }
7635 else
7636 {
7637 leval[i] = DOUBLELINE;
7638 ++ret;
7639 }
7640 }
7641
7642 if (cnt+1 > MAXINFO)
7643 printf("%%%%> This have been the first %d (of %d) intros of that short-title.\n", MAXINFO, cnt+1);
7644
7645 rest = i;
7646 }
7647
7648 i = rest;
7649 while (++i < nlines)
7650 {
7651 if (leval[i] == REJECTLINE);
7652 else
7653 if ( texcmp(subAptr[0][i], TheadA, dqsort[i], Thint) == 0
7654 && texcmp(subAptr[1][i], TheadB, dqsort[i], Thint) == 0
7655 && texcmp(subAptr[2][i], TheadC, dqsort[i], Thint) == 0
7656 && texcmp(subAptr[3][i], TheadD, dqsort[i], Thint) == 0
7657 )
7658 {
7659 leval[i] = DOUBLELINE;
7660 ++ret;
7661 }
7662 else break;
7663 }
7664
7665 return ret;
7666 }
7667
7668
7669 void checkmanipulationk(int i)
7670 {
7671
7672 if ( leval[i] != REJECTLINE
7673 && isvintroduced(i) == ERRENTRY
7674 )
7675 {
7676 printf("%%%%\n%%%%> Warning: Reference %s has unknown status.\n", subRptr[LINECOL][i]);
7677 printK(i);
7678 }
7679 }
7680
7681
7682 void checkshortmismatch(int i, const int nlines, const int mem)
7683 {
7684 while (i < nlines)
7685 {
7686 if ( texcmp(subAptr[0][i], subAptr[0][mem], dqsort[i], dqsort[mem]) == 0
7687 && texcmp(subAptr[1][i], subAptr[1][mem], dqsort[i], dqsort[mem]) == 0
7688 && texcmp(subAptr[2][i], subAptr[2][mem], dqsort[i], dqsort[mem]) == 0
7689 && texcmp(subAptr[3][i], subAptr[3][mem], dqsort[i], dqsort[mem]) != 0
7690 )
7691 {
7692 printf("%%%%\n%%%%> Warning: SAME short-title used for ...li and ...qu:\n");
7693 printK(i);
7694 printf("%%%% See %s in %s and %s in %s.\n", subAptr[3][i], subRptr[LINECOL][i], subAptr[3][mem], subRptr[LINECOL][mem]);
7695 }
7696 else break;
7697
7698 ++i;
7699 }
7700 }
7701
7702
7703 int double_k(int nlines, int deepsort)
7704 {
7705 int i, ret = 0, mem = 0;
7706 char *TheadA = subAptr[0][0];
7707 char *TheadB = subAptr[1][0];
7708 char *TheadC = subAptr[2][0];
7709 char *TheadD = subAptr[3][0];
7710 int Thint = dqsort[0];
7711
7712
7713 i = 0; while (i < nlines)
7714 {
7715 if ( findFEmale(subAptr[0][i]) != 0
7716 || findFEmale(subAptr[1][i]) != 0
7717 || findFEmale(subAptr[2][i]) != 0
7718 )
7719 {
7720 printf("%%%%\n%%%%> Warning: %s or %s in short-%s-title %s:\n", FEMALE, MALE, subAptr[3][i], subRptr[LINECOL][i]);
7721 printK(i);
7722 if (isvintroduced(i) == VENTRY)
7723 printf("%%%% ... That k-entry was generated automatically from a v-entry.\n");
7724 }
7725 ++i;
7726 }
7727
7728 i = 0; while (i < nlines)
7729 {
7730 if (leval[i] == REJECTLINE)
7731 {
7732 ++ret; /* Anzahl bereits auskommentierter Zeilen */
7733 }
7734 ++i;
7735 }
7736
7737 ret = checkifisfullcited(0, nlines, ret);
7738 checkmanipulationk(0);
7739
7740 i = 1; while (i < nlines)
7741 {
7742 if ( leval[i-1] != REJECTLINE
7743 && (
7744 texcmp(subAptr[0][i], TheadA, dqsort[i], Thint) != 0
7745 || texcmp(subAptr[1][i], TheadB, dqsort[i], Thint) != 0
7746 || texcmp(subAptr[2][i], TheadC, dqsort[i], Thint) != 0
7747 || texcmp(subAptr[3][i], TheadD, dqsort[i], Thint) != 0
7748 )
7749 )
7750 {
7751 TheadA = subAptr[0][i];
7752 TheadB = subAptr[1][i];
7753 TheadC = subAptr[2][i];
7754 TheadD = subAptr[3][i];
7755 Thint = dqsort[i];
7756 ret = checkifisfullcited(i, nlines, ret);
7757 checkshortmismatch(i, nlines, mem);
7758 mem = i;
7759 checkSTUFFblock("vkc-seps after", i, nlines, deepsort, deepsort);
7760 }
7761
7762 checkmanipulationk(i);
7763
7764 ++i;
7765 }
7766
7767 return ret;
7768 }
7769
7770
7771 int doubleventries(int nlines, int deepsort)
7772 {
7773 int ret = 0, i = 1, alast = -1, ainfos = 0, aget = 0, mem = -1, difftitle = 0, shown = 0;
7774
7775 /* geht davon aus, dass count_rejected nur REJECTLINE behandelt */
7776 /* und doubleauthor commentANDignlines unveraendert laesst! */
7777
7778 while (i < nlines)
7779 {
7780 if ( texcmp(subAptr[0][i], subAptr[0][i-1], dqsort[i], dqsort[i-1]) == 0
7781 && texcmp(subAptr[1][i], subAptr[1][i-1], dqsort[i], dqsort[i-1]) == 0
7782 && texcmp(subAptr[2][i], subAptr[2][i-1], dqsort[i], dqsort[i-1]) == 0
7783 && texcmp(subAptr[3][i], subAptr[3][i-1], dqsort[i], dqsort[i-1]) == 0
7784 )
7785 {
7786 if (mem < 0) mem = i-1;
7787
7788 if (alast < i-1)
7789 {
7790 if (ainfos < MAXINFO)
7791 {
7792 printf("%%%%\n%%%%> Info: Identical full-titles %s, %s:\n", subRptr[LINECOL][i-1], subRptr[LINECOL][i]);
7793 printV(i);
7794 ainfos+=2;
7795 ++shown;
7796 }
7797 else
7798 ++difftitle;
7799 aget +=2;
7800 }
7801 else
7802 {
7803 if (ainfos < MAXINFO)
7804 {
7805 printf("%%%%> ... and the same entry again from %s.\n", subRptr[LINECOL][i]);
7806 ainfos+=1;
7807 }
7808 aget +=1;
7809 }
7810 alast = i;
7811
7812
7813 if ( leval[i] != REJECTLINE
7814 && leval[i-1] != REJECTLINE
7815 )
7816 {
7817 leval[i] = DOUBLELINE;
7818 ++ret;
7819
7820 if (mem == i-1) checkSTUFFblock("v-seps after", mem, nlines, deepsort, deepsort);
7821 }
7822 }
7823 else mem = -1;
7824
7825 ++i;
7826 }
7827
7828 if (ainfos > 1)
7829 {
7830 printf("%%%%\n%%%%> This have been the first %d (of %d) entries", ainfos, aget);
7831 if (shown > 1)
7832 printf(" (%d different titles)", shown);
7833 printf("\n%%%% which are repeatingly cited");
7834 if (aget > MAXINFO)
7835 printf(" (further %d different titles)", difftitle);
7836 printf(".\n%%%%\n");
7837 }
7838
7839 return ret;
7840 }
7841
7842
7843 int doubleauthor(const char *entry, int nlines)
7844 {
7845 int i, num = 0, len = strlen(entry), killpos, hint, Adq;
7846 char a[MAXLEN], *p, xx[1], *AAp, *ABp, *ACp;
7847
7848 strcpy(a, entry);
7849
7850 i = 0; while (i < nlines)
7851 {
7852 if (findFEmale(subAptr[0][i]) != 0)
7853 { printf("%%%%\n%%%%> Warning: %s or %s in lastname instead firstname %s:\n", FEMALE, MALE, subRptr[LINECOL][i]);
7854 printV(i);
7855 }
7856 if (findFEmale(subAptr[2][i]) != 0)
7857 { printf("%%%%\n%%%%> Warning: %s or %s in OptArg %s:\n", FEMALE, MALE, subRptr[LINECOL][i]);
7858 printV(i);
7859 }
7860 ++i;
7861 }
7862
7863 while(--nlines > 0)
7864 {
7865 if (*subAptr[0][nlines] == '\0' && *subAptr[1][nlines] == '\0') continue;
7866 if (leval[nlines] == REJECTLINE) continue;
7867
7868 hint = nlines-1;
7869 while(hint >= 0 && leval[hint] == REJECTLINE) --hint;
7870 if (hint < 0) break;
7871 AAp = subAptr[0][hint];
7872 ABp = subAptr[1][hint];
7873 Adq = dqsort[hint];
7874 ACp = subAptr[2][hint];
7875
7876 if ( authorcmp(subAptr[0][nlines], AAp, dqsort[nlines], Adq) == 0
7877 && authorcmp(subAptr[1][nlines], ABp, dqsort[nlines], Adq) == 0
7878 )
7879 {
7880 i = len; p = lineptr[nlines] + len;
7881
7882 while (*p == ' ') { a[i++] = ' '; ++p; }
7883 a[i++] = '{'; a[i] = '\0';
7884 p += nextbracket(p, '{', '}');
7885 killpos = i + 1;
7886 strcat(a, IKILLNAME); i = i + strlen(IKILLNAME);
7887 a[i++] = '}';
7888
7889 while (*p == ' ') { a[i++] = ' '; ++p; }
7890 a[i++] = '{';
7891 p += nextbracket(p, '{', '}');
7892 a[i++] = '}';
7893
7894 while (*p == ' ') { a[i++] = ' '; ++p; }
7895 a[i++] = '{';
7896 p += nextbracket(p, '{', '}');
7897
7898 if (findFEmale(ABp) == 0 && findFEmale(subAptr[1][nlines]) == 1)
7899 { printf("%%%%\n%%%%> Warning: No %s or %s in firstname %s:\n", FEMALE, MALE, subRptr[LINECOL][hint]);
7900 printV(hint);
7901 }
7902
7903 xx[0] = '0';
7904 i = subdoubleauthors(0, 0, a, i, i, ACp, subAptr[2][nlines], hint, nlines, findFEmale(ABp), xx);
7905 if (i < 0)
7906 { i = -i; a[killpos] = PLURALCHAR;
7907 a[i++] = '}';
7908 if (xx[0] != '0') i = insertfalse(p, a, i);
7909 else while (*p != '\0' && i < MAXLEN) a[i++] = *p++;
7910 }
7911 else
7912 { a[i++] = '}';
7913 while (*p != '\0' && i < MAXLEN) a[i++] = *p++;
7914 }
7915
7916
7917 if (i < MAXLEN)
7918 { ++num;
7919 myfree(lineptr[nlines]);
7920 lineptr[nlines] = strnmalloc(a, i+1);
7921 }
7922 else printf("%%%%\n%%%%> Error: Can\'t replace {%s}{%s} by %s (too long)\n", subAptr[0][nlines], subAptr[1][nlines], IKILLNAME);
7923 }
7924 }
7925 return num;
7926 }
7927
7928
7929 void pauthorbrackwarn(int nline, const char *head)
7930 {
7931 printf("%%%%\n%%%%> Warning outfile entry %d (in arg 3): Missing brackets as %s{..}{..}\n", nline+1, head);
7932 }
7933
7934
7935 int subdoubleauthors(int found, int addtxt, char a[], int remi, int i, const char *q, const char *p, int qline, int pline, int fe, char xx[])
7936 {
7937 int ql = 0, pl, len, haveto, havedone = 0, ntxt = 0, nn, j;
7938 char qbuf[MAXLEN] = "", pbuf[MAXLEN] = "";
7939 const char *pmem, *qin = q, *pin = p;
7940 const char *head;
7941
7942 while(*q != '\0')
7943 {
7944 haveto = 0;
7945 if ((j=texlistnum(q, NAUTHOR, authortable)) > -1)
7946 {
7947 head = authortable[j][1];
7948 haveto = 1;
7949 }
7950 else if (*q != ' ') ntxt = 1;
7951
7952 if (haveto == 1)
7953 {
7954 q += llstrlen(authortable[j][0]);
7955 while(*q == ' ') ++q;
7956 if (*q == '{' && (ql = nextbracket(q, '{', '}')) > 1)
7957 {
7958 ql = mystrncpy(qbuf, q, ql);
7959 q += ql;
7960 while(*q == ' ') ++q;
7961 ql = ql + (len=nextbracket(q, '{', '}'));
7962 if (len > 1)
7963 {
7964 strncat(qbuf, q, len);
7965 q += len;
7966 }
7967 }
7968 break;
7969 }
7970 else
7971 if (*q == '\\' && *(q+1) == '\\')
7972 {
7973 ntxt = 1;
7974 q++;
7975 }
7976
7977 q++;
7978 }
7979
7980
7981 while(*p != '\0' && i < MAXLEN-1)
7982 {
7983 haveto = 0;
7984 if ((j=texlistnum(p, NAUTHOR, authortable)) > -1)
7985 {
7986 head = authortable[j][1];
7987 haveto = 1;
7988 }
7989 else if (*p != ' ') ntxt = 1;
7990
7991 if (haveto == 1)
7992 {
7993 pmem = p;
7994 p += llstrlen(authortable[j][0]);
7995 while(*p == ' ') ++p;
7996 if (*p == '{' && (pl = nextbracket(p, '{', '}')) > 1)
7997 {
7998 pl = mystrncpy(pbuf, p, pl);
7999 p += pl;
8000 while(*p == ' ') ++p;
8001 pl = pl + (len=nextbracket(p, '{', '}'));
8002 if (len > 1)
8003 { strncat(pbuf, p, len);
8004 p += len;
8005 if ( authorcmp(qbuf, pbuf, dqsort[qline], dqsort[pline]) == 0
8006 && strcmp(qbuf, "{}{}") != 0
8007 && strcmp(qbuf, "{ }{ }") != 0
8008 && i + strlen(head) + 4 + strlen(NKILLNAME) + 1 < MAXLEN
8009 )
8010 {
8011 a[i] = '\0';
8012 strcat(a, head); i += strlen(head);
8013 strcat(a, " {}{"); i += 4;
8014 strcat(a, NKILLNAME); i += strlen(NKILLNAME);
8015 strcat(a, "}"); i += 1;
8016 havedone = 1;
8017 }
8018 else
8019 { p = pmem;
8020 }
8021 }
8022 else
8023 { p = pmem; pauthorbrackwarn(pline, head);
8024 }
8025 break;
8026 }
8027 else
8028 { p = pmem; pauthorbrackwarn(pline, head);
8029 }
8030 }
8031 else
8032 if (*p == '\\' && *(p+1) == '\\')
8033 {
8034 ntxt = 1;
8035 a[i++] = *p++;
8036 }
8037
8038 a[i++] = *p++;
8039 }
8040
8041
8042 if (havedone == 0)
8043 {
8044 if (found > 0 && addtxt == 0 && fe == 1 && findauthor(qin) == -1)
8045 { nn = 1; i = remi;
8046 p = pin;
8047 while (*p == ' ') ++p;
8048 if (ntxt == 1) xx[0] = '1';
8049 } else nn = 0;
8050
8051 while (*p != '\0' && i < MAXLEN) a[i++] = *p++;
8052 if (nn == 1) i = -i;
8053 }
8054 else
8055 { if (ntxt > 0) addtxt = ntxt;
8056 i = subdoubleauthors(++found, addtxt, a, remi, i, q, p, qline, pline, fe, xx);
8057 }
8058
8059 return i;
8060 }
8061
8062
8063 /*--------------------------------------------------------------------------*/
8064
8065
8066 int readlines(int maxlines, int nlines, const char *head)
8067 {
8068 int len, headlen = strlen(head);
8069 char *p, linestr[MAXLEN];
8070
8071 while ((len = ignFRONTSPACESgetline(linestr, MAXLEN)) > 0)
8072 {
8073 if ( strncmp(linestr, head, headlen) == 0
8074 && isLaTeXcmdletter(*(linestr+headlen)) == 0
8075 )
8076 {
8077 if ( nlines >= maxlines
8078 || (p = (char *) malloc(len)) == NULL
8079 ) return -1;
8080 else
8081 { linestr[len-1] = '\0';
8082 strcpy(p, linestr);
8083 lineptr[nlines++] = p;
8084 }
8085 }
8086 }
8087 return nlines;
8088 }
8089
8090
8091 /*--------------------------------------------------------------------------*/
8092
8093 /* Kehrt mit -argc+1 zur"uck, wenn Option da ist. */
8094
8095 int single_option(int argc, char *argv[], char a[], char b[])
8096 {
8097
8098 int l = 1, c;
8099 int _found = 0;
8100
8101 while (l < argc)
8102 {
8103 if (strcmp(argv[l], a) == 0 || strcmp(argv[l], b) == 0)
8104 { _found = 1;
8105 /* myfree(argv[l]); */
8106 --argc;
8107 c = l;
8108 while (c < argc)
8109 { argv[c] = argv[c+1];
8110 ++c;
8111 }
8112 --l;
8113 }
8114 ++l;
8115 }
8116 if (_found == 1) return -argc;
8117 else return argc;
8118 }
8119
8120
8121 char *arg_option(int argc, char *argv[], char a[], char b[], char *info)
8122 {
8123
8124 int l = 1, c, found = 0;
8125 char *p = NULL;
8126
8127 if (argc > 1 && (strcmp(argv[argc-1], a) == 0 || strcmp(argv[argc-1], b) == 0))
8128 {
8129 printf("%%%%\n%%%%> Error: %s is not followed by an argument %s.\n", b, info);
8130 announceexit("get an arg option without arg");
8131 exit(1);
8132 }
8133
8134 while (l < argc-1)
8135 {
8136 if (strcmp(argv[l], a) == 0 || strcmp(argv[l], b) == 0)
8137 {
8138 /* myfree(argv[l]); */
8139 p = argv[l+1];
8140 ++found;
8141 argc -= 2;
8142 c = l;
8143 while (c < argc)
8144 {
8145 argv[c] = argv[c+2];
8146 ++c;
8147 }
8148 --l;
8149 }
8150 ++l;
8151 }
8152
8153 if (found > 1)
8154 {
8155 printf("%%%%\n%%%%> Error: %s [arg] setted %d times.\n", a, found);
8156 announceexit("do not accept multiple defined arg options");
8157 exit(1);
8158 }
8159
8160 return p;
8161 }
8162
8163
8164 /*--------------------------------------------------------------------------*/
8165
8166 /* Erkennt unbekannte Optionen. */
8167
8168 int surp_option(int argc, char *argv[])
8169 {
8170 int l = 1, c;
8171
8172 while (l < argc)
8173 {
8174 if (*argv[l] == '-')
8175 { printf("%%%%\n%%%%> Error: Get unknown option \"%s\"!\n", argv[l]);
8176 /* myfree(argv[l]); */
8177 --argc;
8178 c = l;
8179 while (c < argc)
8180 { argv[c] = argv[c+1];
8181 ++c;
8182 }
8183 --l;
8184 }
8185 ++l;
8186 }
8187 return argc;
8188 }
8189
8190
8191 /*--------------------------------------------------------------------------*/
8192
8193
8194 char *makename(const char *prefix, const char *suffix)
8195 {
8196 char fname[MAXFILENAMLEN];
8197 int plen;
8198
8199 plen = mystrncpy(fname, prefix, MAXFILENAMLEN-1);
8200 strncat(fname, suffix, MAXFILENAMLEN-plen-1);
8201
8202 if (plen + strlen(suffix) > MAXFILENAMLEN-1)
8203 {
8204 announceexit("get a too long path/file name");
8205 printf("%%%%\n%%%% \"%s%s\"\n", prefix, suffix);
8206 exit(1);
8207 }
8208
8209 return strnmalloc(fname, strlen(fname)+1);
8210 }
8211
8212
8213 int dofile(int filenum, char *filenam, int nlines, const char *entry, const char *formO, int deep, int deepsort, int ventry)
8214 {
8215 int alllines = nlines;
8216
8217 infile = fopen(filenam, "r");
8218
8219 if (infile != NULL)
8220 {
8221 printf("%%%%> Search *\"%s\"* in file \"%s\" ...\n", entry, filenam);
8222
8223 if ((alllines = readlines(MAXLINES, nlines, entry)) >= 0)
8224 {
8225 if (alllines-nlines > 0 && MAXLINES > 0)
8226 {
8227 printf("%%%% ^^^^^^^^^^^ ... get %d line(s)", alllines-nlines);
8228 if (alllines*100/MAXLINES > 0)
8229 printf(" [reach %d%% of capacity]", alllines*100/MAXLINES);
8230 printf(".\n");
8231 }
8232 getbrackets(nlines, alllines, entry, deep, filenum, formO, ventry);
8233 dopgfntnumberweight(nlines, alllines);
8234 dodqdeepsort(nlines, alllines, deepsort);
8235 vorbereiten(nlines, alllines, deepsort, ventry);
8236 }
8237 else printf("%%%%\n%%%%> Error: More than %d input entries.\n", MAXLINES); /* exit(1) bei dofile */
8238 }
8239 else
8240 { printf("%%%%\n%%%%> Error: No file \"%s\".\n", filenam);
8241 openfailed(filenam);
8242 }
8243
8244 if (infile != NULL) fclose(infile);
8245
8246 return alllines;
8247 }
8248
8249
8250 char *switchtodospath(char s[])
8251 {
8252 int i = 0;
8253
8254 while (s[i] != '\0')
8255 {
8256 if (s[i] == '/') s[i] = '\\';
8257 ++i;
8258 }
8259
8260 return s;
8261 }
8262
8263
8264 int getfilenames(int nlines, int usedospath)
8265 {
8266 int i = 0, j = 0, len;
8267 char *p;
8268
8269 while (i < nlines)
8270 {
8271 p = setptrtofirstbracket(lineptr[i]);
8272 if (*p == '{' && (len=nextbracket(p, '{', '}')) > 2)
8273 { filelist[j] = strnmalloc(p+1, len-1);
8274 p += len;
8275 if (usedospath == 1)
8276 filelist[j] = switchtodospath(filelist[j]);
8277 ignoreadditionaltext(p, "\\@input", filelist[j]);
8278 ++j;
8279 }
8280 else printf("%%%%\n%%%%> Error after \\@input-cmd %d: Empty, or not matching brackets.\n", i+1);
8281 myfree(lineptr[i]);
8282 ++i;
8283 }
8284 if (i != j && i != 0) printf("%%%% %d input file(s) remain(s).\n", j);
8285 return j;
8286 }
8287
8288
8289 int userusesdq(int deepsort, int linec)
8290 {
8291 int i = 0;
8292 char *p;
8293
8294 while (i < deepsort)
8295 {
8296 p = subAptr[i++][linec];
8297 while (*p != '\0')
8298 {
8299 if (*p == '\"') return 1;
8300 if (*p == '\\' && *(p+1) != '\0') ++p;
8301 ++p;
8302 }
8303 }
8304
8305 return 0;
8306 }
8307
8308
8309 void freeall(int nlines, int deep, int deepsort)
8310 {
8311 int linec = 0, i;
8312
8313 if (deepsort > deep) intern_err(22); /* deepsort > deep */
8314
8315 while(linec < nlines)
8316 { myfree(lineptr[linec]);
8317 i = 0; while (i < deep) myfree(subAptr[i++][linec]);
8318 i = 0; while (i < deepsort) myfree(subBptr[i++][linec]);
8319 while (i < deep ) if (subBptr[i++][linec] != mydefault) intern_err(23); /* FREEALL */
8320 i = 0; while (i < deepsort) myfree(subCptr[i++][linec]);
8321 while (i < deep ) if (subCptr[i++][linec] != mydefault) intern_err(24); /* FREEALL */
8322 i = 0; while (i < BAALLRCOLS) myfree(subRptr[i++][linec]);
8323 ++linec;
8324 }
8325 }
8326
8327
8328 void testdrucken(int linec, int alllines, int deep, char *subptr[MAXBACOLS][MAXLINES])
8329 {
8330 int i;
8331
8332 while (linec < alllines)
8333 {
8334 i = 0;
8335 while (i < deep)
8336 {
8337 printf(" (%s)", subptr[i][linec]);
8338 ++i;
8339 }
8340 printf(" [\"=%d, %d]", dqsort[linec], getarabicnum(subRptr[DQCOL][linec]));
8341 printf("\n");
8342 ++linec;
8343 }
8344 }
8345
8346
8347 #define WARNDOUBLEMAX 5
8348
8349 int fprint_out_ktit(int alllines, int deep, int ventry, const char *suffix)
8350 {
8351 int linec = 0, i = 0, num = 0, numa = -1, numb = -1, numc = -1, numd = -1, kina = 0, kinb = 0, kinc = 0, kind = 0;
8352 int mostoktitarg = O_KTIT_UNINIT, warndouble = 0, j = 0, numalter = 0;
8353
8354 if (ventry == IS_V)
8355 {
8356 while (linec < alllines)
8357 {
8358 numa = -1; numb = -1; numc = -1; numd = -1;
8359 i = 0;
8360 while (i < deep)
8361 {
8362 num = num_of_cmds_in_str(subAptr[i][linec], KTITCMD);
8363
8364 if (num > 0)
8365 {
8366 j = i+1;
8367 while (j < deep)
8368 {
8369 if ((numalter = num_of_cmds_in_str(subAptr[j][linec], KTITCMD)) > 0)
8370 {
8371 num = 0;
8372 break;
8373 }
8374 ++j;
8375 }
8376 }
8377
8378 if (i == 0) { numa = num; }
8379 else if (i == 1) { numb = num; }
8380 else if (i == 2) { numc = num; }
8381 else if (i == 3) { numd = num; }
8382 else intern_err(40);
8383
8384 if (numa+numb+numc+numd > 1)
8385 {
8386 if (warndouble < WARNDOUBLEMAX)
8387 {
8388 printf("%%%%\n%%%%> Warning %s: *Outer* %s used %d times in:\n", subRptr[LINECOL][linec], KTIT, (numa+numb+numc+numd));
8389 printV(linec);
8390 }
8391 ++warndouble;
8392 }
8393 ++i;
8394 }
8395
8396 if (numa > 0) { ++kina; }
8397 if (numb > 0) { ++kinb; }
8398 if (numc > 0) { ++kinc; }
8399 if (numd > 0) { ++kind; }
8400
8401 ++linec;
8402 }
8403
8404 if (warndouble > WARNDOUBLEMAX)
8405 printf("%%%%\n%%%%> ... for %d futher entries with multiple %s see file.\n", warndouble-WARNDOUBLEMAX, KTIT);
8406
8407 if (kina > kinb && kina > kinc && kina > kind) { mostoktitarg = MOST_O_KTIT_ARGONE; /* arg 1 most used */ }
8408 else if (kinb > kina && kinb > kinc && kinb > kind) { mostoktitarg = MOST_O_KTIT_ARGTWO; /* arg 2 most used */ }
8409 else if (kinc > kina && kinc > kinb && kinc > kind) { mostoktitarg = MOST_O_KTIT_ARGTHREE; /* arg 3 most used */ }
8410 else if (kind > kina && kind > kinb && kind > kinc) { mostoktitarg = MOST_O_KTIT_ARGFOUR; /* arg 4 most used */ }
8411 else if (kina > 0 || kinb > 0 || kinc > 0 || kind > 0) { mostoktitarg = O_KTIT_NOPREF; /* no preference */ }
8412 else { mostoktitarg = O_KTIT_NOTUSED; /* ktit not used */ }
8413
8414 printf("%%%%> Summary *outer* v-cmds in %s: %s ", suffix, KTIT);
8415 if (mostoktitarg == O_KTIT_NOTUSED)
8416 {
8417 printf("never used.\n");
8418 }
8419 else
8420 if (mostoktitarg == O_KTIT_NOPREF)
8421 {
8422 printf("defined in different args!\n%%%%\n");
8423 /* kina, kinb, kinc, kind save lastused args with \ktit,
8424 not all args with \ktit! */
8425 }
8426 else
8427 {
8428 if (kina == alllines || kinb == alllines || kinc == alllines || kind == alllines)
8429 { if (alllines > 1) printf("in all %d entries ", alllines); }
8430 else
8431 printf("NOT always ");
8432 printf("defined in ");
8433 if (alllines > 1)
8434 {
8435 if (kina == alllines || kinb == alllines || kinc == alllines || kind == alllines);
8436 else printf("mostused ");
8437 }
8438 printf("arg %d.\n", mostoktitarg);
8439 if (kina == alllines || kinb == alllines || kinc == alllines || kind == alllines);
8440 else printf("%%%% *******\n");
8441 }
8442 }
8443 else
8444 {
8445 mostoktitarg = O_KTIT_UNINIT; /* ventry != IS_V */
8446 }
8447
8448 return mostoktitarg;
8449 }
8450
8451
8452 int check_kandk(int nlines)
8453 {
8454 int i = 0;
8455 int outkurz = 0;
8456 int ktit = 0;
8457
8458 while (i < nlines)
8459 {
8460 outkurz += num_of_cmds_in_str(lineptr[i], KURZCMD);
8461 ktit += num_of_cmds_in_str(lineptr[i], KTITCMD);
8462 ++i;
8463 }
8464
8465 if (outkurz > 0 && ktit > 0)
8466 {
8467 printf("%%%%\n%%%%> Warning: %d time(s) %s and %d time(s) %s found;\n", outkurz, KURZ, ktit, KTIT);
8468 printf("%%%% see %s warnings in the output file.\n", KURZ);
8469 }
8470
8471 if (outkurz > 0 && ktit > 0) return 1;
8472 return 0;
8473 }
8474
8475
8476 char *fill_vbuf(char *b, char *p)
8477 {
8478 char *a = b;
8479 int arglen;
8480
8481 while (*p == ' ') *b++ = *p++;
8482
8483 arglen = nextbracket(p, '{', '}');
8484
8485 if (arglen > 1 && *p == '{')
8486 {
8487 while (arglen-- > 0) *b++ = *p++;
8488 }
8489 else
8490 {
8491 b = a;
8492 }
8493
8494 *b = '\0';
8495
8496 return p;
8497 }
8498
8499
8500 #define MAX_EX_ERR 5
8501
8502 int lastname_first(int nlines)
8503 {
8504 int i = 0, pos, j, k, ex_err = 0, ex_used = 0;
8505 char *p, bufa[MAXLEN], bufb[MAXLEN], *bega, *begp, *begc;
8506
8507
8508 while (i < nlines)
8509 {
8510 p = lineptr[i];
8511 begp = p;
8512
8513
8514 while ((pos=findauthor(p)) > -1)
8515 {
8516 ++ex_used;
8517
8518 p += pos;
8519 begc = p;
8520
8521 while (*p != '{' && *p != '}' && *p != ' ' && *p != '\0') ++p;
8522 bega = p;
8523
8524 p = fill_vbuf (bufa, p);
8525
8526 p = fill_vbuf (bufb, p);
8527
8528
8529 if (*(begc) == '\0' || *(begc+1) == '\0' || *(begc+2) == '\0')
8530 {
8531 intern_err(31);
8532 }
8533 else
8534 {
8535 if (bufb[0] != '\0' && bufa[0] != '\0')
8536 {
8537 *(begc+2) = '@'; /* \v@uthor \m@dvauthor */
8538
8539 j = 0;
8540 k = 0;
8541
8542 if (bufa[0] == ' ' && bufb[0] == '{')
8543 {
8544 *bega++ = bufa[k++];
8545 }
8546
8547 while (bufb[j] != '\0') *bega++ = bufb[j++];
8548
8549 while (bufa[k] != '\0') *bega++ = bufa[k++];
8550 }
8551 else
8552 {
8553 if (ex_err < MAX_EX_ERR)
8554 {
8555 printf("%%%%\n%%%%> Warning: Can\'t identify the brackets of ");
8556 if (bufa[0] == '\0') printf(" {arg1}");
8557 if (bufb[0] == '\0') printf(" {arg2}");
8558 printf(" after your cmd:\n");
8559 printf("%%%% \"%.*s", 30, begc);
8560 if (strlen(begc) > 30) printf(" ...");
8561 printf("\" (entry from %s).\n", subRptr[LINECOL][i]);
8562 }
8563 else
8564 if (ex_err == MAX_EX_ERR)
8565 {
8566 printf("%%%%\n%%%%> -e: Do not report further error details.\n");
8567 }
8568 ++ex_err;
8569 }
8570 }
8571 }
8572
8573 ++i;
8574 }
8575
8576 if (ex_used > 0)
8577 return ex_err;
8578 else
8579 return -1;
8580 }
8581
8582
8583 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 *formO, int ventry, int printsort)
8584 {
8585 int mostoktitarg = O_KTIT_UNINIT; /* new in 2.5 */
8586 int nlines = 0, i = 0, extralines = 0, commentANDignlines = 0;
8587 int filenum = -1, kandkused = 0, ex_err;
8588 char *outname = mydefault;
8589
8590 if (arg_o == NULL) outname = makename(arg_i, suffix);
8591 else outname = makename(arg_o, suffix);
8592
8593 ktiterr = 0;
8594 thisupperascii = 0;
8595 mystrncpy(this_emp_utf_eight, "", UTF_EIGHT_MAXLEN);
8596 mystrncpy(this_err_utf_eight, "", UTF_EIGHT_MAXLEN);
8597
8598 while (i < filec)
8599 {
8600 if (filec > 0) filenum = i+1;
8601 if ((nlines = dofile(filenum, filelist[i++], nlines, entry, formO, deep, deepsort, ventry)) < 0)
8602 {
8603 announceexit("get a too big list of entries");
8604 exit(1);
8605 }
8606 }
8607
8608 if (MAXLINES > 0 && nlines*100/MAXLINES > 90)
8609 printf("%%%% *** WARNING: Have capacity for only %d further entries! ***\n%%%%\n", MAXLINES-nlines);
8610
8611
8612 /* printf("\nC: "); testdrucken(0, nlines, deep, subCptr); */
8613 /* printf("\nB: "); testdrucken(0, nlines, deep, subBptr); */
8614 /* printf("\nA: "); testdrucken(0, nlines, deep, subAptr); */
8615 /* testdrucken(0, nlines, BAALLRCOLS, subRptr); */
8616
8617
8618
8619 if (nlines > 0)
8620 {
8621 ++get_jobs;
8622
8623 if (nlines > 1) printf("%%%% Sort %d lines. Wait.\n", nlines);
8624 QQsort(0, nlines-1, deep, deepsort);
8625
8626
8627 if (prep_kill == DOKILLAUTHORS && nlines > 1)
8628 { printf("%%%%> -k: Search multiply used authors ...\n");
8629 printf("%%%%> -k: Authors in %d line(s) IDEMized [identical full-titles included].\n", doubleauthor(entry, nlines));
8630 commentANDignlines = count_rejected(nlines);
8631 }
8632 else
8633 if (prep_kill == DOKILLABBREVS && nlines > 0)
8634 { printf("%%%% Search multiply used or empty abbreviations ...\n");
8635 commentANDignlines = double_or_empty_abbreviation(nlines, deepsort, deep);
8636 }
8637 else
8638 if (prep_kill == DOKILLREGISTS && nlines > 0)
8639 { printf("%%%% Search multiply used or empty entries ...\n");
8640 if (*suffix == '.')
8641 commentANDignlines = double_or_empty_arqperregisters(nlines, ventry, suffix+1, deepsort, deep);
8642 else intern_err(25); /* ERROR with \\fill... */
8643 }
8644 else
8645 if (prep_kill == DOKILLK && nlines > 0)
8646 { printf("%%%% Search multiply used short-titles ...\n");
8647 commentANDignlines = double_k(nlines, deepsort);
8648 }
8649 else commentANDignlines = count_rejected(nlines);
8650
8651
8652 if (prep_kill == DOKILLAUTHORS || prep_kill == NOKILLAUTHORS)
8653 {
8654 if (deep == VCOLS && ventry == IS_V)
8655 commentANDignlines = commentANDignlines + doubleventries(nlines, deepsort);
8656 else intern_err(26); /* ERROR with doubleventries */
8657 }
8658
8659 kandkused = check_kandk(nlines);
8660 /* oktitused = check_ktit deleted in 2.5 */
8661
8662 if (ex_n == EXCHANGENAMES)
8663 {
8664 ex_err = lastname_first(nlines);
8665 if (ex_err > 0)
8666 {
8667 printf("%%%%\n%%%%> -e: ... the exchange of {FirstName} and {FamilyName} args\n");
8668 printf("%%%% after %s or %s *failed* in %d case(s).\n%%%%\n", authortable[0][1], authortable[1][1], ex_err);
8669 }
8670 /* not used: ex_err < 0 */
8671 }
8672
8673 if ((outfile = fopen(outname, "w")) == NULL)
8674 {
8675 printf("%%%%\n%%%%> Error: Can\'t write to file \"%s\".\n", outname);
8676 openfailed(outname);
8677 }
8678 else
8679 {
8680 mostoktitarg = fprint_out_ktit(nlines, deep, ventry, suffix);
8681 printf("%%%%> Write %d item(s) to file \"%s\".\n", nlines-commentANDignlines, outname);
8682 if ((extralines = writelines(nlines, DQCOL, LANCOL, commentANDignlines, deepsort, filec, printsort, kandkused, mostoktitarg)) > 0)
8683 printf("%%%% (Have added %d line(s) containing commands for LaTeX.)\n", extralines);
8684 if (ktiterr > 0)
8685 printf("%%%%\n%%%%> ** Wrote %d comment(s) into file concerning %s. **\n%%%%\n", ktiterr, KTIT);
8686 }
8687
8688 if (outfile != NULL) { fclose(outfile); fflush(outfile); }
8689 freeall(nlines, deep, deepsort);
8690 }
8691 else
8692 {
8693 printf("%%%% No entries. ");
8694 if ((outfile = fopen(outname, "r")) != NULL)
8695 {
8696 fclose(outfile); fflush(outfile);
8697 if ((outfile = fopen(outname, "w")) != NULL)
8698 {
8699 fclose(outfile); fflush(outfile);
8700 printf("*DELETE* old");
8701 remove(outname);
8702 }
8703 else printf("CAN\'T delete");
8704 }
8705 else printf("Do NOT create");
8706 printf(" file \"%s\".\n", outname);
8707 }
8708
8709 outhline();
8710
8711 myfree(outname);
8712 }
8713
8714
8715 #define ALLWEIGHT ENDWEIGHT-2
8716 void setnewweight(const int pg, const char *p, const char *opt)
8717 {
8718 int lauf = BEGINWEIGHT; /* 4 ... 7+2 */
8719 int have_n = 0;
8720 int have_R = 0, typed_R = 0;
8721 int have_r = 0, typed_r = 0;
8722 int have_A = 0, typed_A = 0;
8723 int have_a = 0, typed_a = 0;
8724 int have_s = 0;
8725 int wrong_letter = 0;
8726 const char *q = p;
8727
8728 while(*p != '\0' && lauf < ALLWEIGHT)
8729 {
8730 if (*p == 'n') { if (pg == 1) { pg_arabic = lauf; } else { fn_arabic = lauf; } ++have_n; }
8731 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; }
8732 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; }
8733 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; }
8734 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; }
8735 else if (*p == 's') { if (pg == 1) { pg_symbol = lauf; } else { fn_symbol = lauf; } ++have_s; }
8736 else { ++wrong_letter; break; }
8737 ++lauf; ++p;
8738 }
8739
8740
8741 if ( *p != '\0'
8742 || lauf != ALLWEIGHT
8743 || have_n != 1
8744 || have_R != 1
8745 || have_r != 1
8746 || have_A != 1
8747 || have_a != 1
8748 || have_s != 1
8749 )
8750 {
8751 printf("%%%%\n%%%%> Error: Not the %d expected letters in \"%s %.29s\".\n", ALLWEIGHT-BEGINWEIGHT, opt, q);
8752 if (strlen(q) <= ALLWEIGHT-BEGINWEIGHT)
8753 {
8754 printf("%%%% Missing:");
8755 if ( have_n == 0) printf(" [n]");
8756 if ( have_s == 0) printf(" [s]");
8757 if (typed_R == 0 && typed_A == 0) printf(" [R *or* A]");
8758 if (typed_r == 0 && typed_a == 0) printf(" [r *or* a]");
8759 }
8760 else
8761 {
8762 printf("%%%% Error: More than %d letters", ALLWEIGHT-BEGINWEIGHT);
8763 }
8764 printf(". E.g.: snRa, nArs, Rrns, naAs.\n");
8765 if ( have_n > 1
8766 || have_s > 1
8767 || typed_R > 1
8768 || typed_A > 1
8769 || typed_r > 1
8770 || typed_a > 1
8771 )
8772 {
8773 printf("%%%% Error: You have setted");
8774 if (typed_A > 1) printf(" [A]");
8775 if (typed_a > 1) printf(" [a]");
8776 if ( have_n > 1) printf(" [n]");
8777 if (typed_R > 1) printf(" [R]");
8778 if (typed_r > 1) printf(" [r]");
8779 if ( have_s > 1) printf(" [s]");
8780 printf(" more than once.\n");
8781 }
8782 if ( (typed_A > 0 && typed_R > 0)
8783 || (typed_a > 0 && typed_r > 0)
8784 )
8785 {
8786 printf("%%%% Error: You have setted");
8787 if (typed_A > 0 && typed_R > 0) printf(" [R] *and* [A]");
8788 if (typed_A > 0 && typed_R > 0 && typed_a > 0 && typed_r > 0)
8789 printf(", and ");
8790 if (typed_a > 0 && typed_r > 0) printf(" [r] *and* [a]");
8791 printf(".\n");
8792 if ( (typed_a > 0 && typed_r > 0)
8793 || (typed_A > 0 && typed_R > 0)
8794 )
8795 {
8796 printf("%%%% ** A number like 'i' could mean 9 (alph), and 1 (roman). In xxxx,\n");
8797 printf("%%%% ** you can only choose R and a, or R and r, or A and a, or A and r.\n");
8798 }
8799 }
8800 if (wrong_letter > 0) printf("%%%% Break: Unexpected character \'%c\'.\n", *p);
8801 announceexit("did not get 4 out of nRrAas (R or A, r or a)");
8802 exit(1);
8803 }
8804
8805
8806 if (pg == 1)
8807 {
8808 if (get_r_pg == BA_FALSE) pg_smallroman = ++lauf;
8809 if (get_R_pg == BA_FALSE) pg_bigroman = ++lauf;
8810 if (get_a_pg == BA_FALSE) pg_smallletter = ++lauf;
8811 if (get_A_pg == BA_FALSE) pg_bigletter = ++lauf;
8812 }
8813 else
8814 {
8815 if (get_r_fn == BA_FALSE) fn_smallroman = ++lauf;
8816 if (get_R_fn == BA_FALSE) fn_bigroman = ++lauf;
8817 if (get_a_fn == BA_FALSE) fn_smallletter = ++lauf;
8818 if (get_A_fn == BA_FALSE) fn_bigletter = ++lauf;
8819 }
8820
8821 if ((pg == 0 || pg == 1) && lauf == ENDWEIGHT);
8822 else intern_err(27); /* setnewweight */
8823 }
8824
8825
8826 void print_arg_list(char *argv[], int argc)
8827 {
8828 int l = 1;
8829 while (l < argc) printf("%%%% %d: \"%s\"\n", l, argv[l++]);
8830 }
8831
8832
8833 void printhex(int n)
8834 {
8835 printf(" (U+");
8836 if (n < 256) printf("0");
8837 if (n < 4096) printf("0");
8838 printf("%X)", n);
8839 }
8840
8841
8842 void print_utf_msg(const char err[UTF_EIGHT_MAXERR][UTF_EIGHT_MAXLEN+1], int err_c, const char *msg_a, const char *msg_b, const char *msg_c, const char *msg_d, const char *msg_e, const char *msg_f)
8843 {
8844 int i, j = 0, a, b, c, d, len;
8845
8846 if (err_c > 0)
8847 {
8848 printf("%%%%\n");
8849 fprintf(stderr, "%%%%> -utf8 : I did %s %s utf8 sequences.\n", msg_d, msg_b);
8850
8851 while (j < err_c && j < UTF_EIGHT_MAXERR)
8852 {
8853 printf("%%%%> %s utf8 sequence ", msg_a);
8854 if (err[j][1] == '\0') printf("consisting only of octet "); /* msg changed in 2.4, 2.5 */
8855 i = 0; while(err[j][i] != '\0') { printf("%d", ((unsigned char)err[j][i])); if(err[j][i+1] != '\0') printf("-"); ++i; }
8856
8857 a = ((unsigned char)err[j][0]);
8858 b = ((unsigned char)err[j][1]);
8859 c = ((unsigned char)err[j][2]);
8860 d = ((unsigned char)err[j][3]);
8861
8862 len = lenUTFacht(a, b, c, d);
8863
8864 /* 64 = (UTF_BLOCK_END - UTF_BLOCK_BEGIN + 1) */
8865
8866 if (len == 2) printhex((a - DOUBLETTES_BEGIN) * 64 + b);
8867 if (len == 3) printhex((a - TRIPLETTES_BEGIN) * 4096 + (b - 128) * 64 + (c - 128));
8868 if (len == 4) printhex((a - QUADRUPLES_BEGIN) * 262144 + (b - 128) * 4096 + (c - 128) * 64 + (d - 128));
8869
8870 printf(" %s.\n", msg_c);
8871 ++j;
8872 }
8873
8874 if (err_c >= UTF_EIGHT_MAXERR) printf("%%%% (Max. %d different %s sequences are reported.)\n", UTF_EIGHT_MAXERR, msg_e);
8875 printf("%%%% %s\n", msg_f);
8876 }
8877 }
8878
8879
8880 void no_upperascii_found_msg(const char *msg)
8881 {
8882 if (get_jobs > 0)
8883 {
8884 printf("%%%%\n%%%%> %s unnecessary yet: No ASCIIs > 127 found!\n", msg);
8885 }
8886 }
8887
8888
8889 int main(int argc, char *argv[])
8890 {
8891 int nlines = 0;
8892 int usedospath = 0;
8893 int filec = 0;
8894 int get_g = 0, get_cp = 0;
8895 int printsort = 0;
8896 char *inname = mydefault, *arg_i = NULL, *arg_o = NULL;
8897
8898
8899 printf("\n%%%%> This is bibsort 2.6 (for help: %s -\?)\n", getmyname(argv[0], 37));
8900 fprintf(stderr, "%%%% bibsort 2.6 is part of BibArts 2.6 (C) Timo Baumann 2023.\n");
8901
8902
8903 argc = single_option(argc, argv, "-B", "-b");
8904 if (argc < 0)
8905 {
8906 bago = 1;
8907 argc = -argc;
8908 }
8909
8910 argc = single_option(argc, argv, "-N1", "-n1");
8911 if (argc < 0)
8912 {
8913 FntIndexOverPages = 0;
8914 argc = -argc;
8915 }
8916
8917 argc = single_option(argc, argv, "-c", "-C");
8918 if (argc < 0)
8919 { argc = -argc;
8920 notext = 1;
8921 }
8922
8923 soptarg = arg_option(argc, argv, "-S2", "-s2", "[sorting key: 4 out of nRrAas]");
8924 if (soptarg != NULL)
8925 {
8926 argc -= 2;
8927 setnewweight(1, soptarg, "-s2");
8928 }
8929
8930 argc = single_option(argc, argv, "-S1", "-s1");
8931 if (argc < 0)
8932 { argc = -argc;
8933 if ( get_R_pg == BA_FALSE
8934 && get_A_pg == BA_FALSE
8935 && get_a_pg == BA_FALSE
8936 && get_r_pg == BA_FALSE
8937 )
8938 {
8939 EinlROEMseiten = 1;
8940 }
8941 else
8942 {
8943 announceexit("get opt -s1 *and* -s2");
8944 exit(1);
8945 }
8946 }
8947
8948 foptarg = arg_option(argc, argv, "-F2", "-f2", "[sorting key: 4 out of nRrAas]");
8949 if (foptarg != NULL)
8950 {
8951 argc -= 2;
8952 setnewweight(0, foptarg, "-f2");
8953 }
8954
8955 argc = single_option(argc, argv, "-F1", "-f1");
8956 if (argc < 0)
8957 { argc = -argc;
8958 if ( get_R_fn == BA_FALSE
8959 && get_A_fn == BA_FALSE
8960 && get_a_fn == BA_FALSE
8961 && get_r_fn == BA_FALSE
8962 )
8963 {
8964 ALPHmpfootnotes = 1;
8965 }
8966 else
8967 {
8968 announceexit("get opt -f1 *and* -f2");
8969 exit(1);
8970 }
8971 }
8972
8973 argc = single_option(argc, argv, "-i=j", "-I=J");
8974 if (argc < 0)
8975 { argc = -argc;
8976 igleichj = 1;
8977 }
8978
8979 argc = single_option(argc, argv, "-D", "-d");
8980 if (argc < 0)
8981 { argc = -argc;
8982 usedospath = 1;
8983 }
8984
8985 argc = single_option(argc, argv, "-K", "-k");
8986 if (argc < 0)
8987 { argc = -argc;
8988 kill = DOKILLAUTHORS;
8989 }
8990
8991 argc = single_option(argc, argv, "-E", "-e");
8992 if (argc < 0)
8993 { argc = -argc;
8994 ex_n = EXCHANGENAMES;
8995 }
8996
8997 argc = single_option(argc, argv, "-L", "-l");
8998 if (argc < 0)
8999 { argc = -argc;
9000 ignorespaces = 1;
9001 }
9002
9003 argc = single_option(argc, argv, "-H", "-h");
9004 if (argc < 0)
9005 { argc = -argc;
9006 hy_as_space = 1;
9007 }
9008
9009 argc = single_option(argc, argv, "-P", "-p");
9010 if (argc < 0)
9011 { argc = -argc;
9012 registpoints = 1;
9013 }
9014
9015
9016 argc = single_option(argc, argv, "-T1", "-t1");
9017 if (argc < 0)
9018 { argc = -argc;
9019 ++get_cp;
9020 encode = IS_TONE_ENC;
9021 }
9022
9023 /* utf8 new in 2.3 (begin with utf8enc.dfu 2021/01/27 v1.2l),
9024 changed in 2.4 (= changes from v1.2l to 2021/06/21 v1.2n),
9025 changed in 2.5 (= changes from v1.2n to 2022/06/07 v1.3c)
9026 */
9027 argc = single_option(argc, argv, "-utf8", "-UTF8");
9028 if (argc < 0)
9029 { argc = -argc;
9030 ++get_cp;
9031 encode = IS_UTFE_ENC;
9032 }
9033
9034 if (get_cp > 1)
9035 {
9036 announceexit("get opt -t1 *and* -utf8");
9037 exit(1);
9038 }
9039
9040
9041 argc = single_option(argc, argv, "-X", "-x");
9042 if (argc < 0)
9043 { argc = -argc;
9044 nogsty = 1;
9045 }
9046
9047 argc = single_option(argc, argv, "-M", "-m");
9048 if (argc < 0)
9049 { argc = -argc;
9050 printsort = 1;
9051 }
9052
9053
9054 argc = single_option(argc, argv, "-G1", "-g1");
9055 if (argc < 0)
9056 { argc = -argc;
9057 ++get_g;
9058 german = 1;
9059 }
9060
9061 argc = single_option(argc, argv, "-G2", "-g2");
9062 if (argc < 0)
9063 { argc = -argc;
9064 if (get_g == 0) german = 2;
9065 ++get_g;
9066 }
9067
9068 if (get_g > 1)
9069 {
9070 announceexit("get opt -g1 *and* -g2");
9071 exit(1);
9072 }
9073
9074
9075 argc = single_option(argc, argv, "-\?", "-h1"); /* 2.2: -h => hyphen */
9076 if (argc < 0)
9077 {
9078 argc = -argc;
9079 maininfo(argv[0]);
9080 announceexit("get your question for help");
9081 exit(1);
9082 }
9083
9084 argc = single_option(argc, argv, "-\?\?", "-h2"); /* 2.2: -hh => -h2 */
9085 if (argc < 0)
9086 {
9087 argc = -argc;
9088 moreinfo(argv[0]);
9089 announceexit("get your question for more help");
9090 exit(1);
9091 }
9092
9093 argc = single_option(argc, argv, "-\?\?\?", "-h3"); /* new in 2.3 */
9094 if (argc < 0)
9095 {
9096 argc = -argc;
9097 moremoreinfo(argv[0]);
9098 announceexit("get your question for more more help");
9099 exit(1);
9100 }
9101
9102 argc = single_option(argc, argv, "-R", "-r");
9103 if (argc < 0)
9104 {
9105 argc = -argc;
9106 licenseinfo();
9107 announceexit("get your question for license informations");
9108 exit(1);
9109 }
9110
9111 if (argc < 2)
9112 { if (argc == 1) maininfo(argv[0]);
9113 announceexit("get no <FileNamePrefix> of an auxiliary file");
9114 exit(1);
9115 }
9116
9117 arg_i = arg_option(argc, argv, "-I", "-i", "<InputFilenamePrefix>");
9118 if (arg_i != NULL)
9119 {
9120 argc -= 2;
9121 }
9122
9123 arg_o = arg_option(argc, argv, "-O", "-o", "<OutputFilenamesPrefix>");
9124 if (arg_o != NULL)
9125 {
9126 argc -= 2;
9127 }
9128
9129 if (argc != surp_option(argc, argv))
9130 {
9131 announceexit("get an unknown -[option]");
9132 exit(1);
9133 }
9134
9135
9136 if ( (argc == 2 && arg_i == NULL)
9137 || (argc == 1 && arg_i != NULL)
9138 )
9139 {
9140 if (argc == 2) { arg_i = argv[1]; --argc; }
9141 inname = makename(arg_i, AUX_SUFFIX);
9142 infile = fopen(inname, "r");
9143 }
9144 else
9145 { printf("%%%%\n%%%%> Error: Too many arguments:\n");
9146 print_arg_list(argv, argc);
9147 printf("%%%% Since vers 2.1, you have to use -o <OutputFileNamesPrefix>.\n");
9148 announceexit("get more than one file name in command line");
9149 exit(1);
9150 }
9151
9152 if (infile == NULL)
9153 {
9154 printf("%%%%\n%%%%> Error: No file \"%s\".\n", inname);
9155 openfailed(inname);
9156 announceexit("did not get the name of an existing file");
9157 exit(0); /* damit TeXnicCenter danach trotzdem LaTeX startet */
9158 }
9159
9160 if ((nlines = readlines(MAXFILES, 0, "\\@input")) == 0)
9161 {
9162 printf("%%%%> No \\@input cmds in \"%s\":\n", inname);
9163 filelist[0] = inname;
9164 filec = 1;
9165 }
9166 else
9167 if (nlines < 0)
9168 {
9169 printf("%%%%> Error: To many \\@input cmds in \"%s\".\n", inname);
9170 announceexit("can not handle such a big list of files");
9171 exit(1);
9172 }
9173 else
9174 {
9175 printf("%%%%> Try to work list of %d \\@input files in \"%s\":\n", nlines, inname);
9176 nlines = getfilenames(nlines, usedospath);
9177 if (nlines < 1)
9178 {
9179 announceexit("get a too big input file");
9180 exit(1);
9181 }
9182 filec = nlines;
9183 }
9184
9185 if (infile != NULL) fclose(infile);
9186
9187 printfilelist( stdout, filec, 0, "%% ", "");
9188
9189
9190
9191 /* changed in 2.2 => inner \\printonlyvli \\printonlyvqu */
9192 /* l = loeschen */
9193 /* e = entkernen */
9194 /* X = weder loeschen noch entkernen */
9195 /* "----" KHVONUM Positionen: \\onlykurz \\onlyhere \\onlyvoll \\onlyout [new in 2.5:] \\ktit <= X */
9196
9197 prepareoutput("%\\literentry", VLI_SUFFIX, VCOLS, VCOLS, filec, arg_i, arg_o, kill, "lleeX", IS_V, printsort);
9198 prepareoutput("%\\quellentry", VQU_SUFFIX, VCOLS, VCOLS, filec, arg_i, arg_o, kill, "lleeX", IS_V, printsort);
9199 prepareoutput("%\\vkcitentry", VKC_SUFFIX, KCOLS, KCOLS, filec, arg_i, arg_o, DOKILLK, "elleX", NO_V, printsort);
9200
9201 prepareoutput("%\\abkrzentry", ABK_SUFFIX, ACOLS, ACOLSSORT, filec, arg_i, arg_o, DOKILLABBREVS, "lleeX", NO_V, printsort);
9202 prepareoutput("%\\perioentry", PER_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "lleeX", NO_V, printsort);
9203 prepareoutput("%\\archqentry", ARQ_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "lleeX", IS_Q, printsort);
9204
9205 prepareoutput("%\\geogrentry", GRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "lleeX", NO_V, printsort);
9206 prepareoutput("%\\persrentry", PRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "lleeX", NO_V, printsort);
9207 prepareoutput("%\\subjrentry", SRR_SUFFIX, PCOLS, PCOLSSORT, filec, arg_i, arg_o, DOKILLREGISTS, "lleeX", NO_V, printsort);
9208
9209
9210
9211 if (encode == IS_BASE_ENC && lastupperascii < 0)
9212 {
9213 printf("%%%%\n%%%%> Default encoding: Gave ASCIIs > 127 like %d NO sorting weight.\n", ((unsigned char)lastupperascii));
9214 fprintf(stderr, "%%%% Did not evaluate your ASCIIs > 127. Start me using -utf8 or -t1 \?\n"); /* msg changed in 2.5 */
9215 printf("%%%% *******\n");
9216 }
9217
9218
9219 if (encode == IS_TONE_ENC && lastupperascii < 0)
9220 {
9221 printf("%%%%\n%%%%> -t1 : Sort ASCIIs > 127 (%d as %s etc.).\n", ((unsigned char)lastupperascii), getTONEenc(lastupperascii));
9222 fprintf(stderr, "%%%%> -t1 : \\UseRawInputEncoding expected.\n");
9223 }
9224
9225
9226 if (encode == IS_TONE_ENC && lastupperascii == 0)
9227 {
9228 no_upperascii_found_msg("-t1");
9229 }
9230
9231
9232 if (encode == IS_UTFE_ENC)
9233 {
9234 print_utf_msg(err_utf_eight, utf_err_c, "Invalid", "invalid", "found", "not interpret", "invalid", "Are you sure, that your text editor uses utf8 \?"); /* msg changed in 2.5 */
9235 print_utf_msg(emp_utf_eight, utf_emp_c, "Gave", "all your", "no sorting weight", "not know the meaning of", "unknown", "Better replace this sequence(s) by LaTeX-cmds in your text.");
9236 if (lastupperascii == 0) no_upperascii_found_msg("-utf8");
9237 }
9238
9239
9240 if (get_jobs == 0) printf("%%%%\n%%%%> Nothing to do!\n");
9241
9242
9243 return 0;
9244 }
9245
9246
9247 /*--------------------------------------------------------------------------*/
9248 /*--------------------------------------------------------------------------*/