74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
static void trans(FILE *in, FILE *out){
int i, j, k; /* Loop counters */
char c1, c2; /* Characters used to start a comment */
int lastWasEq = 0; /* True if last non-whitespace character was "=" */
int lastWasComma = 0; /* True if last non-whitespace character was "," */
char zLine[2000]; /* A single line of input */
char zOut[4000]; /* The input line translated into appropriate output */
int isFirstline = 1; /* True if this is the first line */
c1 = c2 = '-';
while( fgets(zLine, sizeof(zLine), in) ){
if (isFirstline) {
static const char bom[] = { 0xEF, 0xBB, 0xBF };
if( memcmp(zLine, bom, 3)==0 ) {
memmove(zLine, zLine+3, sizeof(zLine)-3);
}
isFirstline = 0;
}
for(i=0; zLine[i] && isspace(zLine[i]); i++){}
if( zLine[i]!='@' ){
if( inPrint || inStr ) end_block(out);
for(j=0; zLine[i]; i++){
if (128 <= (unsigned char)zLine[i]) {
sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
j += 5;
} else {
zOut[j++] = zLine[i];
}
}
zOut[j] = 0;
fprintf(out,"%s",zLine);
fprintf(out,"%s",zOut);
/* 0123456789 12345 */
if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
c1 = zLine[14];
c2 = zLine[15];
}
i += strlen(&zLine[i]);
while( i>0 && isspace(zLine[i-1]) ){ i--; }
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
+
+
+
+
-
+
+
|
if( indent<0 ) indent = 0;
omitline = 0;
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
omitline = 1; break;
}
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
if (128 <= (unsigned char)zLine[i]) {
sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
j += 5;
} else {
zOut[j++] = zLine[i];
zOut[j++] = zLine[i];
}
}
while( j>0 && isspace(zOut[j-1]) ){ j--; }
zOut[j] = 0;
if( j<=0 && omitline ){
fprintf(out,"\n");
}else{
fprintf(out,"%*s\"%s\\n\"\n",indent, "", zOut);
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
+
+
+
+
-
+
+
|
int nC;
char c;
i++;
if( isspace(zLine[i]) ){ i++; }
indent = i;
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
if (128 <= (unsigned char)zLine[i]) {
sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
j += 5;
} else {
zOut[j++] = zLine[i];
zOut[j++] = zLine[i];
}
if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
while( --nC ) zOut[j++] = zLine[++i];
zArg[nArg++] = ',';
k = 0; i++;
while( (c = zLine[i])!=0 ){
|