diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2005-08-15 03:54:31 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2005-08-15 03:54:31 +0000 |
commit | c0299e1868312e623c9b2ec6646cc7d1a5fe0f69 (patch) | |
tree | 83ea37f76e53ce502bbd813f7f93ed99d4df9efa /src/text.c | |
parent | 38f0b3a10354cd2297ae173a07ade3acd1aebd9a (diff) |
* [Indent] Ran Source Through indent
I re-indented the source code using indent with the following options:
indent -kr -bad -bap -nut -i8 -l80 -psl -sob -ss -ncs
There are now _no_ tabs in the source files, and all indentation is
eight spaces. Lines are 80 characters long, and the procedure type is
on it's own line. Read the indent manual for more information about
what each option means.
Diffstat (limited to 'src/text.c')
-rw-r--r-- | src/text.c | 73 |
1 files changed, 38 insertions, 35 deletions
@@ -1,4 +1,4 @@ -/* $Id: text.c,v 1.4 2005-07-12 17:39:44 rjkaes Exp $ +/* $Id: text.c,v 1.5 2005-08-15 03:54:31 rjkaes Exp $ * * The functions included here are useful for text manipulation. They * replace or augment the standard C string library. These functions @@ -31,16 +31,16 @@ size_t strlcpy(char *dst, const char *src, size_t size) { - size_t len = strlen(src); - size_t ret = len; + size_t len = strlen(src); + size_t ret = len; - if (len >= size) - len = size - 1; + if (len >= size) + len = size - 1; - memcpy(dst, src, len); - dst[len] = '\0'; + memcpy(dst, src, len); + dst[len] = '\0'; - return ret; + return ret; } #endif @@ -54,18 +54,18 @@ strlcpy(char *dst, const char *src, size_t size) size_t strlcat(char *dst, const char *src, size_t size) { - size_t len1 = strlen(dst); - size_t len2 = strlen(src); - size_t ret = len1 + len2; - - if (len1 + len2 >= size) - len2 = size - len1 - 1; - if (len2 > 0) { - memcpy(dst + len1, src, len2); - dst[len1 + len2] = '\0'; - } - - return ret; + size_t len1 = strlen(dst); + size_t len2 = strlen(src); + size_t ret = len1 + len2; + + if (len1 + len2 >= size) + len2 = size - len1 - 1; + if (len2 > 0) { + memcpy(dst + len1, src, len2); + dst[len1 + len2] = '\0'; + } + + return ret; } #endif @@ -81,25 +81,28 @@ strlcat(char *dst, const char *src, size_t size) ssize_t chomp(char *buffer, size_t length) { - size_t chars; + size_t chars; - assert(buffer != NULL); - assert(length > 0); + assert(buffer != NULL); + assert(length > 0); - /* Make sure the arguments are valid */ - if (buffer == NULL) return -EFAULT; - if (length < 1) return -ERANGE; + /* Make sure the arguments are valid */ + if (buffer == NULL) + return -EFAULT; + if (length < 1) + return -ERANGE; - chars = 0; + chars = 0; - --length; - while (buffer[length] == '\r' || buffer[length] == '\n') { - buffer[length] = '\0'; - chars++; + --length; + while (buffer[length] == '\r' || buffer[length] == '\n') { + buffer[length] = '\0'; + chars++; - /* Stop once we get to zero to prevent wrap-around */ - if (length-- == 0) break; - } + /* Stop once we get to zero to prevent wrap-around */ + if (length-- == 0) + break; + } - return chars; + return chars; } |