MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / getFewLines

Function getFewLines

src/simulate/runtime_string.cpp:466–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464 }
465
466 static string getFewLines ( const char* st, uint32_t stlen, int ROW, int COL, int /*LROW*/, int LCOL, int TAB ) {
467 TextWriter text;
468 int col=0, row=1;
469 auto it = st;
470 auto itend = st + stlen;
471 if ( ROW>1 ) {
472 while ( it!=itend && *it ) {
473 auto CH = *it++;
474 if ( CH=='\n' ) {
475 row++;
476 col=0;
477 if ( row==ROW ) break;
478 }
479 }
480 }
481 if ( row!=ROW ) return "";
482 auto beginOfLine = it;
483 for (;;) {
484 if (it == itend || *it == 0)
485 {
486 text << "\n";
487 break;
488 }
489 auto CH = *it++;
490 if ( CH=='\t' ) {
491 int tcol = (col + TAB) & ~(TAB-1);
492 while ( col < tcol ) {
493 text << " ";
494 col ++;
495 }
496 continue;
497 } else if ( CH=='\n' ) {
498 row++;
499 col=0;
500 text << "\n";
501 break;
502 } else {
503 text << CH;
504 }
505 col ++;
506 }
507 it = beginOfLine;
508 const char * tail = it + COL;
509 while ( it!=tail && it!=itend && *it ) {
510 auto CH = *it++;
511 if ( CH=='\t' ) {
512 int tcol = (col + TAB) & ~(TAB-1);
513 while ( col < tcol ) {
514 text << " ";
515 col ++;
516 }
517 continue;
518 } else if ( CH=='\n' ) {
519 break;
520 } else {
521 text << " ";
522 }
523 col ++;

Callers 1

reportErrorFunction · 0.85

Calls 2

stringClass · 0.85
strMethod · 0.45

Tested by

no test coverage detected