summaryrefslogtreecommitdiffstats
path: root/src/core/wchar.c
diff options
context:
space:
mode:
authorSimon Rettberg2026-01-28 12:53:53 +0100
committerSimon Rettberg2026-01-28 12:53:53 +0100
commit8e82785c584dc13e20f9229decb95bd17bbe9cd1 (patch)
treea8b359e59196be5b2e3862bed189107f4bc9975f /src/core/wchar.c
parentMerge branch 'master' into openslx (diff)
parent[prefix] Make unlzma.S compatible with 386 class CPUs (diff)
downloadipxe-openslx.tar.gz
ipxe-openslx.tar.xz
ipxe-openslx.zip
Merge branch 'master' into openslxopenslx
Diffstat (limited to 'src/core/wchar.c')
-rw-r--r--src/core/wchar.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/wchar.c b/src/core/wchar.c
index 860322820..27a608bf4 100644
--- a/src/core/wchar.c
+++ b/src/core/wchar.c
@@ -22,6 +22,7 @@
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+FILE_SECBOOT ( PERMITTED );
/**
* @file
@@ -36,12 +37,25 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* Calculate length of wide-character string
*
* @v string String
- * @ret len Length (excluding terminating NUL)
+ * @v max Maximum length (in wide characters)
+ * @ret len Length (in wide characters, excluding terminating NUL)
*/
-size_t wcslen ( const wchar_t *string ) {
+size_t wcsnlen ( const wchar_t *string, size_t max ) {
size_t len = 0;
- while ( *(string++) )
+ while ( max-- && *(string++) )
len++;
return len;
}
+
+/**
+ * Calculate length of wide-character string
+ *
+ * @v string String
+ * @ret len Length (in wide characters, excluding terminating NUL)
+ */
+size_t wcslen ( const wchar_t *string ) {
+
+ return wcsnlen ( string, ( ( ~( ( size_t ) 0 ) ) /
+ sizeof ( string[0] ) ) );
+}