FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 12-23-2011, 09:43 PM
Dave Reisner
 
Default 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>
---
src/util/pactree.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/util/pactree.c b/src/util/pactree.c
index 77ee75e..0adc2ea 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 = '';
- 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);
--
1.7.8.1
 

Thread Tools




All times are GMT. The time now is 04:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org