commit 155ad9e8ff2f940c8b4f3c8a62e8a9f6eec724c5
parent cf3ef6b5a2a286b40b2e6e828b8de3a95dad909c
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 20 Jan 2013 19:14:34 +0100
add xstrdup for some compilers, prevent warning for ctype functions
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/common.c b/common.c
@@ -10,6 +10,15 @@ enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink,
const int FieldSeparator = '\t';
+void *
+xstrdup(const char *s) {
+ size_t len = strlen(s) + 1;
+ void *p = malloc(len);
+ if(p)
+ memcpy(p, s, len);
+ return p;
+}
+
char *
afgets(char **p, size_t *size, FILE *fp) {
char buf[BUFSIZ], *alloc = NULL;
@@ -54,7 +63,7 @@ printlink(const char *link, const char *baseurl) {
int isrelative;
/* protocol part */
- for(p = link; *p && (isalpha(*p) || isdigit(*p) || *p == '+' || *p == '-' || *p == '.'); p++);
+ for(p = link; *p && (isalpha((int)*p) || isdigit((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++);
isrelative = strncmp(p, "://", strlen("://"));
if(isrelative) { /* relative link (baseurl is used). */
if((ebaseproto = strstr(baseurl, "://"))) {