rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString
@ 2024-01-22 18:45 Danilo Krummrich
  2024-01-22 18:57 ` Alice Ryhl
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Danilo Krummrich @ 2024-01-22 18:45 UTC (permalink / raw)
  To: ojeda, alex.gaynor, wedsonaf, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl
  Cc: rust-for-linux, linux-kernel, Danilo Krummrich

Add functions to convert a CString to upper- / lowercase assuming all
characters are ASCII encoded.

Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
 rust/kernel/str.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index 7d848b83add4..d21151d89861 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -581,6 +581,16 @@ pub fn try_from_fmt(args: fmt::Arguments<'_>) -> Result<Self, Error> {
         // exist in the buffer.
         Ok(Self { buf })
     }
+
+    /// Converts the whole CString to lowercase.
+    pub fn to_ascii_lowercase(&mut self) {
+        self.buf.make_ascii_lowercase();
+    }
+
+    /// Converts the whole CString to uppercase.
+    pub fn to_ascii_uppercase(&mut self) {
+        self.buf.make_ascii_uppercase();
+    }
 }
 
 impl Deref for CString {

base-commit: 610347effc2ecb5ededf5037e82240b151f883ab
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-01-25  9:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 18:45 [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString Danilo Krummrich
2024-01-22 18:57 ` Alice Ryhl
2024-01-22 19:35 ` Greg KH
2024-01-22 22:38   ` Danilo Krummrich
2024-01-22 23:12     ` Greg KH
2024-01-23 17:24       ` Danilo Krummrich
2024-01-23 18:18         ` Miguel Ojeda
2024-01-22 19:38 ` Miguel Ojeda
2024-01-22 22:16   ` Danilo Krummrich
2024-01-23 17:35     ` Miguel Ojeda
2024-01-25  9:08 ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).