MCPcopy Create free account
hub / github.com/Entware/Entware / yy_scan_buffer

Function yy_scan_buffer

scripts/config/lexer.lex.c:3655–3682  ·  view source on GitHub ↗

Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */

Source from the content-addressed store, hash-verified

3653 * @return the newly allocated buffer state object.
3654 */
3655YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
3656{
3657 YY_BUFFER_STATE b;
3658
3659 if ( size < 2 ||
3660 base[size-2] != YY_END_OF_BUFFER_CHAR ||
3661 base[size-1] != YY_END_OF_BUFFER_CHAR )
3662 /* They forgot to leave room for the EOB's. */
3663 return NULL;
3664
3665 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
3666 if ( ! b )
3667 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
3668
3669 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
3670 b->yy_buf_pos = b->yy_ch_buf = base;
3671 b->yy_is_our_buffer = 0;
3672 b->yy_input_file = NULL;
3673 b->yy_n_chars = b->yy_buf_size;
3674 b->yy_is_interactive = 0;
3675 b->yy_at_bol = 1;
3676 b->yy_fill_buffer = 0;
3677 b->yy_buffer_status = YY_BUFFER_NEW;
3678
3679 yy_switch_to_buffer( b );
3680
3681 return b;
3682}
3683
3684/** Setup the input buffer state to scan a string. The next call to yylex() will
3685 * scan from a @e copy of @a str.

Callers 1

yy_scan_bytesFunction · 0.85

Calls 2

yyallocFunction · 0.85
yy_switch_to_bufferFunction · 0.85

Tested by

no test coverage detected