⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lex.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 4 页
字号:
    if (b != YY_CURRENT_BUFFER){        b->yy_bs_lineno = 1;        b->yy_bs_column = 0;    }        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;    	errno = oerrno;}/** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. *  */    void yy_flush_buffer (YY_BUFFER_STATE  b ){    	if ( ! b )		return;	b->yy_n_chars = 0;	/* We always need two end-of-buffer characters.  The first causes	 * a transition to the end-of-buffer state.  The second causes	 * a jam in that state.	 */	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;	b->yy_buf_pos = &b->yy_ch_buf[0];	b->yy_at_bol = 1;	b->yy_buffer_status = YY_BUFFER_NEW;	if ( b == YY_CURRENT_BUFFER )		yy_load_buffer_state( );}/** Pushes the new state onto the stack. The new state becomes *  the current state. This function will allocate the stack *  if necessary. *  @param new_buffer The new state. *   */void yypush_buffer_state (YY_BUFFER_STATE new_buffer ){    	if (new_buffer == NULL)		return;	yyensure_buffer_stack();	/* This block is copied from yy_switch_to_buffer. */	if ( YY_CURRENT_BUFFER )		{		/* Flush out information for old buffer. */		*(yy_c_buf_p) = (yy_hold_char);		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);		}	/* Only push if top exists. Otherwise, replace top. */	if (YY_CURRENT_BUFFER)		(yy_buffer_stack_top)++;	YY_CURRENT_BUFFER_LVALUE = new_buffer;	/* copied from yy_switch_to_buffer. */	yy_load_buffer_state( );	(yy_did_buffer_switch_on_eof) = 1;}/** Removes and deletes the top of the stack, if present. *  The next element becomes the new top. *   */void yypop_buffer_state (void){    	if (!YY_CURRENT_BUFFER)		return;	yy_delete_buffer(YY_CURRENT_BUFFER );	YY_CURRENT_BUFFER_LVALUE = NULL;	if ((yy_buffer_stack_top) > 0)		--(yy_buffer_stack_top);	if (YY_CURRENT_BUFFER) {		yy_load_buffer_state( );		(yy_did_buffer_switch_on_eof) = 1;	}}/* Allocates the stack if it does not exist. *  Guarantees space for at least one push. */static void yyensure_buffer_stack (void){	int num_to_alloc;    	if (!(yy_buffer_stack)) {		/* First allocation is just for 2 elements, since we don't know if this		 * scanner will even need a stack. We use 2 instead of 1 to avoid an		 * immediate realloc on the next call.         */		num_to_alloc = 1;		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc								(num_to_alloc * sizeof(struct yy_buffer_state*)								);				memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));						(yy_buffer_stack_max) = num_to_alloc;		(yy_buffer_stack_top) = 0;		return;	}	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){		/* Increase the buffer to prepare for a possible push. */		int grow_size = 8 /* arbitrary grow size */;		num_to_alloc = (yy_buffer_stack_max) + grow_size;		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc								((yy_buffer_stack),								num_to_alloc * sizeof(struct yy_buffer_state*)								);		/* zero only the new slots.*/		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));		(yy_buffer_stack_max) = num_to_alloc;	}}/** 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.  */YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size ){	YY_BUFFER_STATE b;    	if ( size < 2 ||	     base[size-2] != YY_END_OF_BUFFER_CHAR ||	     base[size-1] != YY_END_OF_BUFFER_CHAR )		/* They forgot to leave room for the EOB's. */		return 0;	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );	if ( ! b )		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */	b->yy_buf_pos = b->yy_ch_buf = base;	b->yy_is_our_buffer = 0;	b->yy_input_file = 0;	b->yy_n_chars = b->yy_buf_size;	b->yy_is_interactive = 0;	b->yy_at_bol = 1;	b->yy_fill_buffer = 0;	b->yy_buffer_status = YY_BUFFER_NEW;	yy_switch_to_buffer(b  );	return b;}/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param str a NUL-terminated string to scan *  * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use *       yy_scan_bytes() instead. */YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ){    	return yy_scan_bytes(yystr,strlen(yystr) );}/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan * @param len the number of bytes in the buffer pointed to by @a bytes. *  * @return the newly allocated buffer state object. */YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len ){	YY_BUFFER_STATE b;	char *buf;	yy_size_t n;	int i;    	/* Get memory for full buffer, including space for trailing EOB's. */	n = _yybytes_len + 2;	buf = (char *) yyalloc(n  );	if ( ! buf )		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );	for ( i = 0; i < _yybytes_len; ++i )		buf[i] = yybytes[i];	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;	b = yy_scan_buffer(buf,n );	if ( ! b )		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );	/* It's okay to grow etc. this buffer, and we should throw it	 * away when we're done.	 */	b->yy_is_our_buffer = 1;	return b;}#ifndef YY_EXIT_FAILURE#define YY_EXIT_FAILURE 2#endifstatic void yy_fatal_error (yyconst char* msg ){    	(void) fprintf( stderr, "%s\n", msg );	exit( YY_EXIT_FAILURE );}/* Redefine yyless() so it works in section 3 code. */#undef yyless#define yyless(n) \	do \		{ \		/* Undo effects of setting up yytext. */ \        int yyless_macro_arg = (n); \        YY_LESS_LINENO(yyless_macro_arg);\		yytext[yyleng] = (yy_hold_char); \		(yy_c_buf_p) = yytext + yyless_macro_arg; \		(yy_hold_char) = *(yy_c_buf_p); \		*(yy_c_buf_p) = '\0'; \		yyleng = yyless_macro_arg; \		} \	while ( 0 )/* Accessor  methods (get/set functions) to struct members. *//** Get the current line number. *  */int yyget_lineno  (void){            return yylineno;}/** Get the input stream. *  */FILE *yyget_in  (void){        return yyin;}/** Get the output stream. *  */FILE *yyget_out  (void){        return yyout;}/** Get the length of the current token. *  */int yyget_leng  (void){        return yyleng;}/** Get the current token. *  */char *yyget_text  (void){        return yytext;}/** Set the current line number. * @param line_number *  */void yyset_lineno (int  line_number ){        yylineno = line_number;}/** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. *  * @see yy_switch_to_buffer */void yyset_in (FILE *  in_str ){        yyin = in_str ;}void yyset_out (FILE *  out_str ){        yyout = out_str ;}int yyget_debug  (void){        return yy_flex_debug;}void yyset_debug (int  bdebug ){        yy_flex_debug = bdebug ;}static int yy_init_globals (void){        /* Initialization is the same as for the non-reentrant scanner.     * This function is called from yylex_destroy(), so don't allocate here.     */    (yy_buffer_stack) = 0;    (yy_buffer_stack_top) = 0;    (yy_buffer_stack_max) = 0;    (yy_c_buf_p) = (char *) 0;    (yy_init) = 0;    (yy_start) = 0;/* Defined in main.c */#ifdef YY_STDINIT    yyin = stdin;    yyout = stdout;#else    yyin = (FILE *) 0;    yyout = (FILE *) 0;#endif    /* For future reference: Set errno on error, since we are called by     * yylex_init()     */    return 0;}/* yylex_destroy is for both reentrant and non-reentrant scanners. */int yylex_destroy  (void){        /* Pop the buffer stack, destroying each element. */	while(YY_CURRENT_BUFFER){		yy_delete_buffer(YY_CURRENT_BUFFER  );		YY_CURRENT_BUFFER_LVALUE = NULL;		yypop_buffer_state();	}	/* Destroy the stack itself. */	yyfree((yy_buffer_stack) );	(yy_buffer_stack) = NULL;    /* Reset the globals. This is important in a non-reentrant scanner so the next time     * yylex() is called, initialization will occur. */    yy_init_globals( );    return 0;}/* * Internal utility routines. */#ifndef yytext_ptrstatic void yy_flex_strncpy (char* s1, yyconst char * s2, int n ){	register int i;	for ( i = 0; i < n; ++i )		s1[i] = s2[i];}#endif#ifdef YY_NEED_STRLENstatic int yy_flex_strlen (yyconst char * s ){	register int n;	for ( n = 0; s[n]; ++n )		;	return n;}#endifvoid *yyalloc (yy_size_t  size ){	return (void *) malloc( size );}void *yyrealloc  (void * ptr, yy_size_t  size ){	/* The cast to (char *) in the following accommodates both	 * implementations that use char* generic pointers, and those	 * that use void* generic pointers.  It works with the latter	 * because both ANSI C and C++ allow castless assignment from	 * any pointer type to void*, and deal with argument conversions	 * as though doing an assignment.	 */	return (void *) realloc( (char *) ptr, size );}void yyfree (void * ptr ){	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */}#define YYTABLES_NAME "yytables"#line 75 "lex.l"#ifndef yywrap /* XXX */intyywrap () {     return 1;}#endifstatic intgetstring(void){    char x[128];    int i = 0;    int c;    int quote = 0;    while(i < sizeof(x) - 1 && (c = input()) != EOF){	if(quote) {	    x[i++] = c;	    quote = 0;	    continue;	}	if(c == '\n'){	    error_message("unterminated string");	    lineno++;	    break;	}	if(c == '\\'){	    quote++;	    continue;	}	if(c == '\"')	    break;	x[i++] = c;    }    x[i] = '\0';    yylval.string = strdup(x);    if (yylval.string == NULL)        err(1, "malloc");    return STRING;}voiderror_message (const char *format, ...){     va_list args;     va_start (args, format);     fprintf (stderr, "%s:%d:", filename, lineno);     vfprintf (stderr, format, args);     va_end (args);     numerror++;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -