Re: [PATCH] fc-list: Exit with an error for invalid patterns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 24, 2013 at 06:01:58PM +0900, Akira TAGOH wrote:
> On Tue, Sep 24, 2013 at 1:06 PM, W. Trevor King <wking@xxxxxxxxxx> wrote:
> > That would be true if FcListPatternMatchAny wasn't an internal
> > function:
> >
> >   $ git --no-pager grep FcListPatternMatchAny
> >   src/fccfg.c:    if (FcListPatternMatchAny (patterns->fonts[i], font))
> >   src/fcint.h:FcListPatternMatchAny (const FcPattern *p,
> >   src/fclist.c:FcListPatternMatchAny (const FcPattern *p,
> >   src/fclist.c:       if (FcListPatternMatchAny (p,               /* pattern */
> >
> > I'm also not sure it makes sense to have different handling for NULL
> > FcPatterns and non-NULL FcPatterns with no elements, since the comment
> > for FcListPatternMatchAny says:
> 
> Talking about NULL FcPattern being introduced by FcNameParse() would
> means no valid patterns. given that holding that state and calling
> FcFontList() would ends up to the same result because of no such fonts
> matched to that pattern. and usually not expecting to see NULL pattern
> to any APIs. they should use the empty FcPattern instead.

Ok, it looks like you want different handling for NULL and empty
patterns.  I was just making sure it was a conscious decision ;).

> Or applications shouldn't simply continue to work if FcNameParse()
> failed in this case.

And that's what the !pat check in fc-match.c, fc-pattern.c, and my
patch for fc-list.c does ;).  Maybe we want both my patch (actively
die in fc-list on bad patterns and out-of-memory errors) and yours
(don't crash if a programmer forgets to check for bad patterns or
out-of-memory errors)?  One benefit would be that invalid patterns
return an error code, while the new master does not:

  $ LD_LIBRARY_PATH=src/.libs/ ./fc-list/.libs/fc-list :charset=xyz
  $ echo $?
  0

since it thinks it successfully searched for the unmatchable NULL
pattern.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux