mirror of https://github.com/GNOME/gimp.git
app/base/base.c app/core/gimp-user-install.c
2006-11-12 Michael Natterer <mitch@gimp.org> * app/base/base.c * app/core/gimp-user-install.c * app/core/gimpbrushgenerated-load.c * app/core/gimpcontainer.c * app/core/gimpgradient-load.c * app/core/gimppalette-load.c * app/core/gimpparamspecs-desc.c * app/dialogs/tips-parser.c * app/menus/plug-in-menus.c * app/plug-in/gimppluginmanager.c * app/plug-in/gimppluginprocedure.c * app/text/gimptext-parasite.c * app/tools/gimpforegroundselecttool.c * app/widgets/gimpselectiondata.c * app/xcf/xcf.c: use g_str_has_prefix() instead of strncmp().
This commit is contained in:
parent
8cbc5e652b
commit
85cecec576
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2006-11-12 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/base/base.c
|
||||
* app/core/gimp-user-install.c
|
||||
* app/core/gimpbrushgenerated-load.c
|
||||
* app/core/gimpcontainer.c
|
||||
* app/core/gimpgradient-load.c
|
||||
* app/core/gimppalette-load.c
|
||||
* app/core/gimpparamspecs-desc.c
|
||||
* app/dialogs/tips-parser.c
|
||||
* app/menus/plug-in-menus.c
|
||||
* app/plug-in/gimppluginmanager.c
|
||||
* app/plug-in/gimppluginprocedure.c
|
||||
* app/text/gimptext-parasite.c
|
||||
* app/tools/gimpforegroundselecttool.c
|
||||
* app/widgets/gimpselectiondata.c
|
||||
* app/xcf/xcf.c: use g_str_has_prefix() instead of strncmp().
|
||||
|
||||
2006-11-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* configure.in: added -Winit-self and -Wpointer-arith to CFLAGS.
|
||||
|
|
|
@ -163,7 +163,7 @@ base_toast_old_swap_files (const gchar *swap_path)
|
|||
}
|
||||
|
||||
while ((entry = g_dir_read_name (dir)) != NULL)
|
||||
if (! strncmp (entry, "gimpswap.", 9))
|
||||
if (g_str_has_prefix (entry, "gimpswap."))
|
||||
{
|
||||
/* don't try to kill swap files of running processes
|
||||
* yes, I know they might not all be gimp processes, and when you
|
||||
|
|
|
@ -461,16 +461,16 @@ user_install_migrate_files (GimpUserInstall *install)
|
|||
if (g_file_test (source, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
/* skip these files for all old versions */
|
||||
if ((strncmp (basename, "gimpswap.", 9) == 0) ||
|
||||
(strcmp (basename, "pluginrc") == 0) ||
|
||||
(strcmp (basename, "themerc") == 0) ||
|
||||
(strcmp (basename, "toolrc") == 0))
|
||||
if (g_str_has_prefix (basename, "gimpswap.") ||
|
||||
g_str_has_prefix (basename, "pluginrc") ||
|
||||
g_str_has_prefix (basename, "themerc") ||
|
||||
g_str_has_prefix (basename, "toolrc"))
|
||||
{
|
||||
goto next_file;
|
||||
}
|
||||
|
||||
/* skip menurc for gimp 2.0 since the format has changed */
|
||||
if (install->old_minor == 0 && (strncmp (basename, "menurc", 6) == 0))
|
||||
if (install->old_minor == 0 && g_str_has_prefix (basename, "menurc"))
|
||||
{
|
||||
goto next_file;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ gimp_brush_generated_load (const gchar *filename,
|
|||
if (! fgets (string, sizeof (string), file))
|
||||
goto failed;
|
||||
|
||||
if (strncmp (string, "GIMP-VBR", strlen ("GIMP-VBR")))
|
||||
if (! g_str_has_prefix (string, "GIMP-VBR"))
|
||||
{
|
||||
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
||||
_("Fatal parse error in brush file '%s': "
|
||||
|
@ -96,9 +96,9 @@ gimp_brush_generated_load (const gchar *filename,
|
|||
if (! fgets (string, sizeof (string), file))
|
||||
goto failed;
|
||||
|
||||
if (strncmp (string, "1.0", 3))
|
||||
if (! g_str_has_prefix (string, "1.0"))
|
||||
{
|
||||
if (strncmp (string, "1.5", 3))
|
||||
if (! g_str_has_prefix (string, "1.5"))
|
||||
{
|
||||
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
||||
_("Fatal parse error in brush file '%s': "
|
||||
|
|
|
@ -864,7 +864,7 @@ gimp_container_add_handler (GimpContainer *container,
|
|||
g_return_val_if_fail (signame != NULL, 0);
|
||||
g_return_val_if_fail (callback != NULL, 0);
|
||||
|
||||
if (strncmp (signame, "notify::", 8))
|
||||
if (! g_str_has_prefix (signame, "notify::"))
|
||||
g_return_val_if_fail (g_signal_lookup (signame,
|
||||
container->children_type), 0);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ gimp_gradient_load (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (strncmp (line, "GIMP Gradient", strlen ("GIMP Gradient")))
|
||||
if (! g_str_has_prefix (line, "GIMP Gradient"))
|
||||
{
|
||||
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
||||
_("Fatal parse error in gradient file '%s': "
|
||||
|
@ -101,7 +101,7 @@ gimp_gradient_load (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (! strncmp (line, "Name: ", strlen ("Name: ")))
|
||||
if (g_str_has_prefix (line, "Name: "))
|
||||
{
|
||||
gchar *utf8;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ gimp_palette_load (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (strncmp (str, "GIMP Palette", strlen ("GIMP Palette")))
|
||||
if (! g_str_has_prefix (str, "GIMP Palette"))
|
||||
{
|
||||
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
||||
_("Fatal parse error in palette file '%s': "
|
||||
|
@ -115,7 +115,7 @@ gimp_palette_load (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (! strncmp (str, "Name: ", strlen ("Name: ")))
|
||||
if (g_str_has_prefix (str, "Name: "))
|
||||
{
|
||||
gchar *utf8;
|
||||
|
||||
|
@ -136,7 +136,7 @@ gimp_palette_load (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (! strncmp (str, "Columns: ", strlen ("Columns: ")))
|
||||
if (g_str_has_prefix (str, "Columns: "))
|
||||
{
|
||||
gint columns;
|
||||
|
||||
|
@ -443,16 +443,16 @@ gimp_palette_load_detect_format (const gchar *filename)
|
|||
{
|
||||
if (read (fd, header, sizeof (header)) == sizeof (header))
|
||||
{
|
||||
if (strncmp (header + 0, "RIFF", 4) == 0 &&
|
||||
strncmp (header + 8, "PAL data", 8) == 0)
|
||||
if (g_str_has_prefix (header + 0, "RIFF") &&
|
||||
g_str_has_prefix (header + 8, "PAL data"))
|
||||
{
|
||||
format = GIMP_PALETTE_FILE_FORMAT_RIFF_PAL;
|
||||
}
|
||||
else if (strncmp (header, "GIMP Palette", 12) == 0)
|
||||
else if (g_str_has_prefix (header, "GIMP Palette"))
|
||||
{
|
||||
format = GIMP_PALETTE_FILE_FORMAT_GPL;
|
||||
}
|
||||
else if (strncmp (header, "JASC-PAL", 8) == 0)
|
||||
else if (g_str_has_prefix (header, "JASC-PAL"))
|
||||
{
|
||||
format = GIMP_PALETTE_FILE_FORMAT_PSP_PAL;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ gimp_param_spec_enum_desc (GParamSpec *pspec)
|
|||
if (n > 0)
|
||||
g_string_append (str, ", ");
|
||||
|
||||
if (G_LIKELY (strncmp ("GIMP_", enum_value->value_name, 5) == 0))
|
||||
if (G_LIKELY (g_str_has_prefix (enum_value->value_name, "GIMP_")))
|
||||
name = gimp_canonicalize_identifier (enum_value->value_name + 5);
|
||||
else
|
||||
name = gimp_canonicalize_identifier (enum_value->value_name);
|
||||
|
|
|
@ -190,9 +190,10 @@ gimp_tips_from_file (const gchar *filename,
|
|||
*/
|
||||
tips_locale = _("tips-locale:C");
|
||||
|
||||
if (strncmp (tips_locale, "tips-locale:", 12) == 0)
|
||||
if (g_str_has_prefix (tips_locale, "tips-locale:"))
|
||||
{
|
||||
tips_locale += 12;
|
||||
tips_locale += strlen ("tips-locale:");
|
||||
|
||||
if (*tips_locale && *tips_locale != 'C')
|
||||
parser->locale = tips_locale;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ plug_in_menus_setup (GimpUIManager *manager,
|
|||
|
||||
for (path = plug_in_proc->menu_paths; path; path = g_list_next (path))
|
||||
{
|
||||
if (! strncmp (path->data, manager->name, strlen (manager->name)))
|
||||
if (g_str_has_prefix (path->data, manager->name))
|
||||
{
|
||||
PlugInMenuEntry *entry = g_new0 (PlugInMenuEntry, 1);
|
||||
const gchar *progname;
|
||||
|
@ -254,7 +254,7 @@ plug_in_menus_unregister_procedure (GimpPDB *pdb,
|
|||
|
||||
for (list = plug_in_proc->menu_paths; list; list = g_list_next (list))
|
||||
{
|
||||
if (! strncmp (list->data, manager->name, strlen (manager->name)))
|
||||
if (g_str_has_prefix (list->data, manager->name))
|
||||
{
|
||||
gchar *merge_key;
|
||||
guint merge_id;
|
||||
|
@ -286,7 +286,7 @@ plug_in_menus_menu_path_added (GimpPlugInProcedure *plug_in_proc,
|
|||
gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
|
||||
#endif
|
||||
|
||||
if (! strncmp (menu_path, manager->name, strlen (manager->name)))
|
||||
if (g_str_has_prefix (menu_path, manager->name))
|
||||
{
|
||||
if (! strcmp (manager->name, "<Image>"))
|
||||
{
|
||||
|
|
|
@ -856,8 +856,8 @@ gimp_plug_in_manager_add_from_rc (GimpPlugInManager *manager,
|
|||
! proc->prefixes &&
|
||||
! proc->magics &&
|
||||
proc->menu_paths &&
|
||||
(! strncmp (proc->menu_paths->data, "<Load>", 6) ||
|
||||
! strncmp (proc->menu_paths->data, "<Save>", 6)))
|
||||
(g_str_has_prefix (proc->menu_paths->data, "<Load>") ||
|
||||
g_str_has_prefix (proc->menu_paths->data, "<Save>")))
|
||||
{
|
||||
proc->extensions = g_strdup ("");
|
||||
}
|
||||
|
@ -959,10 +959,10 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
|
|||
gchar *label_b;
|
||||
gint retval = 0;
|
||||
|
||||
if (strncmp (proc_a->prog, "gimp-xcf", 8) == 0)
|
||||
if (g_str_has_prefix (proc_a->prog, "gimp-xcf"))
|
||||
return -1;
|
||||
|
||||
if (strncmp (proc_b->prog, "gimp-xcf", 8) == 0)
|
||||
if (g_str_has_prefix (proc_b->prog, "gimp-xcf"))
|
||||
return 1;
|
||||
|
||||
domain_a = gimp_plug_in_manager_get_locale_domain (manager, proc_a->prog,
|
||||
|
|
|
@ -655,57 +655,57 @@ image_types_parse (const gchar *name,
|
|||
|
||||
if (*image_types)
|
||||
{
|
||||
if (strncmp (image_types, "RGBA", 4) == 0)
|
||||
if (g_str_has_prefix (image_types, "RGBA"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_RGBA_IMAGE;
|
||||
image_types += 4;
|
||||
image_types += strlen ("RGBA");
|
||||
}
|
||||
else if (strncmp (image_types, "RGB*", 4) == 0)
|
||||
else if (g_str_has_prefix (image_types, "RGB*"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_RGB_IMAGE | GIMP_PLUG_IN_RGBA_IMAGE;
|
||||
image_types += 4;
|
||||
image_types += strlen ("RGB*");
|
||||
}
|
||||
else if (strncmp (image_types, "RGB", 3) == 0)
|
||||
else if (g_str_has_prefix (image_types, "RGB"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_RGB_IMAGE;
|
||||
image_types += 3;
|
||||
image_types += strlen ("RGB");
|
||||
}
|
||||
else if (strncmp (image_types, "GRAYA", 5) == 0)
|
||||
else if (g_str_has_prefix (image_types, "GRAYA"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_GRAYA_IMAGE;
|
||||
image_types += 5;
|
||||
image_types += strlen ("GRAYA");
|
||||
}
|
||||
else if (strncmp (image_types, "GRAY*", 5) == 0)
|
||||
else if (g_str_has_prefix (image_types, "GRAY*"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_GRAY_IMAGE | GIMP_PLUG_IN_GRAYA_IMAGE;
|
||||
image_types += 5;
|
||||
image_types += strlen ("GRAY*");
|
||||
}
|
||||
else if (strncmp (image_types, "GRAY", 4) == 0)
|
||||
else if (g_str_has_prefix (image_types, "GRAY"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_GRAY_IMAGE;
|
||||
image_types += 4;
|
||||
image_types += strlen ("GRAY");
|
||||
}
|
||||
else if (strncmp (image_types, "INDEXEDA", 8) == 0)
|
||||
else if (g_str_has_prefix (image_types, "INDEXEDA"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_INDEXEDA_IMAGE;
|
||||
image_types += 8;
|
||||
image_types += strlen ("INDEXEDA");
|
||||
}
|
||||
else if (strncmp (image_types, "INDEXED*", 8) == 0)
|
||||
else if (g_str_has_prefix (image_types, "INDEXED*"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_INDEXED_IMAGE | GIMP_PLUG_IN_INDEXEDA_IMAGE;
|
||||
image_types += 8;
|
||||
image_types += strlen ("INDEXED*");
|
||||
}
|
||||
else if (strncmp (image_types, "INDEXED", 7) == 0)
|
||||
else if (g_str_has_prefix (image_types, "INDEXED"))
|
||||
{
|
||||
types |= GIMP_PLUG_IN_INDEXED_IMAGE;
|
||||
image_types += 7;
|
||||
image_types += strlen ("INDEXED");
|
||||
}
|
||||
else if (strncmp (image_types, "*", 1) == 0)
|
||||
else if (g_str_has_prefix (image_types, "*"))
|
||||
{
|
||||
types |= (GIMP_PLUG_IN_RGB_IMAGE | GIMP_PLUG_IN_RGBA_IMAGE |
|
||||
GIMP_PLUG_IN_GRAY_IMAGE | GIMP_PLUG_IN_GRAYA_IMAGE |
|
||||
GIMP_PLUG_IN_INDEXED_IMAGE | GIMP_PLUG_IN_INDEXEDA_IMAGE);
|
||||
image_types += 1;
|
||||
image_types += strlen ("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -139,10 +139,10 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||
str = gimp_parasite_data (parasite);
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
if (strncmp (str, "GDT10{", 6) != 0) /* magic value */
|
||||
if (! g_str_has_prefix (str, "GDT10{")) /* magic value */
|
||||
return NULL;
|
||||
|
||||
params = g_strsplit (str + 6, "}{", -1);
|
||||
params = g_strsplit (str + strlen ("GDT10{"), "}{", -1);
|
||||
|
||||
/* first check that we have the required number of parameters */
|
||||
for (i = 0; i < NUM_PARAMS; i++)
|
||||
|
|
|
@ -840,7 +840,7 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
|
|||
{
|
||||
refinement = SIOX_REFINEMENT_CHANGE_MULTIBLOB;
|
||||
}
|
||||
else if (strncmp (pspec->name, "sensitivity", strlen ("sensitivity")) == 0)
|
||||
else if (g_str_has_prefix (pspec->name, "sensitivity"))
|
||||
{
|
||||
refinement = SIOX_REFINEMENT_CHANGE_SENSITIVITY;
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
|
|||
fg_select, NULL);
|
||||
}
|
||||
|
||||
if (strncmp (pspec->name, "mask-color", strlen ("mask-color")) == 0)
|
||||
if (g_str_has_prefix (pspec->name, "mask-color"))
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (fg_select);
|
||||
|
||||
|
|
|
@ -204,11 +204,11 @@ gimp_selection_data_get_uri_list (GtkSelectionData *selection)
|
|||
|
||||
const gchar *start = dnd_crap;
|
||||
|
||||
if (! strncmp (dnd_crap, "file://", strlen ("file://")))
|
||||
if (g_str_has_prefix (dnd_crap, "file://"))
|
||||
{
|
||||
start += strlen ("file://");
|
||||
}
|
||||
else if (! strncmp (dnd_crap, "file:", strlen ("file:")))
|
||||
else if (g_str_has_prefix (dnd_crap, "file:"))
|
||||
{
|
||||
start += strlen ("file:");
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ xcf_load_invoker (GimpProcedure *procedure,
|
|||
|
||||
info.cp += xcf_read_int8 (info.fp, (guint8 *) id, 14);
|
||||
|
||||
if (strncmp (id, "gimp xcf ", 9) != 0)
|
||||
if (g_str_has_prefix (id, "gimp xcf "))
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue