[klibc] [SHELL] Fix klibc DEBUG compilation
dash didn't compile in DEBUG mode against klibc for all long time.
Now it only fails at link stage for not having setlinebuf(3) and
freopen(3).
Fixes:
usr/dash/show.o: In function `opentrace':
show.c:(.text+0x36): undefined reference to `freopen'
show.c:(.text+0x86): undefined reference to `setlinebuf'
Skip setlinebuf and use fclose/fopen inside __KLIBC__
Compile tested with debug in klibc and against glibc in dash repo.
Signed-off-by: maximilian attems <max@stro.at>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: maximilian attems <max@stro.at>
diff --git a/usr/dash/show.c b/usr/dash/show.c
index 14dbef3..4a049e9 100644
--- a/usr/dash/show.c
+++ b/usr/dash/show.c
@@ -378,7 +378,11 @@
scopy("./trace", s);
#endif /* not_this_way */
if (tracefile) {
+#ifndef __KLIBC__
if (!freopen(s, "a", tracefile)) {
+#else
+ if (!(!fclose(tracefile) && (tracefile = fopen(s, "a")))) {
+#endif /* __KLIBC__ */
fprintf(stderr, "Can't re-open %s\n", s);
debug = 0;
return;
@@ -394,7 +398,9 @@
if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
#endif
+#ifndef __KLIBC__
setlinebuf(tracefile);
+#endif /* __KLIBC__ */
fputs("\nTracing started.\n", tracefile);
}
#endif /* DEBUG */