w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

preamble.c
Go to the documentation of this file.
1 /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
2 /* From input file "preamble.pas" */
3 
4 
5 #include "p2c.h"
6 
7 
8 #define PREAMBLE_G
9 #include "preamble.h"
10 
11 
12 #ifndef CONTROL_H
13 #include "control.h"
14 #endif
15 
16 #ifndef MTXLINE_H
17 #include "mtxline.h"
18 #endif
19 
20 #ifndef STRINGS_H
21 #include "strings.h"
22 #endif
23 
24 #ifndef MULTFILE_H
25 #include "multfile.h"
26 #endif
27 
28 #ifndef FILES_H
29 #include "files.h"
30 #endif
31 
32 #ifndef STATUS_H
33 #include "status.h"
34 #endif
35 
36 #ifndef UTILITY_H
37 #include "utility.h"
38 #endif
39 
40 
41 #define blank_ ' '
42 #define colon_ ':'
43 #define semicolon ';'
44 #define comma_ ','
45 
46 #define max_styles 24
47 
48 
49 typedef enum {
54 
55 typedef enum {
58 
59 typedef char style_index;
60 
61 typedef char style_index0;
62 
63 
64 #define c1 title
65 #define cn start
66 
67 
68 Static short known_styles = 12;
69 Static boolean warn_redefine = false;
70 
71 Static Char commands[28][17] = {
72  "NONE", "TITLE", "COMPOSER", "PMX", "TEX", "OPTIONS", "SIZE", "BARS/LINE",
73  "SHORT", "STYLE", "SHARPS", "FLATS", "METER", "SPACE", "PAGES", "SYSTEMS",
74  "WIDTH", "HEIGHT", "ENABLE", "DISABLE", "RANGE", "NAME", "INDENT", "POET",
75  "PART", "ONLY", "OCTAVE", "START"
76 };
77 
78 /* short */
79 /* systems */
80 
81 Static Char cline[28][256] = {
82  "", "", "", "", "", "", "", "", "1/4", "", "0", "", "C", "", "1", "1",
83  "190mm", "260mm", "", "", "", "", "", "", "", "", "", ""
84 };
85 
86 Static boolean redefined[28] = {
87  false, false, false, false, false, false, false, false, false, false, false,
88  false, false, false, false, false, false, false, false, false, false, false,
89  false, false, false, false, false, false
90 };
91 
92 /** Known styles */
93 
95  "SATB: Voices S,A T,B; Choral; Clefs G F",
96  "SATB4: Voices S A T B; Choral; Clefs G G G8 F",
97  "SINGER: Voices Voice; Vocal; Clefs G",
98  "PIANO: Voices RH LH; Continuo; Clefs G F",
99  "ORGAN: Voices RH LH Ped; Continuo; Clefs G F F",
100  "SOLO: Voices V; Clefs G", "DUET: Voices V1 Vc; Clefs G F",
101  "TRIO: Voices V1 Va Vc; Clefs G C F",
102  "QUARTET: Voices V1 V2 Va Vc; Clefs G G C F",
103  "QUINTET: Voices V1 V2 Va Vc1 Vc2; Clefs G G C F F",
104  "SEXTET: Voices V1 V2 Va1 Va2 Vc1 Vc2; Clefs G G C C F F",
105  "SEPTET: Voices V1 V2 Va1 Va2 Vc1 Vc2 Cb; Clefs G G C C F F F", "", "", "",
106  "", "", "", "", "", "", "", "", ""
107 };
108 
114 
117  pmx_line[256], options_line[256], start_line[256], voices[256],
118  clefs[256];
122 
123 
124 /* ------------------ Styles ------------------ */
125 
127 {
128  Char s[256];
129  short i, l;
130 
131  strcpy(s, s_);
132  l = strlen(s);
133  for (i = 0; i <= l - 1; i++) {
134  if (s[i] == comma_)
135  s[i] = blank_;
136  }
137  return (wordCount(s));
138 }
139 
140 
142 {
143  style_index0 Result = 0;
144  Char s[256];
145  style_index0 i = 0;
146 
147  strcpy(s, s_);
148  sprintf(s + strlen(s), "%c", colon_);
149  while (i < known_styles) {
150  i++;
152  return i;
153  }
154  return Result;
155 }
156 
157 
159 {
160  style_index0 sn;
161  Char STR1[256];
162 
163  sn = findStyle(NextWord(STR1, S, colon_, dummy));
164  if (sn > 0) {
165  strcpy(known_style[sn-1], S);
166  return;
167  }
168  if (known_styles < max_styles) {
169  known_styles++;
171  } else
172  error("Can't add another style - table full", print);
173 }
174 
175 
176 Static void readStyles(void)
177 {
178  boolean eofstyle;
179  Char S[256];
180  style_index0 l = 0;
181  Char *TEMP;
182 
183  if (styleFileFound())
184  eofstyle = true;
185  else
186  eofstyle = P_eof(stylefile);
187  while (!eofstyle) {
188  fgets(S, 256, stylefile);
189  TEMP = strchr(S, '\n');
190  if (TEMP != NULL)
191  *TEMP = 0;
192  if (*S != '\0') {
193  addStyle(S);
194  l++;
196  }
197  eofstyle = P_eof(stylefile);
198  }
199 }
200 
201 
202 Static void applyStyle(Char *s_, Char *stylename, stave_index first_inst,
203  stave_index first_stave)
204 {
205  Char s[256];
206  Char clef[256], subline[256], subcommand[256];
207  stave_index0 i, last_inst, last_stave;
208  boolean continuo = false, toosoon = false, vocal = false;
209  Char STR2[256];
210 
211  strcpy(s, s_);
212  last_inst = first_inst - 1;
213  GetNextWord(subline, s, blank_, colon_);
214  while (*s != '\0') {
215  GetNextWord(subline, s, semicolon, dummy);
216  i = curtail(subline, semicolon);
217  GetNextWord(subcommand, subline, blank_, dummy);
218  if (equalsIgnoreCase(subcommand, "VOICES")) {
219  sprintf(voices + strlen(voices), " %s", subline);
220  last_stave = first_stave + wordCount(subline) - 1;
221  last_inst = first_inst + voiceCount(subline) - 1;
222  } else if (equalsIgnoreCase(subcommand, "CLEFS")) {
223  strcpy(clef, subline);
224  sprintf(clefs + strlen(clefs), " %s", clef);
225  } else if (equalsIgnoreCase(subcommand, "VOCAL")) {
226  if (last_inst < first_inst)
227  toosoon = true;
228  else {
229  some_vocal = true;
230  vocal = true;
231  for (i = first_inst; i <= last_inst; i++)
232  setVocal(i, true);
233  }
234  } else if (equalsIgnoreCase(subcommand, "CHORAL") ||
235  equalsIgnoreCase(subcommand, "GROUP")) {
236  if (last_inst < first_inst)
237  toosoon = true;
238  else {
239  if (equalsIgnoreCase(subcommand, "CHORAL")) {
240  some_vocal = true;
241  vocal = true;
242  for (i = first_inst; i <= last_inst; i++)
243  setVocal(i, true);
244  }
245  if (ngroups == maxgroups)
246  error("Too many groups", print);
247  else {
248  ngroups++;
249  group_start[ngroups-1] = first_stave;
250  group_stop[ngroups-1] = last_stave;
251  }
252  }
253  } else if (equalsIgnoreCase(subcommand, "CONTINUO"))
254  continuo = true;
255  else {
256  sprintf(STR2, "Subcommand %s in STYLE unknown", subcommand);
257  error(STR2, print);
258  }
259  if (toosoon) {
260  sprintf(STR2, "You must first give VOICES before specifying %s",
261  subcommand);
262  error(STR2, print);
263  }
264  }
265  if (vocal && continuo)
266  error("A continuo instrument may not be vocal", print);
267  if (wordCount(clef) != last_stave - first_stave + 1)
268  error("Number of clefs does not match number of voices", print);
269  if (first_stave == last_stave || continuo) {
270  strcpy(instr_name[first_stave-1], stylename);
271 /* p2c: preamble.pas, line 185:
272  * Note: Possible string truncation in assignment [145] */
273  } else {
274  for (i = first_stave - 1; i <= last_stave - 1; i++)
275  *instr_name[i] = '\0';
276  }
277  if (continuo) {
278  ninstr++;
279  stave[ninstr-1] = first_stave;
280  for (i = first_stave - 1; i <= last_stave - 1; i++)
281  instr[i] = ninstr;
282  return;
283  }
284  for (i = first_stave; i <= last_stave; i++) {
285  ninstr++;
286  stave[ninstr-1] = i;
287  instr[i-1] = ninstr;
288  }
289 }
290 
291 
292 Static void applyStyles(void)
293 {
294  short n1, n2, sn;
295  Char s[256];
296  Char STR2[256];
297 
298  *voices = '\0';
299  *clefs = '\0';
300  ninstr = 0;
301  while (*cline[(long)style] != '\0') {
302  n1 = voiceCount(voices) + 1;
303  n2 = wordCount(voices) + 1;
304  GetNextWord(s, cline[(long)style], blank_, comma_);
305  curtail(s, comma_);
306  sn = findStyle(s);
307  if (sn == 0) {
308  sprintf(STR2, "Style %s unknown", s);
309  error(STR2, print);
310  }
311  line_no = orig_style_line[sn-1];
312  applyStyle(known_style[sn-1], s, n1, n2);
313  style_used[sn-1] = true;
314  }
315 }
316 
317 
318 /* ------------------------------------------------------------- */
319 
321 {
322  command_type c;
323 
324  for (c = c1; c <= cn; c = (command_type)((long)c + 1))
325  *cline[(long)c] = '\0';
326 }
327 
328 
330 {
331  return (line > 0 && omit_line[line-1]);
332 }
333 
334 
335 Static void setName(void)
336 {
337  short i, FORLIM;
338 
339  if (!redefined[(long)name])
340  return;
341  setFeature("instrumentNames", true);
342  FORLIM = ninstr;
343  for (i = 0; i <= FORLIM - 1; i++) {
345 /* p2c: preamble.pas, line 226:
346  * Note: Possible string truncation in assignment [145] */
347  }
348 }
349 
350 
351 Static void setIndent(void)
352 {
353  if (redefined[(long)indent])
354  strcpy(fracindent, cline[(long)indent]);
355 }
356 
357 
359 {
360  if (redefined[(long)octave_])
361  initOctaves(cline[(long)octave_]);
362 }
363 
364 
366 {
367  voice_index j, FORLIM;
368  Char STR1[256], STR2[256];
369 
370  FORLIM = nvoices;
371  for (j = 0; j <= FORLIM - 1; j++) {
372  if (!strcmp(w, voice_label[j])) {
373  sprintf(STR2, "Voice label %s not unique", w);
374  warning(STR2, print);
375  return;
376  }
377  }
378  if (strlen(w) > 2)
379  return;
380  if (pos1(w[0], "CLU") > 0) {
381  if (strlen(w) > 1) {
382  if (pos1(w[1], "123456789") == 0)
383  return;
384  }
385  } else if (pos1(w[0], "123456789") == 0)
386  return;
387  sprintf(STR1, "Voice label %s conflicts with reserved label", w);
388  error(STR1, print);
389 }
390 
391 
393 {
394  short k;
395  Char s[256], w[256];
396  Char STR1[256];
397  short FORLIM;
398 
399  nvoices = 0;
400  nstaves = 0;
401  do {
403  if (*s != '\0') {
404  nstaves++;
405  k = 0;
406  first_on_stave[nstaves-1] = nvoices + 1;
407  do {
409  curtail(w, comma_);
410  if (*w != '\0') {
411  k++;
412  if (k <= 2) {
413  nvoices++;
414  checkLabel(w);
416  if (*instr_name[nstaves-1] == '\0') {
417  strcpy(instr_name[nstaves-1], w);
418 /* p2c: preamble.pas, line 266:
419  * Note: Possible string truncation in assignment [145] */
420  }
422  }
423  }
424  } while (*w != '\0');
425  if (k > 2) {
426  sprintf(STR1, "More than two voices per stave: %s", s);
427  error(STR1, print);
428  }
429  if (k == 2) {
430  sprintf(instr_name[nstaves-1], "\\mtxTwoInstruments{%s}{%s}",
432 /* p2c: preamble.pas, line 273:
433  * Note: Possible string truncation in assignment [145] */
434  }
436  }
437  } while (*line != '\0');
438  FORLIM = nvoices;
439  for (k = 0; k <= FORLIM - 1; k++)
440  selected[k] = true;
441 }
442 
443 
444 Static void setClefs(Char *line_)
445 {
446  Char line[256];
447  Char s[256];
448 
449  strcpy(line, line_);
450  nclefs = 0;
451  do {
453  if (*s != '\0') {
454  nclefs++;
455  if (strlen(s) == 1)
456  clef[nclefs-1] = s[0];
457  else
458  clef[nclefs-1] = s[1];
459  }
460  } while (*s != '\0');
461 }
462 
463 
465 {
466  Char line[256];
467  short l;
468  short n = 0, p = 0;
469  Char STR1[256];
470 
471  strcpy(line, line_);
472  if (*line == '\0')
473  return;
474  l = strlen(line);
475  do {
476  n++;
477  if (line[n-1] == '.')
478  p++;
479  } while (n <= l && (line[n-1] == '.' || isdigit(line[n-1])));
480  if (n == p || p > 1 ||
481  line[n-1] != 'i' && line[n-1] != 'm' && line[n-1] != 'p')
482  error("Dimension must be a number followed by in, mm or pt", print);
483  sprintf(cline[(long)lno], "w%s", substr_(STR1, line, 1, n));
484 }
485 
486 
487 Static void setSize(Char *line_)
488 {
489  Char line[256];
490  stave_index0 i = 0;
491  Char word[256];
492  stave_index0 FORLIM;
493 
494  strcpy(line, line_);
495  while (i < ninstr) {
497  if (*word == '\0')
498  break;
499  i++;
500  getNum(word, &musicsize);
501  stave_size[i-1] = musicsize;
502  }
503  if ((unsigned)musicsize >= 32 || ((1L << musicsize) & 0x110000L) == 0) {
504  FORLIM = ninstr;
505  for (i = 0; i <= FORLIM - 1; i++) {
506  if (stave_size[i] == unspec)
508  }
509  }
510  if (musicsize < 16)
511  musicsize = 16;
512  else if (musicsize > 20)
513  musicsize = 20;
514 }
515 
516 
518 {
519  command_type j;
520 
521  curtail(command, ':');
522  if (equalsIgnoreCase(command, "STYLE"))
523  style_supplied = true;
524  for (j = c1; j <= cn; j = (command_type)((long)j + 1)) {
525  if (equalsIgnoreCase(command, commands[(long)j]))
526  return j;
527  }
528  return none;
529 }
530 
531 
532 boolean isCommand(Char *command_)
533 {
534  Char command[256];
535 
536  strcpy(command, command_);
537  return (findCommand(command) != none);
538 }
539 
540 
542 {
543  return (command == tex);
544 }
545 
546 
547 Static void doEnable(Char *line, boolean choice)
548 {
549  Char word[256];
550  Char STR1[256];
551 
552  do {
554  if (*word != '\0') {
555  if (!setFeature(word, choice)) {
556  sprintf(STR1, "No such feature: %s", word);
557  error(STR1, !print);
558  }
559  }
560  } while (*word != '\0');
561 }
562 
563 
564 Static void setRange(Char *line_)
565 {
566  Char line[256];
567  short v, p;
568  Char vl[256];
569  short FORLIM;
570  Char STR1[256], STR2[256];
571 
572  strcpy(line, line_);
574  FORLIM = nvoices;
575  for (v = 1; v <= FORLIM; v++) {
576  strcpy(vl, voice_label[v-1]);
577  sprintf(STR1, "%s=", vl);
578  p = strpos2(line, STR1, 1);
579  if (p > 0) {
580  if (strlen(line) < p + 6) {
581  sprintf(STR2, "At least five characters must follow \"%s=\"", vl);
582  error(STR2, print);
583  }
584  defineRange(v, substr_(STR2, line, p + strlen(vl) + 1, 5));
585  } else {
586  sprintf(STR2, "No range defined for voice %s", vl);
587  warning(STR2, print);
588  defineRange(v, "");
589  }
590  }
591 }
592 
593 
594 /* TODO: This procedure should test for assertions in a comment
595  or be removed */
597 {
598  return false;
599 }
600 
601 
603 {
604  line_type Result;
605  Char line[256];
606  Char command[256];
607  command_type last_command;
608  boolean starts_with_note;
609  Char STR1[256];
610  Char STR3[70];
611  Char STR4[256];
612 
613  strcpy(line, line_);
614  if (line[0] == comment && !isAssertion(line))
615  return comment_line;
616  starts_with_note = maybeMusicLine(line);
618  sprintf(STR1, "%c", colon_);
619  if (endsWith(command, STR1)) {
620  last_command = findCommand(command);
621  Result = command_line;
622  if (last_command == enable)
623  doEnable(line, true);
624  else if (last_command == disable)
625  doEnable(line, false);
626  else if (last_command == range)
628  if (last_command != none) {
629  if (mustAppend(last_command) && redefined[(long)last_command]) {
630  if (strlen(cline[(long)last_command]) + strlen(line) > 254) {
631  sprintf(STR3,
632  "Total length of preamble command %s must not exceed 255",
633  commands[(long)last_command]);
634  error(STR3, !print);
635  }
636  sprintf(cline[(long)last_command] + strlen(cline[(long)last_command]),
637  "\n%s", line);
638  } else {
639  strcpy(cline[(long)last_command], line);
640  if (warn_redefine && redefined[(long)last_command]) {
641  sprintf(STR4, "You have redefined preamble command %s", command);
642  warning(STR4, print);
643  }
644  }
645  if (last_command == start)
647  redefined[(long)last_command] = true;
648  return Result;
649  }
650  Result = colon_line;
651  sprintf(STR4, "%s%c %s", command, colon_, line);
652  addStyle(STR4);
654  return Result;
655  } else if (starts_with_note)
656  return plain_line;
657  else
658  return unknown;
659  return Result;
660 }
661 
662 
663 void setOnly(Char *line_)
664 {
665  Char line[256];
666  short num, num1, num2, l;
667  Char s[256];
668  Char STR1[256];
669 
670  strcpy(line, line_);
671  if (*line == '\0')
672  return;
673  if (startsWithIgnoreCase(line, "only"))
674  GetNextWord(STR1, line, colon_, dummy);
675  for (l = 0; l <= lines_in_paragraph - 1; l++)
676  omit_line[l] = true;
677  do {
679  if (*s == '\0')
680  return;
681  curtail(s, comma_);
682  if (pos1('-', s) == 0) {
683  getNum(s, &num);
684  if (num > 0 && num <= lines_in_paragraph)
685  omit_line[num-1] = false;
686  else
687  warning("Invalid line number in Only: is skipped", print);
688  } else {
689  getTwoNums(s, &num1, &num2);
690  if (num1 > 0 && num2 <= lines_in_paragraph) {
691  for (num = num1 - 1; num <= num2 - 1; num++)
692  omit_line[num] = false;
693  } else
694  warning("Invalid line range in Only: is skipped", print);
695  }
696  } while (true);
697 }
698 
699 
701 {
702  short i, num, den, nbars;
703  Char STR2[256];
704  short FORLIM;
705 
706  strcpy(title_line, cline[(long)title]);
707  strcpy(part_line, cline[(long)part]);
708  if (*cline[(long)poet] != '\0' || *cline[(long)composer] != '\0')
709  sprintf(composer_line, "\\mtxComposerLine{%s}{%s}",
710  cline[(long)poet], cline[(long)composer]);
711  else
712  *composer_line = '\0';
713  strcpy(pmx_line, cline[(long)pmx]);
715  FORLIM = known_styles;
716  for (i = 0; i <= FORLIM - 1; i++)
717  style_used[i] = false;
718  applyStyles();
719  setVoices(voices);
720  FORLIM = known_styles;
721  for (i = old_known_styles; i <= FORLIM - 1; i++) {
722  if (!style_used[i]) {
723  warning("The following style was supplied but not used", !print);
724  puts(known_style[i]);
725  }
726  }
727  setClefs(clefs);
728  if (!redefined[(long)meter]) {
729  sprintf(STR2, "You have not defined Meter, assuming \"%s\" ",
730  cline[(long)meter]);
731  warning(STR2, !print);
732  }
735  if (meternum == 0 &&
736  !(redefined[(long)pages] || redefined[(long)systems] ||
737  redefined[(long)bars])) {
738  strcpy(cline[(long)bars], "1");
739  redefined[(long)bars] = true;
740  }
741  if (redefined[(long)pages] || redefined[(long)systems]) {
742  if (redefined[(long)bars])
743  warning("BARS/LINE ignored since you specified PAGES or SYSTEMS", print);
744  if (redefined[(long)systems])
745  getNum(cline[(long)systems], &n_systems);
746  else
747  warning("PAGES specified but not SYSTEMS", !print);
748  if (redefined[(long)pages])
749  getNum(cline[(long)pages], &n_pages);
750  else
751  warning("SYSTEMS specified but not PAGES", !print);
752  } else if (redefined[(long)bars]) {
753  getNum(cline[(long)bars], &nbars);
754  if (nbars > 0) {
755  n_pages = 0;
756  n_systems = nbars;
757  }
758  }
759  getNum(cline[(long)sharps], &n_sharps);
760  setSpace(cline[(long)space]);
761  setSize(cline[(long)msize]);
762  getTwoNums(cline[(long)shortnote], &num, &den);
763  if (den == 0)
764  den = 1;
765  short_note = num * 64 / den;
766  if (*cline[(long)flats] != '\0') {
767  getNum(cline[(long)flats], &n_sharps);
768  n_sharps = -n_sharps;
769  }
770  setName();
771  setIndent();
772  setInitOctave();
773  setOnly(cline[(long)only]);
774  setRange(cline[(long)range]);
775  setDimension(cline[(long)width], width);
776  setDimension(cline[(long)height], height);
777  if (*options_line != '\0') {
778  warning("\"Options\" is cryptic and obsolescent.", !print);
779  printf(" Use \"Enable\" and \"Disable\" instead.\n");
780  }
781  FORLIM = strlen(options_line);
782  for (i = 0; i <= FORLIM - 1; i++)
784 }
785 
786 
788 {
789  short i;
790 
791  xmtrnum0 = 0.0;
792  strcpy(fracindent, "0");
793  musicsize = 20;
794  *start_line = '\0';
795  some_vocal = false;
796  ngroups = 0;
797  style_supplied = false;
798  for (i = 1; i <= maxvoices; i++)
799  setVocal(i, false);
800  for (i = 0; i <= maxstaves - 1; i++)
801  stave_size[i] = unspec;
802  for (i = 0; i <= maxstaves; i++)
803  nspace[i] = unspec;
804  /* next line seems to be spurious. 0.63a RDT */
805  /* begin nspace[i]:=unspec; stave_size[i]:=unspec; end; */
806  n_pages = 1;
807  n_systems = 1;
808  readStyles();
810  for (i = 0; i <= lines_in_paragraph - 1; i++)
811  omit_line[i] = false;
812 }
813 
814 
815 Static void preambleGuess(voice_index maybe_voices)
816 {
817  switch (maybe_voices) {
818 
819  case 1:
820  strcpy(cline[(long)style], "Solo");
821  break;
822 
823  case 2:
824  strcpy(cline[(long)style], "Duet");
825  break;
826 
827  case 3:
828  strcpy(cline[(long)style], "Trio");
829  break;
830 
831  case 4:
832  strcpy(cline[(long)style], "Quartet");
833  break;
834 
835  case 5:
836  strcpy(cline[(long)style], "Quintet");
837  break;
838 
839  case 6:
840  strcpy(cline[(long)style], "Sextet");
841  break;
842 
843  case 7:
844  strcpy(cline[(long)style], "Septet");
845  break;
846 
847  default:
848  error("I cannot guess a style", !print);
849  return;
850  break;
851  }
852  printf("I guess this piece is a %s for strings in C major.\n",
853  cline[(long)style]);
854  printf(" Why not provide a STYLE in the setup paragraph to make sure?\n");
855 }
856 
857 
858 /* ------------------------------------------------------------------ */
859 
860 void nonMusic(void)
861 {
862  paragraph_index i, FORLIM;
863 
864  FORLIM = para_len;
865  for (i = 0; i <= FORLIM - 1; i++)
866  doCommand(P[i]);
867  setOnly(cline[(long)only]);
868  wipeCommands();
869 }
870 
871 
872 boolean thisCase(void)
873 {
874  boolean Result;
875 
876 /* p2c: preamble.pas: Note: Eliminated unused assignment statement [338] */
877  if (!startsWithIgnoreCase(P[0], "case:"))
878  return true;
879  Result = (choice != ' ' && pos1(choice, P[0]) > 0);
880  strcpy(P[0], "%");
881  return Result;
882 }
883 
884 
885 void augmentPreamble(boolean control_para)
886 {
888  line_type l;
889  short s[5];
890  paragraph_index FORLIM;
891 
892  if (!thisCase())
893  return;
894  for (l = unknown; l <= plain_line; l = (line_type)((long)l + 1))
895  s[(long)l] = 0;
896  FORLIM = para_len;
897  for (i = 0; i <= FORLIM - 1; i++) {
899  l = doCommand(P[i]);
900  s[(long)l]++;
901  if (l == comment_line && P[i][1] == comment) {
902  predelete(P[i], 2);
903  putLine(P[i]);
904  }
905  if (!control_para && l == unknown)
906  error("Unidentifiable line", print);
907  }
908  if (!control_para && s[(long)command_line] > 0 && s[(long)plain_line] > 0)
909  error("Mixture of preamble commands and music", !print);
910 }
911 
912 
913 void doPreamble(void)
914 {
916  voice_index0 maybe_voices = 0;
917  paragraph_index FORLIM;
918 
919  if (style_supplied) /*augmentPreamble(not known);*/
920  return;
921  if (true)
922  warning("No STYLE supplied", !print);
923  FORLIM = para_len;
924  for (i = 0; i <= FORLIM - 1; i++) {
925  if (maybeMusicLine(P[i]))
926  maybe_voices++;
927  }
928  if (maybe_voices > 0)
929  preambleGuess(maybe_voices);
930  else
931  error("No voices found", !print);
932 }
933 
934 
935 void respace(void)
936 {
937  stave_index i, j;
938  Char STR1[256];
939  Char STR2[256], STR3[256];
940 
941  for (i = ninstr; i >= 2; i--) {
942  j = ninstr - i + 1;
943  if (nspace[j] != unspec) {
944  sprintf(STR3, "\\mtxInterInstrument{%s}{%s}",
945  toString(STR1, i - 1), toString(STR2, nspace[j]));
946  TeXtype2(STR3);
947  }
948  }
949  if (nspace[ninstr] != unspec) {
950  sprintf(STR3, "\\mtxStaffBottom{%s}", toString(STR1, nspace[ninstr]));
951  TeXtype2(STR3);
952  }
953  must_respace = false;
954 }
955 
956 
957 void restyle(void)
958 {
959  must_restyle = false;
960 }
961 
962 
963 Static short clefno(Char cl)
964 {
965  short Result;
966  Char STR2[44];
967 
968  switch (cl) {
969 
970  case 'G':
971  case '0':
972  case 't':
973  case '8':
974  Result = 0;
975  break;
976 
977  case 's':
978  case '1':
979  Result = 1;
980  break;
981 
982  case 'm':
983  case '2':
984  Result = 2;
985  break;
986 
987  case 'a':
988  case '3':
989  Result = 3;
990  break;
991 
992  case 'n':
993  case '4':
994  Result = 4;
995  break;
996 
997  case 'r':
998  case '5':
999  Result = 5;
1000  break;
1001 
1002  case 'F':
1003  case 'b':
1004  case '6':
1005  Result = 6;
1006  break;
1007 
1008  case 'C':
1009  Result = 3;
1010  break;
1011 
1012  default:
1013  sprintf(STR2, "Unknown clef code \"%c\" - replaced by treble", cl);
1014  warning(STR2, print);
1015  Result = 0;
1016  break;
1017  }
1018  return Result;
1019 }
1020 
1021 
1023 {
1024  voice_index i;
1025  Char c;
1026  voice_index FORLIM;
1027  Char STR1[256];
1028  Char STR3[256];
1029 
1030  FORLIM = nclefs;
1031  for (i = 1; i <= FORLIM; i++) {
1032  c = clef[i-1];
1033  if (c == '8' || c == 't') {
1034  sprintf(STR3, "\\\\mtxTenorClef{%s}\\", toString(STR1, PMXinstr(i)));
1035  putLine(STR3);
1036  }
1037  }
1038 }
1039 
1040 
1041 Static void insertTeX(void)
1042 {
1043  if (redefined[(long)tex])
1044  TeXtype2(cline[(long)tex]);
1045 }
1046 
1047 
1049 {
1050  short denom, num;
1051  Char STR1[256], STR3[256], STR4[256], STR5[256];
1052 
1053  if (meternum == 0) {
1054  num = beatsPerLine(); /** denom := 0; **/
1056  } else
1057  num = meternum; /** denom := pmdenom; **/
1058  /* CMO: unconditonally assign value of pmdenom to denom */
1059  denom = pmdenom;
1060  sprintf(Result, "%s %s %s %s",
1061  toString(STR1, num), toString(STR3, PMXmeterdenom(meterdenom)),
1062  toString(STR4, pmnum), toString(STR5, denom));
1063  return Result;
1064 }
1065 
1066 Local Char *sizecode(Char *Result, short k)
1067 {
1068  strcpy(Result, "\\mtxNormalSize");
1069  switch (k) {
1070 
1071  case 13:
1072  if (musicsize == 20)
1073  strcpy(Result, "\\mtxTinySize");
1074  else
1075  strcpy(Result, "\\mtxSmallSize");
1076  break;
1077 
1078  case 16:
1079  if (musicsize == 20)
1080  strcpy(Result, "\\mtxSmallSize");
1081  break;
1082 
1083  case 20:
1084  if (musicsize == 16)
1085  strcpy(Result, "\\mtxLargeSize");
1086  break;
1087 
1088  case 24:
1089  if (musicsize == 20)
1090  strcpy(Result, "\\mtxLargeSize");
1091  else
1092  strcpy(Result, "\\mtxHugeSize");
1093  break;
1094 
1095  case 29:
1096  strcpy(Result, "\\mtxHugeSize");
1097  break;
1098 
1099  default:
1100  error("Valid sizes are 13, 16, 20, 24, 29", print);
1101  break;
1102  }
1103  return Result;
1104 }
1105 
1106 
1107 void doPMXpreamble(void)
1108 {
1109  static Char clefcode[9] = "0123456";
1110  short i, j;
1111  Char clefs[256];
1112  Char STR1[256], STR2[256];
1113  Char STR3[58];
1114  short FORLIM;
1115  Char STR5[256];
1116 
1117  if (*composer_line != '\0')
1119  if (*title_line != '\0') {
1120  sprintf(STR2, "\\mtxTitleLine{%s}", title_line);
1121  putLine(STR2);
1122  }
1123  putLine("---");
1124  if (instrumentNames() && !redefined[(long)indent])
1125  strcpy(fracindent, "0.12");
1126  fprintf(outfile, "%d", nstaves);
1127  fprintf(outfile, " %d", -ninstr);
1128  stave[ninstr] = nstaves + 1;
1129  for (j = ninstr; j >= 1; j--)
1130  fprintf(outfile, " %d", stave[j] - stave[j-1]);
1131  fprintf(outfile, " %s %8.5f %d %d %d %d %s\n",
1133  fracindent);
1134  FORLIM = ninstr;
1135  for (i = 1; i <= FORLIM; i++) {
1136  if (!instrumentNames())
1137  putLine("");
1138  else {
1139  sprintf(STR3, "\\mtxInstrName{%s}", instr_name[ninstr - i]);
1140  putLine(STR3);
1141  }
1142  }
1143  *clefs = '\0';
1144  for (i = nclefs - 1; i >= 0; i--)
1145  sprintf(clefs + strlen(clefs), "%c", clefcode[clefno(clef[i])]);
1146  putLine(clefs);
1147  if (*texdir == '\0')
1148  strcpy(texdir, "./");
1149  putLine(texdir);
1150 
1151  pmx_preamble_done = true;
1152  insertTeX();
1153  respace();
1154 
1155  FORLIM = ngroups;
1156  for (j = 1; j <= FORLIM; j++)
1157  fprintf(outfile, "\\\\mtxGroup{%s}{%s}{%s}\\\n",
1158  toString(STR1, j), toString(STR2, ninstr - group_start[j-1] + 1),
1159  toString(STR5, ninstr - group_stop[j-1] + 1));
1160  FORLIM = ninstr;
1161  for (j = 1; j <= FORLIM; j++) {
1162  if (stave_size[j-1] != unspec) {
1163  sprintf(STR5, "\\\\mtxSetSize{%s}{%s}\\",
1164  toString(STR1, ninstr - j + 1),
1165  sizecode(STR2, stave_size[j-1]));
1166  putLine(STR5);
1167  }
1168  }
1169  if (*part_line != '\0') {
1170  putLine("Ti");
1171  putLine(part_line);
1172  }
1173  if (*composer_line != '\0') {
1174  putLine("Tc");
1175  putLine("\\mtxPoetComposer");
1176  }
1177  if (*title_line != '\0') {
1178  fprintf(outfile, "Tt");
1179  if (nspace[0] != unspec)
1180  fputs(toString(STR1, nspace[0]), outfile);
1181  putc('\n', outfile);
1182  putLine("\\mtxTitle");
1183  }
1184  if (*pmx_line != '\0')
1185  putLine(pmx_line);
1186  doTenorClefs();
1187  if (*cline[(long)width] != '\0')
1188  putLine(cline[(long)width]);
1189  wipeCommands();
1190 }
1191 
1192 
1194 {
1195  Char s[256], w[256];
1196  voice_index j;
1197 
1198  strcpy(s, start_line);
1199  for (j = 1; j <= voice; j++)
1200  GetNextWord(w, s, dummy, ';');
1201  curtail(w, ';');
1202  if (*w != '\0') {
1203  sprintf(Result, "%s ", w);
1204  return Result;
1205  } else
1206  return strcpy(Result, w);
1207 }
1208 
1209 
1210 
1211 
1212 /* End. */
#define num1(a)
#define num2(a)
char * substr_(char *Result, char *s, short start, short count)
Definition: cfuncs.c:83
short strpos2(char *s1, char *s2, short p)
Definition: cfuncs.c:91
int P_eof(FILE *infile)
Definition: cfuncs.c:14
void predelete(char *s, short l)
Definition: cfuncs.c:40
void getNum(char *line, short *k)
Definition: cfuncs.c:57
short pos1(char c, char *s)
Definition: cfuncs.c:30
void getTwoNums(char *line, short *k1, short *k2)
Definition: cfuncs.c:63
#define Local
Definition: cfuncs.h:10
#define Static
Definition: cfuncs.h:9
#define n
Definition: t4ht.c:1290
boolean setFeature(char *which, boolean val)
Definition: control.c:105
boolean instrumentNames(void)
Definition: control.c:188
int dummy
Definition: dummy.c:29
int w
Definition: dviconv.c:26
int v
Definition: dviconv.c:10
#define fgets
Definition: xxstdio.h:29
int strcmp()
Definition: coll.cpp:143
int printf()
char * strcpy()
#define error(a)
Definition: dviinfo.c:48
boolean styleFileFound(void)
Definition: files.c:112
void processOption(char j)
Definition: files.c:152
void putLine(char *line)
Definition: files.c:81
void TeXtype2(char *s)
Definition: files.c:60
static int voice
#define s
Definition: afcover.h:80
char * meterChange(char *Result, short n1, short n2, boolean blind)
Definition: globals.c:70
short PMXinstr(short stave)
Definition: globals.c:262
void getMeter(char *line_, short *meternum, short *meterdenom, short *pmnum, short *pmdenom)
Definition: globals.c:163
char choice
Definition: globals.c:17
char old_meter_word[256]
Definition: globals.c:20
void setDefaultDuration(short meterdenom)
Definition: globals.c:268
char texdir[256]
Definition: globals.c:19
short PMXmeterdenom(short denom)
Definition: globals.c:303
void setSpace(char *line_)
Definition: globals.c:88
paragraph_index0 para_len
#define maxgroups
Definition: globals.h:35
boolean pmx_preamble_done
boolean must_respace
Definition: globals.h:127
char stave_index0
Definition: globals.h:90
voice_index0 stave[15]
Definition: globals.h:110
#define maxstaves
Definition: globals.h:33
short pmnum
Definition: globals.h:116
boolean must_restyle
Definition: globals.h:127
char stave_index
Definition: globals.h:80
short short_note
Definition: globals.h:115
FILE * stylefile
Definition: globals.h:122
double xmtrnum0
Char voice_label[15][256]
short line_no
Definition: globals.h:115
char voice_index
Definition: globals.h:78
short meternum
Definition: globals.h:115
paragraph P
voice_index0 nstaves
Definition: globals.h:114
boolean some_vocal
Definition: globals.h:127
voice_index0 first_on_stave[15]
Definition: globals.h:111
short musicsize
Definition: globals.h:115
short meterdenom
Definition: globals.h:116
short nbars
Definition: globals.h:116
line_nos orig_line_no
char paragraph_index
Definition: globals.h:76
#define unspec
Definition: globals.h:41
voice_index0 instr[15]
voice_index0 number_on_stave[15]
Definition: globals.h:111
char voice_index0
Definition: globals.h:88
Char fracindent[256]
Definition: pmxab.c:137
Char clef[15]
short pmdenom
Definition: globals.h:116
#define lines_in_paragraph
Definition: globals.h:24
short stave_size[15]
short nspace[15+1]
voice_index0 nvoices
#define maxvoices
Definition: globals.h:34
#define c(n)
Definition: gpos-common.c:150
#define strchr
Definition: gsftopk.c:59
char comment[255+1]
Definition: hbf2gf.c:350
#define putc
Definition: jbib.h:20
static FILE * outfile
Definition: wrjpgcom.c:80
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
void warning(char msg[])
Definition: utils.c:72
int den
Definition: dvi.c:19
int num
Definition: disdvi.c:621
#define fputs
Definition: mendex.h:67
#define fprintf
Definition: mendex.h:64
#define sprintf
Definition: snprintf.c:44
#define isdigit(c)
Definition: snprintf.c:177
boolean maybeMusicLine(char *l_)
Definition: mtxline.c:452
void setStavePos(voice_index voice, stave_index stave, stave_index pos)
Definition: mtxline.c:149
void setVocal(voice_index voice, boolean voc)
Definition: mtxline.c:137
short beatsPerLine(void)
Definition: mtxline.c:59
boolean selected[15]
int k
Definition: otp-parser.c:70
#define print(s)
Definition: pbmtoln03.c:48
unsigned short word
Definition: picttoppm.c:64
int ninstr
Definition: process_score.c:15
#define STR2(tok)
Definition: t1part.c:39
Definition: bdf.c:133
Definition: pdfdoc.c:79
int j
Definition: t4ht.c:1589
*job_name strlen((char *) job_name) - 4)
@ S
Definition: ubidiimp.h:53
char * GetNextWord(char *Result, char *s, char Delim, char Term)
Definition: utility.c:40
short wordCount(char *s)
Definition: utility.c:21
boolean endsWith(char *s1_, char *s2)
Definition: utility.c:158
boolean equalsIgnoreCase(char *s1_, char *s2_)
Definition: utility.c:111
char * toString(char *Result, short n)
Definition: utility.c:96
char * NextWord(char *Result, char *s_, char Delim, char Term)
Definition: utility.c:64
short curtail(char *s, char c)
Definition: utility.c:82
boolean startsWithIgnoreCase(char *s1_, char *s2_)
Definition: utility.c:123
static char pmx_line[256]
Definition: preamble.c:117
static short orig_range_line
Definition: preamble.c:113
static short ngroups
Definition: preamble.c:115
static char options_line[256]
Definition: preamble.c:117
static void setVoices(char *line)
Definition: preamble.c:392
static short group_start[3]
Definition: preamble.c:119
static boolean redefined[28]
Definition: preamble.c:86
static style_index0 findStyle(char *s_)
Definition: preamble.c:141
static boolean style_supplied
Definition: preamble.c:121
static void setClefs(char *line_)
Definition: preamble.c:444
boolean omitLine(paragraph_index line)
Definition: preamble.c:329
static char * pmxMeter(char *Result)
Definition: preamble.c:1048
static short n_pages
Definition: preamble.c:115
char style_index
Definition: preamble.c:59
void augmentPreamble(boolean control_para)
Definition: preamble.c:885
static char composer_line[256]
Definition: preamble.c:116
static char part_line[256]
Definition: preamble.c:116
static short clefno(char cl)
Definition: preamble.c:963
static command_type findCommand(char *command)
Definition: preamble.c:517
static boolean warn_redefine
Definition: preamble.c:69
#define semicolon
Definition: preamble.c:43
static void readStyles(void)
Definition: preamble.c:176
#define colon_
Definition: preamble.c:42
static short n_systems
Definition: preamble.c:115
boolean thisCase(void)
Definition: preamble.c:872
static char clefs[256]
Definition: preamble.c:118
static char start_line[256]
Definition: preamble.c:117
static short known_styles
Definition: preamble.c:68
#define comma_
Definition: preamble.c:44
static void setName(void)
Definition: preamble.c:335
static void setRange(char *line_)
Definition: preamble.c:564
static short group_stop[3]
Definition: preamble.c:119
command_type
Definition: preamble.c:49
@ pmx
Definition: preamble.c:50
@ height
Definition: preamble.c:51
@ start
Definition: preamble.c:52
@ poet
Definition: preamble.c:52
@ enable
Definition: preamble.c:51
@ systems
Definition: preamble.c:51
@ range
Definition: preamble.c:52
@ name
Definition: preamble.c:52
@ only
Definition: preamble.c:52
@ style
Definition: preamble.c:50
@ width
Definition: preamble.c:51
@ pages
Definition: preamble.c:51
@ options
Definition: preamble.c:50
@ composer
Definition: preamble.c:50
@ meter
Definition: preamble.c:51
@ msize
Definition: preamble.c:50
@ flats
Definition: preamble.c:51
@ tex
Definition: preamble.c:50
@ sharps
Definition: preamble.c:51
@ disable
Definition: preamble.c:51
@ shortnote
Definition: preamble.c:50
@ bars
Definition: preamble.c:50
@ none
Definition: preamble.c:50
@ indent
Definition: preamble.c:52
@ space
Definition: preamble.c:51
@ octave_
Definition: preamble.c:52
@ part
Definition: preamble.c:52
@ title
Definition: preamble.c:50
void interpretCommands(void)
Definition: preamble.c:700
char style_index0
Definition: preamble.c:61
static void setSize(char *line_)
Definition: preamble.c:487
static void applyStyles(void)
Definition: preamble.c:292
void restyle(void)
Definition: preamble.c:957
void preambleDefaults(void)
Definition: preamble.c:787
static line_type doCommand(char *line_)
Definition: preamble.c:602
static boolean omit_line[100]
Definition: preamble.c:111
#define cn
Definition: preamble.c:65
static char cline[28][256]
Definition: preamble.c:81
char * startString(char *Result, voice_index0 voice)
Definition: preamble.c:1193
static void insertTeX(void)
Definition: preamble.c:1041
#define c1
Definition: preamble.c:64
boolean isCommand(char *command_)
Definition: preamble.c:532
static boolean mustAppend(command_type command)
Definition: preamble.c:541
static char instr_name[15][41]
Definition: preamble.c:120
void nonMusic(void)
Definition: preamble.c:860
void setOnly(char *line_)
Definition: preamble.c:663
static void doTenorClefs(void)
Definition: preamble.c:1022
static style_index0 orig_style_line[24]
Definition: preamble.c:112
static void wipeCommands(void)
Definition: preamble.c:320
static voice_index0 voiceCount(char *s_)
Definition: preamble.c:126
static void addStyle(char *S)
Definition: preamble.c:158
static void setInitOctave(void)
Definition: preamble.c:358
static void setDimension(char *line_, command_type lno)
Definition: preamble.c:464
#define max_styles
Definition: preamble.c:46
void doPreamble(void)
Definition: preamble.c:913
void doPMXpreamble(void)
Definition: preamble.c:1107
static boolean isAssertion(char *line)
Definition: preamble.c:596
static boolean style_used[24]
Definition: preamble.c:110
static void setIndent(void)
Definition: preamble.c:351
static char known_style[24][256]
Definition: preamble.c:94
static char * sizecode(char *Result, short k)
Definition: preamble.c:1066
static style_index old_known_styles
Definition: preamble.c:109
static short n_sharps
Definition: preamble.c:115
static short nclefs
Definition: preamble.c:115
line_type
Definition: preamble.c:55
@ comment_line
Definition: preamble.c:56
@ colon_line
Definition: preamble.c:56
@ unknown
Definition: preamble.c:56
@ plain_line
Definition: preamble.c:56
@ command_line
Definition: preamble.c:56
static char voices[256]
Definition: preamble.c:117
static char title_line[256]
Definition: preamble.c:116
static void checkLabel(char *w)
Definition: preamble.c:365
static void preambleGuess(voice_index maybe_voices)
Definition: preamble.c:815
static void applyStyle(char *s_, char *stylename, stave_index first_inst, stave_index first_stave)
Definition: preamble.c:202
#define blank_
Definition: preamble.c:41
void respace(void)
Definition: preamble.c:935
static void doEnable(char *line, boolean choice)
Definition: preamble.c:547
void initOctaves(char *octaves)
Definition: status.c:258
void defineRange(short voice, char *range_)
Definition: status.c:100