Removed utils_str_equal() and use g_str_equal() from GLib because it does exactly the same.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1056 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-12-06 20:44:32 +00:00
parent f0044beb30
commit c461da68f1
14 changed files with 57 additions and 81 deletions

View File

@ -132,7 +132,7 @@ static GtkWidget *create_dialog(void)
header_label = gtk_label_new(NULL);
gtk_label_set_use_markup(GTK_LABEL(header_label), TRUE);
// print the subversion revision if it is available
g_snprintf(buffer, sizeof(buffer), HEADER, (utils_str_equal(REVISION, "-1")) ? "" : " (" REVISION ")");
g_snprintf(buffer, sizeof(buffer), HEADER, (g_str_equal(REVISION, "-1")) ? "" : " (" REVISION ")");
gtk_label_set_markup(GTK_LABEL(header_label), buffer);
gtk_widget_show(header_label);
gtk_box_pack_start(GTK_BOX(header_hbox), header_label, FALSE,FALSE,0);

View File

@ -1147,9 +1147,9 @@ static void set_stop_button(gboolean stop)
GtkWidget *menuitem =
build_get_menu_items(filetypes[run_info.file_type_id])->item_exec;
if (stop && utils_str_equal(
if (stop && g_str_equal(
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(app->run_button)), "gtk-stop")) return;
if (! stop && utils_str_equal(
if (! stop && g_str_equal(
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(app->run_button)), "gtk-execute")) return;
// use the run button also as stop button

View File

@ -765,7 +765,7 @@ on_file_open_dialog_response (GtkDialog *dialog,
filelist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(app->open_filesel));
flist = filelist;
while(flist != NULL)
while (flist != NULL)
{
if (g_file_test((gchar*) flist->data, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
{
@ -1604,24 +1604,24 @@ on_insert_date_activate (GtkMenuItem *menuitem,
if (idx < 0 || ! doc_list[idx].is_valid) return;
if (utils_str_equal(_("dd.mm.yyyy"), (gchar*) user_data))
if (g_str_equal(_("dd.mm.yyyy"), (gchar*) user_data))
format = "%d.%m.%Y";
else if (utils_str_equal(_("mm.dd.yyyy"), (gchar*) user_data))
else if (g_str_equal(_("mm.dd.yyyy"), (gchar*) user_data))
format = "%m.%d.%Y";
else if (utils_str_equal(_("yyyy/mm/dd"), (gchar*) user_data))
else if (g_str_equal(_("yyyy/mm/dd"), (gchar*) user_data))
format = "%Y/%m/%d";
else if (utils_str_equal(_("dd.mm.yyyy hh:mm:ss"), (gchar*) user_data))
else if (g_str_equal(_("dd.mm.yyyy hh:mm:ss"), (gchar*) user_data))
format = "%d.%m.%Y %H:%M:%S";
else if (utils_str_equal(_("mm.dd.yyyy hh:mm:ss"), (gchar*) user_data))
else if (g_str_equal(_("mm.dd.yyyy hh:mm:ss"), (gchar*) user_data))
format = "%m.%d.%Y %H:%M:%S";
else if (utils_str_equal(_("yyyy/mm/dd hh:mm:ss"), (gchar*) user_data))
else if (g_str_equal(_("yyyy/mm/dd hh:mm:ss"), (gchar*) user_data))
format = "%Y/%m/%d %H:%M:%S";
else if (utils_str_equal(_("Use custom date format"), (gchar*) user_data))
else if (g_str_equal(_("Use custom date format"), (gchar*) user_data))
format = app->custom_date_format;
else
{
// set default value
if (utils_str_equal("", app->custom_date_format)) app->custom_date_format = g_strdup("%d.%m.%Y");
if (g_str_equal("", app->custom_date_format)) app->custom_date_format = g_strdup("%d.%m.%Y");
dialogs_show_input(_("Custom date format"),
_("Enter here a custom date and time format. You can use any conversion specifiers which can be used with the ANSI C strftime function. See \"man strftime\" for more information."),
@ -1655,7 +1655,7 @@ on_insert_include_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(), pos = -1;
gchar *text;
if (utils_str_equal(user_data, "blank"))
if (g_str_equal(user_data, "blank"))
{
text = g_strdup("#include \"\"\n");
pos = editor_info.click_pos + 10;
@ -1690,7 +1690,7 @@ on_includes_arguments_dialog_response (GtkDialog *dialog,
{
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry1")));
if (! utils_str_equal(newstr, programs->compiler))
if (! g_str_equal(newstr, programs->compiler))
{
if (programs->compiler) g_free(programs->compiler);
programs->compiler = g_strdup(newstr);
@ -1701,7 +1701,7 @@ on_includes_arguments_dialog_response (GtkDialog *dialog,
{
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry2")));
if (! utils_str_equal(newstr, programs->linker))
if (! g_str_equal(newstr, programs->linker))
{
if (programs->linker) g_free(programs->linker);
programs->linker = g_strdup(newstr);
@ -1712,7 +1712,7 @@ on_includes_arguments_dialog_response (GtkDialog *dialog,
{
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry3")));
if (! utils_str_equal(newstr, programs->run_cmd))
if (! g_str_equal(newstr, programs->run_cmd))
{
if (programs->run_cmd) g_free(programs->run_cmd);
programs->run_cmd = g_strdup(newstr);
@ -1738,7 +1738,7 @@ on_includes_arguments_tex_dialog_response (GtkDialog *dialog,
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "tex_entry1")));
if (! utils_str_equal(newstr, programs->compiler))
if (! g_str_equal(newstr, programs->compiler))
{
if (programs->compiler) g_free(programs->compiler);
programs->compiler = g_strdup(newstr);
@ -1746,7 +1746,7 @@ on_includes_arguments_tex_dialog_response (GtkDialog *dialog,
}
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "tex_entry2")));
if (! utils_str_equal(newstr, programs->linker))
if (! g_str_equal(newstr, programs->linker))
{
if (programs->linker) g_free(programs->linker);
programs->linker = g_strdup(newstr);
@ -1754,7 +1754,7 @@ on_includes_arguments_tex_dialog_response (GtkDialog *dialog,
}
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "tex_entry3")));
if (! utils_str_equal(newstr, programs->run_cmd))
if (! g_str_equal(newstr, programs->run_cmd))
{
if (programs->run_cmd) g_free(programs->run_cmd);
programs->run_cmd = g_strdup(newstr);
@ -1762,7 +1762,7 @@ on_includes_arguments_tex_dialog_response (GtkDialog *dialog,
}
newstr = gtk_entry_get_text(
GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "tex_entry4")));
if (! utils_str_equal(newstr, programs->run_cmd2))
if (! g_str_equal(newstr, programs->run_cmd2))
{
if (programs->run_cmd2) g_free(programs->run_cmd2);
programs->run_cmd2 = g_strdup(newstr);
@ -1845,7 +1845,7 @@ on_encoding_change (GtkMenuItem *menuitem,
guint i = GPOINTER_TO_INT(user_data);
if (app->ignore_callback || ! DOC_IDX_VALID(idx) || encodings[i].charset == NULL ||
utils_str_equal(encodings[i].charset, doc_list[idx].encoding)) return;
g_str_equal(encodings[i].charset, doc_list[idx].encoding)) return;
if (doc_list[idx].readonly)
{

View File

@ -92,7 +92,7 @@ gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename)
// ignore the case of filenames and paths under WIN32, causes errors if not
if (dl_fname && ! strcasecmp(dl_fname, filename)) return i;
#else
if (dl_fname && utils_str_equal(dl_fname, filename)) return i;
if (dl_fname && g_str_equal(dl_fname, filename)) return i;
#endif
}
return -1;
@ -427,7 +427,7 @@ static gboolean
handle_forced_encoding(gchar **data, gsize *size, const gchar *forced_enc, gchar **enc,
gboolean *bom)
{
if (utils_str_equal(forced_enc, "UTF-8"))
if (g_str_equal(forced_enc, "UTF-8"))
{
if (! g_utf8_validate(*data, *size, NULL))
{
@ -435,7 +435,7 @@ handle_forced_encoding(gchar **data, gsize *size, const gchar *forced_enc, gchar
}
else
{
*bom = utils_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
*bom = g_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
*enc = g_strdup(forced_enc);
}
}
@ -452,7 +452,7 @@ handle_forced_encoding(gchar **data, gsize *size, const gchar *forced_enc, gchar
g_free(*data);
*data = (void*)converted_text;
*size = strlen(converted_text);
*bom = utils_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
*bom = g_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
*enc = g_strdup(forced_enc);
}
}
@ -631,7 +631,7 @@ int document_open_file(gint idx, const gchar *filename, gint pos, gboolean reado
if (forced_enc != NULL)
{
// the encoding should be ignored(requested by user), so open the file "as it is"
if (utils_str_equal(forced_enc, encodings[GEANY_ENCODING_NONE].charset))
if (g_str_equal(forced_enc, encodings[GEANY_ENCODING_NONE].charset))
{
bom = FALSE;
enc = g_strdup(encodings[GEANY_ENCODING_NONE].charset);
@ -830,8 +830,8 @@ gboolean document_save_file(gint idx, gboolean force)
}
// save in original encoding, skip when it is already UTF-8 or has the encoding "None"
if (doc_list[idx].encoding != NULL && ! utils_str_equal(doc_list[idx].encoding, "UTF-8") &&
! utils_str_equal(doc_list[idx].encoding, encodings[GEANY_ENCODING_NONE].charset))
if (doc_list[idx].encoding != NULL && ! g_str_equal(doc_list[idx].encoding, "UTF-8") &&
! g_str_equal(doc_list[idx].encoding, encodings[GEANY_ENCODING_NONE].charset))
{
GError *conv_error = NULL;
gchar* conv_file_contents = NULL;
@ -1528,7 +1528,7 @@ void document_ensure_final_newline(gint idx)
void document_set_encoding(gint idx, const gchar *new_encoding)
{
if (! DOC_IDX_VALID(idx) || new_encoding == NULL ||
utils_str_equal(new_encoding, doc_list[idx].encoding)) return;
g_str_equal(new_encoding, doc_list[idx].encoding)) return;
g_free(doc_list[idx].encoding);
doc_list[idx].encoding = g_strdup(new_encoding);
@ -1625,7 +1625,7 @@ static void update_changed_state(gint idx)
doc_list[idx].changed =
(sci_is_modified(doc_list[idx].sci) ||
doc_list[idx].has_bom != doc_list[idx].saved_encoding.has_bom ||
! utils_str_equal(doc_list[idx].encoding, doc_list[idx].saved_encoding.encoding));
! g_str_equal(doc_list[idx].encoding, doc_list[idx].saved_encoding.encoding));
document_set_text_changed(idx);
}

View File

@ -176,7 +176,7 @@ void encodings_select_radio_item(const gchar *charset)
i = 0;
while (i < GEANY_ENCODINGS_MAX)
{
if (utils_str_equal(charset, encodings[i].charset)) break;
if (g_str_equal(charset, encodings[i].charset)) break;
i++;
}
if (i == GEANY_ENCODINGS_MAX) i = GEANY_ENCODING_UTF_8; // fallback to UTF-8
@ -347,7 +347,7 @@ gchar *encodings_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_e
for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
{
if (i == (guint) encodings[GEANY_ENCODING_NONE].idx) continue;
if (check_current)
{
check_current = FALSE;

View File

@ -1324,7 +1324,7 @@ static gboolean gb_on_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointe
{
text[4] = 'y';
text[5] = '\0';
if (utils_str_equal(text, "geany")) gb_start_easteregg();
if (g_str_equal(text, "geany")) gb_start_easteregg();
return TRUE;
break;
}

View File

@ -288,8 +288,7 @@ gboolean configuration_load()
GtkIconSize tb_iconsize;
GtkToolbarStyle tb_style;
GEANY_GET_SETTING("gtk-toolbar-style", tb_style, GTK_TOOLBAR_ICONS);
GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize,
GTK_ICON_SIZE_LARGE_TOOLBAR);
GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize, GTK_ICON_SIZE_LARGE_TOOLBAR);
app->toolbar_icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style);
app->toolbar_icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize);
}
@ -384,7 +383,7 @@ gboolean configuration_load()
vc = g_new0(VteConfig, 1);
vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
if ((vte_info.dir == NULL || utils_str_equal(vte_info.dir, "")) && pw != NULL)
if ((vte_info.dir == NULL || g_str_equal(vte_info.dir, "")) && pw != NULL)
// last dir is not set, fallback to user's home directory
vte_info.dir = g_strdup(pw->pw_dir);
else if (vte_info.dir == NULL && pw == NULL)

View File

@ -872,7 +872,7 @@ static void on_dialog_response(GtkWidget *dialog, gint response, gpointer user_d
for (idx = 0; idx < GEANY_MAX_KEYS; idx++)
{
if (utils_str_equal(dialog_key_name, keys[idx]->label)) break;
if (g_str_equal(dialog_key_name, keys[idx]->label)) break;
}
gtk_accelerator_parse(gtk_label_get_text(GTK_LABEL(dialog_label)), &lkey, &lmods);

View File

@ -1090,15 +1090,15 @@ static gboolean handle_xml(ScintillaObject *sci, gchar ch, gint idx)
str_found = utils_find_open_xml_tag(sel, pos - min, FALSE);
// when found string is something like br, img or another short tag, quit
if (utils_str_equal(str_found, "br")
|| utils_str_equal(str_found, "img")
|| utils_str_equal(str_found, "base")
|| utils_str_equal(str_found, "basefont") // < or not <
|| utils_str_equal(str_found, "frame")
|| utils_str_equal(str_found, "input")
|| utils_str_equal(str_found, "link")
|| utils_str_equal(str_found, "area")
|| utils_str_equal(str_found, "meta"))
if (g_str_equal(str_found, "br")
|| g_str_equal(str_found, "img")
|| g_str_equal(str_found, "base")
|| g_str_equal(str_found, "basefont") // < or not <
|| g_str_equal(str_found, "frame")
|| g_str_equal(str_found, "input")
|| g_str_equal(str_found, "link")
|| g_str_equal(str_found, "area")
|| g_str_equal(str_found, "meta"))
{
return FALSE;
}
@ -1115,7 +1115,7 @@ static gboolean handle_xml(ScintillaObject *sci, gchar ch, gint idx)
if (ch == '>')
{
SSM(sci, SCI_SETSEL, pos, pos);
if (utils_str_equal(str_found, "table")) sci_cb_auto_table(sci, pos);
if (g_str_equal(str_found, "table")) sci_cb_auto_table(sci, pos);
}
sci_end_undo_action(sci);
g_free(to_insert);
@ -1718,8 +1718,8 @@ void sci_cb_auto_multiline(ScintillaObject *sci, gint pos)
gint lexer = SSM(sci, SCI_GETLEXER, 0, 0);
gint i = pos;
if (((lexer == SCLEX_CPP && style == SCE_C_COMMENT) ||
(lexer == SCLEX_HTML && style == SCE_HPHP_COMMENT)))
if ((lexer == SCLEX_CPP && style == SCE_C_COMMENT) ||
(lexer == SCLEX_HTML && style == SCE_HPHP_COMMENT))
{
while (isspace(sci_get_char_at(sci, i))) i--;
if (sci_get_char_at(sci, i) == '/' && sci_get_char_at(sci, i - 1) == '*') return;

View File

@ -223,7 +223,7 @@ static void send_find_dialog_response(GtkButton *button, gpointer user_data)
static gchar *get_default_text(gint idx)
{
gchar *s = NULL;
if (sci_get_lines_selected(doc_list[idx].sci) == 1)
{
s = g_malloc(sci_get_selected_text_length(doc_list[idx].sci));
@ -235,7 +235,7 @@ static gchar *get_default_text(gint idx)
sci_cb_find_current_word(doc_list[idx].sci, -1, word, sizeof(word));
if (word[0] != '\0') s = g_strdup(word);
}
return s;
}
@ -632,7 +632,7 @@ void search_show_find_in_files_dialog()
}
// put the focus to the directory entry if it is empty
if (utils_str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), ""))
if (g_str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), ""))
gtk_widget_grab_focus(dir_combo);
else
gtk_widget_grab_focus(combo);
@ -762,7 +762,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
(fl2 ? SCFIND_WHOLEWORD : 0) |
(fl3 ? SCFIND_REGEXP | SCFIND_POSIX: 0) |
(fl4 ? SCFIND_WORDSTART : 0);
switch (response)
{
case GEANY_RESPONSE_FIND:
@ -948,7 +948,7 @@ on_find_in_files_dialog_response(GtkDialog *dialog, gint response, gpointer user
const gchar *utf8_dir =
gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dir_combo))));
if (utf8_dir == NULL || utils_str_equal(utf8_dir, ""))
if (utf8_dir == NULL || g_str_equal(utf8_dir, ""))
msgwin_status_add(_("Invalid directory for find in files."));
else if (search_text && *search_text)
{

View File

@ -169,7 +169,7 @@ const GList *symbols_get_tag_list(gint idx, guint tag_types)
}
// do this comparison only once
if (utils_str_equal(doc_list[idx].encoding, "UTF-8")) doc_is_utf8 = TRUE;
if (g_str_equal(doc_list[idx].encoding, "UTF-8")) doc_is_utf8 = TRUE;
for (i = 0; i < (doc_list[idx].tm_file)->tags_array->len; ++i)
{
@ -186,7 +186,7 @@ const GList *symbols_get_tag_list(gint idx, guint tag_types)
{
// context separator
gchar *cosep = (doc_list[idx].file_type->id == GEANY_FILETYPES_CPP) ? "::" : ".";
symbol = g_new0(GeanySymbol, 1);
symbol->str = g_strdup_printf("%s%s%s [%ld]", tag->atts.entry.scope, cosep,
utf8_name, tag->atts.entry.line);
@ -254,7 +254,7 @@ symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
for (i = 0; i < tags->len; ++i)
{
if (utils_str_equal(TM_TAG(tags->pdata[i])->name, tag_name))
if (g_str_equal(TM_TAG(tags->pdata[i])->name, tag_name))
return TM_TAG(tags->pdata[i]);
}
return NULL;

View File

@ -1144,7 +1144,7 @@ void ui_combo_box_add_to_history(GtkComboBox *combo, const gchar *text)
if (gtk_tree_model_get_iter_first(model, &iter))
{
gtk_tree_model_get(model, &iter, 0, &combo_text, -1);
equal = utils_str_equal(combo_text, text);
equal = g_str_equal(combo_text, text);
g_free(combo_text);
}
if (equal) return; // don't prepend duplicate

View File

@ -679,23 +679,6 @@ gdouble utils_scale_round (gdouble val, gdouble factor)
}
/* (taken from libexo from os-cillation)
* NULL-safe string comparison. Returns TRUE if both a and b are
* NULL or if a and b refer to valid strings which are equal.
*/
gboolean utils_str_equal(const gchar *a, const gchar *b)
{
if (a == NULL && b == NULL) return TRUE;
else if (a == NULL || b == NULL) return FALSE;
while (*a == *b++)
if (*a++ == '\0')
return TRUE;
return FALSE;
}
/* removes the extension from filename and return the result in
* a newly allocated string */
gchar *utils_remove_ext_from_filename(const gchar *filename)

View File

@ -71,12 +71,6 @@ gboolean utils_is_absolute_path(const gchar *path);
gdouble utils_scale_round(gdouble val, gdouble factor);
/* (taken from libexo from os-cillation)
* NULL-safe string comparison. Returns TRUE if both a and b are
* NULL or if a and b refer to valid strings which are equal.
*/
gboolean utils_str_equal(const gchar *a, const gchar *b);
/* removes the extension from filename and return the result in
* a newly allocated string */
gchar *utils_remove_ext_from_filename(const gchar *filename);