[systemd-devel] [PATCH 1/9] util: Add unescape_first_word()
Lennart Poettering
lennart at poettering.net
Fri Jun 19 03:36:59 PDT 2015
On Fri, 19.06.15 10:56, Richard Maw (richard.maw at codethink.co.uk) wrote:
> On Thu, Jun 18, 2015 at 08:30:22PM +0200, Lennart Poettering wrote:
> > On Thu, 28.05.15 13:02, Richard Maw (richard.maw at codethink.co.uk) wrote:
> >
> > > This is a superset of the functionality of unquote_first_word, allowing
> > > non-whitespace separators, and doesn't interpret quotes unless
> > > UNQUOTE_QUOTES is included in flags.
> >
> > Hmm, makes sense, but I'd actually just have one function
> > extract_first_word() then, which replaces unquote_first_word() but has
> > the signature of your unescape_first_word(). It would take the
> > separators parameter, which would default to WHITESPACE if passed as
> > NULL. THe flags should all be renamed EXTRACT_xyz instead of
> > UNQUOTE_xyz then, and EXTRACT_UNQUOTE should be a prominent flag.
>
> Thanks, I was sweating the nomeclature and wasn't happy with what I came up
> with, but couldn't think of anything better.
>
> > Then, all our current users of unquote_first_word() should be changed
> > to use this new call.
> >
> > Does that make sense?
>
> Sure, I was just a little wary of making such wide changes across
> the codebase.
We are not afraid of refactoring things like this, if it makes our
internal APIs simpler and cleaner!
> I also saw a couple of TODOs to convert uses of FOREACH_WORD family to the
> unquote_many_words family. I'll see if I can feasibly convert those while I'm
> changing string handling elsewhere.
Yes, we should stop using FOREACH_WORD, and move everything to
extract_first_word() loops, but I fear that's a major
endeavour... Would love patches for that, though.
Moving things over would slightly change behaviour of systemd when we
parse things, but I am sure it's a good thing actually.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list