summaryrefslogtreecommitdiff
path: root/include/dux/cstr.d/cstrcpy.hh
diff options
context:
space:
mode:
Diffstat (limited to 'include/dux/cstr.d/cstrcpy.hh')
-rw-r--r--include/dux/cstr.d/cstrcpy.hh27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/dux/cstr.d/cstrcpy.hh b/include/dux/cstr.d/cstrcpy.hh
new file mode 100644
index 0000000..a8e5f65
--- /dev/null
+++ b/include/dux/cstr.d/cstrcpy.hh
@@ -0,0 +1,27 @@
+/*
+ Copyright 2021 Gabriel Jensen
+
+ This file is part of dux.
+
+ dux is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ dux is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with dux. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+constexpr auto ::dux::cstrcpy(char * const dux_restr _dest,char const * const dux_restr _src) noexcept -> char * {
+ auto const sz = ::dux::cstrlen(_src);
+ if (sz == 0x0uz) [[unlikely]] {
+ return _dest;
+ }
+ ::dux::cpy(_src,_src + sz - 0x1uz,_dest);
+ return _dest;
+}