From f556fe8b4a199116b5665bb5f0886e4c2962b077 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Mon, 28 May 2012 17:32:11 -0400 Subject: add line length parameter to _alpm_strip_newline If known, callers can pass the line size to this function in order to avoid an strlen call. Otherwise, they simply pass 0 and _alpm_strip_newline will do the call instead. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/be_local.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/libalpm/be_local.c') diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 30e59d00..ee805b9e 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -496,7 +496,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, #define READ_NEXT() do { \ if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \ - _alpm_strip_newline(line); \ + _alpm_strip_newline(line, 0); \ } while(0) #define READ_AND_STORE(f) do { \ @@ -509,7 +509,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, if(fgets(line, sizeof(line), fp) == NULL) {\ if(!feof(fp)) goto error; else break; \ } \ - if(_alpm_strip_newline(line) == 0) break; \ + if(_alpm_strip_newline(line, 0) == 0) break; \ STRDUP(linedup, line, goto error); \ f = alpm_list_add(f, linedup); \ } while(1) /* note the while(1) and not (0) */ @@ -518,7 +518,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, if(fgets(line, sizeof(line), fp) == NULL) {\ if(!feof(fp)) goto error; else break; \ } \ - if(_alpm_strip_newline(line) == 0) break; \ + if(_alpm_strip_newline(line, 0) == 0) break; \ f = alpm_list_add(f, _alpm_splitdep(line)); \ } while(1) /* note the while(1) and not (0) */ @@ -564,7 +564,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) { goto error; } - if(_alpm_strip_newline(line) == 0) { + if(_alpm_strip_newline(line, 0) == 0) { /* length of stripped line was zero */ continue; } @@ -651,13 +651,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) } free(path); while(fgets(line, sizeof(line), fp)) { - _alpm_strip_newline(line); + _alpm_strip_newline(line, 0); if(strcmp(line, "%FILES%") == 0) { size_t files_count = 0, files_size = 0, len; alpm_file_t *files = NULL; while(fgets(line, sizeof(line), fp) && - (len = _alpm_strip_newline(line))) { + (len = _alpm_strip_newline(line, 0))) { if(files_count >= files_size) { size_t old_size = files_size; if(files_size == 0) { @@ -691,7 +691,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) info->files.count = files_count; info->files.files = files; } else if(strcmp(line, "%BACKUP%") == 0) { - while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line)) { + while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line, 0)) { alpm_backup_t *backup; CALLOC(backup, 1, sizeof(alpm_backup_t), goto error); if(_alpm_split_backup(line, &backup)) { -- cgit v1.2.3-24-g4f1b