Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
e66fd568
Commit
e66fd568
authored
7 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/repl: Change mp_uint_t to size_t in repl helpers.
parent
7bd10c1f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/mp-readline/readline.c
+3
-3
3 additions, 3 deletions
lib/mp-readline/readline.c
py/repl.c
+9
-9
9 additions, 9 deletions
py/repl.c
py/repl.h
+1
-1
1 addition, 1 deletion
py/repl.h
unix/coverage.c
+1
-1
1 addition, 1 deletion
unix/coverage.c
with
14 additions
and
14 deletions
lib/mp-readline/readline.c
+
3
−
3
View file @
e66fd568
...
...
@@ -188,17 +188,17 @@ int readline_process_char(int c) {
}
else
if
(
c
==
9
)
{
// tab magic
const
char
*
compl_str
;
mp_uint
_t
compl_len
=
mp_repl_autocomplete
(
rl
.
line
->
buf
+
rl
.
orig_line_len
,
rl
.
cursor_pos
-
rl
.
orig_line_len
,
&
mp_plat_print
,
&
compl_str
);
size
_t
compl_len
=
mp_repl_autocomplete
(
rl
.
line
->
buf
+
rl
.
orig_line_len
,
rl
.
cursor_pos
-
rl
.
orig_line_len
,
&
mp_plat_print
,
&
compl_str
);
if
(
compl_len
==
0
)
{
// no match
}
else
if
(
compl_len
==
(
mp_uint
_t
)(
-
1
))
{
}
else
if
(
compl_len
==
(
size
_t
)(
-
1
))
{
// many matches
mp_hal_stdout_tx_str
(
rl
.
prompt
);
mp_hal_stdout_tx_strn
(
rl
.
line
->
buf
+
rl
.
orig_line_len
,
rl
.
cursor_pos
-
rl
.
orig_line_len
);
redraw_from_cursor
=
true
;
}
else
{
// one match
for
(
mp_uint
_t
i
=
0
;
i
<
compl_len
;
++
i
)
{
for
(
size
_t
i
=
0
;
i
<
compl_len
;
++
i
)
{
vstr_ins_byte
(
rl
.
line
,
rl
.
cursor_pos
+
i
,
*
compl_str
++
);
}
// set redraw parameters
...
...
This diff is collapsed.
Click to expand it.
py/repl.c
+
9
−
9
View file @
e66fd568
...
...
@@ -32,7 +32,7 @@
#if MICROPY_HELPER_REPL
STATIC
bool
str_startswith_word
(
const
char
*
str
,
const
char
*
head
)
{
mp_uint
_t
i
;
size
_t
i
;
for
(
i
=
0
;
str
[
i
]
&&
head
[
i
];
i
++
)
{
if
(
str
[
i
]
!=
head
[
i
])
{
return
false
;
...
...
@@ -124,7 +124,7 @@ bool mp_repl_continue_with_input(const char *input) {
return
false
;
}
mp_uint
_t
mp_repl_autocomplete
(
const
char
*
str
,
mp_uint
_t
len
,
const
mp_print_t
*
print
,
const
char
**
compl_str
)
{
size
_t
mp_repl_autocomplete
(
const
char
*
str
,
size
_t
len
,
const
mp_print_t
*
print
,
const
char
**
compl_str
)
{
// scan backwards to find start of "a.b.c" chain
const
char
*
org_str
=
str
;
const
char
*
top
=
str
+
len
;
...
...
@@ -145,13 +145,13 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
while
(
str
<
top
&&
*
str
!=
'.'
)
{
++
str
;
}
mp_uint
_t
s_len
=
str
-
s_start
;
size
_t
s_len
=
str
-
s_start
;
if
(
str
<
top
)
{
// a complete word, lookup in current dict
mp_obj_t
obj
=
MP_OBJ_NULL
;
for
(
mp_uint
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
&
dict
->
map
,
i
))
{
size_t
d_len
;
const
char
*
d_str
=
mp_obj_str_get_data
(
dict
->
map
.
table
[
i
].
key
,
&
d_len
);
...
...
@@ -194,8 +194,8 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
// look for matches
int
n_found
=
0
;
const
char
*
match_str
=
NULL
;
mp_uint
_t
match_len
=
0
;
for
(
mp_uint
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
size
_t
match_len
=
0
;
for
(
size
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
&
dict
->
map
,
i
))
{
size_t
d_len
;
const
char
*
d_str
=
mp_obj_str_get_data
(
dict
->
map
.
table
[
i
].
key
,
&
d_len
);
...
...
@@ -206,7 +206,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
}
else
{
// search for longest common prefix of match_str and d_str
// (assumes these strings are null-terminated)
for
(
mp_uint
_t
j
=
s_len
;
j
<=
match_len
&&
j
<=
d_len
;
++
j
)
{
for
(
size
_t
j
=
s_len
;
j
<=
match_len
&&
j
<=
d_len
;
++
j
)
{
if
(
match_str
[
j
]
!=
d_str
[
j
])
{
match_len
=
j
;
break
;
...
...
@@ -245,7 +245,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
#define MAX_LINE_LEN (4 * WORD_SLOT_LEN)
int
line_len
=
MAX_LINE_LEN
;
// force a newline for first word
for
(
mp_uint
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
dict
->
map
.
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
&
dict
->
map
,
i
))
{
size_t
d_len
;
const
char
*
d_str
=
mp_obj_str_get_data
(
dict
->
map
.
table
[
i
].
key
,
&
d_len
);
...
...
@@ -270,7 +270,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
}
mp_print_str
(
print
,
"
\n
"
);
return
(
mp_uint
_t
)(
-
1
);
// indicate many matches
return
(
size
_t
)(
-
1
);
// indicate many matches
}
}
}
...
...
This diff is collapsed.
Click to expand it.
py/repl.h
+
1
−
1
View file @
e66fd568
...
...
@@ -32,7 +32,7 @@
#if MICROPY_HELPER_REPL
bool
mp_repl_continue_with_input
(
const
char
*
input
);
mp_uint
_t
mp_repl_autocomplete
(
const
char
*
str
,
mp_uint
_t
len
,
const
mp_print_t
*
print
,
const
char
**
compl_str
);
size
_t
mp_repl_autocomplete
(
const
char
*
str
,
size
_t
len
,
const
mp_print_t
*
print
,
const
char
**
compl_str
);
#endif
#endif // __MICROPY_INCLUDED_PY_REPL_H__
This diff is collapsed.
Click to expand it.
unix/coverage.c
+
1
−
1
View file @
e66fd568
...
...
@@ -190,7 +190,7 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf
(
&
mp_plat_print
,
"# repl
\n
"
);
const
char
*
str
;
mp_uint
_t
len
=
mp_repl_autocomplete
(
"__n"
,
3
,
&
mp_plat_print
,
&
str
);
size
_t
len
=
mp_repl_autocomplete
(
"__n"
,
3
,
&
mp_plat_print
,
&
str
);
mp_printf
(
&
mp_plat_print
,
"%.*s
\n
"
,
(
int
)
len
,
str
);
mp_store_global
(
MP_QSTR_sys
,
mp_import_name
(
MP_QSTR_sys
,
mp_const_none
,
MP_OBJ_NEW_SMALL_INT
(
0
)));
...
...
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