[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 07/13: src/include/stringclass.h: Fix code style nit.
From: |
G. Branden Robinson |
Subject: |
[groff] 07/13: src/include/stringclass.h: Fix code style nit. |
Date: |
Mon, 7 Oct 2024 08:00:14 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 788992d896150bbc161f60748d9e7db10e812f93
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 6 11:59:06 2024 -0500
src/include/stringclass.h: Fix code style nit.
* src/include/stringclass.h (class string): Fix code style nit:
`const`-ify argument to `search` public member function.
Also delete trailing whitespace from file.
---
ChangeLog | 5 +++++
src/include/stringclass.h | 14 +++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dfd8ec63c..dd9e7bc9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-10-06 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/include/stringclass.h (class string): Fix code style nit:
+ `const`-ify argument to `search` public member function.
+
2024-10-05 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/reg.cpp (dump_register): Remove garbage from
diff --git a/src/include/stringclass.h b/src/include/stringclass.h
index cc4616009..6889c41a9 100644
--- a/src/include/stringclass.h
+++ b/src/include/stringclass.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -46,7 +46,7 @@ public:
string(char);
~string();
-
+
string &operator=(const string &);
string &operator=(const char *);
string &operator=(char);
@@ -55,7 +55,7 @@ public:
string &operator+=(const char *);
string &operator+=(char);
void append(const char *, int);
-
+
int length() const;
int empty() const;
int operator*() const;
@@ -67,7 +67,7 @@ public:
void set_length(int i);
const char *contents() const;
- int search(char) const;
+ int search(const char) const;
char *extract() const;
void remove_spaces();
void clear();
@@ -78,7 +78,7 @@ public:
friend string operator+(const char *, const string &);
friend string operator+(const string &, char);
friend string operator+(char, const string &);
-
+
friend int operator==(const string &, const string &);
friend int operator!=(const string &, const string &);
friend int operator<=(const string &, const string &);
@@ -169,13 +169,13 @@ inline string operator+(char c, const string &s)
inline int operator==(const string &s1, const string &s2)
{
- return (s1.len == s2.len
+ return (s1.len == s2.len
&& (s1.len == 0 || memcmp(s1.ptr, s2.ptr, s1.len) == 0));
}
inline int operator!=(const string &s1, const string &s2)
{
- return (s1.len != s2.len
+ return (s1.len != s2.len
|| (s1.len != 0 && memcmp(s1.ptr, s2.ptr, s1.len) != 0));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 07/13: src/include/stringclass.h: Fix code style nit.,
G. Branden Robinson <=