diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2013-01-20 19:14:34 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2013-01-20 19:14:34 +0100 |
commit | 155ad9e8ff2f940c8b4f3c8a62e8a9f6eec724c5 (patch) | |
tree | a7b6fa17669da6e2cc04a4f89ec020b8d1f708ec | |
parent | cf3ef6b5a2a286b40b2e6e828b8de3a95dad909c (diff) |
add xstrdup for some compilers, prevent warning for ctype functions
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
-rw-r--r-- | common.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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, "://"))) { |