MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ReadString

Method ReadString

neo/idlib/BitMsg.cpp:424–450  ·  view source on GitHub ↗

================ idBitMsg::ReadString ================ */

Source from the content-addressed store, hash-verified

422================
423*/
424int idBitMsg::ReadString( char *buffer, int bufferSize ) const {
425 int l, c;
426
427 ReadByteAlign();
428 l = 0;
429 while( 1 ) {
430 c = ReadByte();
431 if ( c <= 0 || c >= 255 ) {
432 break;
433 }
434 // translate all fmt spec to avoid crash bugs in string routines
435 if ( c == '%' ) {
436 c = '.';
437 }
438
439 // we will read past any excessively long string, so
440 // the following data can be read, but the string will
441 // be truncated
442 if ( l < bufferSize - 1 ) {
443 buffer[l] = c;
444 l++;
445 }
446 }
447
448 buffer[l] = 0;
449 return l;
450}
451
452/*
453================

Callers 1

WriteStringMethod · 0.45

Calls 3

ReadByteFunction · 0.85
ReadBitsMethod · 0.45
WriteStringMethod · 0.45

Tested by

no test coverage detected