From: re (m11048_at_[hidden])
Date: 2005-05-16 17:25:01
> Preston A. Elder wrote:
>>The INI file parser module of program_options needs to be changed. For
>>The more common INI file comment behavior is:
>>'#' is a comment ONLY if it is the first character of the line
>>';' is a comment from that point of the line on, unless preceeded by a '\'
>>(or more accurately, an odd number of '\' characters, since you could
>>theoretically do \\\;, to translate to \; when made a string).
These rules would misparse many INI files.
On DOS and Windows, backslashes are used in file paths,
and semicolons are commonly used as separator in path and file lists.
Such lists are often stored as value strings.
The box character (#) is generally not used to start comments
in Windows ini files, though certainly some programs allow it.
Vladimir Prus wrote:
> It's the first time I hear about ';' being used as comment delimiter. Can
> you point me out to some docs which document INI format as above? Note also
> that I never say that format of config files is exactly as used by
> Windows .ini files.
From Windows 3.1 Resource Kit WIN.INI Section Settings (KB item 83433)
Format of the WIN.INI File
The WIN.INI file contains several sections, each of which consists of
a group of related settings. The sections and settings are listed in
the WIN.INI file in the following format:
In this example, [section name] is the name of a section. The
enclosing brackets () are required, and the left bracket must be in
the leftmost column on the screen.
The keyname=value statement defines the value of each setting. A
keyname is the name of a setting. It can consist of any combination of
letters and digits, and must be followed immediately by an equal sign
(=). The value can be an integer, a string, or a quoted string,
depending on the setting.
You can include comments in initialization files. You must begin each
line of a comment with a semicolon (;).
=== end quote ====================================
Actually one shouldn't even try to write a parser on Windows,
the API functions Get/SetPrivateProfileString are the preferred way
of interacting with INI files. (And the Registry is of course preferred
over ini files since win 95.)
The docs for GetPrivateProfileStringA states that
any byte values >= hex 20 are valid in keyname and value strings.
If program_options chooses to support Win32 INI files,
it should IMO not try to to parse the value strings,
the programmer has to decide what to do with them.
She may want to unescape characters in some way,
or to discard everything following a ; or # or C.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk