32 lines
934 B
C
32 lines
934 B
C
// Stubs for libc functions Lua references that our libc doesn't provide.
|
|
// Kept minimal — only what's needed for the small embedded scripts that
|
|
// our test harness runs (no real file I/O, no locale).
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
int strcoll(const char *a, const char *b) {
|
|
return strcmp(a, b);
|
|
}
|
|
|
|
|
|
size_t strxfrm(char *dst, const char *src, size_t n) {
|
|
// C locale: strxfrm is just a length-bounded copy.
|
|
size_t len = strlen(src);
|
|
if (n > 0) {
|
|
size_t copy = (len < n) ? len : (n - 1);
|
|
memcpy(dst, src, copy);
|
|
dst[copy] = '\0';
|
|
}
|
|
return len;
|
|
}
|
|
|
|
|
|
// freopen is referenced by lauxlib.c's loadfile for switching to "rb"
|
|
// mode after a preamble peek. Our fopen already opens binary-clean
|
|
// (no \r\n translation), so we can just return the same handle.
|
|
FILE *freopen(const char *path, const char *mode, FILE *stream) {
|
|
(void)path;
|
|
(void)mode;
|
|
return stream;
|
|
}
|