aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2009-06-25 22:56:24 +0000
committerJason Woodward2009-06-25 22:56:24 +0000
commitf0c219af9a0549754cee97d936d35cc8c9d999d2 (patch)
treed934d4db85cb1407cd6766c319da03b0dd02b5c1
parent2336d93d126fa67f7c13382a112d9928315dc8c9 (diff)
downloadslapt-get-f0c219af9a0549754cee97d936d35cc8c9d999d2.tar.gz
updated conflicts and suggests parsing to fix certain PACKAGES.TXT formatting
-rw-r--r--ChangeLog1
-rw-r--r--src/package.c18
2 files changed, 11 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 9022a7b..ccb85cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.10.1c Jun 25, 2009
+ * updated conflicts and suggests parsing to fix certain PACKAGES.TXT formatting
0.10.1b May 23, 2009
* updated parsing of compressed and uncompressed sizes in
diff --git a/src/package.c b/src/package.c
index 76f63db..9b7a8dd 100644
--- a/src/package.c
+++ b/src/package.c
@@ -307,16 +307,17 @@ struct slapt_pkg_list *slapt_parse_packages_txt(FILE *pkg_list_fh)
((char_pointer = strstr(getline_buffer,"PACKAGE CONFLICTS")) != NULL)
) {
char *tmp_realloc = NULL;
- char *conflicts = (char *)strpbrk(char_pointer,":") + 3;
+ size_t req_len = 19; /* "PACKAGE CONFLICTS" + 2 */
getline_buffer[bytes_read - 1] = '\0';
tmp_realloc = realloc(tmp_pkg->conflicts,
- sizeof *tmp_pkg->conflicts * (strlen(conflicts) + 1)
+ sizeof *tmp_pkg->conflicts * (strlen(char_pointer + req_len) + 1)
);
if (tmp_realloc != NULL) {
tmp_pkg->conflicts = tmp_realloc;
- strncat(tmp_pkg->conflicts,conflicts,strlen(conflicts));
- tmp_pkg->conflicts[ strlen(conflicts) ] = '\0';
+ strncpy(tmp_pkg->conflicts,char_pointer + req_len,
+ strlen(char_pointer + req_len));
+ tmp_pkg->conflicts[ strlen(char_pointer + req_len) ] = '\0';
}
} else {
/* conflicts isn't provided... rewind one line */
@@ -331,16 +332,17 @@ struct slapt_pkg_list *slapt_parse_packages_txt(FILE *pkg_list_fh)
((char_pointer = strstr(getline_buffer,"PACKAGE SUGGESTS")) != NULL)
) {
char *tmp_realloc = NULL;
- char *suggests = (char *)strpbrk(char_pointer,":") + 3;
+ size_t req_len = 18; /* "PACKAGE SUGGESTS" + 2 */
getline_buffer[bytes_read - 1] = '\0';
tmp_realloc = realloc(tmp_pkg->suggests,
- sizeof *tmp_pkg->suggests * (strlen(suggests) + 1)
+ sizeof *tmp_pkg->suggests * (strlen(char_pointer + req_len) + 1)
);
if (tmp_realloc != NULL) {
tmp_pkg->suggests = tmp_realloc;
- strncat(tmp_pkg->suggests,suggests,strlen(suggests));
- tmp_pkg->suggests[ strlen(suggests) ] = '\0';
+ strncpy(tmp_pkg->suggests,char_pointer + req_len,
+ strlen(char_pointer + req_len));
+ tmp_pkg->suggests[ strlen(char_pointer + req_len) ] = '\0';
}
} else {
/* suggests isn't provided... rewind one line */