Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Configfile include
12-22-2010, 02:35 AM,
#1
Configfile include
I was reading some of the CONFIG class while updating the wiki page about the format. I noticed a new undocumented feature whereupon one file can include another file. I'm just curious what this is used for and how it behaves...

For instance, what if the current file defines setting "A" in section "1", and the included file has a section "1" with only a setting "B". From my reading of the code, it looks as if there will be no section "1" setting "A" at all. It also looks like it will clear out the "" section even if there is nothing in it.

I think because of the recursive nature of the implementation, it would enter an infinite loop with a pair of files that include each other.

I haven't tested this yet, but if my interpretation is correct, I think this should be fixed. A better way to handle includes might be to scan the file for include lines and load all the includes as separate CONFIG objects, then copy the sections of data into the current object. After all that, re-scan the file, ignoring all include lines, and adding to/overwriting settings in existing (imported) sections. Another way (which would avoid scanning the file twice) would be to enforce a limitation that includes must come before all settings and sections, logging a warning (and ignoring) any include lines that come after the first setting or section heading.
Reply


Messages In This Thread
Configfile include - by thelusiv - 12-22-2010, 02:35 AM
[No subject] - by NaN - 12-22-2010, 06:45 AM
[No subject] - by thelusiv - 12-22-2010, 10:17 AM
[No subject] - by NaN - 12-22-2010, 11:54 AM
[No subject] - by thelusiv - 12-22-2010, 01:12 PM
[No subject] - by NaN - 12-22-2010, 02:47 PM
[No subject] - by thelusiv - 12-23-2010, 08:40 AM
[No subject] - by NaN - 12-23-2010, 09:08 AM
[No subject] - by thelusiv - 12-23-2010, 11:18 AM
[No subject] - by NaN - 12-23-2010, 12:00 PM
[No subject] - by thelusiv - 12-27-2010, 02:43 AM
[No subject] - by joevenzon_phpbb2_import3 - 12-27-2010, 11:37 AM
[No subject] - by NaN - 12-27-2010, 08:10 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)