Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=6a590128145b4a7bc35a7d761c4caba9bafe3e37

commit 6a590128145b4a7bc35a7d761c4caba9bafe3e37
Author: Marius Cirsta <[email protected]>
Date:   Fri Nov 29 23:04:07 2013 +0200

* replace _pacman_strtoupper with f_strtoupper
* replace _pacman_strtrim with f_strtrim

diff --git a/lib/libpacman/config_parser.c b/lib/libpacman/config_parser.c
index ec0798a..4515355 100644
--- a/lib/libpacman/config_parser.c
+++ b/lib/libpacman/config_parser.c
@@ -96,7 +96,7 @@ int _pacman_parse_config(const char *file, 
pacman_cb_db_register callback, const

while(fgets(line, PATH_MAX, fp)) {
linenum++;
-               _pacman_strtrim(line);
+               f_strtrim(line);
if(line[0] == '\0' || line[0] == '#') {
continue;
}
@@ -130,8 +130,8 @@ int _pacman_parse_config(const char *file, 
pacman_cb_db_register callback, const
if(key == NULL) {
RET_ERR(PM_ERR_CONF_BAD_SYNTAX, -1);
}
-                       _pacman_strtrim(key);
-                       key = _pacman_strtoupper(key);
+                       f_strtrim(key);
+                       key = f_strtoupper(key);
if(!strlen(section) && strcmp(key, "INCLUDE")) {
RET_ERR(PM_ERR_CONF_DIRECTIVE_OUTSIDE_SECTION, -1);
}
@@ -147,7 +147,7 @@ int _pacman_parse_config(const char *file, 
pacman_cb_db_register callback, const
RET_ERR(PM_ERR_CONF_BAD_SYNTAX, -1);
}
} else {
-                               _pacman_strtrim(ptr);
+                               f_strtrim(ptr);
if(!strcmp(key, "INCLUDE")) {
char conf[PATH_MAX];
strncpy(conf, ptr, PATH_MAX);
diff --git a/lib/libpacman/db/localdb_files.c b/lib/libpacman/db/localdb_files.c
index 7985572..f4cf729 100644
--- a/lib/libpacman/db/localdb_files.c
+++ b/lib/libpacman/db/localdb_files.c
@@ -46,6 +46,7 @@
#include "util/stringlist.h"
#include "util.h"
#include "db.h"
+#include "fstring.h"
#include "package.h"
#include "pacman.h"
#include "error.h"
@@ -56,7 +57,7 @@ int _pacman_db_read_lines(FStringList **list, char *s, size_t 
size, FILE *fp)
{
int lines = 0;

-       while(fgets(s, size, fp) && !_pacman_strempty(_pacman_strtrim(s))) {
+       while(fgets(s, size, fp) && !_pacman_strempty(f_strtrim(s))) {
*list = f_stringlist_append(*list, s);
lines++;
}
@@ -73,7 +74,7 @@ int _pacman_localdb_desc_fread(pmpkg_t *info, FILE *fp)
if(fgets(line, 256, fp) == NULL) {
break;
}
-               _pacman_strtrim(line);
+               f_strtrim(line);
if(!strcmp(line, "%DESC%")) {
_pacman_db_read_lines(&info->desc_localized, line, sline, fp);
STRNCPY(info->desc, (char*)info->desc_localized->data, sizeof(info->desc));
@@ -83,47 +84,47 @@ int _pacman_localdb_desc_fread(pmpkg_t *info, FILE *fp)
STRNCPY(info->desc, (char*)i->data+strlen(handle->language)+1, 
sizeof(info->desc));
}
}
-                       _pacman_strtrim(info->desc);
+                       f_strtrim(info->desc);
} else if(!strcmp(line, "%GROUPS%")) {
_pacman_db_read_lines(&info->groups, line, sline, fp);
} else if(!strcmp(line, "%URL%")) {
if(fgets(info->url, sizeof(info->url), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->url);
+                       f_strtrim(info->url);
} else if(!strcmp(line, "%LICENSE%")) {
_pacman_db_read_lines(&info->license, line, sline, fp);
} else if(!strcmp(line, "%ARCH%")) {
if(fgets(info->arch, sizeof(info->arch), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->arch);
+                       f_strtrim(info->arch);
} else if(!strcmp(line, "%BUILDDATE%")) {
if(fgets(info->builddate, sizeof(info->builddate), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->builddate);
+                       f_strtrim(info->builddate);
} else if(!strcmp(line, "%BUILDTYPE%")) {
if(fgets(info->buildtype, sizeof(info->buildtype), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->buildtype);
+                       f_strtrim(info->buildtype);
} else if(!strcmp(line, "%INSTALLDATE%")) {
if(fgets(info->installdate, sizeof(info->installdate), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->installdate);
+                       f_strtrim(info->installdate);
} else if(!strcmp(line, "%PACKAGER%")) {
if(fgets(info->packager, sizeof(info->packager), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(info->packager);
+                       f_strtrim(info->packager);
} else if(!strcmp(line, "%REASON%")) {
char tmp[32];
if(fgets(tmp, sizeof(tmp), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(tmp);
+                       f_strtrim(tmp);
info->reason = atol(tmp);
} else if(!strcmp(line, "%TRIGGERS%")) {
_pacman_db_read_lines(&info->triggers, line, sline, fp);
@@ -137,7 +138,7 @@ int _pacman_localdb_desc_fread(pmpkg_t *info, FILE *fp)
if(fgets(tmp, sizeof(tmp), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(tmp);
+                       f_strtrim(tmp);
info->size = atol(tmp);
} else if(!strcmp(line, "%USIZE%")) {
/* USIZE (uncompressed size) tag only appears in sync repositories,
@@ -146,7 +147,7 @@ int _pacman_localdb_desc_fread(pmpkg_t *info, FILE *fp)
if(fgets(tmp, sizeof(tmp), fp) == NULL) {
goto error;
}
-                       _pacman_strtrim(tmp);
+                       f_strtrim(tmp);
info->usize = atol(tmp);
} else if(!strcmp(line, "%SHA1SUM%")) {
/* SHA1SUM tag only appears in sync repositories,
@@ -193,7 +194,7 @@ int _pacman_localdb_depends_fread(pmpkg_t *info, FILE *fp)
if(fgets(line, 256, fp) == NULL) {
break;
}
-               _pacman_strtrim(line);
+               f_strtrim(line);
if(!strcmp(line, "%DEPENDS%")) {
_pacman_db_read_lines(&info->depends, line, sline, fp);
} else if(!strcmp(line, "%REQUIREDBY%")) {
@@ -228,9 +229,9 @@ int _pacman_localdb_files_fread(pmpkg_t *info, FILE *fp)
if(fgets(line, 256, fp) == NULL) {
break;
}
-               _pacman_strtrim(line);
+               f_strtrim(line);
if(!strcmp(line, "%FILES%")) {
-                       while(fgets(line, sline, fp) && 
!_pacman_strempty(_pacman_strtrim(line))) {
+                       while(fgets(line, sline, fp) && 
!_pacman_strempty(f_strtrim(line))) {
char *ptr;

if((ptr = strchr(line, '|'))) {
@@ -240,7 +241,7 @@ int _pacman_localdb_files_fread(pmpkg_t *info, FILE *fp)
info->files = f_stringlist_append(info->files, line);
}
} else if(!strcmp(line, "%BACKUP%")) {
-                       while(fgets(line, sline, fp) && 
!_pacman_strempty(_pacman_strtrim(line))) {
+                       while(fgets(line, sline, fp) && 
!_pacman_strempty(f_strtrim(line))) {
info->backup = f_stringlist_append(info->backup, line);
}
}
diff --git a/lib/libpacman/fstring.h b/lib/libpacman/fstring.h
index fc7a906..c1f6778 100644
--- a/lib/libpacman/fstring.h
+++ b/lib/libpacman/fstring.h
@@ -23,9 +23,6 @@

#include <string.h>

-#define _pacman_strtoupper f_strtoupper
-#define _pacman_strtrim f_strtrim
-
static inline
int f_strempty(const char *s)
{
diff --git a/lib/libpacman/package.c b/lib/libpacman/package.c
index e94687c..7848c57 100644
--- a/lib/libpacman/package.c
+++ b/lib/libpacman/package.c
@@ -69,7 +69,7 @@ pmpkg_t *_pacman_pkg_new(const char *name, const char 
*version)
pmpkg_t *_pacman_pkg_new_from_filename(const char *filename, int witharch)
{
pmpkg_t *pkg;
-
+
ASSERT(pkg = _pacman_pkg_new(NULL, NULL), return NULL);

if(_pacman_pkg_splitname(filename, pkg->name, pkg->version, witharch) == -1) {
@@ -258,7 +258,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
if(fgets(str, PATH_MAX, filelist) == NULL) {
continue;
}
-                               _pacman_strtrim(str);
+                               f_strtrim(str);
info->files = _pacman_stringlist_append(info->files, str);
}
FREE(str);
diff --git a/lib/libpacman/package/pkginfo.c b/lib/libpacman/package/pkginfo.c
index ad6af3d..7ef5943 100644
--- a/lib/libpacman/package/pkginfo.c
+++ b/lib/libpacman/package/pkginfo.c
@@ -59,7 +59,7 @@ int _pacman_pkginfo_fread(FILE *descfile, pmpkg_t *info, int 
output)
while(!feof(descfile)) {
fgets(line, PATH_MAX, descfile);
linenum++;
-               _pacman_strtrim(line);
+               f_strtrim(line);
if(_pacman_strempty(line) || line[0] == '#') {
continue;
}
@@ -72,9 +72,9 @@ int _pacman_pkginfo_fread(FILE *descfile, pmpkg_t *info, int 
output)
_pacman_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
info->name[0] != '\0' ? info->name : "error", linenum);
} else {
-                       _pacman_strtrim(key);
-                       key = _pacman_strtoupper(key);
-                       _pacman_strtrim(ptr);
+                       f_strtrim(key);
+                       key = f_strtoupper(key);
+                       f_strtrim(ptr);
if(!strcmp(key, "PKGNAME")) {
STRNCPY(info->name, ptr, sizeof(info->name));
} else if(!strcmp(key, "PKGVER")) {
diff --git a/lib/libpacman/util.c b/lib/libpacman/util.c
index cae601c..808daf0 100644
--- a/lib/libpacman/util.c
+++ b/lib/libpacman/util.c
@@ -186,51 +186,6 @@ int _pacman_copyfile(char *src, char *dest)
return(0);
}

-/* Convert a string to uppercase
- */
-char *_pacman_strtoupper(char *str)
-{
-       char *ptr = str;
-
-       while(*ptr) {
-               (*ptr) = toupper(*ptr);
-               ptr++;
-       }
-       return str;
-}
-
-/* Trim whitespace and newlines from a string
- */
-char *_pacman_strtrim(char *str)
-{
-       char *pch = str;
-
-       if(f_strempty(str)) {
-               /* string is empty, so we're done. */
-               return(str);
-       }
-
-       while(isspace((int)*pch)) {
-               pch++;
-       }
-       if(pch != str) {
-               memmove(str, pch, (strlen(pch) + 1));
-       }
-
-       /* check if there wasn't anything but whitespace in the string. */
-       if(f_strempty(str)) {
-               return(str);
-       }
-
-       pch = (char *)(str + (strlen(str) - 1));
-       while(isspace((int)*pch)) {
-               pch--;
-       }
-       *++pch = '\0';
-
-       return(str);
-}
-
/* Create a lock file
*/
int _pacman_lckmk(char *file)
@@ -495,12 +450,12 @@ int _pacman_chroot_system(const char *cmdline, pmtrans_t 
*trans)
break;
/* "START <event desc>" */
if((strlen(line) > strlen(STARTSTR)) && !strncmp(line, STARTSTR, 
strlen(STARTSTR))) {
-                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START, 
_pacman_strtrim(line + strlen(STARTSTR)), NULL);
+                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START, 
f_strtrim(line + strlen(STARTSTR)), NULL);
/* "DONE <ret code>" */
} else if((strlen(line) > strlen(DONESTR)) && !strncmp(line, DONESTR, 
strlen(DONESTR))) {
-                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE, 
(void*)atol(_pacman_strtrim(line + strlen(DONESTR))), NULL);
+                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE, 
(void*)atol(f_strtrim(line + strlen(DONESTR))), NULL);
} else {
-                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO, 
_pacman_strtrim(line), NULL);
+                               EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO, 
f_strtrim(line), NULL);
}
}
pclose(pp);
@@ -574,7 +529,7 @@ cleanup:

int _pacman_runhook(const char *hookname, pmtrans_t *trans)
{
-       char *hookdir, *root, *scriptpath;
+       char *hookdir, *root, *scriptpath;
char scriptfn[PATH_MAX];
char hookpath[PATH_MAX];
char cmdline[PATH_MAX];
diff --git a/lib/libpacman/util/log.c b/lib/libpacman/util/log.c
index dbaad1c..4694058 100644
--- a/lib/libpacman/util/log.c
+++ b/lib/libpacman/util/log.c
@@ -75,9 +75,9 @@ void _pacman_vlogaction(unsigned char usesyslog, FILE *f, 
const char *format, va

tm = _pacman_localtime(NULL);
fprintf(f, "[%02d/%02d/%02d %02d:%02d] %s\n",
-                       tm->tm_mon+1, tm->tm_mday, tm->tm_year-100,
-                       tm->tm_hour, tm->tm_min,
-                       _pacman_strtrim(msg));
+                               tm->tm_mon+1, tm->tm_mday, tm->tm_year-100,
+                               tm->tm_hour, tm->tm_min,
+                               f_strtrim(msg));
fflush(f);
}
}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to