Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
5dfeaf27
Commit
5dfeaf27
authored
Nov 09, 2008
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of one-liner fields.
parent
aa722914
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
tools/doc_extract.c
tools/doc_extract.c
+23
-10
No files found.
tools/doc_extract.c
View file @
5dfeaf27
...
...
@@ -51,7 +51,7 @@ static bool is_blank(const char *line)
return
line
&&
line
[
strspn
(
line
,
"
\t\n
"
)]
==
'\0'
;
}
static
bool
is_section
(
const
char
*
line
)
static
bool
is_section
(
const
char
*
line
,
bool
maybe_one_liner
)
{
unsigned
int
len
;
...
...
@@ -59,21 +59,29 @@ static bool is_section(const char *line)
if
(
len
==
0
)
return
false
;
if
(
line
[
len
]
!=
':'
)
return
false
;
/* If it can be a one-liner, a space is sufficient.*/
if
(
maybe_one_liner
&&
(
line
[
len
+
1
]
==
' '
||
line
[
len
+
1
]
==
'\t'
))
return
true
;
return
line
[
len
]
==
':'
&&
is_blank
(
line
+
len
+
1
);
}
static
bool
end_section
(
const
char
*
line
)
{
return
!
line
||
is_section
(
line
);
return
!
line
||
is_section
(
line
,
true
);
}
static
unsigned
int
find_section
(
char
**
lines
,
const
char
*
name
)
static
unsigned
int
find_section
(
char
**
lines
,
const
char
*
name
,
bool
maybe_one_liner
)
{
unsigned
int
i
;
for
(
i
=
0
;
lines
[
i
];
i
++
)
{
if
(
!
is_section
(
lines
[
i
]))
if
(
!
is_section
(
lines
[
i
]
,
maybe_one_liner
))
continue
;
if
(
strncasecmp
(
lines
[
i
],
name
,
strlen
(
name
))
!=
0
)
continue
;
...
...
@@ -104,12 +112,17 @@ int main(int argc, char *argv[])
if
(
streq
(
type
,
"author"
)
||
streq
(
type
,
"maintainer"
)
||
streq
(
type
,
"licence"
))
{
line
=
find_section
(
lines
,
type
);
line
=
find_section
(
lines
,
type
,
true
);
if
(
lines
[
line
])
{
if
(
!
lines
[
line
+
1
])
errx
(
1
,
"Malformed %s, end of file"
,
type
);
puts
(
lines
[
line
+
1
]);
const
char
*
p
=
strchr
(
lines
[
line
],
':'
)
+
1
;
p
+=
strspn
(
p
,
"
\t\n
"
);
if
(
p
[
0
]
==
'\0'
)
{
/* Must be on next line. */
if
(
end_section
(
lines
[
line
+
1
]))
errx
(
1
,
"Malformed %s"
,
type
);
puts
(
lines
[
line
+
1
]);
}
else
puts
(
p
);
}
}
else
if
(
streq
(
type
,
"summary"
))
{
/* Summary comes after - on first line. */
...
...
@@ -128,7 +141,7 @@ int main(int argc, char *argv[])
while
(
!
end_section
(
lines
[
line
]))
puts
(
lines
[
line
++
]);
}
else
if
(
streq
(
type
,
"example"
))
{
line
=
find_section
(
lines
,
type
);
line
=
find_section
(
lines
,
type
,
false
);
if
(
lines
[
line
])
{
unsigned
int
strip
;
line
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment