Просмотр исходного кода

Hack in zero byte again to not pass in old buffer

Ugh.  Quite hideous but it works.  Hm.
Luna Stadler лет назад: 4
Родитель
Сommit
dd94c3ba98
1 измененных файлов с 9 добавлено и 9 удалено
  1. 9 9
      zig/sdl/hello_sdl.zig

+ 9 - 9
zig/sdl/hello_sdl.zig

@ -200,7 +200,7 @@ const Runner = struct {
200 200
                    return err;
201 201
                },
202 202
            };
203
            std.debug.print("{d} ({d})\n", .{ process.stdout_buf.items.len, process.stderr_buf.items.len });
203
            //std.debug.print("{d} ({d})\n", .{ process.stdout_buf.items.len, process.stderr_buf.items.len });
204 204
            if (process.stdout_buf.items.len > 0) {
205 205
                return process.stdout();
206 206
            } else if (process.stderr_buf.items.len > 0) {
@ -231,7 +231,7 @@ const GoDocRunner = struct {
231 231
232 232
    fn toArgv(cmd: []const u8) []const []const u8 {
233 233
        // NO idea why bufPrint is required, but without `cmd` will just be some random bit of memory, which is rude.
234
        _ = std.fmt.bufPrint(&cmd_buf, "{s}", .{cmd["go ".len..]}) catch "???";
234
        _ = std.fmt.bufPrint(&cmd_buf, "{s}\x00", .{cmd["go ".len..]}) catch "???";
235 235
        return &[_][]const u8{ "go", "doc", &cmd_buf };
236 236
    }
237 237
};
@ -246,7 +246,7 @@ const PythonHelpRunner = struct {
246 246
    }
247 247
248 248
    fn toArgv(cmd: []const u8) []const []const u8 {
249
        _ = std.fmt.bufPrint(&cmd_buf, "import {s}; help({s});", .{ std.mem.sliceTo(cmd["py ".len..], '.'), cmd["py ".len..] }) catch "???";
249
        _ = std.fmt.bufPrint(&cmd_buf, "import {s}; help({s});\x00", .{ std.mem.sliceTo(cmd["py ".len..], '.'), cmd["py ".len..] }) catch "???";
250 250
        return &[_][]const u8{ "python", "-c", &cmd_buf };
251 251
    }
252 252
};
@ -261,7 +261,7 @@ const PythonRunner = struct {
261 261
    }
262 262
263 263
    fn toArgv(cmd: []const u8) []const []const u8 {
264
        _ = std.fmt.bufPrint(&cmd_buf, "print({s})", .{cmd["py! ".len..]}) catch "???";
264
        _ = std.fmt.bufPrint(&cmd_buf, "print({s})\x00", .{cmd["py! ".len..]}) catch "???";
265 265
        return &[_][]const u8{ "python", "-c", &cmd_buf };
266 266
    }
267 267
};
@ -276,7 +276,7 @@ const HelpRunner = struct {
276 276
    }
277 277
278 278
    fn toArgv(cmd: []const u8) []const []const u8 {
279
        _ = std.fmt.bufPrint(&cmd_buf, "{s}", .{cmd[0 .. cmd.len - " --help".len]}) catch "???";
279
        _ = std.fmt.bufPrint(&cmd_buf, "{s}\x00", .{cmd[0 .. cmd.len - " --help".len]}) catch "???";
280 280
        return &[_][]const u8{ &cmd_buf, "--help" };
281 281
    }
282 282
};
@ -291,7 +291,7 @@ const ManPageRunner = struct {
291 291
    }
292 292
293 293
    fn toArgv(cmd: []const u8) []const []const u8 {
294
        _ = std.fmt.bufPrint(&cmd_buf, "{s}", .{cmd["man ".len..]}) catch "???";
294
        _ = std.fmt.bufPrint(&cmd_buf, "{s}\x00", .{cmd["man ".len..]}) catch "???";
295 295
        return &[_][]const u8{ "man", &cmd_buf };
296 296
    }
297 297
};
@ -306,7 +306,7 @@ const SearchRunner = struct {
306 306
    }
307 307
308 308
    fn toArgv(cmd: []const u8) []const []const u8 {
309
        _ = std.fmt.bufPrint(&cmd_buf, "{s}", .{cmd["s ".len..]}) catch "???";
309
        _ = std.fmt.bufPrint(&cmd_buf, "{s}\x00", .{cmd["s ".len..]}) catch "???";
310 310
        return &[_][]const u8{ "ag", &cmd_buf, "/home/luna/k/the-thing" };
311 311
    }
312 312
};
@ -326,7 +326,7 @@ const LogsRunner = struct {
326 326
        }
327 327
328 328
        const service = cmd["logs ".len..];
329
        _ = std.fmt.bufPrint(&cmd_buf, "(systemctl status {s} &> /dev/null && journalctl -u {s} -f) || (systemctl status --user {s} &> /dev/null && journalctl --user -u {s} -f) || echo \"no logs for '{s}'\"", .{ service, service, service, service, service }) catch "???";
329
        _ = std.fmt.bufPrint(&cmd_buf, "(systemctl status {s} &> /dev/null && journalctl -u {s} -f) || (systemctl status --user {s} &> /dev/null && journalctl --user -u {s} -f) || echo \"no logs for '{s}'\"\x00", .{ service, service, service, service, service }) catch "???";
330 330
        return &[_][]const u8{ "bash", "-c", &cmd_buf };
331 331
    }
332 332
};
@ -341,7 +341,7 @@ const QalcRunner = struct {
341 341
    }
342 342
343 343
    fn toArgv(cmd: []const u8) []const []const u8 {
344
        _ = std.fmt.bufPrint(&cmd_buf, "{s}", .{cmd}) catch "???";
344
        _ = std.fmt.bufPrint(&cmd_buf, "{s}\x00", .{cmd}) catch "???";
345 345
        return &[_][]const u8{ "qalc", "-terse", &cmd_buf };
346 346
    }
347 347
};