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
e8e8f212
Commit
e8e8f212
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Plain Diff
Merge pull request #412 from dhylands/pfenv-strn-stack
Pfenv strn stack
parents
ef13e203
1c6b4b2e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/pfenv.c
+13
-10
13 additions, 10 deletions
py/pfenv.c
with
13 additions
and
10 deletions
py/pfenv.c
+
13
−
10
View file @
e8e8f212
...
...
@@ -16,9 +16,8 @@
#include
"formatfloat.h"
#endif
#define PF_PAD_SIZE 16
static
const
char
*
pad_spaces
=
" "
;
static
const
char
*
pad_zeroes
=
"0000000000000000"
;
static
const
char
pad_spaces
[]
=
" "
;
static
const
char
pad_zeroes
[]
=
"0000000000000000"
;
void
pfenv_vstr_add_strn
(
void
*
data
,
const
char
*
str
,
unsigned
int
len
){
vstr_add_strn
(
data
,
str
,
len
);
...
...
@@ -28,16 +27,20 @@ int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, in
int
left_pad
=
0
;
int
right_pad
=
0
;
int
pad
=
width
-
len
;
char
pad_
fill
[
PF_PAD_SIZE
]
;
int
pad_
size
;
const
char
*
pad_chars
;
if
(
!
fill
||
fill
==
' '
)
{
pad_chars
=
pad_spaces
;
pad_size
=
sizeof
(
pad_spaces
)
-
1
;
}
else
if
(
fill
==
'0'
)
{
pad_chars
=
pad_zeroes
;
pad_size
=
sizeof
(
pad_zeroes
)
-
1
;
}
else
{
memset
(
pad_fill
,
fill
,
PF_PAD_SIZE
);
pad_chars
=
pad_fill
;
// Other pad characters are fairly unusual, so we'll take the hit
// and output them 1 at a time.
pad_chars
=
&
fill
;
pad_size
=
1
;
}
if
(
flags
&
PF_FLAG_CENTER_ADJUST
)
{
...
...
@@ -52,8 +55,8 @@ int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, in
if
(
left_pad
)
{
while
(
left_pad
>
0
)
{
int
p
=
left_pad
;
if
(
p
>
PF_PAD_SIZE
)
p
=
PF_PAD_SIZE
;
if
(
p
>
pad_size
)
p
=
pad_size
;
pfenv
->
print_strn
(
pfenv
->
data
,
pad_chars
,
p
);
left_pad
-=
p
;
}
...
...
@@ -62,8 +65,8 @@ int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, in
if
(
right_pad
)
{
while
(
right_pad
>
0
)
{
int
p
=
right_pad
;
if
(
p
>
PF_PAD_SIZE
)
p
=
PF_PAD_SIZE
;
if
(
p
>
pad_size
)
p
=
pad_size
;
pfenv
->
print_strn
(
pfenv
->
data
,
pad_chars
,
p
);
right_pad
-=
p
;
}
...
...
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