[fpc-devel] fnmatch (linux), where is the external code/symbol located?

Wayne Sherman wsherman at gmail.com
Thu Oct 26 01:10:09 CEST 2023


On Tue, Oct 17, 2023 at 12:32 AM Marco van de Voort wrote:
> - Since it has perfectly fine definition in libc, my guess that this is
> some old workaround of GTK2 for some defunct version (or multiple
> varying prototypes) of fnmatch, something might have been resolved a
> decade ago already.
>
> - the symbol is never used in Lazarus to my best knowledge. Simply
> omitting the line from the GTK2 header should allow you to continue with
> your patch evaluation.

fnmatch is a libc function and AFAICT, GTK never exported a function
with the name "fnmatch".  GTK has a file named fnmatch.c which
declares "_gtk_fnmatch" with different parameters than libc fnmatch.
There is no GTK header file named fnmatch.h.  GTK "_gtk_fnmatch" is
only exposed in gtkprivate.h (likely for private / internal use only).

_gtk_fnmatch current version:
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/fnmatch.c#L249
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkprivate.h#L63

_gtk_fnmatch 2004 version (just before fpc did their gtk header conversion):
https://gitlab.gnome.org/GNOME/gtk/-/blob/3127f29ef626097dd861376f36a0914a20f4598c/gtk/fnmatch.c#L253
https://gitlab.gnome.org/GNOME/gtk/-/blob/3127f29ef626097dd861376f36a0914a20f4598c/gtk/gtkprivate.h#L102

To promote good housekeeping, and prevent strange linking behavior and
errors I propose the removal of the incorrect declaration from
./packages/gtk2/src/gtk+/gtk/fnmatch.inc:

function fnmatch(__pattern: AnsiChar; __string: AnsiChar;
  __flags: gint): gint; cdecl; external gtklib;

or remove the entire file (or move it out of gtk2 and put it where it belongs?):
./packages/gtk2/src/gtk+/gtk/fnmatch.inc

Trunk fpc fnmatch.inc version:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/gtk2/src/gtk+/gtk/fnmatch.inc

Original 2005 fpc fnmatch.inc version:
https://gitlab.com/freepascal.org/fpc/source/-/blob/3c9295f2856b775a6db83a2fde40b9992b492cb9/packages/extra/gtk2/gtk+/gtk/fnmatch.inc


More information about the fpc-devel mailing list