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

This commit is contained in:
Max Kellermann
2021-11-26 16:23:16 +01:00
parent f01388559f
commit 05f529fffd
5 changed files with 24 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
/*
* 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;