From cbaff216b3eca57b4fd717da53f43a6713722e95 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 29 Jul 2011 18:49:38 -0500 Subject: Don't trim whitespace when reading database entries We don't write with extra or unknown whitespace, so there is little reason for us to trim it when reading either. This also fixes the hopefully never encountered "paths that start or end with spaces" issue, for which two pactests have been added. The tests also contain other evil characters that we have encountered before and handle just fine, but it doesn't hurt to ensure we don't break such support in the future. Signed-off-by: Dan McGee --- lib/libalpm/be_package.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/libalpm/be_package.c') diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 0edaa5a3..7e90af71 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -149,13 +149,13 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t * /* loop until we reach EOF or other error */ while((ret = _alpm_archive_fgets(a, &buf)) == ARCHIVE_OK) { - char *line = _alpm_strtrim(buf.line); + size_t len = _alpm_strip_newline(buf.line); linenum++; - if(strlen(line) == 0 || line[0] == '#') { + if(len == 0 || buf.line[0] == '#') { continue; } - ptr = line; + ptr = buf.line; key = strsep(&ptr, "="); if(key == NULL || ptr == NULL) { _alpm_log(handle, ALPM_LOG_DEBUG, "%s: syntax error in description file line %d\n", @@ -213,7 +213,6 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t * newpkg->name ? newpkg->name : "error", key, linenum); } } - line[0] = '\0'; } if(ret != ARCHIVE_EOF) { _alpm_log(handle, ALPM_LOG_DEBUG, "error parsing package descfile\n"); -- cgit v1.2.3-24-g4f1b