Revert "build: fix Windows build failures in helpgen and framegen"

This reverts commit 704511465b.
This commit is contained in:
Mitchell Hashimoto
2026-03-22 14:10:12 -07:00
parent 48cf3f36cd
commit 0fdddd5bc2
3 changed files with 10 additions and 33 deletions

View File

@@ -8,16 +8,15 @@
#define SEPARATOR '\x01'
#define CHUNK_SIZE 16384
#define MAX_FRAMES 1024
#define PATH_SEP '/'
static int is_frame_file(const char *name) {
static int filter_frames(const struct dirent *entry) {
const char *name = entry->d_name;
size_t len = strlen(name);
return len > 4 && strcmp(name + len - 4, ".txt") == 0;
}
static int compare_names(const void *a, const void *b) {
return strcmp(*(const char **)a, *(const char **)b);
static int compare_frames(const struct dirent **a, const struct dirent **b) {
return strcmp((*a)->d_name, (*b)->d_name);
}
static char *read_file(const char *path, size_t *out_size) {
@@ -55,47 +54,25 @@ int main(int argc, char **argv) {
const char *frames_dir = argv[1];
const char *output_file = argv[2];
// Use opendir/readdir instead of scandir for Windows compatibility
DIR *dir = opendir(frames_dir);
if (!dir) {
struct dirent **namelist;
int n = scandir(frames_dir, &namelist, filter_frames, compare_frames);
if (n < 0) {
fprintf(stderr, "Failed to scan directory %s: %s\n", frames_dir, strerror(errno));
return 1;
}
char *names[MAX_FRAMES];
int n = 0;
struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
if (!is_frame_file(entry->d_name)) continue;
if (n >= MAX_FRAMES) {
fprintf(stderr, "Too many frame files (max %d)\n", MAX_FRAMES);
closedir(dir);
return 1;
}
names[n] = strdup(entry->d_name);
if (!names[n]) {
fprintf(stderr, "Failed to allocate memory\n");
closedir(dir);
return 1;
}
n++;
}
closedir(dir);
if (n == 0) {
fprintf(stderr, "No frame files found in %s\n", frames_dir);
return 1;
}
qsort(names, n, sizeof(char *), compare_names);
size_t total_size = 0;
char **frame_contents = calloc(n, sizeof(char*));
size_t *frame_sizes = calloc(n, sizeof(size_t));
for (int i = 0; i < n; i++) {
char path[4096];
snprintf(path, sizeof(path), "%s%c%s", frames_dir, PATH_SEP, names[i]);
snprintf(path, sizeof(path), "%s/%s", frames_dir, namelist[i]->d_name);
frame_contents[i] = read_file(path, &frame_sizes[i]);
if (!frame_contents[i]) {

View File

@@ -12,7 +12,7 @@ pub fn main() !void {
const alloc = gpa.allocator();
var buf: [4096]u8 = undefined;
var stdout = std.fs.File.stdout().writerStreaming(&buf);
var stdout = std.fs.File.stdout().writer(&buf);
const writer = &stdout.interface;
try writer.writeAll(
\\// THIS FILE IS AUTO GENERATED

View File

@@ -34,7 +34,7 @@ pub fn main() !void {
// Our output always goes to stdout.
var buffer: [1024]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writerStreaming(&buffer);
var stdout_writer = std.fs.File.stdout().writer(&buffer);
const writer = &stdout_writer.interface;
switch (action) {
.bash => try writer.writeAll(@import("extra/bash.zig").completions),