diff --git a/sexp-format.c b/sexp-format.c index 1db2563aac3608178faa6a38c0716cf3e51e5cb1..134a081d5eb6f43fb053d577b8ba5d4181a25ca7 100644 --- a/sexp-format.c +++ b/sexp-format.c @@ -146,6 +146,14 @@ sexp_vformat(struct nettle_buffer *buffer, const char *format, va_list args) default: abort(); + case '(': + case ')': + /* Allow unbalanced parenthesis */ + if (buffer && !NETTLE_BUFFER_PUTC(buffer, format[-1])) + return 0; + done++; + break; + case 's': { const char *s; diff --git a/sexp.h b/sexp.h index 212527961686808063c41db87cf6bfcfaa9826b8..2b72a2be8129b8cc0999af714fe9b4a9af2497fa 100644 --- a/sexp.h +++ b/sexp.h @@ -153,14 +153,15 @@ struct nettle_buffer; * subexpression. Represented as unsigned length, const uint8_t * *data. * + * %(, %) Allows insertion of unbalanced parenthesis. + * * Modifiers: * * %0 For %s, %t and %l, says that there's no length argument, * instead the string is NUL-terminated, and there's only one * const uint8_t * argument. - * - * FIXME: Allow "%(" for unbalanced parenthesis. */ - + */ + unsigned sexp_format(struct nettle_buffer *buffer, const char *format, ...);