summaryrefslogtreecommitdiff
path: root/src/inspstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inspstring.cpp')
-rw-r--r--src/inspstring.cpp87
1 files changed, 43 insertions, 44 deletions
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
index f5f607609..98e7228d5 100644
--- a/src/inspstring.cpp
+++ b/src/inspstring.cpp
@@ -43,60 +43,59 @@
#ifndef HAS_STRLCPY
CoreExport size_t strlcat(char *dst, const char *src, size_t siz)
{
- char *d = dst;
- const char *s = src;
- size_t n = siz, dlen;
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz, dlen;
- while (n-- != 0 && *d != '\0')
- d++;
+ while (n-- != 0 && *d != '\0')
+ d++;
- dlen = d - dst;
- n = siz - dlen;
+ dlen = d - dst;
+ n = siz - dlen;
- if (n == 0)
- return(dlen + strlen(s));
+ if (n == 0)
+ return(dlen + strlen(s));
- while (*s != '\0')
- {
- if (n != 1)
- {
- *d++ = *s;
- n--;
- }
+ while (*s != '\0')
+ {
+ if (n != 1)
+ {
+ *d++ = *s;
+ n--;
+ }
- s++;
- }
+ s++;
+ }
- *d = '\0';
- return(dlen + (s - src)); /* count does not include NUL */
+ *d = '\0';
+ return(dlen + (s - src)); /* count does not include NUL */
}
CoreExport size_t strlcpy(char *dst, const char *src, size_t siz)
{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0)
- {
- do
- {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0)
- {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0)
+ {
+ do
+ {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0)
+ {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++);
+ }
+
+ return(s - src - 1); /* count does not include NUL */
}
#endif