diff --git a/CHANGELOG.md b/CHANGELOG.md index 22bef911..597a4451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Change C api's `janet_formatb` -> `janet_formatbv`. +- Add C `janet_formatb` to C api. - Add `edefer` macro to core. - A struct/table literal/constructor with duplicate keys will use the last value given. Previously, this was inconsistent between tables and structs, literals and constructor functions. diff --git a/src/core/capi.c b/src/core/capi.c index 28c59ea7..ce7ef70b 100644 --- a/src/core/capi.c +++ b/src/core/capi.c @@ -54,7 +54,7 @@ void janet_panicf(const char *format, ...) { while (format[len]) len++; janet_buffer_init(&buffer, len); va_start(args, format); - janet_formatb(&buffer, format, args); + janet_formatbv(&buffer, format, args); va_end(args); ret = janet_string(buffer.data, buffer.count); janet_buffer_deinit(&buffer); diff --git a/src/core/io.c b/src/core/io.c index fe6c2625..7312c266 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -502,7 +502,7 @@ void janet_dynprintf(const char *name, FILE *dflt_file, const char *format, ...) int32_t len = 0; while (format[len]) len++; janet_buffer_init(&buffer, len); - janet_formatb(&buffer, format, args); + janet_formatbv(&buffer, format, args); if (xtype == JANET_ABSTRACT) { void *abstract = janet_unwrap_abstract(x); if (janet_abstract_type(abstract) != &janet_file_type) @@ -515,7 +515,7 @@ void janet_dynprintf(const char *name, FILE *dflt_file, const char *format, ...) break; } case JANET_BUFFER: - janet_formatb(janet_unwrap_buffer(x), format, args); + janet_formatbv(janet_unwrap_buffer(x), format, args); break; } va_end(args); diff --git a/src/core/parse.c b/src/core/parse.c index 4e8bba04..4feaebe4 100644 --- a/src/core/parse.c +++ b/src/core/parse.c @@ -642,7 +642,7 @@ void janet_parser_eof(JanetParser *parser) { if (parser->statecount > 1) { JanetParseState *s = parser->states + (parser->statecount - 1); JanetBuffer *buffer = janet_buffer(40); - janet_buffer_push_cstring(buffer, "unexpected end of source: "); + janet_buffer_push_cstring(buffer, "unexpected end of source, "); if (s->flags & PFLAG_PARENS) { janet_buffer_push_u8(buffer, '('); } else if (s->flags & PFLAG_SQRBRACKETS) { @@ -657,7 +657,7 @@ void janet_parser_eof(JanetParser *parser) { janet_buffer_push_u8(buffer, '`'); } } - janet_formatbb(buffer, " opened at line %d, column %d", s->line, s->column); + janet_formatb(buffer, " opened at line %d, column %d", s->line, s->column); parser->error = (const char *) janet_string(buffer->data, buffer->count); parser->flag |= JANET_PARSER_GENERATED_ERROR; } diff --git a/src/core/pp.c b/src/core/pp.c index 828e4c11..95fca574 100644 --- a/src/core/pp.c +++ b/src/core/pp.c @@ -728,7 +728,7 @@ static const char *scanformat( return p; } -void janet_formatb(JanetBuffer *b, const char *format, va_list args) { +void janet_formatbv(JanetBuffer *b, const char *format, va_list args) { const char *format_end = format + strlen(format); const char *c = format; int32_t startlen = b->count; @@ -853,7 +853,7 @@ const uint8_t *janet_formatc(const char *format, ...) { va_start(args, format); /* Run format */ - janet_formatb(&buffer, format, args); + janet_formatbv(&buffer, format, args); /* Iterate length */ va_end(args); @@ -863,10 +863,10 @@ const uint8_t *janet_formatc(const char *format, ...) { return ret; } -JanetBuffer *janet_formatbb(JanetBuffer *buffer, const char *format, ...) { +JanetBuffer *janet_formatb(JanetBuffer *buffer, const char *format, ...) { va_list args; va_start(args, format); - janet_formatb(buffer, format, args); + janet_formatbv(buffer, format, args); va_end(args); return buffer; } diff --git a/src/include/janet.h b/src/include/janet.h index 66cd1813..848fe7b9 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -1238,8 +1238,8 @@ JANET_API void janet_description_b(JanetBuffer *buffer, Janet x); #define janet_cstringv(cstr) janet_wrap_string(janet_cstring(cstr)) #define janet_stringv(str, len) janet_wrap_string(janet_string((str), (len))) JANET_API JanetString janet_formatc(const char *format, ...); -JANET_API void janet_formatb(JanetBuffer *bufp, const char *format, va_list args); -JANET_API JanetBuffer *janet_formatbb(JanetBuffer *bufp, const char *format, ...); +JANET_API JanetBuffer *janet_formatb(JanetBuffer *bufp, const char *format, ...); +JANET_API void janet_formatbv(JanetBuffer *bufp, const char *format, va_list args); /* Symbol functions */ JANET_API JanetSymbol janet_symbol(const uint8_t *str, int32_t len);