From 20597b3632d3b6e25ba532716106f90d5b64d0e8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 28 Oct 2013 23:58:17 +0100 Subject: *: use nullptr instead of NULL --- src/playlist/AsxPlaylistPlugin.cxx | 24 +++++++------- src/playlist/CuePlaylistPlugin.cxx | 8 ++--- src/playlist/EmbeddedCuePlaylistPlugin.cxx | 14 ++++----- src/playlist/M3uPlaylistPlugin.cxx | 6 ++-- src/playlist/PlsPlaylistPlugin.cxx | 30 +++++++++--------- src/playlist/RssPlaylistPlugin.cxx | 24 +++++++------- src/playlist/SoundCloudPlaylistPlugin.cxx | 50 +++++++++++++++--------------- src/playlist/XspfPlaylistPlugin.cxx | 24 +++++++------- 8 files changed, 90 insertions(+), 90 deletions(-) (limited to 'src/playlist') diff --git a/src/playlist/AsxPlaylistPlugin.cxx b/src/playlist/AsxPlaylistPlugin.cxx index 23985cad8..94198b8c3 100644 --- a/src/playlist/AsxPlaylistPlugin.cxx +++ b/src/playlist/AsxPlaylistPlugin.cxx @@ -75,11 +75,11 @@ static const gchar * get_attribute(const gchar **attribute_names, const gchar **attribute_values, const gchar *name) { - for (unsigned i = 0; attribute_names[i] != NULL; ++i) + for (unsigned i = 0; attribute_names[i] != nullptr; ++i) if (StringEqualsCaseASCII(attribute_names[i], name)) return attribute_values[i]; - return NULL; + return nullptr; } static void @@ -106,7 +106,7 @@ asx_start_element(gcc_unused GMarkupParseContext *context, const gchar *href = get_attribute(attribute_names, attribute_values, "href"); - if (href != NULL) { + if (href != nullptr) { /* create new song object, and copy the existing tag over; we cannot replace the existing song's URI, @@ -114,9 +114,9 @@ asx_start_element(gcc_unused GMarkupParseContext *context, immutable */ Song *song = Song::NewRemote(href); - if (parser->song != NULL) { + if (parser->song != nullptr) { song->tag = parser->song->tag; - parser->song->tag = NULL; + parser->song->tag = nullptr; parser->song->Free(); } @@ -172,7 +172,7 @@ asx_text(gcc_unused GMarkupParseContext *context, case AsxParser::ENTRY: if (parser->tag != TAG_NUM_OF_ITEM_TYPES) { - if (parser->song->tag == NULL) + if (parser->song->tag == nullptr) parser->song->tag = new Tag(); parser->song->tag->AddItem(parser->tag, text, text_len); @@ -213,7 +213,7 @@ asx_open_stream(InputStream &is) size_t nbytes; bool success; Error error2; - GError *error = NULL; + GError *error = nullptr; /* parse the ASX XML file */ @@ -227,7 +227,7 @@ asx_open_stream(InputStream &is) if (error2.IsDefined()) { g_markup_parse_context_free(context); LogError(error2); - return NULL; + return nullptr; } break; @@ -240,7 +240,7 @@ asx_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } } @@ -250,7 +250,7 @@ asx_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } parser.songs.reverse(); @@ -264,12 +264,12 @@ asx_open_stream(InputStream &is) static const char *const asx_suffixes[] = { "asx", - NULL + nullptr }; static const char *const asx_mime_types[] = { "video/x-ms-asf", - NULL + nullptr }; const struct playlist_plugin asx_playlist_plugin = { diff --git a/src/playlist/CuePlaylistPlugin.cxx b/src/playlist/CuePlaylistPlugin.cxx index 0ec030a54..42a43bbad 100644 --- a/src/playlist/CuePlaylistPlugin.cxx +++ b/src/playlist/CuePlaylistPlugin.cxx @@ -52,14 +52,14 @@ Song * CuePlaylist::NextSong() { Song *song = parser.Get(); - if (song != NULL) + if (song != nullptr) return song; std::string line; while (tis.ReadLine(line)) { parser.Feed(line.c_str()); song = parser.Get(); - if (song != NULL) + if (song != nullptr) return song; } @@ -69,12 +69,12 @@ CuePlaylist::NextSong() static const char *const cue_playlist_suffixes[] = { "cue", - NULL + nullptr }; static const char *const cue_playlist_mime_types[] = { "application/x-cue", - NULL + nullptr }; const struct playlist_plugin cue_playlist_plugin = { diff --git a/src/playlist/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/EmbeddedCuePlaylistPlugin.cxx index b21d78daa..d758650eb 100644 --- a/src/playlist/EmbeddedCuePlaylistPlugin.cxx +++ b/src/playlist/EmbeddedCuePlaylistPlugin.cxx @@ -97,7 +97,7 @@ embcue_playlist_open_uri(const char *uri, { if (!PathTraits::IsAbsoluteUTF8(uri)) /* only local files supported */ - return NULL; + return nullptr; const auto path_fs = AllocatedPath::FromUTF8(uri); if (path_fs.IsNull()) @@ -115,7 +115,7 @@ embcue_playlist_open_uri(const char *uri, if (playlist->cuesheet.empty()) { /* no "CUESHEET" tag found */ delete playlist; - return NULL; + return nullptr; } playlist->filename = PathTraits::GetBaseUTF8(uri); @@ -130,13 +130,13 @@ Song * EmbeddedCuePlaylist::NextSong() { Song *song = parser->Get(); - if (song != NULL) + if (song != nullptr) return song; while (*next != 0) { const char *line = next; char *eol = strpbrk(next, "\r\n"); - if (eol != NULL) { + if (eol != nullptr) { /* null-terminate the line */ *eol = 0; next = eol + 1; @@ -147,13 +147,13 @@ EmbeddedCuePlaylist::NextSong() parser->Feed(line); song = parser->Get(); - if (song != NULL) + if (song != nullptr) return song->ReplaceURI(filename.c_str()); } parser->Finish(); song = parser->Get(); - if (song != NULL) + if (song != nullptr) song = song->ReplaceURI(filename.c_str()); return song; } @@ -167,7 +167,7 @@ static const char *const embcue_playlist_suffixes[] = { "ape", "wv", "ogg", "oga", - NULL + nullptr }; const struct playlist_plugin embcue_playlist_plugin = { diff --git a/src/playlist/M3uPlaylistPlugin.cxx b/src/playlist/M3uPlaylistPlugin.cxx index 20b192cf5..3f99bdfdf 100644 --- a/src/playlist/M3uPlaylistPlugin.cxx +++ b/src/playlist/M3uPlaylistPlugin.cxx @@ -50,7 +50,7 @@ M3uPlaylist::NextSong() do { if (!tis.ReadLine(line)) - return NULL; + return nullptr; line_s = line.c_str(); line_s = strchug_fast(line_s); @@ -61,12 +61,12 @@ M3uPlaylist::NextSong() static const char *const m3u_suffixes[] = { "m3u", - NULL + nullptr }; static const char *const m3u_mime_types[] = { "audio/x-mpegurl", - NULL + nullptr }; const struct playlist_plugin m3u_playlist_plugin = { diff --git a/src/playlist/PlsPlaylistPlugin.cxx b/src/playlist/PlsPlaylistPlugin.cxx index 46143225b..b6c723b5a 100644 --- a/src/playlist/PlsPlaylistPlugin.cxx +++ b/src/playlist/PlsPlaylistPlugin.cxx @@ -39,21 +39,21 @@ pls_parser(GKeyFile *keyfile, std::forward_list &songs) { gchar *value; int length; - GError *error = NULL; + GError *error = nullptr; int num_entries = g_key_file_get_integer(keyfile, "playlist", "NumberOfEntries", &error); if (error) { FormatError(pls_domain, "Invalid PLS file: '%s'", error->message); g_error_free(error); - error = NULL; + error = nullptr; /* Hack to work around shoutcast failure to comform to spec */ num_entries = g_key_file_get_integer(keyfile, "playlist", "numberofentries", &error); if (error) { g_error_free(error); - error = NULL; + error = nullptr; } } @@ -78,27 +78,27 @@ pls_parser(GKeyFile *keyfile, std::forward_list &songs) sprintf(key, "Title%u", num_entries); value = g_key_file_get_string(keyfile, "playlist", key, &error); - if(error == NULL && value){ - if (song->tag == NULL) + if(error == nullptr && value){ + if (song->tag == nullptr) song->tag = new Tag(); song->tag->AddItem(TAG_TITLE, value); } /* Ignore errors? Most likely value not present */ if(error) g_error_free(error); - error = NULL; + error = nullptr; g_free(value); sprintf(key, "Length%u", num_entries); length = g_key_file_get_integer(keyfile, "playlist", key, &error); - if(error == NULL && length > 0){ - if (song->tag == NULL) + if(error == nullptr && length > 0){ + if (song->tag == nullptr) song->tag = new Tag(); song->tag->time = length; } /* Ignore errors? Most likely value not present */ if(error) g_error_free(error); - error = NULL; + error = nullptr; songs.emplace_front(song); num_entries--; @@ -109,7 +109,7 @@ pls_parser(GKeyFile *keyfile, std::forward_list &songs) static SongEnumerator * pls_open_stream(InputStream &is) { - GError *error = NULL; + GError *error = nullptr; Error error2; size_t nbytes; char buffer[1024]; @@ -123,7 +123,7 @@ pls_open_stream(InputStream &is) if (nbytes == 0) { if (error2.IsDefined()) { LogError(error2); - return NULL; + return nullptr; } break; @@ -135,7 +135,7 @@ pls_open_stream(InputStream &is) if (kf_data.empty()) { LogWarning(pls_domain, "KeyFile parser failed: No Data"); - return NULL; + return nullptr; } keyfile = g_key_file_new(); @@ -148,7 +148,7 @@ pls_open_stream(InputStream &is) "KeyFile parser failed: %s", error->message); g_error_free(error); g_key_file_free(keyfile); - return NULL; + return nullptr; } std::forward_list songs; @@ -161,12 +161,12 @@ pls_open_stream(InputStream &is) static const char *const pls_suffixes[] = { "pls", - NULL + nullptr }; static const char *const pls_mime_types[] = { "audio/x-scpls", - NULL + nullptr }; const struct playlist_plugin pls_playlist_plugin = { diff --git a/src/playlist/RssPlaylistPlugin.cxx b/src/playlist/RssPlaylistPlugin.cxx index 43ad68cf6..e2a44bfd3 100644 --- a/src/playlist/RssPlaylistPlugin.cxx +++ b/src/playlist/RssPlaylistPlugin.cxx @@ -74,11 +74,11 @@ static const gchar * get_attribute(const gchar **attribute_names, const gchar **attribute_values, const gchar *name) { - for (unsigned i = 0; attribute_names[i] != NULL; ++i) + for (unsigned i = 0; attribute_names[i] != nullptr; ++i) if (StringEqualsCaseASCII(attribute_names[i], name)) return attribute_values[i]; - return NULL; + return nullptr; } static void @@ -105,7 +105,7 @@ rss_start_element(gcc_unused GMarkupParseContext *context, const gchar *href = get_attribute(attribute_names, attribute_values, "url"); - if (href != NULL) { + if (href != nullptr) { /* create new song object, and copy the existing tag over; we cannot replace the existing song's URI, @@ -113,9 +113,9 @@ rss_start_element(gcc_unused GMarkupParseContext *context, immutable */ Song *song = Song::NewRemote(href); - if (parser->song != NULL) { + if (parser->song != nullptr) { song->tag = parser->song->tag; - parser->song->tag = NULL; + parser->song->tag = nullptr; parser->song->Free(); } @@ -169,7 +169,7 @@ rss_text(gcc_unused GMarkupParseContext *context, case RssParser::ITEM: if (parser->tag != TAG_NUM_OF_ITEM_TYPES) { - if (parser->song->tag == NULL) + if (parser->song->tag == nullptr) parser->song->tag = new Tag(); parser->song->tag->AddItem(parser->tag, text, text_len); @@ -210,7 +210,7 @@ rss_open_stream(InputStream &is) size_t nbytes; bool success; Error error2; - GError *error = NULL; + GError *error = nullptr; /* parse the RSS XML file */ @@ -224,7 +224,7 @@ rss_open_stream(InputStream &is) if (error2.IsDefined()) { g_markup_parse_context_free(context); LogError(error2); - return NULL; + return nullptr; } break; @@ -237,7 +237,7 @@ rss_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } } @@ -247,7 +247,7 @@ rss_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } parser.songs.reverse(); @@ -261,13 +261,13 @@ rss_open_stream(InputStream &is) static const char *const rss_suffixes[] = { "rss", - NULL + nullptr }; static const char *const rss_mime_types[] = { "application/rss+xml", "text/xml", - NULL + nullptr }; const struct playlist_plugin rss_playlist_plugin = { diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index f9c030a21..f6797b14d 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -68,10 +68,10 @@ soundcloud_resolve(const char* uri) { if (g_str_has_prefix(uri, "http://")) { u = g_strdup(uri); } else if (g_str_has_prefix(uri, "soundcloud.com")) { - u = g_strconcat("http://", uri, NULL); + u = g_strconcat("http://", uri, nullptr); } else { /* assume it's just a path on soundcloud.com */ - u = g_strconcat("http://soundcloud.com/", uri, NULL); + u = g_strconcat("http://soundcloud.com/", uri, nullptr); } ru = g_strconcat("http://api.soundcloud.com/resolve.json?url=", @@ -95,7 +95,7 @@ const char* key_str[] = { "duration", "title", "stream_url", - NULL, + nullptr, }; struct parse_data { @@ -141,12 +141,12 @@ static int handle_string(void *ctx, const unsigned char* stringval, switch (data->key) { case Title: - if (data->title != NULL) + if (data->title != nullptr) g_free(data->title); data->title = g_strndup(s, stringlen); break; case Stream_URL: - if (data->stream_url != NULL) + if (data->stream_url != nullptr) g_free(data->stream_url); data->stream_url = g_strndup(s, stringlen); data->got_url = 1; @@ -216,7 +216,7 @@ static int handle_end_map(void *ctx) Tag *t = new Tag(); t->time = data->duration / 1000; - if (data->title != NULL) + if (data->title != nullptr) t->AddItem(TAG_NAME, data->title); s->tag = t; @@ -226,17 +226,17 @@ static int handle_end_map(void *ctx) } static yajl_callbacks parse_callbacks = { - NULL, - NULL, + nullptr, + nullptr, handle_integer, - NULL, - NULL, + nullptr, + nullptr, handle_string, handle_start_map, handle_mapkey, handle_end_map, - NULL, - NULL, + nullptr, + nullptr, }; /** @@ -255,7 +255,7 @@ soundcloud_parse_json(const char *url, yajl_handle hand, Error error; InputStream *input_stream = InputStream::Open(url, mutex, cond, error); - if (input_stream == NULL) { + if (input_stream == nullptr) { if (error.IsDefined()) LogError(error); return -1; @@ -348,10 +348,10 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) "incompatible scheme for soundcloud plugin: %s", scheme); g_free(s); - return NULL; + return nullptr; } - char *u = NULL; + char *u = nullptr; if (strcmp(arg, "track") == 0) { u = g_strconcat("http://api.soundcloud.com/tracks/", rest, ".json?client_id=", @@ -367,34 +367,34 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) } g_free(s); - if (u == NULL) { + if (u == nullptr) { LogWarning(soundcloud_domain, "unknown soundcloud URI"); - return NULL; + return nullptr; } yajl_handle hand; struct parse_data data; data.got_url = 0; - data.title = NULL; - data.stream_url = NULL; + data.title = nullptr; + data.stream_url = nullptr; #ifdef HAVE_YAJL1 - hand = yajl_alloc(&parse_callbacks, NULL, NULL, (void *) &data); + hand = yajl_alloc(&parse_callbacks, nullptr, nullptr, (void *) &data); #else - hand = yajl_alloc(&parse_callbacks, NULL, (void *) &data); + hand = yajl_alloc(&parse_callbacks, nullptr, (void *) &data); #endif int ret = soundcloud_parse_json(u, hand, mutex, cond); g_free(u); yajl_free(hand); - if (data.title != NULL) + if (data.title != nullptr) g_free(data.title); - if (data.stream_url != NULL) + if (data.stream_url != nullptr) g_free(data.stream_url); if (ret == -1) - return NULL; + return nullptr; data.songs.reverse(); return new MemorySongEnumerator(std::move(data.songs)); @@ -402,7 +402,7 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) static const char *const soundcloud_schemes[] = { "soundcloud", - NULL + nullptr }; const struct playlist_plugin soundcloud_playlist_plugin = { diff --git a/src/playlist/XspfPlaylistPlugin.cxx b/src/playlist/XspfPlaylistPlugin.cxx index 75991cfd4..dcfab5a80 100644 --- a/src/playlist/XspfPlaylistPlugin.cxx +++ b/src/playlist/XspfPlaylistPlugin.cxx @@ -94,7 +94,7 @@ xspf_start_element(gcc_unused GMarkupParseContext *context, case XspfParser::TRACKLIST: if (strcmp(element_name, "track") == 0) { parser->state = XspfParser::TRACK; - parser->song = NULL; + parser->song = nullptr; parser->tag = TAG_NUM_OF_ITEM_TYPES; } @@ -148,7 +148,7 @@ xspf_end_element(gcc_unused GMarkupParseContext *context, case XspfParser::TRACK: if (strcmp(element_name, "track") == 0) { - if (parser->song != NULL) + if (parser->song != nullptr) parser->songs.emplace_front(parser->song); parser->state = XspfParser::TRACKLIST; @@ -177,9 +177,9 @@ xspf_text(gcc_unused GMarkupParseContext *context, break; case XspfParser::TRACK: - if (parser->song != NULL && + if (parser->song != nullptr && parser->tag != TAG_NUM_OF_ITEM_TYPES) { - if (parser->song->tag == NULL) + if (parser->song->tag == nullptr) parser->song->tag = new Tag(); parser->song->tag->AddItem(parser->tag, text, text_len); } @@ -187,7 +187,7 @@ xspf_text(gcc_unused GMarkupParseContext *context, break; case XspfParser::LOCATION: - if (parser->song == NULL) { + if (parser->song == nullptr) { char *uri = g_strndup(text, text_len); parser->song = Song::NewRemote(uri); g_free(uri); @@ -210,7 +210,7 @@ xspf_parser_destroy(gpointer data) { XspfParser *parser = (XspfParser *)data; - if (parser->state >= XspfParser::TRACK && parser->song != NULL) + if (parser->state >= XspfParser::TRACK && parser->song != nullptr) parser->song->Free(); } @@ -228,7 +228,7 @@ xspf_open_stream(InputStream &is) size_t nbytes; bool success; Error error2; - GError *error = NULL; + GError *error = nullptr; /* parse the XSPF XML file */ @@ -242,7 +242,7 @@ xspf_open_stream(InputStream &is) if (error2.IsDefined()) { g_markup_parse_context_free(context); LogError(error2); - return NULL; + return nullptr; } break; @@ -255,7 +255,7 @@ xspf_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } } @@ -265,7 +265,7 @@ xspf_open_stream(InputStream &is) "XML parser failed: %s", error->message); g_error_free(error); g_markup_parse_context_free(context); - return NULL; + return nullptr; } parser.songs.reverse(); @@ -279,12 +279,12 @@ xspf_open_stream(InputStream &is) static const char *const xspf_suffixes[] = { "xspf", - NULL + nullptr }; static const char *const xspf_mime_types[] = { "application/xspf+xml", - NULL + nullptr }; const struct playlist_plugin xspf_playlist_plugin = { -- cgit v1.2.3