Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
a307da34
Commit
a307da34
authored
3 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
aql: more code to cpp
parent
79493399
No related branches found
Branches containing commit
No related tags found
1 merge request
!203
Adress some more clang-tidy issues
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aql2/src/prompt/ReadlinePromptHistory.cpp
+13
-9
13 additions, 9 deletions
aql2/src/prompt/ReadlinePromptHistory.cpp
aql2/src/prompt/ReadlinePromptHistory.h
+0
-4
0 additions, 4 deletions
aql2/src/prompt/ReadlinePromptHistory.h
with
13 additions
and
13 deletions
aql2/src/prompt/ReadlinePromptHistory.cpp
+
13
−
9
View file @
a307da34
...
@@ -3,25 +3,27 @@
...
@@ -3,25 +3,27 @@
#include
<readline/history.h>
#include
<readline/history.h>
#include
<cstring>
#include
<cstring>
#include
<array>
char
ReadlinePromptHistory
::
esc_char
[]
=
{
'\a'
,
'\b'
,
'\f'
,
'\n'
,
'\r'
,
'\t'
,
'\v'
,
'\\'
};
static
constexpr
std
::
array
<
std
::
pair
<
char
,
char
>
,
8
>
esc_char_list
=
{
{
{
'\a'
,
'a'
},
{
'\b'
,
'b'
},
{
'\f'
,
'f'
},
{
'\n'
,
'n'
},
{
'\r'
,
'r'
},
{
'\t'
,
't'
},
{
'\v'
,
'v'
},
{
'\\'
,
'\\'
}
}
};
char
ReadlinePromptHistory
::
essc_str
[]
=
{
'a'
,
'b'
,
'f'
,
'n'
,
'r'
,
't'
,
'v'
,
'\\'
};
size_t
ReadlinePromptHistory
::
esc_char_size
=
sizeof
(
ReadlinePromptHistory
::
esc_char
);
char
*
ReadlinePromptHistory
::
descape
(
const
char
*
buffer
)
{
char
*
ReadlinePromptHistory
::
descape
(
const
char
*
buffer
)
{
size_t
l
=
strlen
(
buffer
);
size_t
l
=
strlen
(
buffer
);
char
*
dest
=
static_cast
<
char
*
>
(
malloc
(
(
l
+
1
)
*
sizeof
(
char
)
)
);
char
*
dest
=
static_cast
<
char
*
>
(
malloc
(
(
l
+
1
)
*
sizeof
(
char
)
)
);
char
*
ptr
=
dest
;
char
*
ptr
=
dest
;
for
(
size_t
i
=
0
;
i
<
l
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
l
;
++
i
)
{
if
(
buffer
[
i
]
==
'\\'
)
{
if
(
buffer
[
i
]
==
'\\'
)
{
++
i
;
++
i
;
size_t
j
=
std
::
find
(
essc_str
,
essc_str
+
esc_char_size
,
buffer
[
i
]
)
-
essc_str
;
auto
find_by_escaped
=
[
&
]
(
const
std
::
pair
<
char
,
char
>
&
esc_pair
)
{
return
esc_pair
.
second
==
buffer
[
i
];
};
if
(
j
==
esc_char_size
)
{
std
::
array
<
std
::
pair
<
char
,
char
>
,
8
>::
const_iterator
iter
=
std
::
find_if
(
esc_char_list
.
begin
(
),
esc_char_list
.
end
(
),
find_by_escaped
);
if
(
iter
==
esc_char_list
.
end
(
)
)
{
free
(
dest
);
free
(
dest
);
return
strdup
(
buffer
);
return
strdup
(
buffer
);
}
else
{
*
ptr
++
=
iter
->
first
;
}
}
*
ptr
++
=
esc_char
[
j
];
}
else
{
}
else
{
*
ptr
++
=
buffer
[
i
];
*
ptr
++
=
buffer
[
i
];
}
}
...
@@ -36,13 +38,15 @@ char * ReadlinePromptHistory::escape ( const char * buffer){
...
@@ -36,13 +38,15 @@ char * ReadlinePromptHistory::escape ( const char * buffer){
char
*
dest
=
static_cast
<
char
*
>
(
malloc
(
(
l
*
2
+
1
)
*
sizeof
(
char
)
)
);
char
*
dest
=
static_cast
<
char
*
>
(
malloc
(
(
l
*
2
+
1
)
*
sizeof
(
char
)
)
);
char
*
ptr
=
dest
;
char
*
ptr
=
dest
;
for
(
size_t
i
=
0
;
i
<
l
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
l
;
++
i
)
{
size_t
j
=
std
::
find
(
esc_char
,
esc_char
+
esc_char_size
,
buffer
[
i
]
)
-
esc_char
;
auto
find_by_actual
=
[
&
]
(
const
std
::
pair
<
char
,
char
>
&
esc_pair
)
{
return
esc_pair
.
first
==
buffer
[
i
];
};
if
(
j
==
esc_char_size
)
{
std
::
array
<
std
::
pair
<
char
,
char
>
,
8
>::
const_iterator
iter
=
std
::
find_if
(
esc_char_list
.
begin
(
),
esc_char_list
.
end
(
),
find_by_actual
);
if
(
iter
==
esc_char_list
.
end
(
)
)
{
*
ptr
++
=
buffer
[
i
];
*
ptr
++
=
buffer
[
i
];
}
else
{
}
else
{
*
ptr
++
=
'\\'
;
*
ptr
++
=
'\\'
;
*
ptr
++
=
essc_str
[
j
]
;
*
ptr
++
=
iter
->
second
;
}
}
}
}
*
ptr
=
'\0'
;
*
ptr
=
'\0'
;
...
...
This diff is collapsed.
Click to expand it.
aql2/src/prompt/ReadlinePromptHistory.h
+
0
−
4
View file @
a307da34
...
@@ -3,10 +3,6 @@
...
@@ -3,10 +3,6 @@
#include <string>
#include <string>
class ReadlinePromptHistory {
class ReadlinePromptHistory {
static char esc_char [];
static char essc_str [];
static size_t esc_char_size;
static char * descape ( const char * buffer );
static char * descape ( const char * buffer );
static char * escape ( const char * buffer);
static char * escape ( const char * buffer);
...
...
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