summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-01-31 11:31:56 +0100
committerZenWalker <[email protected]>2020-03-08 21:14:36 +0100
commit144ac2fb1395a76a04773c577965a8754f2dab3b (patch)
tree61820c300316ed7b1893160b53f0f4b7ae5c408e /src
parent3c6c1cef810b6a27ecf5142893bd960d6efb32f2 (diff)
downloadengrampa-144ac2fb1395a76a04773c577965a8754f2dab3b.tar.bz2
engrampa-144ac2fb1395a76a04773c577965a8754f2dab3b.tar.xz
glib-utils: remove n_fields function
Diffstat (limited to 'src')
-rw-r--r--src/fr-command-ace.c2
-rw-r--r--src/fr-command-cpio.c2
-rw-r--r--src/fr-command-rpm.c2
-rw-r--r--src/glib-utils.c17
-rw-r--r--src/glib-utils.h1
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);