From 155ad9e8ff2f940c8b4f3c8a62e8a9f6eec724c5 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 20 Jan 2013 19:14:34 +0100 Subject: add xstrdup for some compilers, prevent warning for ctype functions Signed-off-by: Hiltjo Posthuma --- common.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common.c b/common.c index 552e9af..647f062 100644 --- 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, "://"))) { -- cgit v1.2.3