summaryrefslogtreecommitdiffstatshomepage
path: root/py/vstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-03 14:03:48 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-03 14:03:48 +0000
commit66028ab6dcd1b2ec9504c3473d817649935a4a1e (patch)
treec441ee4d665b3218e235dec24dd5a66a6fe050ef /py/vstr.c
parentaae7847508e2a9555ad3276c5cd4f42b2e66686c (diff)
downloadmicropython-66028ab6dcd1b2ec9504c3473d817649935a4a1e.tar.gz
micropython-66028ab6dcd1b2ec9504c3473d817649935a4a1e.zip
Basic implementation of import.
import works for simple cases. Still work to do on finding the right script, and setting globals/locals correctly when running an imported function.
Diffstat (limited to 'py/vstr.c')
-rw-r--r--py/vstr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/py/vstr.c b/py/vstr.c
index 98cf027250..80841b24ca 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -167,8 +167,12 @@ void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap) {
while (1) {
// try to print in the allocated space
+ // need to make a copy of the va_list because we may call vsnprintf multiple times
int size = vstr->alloc - vstr->len;
- int n = vsnprintf(vstr->buf + vstr->len, size, fmt, ap);
+ va_list ap2;
+ va_copy(ap2, ap);
+ int n = vsnprintf(vstr->buf + vstr->len, size, fmt, ap2);
+ va_end(ap2);
// if that worked, return
if (n > -1 && n < size) {