Changeset 41179 in vbox for trunk/src/bldprogs/scmstream.cpp
- Timestamp:
- May 6, 2012 8:31:02 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scmstream.cpp
r40558 r41179 21 21 #include <iprt/assert.h> 22 22 #include <iprt/ctype.h> 23 #include <iprt/err.h> 23 24 #include <iprt/file.h> 24 #include <iprt/ err.h>25 #include <iprt/handle.h> 25 26 #include <iprt/mem.h> 27 #include <iprt/pipe.h> 26 28 #include <iprt/string.h> 27 29 … … 328 330 329 331 /** 332 * Writes the stream to standard output. 333 * 334 * @returns IPRT status code 335 * @param pStream The stream. 336 */ 337 int ScmStreamWriteToStdOut(PSCMSTREAM pStream) 338 { 339 int rc; 340 341 #ifdef RT_STRICT 342 /* 343 * Check that what we're going to write makes sense first. 344 */ 345 rc = ScmStreamCheckItegrity(pStream); 346 if (RT_FAILURE(rc)) 347 return rc; 348 #endif 349 350 /* 351 * Do the actual writing. 352 */ 353 RTHANDLE h; 354 rc = RTHandleGetStandard(RTHANDLESTD_OUTPUT, &h); 355 if (RT_SUCCESS(rc)) 356 { 357 switch (h.enmType) 358 { 359 case RTHANDLETYPE_FILE: 360 rc = RTFileWrite(h.u.hFile, pStream->pch, pStream->cb, NULL); 361 break; 362 case RTHANDLETYPE_PIPE: 363 rc = RTPipeWriteBlocking(h.u.hPipe, pStream->pch, pStream->cb, NULL); 364 break; 365 default: 366 rc = VERR_INVALID_HANDLE; 367 break; 368 } 369 } 370 return rc; 371 } 372 373 /** 330 374 * Worker for ScmStreamGetLine that builds the line number index while parsing 331 375 * the stream. … … 642 686 const char *ScmStreamGetLine(PSCMSTREAM pStream, size_t *pcchLine, PSCMEOL penmEol) 643 687 { 644 /** @todo this doesn't work when pStream->off !=645 * pStream->paLines[pStream->iLine-1].off. */646 688 if (!pStream->fFullyLineated) 647 689 return scmStreamGetLineInternal(pStream, pcchLine, penmEol); 648 return ScmStreamGetLineByNo(pStream, pStream->iLine, pcchLine, penmEol); 690 691 size_t offCur = pStream->off; 692 size_t iCurLine = pStream->iLine; 693 const char *pszLine = ScmStreamGetLineByNo(pStream, iCurLine, pcchLine, penmEol); 694 if ( pszLine 695 && pStream->paLines[iCurLine].off < offCur) 696 { 697 offCur -= pStream->paLines[iCurLine].off; 698 Assert(offCur <= pStream->paLines[iCurLine].off); 699 *pcchLine -= offCur; 700 pszLine += offCur; 701 } 702 return pszLine; 649 703 } 650 704
Note:
See TracChangeset
for help on using the changeset viewer.