Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
Base
Commits
a7db159d
Commit
a7db159d
authored
Mar 19, 2020
by
Martin Marinov
Browse files
Stop replacing digits after dots in set_filename_extension()
parent
06f91cdd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Utils/FileOutput.cc
View file @
a7db159d
...
...
@@ -7,6 +7,7 @@
#include <iomanip>
#include <fstream>
#include <limits>
#include <cctype>
namespace
Base
{
...
...
@@ -29,11 +30,17 @@ std::string make_filename(
std
::
string
set_filename_extension
(
const
char
*
_flnm
,
const
char
*
_ext
)
{
std
::
string
flnm
(
_flnm
);
const
size_t
dot_pos
=
flnm
.
find_last_of
(
'.'
);
if
(
dot_pos
!=
std
::
string
::
npos
)
flnm
.
replace
(
flnm
.
begin
()
+
dot_pos
+
1
,
flnm
.
end
(),
_ext
);
const
auto
dot_pos
=
flnm
.
find_last_of
(
'.'
);
if
(
dot_pos
==
std
::
string
::
npos
)
flnm
+=
std
::
string
(
"."
)
+
_ext
;
// no dot, add the dot and the extension
else
if
(
dot_pos
+
1
==
flnm
.
size
())
flnm
+=
_ext
;
// last char is dot, add the extension
else
if
(
isdigit
(
flnm
[
dot_pos
+
1
]))
// char after dot is a digit?
flnm
+=
std
::
string
(
"."
)
+
_ext
;
// add the dot and the extension
else
flnm
+=
std
::
string
(
"."
)
+
_ext
;
flnm
.
replace
(
flnm
.
begin
()
+
dot_pos
+
1
,
flnm
.
end
(),
_ext
);
return
flnm
;
}
...
...
Write
Preview
Supports
Markdown
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