[SOLVED] Using libmenu and ncurses, listing stops if char is encountered
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using libmenu and ncurses, listing stops if char is encountered
The problem is that I'm populating a menu array with file names. If any of the filenames contains a " ", the menu list selection will only show up to (but not including) the file that has the " " in the filename.
The menu gets populated by items that were sorted and put into a binary search tree.
My program is working as intended when there are no filenames that contain the " ". Using gdb, When I look at the function at the time when items are being copied to the menu array that post_menu() uses, everything looks fine. But when post_menu() and refresh() are executed, the menu doesn't show the full list.
For example, if there is a file called custers last stand, at the menu selection window, I would see
Quote:
...
carp
copying
culvert
and the listing would be ended. I can still scroll up and back down, and do everything as normal. I can quit the program and get a "0" for a return code.
The character appears to be 146 on the extended ASCII chart. I can reproduce the problem every time.
I normally build the program with ncurses 5.9, but I tried with the latest, 6.1, and the result was the same.
When it's not using ncurses, my program operates on filenames with the character fine, as far as I can tell.
Iconv might help but I suggest simply deleting every files that have non-ASCII characters in their names.
That would be impossible in this case. The program is a console "recycle bin". I found the bug completely by chance because I had a single file present in my trashcan that had this silly char.
That could get pretty tricky. What's displayed in the list are the names of the files in the "Waste" folder; from there, selecting one or multiple files will restore them. If a filename gets changed, then it can't get restored.
The only way I can think of off the top of my head to do that would be keep track of the file that has it's name changed, the character that it was previously. And if it's selected for restoration, change it back.
I remodelled by autoconf file and the build is working on OpenBSD and Mac OSX again. Though I'm not too sure if wide-char support is available on osx yet. On the Travis code integration logs, it's showing that ncursesw and menuw can't be found; and it's linking against the "non-w" libraries.
As for iconv, I've heard of it course but I'm not at all familiar with it. Are you suggesting that would be a better long-term solution than using ncurses with wide-character support enabled?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.