MCPcopy Create free account
hub / github.com/coreutils/coreutils / subst_suffix

Function subst_suffix

src/copy.c:1527–1535  ·  view source on GitHub ↗

Return a newly-allocated string that is like STR except replace its suffix SUFFIX with NEWSUFFIX. */

Source from the content-addressed store, hash-verified

1525/* Return a newly-allocated string that is like STR
1526 except replace its suffix SUFFIX with NEWSUFFIX. */
1527static char *
1528subst_suffix (char const *str, char const *suffix, char const *newsuffix)
1529{
1530 idx_t prefixlen = suffix - str;
1531 idx_t newsuffixsize = strlen (newsuffix) + 1;
1532 char *r = ximalloc (prefixlen + newsuffixsize);
1533 memcpy (r + prefixlen, newsuffix, newsuffixsize);
1534 return memcpy (r, str, prefixlen);
1535}
1536
1537/* Create a hard link to SRC_NAME aka SRC_DIRFD+SRC_RELNAME;
1538 the new link is at DST_NAME aka DST_DIRFD+DST_RELNAME.

Callers 3

create_hard_linkFunction · 0.85
source_is_dst_backupFunction · 0.85
copy_internalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected