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. */
| 4919 | * @return the newly allocated buffer state object. |
| 4920 | */ |
| 4921 | YY_BUFFER_STATE msyy_scan_buffer (char * base, yy_size_t size ) |
| 4922 | { |
| 4923 | YY_BUFFER_STATE b; |
| 4924 | |
| 4925 | if ( size < 2 || |
| 4926 | base[size-2] != YY_END_OF_BUFFER_CHAR || |
| 4927 | base[size-1] != YY_END_OF_BUFFER_CHAR ) |
| 4928 | /* They forgot to leave room for the EOB's. */ |
| 4929 | return 0; |
| 4930 | |
| 4931 | b = (YY_BUFFER_STATE) msyyalloc(sizeof( struct yy_buffer_state ) ); |
| 4932 | if ( ! b ) |
| 4933 | YY_FATAL_ERROR( "out of dynamic memory in msyy_scan_buffer()" ); |
| 4934 | |
| 4935 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ |
| 4936 | b->yy_buf_pos = b->yy_ch_buf = base; |
| 4937 | b->yy_is_our_buffer = 0; |
| 4938 | b->yy_input_file = 0; |
| 4939 | b->yy_n_chars = b->yy_buf_size; |
| 4940 | b->yy_is_interactive = 0; |
| 4941 | b->yy_at_bol = 1; |
| 4942 | b->yy_fill_buffer = 0; |
| 4943 | b->yy_buffer_status = YY_BUFFER_NEW; |
| 4944 | |
| 4945 | msyy_switch_to_buffer(b ); |
| 4946 | |
| 4947 | return b; |
| 4948 | } |
| 4949 | |
| 4950 | /** Setup the input buffer state to scan a string. The next call to msyylex() will |
| 4951 | * scan from a @e copy of @a str. |
no test coverage detected