153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
zOut[j] = 0;
if( j<=0 && omitline ){
fprintf(out,"\n");
}else{
fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
}
}else{
/* Otherwise (if the last non-whitespace was not '=') then generate
** a cgi_printf() statement whose format is the text following the '@'.
** Substrings of the form "%C(...)" (where C is any sequence of
** characters other than \000 and '(') will put "%C" in the
** format and add the "(...)" as an argument to the cgi_printf call.
*/
const char *zNewline = "\\n";
int indent;
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+1] || zLine[i+1]=='\r'
|| zLine[i+1]=='\n') ){
zNewline = "";
break;
}
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
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 ){
zArg[nArg++] = c;
if( c==')' ){
k--;
if( k==0 ) break;
}else if( c=='(' ){
k++;
}
i++;
}
}
zOut[j] = 0;
if( !inPrint ){
fprintf(out,"%*scgi_printf(\"%s%s\"",indent-2,"", zOut, zNewline);
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
|
|
|
|
|
|
>
>
>
>
>
>
|
>
>
>
|
|
>
|
|
|
|
|
|
|
|
|
|
>
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
zOut[j] = 0;
if( j<=0 && omitline ){
fprintf(out,"\n");
}else{
fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
}
}else{
/* Otherwise (if the last non-whitespace was not '=') then generate a
** cgi_printf() statement whose format is the text following the '@'.
** Substrings of the form "%C(...)" (where C is any sequence of characters
** other than \000 and '(') will put "%C" in the format and add the
** "(...)" as an argument to the cgi_printf call. Each '*' character
** present in C (max two) causes one more "(...)" sequence to be consumed.
** For example, "%*.*d(4)(2)(1)" converts to "%*.*d" with arguments "4",
** "2", and "1", which will be used as the field width, precision, and
** value, respectively, producing a final formatted result of " 01".
*/
const char *zNewline = "\\n";
int indent;
int nC;
int nParam;
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+1] || zLine[i+1]=='\r'
|| zLine[i+1]=='\n') ){
zNewline = "";
break;
}
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
zOut[j++] = zLine[i];
if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
nParam=1;
for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){
if( zLine[i+nC]=='*' && nParam < 3 ) nParam++;
}
if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
while( --nC ) zOut[j++] = zLine[++i];
do{
zArg[nArg++] = ',';
k = 0; i++;
if( zLine[i]!='(' ) break;
while( (c = zLine[i])!=0 ){
zArg[nArg++] = c;
if( c==')' ){
k--;
if( k==0 ) break;
}else if( c=='(' ){
k++;
}
i++;
}
}while( --nParam );
}
zOut[j] = 0;
if( !inPrint ){
fprintf(out,"%*scgi_printf(\"%s%s\"",indent-2,"", zOut, zNewline);
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
|