Sorry, but I disagree with the fix. '\r\n' <=> '\r' <=> '\n' have a clear and unambiguous interpretation. I can see emitting a warning for consistency, but there should be no reason to exit, or if there is please explain.
I would propose: > f = open(filename).read() > + if '\r\n' in f: > + f.replace('\r\n','\n') > + logging.warn("%s:0: File contains DOS-style line > endings, cannot continue" % filename) > + if '\r' in f: > + f.replace('\r','\n') > + logging.warn("%s:0: File contains Mac-style line > endings, cannot continue" % filename) > a, b = f.split("\n;;\n", 1) > p = _parse('File', a + "\n\n", filename) > if not p: raise SystemExit, 1 Of what might be easier is just to search for '\r' and report that there is a DOS or MAC style line... On Jul 4 2016 8:35 AM, Jeff Epler wrote: > Signed-off-by: Jeff Epler <jep...@unpythonic.net> > --- > Untested, natch. > > src/hal/utils/halcompile.g | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/hal/utils/halcompile.g b/src/hal/utils/halcompile.g > index ca59af3..b489979 100644 > --- a/src/hal/utils/halcompile.g > +++ b/src/hal/utils/halcompile.g > @@ -119,6 +119,10 @@ def _parse(rule, text, filename=None): > def parse(filename): > initialize() > f = open(filename).read() > + if '\r\n' in f: > + raise SystemExit, "%s:0: File contains DOS-style line > endings, cannot continue" % filename > + if '\r' in f: > + raise SystemExit, "%s:0: File contains Mac-style line > endings, cannot continue" % filename > a, b = f.split("\n;;\n", 1) > p = _parse('File', a + "\n\n", filename) > if not p: raise SystemExit, 1 ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers