Skip to content

Commit 5902fec

Browse files
committed
Temp disable (v)fprintf for now, it causes linking issues in some cases.
Originally from 8cb0eb4
1 parent 3a684ba commit 5902fec

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

src/libc/nanoprintf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,11 @@ static void npf_putc_std(int c, void *ctx) {
641641
outchar(c);
642642
}
643643

644+
#if 0
644645
static void npf_fputc_std(int c, void *ctx) {
645646
fputc(c, (FILE*)ctx);
646647
}
648+
#endif
647649

648650
typedef struct npf_cnt_putc_ctx {
649651
npf_putc pc;
@@ -1065,6 +1067,7 @@ int _asprintf_c(char **__restrict p_str, const char *__restrict format, ...) {
10651067
return ret;
10661068
}
10671069

1070+
#if 0
10681071
int _vfprintf_c(FILE* __restrict stream, const char* __restrict format, va_list vlist)
10691072
{
10701073
return npf_vpprintf(npf_fputc_std, (void*)stream, format, vlist);
@@ -1078,6 +1081,7 @@ int _fprintf_c(FILE* __restrict stream, const char* __restrict format, ...)
10781081
va_end(va);
10791082
return ret;
10801083
}
1084+
#endif
10811085

10821086
#if NANOPRINTF_HAVE_GCC_WARNING_PRAGMAS
10831087
#pragma GCC diagnostic pop

src/libc/printf.src

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if HAS_PRINTF
1212
public _vsnprintf
1313
public _asprintf
1414
public _vasprintf
15-
public _fprintf
16-
public _vfprintf
15+
;public _fprintf
16+
;public _vfprintf
1717

1818
_printf := __printf_c
1919
_vprintf := __vprintf_c
@@ -23,8 +23,8 @@ _snprintf := __snprintf_c
2323
_vsnprintf := __vsnprintf_c
2424
_asprintf := __asprintf_c
2525
_vasprintf := __vasprintf_c
26-
_fprintf := __fprintf_c
27-
_vfprintf := __vfprintf_c
26+
;_fprintf := __fprintf_c
27+
;_vfprintf := __vfprintf_c
2828

2929
extern __printf_c
3030
extern __vprintf_c
@@ -34,8 +34,8 @@ _vfprintf := __vfprintf_c
3434
extern __vsnprintf_c
3535
extern __asprintf_c
3636
extern __vasprintf_c
37-
extern __fprintf_c
38-
extern __vfprintf_c
37+
;extern __fprintf_c
38+
;extern __vfprintf_c
3939

4040
else
4141

src/libcxx/include/cstdio

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ using ::sprintf;
3535
using ::vsprintf;
3636
using ::snprintf;
3737
using ::vsnprintf;
38+
#if 0
3839
using ::fprintf;
3940
using ::vfprintf;
41+
#endif
4042
using ::asprintf;
4143
using ::vasprintf;
4244
using ::perror;

test/standalone/asprintf_fprintf/src/main.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* ti_snprintf
1515
* ti_asprintf
1616
* asprintf
17-
* fprintf
17+
* fprintf // disabled for now
1818
* stpcpy
1919
* memccpy
2020
*/
@@ -69,6 +69,8 @@ static const int pos_2 = 42;
6969
static char* buf = NULL;
7070
static FILE* file = NULL;
7171

72+
static char sprintfbuf[200] = {0};
73+
7274
int ti_tests(void) {
7375
int pos;
7476
int len = ti_asprintf(
@@ -157,6 +159,7 @@ int nano_tests(void) {
157159
return 0;
158160
}
159161

162+
#if 0
160163
static char const * const fprintf_test =
161164
"Terminal ':' (found):\t\"Stars:\"\n"
162165
"Terminal ' ' (found):\t\"Stars: \"\n"
@@ -167,6 +170,7 @@ static char const * const fprintf_test =
167170
"Separate star names from distances (ly):\n"
168171
"Arcturus Vega Capella Rigel Procyon \n"
169172
/* fprintf_test */;
173+
#endif
170174

171175
static char const * const file_name = "FPRINTST";
172176

@@ -208,8 +212,9 @@ int memccpy_tests(void) {
208212
for (size_t i = 0; i != sizeof terminal; ++i)
209213
{
210214
void* to = T_memccpy(dest, src, terminal[i], sizeof dest);
211-
212-
fprintf(file,"Terminal '%c' (%s):\t\"", terminal[i], to ? "found" : "absent");
215+
216+
sprintf(sprintfbuf, "Terminal '%c' (%s):\t\"", terminal[i], to ? "found" : "absent");
217+
fputs(sprintfbuf, file);
213218

214219
// if `terminal` character was not found - print the whole `dest`
215220
to = to ? to : dest + sizeof dest;
@@ -222,7 +227,8 @@ int memccpy_tests(void) {
222227
}
223228

224229

225-
fprintf(file, "%c%s", '\n', "Separate star names from distances (ly):\n");
230+
sprintf(sprintfbuf, "%c%s", '\n', "Separate star names from distances (ly):\n");
231+
fputs(sprintfbuf, file);
226232
const char *star_distance[] = {
227233
"Arcturus : 37", "Vega : 25", "Capella : 43", "Rigel : 860", "Procyon : 11"
228234
};
@@ -241,7 +247,8 @@ int memccpy_tests(void) {
241247

242248
if (first) {
243249
*first = '\0';
244-
fprintf(file, "%s%c", names_only, '\n');
250+
sprintf(sprintfbuf, "%s%c", names_only, '\n');
251+
fputs(sprintfbuf, file);
245252
} else {
246253
printf("Error Buffer is too small.\n");
247254
}
@@ -266,6 +273,7 @@ int memccpy_tests(void) {
266273
perror("Error reading from file");
267274
return __LINE__;
268275
}
276+
#if 0
269277
if (T_strlen(buf) != T_strlen(fprintf_test)) {
270278
printf("E: %zu != %zu\n", T_strlen(buf), T_strlen(fprintf_test));
271279
get_diff_char(buf, fprintf_test);
@@ -277,6 +285,7 @@ int memccpy_tests(void) {
277285
get_diff_char(buf, fprintf_test);
278286
return __LINE__;
279287
}
288+
#endif
280289
return 0;
281290
}
282291

@@ -347,7 +356,7 @@ int main(void)
347356
if (ret != 0) {
348357
printf("Failed test L%d\n", ret);
349358
} else {
350-
fprintf(stdout, "All tests %s", "passed");
359+
printf("All tests passed\n");
351360
}
352361

353362
while (!os_GetCSC());

0 commit comments

Comments
 (0)