~ubuntu-branches/ubuntu/utopic/texlive-bin/utopic

« back to all changes in this revision

Viewing changes to utils/mtx/mtx-0.60d/uptext.c

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2012-05-07 10:47:49 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20120507104749-p00ot5sajjbkp1hp
Tags: 2011.20120507-1
* new upstream checkout: uptex 1.10
* drop patches for config file inclusion in (x)dvipdfmx, included upstream
* add man page for etex
* include pmpost patches and build it
* adapt/unfuzzify patches for current sources
* disable mtx building, we have prepmx package in Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
 
2
/* From input file "uptext.pas" */
 
3
 
 
4
 
 
5
#include "p2c.h"
 
6
 
 
7
 
 
8
#define UPTEXT_G
 
9
#include "uptext.h"
 
10
 
 
11
 
 
12
#ifndef GLOBALS_H
 
13
#include "globals.h"
 
14
#endif
 
15
 
 
16
#ifndef STRINGS_H
 
17
#include "strings.h"
 
18
#endif
 
19
 
 
20
#ifndef MTXLINE_H
 
21
#include "mtxline.h"
 
22
#endif
 
23
 
 
24
#ifndef UTILITY_H
 
25
#include "utility.h"
 
26
#endif
 
27
 
 
28
 
 
29
typedef struct uptext_info {
 
30
  short uptext, uptext_adjust, uptext_lcz;
 
31
  Char uptext_font[256];
 
32
} uptext_info;
 
33
 
 
34
 
 
35
Static uptext_info U[maxvoices];
 
36
 
 
37
 
 
38
short uptextLineNo(voice)
 
39
short voice;
 
40
{
 
41
  return (U[voice-1].uptext);
 
42
}
 
43
 
 
44
 
 
45
Void setUptextLineNo(voice, lno)
 
46
short voice, lno;
 
47
{
 
48
  U[voice-1].uptext = lno;
 
49
}
 
50
 
 
51
 
 
52
Void clearUptext()
 
53
{
 
54
  voice_index voice, FORLIM;
 
55
 
 
56
  FORLIM = nvoices;
 
57
  for (voice = 0; voice <= FORLIM - 1; voice++)
 
58
    U[voice].uptext = 0;
 
59
}
 
60
 
 
61
 
 
62
Void initUptext()
 
63
{
 
64
  voice_index voice, FORLIM;
 
65
  uptext_info *WITH;
 
66
 
 
67
  FORLIM = nvoices;
 
68
  for (voice = 0; voice <= FORLIM - 1; voice++) {
 
69
    WITH = &U[voice];
 
70
    WITH->uptext_adjust = 0;
 
71
    WITH->uptext_lcz = 3;
 
72
    *WITH->uptext_font = '\0';
 
73
  }
 
74
}
 
75
 
 
76
 
 
77
Static Void textTranslate(uptext, font)
 
78
Char *uptext, *font;
 
79
{
 
80
  short k;
 
81
  Char STR1[256], STR2[256], STR3[256], STR4[256];
 
82
  short FORLIM;
 
83
 
 
84
  if (*uptext == '\0')
 
85
    return;
 
86
  do {
 
87
    k = pos1('%', uptext);
 
88
    if (k > 0) {
 
89
      sprintf(STR4, "%s{\\mtxFlat}%s",
 
90
              substr_(STR1, uptext, 1, k - 1),
 
91
              substr_(STR3, uptext, k + 1, strlen(uptext) - k));
 
92
      strcpy(uptext, STR4);
 
93
    }
 
94
  } while (k != 0);
 
95
  do {
 
96
    k = pos1('#', uptext);
 
97
    if (k > 0) {
 
98
      sprintf(STR2, "%s{\\mtxSharp}%s",
 
99
              substr_(STR1, uptext, 1, k - 1),
 
100
              substr_(STR4, uptext, k + 1, strlen(uptext) - k));
 
101
      strcpy(uptext, STR2);
 
102
    }
 
103
  } while (k != 0);
 
104
  switch (uptext[0]) {
 
105
 
 
106
  case '<':
 
107
    if (!strcmp(uptext, "<"))
 
108
      strcpy(uptext, "\\mtxIcresc");
 
109
    else if (!strcmp(uptext, "<."))
 
110
      strcpy(uptext, "\\mtxTcresc");
 
111
    else {
 
112
      predelete(uptext, 1);
 
113
      sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext));
 
114
    }
 
115
    break;
 
116
 
 
117
  case '>':
 
118
    if (!strcmp(uptext, ">"))
 
119
      strcpy(uptext, "\\mtxIdecresc");
 
120
    else if (!strcmp(uptext, ">."))
 
121
      strcpy(uptext, "\\mtxTdecresc");
 
122
    else {
 
123
      predelete(uptext, 1);
 
124
      sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext));
 
125
    }
 
126
    break;
 
127
 
 
128
  default:
 
129
    FORLIM = strlen(uptext);
 
130
    for (k = 0; k <= FORLIM - 1; k++) {
 
131
      if (pos1(uptext[k], "mpfzrs~") == 0)
 
132
        return;
 
133
    }
 
134
    break;
 
135
  }
 
136
  strcpy(font, "\\mtxPF");
 
137
}
 
138
 
 
139
 
 
140
#define default_        10
 
141
#define under           (-14)
 
142
 
 
143
 
 
144
/* Local variables for addUptext: */
 
145
struct LOC_addUptext {
 
146
  short voice;
 
147
  Char w[256];
 
148
  short adj;
 
149
} ;
 
150
 
 
151
Local Void adjustUptext(LINK)
 
152
struct LOC_addUptext *LINK;
 
153
{
 
154
  Char letter;
 
155
  boolean force = false;
 
156
  uptext_info *WITH1;
 
157
 
 
158
  delete1(LINK->w, 1);
 
159
  while (*LINK->w != '\0') {
 
160
/* p2c: uptext.pas: Note: Eliminated unused assignment statement [338] */
 
161
    letter = LINK->w[0];
 
162
    delete1(LINK->w, 1);
 
163
    WITH1 = &U[LINK->voice-1];
 
164
    switch (letter) {
 
165
 
 
166
    case '<':
 
167
      if (WITH1->uptext_lcz > 1)
 
168
        WITH1->uptext_lcz--;
 
169
      break;
 
170
 
 
171
    case '>':
 
172
      if (WITH1->uptext_lcz < 3)
 
173
        WITH1->uptext_lcz++;
 
174
      break;
 
175
 
 
176
    case '^':
 
177
      WITH1->uptext_adjust = 0;
 
178
      break;
 
179
 
 
180
    case 'v':
 
181
      WITH1->uptext_adjust = under;
 
182
      break;
 
183
 
 
184
    case '=':
 
185
      force = true;
 
186
      break;
 
187
 
 
188
    case '+':
 
189
    case '-':
 
190
      if (*LINK->w != '\0')
 
191
        getNum(LINK->w, &LINK->adj);
 
192
      else
 
193
        LINK->adj = 0;
 
194
      if (letter == '-')
 
195
        LINK->adj = -LINK->adj;
 
196
      if (force)
 
197
        WITH1->uptext_adjust = LINK->adj;
 
198
      else
 
199
        WITH1->uptext_adjust += LINK->adj;
 
200
      *LINK->w = '\0';
 
201
      break;
 
202
 
 
203
    default:
 
204
      error3(LINK->voice, "Unknown uptext adjustment");
 
205
      break;
 
206
    }
 
207
  }
 
208
  strcpy(LINK->w, "!");
 
209
}
 
210
 
 
211
 
 
212
Void addUptext(voice_, no_uptext, pretex)
 
213
short voice_;
 
214
boolean *no_uptext;
 
215
Char *pretex;
 
216
{
 
217
  struct LOC_addUptext V;
 
218
  Char font[256];
 
219
  static Char lcz[4] = "lcz";
 
220
  uptext_info *WITH;
 
221
  Char STR1[256], STR2[256], STR3[256];
 
222
 
 
223
  V.voice = voice_;
 
224
  WITH = &U[V.voice-1];
 
225
  if (WITH->uptext == 0)
 
226
    *no_uptext = true;
 
227
  if (*no_uptext)
 
228
    return;
 
229
  do {
 
230
    GetNextWord(V.w, P[WITH->uptext - 1], blank, dummy);
 
231
    sprintf(STR1, "%c", barsym);
 
232
    if (!strcmp(V.w, STR1) || *V.w == '\0')
 
233
      *no_uptext = true;
 
234
    sprintf(STR1, "%c", tilde);
 
235
    if (!strcmp(V.w, STR1) || *no_uptext)
 
236
      return;
 
237
    if (V.w[0] == '!') {
 
238
      strcpy(WITH->uptext_font, V.w);
 
239
      WITH->uptext_font[0] = '\\';
 
240
    }
 
241
    if (V.w[0] == '@')
 
242
      adjustUptext(&V);
 
243
  } while (V.w[0] == '!');   /* ! is a kludge, will get me in trouble later */
 
244
  strcpy(font, WITH->uptext_font);
 
245
  textTranslate(V.w, font);
 
246
  if (*font != '\0')
 
247
    sprintf(V.w, "%s{%s}", font, strcpy(STR1, V.w));
 
248
  switch (lcz[WITH->uptext_lcz - 1]) {
 
249
 
 
250
  case 'l':
 
251
    sprintf(V.w, "\\mtxLchar{%s}{%s}",
 
252
            toString(STR1, default_ + WITH->uptext_adjust),
 
253
            strcpy(STR3, V.w));
 
254
    break;
 
255
 
 
256
  case 'c':
 
257
    sprintf(V.w, "\\mtxCchar{%s}{%s}",
 
258
            toString(STR1, default_ + WITH->uptext_adjust),
 
259
            strcpy(STR2, V.w));
 
260
    break;
 
261
 
 
262
  case 'z':
 
263
    sprintf(V.w, "\\mtxZchar{%s}{%s}",
 
264
            toString(STR1, default_ + WITH->uptext_adjust),
 
265
            strcpy(STR3, V.w));
 
266
    break;
 
267
  }
 
268
  strcat(pretex, V.w);
 
269
}
 
270
 
 
271
#undef default_
 
272
#undef under
 
273
 
 
274
 
 
275
 
 
276
 
 
277
/* End. */