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
3a6b3d23
Commit
3a6b3d23
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
main.c: Switch stderr printing from ANSI C to native POSIX.
parent
94f9330d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/main.c
+6
-4
6 additions, 4 deletions
unix/main.c
with
6 additions
and
4 deletions
unix/main.c
+
6
−
4
View file @
3a6b3d23
...
...
@@ -61,7 +61,8 @@ long heap_size = 1024*1024 * (sizeof(mp_uint_t) / 4);
STATIC
void
stderr_print_strn
(
void
*
env
,
const
char
*
str
,
mp_uint_t
len
)
{
(
void
)
env
;
fwrite
(
str
,
len
,
1
,
stderr
);
ssize_t
dummy
=
write
(
STDERR_FILENO
,
str
,
len
);
(
void
)
dummy
;
}
const
mp_print_t
mp_stderr_print
=
{
NULL
,
stderr_print_strn
};
...
...
@@ -84,6 +85,7 @@ STATIC int handle_uncaught_exception(mp_obj_t exc) {
// Report all other exceptions
mp_obj_print_exception
(
&
mp_stderr_print
,
exc
);
mp_printf
(
&
mp_stderr_print
,
exc
);
return
1
;
}
...
...
@@ -492,7 +494,7 @@ int main(int argc, char **argv) {
if
(
mp_obj_is_package
(
mod
))
{
// TODO
f
printf
(
stderr
,
"%s: -m for packages not yet implemented
\n
"
,
argv
[
0
]);
mp_
printf
(
&
mp_
stderr
_print
,
"%s: -m for packages not yet implemented
\n
"
,
argv
[
0
]);
exit
(
1
);
}
ret
=
0
;
...
...
@@ -515,7 +517,7 @@ int main(int argc, char **argv) {
char
*
pathbuf
=
malloc
(
PATH_MAX
);
char
*
basedir
=
realpath
(
argv
[
a
],
pathbuf
);
if
(
basedir
==
NULL
)
{
f
printf
(
stderr
,
"%s: can't open file '%s': [Errno %d] "
,
argv
[
0
],
argv
[
a
],
errno
);
mp_
printf
(
&
mp_
stderr
_print
,
"%s: can't open file '%s': [Errno %d] "
,
argv
[
0
],
argv
[
a
],
errno
);
perror
(
""
);
// CPython exits with 2 in such case
ret
=
2
;
...
...
@@ -577,7 +579,7 @@ uint mp_import_stat(const char *path) {
int
DEBUG_printf
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
int
ret
=
v
f
printf
(
stderr
,
fmt
,
ap
);
int
ret
=
mp_
vprintf
(
&
mp_
stderr
_print
,
fmt
,
ap
);
va_end
(
ap
);
return
ret
;
}
...
...
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