… | |
… | |
292 | // end == -2, till '\n' |
292 | // end == -2, till '\n' |
293 | // end == -1, till '>' |
293 | // end == -1, till '>' |
294 | // end == 0, till eos |
294 | // end == 0, till eos |
295 | // end >= 1, levels of " >>>" |
295 | // end >= 1, levels of " >>>" |
296 | static const char * |
296 | static const char * |
297 | expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end) |
297 | expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0) |
298 | { |
298 | { |
299 | static dynbuf_text nest(128, 128); |
299 | static dynbuf_text nest(128, 128); |
300 | |
300 | |
301 | for (;;) |
301 | for (;;) |
302 | switch (char ch = *cfpod++) |
302 | switch (char ch = *cfpod++) |
303 | { |
303 | { |
304 | case 0: |
304 | case 0: |
305 | return cfpod - 1; |
305 | return cfpod - 1; |
306 | |
306 | |
307 | case ' ': |
307 | case ' ': |
|
|
308 | // verbatim block? |
|
|
309 | if (!buf.size () && !end) |
|
|
310 | { |
|
|
311 | --cfpod; |
|
|
312 | goto verbatim; |
|
|
313 | } |
|
|
314 | |
308 | if (end < 1) |
315 | if (end < 1) |
309 | goto passthrough; |
316 | goto passthrough; |
310 | |
317 | |
311 | for (int i = 0; i < end; ++i) |
318 | for (int i = 0; i < end; ++i) |
312 | if (cfpod [i] != '>') |
319 | if (cfpod [i] != '>') |
… | |
… | |
352 | while (*cfpod == '\n'); |
359 | while (*cfpod == '\n'); |
353 | } |
360 | } |
354 | else if (*cfpod != ' ') |
361 | else if (*cfpod != ' ') |
355 | buf << ' '; |
362 | buf << ' '; |
356 | |
363 | |
357 | // start verbatim block's? |
364 | // verbatim block? |
358 | if (*cfpod == ' ') |
365 | if (*cfpod == ' ') |
359 | { |
366 | goto verbatim; |
360 | // elements cannot currently span multiple lines |
|
|
361 | do |
|
|
362 | { |
|
|
363 | buf << "<tt>"; |
|
|
364 | cfpod = expand_cfpod (pl, buf, cfpod, -2); |
|
|
365 | buf << "</tt>\n"; |
|
|
366 | } |
|
|
367 | while (*cfpod == ' '); |
|
|
368 | |
|
|
369 | while (*cfpod == '\n') |
|
|
370 | buf << *cfpod++; |
|
|
371 | } |
|
|
372 | |
367 | |
373 | break; |
368 | break; |
374 | |
369 | |
375 | case 'B': case 'C': case 'E': case 'G': |
370 | case 'B': case 'C': case 'E': case 'G': |
376 | case 'H': case 'I': case 'T': case 'U': |
371 | case 'H': case 'I': case 'T': case 'U': |
… | |
… | |
458 | default: |
453 | default: |
459 | passthrough: |
454 | passthrough: |
460 | buf << ch; |
455 | buf << ch; |
461 | skip: |
456 | skip: |
462 | break; |
457 | break; |
|
|
458 | |
|
|
459 | verbatim: |
|
|
460 | // elements cannot currently span multiple lines |
|
|
461 | do |
|
|
462 | { |
|
|
463 | buf << "<tt>"; |
|
|
464 | cfpod = expand_cfpod (pl, buf, cfpod, -2); |
|
|
465 | buf << "</tt>\n"; |
|
|
466 | } |
|
|
467 | while (*cfpod == ' '); |
|
|
468 | |
|
|
469 | while (*cfpod == '\n') |
|
|
470 | buf << *cfpod++; |
|
|
471 | |
|
|
472 | break; |
463 | } |
473 | } |
464 | } |
474 | } |
465 | |
475 | |
466 | dynbuf_text * |
476 | dynbuf_text * |
467 | player::expand_cfpod (const char *cfpod) const |
477 | player::expand_cfpod (const char *cfpod) const |
468 | { |
478 | { |
469 | static dynbuf_text buf(1024, 1024); |
479 | static dynbuf_text buf(1024, 1024); |
470 | buf.clear (); |
480 | buf.clear (); |
471 | |
481 | |
472 | ::expand_cfpod (this, buf, cfpod, 0); |
482 | ::expand_cfpod (this, buf, cfpod); |
473 | |
483 | |
474 | return &buf; |
484 | return &buf; |
475 | } |
485 | } |
476 | |
486 | |