Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Willers
KWSys
Commits
4d2b5818
Commit
4d2b5818
authored
19 years ago
by
Sebastien Barre
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add method to escape some chars in a string
parent
895f7c11
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SystemTools.cxx
+35
-0
35 additions, 0 deletions
SystemTools.cxx
SystemTools.hxx.in
+6
-0
6 additions, 0 deletions
SystemTools.hxx.in
with
41 additions
and
0 deletions
SystemTools.cxx
+
35
−
0
View file @
4d2b5818
...
...
@@ -1205,6 +1205,41 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap)
return
length
;
}
kwsys_stl
::
string
SystemTools
::
EscapeChars
(
const
char
*
str
,
const
char
*
chars_to_escape
,
char
escape_char
)
{
kwsys_stl
::
string
n
;
if
(
str
)
{
if
(
!
chars_to_escape
|
!*
chars_to_escape
)
{
n
.
append
(
str
);
}
else
{
n
.
reserve
(
strlen
(
str
));
while
(
*
str
)
{
const
char
*
ptr
=
chars_to_escape
;
while
(
*
ptr
)
{
if
(
*
str
==
*
ptr
)
{
n
+=
escape_char
;
break
;
}
++
ptr
;
}
n
+=
*
str
;
++
str
;
}
}
}
return
n
;
}
// convert windows slashes to unix slashes
void
SystemTools
::
ConvertToUnixSlashes
(
kwsys_stl
::
string
&
path
)
{
...
...
This diff is collapsed.
Click to expand it.
SystemTools.hxx.in
+
6
−
0
View file @
4d2b5818
...
...
@@ -220,6 +220,12 @@ public:
*/
static int EstimateFormatLength(const char *format, va_list ap);
/**
* Escape specific characters in 'str'.
*/
static kwsys_stl::string EscapeChars(
const char *str, const char *chars_to_escape, char escape_char = '\\');
/** -----------------------------------------------------------------
* Filename Manipulation Routines
* -----------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment