mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 1210329 - Remove support for line endings munging in the preprocessor. r=gps
It was added back in
5147d5c69f
for unclear reasons (and the lack of bug number doesn't help), and hasn't been
used, as far as I can see in the gecko-dev history, other than in bug 206029,
which is the only use currently in the tree.
Bug 206029 was working around the Flash player installer modifying Firefox's
prefs file and not dealing with it properly or something depending on the line
endings. 11 years later, all prefs files except channel-prefs.js are in
omni.ja, so obviously, bug 206029 doesn't actually apply anymore.
So, let's simplify it all and get rid of this.
This commit is contained in:
parent
760213a14e
commit
7f68f92edb
@ -1152,11 +1152,6 @@ ifneq (,$(DIST_SUBDIR)$(XPI_NAME)$(LIBXUL_SDK))
|
||||
PREF_DIR = defaults/preferences
|
||||
endif
|
||||
|
||||
# on win32, pref files need CRLF line endings... see bug 206029
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
PREF_PPFLAGS += --line-endings=crlf
|
||||
endif
|
||||
|
||||
ifneq ($(PREF_JS_EXPORTS),)
|
||||
ifndef NO_DIST_INSTALL
|
||||
PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
|
||||
|
@ -117,9 +117,6 @@ class FasterMakeBackend(CommonBackend):
|
||||
|
||||
dest = mozpath.join(obj.install_target, pref_dir,
|
||||
mozpath.basename(obj.path))
|
||||
# on win32, pref files need CRLF line endings... see bug 206029
|
||||
if self.environment.substs['OS_ARCH'] == 'WINNT':
|
||||
defines.append('--line-endings=crlf')
|
||||
# We preprocess these, but they don't necessarily have preprocessor
|
||||
# directives, so tell the preprocessor to not complain about that.
|
||||
defines.append('--silence-missing-directive-warnings')
|
||||
|
@ -274,7 +274,7 @@ class Preprocessor:
|
||||
self.key = MSG
|
||||
RuntimeError.__init__(self, (self.file, self.line, self.key, context))
|
||||
|
||||
def __init__(self, line_endings='\n', defines=None, marker='#'):
|
||||
def __init__(self, defines=None, marker='#'):
|
||||
self.context = Context()
|
||||
for k,v in {'FILE': '',
|
||||
'LINE': 0,
|
||||
@ -311,7 +311,6 @@ class Preprocessor:
|
||||
self.cmds[cmd] = (level, getattr(self, 'do_' + cmd))
|
||||
self.out = sys.stdout
|
||||
self.setMarker(marker)
|
||||
self.LE = line_endings
|
||||
self.varsubst = re.compile('@(?P<VAR>\w+)@', re.U)
|
||||
self.includes = set()
|
||||
self.silenceMissingDirectiveWarnings = False
|
||||
@ -325,12 +324,6 @@ class Preprocessor:
|
||||
sys.stderr.write('{0}: WARNING: no useful preprocessor directives found\n'.format(file))
|
||||
pass
|
||||
|
||||
def setLineEndings(self, aLE):
|
||||
"""
|
||||
Set the line endings to be used for output.
|
||||
"""
|
||||
self.LE = {'cr': '\x0D', 'lf': '\x0A', 'crlf': '\x0D\x0A'}[aLE]
|
||||
|
||||
def setMarker(self, aMarker):
|
||||
"""
|
||||
Set the marker to be used for processing directives.
|
||||
@ -373,7 +366,6 @@ class Preprocessor:
|
||||
rv = Preprocessor()
|
||||
rv.context.update(self.context)
|
||||
rv.setMarker(self.marker)
|
||||
rv.LE = self.LE
|
||||
rv.out = self.out
|
||||
return rv
|
||||
|
||||
@ -422,16 +414,12 @@ class Preprocessor:
|
||||
self.writtenLines += 1
|
||||
ln = self.context['LINE']
|
||||
if self.writtenLines != ln:
|
||||
self.out.write('//@line {line} "{file}"{le}'.format(line=ln,
|
||||
file=self.context['FILE'],
|
||||
le=self.LE))
|
||||
self.out.write('//@line {line} "{file}"\n'.format(line=ln,
|
||||
file=self.context['FILE']))
|
||||
self.writtenLines = ln
|
||||
filteredLine = self.applyFilters(aLine)
|
||||
if filteredLine != aLine:
|
||||
self.actionLevel = 2
|
||||
# ensure our line ending. Only need to handle \n, as we're reading
|
||||
# with universal line ending support, at least for files.
|
||||
filteredLine = re.sub('\n', self.LE, filteredLine)
|
||||
self.out.write(filteredLine)
|
||||
|
||||
def handleCommandLine(self, args, defaultToStdin = False):
|
||||
@ -504,8 +492,6 @@ class Preprocessor:
|
||||
del self.context[value]
|
||||
def handleF(option, opt, value, parser):
|
||||
self.do_filter(value)
|
||||
def handleLE(option, opt, value, parser):
|
||||
self.setLineEndings(value)
|
||||
def handleMarker(option, opt, value, parser):
|
||||
self.setMarker(value)
|
||||
def handleSilenceDirectiveWarnings(option, opt, value, parse):
|
||||
@ -524,9 +510,6 @@ class Preprocessor:
|
||||
'instead of stdout')
|
||||
p.add_option('--depend', type="string", default=None, metavar="FILENAME",
|
||||
help='Generate dependencies in the given file')
|
||||
p.add_option('--line-endings', action='callback', callback=handleLE,
|
||||
type="string", metavar="[cr|lr|crlf]",
|
||||
help='Use the specified line endings [Default: OS dependent]')
|
||||
p.add_option('--marker', action='callback', callback=handleMarker,
|
||||
type="string",
|
||||
help='Use the specified marker instead of #')
|
||||
@ -683,7 +666,7 @@ class Preprocessor:
|
||||
lst.append('\n') # add back the newline
|
||||
self.write(reduce(lambda x, y: x+y, lst, ''))
|
||||
def do_literal(self, args):
|
||||
self.write(args + self.LE)
|
||||
self.write(args + '\n')
|
||||
def do_filter(self, args):
|
||||
filters = [f for f in args.split(' ') if hasattr(self, 'filter_' + f)]
|
||||
if len(filters) == 0:
|
||||
@ -796,9 +779,8 @@ class Preprocessor:
|
||||
|
||||
def preprocess(includes=[sys.stdin], defines={},
|
||||
output = sys.stdout,
|
||||
line_endings='\n', marker='#'):
|
||||
pp = Preprocessor(line_endings=line_endings,
|
||||
defines=defines,
|
||||
marker='#'):
|
||||
pp = Preprocessor(defines=defines,
|
||||
marker=marker)
|
||||
for f in includes:
|
||||
with open(f, 'rU') as input:
|
||||
|
@ -440,12 +440,6 @@ class TestPreprocessor(unittest.TestCase):
|
||||
'#endif',
|
||||
])
|
||||
|
||||
def test_lineEndings(self):
|
||||
with MockedOpen({'f': 'first\n#literal second\n'}):
|
||||
self.pp.setLineEndings('cr')
|
||||
self.pp.do_include('f')
|
||||
self.assertEqual(self.pp.out.getvalue(), "first\rsecond\r")
|
||||
|
||||
def test_filterDefine(self):
|
||||
self.do_include_pass([
|
||||
'#filter substitution',
|
||||
|
Loading…
x
Reference in New Issue
Block a user