[poppler] strndup is not universally available
Albert Astals Cid
aacid at kde.org
Mon Jan 28 11:46:31 PST 2008
A Dilluns 28 Gener 2008, Jonathan Kew va escriure:
> The patch in December to support the Adobe Glyph Naming convention
> introduced the use of strndup() into GfxFont.cc. However, strndup is
> a GNU library extension, not universally available and not defined in
> POSIX, AFAIK.
>
> Therefore, I suggest that it should be checked at configure time, and
> an alternative provided for systems that lack this function:
Thanks :-)
Commited, but please next time attach the patch as a file, it's much easier to
apply than having to get it from the mail window, unbreak spaces and finally
apply it manually :-D
Albert
>
> --- a/configure.ac
> +++ b/configure.ac
> @@ -17,6 +17,7 @@ AC_PROG_CXX
> AC_PROG_INSTALL
> AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1,
> [Defines if gettimeofday is available on your system]))
> AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines
> if localtime_r is available on your system]))
> +AC_CHECK_FUNC(strndup, AC_DEFINE(HAVE_STRNDUP, 1, [Defines if
> strndup is available on your system]))
>
> dnl Enable these unconditionally.
> AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.])
>
> --- a/poppler/GfxFont.cc
> +++ b/poppler/GfxFont.cc
> @@ -974,7 +974,13 @@ static int parseCharName(char *charName, Unicode
> *uBuf, int uLen,
> return 0; // .notdef or similar
> } else if (var_part != NULL) {
> // parse names of the form 7.oldstyle, P.swash, s.sc, etc.
> +#ifdef HAVE_STRNDUP
> char *main_part = strndup(charName, var_part - charName);
> +#else
> + char *main_part = (char*)gmalloc(var_part - charName + 1);
> + main_part[var_part - charName] = '\0';
> + (void)memcpy(main_part, charName, var_part - charName);
> +#endif
> GBool namesRecurse = gTrue, variantsRecurse = gFalse;
> int n = parseCharName(main_part, uBuf, uLen, namesRecurse,
> ligatures,
> numeric, hex, variantsRecurse);
>
> --
> Jonathan
>
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
More information about the poppler
mailing list