Replace skipPast with strings.TrimPrefix.
There was a bug in skipPast; it was skipping to the start of the string, rather than the end of it. But more of an issue is that it would skip if it was in the middle of the string, which caused problems when STACK_OF(FOO) was used as a parameter. At some point, we'll probably need to give this a real C declaration parser. We still have declarations (like those that return function pointers) which we can't parse. But for now let's clear the low-hanging fruit. Change-Id: Ic2cee452cc8cf6887a6ff1b00cea353cec361955 Reviewed-on: https://boringssl-review.googlesource.com/5875 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
ee0c82789a
commit
361ecc0236
13
util/doc.go
13
util/doc.go
@ -189,14 +189,6 @@ func extractDecl(lines []string, lineNo int) (decl string, rest []string, restLi
|
||||
return
|
||||
}
|
||||
|
||||
func skipPast(s, skip string) string {
|
||||
i := strings.Index(s, skip)
|
||||
if i > 0 {
|
||||
return s[i:]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func skipLine(s string) string {
|
||||
i := strings.Index(s, "\n")
|
||||
if i > 0 {
|
||||
@ -224,8 +216,9 @@ func getNameFromDecl(decl string) (string, bool) {
|
||||
}
|
||||
return decl[:i], true
|
||||
}
|
||||
decl = skipPast(decl, "STACK_OF(")
|
||||
decl = skipPast(decl, "LHASH_OF(")
|
||||
decl = strings.TrimPrefix(decl, "OPENSSL_EXPORT ")
|
||||
decl = strings.TrimPrefix(decl, "STACK_OF(")
|
||||
decl = strings.TrimPrefix(decl, "LHASH_OF(")
|
||||
i := strings.Index(decl, "(")
|
||||
if i < 0 {
|
||||
return "", false
|
||||
|
Loading…
Reference in New Issue
Block a user