plug-ins: don't fail loading gflare files with Windows line endings

There was a report on reddit that the flare files on Windows were
stored with Windows (\r\n) line endings and that gradient flare did
not recognize these flare files.

Since these files are text files there is no reason not to accept
windows line endings. To do this, we adjust the header to not include
the line feed and check for the header as a prefix instead of the
whole line including line ending.

Also adjust saving to add the line feed separately.
This commit is contained in:
Jacob Boerema 2026-02-07 13:31:21 -05:00
parent 0d59f00b36
commit fa0e95941d

View file

@ -71,7 +71,7 @@
#define GRADIENT_RESOLUTION 360
#define GFLARE_NAME_MAX 256
#define GFLARE_FILE_HEADER "GIMP GFlare 0.25\n"
#define GFLARE_FILE_HEADER "GIMP GFlare 0.25"
#define SFLARE_NUM 30
#define DLG_PREVIEW_WIDTH 256
@ -1366,8 +1366,8 @@ gflare_load (const gchar *filename,
return NULL;
}
if (fgets (header, sizeof(header), fp) == NULL
|| strcmp (header, GFLARE_FILE_HEADER) != 0)
if (fgets (header, sizeof(header), fp) == NULL ||
! g_str_has_prefix (header, GFLARE_FILE_HEADER))
{
g_warning (_("'%s' is not a valid GFlare file."),
gimp_filename_to_utf8 (filename));
@ -1588,7 +1588,7 @@ gflare_save (GFlare *gflare)
return;
}
fprintf (fp, "%s", GFLARE_FILE_HEADER);
fprintf (fp, "%s\n", GFLARE_FILE_HEADER);
g_ascii_dtostr (buf[0],
G_ASCII_DTOSTR_BUF_SIZE, gflare->glow_opacity);
fprintf (fp, "%s %s\n", buf[0], gflare_modes[gflare->glow_mode]);