From 7ce02733e82881e5a5051813eb48615d45569291 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 8 Mar 2006 15:52:51 +0000 Subject: [PATCH] Replace index(3) by strchr(3) and rindex(3) by strrchr(3) because the latter is more widely available. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13540 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 14 ++++++++++++++ src/app-utils/file-utils.c | 2 +- src/app-utils/gnc-ui-util.c | 4 ++-- src/business/business-gnome/business-urls.c | 3 +-- src/core-utils/gnc-gconf-utils.c | 10 +++++----- src/gnome-utils/dialog-preferences.c | 4 ++-- src/gnome-utils/dialog-reset-warnings.c | 2 +- src/gnome-utils/gnc-currency-edit.c | 3 +-- src/gnome-utils/gnc-main-window.c | 6 +++--- src/gnome-utils/gnc-plugin-file-history.c | 2 +- src/gnome-utils/gnc-tree-view.c | 4 ++-- src/gnome/window-reconcile.c | 2 +- 12 files changed, 34 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index d73e45bc80..a82f7cb866 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-03-08 Christian Stimming + + * src/core-utils/gnc-gconf-utils.c, + src/business/business-gnome/business-urls.c + src/gnome-utils/dialog-preferences.c + src/gnome-utils/gnc-currency-edit.c + src/gnome-utils/gnc-plugin-file-history.c + src/gnome-utils/gnc-main-window.c + src/gnome-utils/dialog-reset-warnings.c + src/gnome-utils/gnc-tree-view.c src/gnome/window-reconcile.c + src/app-utils/file-utils.c src/app-utils/gnc-ui-util.c : Replace + index(3) by strchr(3) and rindex(3) by strrchr(3) because the + latter is more widely available. + 2006-03-07 David Hampton * src/gnome-utils/gnc-splash.c: Use a font size of "smaller" when diff --git a/src/app-utils/file-utils.c b/src/app-utils/file-utils.c index d7fae2cb4a..ded797ca32 100644 --- a/src/app-utils/file-utils.c +++ b/src/app-utils/file-utils.c @@ -181,7 +181,7 @@ gnc_find_state_file (const gchar *url, gint i; ENTER("url %s, guid %s", url, guid); - tmp = index(url, ':'); + tmp = strchr(url, ':'); if (tmp) url = tmp + 1; diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index eb23d80e92..4396dff205 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -189,13 +189,13 @@ gnc_extract_directory (char **dirname, const char *filename) free(*dirname); /* Parse out the directory. */ - if ((filename == NULL) || (rindex(filename, '/') == NULL)) { + if ((filename == NULL) || (strrchr(filename, '/') == NULL)) { *dirname = NULL; return; } *dirname = g_strdup(filename); - tmp = rindex(*dirname, '/'); + tmp = strrchr(*dirname, '/'); *(tmp+1) = '\0'; } diff --git a/src/business/business-gnome/business-urls.c b/src/business/business-gnome/business-urls.c index 42d581d164..2797d649a0 100644 --- a/src/business/business-gnome/business-urls.c +++ b/src/business/business-gnome/business-urls.c @@ -26,7 +26,6 @@ #include #include -#include /* index() on Solaris */ #include "gnc-html.h" #include "gnc-ui-util.h" @@ -183,7 +182,7 @@ ownerreportCB (const char *location, const char *label, /* href="...:owner=:guid=[&acct=]" */ - acctptr = index (location, '&'); + acctptr = strchr (location, '&'); if (acctptr) acctptr++; diff --git a/src/core-utils/gnc-gconf-utils.c b/src/core-utils/gnc-gconf-utils.c index 7c8a4ff4d7..cd71ee8712 100644 --- a/src/core-utils/gnc-gconf-utils.c +++ b/src/core-utils/gnc-gconf-utils.c @@ -87,14 +87,14 @@ gnc_enum_from_nick(GType type, /* Flip '-' and '_' and try again */ alt_name = g_strdup(name); - if ((ptr = index(alt_name, '-')) != NULL) { + if ((ptr = strchr(alt_name, '-')) != NULL) { do { *ptr++ = '_'; - } while ((ptr = index(ptr, '-')) != NULL); - } else if ((ptr = index(alt_name, '_')) != NULL) { + } while ((ptr = strchr(ptr, '-')) != NULL); + } else if ((ptr = strchr(alt_name, '_')) != NULL) { do { *ptr++ = '-'; - } while ((ptr = index(ptr, '_')) != NULL); + } while ((ptr = strchr(ptr, '_')) != NULL); } else { g_free(alt_name); return default_value; @@ -144,7 +144,7 @@ gnc_gconf_general_changed (GConfClient *client, g_once(&gcb_init_once, gcb_init, NULL); key = gconf_entry_get_key(entry); - key_tail = rindex(key, '/'); + key_tail = strrchr(key, '/'); if (key_tail != NULL) { key_tail++; } diff --git a/src/gnome-utils/dialog-preferences.c b/src/gnome-utils/dialog-preferences.c index 9490637dd5..2e387a467c 100644 --- a/src/gnome-utils/dialog-preferences.c +++ b/src/gnome-utils/dialog-preferences.c @@ -603,7 +603,7 @@ gnc_prefs_radio_button_user_cb (GtkRadioButton *button, /* Copy the widget name and split into gconf key and button value parts */ key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN); - button_name = rindex(key, '/'); + button_name = strrchr(key, '/'); *button_name++ = '\0'; DEBUG("Radio button group %s now set to %s", key, button_name); @@ -655,7 +655,7 @@ gnc_prefs_connect_radio_button (GtkRadioButton *button) /* Copy the widget name and split into gconf key and button name parts */ key = g_strdup(gtk_widget_get_name(GTK_WIDGET(button)) + PREFIX_LEN); - button_name = rindex(key, '/'); + button_name = strrchr(key, '/'); *button_name++ = '\0'; /* Get the current value. */ diff --git a/src/gnome-utils/dialog-reset-warnings.c b/src/gnome-utils/dialog-reset-warnings.c index b959c717d0..6bb90995d9 100644 --- a/src/gnome-utils/dialog-reset-warnings.c +++ b/src/gnome-utils/dialog-reset-warnings.c @@ -226,7 +226,7 @@ gnc_reset_warnings_add_one (GConfEntry *entry, GtkWidget *box) GConfSchema *schema = NULL; ENTER(" "); - name = rindex(entry->key, '/') + 1; + name = strrchr(entry->key, '/') + 1; schema_name = gconf_entry_get_schema_name(entry); if (schema_name) schema = gnc_gconf_get_schema(NULL, schema_name, NULL); diff --git a/src/gnome-utils/gnc-currency-edit.c b/src/gnome-utils/gnc-currency-edit.c index 134290b176..bf1d865f19 100644 --- a/src/gnome-utils/gnc-currency-edit.c +++ b/src/gnome-utils/gnc-currency-edit.c @@ -59,7 +59,6 @@ #include #include -#include /* for index() on Solaris */ #include #include @@ -294,7 +293,7 @@ gnc_currency_edit_get_currency (GNCCurrencyEdit *gce) mnemonic = g_strdup(fullname); g_value_unset(&value); - name = index(mnemonic, ' '); + name = strchr(mnemonic, ' '); if (name != NULL) *name = '\0'; commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (), diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index cdc78cde3c..f908490653 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -869,7 +869,7 @@ gnc_main_window_prompt_for_save (GtkWidget *window) filename = qof_session_get_file_path(session); if (filename == NULL) filename = _(""); - if ((tmp = rindex(filename, '/')) != NULL) + if ((tmp = strrchr(filename, '/')) != NULL) filename = tmp + 1; /* @@ -1059,7 +1059,7 @@ gnc_main_window_generate_title (GncMainWindow *window) filename = _(""); else { /* The Gnome HIG 2.0 recommends only the file name (no path) be used. (p15) */ - ptr = rindex(filename, '/'); + ptr = strrchr(filename, '/'); if (ptr != NULL) filename = ptr+1; } @@ -2359,7 +2359,7 @@ gnc_main_window_gconf_changed (GConfClient *client, if (!key || !value) return; - key_tail = rindex(key, '/'); + key_tail = strrchr(key, '/'); if (key_tail != NULL) key_tail++; if (strcmp(key_tail, KEY_TOOLBAR_STYLE) == 0) { diff --git a/src/gnome-utils/gnc-plugin-file-history.c b/src/gnome-utils/gnc-plugin-file-history.c index 7ad28b8e51..86fed4e4db 100644 --- a/src/gnome-utils/gnc-plugin-file-history.c +++ b/src/gnome-utils/gnc-plugin-file-history.c @@ -380,7 +380,7 @@ gnc_plugin_history_list_changed (GConfClient *client, window = GNC_MAIN_WINDOW(user_data); fullkey = gconf_entry_get_key(entry); - key = rindex(fullkey, '/') + 1; + key = strrchr(fullkey, '/') + 1; if (strcmp(key, HISTORY_STRING_MAXFILES) == 0) { gnc_history_update_menus (window); LEAVE("updated maxfiles"); diff --git a/src/gnome-utils/gnc-tree-view.c b/src/gnome-utils/gnc-tree-view.c index 43c9c798b4..cc7b2dc590 100644 --- a/src/gnome-utils/gnc-tree-view.c +++ b/src/gnome-utils/gnc-tree-view.c @@ -1062,7 +1062,7 @@ gnc_tree_view_gconf_changed (GConfClient *client, } DEBUG("Key %s, value %p", key, value); - local = rindex(key, '/')+1; + local = strrchr(key, '/')+1; if (strcmp(local, GCONF_KEY_SORT_COLUMN) == 0) { gnc_tree_view_set_sort_column(view, gconf_value_get_string(value)); } else if (strcmp(local, GCONF_KEY_SORT_ORDER) == 0) { @@ -1074,7 +1074,7 @@ gnc_tree_view_gconf_changed (GConfClient *client, * into column name and key type */ known = FALSE; column_name = strdup(local); - type_name = rindex(column_name, '_'); + type_name = strrchr(column_name, '_'); *type_name++ = '\0'; if (strcmp(type_name, GCONF_KEY_VISIBLE) == 0) { diff --git a/src/gnome/window-reconcile.c b/src/gnome/window-reconcile.c index 6a99ca5e6a..64388b215a 100644 --- a/src/gnome/window-reconcile.c +++ b/src/gnome/window-reconcile.c @@ -1189,7 +1189,7 @@ gnc_toolbar_change_cb (GConfClient *client, if (!key || !value) return; - key_tail = rindex(key, '/'); + key_tail = strrchr(key, '/'); if (key_tail != NULL) key_tail++; if (strcmp(key_tail, KEY_TOOLBAR_STYLE) == 0) {