File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,33 @@ load("@bazel_skylib//lib:sets.bzl", "sets")
55load ("@cgrindel_bazel_starlib//bzllib:defs.bzl" , "lists" )
66load (":apple_builtin_frameworks.bzl" , "apple_builtin_frameworks" )
77
8- _pound_import = "#import "
9- _pound_import_len = len (_pound_import )
108_at_import = "@import "
119_at_import_len = len (_at_import )
1210
1311def _parse_pound_import (line ):
14- import_idx = line .find (_pound_import )
15- if import_idx < 0 :
16- return None
17- start_idx = import_idx + _pound_import_len
1812 line_len = len (line )
1913
14+ # Find the pound sign
15+ pound_idx = line .find ("#" )
16+ if pound_idx < 0 :
17+ return None
18+ start_idx = pound_idx + 1
19+
20+ # Find import
21+ begin_of_import_idx = - 1
22+ for idx in range (start_idx , line_len ):
23+ char = line [idx ]
24+ if char == " " or char == "\t " :
25+ continue
26+ elif char == "i" :
27+ begin_of_import_idx = idx
28+ break
29+ else :
30+ return None
31+ if not line [begin_of_import_idx :].startswith ("import" ):
32+ return None
33+ start_idx = begin_of_import_idx + len ("import" )
34+
2035 # Find the opening bracket
2136 open_bracket_idx = - 1
2237 for idx in range (start_idx , line_len ):
Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ def _parse_for_imported_framework_test(ctx):
3232""" ,
3333 exp = "CoreTelephony" ,
3434 ),
35+ struct (
36+ msg = "# import, the pound is not adjacent to import " ,
37+ line = """\
38+ # import <SystemConfiguration/SystemConfiguration.h>
39+ """ ,
40+ exp = "SystemConfiguration" ,
41+ ),
3542 struct (
3643 msg = "#import dir/header with brackets, is not framework" ,
3744 line = """\
You can’t perform that action at this time.
0 commit comments