Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
08ab3530
Commit
08ab3530
authored
Aug 31, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified upper/lower case conversions
parent
1c80c602
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
29 deletions
+20
-29
src/lib/co/src/co_string.c
src/lib/co/src/co_string.c
+3
-21
src/lib/co/src/co_string.h
src/lib/co/src/co_string.h
+17
-8
No files found.
src/lib/co/src/co_string.c
View file @
08ab3530
...
@@ -41,15 +41,6 @@
...
@@ -41,15 +41,6 @@
char
*
str_ToLower
(
char
*
dst
,
const
char
*
src
)
char
*
str_ToLower
(
char
*
dst
,
const
char
*
src
)
{
{
char
*
rs
=
dst
;
char
*
rs
=
dst
;
static
const
char
cvttab
[]
=
"\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
!abcdefghijklmnopqrstuvwxyz!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
àáâãäåæçèéêëìíîï!ñòóôõö÷øùúûüý!!"
;
if
(
dst
==
NULL
)
if
(
dst
==
NULL
)
return
NULL
;
return
NULL
;
...
@@ -57,7 +48,7 @@ char* str_ToLower(char* dst, const char* src)
...
@@ -57,7 +48,7 @@ char* str_ToLower(char* dst, const char* src)
src
=
dst
;
src
=
dst
;
while
(
*
src
)
while
(
*
src
)
if
(
cvttab
[(
unsigned
char
)
*
src
]
==
'^'
)
if
(
(
*
src
>=
65
&&
*
src
<=
90
)
||
(((
unsigned
char
)
*
src
)
>=
192
&&
((
unsigned
char
)
*
src
)
<=
222
)
)
*
dst
++
=
(
*
src
++
)
+
32
;
*
dst
++
=
(
*
src
++
)
+
32
;
else
else
*
dst
++
=
*
src
++
;
*
dst
++
=
*
src
++
;
...
@@ -70,15 +61,6 @@ char* str_ToLower(char* dst, const char* src)
...
@@ -70,15 +61,6 @@ char* str_ToLower(char* dst, const char* src)
char
*
str_ToUpper
(
char
*
dst
,
const
char
*
src
)
char
*
str_ToUpper
(
char
*
dst
,
const
char
*
src
)
{
{
char
*
rs
=
dst
;
char
*
rs
=
dst
;
static
const
char
cvttab
[]
=
"\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!!\
!^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖ×ØÙÚÛÜÝ!!\
^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!"
;
if
(
dst
==
NULL
)
if
(
dst
==
NULL
)
return
NULL
;
return
NULL
;
...
@@ -86,7 +68,7 @@ char* str_ToUpper(char* dst, const char* src)
...
@@ -86,7 +68,7 @@ char* str_ToUpper(char* dst, const char* src)
src
=
dst
;
src
=
dst
;
while
(
*
src
)
while
(
*
src
)
if
(
cvttab
[(
unsigned
char
)
*
src
]
==
'^'
)
if
(
(
*
src
>=
97
&&
*
src
<=
122
)
||
(((
unsigned
char
)
*
src
)
>=
224
&&
((
unsigned
char
)
*
src
)
<=
254
)
)
*
dst
++
=
(
*
src
++
)
-
32
;
*
dst
++
=
(
*
src
++
)
-
32
;
else
else
*
dst
++
=
*
src
++
;
*
dst
++
=
*
src
++
;
...
...
src/lib/co/src/co_string.h
View file @
08ab3530
...
@@ -38,8 +38,15 @@
...
@@ -38,8 +38,15 @@
#include <string.h>
#include <string.h>
/*!
Checks if two strings a and b are equal
strcmp returns 0 (i.e. false) if the strings are equal, which is not that obvious
*/
#define streq(a,b) (strcmp((a),(b)) == 0)
#define streq(a,b) (strcmp((a),(b)) == 0)
/*!
Checks if the string 'str' starts with the substring 'prefix'
*/
#define str_StartsWith(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
#define str_StartsWith(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -48,21 +55,23 @@ extern "C" {
...
@@ -48,21 +55,23 @@ extern "C" {
//! Convert string to lower case.
//! Convert string to lower case.
/*!
/*!
If s is NULL, t is used also as input string.
Handles all ISO 8859-1 characters, not only ASCII.
If src is NULL, dst is used also as input string.
\param t Output string.
\param
ds
t Output string.
\param s Input string.
\param s
rc
Input string.
\return Returns t.
\return Returns
ds
t.
*/
*/
char
*
str_ToLower
(
char
*
dst
,
const
char
*
src
);
char
*
str_ToLower
(
char
*
dst
,
const
char
*
src
);
//! Convert string to upper case.
//! Convert string to upper case.
/*!
/*!
If s is NULL, t is used also as input string.
Handles all ISO 8859-1 characters, not only ASCII.
If src is NULL, dst is used also as input string.
\param t Output string.
\param
ds
t Output string.
\param s Input string.
\param s
rc
Input string.
\return Returns t.
\return Returns
ds
t.
*/
*/
char
*
str_ToUpper
(
char
*
dst
,
const
char
*
src
);
char
*
str_ToUpper
(
char
*
dst
,
const
char
*
src
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment