aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/src/ic_pp.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2012-06-08 17:33:41 +0200
committerLukas Larsson <[email protected]>2012-06-08 17:33:41 +0200
commit1fc1233587a00b318ce15fd520b057dee726a7fc (patch)
tree1a7c446ee60b922fb11c89c930f32f55719015f1 /lib/ic/src/ic_pp.erl
parentd7554d5b53ef85861bb5593fba38f65c40faca33 (diff)
parent3341122a92e71ade3edc7ecaadab9f55da29e20d (diff)
downloadotp-1fc1233587a00b318ce15fd520b057dee726a7fc.tar.gz
otp-1fc1233587a00b318ce15fd520b057dee726a7fc.tar.bz2
otp-1fc1233587a00b318ce15fd520b057dee726a7fc.zip
Merge branch 'maint'
* maint: Update to work with space in include path Update to work with whitespace in exec path
Diffstat (limited to 'lib/ic/src/ic_pp.erl')
-rw-r--r--lib/ic/src/ic_pp.erl39
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/ic/src/ic_pp.erl b/lib/ic/src/ic_pp.erl
index 8b53473caa..50eeeab48c 100644
--- a/lib/ic/src/ic_pp.erl
+++ b/lib/ic/src/ic_pp.erl
@@ -1894,23 +1894,37 @@ include_dir(Flags) when is_list(Flags)->
include_dir(_Flags) ->
[].
-include_dir(Flags,IncDir) ->
+include_dir(Flags,IncDirs) ->
case string:str(Flags,"-I") of
0 ->
- lists:reverse(IncDir);
+ lists:reverse(IncDirs);
X ->
- Rem2 = string:sub_string(Flags, X+2),
- Rem = string:strip(Rem2, left),
- Y = string:str(Rem," "),
- case string:str(Rem," ") of
- 0 ->
- lists:reverse([string:sub_string(Rem, Y+1)|IncDir]);
- Y ->
- include_dir(string:sub_string(Rem, Y+1),
- [string:sub_string(Rem,1,Y-1)|IncDir])
- end
+ {NewDir, RemainingFlags} =
+ gobble_inc_dir(string:sub_string(Flags, X+2),nq,[]),
+ include_dir(RemainingFlags, [NewDir|IncDirs])
end.
+% nq = not-quoted, q = quoted.
+% Possible strange scenarios:
+% /usr/test\ ing/
+% "/usr/test ing/"
+% /usr/test\"ing/
+% "/usr/test\"ing/"
+gobble_inc_dir([],nq,Acc) ->
+ % Only accept nq here, if we end up here in q mode the user has missed a "
+ {lists:reverse(Acc),[]};
+gobble_inc_dir([$\\,$"|R],Q,Acc) ->
+ gobble_inc_dir(R,Q,[$"|Acc]);
+gobble_inc_dir([$"|R],nq,Acc) ->
+ gobble_inc_dir(R,q,Acc);
+gobble_inc_dir([$"|R],q,Acc) ->
+ gobble_inc_dir(R,nq,Acc);
+gobble_inc_dir([$\\,$ |R],nq,Acc) ->
+ gobble_inc_dir(R,nq,[$ |Acc]);
+gobble_inc_dir([$ |R],nq,Acc) ->
+ {lists:reverse(Acc),R};
+gobble_inc_dir([C|R],Q,Acc) ->
+ gobble_inc_dir(R,Q,[C|Acc]).
%%===============================================================
@@ -1954,7 +1968,6 @@ find_inc_file2(FileName, [D|Rem]) ->
_ ->
D++"/"
end,
-
case catch file:read_file_info(Dir++FileName) of
{ok, _} ->
{ok, Dir++FileName};