gbranden pushed a commit to branch master
in repository groff.
commit 815ce3204a52c305a6cf6ec0b2ebade497a5df3a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 23 15:55:55 2025 -0500
[libgroff]: Fix code style nit (1/2).
* src/include/stringclass.h (operator[], string::empty, operator+)
(string::substring): Parenthesize formally complex expressions.
---
ChangeLog | 6 ++++++
src/include/stringclass.h | 12 ++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fdcec18fd..9ffd69877 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-04-23 G. Branden Robinson <[email protected]>
+
+ * src/include/stringclass.h (operator[], string::empty)
+ (operator+, string::substring): Fix code style nit: parenthesize
+ formally complex expressions.
+
2025-04-22 G. Branden Robinson <[email protected]>
* src/include/stringclass.h (operator+): Dump workaround for
diff --git a/src/include/stringclass.h b/src/include/stringclass.h
index 13e7514c8..35c0a46af 100644
--- a/src/include/stringclass.h
+++ b/src/include/stringclass.h
@@ -101,13 +101,13 @@ private:
inline char &string::operator[](int i)
{
- assert(i >= 0 && i < len);
+ assert((i >= 0) && (i < len));
return ptr[i];
}
inline char string::operator[](int i) const
{
- assert(i >= 0 && i < len);
+ assert((i >= 0) && (i < len));
return ptr[i];
}
@@ -118,7 +118,7 @@ inline int string::length() const
inline int string::empty() const
{
- return len == 0;
+ return (len == 0);
}
inline int string::operator*() const
@@ -138,12 +138,12 @@ inline string operator+(const string &s1, const string
&s2)
inline string operator+(const string &s1, const char *s2)
{
- return s2 == 0 ? s1 : string(s1.ptr, s1.len, s2, strlen(s2));
+ return (s2 == 0) ? s1 : string(s1.ptr, s1.len, s2, strlen(s2));
}
inline string operator+(const char *s1, const string &s2)
{
- return s1 == 0 ? s2 : string(s1, strlen(s1), s2.ptr, s2.len);
+ return (s1 == 0) ? s2 : string(s1, strlen(s1), s2.ptr, s2.len);
}
inline string operator+(const string &s, char c)
@@ -170,7 +170,7 @@ inline int operator!=(const string &s1, const string &s2)
inline string string::substring(int i, int n) const
{
- assert(i >= 0 && i + n <= len);
+ assert((i >= 0) && ((i + n) <= len));
return string(ptr + i, n);
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit