diff options
-rw-r--r-- | src/fr-command-ace.c | 2 | ||||
-rw-r--r-- | src/fr-command-cpio.c | 2 | ||||
-rw-r--r-- | src/fr-command-rpm.c | 2 | ||||
-rw-r--r-- | src/glib-utils.c | 17 | ||||
-rw-r--r-- | src/glib-utils.h | 1 |
5 files changed, 4 insertions, 20 deletions
diff --git a/src/fr-command-ace.c b/src/fr-command-ace.c index 5d277fc..5e36819 100644 --- a/src/fr-command-ace.c +++ b/src/fr-command-ace.c @@ -130,7 +130,7 @@ process_line (char *line, else if (ace_comm->command_type == FR_ACE_COMMAND_NONFREE) fields = split_line (line, 5); - if ((fields == NULL) || (fields[0] == NULL) || (n_fields (fields) < 5)) + if ((fields == NULL) || (g_strv_length (fields) < 5)) return; fdata->size = g_ascii_strtoull (fields[3], NULL, 10); diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c index 6cbe61d..457de72 100644 --- a/src/fr-command-cpio.c +++ b/src/fr-command-cpio.c @@ -66,7 +66,7 @@ mktime_from_string (char *month, tm.tm_mday = atoi (mday); if (strchr (year, ':') != NULL) { char **fields = g_strsplit (year, ":", 2); - if (n_fields (fields) == 2) { + if ((fields != NULL) && (g_strv_length (fields) == 2)) { time_t now; struct tm *now_tm; diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c index 227fd58..3c5c755 100644 --- a/src/fr-command-rpm.c +++ b/src/fr-command-rpm.c @@ -73,7 +73,7 @@ mktime_from_string (char *month, if (year != NULL) { if (strchr (year, ':') != NULL) { char **fields = g_strsplit (year, ":", 2); - if (n_fields (fields) == 2) { + if ((fields != NULL) && (g_strv_length (fields) == 2)) { time_t now; struct tm *now_tm; diff --git a/src/glib-utils.c b/src/glib-utils.c index cffa591..ed42dd7 100644 --- a/src/glib-utils.c +++ b/src/glib-utils.c @@ -378,7 +378,7 @@ search_util_get_regexps (const char *pattern_string, if (patterns == NULL) return NULL; - regexps = g_new0 (GRegex*, n_fields (patterns) + 1); + regexps = g_new0 (GRegex*, g_strv_length (patterns) + 1); for (i = 0; patterns[i] != NULL; i++) regexps[i] = g_regex_new (patterns[i], G_REGEX_OPTIMIZE | compile_options, @@ -452,21 +452,6 @@ get_last_field (const char *line, } -int -n_fields (char **str_array) -{ - int i; - - if (str_array == NULL) - return 0; - - i = 0; - while (str_array[i] != NULL) - i++; - return i; -} - - void debug (const char *file, int line, diff --git a/src/glib-utils.h b/src/glib-utils.h index 957aff9..f9820c4 100644 --- a/src/glib-utils.h +++ b/src/glib-utils.h @@ -59,7 +59,6 @@ char ** split_line (const char *line, int n_fields); const char * get_last_field (const char *line, int last_field); -int n_fields (char **str_array); void g_ptr_array_free_full (GPtrArray *array, GFunc func, gpointer user_data); |