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 02-05-2011, 02:48 AM
Pang Yan Han
 
Default Remove redundant _alpm_strtrim() in be_local.c

When reading the "desc" file in _alpm_local_db_read(), some
strings are trimmed and checked for length > 0 before their
use/duplication subsequently. They are then trimmed again
when there is no need to.

The following code snippet should illustrate it clearly:

while(fgets(line, sizeof(line), fp) &&
strlen(_alpm_strtrim(line))) {

char *linedup;
STRDUP(linedup, _alpm_strtrim(line), goto error);
info->groups = alpm_list_add(info->groups, linedup);
}

This patch removes the redundant _alpm_strtrim() calls in
_alpm_local_db_read() such as the one inside the STRDUP shown
above.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
---
lib/libalpm/be_local.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index c7110fa..c005532 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -539,7 +539,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
} else if(strcmp(line, "%GROUPS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->groups = alpm_list_add(info->groups, linedup);
}
} else if(strcmp(line, "%URL%") == 0) {
@@ -550,7 +550,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
} else if(strcmp(line, "%LICENSE%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->licenses = alpm_list_add(info->licenses, linedup);
}
} else if(strcmp(line, "%ARCH%") == 0) {
@@ -595,30 +595,30 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
} else if(strcmp(line, "%REPLACES%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->replaces = alpm_list_add(info->replaces, linedup);
}
} else if(strcmp(line, "%DEPENDS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
- pmdepend_t *dep = _alpm_splitdep(_alpm_strtrim(line));
+ pmdepend_t *dep = _alpm_splitdep(line);
info->depends = alpm_list_add(info->depends, dep);
}
} else if(strcmp(line, "%OPTDEPENDS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->optdepends = alpm_list_add(info->optdepends, linedup);
}
} else if(strcmp(line, "%CONFLICTS%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->conflicts = alpm_list_add(info->conflicts, linedup);
}
} else if(strcmp(line, "%PROVIDES%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->provides = alpm_list_add(info->provides, linedup);
}
}
@@ -639,13 +639,13 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
if(strcmp(line, "%FILES%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->files = alpm_list_add(info->files, linedup);
}
} else if(strcmp(line, "%BACKUP%") == 0) {
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
char *linedup;
- STRDUP(linedup, _alpm_strtrim(line), goto error);
+ STRDUP(linedup, line, goto error);
info->backup = alpm_list_add(info->backup, linedup);
}
}
--
1.7.4
 

Thread Tools




All times are GMT. The time now is 03:37 AM.

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