Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1526)

Side by Side Diff: pylib/gyp/input.py

Issue 8937016: Add a test for escaping of backslashes in list expansion (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/variables/commands/commands.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from compiler.ast import Const 5 from compiler.ast import Const
6 from compiler.ast import Dict 6 from compiler.ast import Dict
7 from compiler.ast import Discard 7 from compiler.ast import Discard
8 from compiler.ast import List 8 from compiler.ast import List
9 from compiler.ast import Module 9 from compiler.ast import Module
10 from compiler.ast import Node 10 from compiler.ast import Node
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 if expand_to_list: 730 if expand_to_list:
731 # Expanding in list context. It's guaranteed that there's only one 731 # Expanding in list context. It's guaranteed that there's only one
732 # replacement to do in |input_str| and that it's this replacement. See 732 # replacement to do in |input_str| and that it's this replacement. See
733 # above. 733 # above.
734 if isinstance(replacement, list): 734 if isinstance(replacement, list):
735 # If it's already a list, make a copy. 735 # If it's already a list, make a copy.
736 output = replacement[:] 736 output = replacement[:]
737 else: 737 else:
738 # Split it the same way sh would split arguments. 738 # Split it the same way sh would split arguments.
739 output = shlex.split(str(replacement)) 739 output = shlex.split(str(replacement).replace('\\', '\\\\'))
Mark Mentovai 2011/12/14 17:53:54 Are you sure that this is right? Seems perverse. T
tony 2011/12/14 18:41:39 Backslash is only special when being passed to a c
740 else: 740 else:
741 # Expanding in string context. 741 # Expanding in string context.
742 encoded_replacement = '' 742 encoded_replacement = ''
743 if isinstance(replacement, list): 743 if isinstance(replacement, list):
744 # When expanding a list into string context, turn the list items 744 # When expanding a list into string context, turn the list items
745 # into a string in a way that will work with a subprocess call. 745 # into a string in a way that will work with a subprocess call.
746 # 746 #
747 # TODO(mark): This isn't completely correct. This should 747 # TODO(mark): This isn't completely correct. This should
748 # call a generator-provided function that observes the 748 # call a generator-provided function that observes the
749 # proper list-to-argument quoting rules on a specific 749 # proper list-to-argument quoting rules on a specific
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 ValidateRunAsInTarget(target, target_dict, build_file) 2346 ValidateRunAsInTarget(target, target_dict, build_file)
2347 ValidateActionsInTarget(target, target_dict, build_file) 2347 ValidateActionsInTarget(target, target_dict, build_file)
2348 2348
2349 # Generators might not expect ints. Turn them into strs. 2349 # Generators might not expect ints. Turn them into strs.
2350 TurnIntIntoStrInDict(data) 2350 TurnIntIntoStrInDict(data)
2351 2351
2352 # TODO(mark): Return |data| for now because the generator needs a list of 2352 # TODO(mark): Return |data| for now because the generator needs a list of
2353 # build files that came in. In the future, maybe it should just accept 2353 # build files that came in. In the future, maybe it should just accept
2354 # a list, and not the whole data dict. 2354 # a list, and not the whole data dict.
2355 return [flat_list, targets, data] 2355 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « no previous file | test/variables/commands/commands.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698