Two different manpages for strftime? - strftime

I'm baffled. In one tmux pane, I can see an entry for %Z and %z with manpage strftime. Yet in another pane, I only see %z but not %Z. Both manpages say:
STRFTIME(3) BSD Library Functions Manual STRFTIME(3)
at the top.
Any ideas?

Looks like something goofy was going on with wrapping. I widened the pane and the problem was resolved.

Related

Is it possible to use quotation marks for FindFirstFile() function?

I try to return a specific .xls file with FindFirstFile(). Howerver it also returns .xlsx, due to naming convention. It is possible to use "*.xls" in the file explorer to return only .xls files. Does this work for the functi
As #Hans Passant said you got bitten by the legacy support for 8.3 MSDOS names.
Your LovelyTable.xlsx also has a secondary name, something like LOVELY~1.XLS and this second name is what FindFirstFile()/FindNextFile() gives you. The only robust way to avoid such results is to recheck what is returned back to you.
If you don't want to change the application you can also remove short names from the volume and also disable their generation. You can check the fsutil command (its 8dot3name sub-command) for that but beware that this might break some software even nowadays. (For example software believing it is installed under C:\PROGRA~2\)
I thought that FindFirstFileEx() can filter-out the 8.3 names:
FindFirstFileEx(searchPattern, FindExInfoBasic, ...)
but it cannot. Thanks to #RbMm for clearing this out. FindExInfoBasic only avoids filling in the WIN32_FIND_DATA's cAlternateFileName field. You still receive files discovered by their short names.
This is a consequence of support for short 8.3 filenames. Your .xlsx file is given a short name with .xls extension. And it is the short file name that is matching.
Whilst you can turn off support for short filenames of drives that you control, that option is not practical for machines that you don't control. So realistically you will have to apply your own filtering.

Up arrow based command history in console input (C++)

I am trying to build a console application that takes user input. I was able to use printf to keep the cursor in the same place, I could have used curses as well, but I can't get up-arrow command history to work. Any pointers ?
I think you want readline (www.gnu.org/software/readline/ which seems to now redirect to the maintainer site at http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html)
In addition to the mentions of the readline library, I'll also mention the BSD-licensed editline library and the rlwrap command-line wrapper tool that runs any program with a readline-based history.
As long as the GNU license is not a problem for you, I would strongly consider GNU Readline
Have a look at the GNU Readline library. It can provide input history support.
In Windows the standard console windows provide up-arrow input history -- you don't have to do anything. For other standard Windows console services see the doskey command quickhelp, and simply replace the word "command" with "line of input". It's a bit misleading, yes.
EDIT, added para: Possibly you're doing something that circumvents the standard services. I just noticed that the browser window title says "ncurses", which is not in your current question title. Perhaps that's it, but in that case, ask specifically for help with ncurses.
For *nix see the other answers.
Cheers & hth.

Is there a plugin for Vim that would help me debugging like Visual Studio?

The reason why I'm asking this, is because I'm coding in C++, in putty/ssh and I like the fact that I can code from pretty much everywhere without having to install anything.
So I'd like to have something that could help me debugging (viewing LIVE value of a variable, breakpoints, etc)
If you think that there's no such thing in this world, is there any good technique I could use to debug in command line?
Thanks
I've used gdb for command line debugging in the past with success:
http://www.gnu.org/software/gdb/
A decent tutorial can be found at:
http://www.cs.cmu.edu/~gilpin/tutorial/
vimgdb will give what you want. I've used it for about one year. The most interesting feature is:
Hightlight current line
List item
Can show disassembly code
Step into, Step over
inspect variables, memory address
Run all the underlying gdb command is possible
And, of course, set breakpoint, conditional breakpoint etc.
Highly customizable by vim key mapping and scripts.
Actually I use checkinstall to make an rpm for it, and installed it everywhere when I need to debug on the box.
I think it have the most important features I want from a visual debugger.
Have you tried gdb ? That's pretty much the command line debugger, but it's no vim plugin.
You have a script to do that: http://www.vim.org/scripts/script.php?script_id=1954
In my humble opinion, Vim is not designed to do such things and it is a bad idea to do so.

Is it possible to refresh two lines of text at once using something like a CR? (C++)

Right now, I have a console application I'm working on, which is supposed to display and update information to the console at a given interval. The problem I'm having is that with a carriage return, I can only update one line of text at a time. If I use a newline, the old line can no longer be updated using a carriage return.
What can I do here?
You might be able to find a curses library variant that works on your platform.
The correct answer is to use the curses library as mentioned by Mark. But if you're on Unix-like systems and can't be bothered with curses then the quick and dirty solution is to directly print out vt100 escape sequences:
http://ascii-table.com/ansi-escape-sequences-vt-100.php
I often do this especially in scripting languages that doesn't have a curses binding.
This is a really ugly solution, but in a pinch you could always just clear the console entirely and then reprint everything. This strategy looks a bit ugly in some cases; it may make things look blinky.

Central Clickable MSDN like Linux System/C/C++ Standard Library Documentation

If you are windows programmer and you want to program something new where you
are going to use some new API with which you are not that familiar then you can type MSDN on your web browser and you get immediately what you need. Nicely grouped API functions where you can see what to include and what to link.
I am looking for something similar in the Linux world. I want to sleep my function for some milliseconds and I type "man sleep" then I get the explanation of shell command "sleep". But I don't want that. I am programming and I just want see the programmatical usage of that function.
So the question is: Is there a central, clickable and browsable documentation of C, C++ standard libraries AND linux system calls which are not part of the C/C++ standard but quite often used in linux programming ?
Thanks in advance,
G.
Man is broken down into sections If you type "man man" you can see them.
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and convenā€
tions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
So since you wnat the library call version of sleep() you would write "man 3 sleep". Also "info" is another way to access the same information.
You can also do a search with "man -k sleep", which will list everything matching sleep.
There are hyperlinked man pages scattered around the internet if you want to bookmark them.
For C++ APIs there are some good sites that many people have bookmarked and open a good portion of the time.
The important thing to remember is that unlike Windows, no one really owns or controls Linux. You can build any kind of distribution you want with many different kernel options. It makes things less tidy in some ways but far more flexible in others.
Well in your case you could have typed "man 3 sleep"...
Konqueror (the KDE web/file browser) lets you type "#XXX" in the bar to look up the man page for XXX, and "##XXX" to look up the info page for XXX. Unlike man, it gives you the choice between which man page you want to choose if there is more than one. They are interlinked together, so looking up "sleep", you will see in the "SEE ALSO" section, signal, and you can click it to go to its man page.
I don't know of anything like this for C++, but there are several good websites with documentation:
http://www.cplusplus.com/reference/
http://www.sgi.com/tech/stl/
(just to name a few that I use regularly)
By default, man pages look under man 1, which is classified as "General Commands." You want man 3, which is "Subroutines."
For a list of all the man pages, and their topics, I use http://www.linuxmanpages.com/ a lot, which is just a copy of all the man pages online.
man 3 sleep
You can also browse them online, http://www.kernel.org/doc/man-pages/
Man pages are nice for reference, but they do not substitute a book on unix programming.
However, many libraries maintain browsable and verbose documentation. Like Qt, Boost, and many others.
Some tools are stand-alone projects, like Valgrind, and it's up to you to choose tools. The freedom to choose tools has a cost: there is no central point of reference.
But Google is the ultimate place to search for the appropriate tools, manuals and references. Actually, it's very good in finding and indexing unix programming manuals. Ctrl+K in Firefox, unix sleep function, and here you go.