Commit 4e2f4e20 authored by Max Kellermann's avatar Max Kellermann

util/StringUtil: add ToUpperASCII()

Replaces g_ascii_strup() and allows building the Vorbis encoder without GLib.
parent e69bef3c
......@@ -1145,9 +1145,8 @@ MPD_ENABLE_AUTO_PKG(shine_encoder, SHINE, [shine >= 3.1],
[shine encoder], [libshine not found])
dnl ---------------------------- Ogg Vorbis Encoder ---------------------------
MPD_ENABLE_AUTO_PKG_DEPENDS(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
[Ogg Vorbis encoder], [libvorbisenc not found], [],
[enable_glib], [Cannot use --enable-vorbis-encoder with --disable-glib])
MPD_ENABLE_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
[Ogg Vorbis encoder], [libvorbisenc not found])
dnl ------------------------------- LAME Encoder ------------------------------
......
......@@ -25,14 +25,13 @@
#include "tag/Tag.hxx"
#include "AudioFormat.hxx"
#include "config/ConfigError.hxx"
#include "util/StringUtil.hxx"
#include "util/NumberParser.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <vorbis/vorbisenc.h>
#include <glib.h>
struct vorbis_encoder {
/** the base class */
Encoder encoder;
......@@ -273,9 +272,9 @@ static void
copy_tag_to_vorbis_comment(vorbis_comment *vc, const Tag &tag)
{
for (const auto &item : tag) {
char *name = g_ascii_strup(tag_item_names[item.type], -1);
char name[64];
ToUpperASCII(name, tag_item_names[item.type], sizeof(name));
vorbis_comment_add_tag(vc, name, item.value);
g_free(name);
}
}
......
......@@ -120,3 +120,23 @@ string_array_contains(const char *const* haystack, const char *needle)
return false;
}
void
ToUpperASCII(char *dest, const char *src, size_t size)
{
assert(dest != nullptr);
assert(src != nullptr);
assert(size > 1);
char *const end = dest + size - 1;
do {
char ch = *src++;
if (ch == 0)
break;
*dest++ = ToUpperASCII(ch);
} while (dest < end);
*dest = 0;
}
......@@ -114,4 +114,12 @@ gcc_pure
bool
string_array_contains(const char *const* haystack, const char *needle);
/**
* Convert the specified ASCII string (0x00..0x7f) to upper case.
*
* @param size the destination buffer size
*/
void
ToUpperASCII(char *dest, const char *src, size_t size);
#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