Commit dad7d7e7 authored by Max Kellermann's avatar Max Kellermann

util/TruncateString: rename CopyString() to CopyTruncateString()

parent 4b94ae80
...@@ -143,7 +143,7 @@ parse_cdio_uri(struct cdio_uri *dest, const char *src) ...@@ -143,7 +143,7 @@ parse_cdio_uri(struct cdio_uri *dest, const char *src)
const char *slash = strrchr(src, '/'); const char *slash = strrchr(src, '/');
if (slash == nullptr) { if (slash == nullptr) {
/* play the whole CD in the specified drive */ /* play the whole CD in the specified drive */
CopyString(dest->device, src, sizeof(dest->device)); CopyTruncateString(dest->device, src, sizeof(dest->device));
dest->track = -1; dest->track = -1;
return true; return true;
} }
......
...@@ -38,7 +38,7 @@ Java::String::CopyTo(JNIEnv *env, jstring value, ...@@ -38,7 +38,7 @@ Java::String::CopyTo(JNIEnv *env, jstring value,
if (p == nullptr) if (p == nullptr)
return nullptr; return nullptr;
char *result = CopyString(buffer, p, max_size); char *result = CopyTruncateString(buffer, p, max_size);
env->ReleaseStringUTFChars(value, p); env->ReleaseStringUTFChars(value, p);
return result; return result;
} }
...@@ -101,10 +101,10 @@ icy_server_metadata_page(const Tag &tag, const TagType *types) ...@@ -101,10 +101,10 @@ icy_server_metadata_page(const Tag &tag, const TagType *types)
stream_title[0] = '\0'; stream_title[0] = '\0';
while (p < end && item <= last_item) { while (p < end && item <= last_item) {
p = CopyString(p, tag_items[item++], end - p); p = CopyTruncateString(p, tag_items[item++], end - p);
if (item <= last_item) if (item <= last_item)
p = CopyString(p, " - ", end - p); p = CopyTruncateString(p, " - ", end - p);
} }
const auto icy_string = icy_server_metadata_string(stream_title, ""); const auto icy_string = icy_server_metadata_string(stream_title, "");
......
...@@ -73,7 +73,7 @@ SanitizeString(const char *s, char *buffer, size_t buffer_size) noexcept ...@@ -73,7 +73,7 @@ SanitizeString(const char *s, char *buffer, size_t buffer_size) noexcept
if (!HasUnsafeChar(s)) if (!HasUnsafeChar(s))
return s; return s;
char *end = CopyString(buffer, s, buffer_size); char *end = CopyTruncateString(buffer, s, buffer_size);
std::replace_if(buffer, end, IsUnsafeChar, ' '); std::replace_if(buffer, end, IsUnsafeChar, ' ');
return buffer; return buffer;
} }
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include <string.h> #include <string.h>
char * char *
CopyString(char *gcc_restrict dest, const char *gcc_restrict src, CopyTruncateString(char *gcc_restrict dest, const char *gcc_restrict src,
size_t size) noexcept size_t size) noexcept
{ {
size_t length = strlen(src); size_t length = strlen(src);
if (length >= size) if (length >= size)
......
...@@ -44,6 +44,6 @@ ...@@ -44,6 +44,6 @@
*/ */
gcc_nonnull_all gcc_nonnull_all
char * char *
CopyString(char *dest, const char *src, size_t size) noexcept; CopyTruncateString(char *dest, const char *src, size_t size) noexcept;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment