Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-12-23 12:02:49 -0500
committerDan McGee <dan@archlinux.org>2011-12-23 14:37:03 -0600
commite28f321a486a310aeb3358ceff032793a88e5eb4 (patch)
tree24a1e66850e2009cc19ec1a5652fff64e00f4f8a /src
parentbec0b0c8234e9fafbf442c4eb18f92e984ee2516 (diff)
pactree: cleanup register_syncs
- take advantage of the new strtrim return value - tighten scope on line pointer Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/util/pactree.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 77ee75e8..0adc2ea8 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -154,7 +154,7 @@ static size_t strtrim(char *str)
static int register_syncs(void) {
FILE *fp;
- char *ptr, *section = NULL;
+ char *section = NULL;
char line[LINE_MAX];
const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
@@ -165,20 +165,23 @@ static int register_syncs(void) {
}
while(fgets(line, LINE_MAX, fp)) {
- strtrim(line);
+ size_t linelen;
+ char *ptr;
- if(line[0] == '#' || !strlen(line)) {
+ linelen = strtrim(line);
+
+ if(line[0] == '#' || !linelen) {
continue;
}
if((ptr = strchr(line, '#'))) {
*ptr = '\0';
- strtrim(line);
+ linelen = strtrim(line);
}
- if(line[0] == '[' && line[strlen(line) - 1] == ']') {
+ if(line[0] == '[' && line[linelen - 1] == ']') {
free(section);
- section = strndup(&line[1], strlen(line) - 2);
+ section = strndup(&line[1], linelen - 2);
if(section && strcmp(section, "options") != 0) {
alpm_db_register_sync(handle, section, level);