Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
23ff7af0
authored
2013-11-28 11:56:13 +0800
by
smallfish
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update logic for check ini comments
1 parent
9cc2e723
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
config/ini.go
config/ini.go
View file @
23ff7af
...
...
@@ -14,8 +14,8 @@ import (
var
(
DEFAULT_SECTION
=
"DEFAULT"
b
Comment
=
[]
byte
{
'#'
}
alterComment
=
[]
byte
{
';'
}
b
NumComment
=
[]
byte
{
'#'
}
// number sign
bSemComment
=
[]
byte
{
';'
}
// semicolon
bEmpty
=
[]
byte
{}
bEqual
=
[]
byte
{
'='
}
bDQuote
=
[]
byte
{
'"'
}
...
...
@@ -58,20 +58,21 @@ func (ini *IniConfig) Parse(name string) (ConfigContainer, error) {
}
line
=
bytes
.
TrimSpace
(
line
)
if
bytes
.
HasPrefix
(
line
,
bComment
)
{
line
=
bytes
.
TrimLeft
(
line
,
"#"
)
line
=
bytes
.
TrimLeftFunc
(
line
,
unicode
.
IsSpace
)
comment
.
Write
(
line
)
comment
.
WriteByte
(
'\n'
)
continue
var
bComment
[]
byte
switch
{
case
bytes
.
HasPrefix
(
line
,
bNumComment
)
:
bComment
=
bNumComment
case
bytes
.
HasPrefix
(
line
,
bSemComment
)
:
bComment
=
bSemComment
}
if
b
ytes
.
HasPrefix
(
line
,
alterComment
)
{
line
=
bytes
.
TrimLeft
(
line
,
";"
)
if
b
Comment
!=
nil
{
line
=
bytes
.
TrimLeft
(
line
,
string
(
bComment
)
)
line
=
bytes
.
TrimLeftFunc
(
line
,
unicode
.
IsSpace
)
comment
.
Write
(
line
)
comment
.
WriteByte
(
'\n'
)
continue
}
if
bytes
.
HasPrefix
(
line
,
sectionStart
)
&&
bytes
.
HasSuffix
(
line
,
sectionEnd
)
{
section
=
string
(
line
[
1
:
len
(
line
)
-
1
])
if
comment
.
Len
()
>
0
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment