mirror of
https://github.com/jart/cosmopolitan.git
synced 2024-05-17 02:52:40 +00:00
36f52ea687
_PFLINK is supposed to automatically pull in required functions for specific conversion specifiers. However, it fails to do so for the F, G and E conversion specifiers. This means that, for example, the following program: #include <stdio.h> int main() { printf("%F %G %E\n", .0, .0, .0); } fails to run correctly, printing "? ? ?" instead of "0.000000 0 0.000000E+00". This patch fixes this.
42 lines
2.5 KiB
C
42 lines
2.5 KiB
C
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
│ Copyright 2023 Gabriel Ravier │
|
|
│ │
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
|
│ │
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
|
|
#include "libc/fmt/fmt.h"
|
|
#include "libc/intrin/kprintf.h"
|
|
#include "libc/runtime/runtime.h"
|
|
#include "libc/str/str.h"
|
|
|
|
// We specifically avoid the test framework because otherwise __fmt_dtoa is
|
|
// always automatically pulled in from code in there - and this is what we're
|
|
// testing for here
|
|
int main() {
|
|
char buffer[30];
|
|
|
|
int snprintf_result = snprintf(buffer, sizeof(buffer), "%F", .0);
|
|
if (strcmp(buffer, "0.000000")) {
|
|
kprintf("error: snprintf gave us '%s' instead of the expected '0.000000'\n",
|
|
buffer);
|
|
abort();
|
|
}
|
|
if (snprintf_result != 8) {
|
|
kprintf("error: snprintf returned %d instead of 8\n", snprintf_result);
|
|
abort();
|
|
}
|
|
}
|