2
3
Fork
You've already forked ncsu
0

replace ncurses_refs.c workaround with pure Zig workaround #229

Closed
BratishkaErik wants to merge 0 commits from refs/pull/229/head into zig
pull from: refs/pull/229/head
merge into: selfisekai:zig
selfisekai:zig
selfisekai:zig0.16
selfisekai:master
selfisekai:zig-threaded
selfisekai:openat
selfisekai:chdir
selfisekai:clear
selfisekai:compll
BratishkaErik commented 2023年10月13日 20:06:11 +02:00 (Migrated from code.blicky.net)
Copy link

Works on both 0.11.0 and 9999 (git) versions (0.12.0-dev.867+1f6d82ec0).

Signed-off-by: Eric Joldasov bratishkaerik@getgoogleoff.me

Works on both 0.11.0 and 9999 (git) versions (0.12.0-dev.867+1f6d82ec0). Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
BratishkaErik (Migrated from code.blicky.net) reviewed 2023年10月13日 20:09:44 +02:00
BratishkaErik (Migrated from code.blicky.net) reviewed 2023年10月13日 20:10:21 +02:00
BratishkaErik (Migrated from code.blicky.net) reviewed 2023年10月13日 20:13:06 +02:00
BratishkaErik (Migrated from code.blicky.net) reviewed 2023年10月13日 20:16:45 +02:00
BratishkaErik commented 2023年10月14日 06:25:52 +02:00 (Migrated from code.blicky.net)
Copy link

Sorry, I forgot to remove ncurses_refs.c from Makefile, will do now.

Sorry, I forgot to remove `ncurses_refs.c` from Makefile, will do now.
BratishkaErik commented 2023年10月14日 06:30:51 +02:00 (Migrated from code.blicky.net)
Copy link

done

done
BratishkaErik commented 2023年11月17日 14:35:48 +01:00 (Migrated from code.blicky.net)
Copy link

BTW it is a nice help for future work based on https://github.com/gentoo/gentoo/pull/33868.

BTW it is a nice help for future work based on https://github.com/gentoo/gentoo/pull/33868.
yorhel commented 2023年11月19日 08:14:47 +01:00 (Migrated from code.blicky.net)
Copy link

Sorry for the delay, getting rid of the C file isn't too high of a priority and there's the potential to break some systems, so I'd err on the side of caution.

Overall this approach looks sensible; hardcoding the map indices seems like a bad idea at first, but ncurses can't really change them anyway without breaking ABI compat and I doubt they'd do that at this point. There's also a minor concern with some systems (notably pkgsrc) using alternative curses implementations, but I don't think that works with ncdu2 yet so that won't count as a regression. And they can always fall back to proper ncurses as well.

The whole init() approach seems pretty roundabout, is there a reason you didn't go for a simpler approach like this?

// Replaces the 'ACS.init()' call:constacs_map=@extern(*[128]c.chtype,.{.name="acs_map"});constulcorner=acs_map['l'];// ...
Sorry for the delay, getting rid of the C file isn't too high of a priority and there's the potential to break some systems, so I'd err on the side of caution. Overall this approach looks sensible; hardcoding the map indices seems like a bad idea at first, but ncurses can't really change them anyway without breaking ABI compat and I doubt they'd do that at this point. There's also a minor concern with some systems (notably pkgsrc) using alternative curses implementations, but I don't think that works with ncdu2 yet so that won't count as a regression. And they can always fall back to proper ncurses as well. The whole `init()` approach seems pretty roundabout, is there a reason you didn't go for a simpler approach like this? ```zig // Replaces the 'ACS.init()' call: const acs_map = @extern(*[128]c.chtype, .{ .name = "acs_map" }); const ulcorner = acs_map['l']; // ... ```
BratishkaErik commented 2023年11月19日 09:36:36 +01:00 (Migrated from code.blicky.net)
Copy link

Sorry for the delay, getting rid of the C file isn't too high of a priority and there's the potential to break some systems, so I'd err on the side of caution.

Sure!

Overall this approach looks sensible; hardcoding the map indices seems like a bad idea at first, but ncurses can't really change them anyway without breaking ABI compat and I doubt they'd do that at this point. There's also a minor concern with some systems (notably pkgsrc) using alternative curses implementations, but I don't think that works with ncdu2 yet so that won't count as a regression. And they can always fall back to proper ncurses as well.

Yep, I thought about this (and it should be properly fixed in translate-c instead), but it also helps to build sys-fs/ncdu with other non-LLVM backends so IMO it should be a net-win for portability.

The whole init() approach seems pretty roundabout, is there a reason you didn't go for a simpler approach like this?

// Replaces the 'ACS.init()' call:constacs_map=@extern(*[128]c.chtype,.{.name="acs_map"});constulcorner=acs_map['l'];// ...

Initially, I added it as an interface that can be used in other files, not just Box.create (https://code.blicky.net/yorhel/ncdu/pulls/229#issuecomment-1435) and left this idea as-is in the current version. Struct-level constants or variable initializers are required to be comptime-known so I moved them to this runtime function. But to think of it, it's unnecessary (Box.create is the only user) so you are right.

> Sorry for the delay, getting rid of the C file isn't too high of a priority and there's the potential to break some systems, so I'd err on the side of caution. Sure! > Overall this approach looks sensible; hardcoding the map indices seems like a bad idea at first, but ncurses can't really change them anyway without breaking ABI compat and I doubt they'd do that at this point. There's also a minor concern with some systems (notably pkgsrc) using alternative curses implementations, but I don't think that works with ncdu2 yet so that won't count as a regression. And they can always fall back to proper ncurses as well. Yep, I thought about this (and it should be properly fixed in translate-c instead), but it also helps to build sys-fs/ncdu with other non-LLVM backends so IMO it should be a net-win for portability. > > The whole `init()` approach seems pretty roundabout, is there a reason you didn't go for a simpler approach like this? > > ```zig > // Replaces the 'ACS.init()' call: > const acs_map = @extern(*[128]c.chtype, .{ .name = "acs_map" }); > const ulcorner = acs_map['l']; > // ... > ``` Initially, I added it as an interface that can be used in other files, not just Box.create (https://code.blicky.net/yorhel/ncdu/pulls/229#issuecomment-1435) and left this idea as-is in the current version. Struct-level constants or variable initializers are required to be comptime-known so I moved them to this runtime function. But to think of it, it's unnecessary (Box.create is the only user) so you are right.
yorhel commented 2023年11月19日 10:25:23 +01:00 (Migrated from code.blicky.net)
Copy link

Pulled, thanks!

Pulled, thanks!
BratishkaErik commented 2023年11月19日 11:23:31 +01:00 (Migrated from code.blicky.net)
Copy link

Thank you!

Thank you!

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No reviewers
No labels
1.x
2.x
bug
feature
imported
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
selfisekai/ncsu!229
Reference in a new issue
selfisekai/ncsu
No description provided.
Delete branch "refs/pull/229/head"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?