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)  

globals.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 "globals.pas" */
3 
4 
5 #include "p2c.h"
6 
7 
8 #define GLOBALS_G
9 #include "globals.h"
10 
11 
12 Char double_comment[3] = "%%";
13 Char durations[ndurs + 1] = "90248136";
14 Char terminators[256] = ".x";
15 Char has_duration[9] = "abcdefgr";
16 Char solfa_names[8] = "drmfslt";
17 Char choice = ' ';
18 boolean outfile_open = false;
19 Char texdir[256] = "";
20 Char old_meter_word[256] = "";
21 short outlen = 0;
22 boolean ignore_input = false;
23 
24 #ifndef STRINGS_H
25 #include "strings.h"
26 #endif
27 
28 #ifndef CONTROL_H
29 #include "control.h"
30 #endif
31 
32 #ifndef UTILITY_H
33 #include "utility.h"
34 #endif
35 
36 
37 boolean isNoteOrRest(Char *w)
38 {
39  return (pos1(w[0], has_duration) > 0);
40 }
41 
42 
43 boolean isPause(Char *note)
44 {
45  return (startsWith(note, pause));
46 }
47 
48 
49 void cancel(short *num, short *denom, short lowest)
50 {
51  while (((*num) & 1) == 0 && *denom > lowest) {
52  *num /= 2;
53  *denom /= 2;
54  }
55 }
56 
57 
58 Char *meterWord(Char *Result, short num, short denom, short pnum,
59  short pdenom)
60 {
61  Char STR1[256], STR2[256], STR4[256], STR5[256];
62 
63  sprintf(Result, "m%s/%s/%s/%s",
64  toString(STR1, num), toString(STR2, denom), toString(STR4, pnum),
65  toString(STR5, pdenom));
66  return Result;
67 }
68 
69 
70 Char *meterChange(Char *Result, short n1, short n2, boolean blind)
71 {
72  short f = 64;
73  short l;
74 
75  if (!blind)
76  return (meterWord(Result, n1, PMXmeterdenom(n2), 0, 0));
77  /* CMO: process denominator value with function PMXmeterdenom */
78  l = n1 * (64 / n2);
79  cancel(&l, &f, meterdenom);
80  /* CMO: process denominator value with function PMXmeterdenom */
81  meterWord(Result, l, PMXmeterdenom(f), 0, 0);
82  if (meternum > 0)
83  printf("Blind meter change to %d/%d on line %d\n", l, f, line_no);
84  return Result;
85 }
86 
87 
88 void setSpace(Char *line_)
89 {
90  Char line[256];
91  short i;
92  Char word[256];
93  Char STR1[256];
94 
95  strcpy(line, line_);
96  i = pos1(';', line);
97  if (i > 0) {
98  getNum(substr_(STR1, line, 1, i - 1), nspace);
99  predelete(line, i);
100  }
101  i = 0;
102  while (i < ninstr) {
104  if (*word == '\0')
105  return;
106  i++;
107  getNum(word, &nspace[i]);
108  }
109 }
110 
111 
112 Static void onumber(Char *s, short *j, short *n1)
113 {
114  if (s[*j - 1] == 'o')
115  *n1 = 1;
116  else if (s[*j - 1] == '1') {
117  *n1 = digit(s[*j]) + 10;
118  (*j)++;
119  } else
120  *n1 = digit(s[*j - 1]);
121  (*j)++;
122 }
123 
124 
125 Static void extractNumber(Char *s, short *k)
126 {
127  Char w[256];
128 
129  GetNextWord(w, s, '/', dummy);
130  getNum(w, k);
131 }
132 
133 
134 Static void readMeter(Char *meter_, short *meternum, short *meterdenom,
135  short *pmnum, short *pmdenom)
136 {
137  Char meter[256];
138  short j;
139 
140  strcpy(meter, meter_);
141  if (meter[0] == 'm') {
142  if (pos1('/', meter) == 0) {
143  j = 2;
144  onumber(meter, &j, meternum);
146  onumber(meter, &j, pmnum);
147  onumber(meter, &j, pmdenom);
148  return;
149  }
150  predelete(meter, 1);
155  return;
156  }
158  *pmnum = *meternum;
159  *pmdenom = *meterdenom;
160 }
161 
162 
163 void getMeter(Char *line_, short *meternum, short *meterdenom, short *pmnum,
164  short *pmdenom)
165 {
166  Char line[256];
167  Char meter[256];
168  Char STR1[256];
169 
170  strcpy(line, line_);
172  if (!strcmp(meter, "C/") || !strcmp(meter, "mC/")) {
173  *meternum = 2;
174  *meterdenom = 2;
175  *pmdenom = 5;
176  *pmnum = 0;
177  } else if (!strcmp(meter, "C") || !strcmp(meter, "mC")) {
178  *meternum = 4;
179  *meterdenom = 4;
180  *pmdenom = 6;
181  *pmnum = 0;
182  } else
184  if (*meterdenom == 0) {
185  sprintf(STR1, "%s: Meter denominator must be nonzero", meter);
186  error(STR1, print);
187  }
188  /* CMO: Convert PMX syntax meter denominator '0' to '1' to be used for
189  prepmx duration checks */
190  /* if meterdenom=0 then meterdenom:=1; */
191 }
192 
193 
195 {
196  short Result = 0;
197  short j, FORLIM;
198 
199  FORLIM = para_len;
200  for (j = 1; j <= FORLIM; j++) {
201  if (orig_line_no[j-1] == l)
202  return j;
203  }
204  return Result;
205 }
206 
207 
209 {
210  setFeature("ignoreErrors", false);
211  error(message, !print);
212 }
213 
214 
215 void error(Char *message, boolean printLine)
216 {
217  short j;
218 
220  if (j > 0 && printLine)
221  puts(orig_P[j-1]);
222  printf("%s: ERROR on line %d\n", message, line_no);
223  if (j > 0 && printLine) {
224  printf("The line has been modified internally to:\n");
225  puts(P[j-1]);
226  }
227  if (ignoreErrors())
228  return;
229  if (outfile_open) {
230  if (outfile != NULL)
231  fclose(outfile);
232  outfile = NULL;
233  outfile = fopen(outfile_NAME, "wb");
234  if (outfile == NULL)
236  fclose(outfile);
237  outfile = NULL;
238  }
239  if (line_no == 0)
240  line_no = 10000;
241  _Escape(line_no);
242 }
243 
244 
245 void warning(Char *message, boolean printLine)
246 {
247  short j;
248 
249  if (line_no <= 0) {
250  printf("%s: WARNING in preamble\n", message);
251  return;
252  }
253  printf("%s: WARNING on line %d\n", message, line_no);
254  if (!printLine)
255  return;
257  if (j > 0)
258  puts(P[j-1]);
259 }
260 
261 
262 short PMXinstr(short stave)
263 {
264  return (ninstr - instr[stave-1] + 1);
265 }
266 
267 
269 {
270  switch (meterdenom) {
271 
272  case 1:
273  default_duration = '0';
274  break;
275 
276  case 2:
277  default_duration = '2';
278  break;
279 
280  case 4:
281  default_duration = '4';
282  break;
283 
284  case 8:
285  default_duration = '8';
286  break;
287 
288  case 16:
289  default_duration = '1';
290  break;
291 
292  case 32:
293  default_duration = '3';
294  break;
295 
296  case 64:
297  default_duration = '6';
298  break;
299  }
300 }
301 
302 
303 short PMXmeterdenom(short denom)
304 {
305  short Result;
306 
307  /* CMO: Convert M-Tx meter denominators to PMX syntax */
308  switch (denom) {
309 
310  case 1:
311  Result = 0;
312  break;
313 
314  case 16:
315  Result = 1;
316  break;
317 
318  case 32:
319  Result = 3;
320  break;
321 
322  case 64:
323  Result = 6;
324  break;
325 
326  default:
327  Result = denom;
328  break;
329  }
330  return Result;
331 }
332 
333 
334 
335 
336 /* End. */
#define message
Definition: aptex-macros.h:418
char * substr_(char *Result, char *s, short start, short count)
Definition: cfuncs.c:83
int _Escape(int exitcode)
Definition: cfuncs.c:11
void predelete(char *s, short l)
Definition: cfuncs.c:40
void getNum(char *line, short *k)
Definition: cfuncs.c:57
boolean startsWith(char *s1, char *s2)
Definition: cfuncs.c:72
short pos1(char c, char *s)
Definition: cfuncs.c:30
void getTwoNums(char *line, short *k1, short *k2)
Definition: cfuncs.c:63
int _EscIO2(int errorcode, char *filename)
Definition: cfuncs.c:7
#define FileNotFound
Definition: cfuncs.h:13
#define Static
Definition: cfuncs.h:9
boolean setFeature(char *which, boolean val)
Definition: control.c:105
boolean ignoreErrors(void)
Definition: control.c:206
int dummy
Definition: dummy.c:29
int w
Definition: dviconv.c:26
#define fopen
Definition: xxstdio.h:21
int strcmp()
Definition: coll.cpp:143
int printf()
char * strcpy()
char * digit
Definition: io.c:63
mpz_t * f
Definition: gen-fib.c:34
#define s
Definition: afcover.h:80
char terminators[256]
Definition: globals.c:14
char * meterChange(char *Result, short n1, short n2, boolean blind)
Definition: globals.c:70
short PMXinstr(short stave)
Definition: globals.c:262
char solfa_names[8]
Definition: globals.c:16
static void extractNumber(char *s, short *k)
Definition: globals.c:125
void getMeter(char *line_, short *meternum, short *meterdenom, short *pmnum, short *pmdenom)
Definition: globals.c:163
boolean outfile_open
Definition: globals.c:18
char choice
Definition: globals.c:17
static void onumber(char *s, short *j, short *n1)
Definition: globals.c:112
char old_meter_word[256]
Definition: globals.c:20
boolean isNoteOrRest(char *w)
Definition: globals.c:37
void setDefaultDuration(short meterdenom)
Definition: globals.c:268
short outlen
Definition: globals.c:21
char texdir[256]
Definition: globals.c:19
void cancel(short *num, short *denom, short lowest)
Definition: globals.c:49
void fatalerror(char *message)
Definition: globals.c:208
char has_duration[9]
Definition: globals.c:15
short PMXmeterdenom(short denom)
Definition: globals.c:303
char double_comment[3]
Definition: globals.c:12
void warning(char *message, boolean printLine)
Definition: globals.c:245
void setSpace(char *line_)
Definition: globals.c:88
boolean ignore_input
Definition: globals.c:22
char durations[8+1]
Definition: globals.c:13
char * meterWord(char *Result, short num, short denom, short pnum, short pdenom)
Definition: globals.c:58
boolean isPause(char *note)
Definition: globals.c:43
static void readMeter(char *meter_, short *meternum, short *meterdenom, short *pmnum, short *pmdenom)
Definition: globals.c:134
static short whereInParagraph(short l)
Definition: globals.c:194
void error(char *message, boolean printLine)
Definition: globals.c:215
paragraph_index0 para_len
voice_index0 stave[15]
Definition: globals.h:110
#define pause
Definition: globals.h:48
short pmnum
Definition: globals.h:116
short line_no
Definition: globals.h:115
paragraph orig_P
Definition: globals.h:120
short meternum
Definition: globals.h:115
Char default_duration
Char outfile_NAME[_FNSIZE]
paragraph P
short meterdenom
Definition: globals.h:116
line_nos orig_line_no
#define blank
Definition: globals.h:55
voice_index0 instr[15]
#define ndurs
Definition: globals.h:62
short pmdenom
Definition: globals.h:116
short nspace[15+1]
static FILE * outfile
Definition: wrjpgcom.c:80
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
int num
Definition: disdvi.c:621
#define fclose
Definition: debug.h:100
#define sprintf
Definition: snprintf.c:44
int k
Definition: otp-parser.c:70
#define print(s)
Definition: pbmtoln03.c:48
unsigned short word
Definition: picttoppm.c:64
#define blind
Definition: prepmx.c:88
int ninstr
Definition: process_score.c:15
static void printLine(FILE *f, const TextLine *line)
Definition: pdftotext.cc:462
#define STR2(tok)
Definition: t1part.c:39
Definition: bdf.c:133
int j
Definition: t4ht.c:1589
char * GetNextWord(char *Result, char *s, char Delim, char Term)
Definition: utility.c:40
char * toString(char *Result, short n)
Definition: utility.c:96
@ meter
Definition: preamble.c:51