Changeset 3300
- Timestamp:
- 05/20/06 17:24:37 (7 years ago)
- Location:
- lm-sensors/trunk/lib
- Files:
-
- 1 added
- 2 modified
-
conf-lex.l (modified) (3 diffs)
-
init.c (modified) (3 diffs)
-
scanner.h (added)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/conf-lex.l
r3296 r3300 26 26 #include "conf-parse.h" 27 27 #include "error.h" 28 #include "scanner.h" 28 29 29 30 static int buffer_count; … … 49 50 50 51 %option nodefault 52 %option noyywrap 51 53 %option yylineno 52 54 %option nounput … … 270 272 %% 271 273 272 int sensors_yywrap(void) 274 /* 275 Do the buffer handling manually. This allows us to scan as many 276 config files as we need to, while cleaning up properly after each 277 one. The "BEGIN(0)" line ensures that we start in the default state, 278 even if e.g. the previous config file was syntactically broken. 279 280 Returns 0 if successful, !0 otherwise. 281 */ 282 283 static YY_BUFFER_STATE scan_buf = (YY_BUFFER_STATE)0; 284 285 int sensors_scanner_init(FILE *input) 273 286 { 274 yy_delete_buffer(YY_CURRENT_BUFFER); 275 return 1; 287 BEGIN(0); 288 if (!(scan_buf = sensors_yy_create_buffer(input, YY_BUF_SIZE))) 289 return -1; 290 291 sensors_yy_switch_to_buffer(scan_buf); 292 return 0; 276 293 } 277 294 295 void sensors_scanner_exit(void) 296 { 297 sensors_yy_delete_buffer(scan_buf); 298 scan_buf = (YY_BUFFER_STATE)0; 299 } 300 -
lm-sensors/trunk/lib/init.c
r3293 r3300 27 27 #include "conf.h" 28 28 #include "sysfs.h" 29 #include "scanner.h" 29 30 30 31 static void free_proc_chips_entry(sensors_proc_chips_entry entry); … … 49 50 return res; 50 51 } 51 sensors_yyin = input; 52 if ((res = sensors_scanner_init(input))) 53 return -SENSORS_ERR_PARSE; 52 54 if ((res = sensors_yyparse())) 53 55 return -SENSORS_ERR_PARSE; … … 60 62 { 61 63 int i; 64 65 sensors_scanner_exit(); 62 66 63 67 for (i = 0; i < sensors_proc_chips_count; i++)
