summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/string_utils.C17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/string_utils.C b/src/lib/string_utils.C
index 27d9228fb..6e7bcd804 100644
--- a/src/lib/string_utils.C
+++ b/src/lib/string_utils.C
@@ -159,20 +159,17 @@ extern "C" int strncmp(const char* a, const char* b, size_t l)
extern "C" char* strncpy(char* d, const char* s, size_t l)
{
char* d1 = d;
- size_t len = 0;
-
- do
+ while ( (l > 0) && (*s != '\0') )
{
- if (len++ >= l) break;
- *d1 = *s;
- if (*s == '\0') break;
- d1++; s++;
- } while(1);
+ *d1++ = *s++;
+ --l;
+ }
// pad the remainder
- while( len < l )
+ while (l > 0)
{
- d1[len++] = '\0';
+ *d1++ = '\0';
+ --l;
}
return d;
OpenPOWER on IntegriCloud