Mercurial > hg > th-libs
changeset 44:669d2bc97c57
More cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 03 Oct 2011 00:28:55 +0300 |
parents | 8c015ac0c556 |
children | e031a062b731 |
files | th_string.c |
diffstat | 1 files changed, 16 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/th_string.c Mon Oct 03 00:21:32 2011 +0300 +++ b/th_string.c Mon Oct 03 00:28:55 2011 +0300 @@ -17,10 +17,10 @@ char *res; if (s == NULL) return NULL; - + if ((res = th_malloc(strlen(s) + 1)) == NULL) return NULL; - + strcpy(res, s); return res; } @@ -65,7 +65,7 @@ if ((buf = th_malloc(size)) == NULL) return NULL; - + while (1) { int n; @@ -86,7 +86,7 @@ th_free(buf); return NULL; } - + buf = nbuf; } } @@ -335,7 +335,8 @@ } else didMatch = FALSE; - } else + } + else isEnd = TRUE; } break; @@ -409,7 +410,8 @@ { pattern++; str++; - } else + } + else didMatch = FALSE; break; @@ -440,7 +442,8 @@ } else didMatch = FALSE; - } else + } + else isEnd = TRUE; } break; @@ -498,7 +501,7 @@ { const char *p = str; int len, val = 0; - + for (len = 0; *p && len < 6; p++, len++) { if (*p >= '0' && *p <= '9') @@ -519,7 +522,7 @@ else return -1; } - + return (len == 6) ? val : -1; } @@ -528,7 +531,7 @@ { if (*buf == NULL) *bufsize = *len = 0; - + if (*buf == NULL || *len + grow >= *bufsize) { *bufsize += grow + TH_BUFGROW; @@ -544,7 +547,7 @@ { if (!th_growbuf(buf, bufsize, len, 1)) return FALSE; - + (*buf)[*len] = ch; (*len)++; @@ -557,14 +560,13 @@ size_t slen; if (str == NULL) return FALSE; - + slen = strlen(str); if (!th_growbuf(buf, bufsize, len, slen)) return FALSE; strcpy(*buf + *len, str); (*len) += slen; - + return TRUE; } -