Commit 05f529ff authored by Max Kellermann's avatar Max Kellermann

util/StringStrip: use [[gnu::...]] attributes

parent f0138855
......@@ -19,6 +19,7 @@
#include "LogBackend.hxx"
#include "Log.hxx"
#include "util/Compiler.h"
#include "util/Domain.hxx"
#include "util/StringStrip.hxx"
#include "Version.h"
......@@ -110,7 +111,7 @@ chomp_length(std::string_view p) noexcept
#ifdef HAVE_SYSLOG
gcc_const
[[gnu::const]]
static int
ToSysLogLevel(LogLevel log_level) noexcept
{
......
/*
* Copyright 2009-2020 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2009-2021 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......
/*
* Copyright 2009-2020 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2009-2021 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -30,8 +30,6 @@
#ifndef STRING_STRIP_HXX
#define STRING_STRIP_HXX
#include "Compiler.h"
#include <cstddef>
/**
......@@ -40,11 +38,11 @@
* non-whitespace characters, then a pointer to the NULL terminator is
* returned.
*/
gcc_pure gcc_returns_nonnull gcc_nonnull_all
[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]]
const char *
StripLeft(const char *p) noexcept;
gcc_pure gcc_returns_nonnull gcc_nonnull_all
[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]]
static inline char *
StripLeft(char *p) noexcept
{
......@@ -55,21 +53,21 @@ StripLeft(char *p) noexcept
* Skips whitespace at the beginning of the string, and returns the
* first non-whitespace character or the end pointer.
*/
gcc_pure gcc_returns_nonnull gcc_nonnull_all
[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]]
const char *
StripLeft(const char *p, const char *end) noexcept;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure gcc_returns_nonnull gcc_nonnull_all
[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]]
const char *
StripRight(const char *p, const char *end) noexcept;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure gcc_returns_nonnull gcc_nonnull_all
[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]]
static inline char *
StripRight(char *p, char *end) noexcept
{
......@@ -81,14 +79,14 @@ StripRight(char *p, char *end) noexcept
* Determine the string's length as if it was stripped on the right
* side.
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
std::size_t
StripRight(const char *p, std::size_t length) noexcept;
/**
* Strip trailing whitespace by null-terminating the string.
*/
gcc_nonnull_all
[[gnu::nonnull]]
void
StripRight(char *p) noexcept;
......@@ -96,7 +94,7 @@ StripRight(char *p) noexcept;
* Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character.
*/
gcc_returns_nonnull gcc_nonnull_all
[[gnu::returns_nonnull]] [[gnu::nonnull]]
char *
Strip(char *p) noexcept;
......
/*
* Copyright 2011-2019 Max Kellermann <max.kellermann@gmail.com>
* http://www.musicpd.org
* Copyright 2011-2021 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -30,6 +29,7 @@
#include "UTF8.hxx"
#include "CharUtil.hxx"
#include "Compiler.h"
#include <algorithm>
#include <cstdint>
......@@ -196,7 +196,7 @@ SequenceLengthUTF8(char ch) noexcept
template<std::size_t L>
struct CheckSequenceUTF8 {
gcc_pure
[[gnu::pure]]
bool operator()(const char *p) const noexcept {
return IsContinuation(*p) && CheckSequenceUTF8<L-1>()(p + 1);
}
......@@ -210,7 +210,7 @@ struct CheckSequenceUTF8<0U> {
};
template<std::size_t L>
gcc_pure
[[gnu::pure]]
static std::size_t
InnerSequenceLengthUTF8(const char *p) noexcept
{
......@@ -247,7 +247,7 @@ SequenceLengthUTF8(const char *p) noexcept
return 0;
}
gcc_pure
[[gnu::pure]]
static const char *
FindNonASCIIOrZero(const char *p) noexcept
{
......
/*
* Copyright 2011-2019 Max Kellermann <max.kellermann@gmail.com>
* http://www.musicpd.org
* Copyright 2011-2021 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -31,14 +30,12 @@
#ifndef UTF8_HXX
#define UTF8_HXX
#include "Compiler.h"
#include <cstddef>
/**
* Is this a valid UTF-8 string?
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
bool
ValidateUTF8(const char *p) noexcept;
......@@ -46,7 +43,7 @@ ValidateUTF8(const char *p) noexcept;
* @return the number of the sequence beginning with the given
* character, or 0 if the character is not a valid start byte
*/
gcc_const
[[gnu::const]]
std::size_t
SequenceLengthUTF8(char ch) noexcept;
......@@ -54,7 +51,7 @@ SequenceLengthUTF8(char ch) noexcept;
* @return the number of the first sequence in the given string, or 0
* if the sequence is malformed
*/
gcc_pure
[[gnu::pure]]
std::size_t
SequenceLengthUTF8(const char *p) noexcept;
......@@ -65,7 +62,7 @@ SequenceLengthUTF8(const char *p) noexcept;
* there are no non-ASCII characters; returns nullptr if the destination
* buffer is too small
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
const char *
Latin1ToUTF8(const char *src, char *buffer, std::size_t buffer_size) noexcept;
......@@ -75,7 +72,7 @@ Latin1ToUTF8(const char *src, char *buffer, std::size_t buffer_size) noexcept;
*
* @return a pointer to the buffer plus the added bytes(s)
*/
gcc_nonnull_all
[[gnu::nonnull]]
char *
UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
......@@ -83,7 +80,7 @@ UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
* Returns the number of characters in the string. This is different
* from strlen(), which counts the number of bytes.
*/
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
std::size_t
LengthUTF8(const char *p) noexcept;
......
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