[Mesa-dev] [PATCH 06/11] glapi: Fix whitespace droppings when printing the license header
Dylan Baker
baker.dylan.c at gmail.com
Tue Mar 29 16:24:29 UTC 2016
Quoting Adam Jackson (2016-03-29 07:41:01)
> On Mon, 2016-03-28 at 11:19 -0700, Dylan Baker wrote:
> > Quoting Ian Romanick (2016-03-28 11:03:58)
> > >
> > > On 03/25/2016 05:33 PM, Dylan Baker wrote:
> > > >
> > > > Quoting Dylan Baker (2016-03-25 16:01:00)
> > > > >
> > > > > Quoting Adam Jackson (2016-03-24 11:10:01)
> > > > > >
> > > > > > Signed-off-by: Adam Jackson <ajax at redhat.com>
> > > > > > ---
> > > > > > src/mapi/glapi/gen/gl_XML.py | 2 +-
> > > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> > > > > > index 2e7123e..e11f6fc 100644
> > > > > > --- a/src/mapi/glapi/gen/gl_XML.py
> > > > > > +++ b/src/mapi/glapi/gen/gl_XML.py
> > > > > > @@ -130,7 +130,7 @@ class gl_print_base(object):
> > > > > > % (self.name)
> > > > > > print ''
> > > > > > print '/*'
> > > > > > - print ' * ' + self.license.replace('\n', '\n * ')
> > > > > > + print (' * ' + self.license.replace('\n', '\n * ')).replace(' \n', '\n')
> > > > > That's a brainful to parse, what about to stupid, but obvious solution:
> > > > >
> > > > > for l in self.license.split('\n'):
> > > > > print ' * {0}'.format(l)
> > > > Or, since mesa's python code seems to use C style formatters:
> > > > print ' * %s' % l
> > > Do those actually do the right thing? self.license is multiple lines of
> > > text. The old code prefixes each line after the first line with ' * '.
> > >
> > > I'm not sure how the dangling whitespace occurs in the first place. Is
> > > it in the original license text? Could we just trim it there?
> > I didn't test Ajax's solution, but mine does print what we really want.
> > It might make more sense to just put the comments in self.license.
>
> No, it doesn't (neither the format one or the %s one). Blank lines in
> the template turn into ' * ' in the generated source, where the code in
> xserver git has ' *'.
>
> Fixing the license text to just include the comment syntax seems
> simpler overall though. It's not like we're ever generating something
> besides C.
>
> - ajax
Ah, that's the problem. While we could do something like add .rstrip()
to the string, I think that just fixing this in the template would be
easier.
Somewhere I have patches that convert all of these into fairly straight
forward mako templates. I should dredge them up and rebase them.
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160329/c3664abb/attachment.sig>
More information about the mesa-dev
mailing list