kconfig/lex.zconf.c
changeset 2448 a103abae1560
parent 1237 d757b7d685c3
     1.1 --- a/kconfig/lex.zconf.c	Fri Mar 06 12:39:04 2009 +0000
     1.2 +++ b/kconfig/lex.zconf.c	Sun May 08 14:14:40 2011 +0200
     1.3 @@ -160,7 +160,15 @@
     1.4  
     1.5  /* Size of default input buffer. */
     1.6  #ifndef YY_BUF_SIZE
     1.7 +#ifdef __ia64__
     1.8 +/* On IA-64, the buffer size is 16k, not 8k.
     1.9 + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
    1.10 + * Ditto for the __ia64__ case accordingly.
    1.11 + */
    1.12 +#define YY_BUF_SIZE 32768
    1.13 +#else
    1.14  #define YY_BUF_SIZE 16384
    1.15 +#endif /* __ia64__ */
    1.16  #endif
    1.17  
    1.18  /* The state buf must be large enough to hold one state per character in the main buffer.
    1.19 @@ -802,7 +810,7 @@
    1.20  static void zconf_endhelp(void);
    1.21  static void zconf_endfile(void);
    1.22  
    1.23 -void new_string(void)
    1.24 +static void new_string(void)
    1.25  {
    1.26  	text = malloc(START_STRSIZE);
    1.27  	text_asize = START_STRSIZE;
    1.28 @@ -810,7 +818,7 @@
    1.29  	*text = 0;
    1.30  }
    1.31  
    1.32 -void append_string(const char *str, int size)
    1.33 +static void append_string(const char *str, int size)
    1.34  {
    1.35  	int new_size = text_size + size + 1;
    1.36  	if (new_size > text_asize) {
    1.37 @@ -824,7 +832,7 @@
    1.38  	text[text_size] = 0;
    1.39  }
    1.40  
    1.41 -void alloc_string(const char *str, int size)
    1.42 +static void alloc_string(const char *str, int size)
    1.43  {
    1.44  	text = malloc(size + 1);
    1.45  	memcpy(text, str, size);
    1.46 @@ -914,7 +922,12 @@
    1.47  
    1.48  /* Amount of stuff to slurp up with each read. */
    1.49  #ifndef YY_READ_BUF_SIZE
    1.50 +#ifdef __ia64__
    1.51 +/* On IA-64, the buffer size is 16k, not 8k */
    1.52 +#define YY_READ_BUF_SIZE 16384
    1.53 +#else
    1.54  #define YY_READ_BUF_SIZE 8192
    1.55 +#endif /* __ia64__ */
    1.56  #endif
    1.57  
    1.58  /* Copy whatever the last rule matched to the standard output. */
    1.59 @@ -922,7 +935,7 @@
    1.60  /* This used to be an fputs(), but since the string might contain NUL's,
    1.61   * we now use fwrite().
    1.62   */
    1.63 -#define ECHO fwrite( zconftext, zconfleng, 1, zconfout )
    1.64 +#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
    1.65  #endif
    1.66  
    1.67  /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
    1.68 @@ -2060,8 +2073,8 @@
    1.69  
    1.70  /** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
    1.71   * scan from a @e copy of @a bytes.
    1.72 - * @param bytes the byte buffer to scan
    1.73 - * @param len the number of bytes in the buffer pointed to by @a bytes.
    1.74 + * @param yybytes the byte buffer to scan
    1.75 + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
    1.76   * 
    1.77   * @return the newly allocated buffer state object.
    1.78   */
    1.79 @@ -2350,37 +2363,45 @@
    1.80  
    1.81  	current_file = file_lookup(name);
    1.82  	current_file->lineno = 1;
    1.83 -	current_file->flags = FILE_BUSY;
    1.84  }
    1.85  
    1.86  void zconf_nextfile(const char *name)
    1.87  {
    1.88 +	struct file *iter;
    1.89  	struct file *file = file_lookup(name);
    1.90  	struct buffer *buf = malloc(sizeof(*buf));
    1.91  	memset(buf, 0, sizeof(*buf));
    1.92  
    1.93  	current_buf->state = YY_CURRENT_BUFFER;
    1.94 -	zconfin = zconf_fopen(name);
    1.95 +	zconfin = zconf_fopen(file->name);
    1.96  	if (!zconfin) {
    1.97 -		printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
    1.98 +		printf("%s:%d: can't open file \"%s\"\n",
    1.99 +		    zconf_curname(), zconf_lineno(), file->name);
   1.100  		exit(1);
   1.101  	}
   1.102  	zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
   1.103  	buf->parent = current_buf;
   1.104  	current_buf = buf;
   1.105  
   1.106 -	if (file->flags & FILE_BUSY) {
   1.107 -		printf("%s:%d: do not source '%s' from itself\n",
   1.108 -		       zconf_curname(), zconf_lineno(), name);
   1.109 -		exit(1);
   1.110 +	for (iter = current_file->parent; iter; iter = iter->parent ) {
   1.111 +		if (!strcmp(current_file->name,iter->name) ) {
   1.112 +			printf("%s:%d: recursive inclusion detected. "
   1.113 +			       "Inclusion path:\n  current file : '%s'\n",
   1.114 +			       zconf_curname(), zconf_lineno(),
   1.115 +			       zconf_curname());
   1.116 +			iter = current_file->parent;
   1.117 +			while (iter && \
   1.118 +			       strcmp(iter->name,current_file->name)) {
   1.119 +				printf("  included from: '%s:%d'\n",
   1.120 +				       iter->name, iter->lineno-1);
   1.121 +				iter = iter->parent;
   1.122 +			}
   1.123 +			if (iter)
   1.124 +				printf("  included from: '%s:%d'\n",
   1.125 +				       iter->name, iter->lineno+1);
   1.126 +			exit(1);
   1.127 +		}
   1.128  	}
   1.129 -	if (file->flags & FILE_SCANNED) {
   1.130 -		printf("%s:%d: file '%s' is already sourced from '%s'\n",
   1.131 -		       zconf_curname(), zconf_lineno(), name,
   1.132 -		       file->parent->name);
   1.133 -		exit(1);
   1.134 -	}
   1.135 -	file->flags |= FILE_BUSY;
   1.136  	file->lineno = 1;
   1.137  	file->parent = current_file;
   1.138  	current_file = file;
   1.139 @@ -2390,8 +2411,6 @@
   1.140  {
   1.141  	struct buffer *parent;
   1.142  
   1.143 -	current_file->flags |= FILE_SCANNED;
   1.144 -	current_file->flags &= ~FILE_BUSY;
   1.145  	current_file = current_file->parent;
   1.146  
   1.147  	parent = current_buf->parent;
   1.148 @@ -2409,7 +2428,7 @@
   1.149  	return current_pos.lineno;
   1.150  }
   1.151  
   1.152 -char *zconf_curname(void)
   1.153 +const char *zconf_curname(void)
   1.154  {
   1.155  	return current_pos.file ? current_pos.file->name : "<none>";
   1.156  }