Skip to content

Commit

Permalink
Update mongoose for mos
Browse files Browse the repository at this point in the history
PUBLISHED_FROM=78800c0b735132f48270ed63de5767851501b617
  • Loading branch information
rojer authored and cesantabot committed Oct 26, 2020
1 parent 6582e43 commit 365a7dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
25 changes: 3 additions & 22 deletions frozen.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,35 +627,16 @@ int json_vprintf(struct json_out *out, const char *fmt, va_list xap) {
len += json_escape(out, p, l);
len += out->printer(out, quote, 1);
}
} else if (fmt[1] == 's' ||
(fmt[1] == '.' && fmt[2] == '*' && fmt[3] == 's')) {
size_t l = 0;
const char *p;

if (fmt[1] == '.') {
l = (size_t) va_arg(ap, int);
skip += 2;
}
p = va_arg(ap, char *);

if (p == NULL) {
len += out->printer(out, null, 4);
} else {
if (fmt[1] == 's') {
l = strlen(p);
}
len += out->printer(out, p, l);
}
} else {
/*
* we delegate printing to the system printf.
* The goal here is to delegate all modifiers parsing to the system
* printf, as you can see below we still have to parse the format
* types.
*
* format string / arguments combinations that result in outputs longer
* than 20 chars will require double-buffering (an auxiliary buffer will
* be allocated from heap).
* Currently, %s with strings longer than 20 chars will require
* double-buffering (an auxiliary buffer will be allocated from heap).
* TODO(dfrank): reimplement %s and %.*s in order to avoid that.
*/

const char *end_of_format_specifier = "sdfFeEgGlhuIcx.*-0123456789";
Expand Down
21 changes: 11 additions & 10 deletions unit_test.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/*
* Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
* Copyright (c) 2018-2020 Cesanta Software Limited
* Copyright (c) 2013 Cesanta Software Limited
* All rights reserved
*
* Licensed under the Apache License, Version 2.0 (the ""License"");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* This library is dual-licensed: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. For the terms of this
* license, see <http: *www.gnu.org/licenses/>.
*
* http://www.apache.org/licenses/LICENSE-2.0
* You are free to use this library under the terms of the GNU General
* Public License, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an ""AS IS"" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Alternatively, you can license this library under a commercial
* license, as set out in <http://cesanta.com/products.html>.
*/

/*
Expand Down

0 comments on commit 365a7dd

Please sign in to comment.