err and warn are BSD format but they are not recommended by library
developers. However their consiseness is useful!
The solution is to use some macros that create xerr etc which then
just map to the error() function. The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name
This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
The library used to be called libprocps but it was renamed to make sure
there was only one. However the formatting of the library SONAME has
changed so there cannot be any confusion.
libprocps makes it clear that its a library from this project and not a
set of functions directly on the filesystem.
The Kbytes column when using the pmap -x flag would always be zero. This
was because the diff variable was reset before it could be printed.
pmap with no -x was not impacted by this bug or fix.
This patch represents the final resting place for miscellaneous
changes not otherwise encountered or for which the resolution
was incomplete or incorrect.
The gettext documentation leads one to believe that
a printf type call is necessary for gettext string
extraction. That turns out to be misleading and
all one really needs is the runtime gettext string
address resolution.
Thus, we can avoid our original snprintf/strdup
overhead and establish an address for the original
or translated string just by issuing the _() macro.
We create these nls string tables so that:
1) top avoids the overhead of repeated
runtime function calls
2) we can control the order of top's
strings in the .pot file
3) translator comments don't obscure
and clutter the main program
Until this patch, top had used some strings with
special escape sequences to produce colors, normal
text, bold text, etc. They took the following form,
explained by an excerpt from program comments:
...
Our special formatting consists of:
"some text <_delimiter_> some more text <_delimiter_>...\n"
Where <_delimiter_> is a single byte in the range of:
\001 through \010 (in decimalizee, 1 - 8)
and is used to select an 'attribute' from a capabilities table
which is then applied to the *preceding* substring.
...
Unfortunately, these nonprinting values revealed
insurmountable inconsistencies in both the front-end
and back-end translation tools.
The xgettext (extraction) program would take those
special escapes, convert them and then output raw
binary values. Thus the .pot file would contain
lots of unprintable stuff making it unreadable.
If the following was added to po/Makevars, most of
those special escapes would be preserved in their
escape notation:
XGETTEXT_OPTIONS = ... --escape
But two escapes were converted from octal notation
and there was no way to prevent it:
\007 --> \a
\010 --> \b
After a pass through the msginit program, most of
the escapes were reconverted to raw binary values
making translation impossible. There was no
"--escape" option for the back-end programs like
there was for xgettext.
But the real killer was the escape \004, also used
in some of top's special strings. This value would
be silently accepted by xgettext, only to produce
the following fatal error in back-end programs like
msginit, msgfmt and msgen:
.pot:2647: context separator <EOT> within string
To quote from one of the references below:
"Would you create a suite of tools that silently
allow what is destined to become a fatal error
to pass unnoticed?"
So the bottom line was: top's special strings, in
use for the past nine years, had to be redesigned.
References:
http://www.freelists.org/post/procps/procpsng-nls-support,11http://www.freelists.org/post/procps/procpsng-nls-support,14
summary of changes:
. adopted relative paths to 'include' and 'proc'
dirs so that stand alone compiles are made
easier and no one need guess their locations
. corrected several names for enums and macro
usage reflecting fmt vs. txt
. expanded all octal escape sequences to a full
3 digits since one already required 3 digits
. finalized translator hints (for now)
programming note:
as an aside, by not including an argument for
the gettext --add-comments, any preceeding c
style comment will be propagated to the .pot
file, if the gettext macro isn't empty.
/* Need Not Say 'TRANSLATORS' ...
snprintf(buf, sizeof(buf), "%s", _( // unseen
/* Translator Hint: ...
snprintf(buf, sizeof(buf), "%s", _("" // seen
With the privatization of the library xalloc functions,
this patch restores top's previous internal memory logic.
This puts us back on a 3.3.1 (and earlier) footing wherein
memory allocation errors carry these implications:
. if top detected, the terminal will be restored
prior to an abnormal exit and message
. if library detected, the terminal will become
corrupted following the message
To my knowledge, neither type of memory error has ever occurred
during the nine years since top was rewritten. So the issue of
restoring the termios structure is probably moot.
Pattern matching support in `sysctl: implement --pattern option'
commit did not work when variable path was defined, for example
$ sysctl net.ipv4 -r arp.ignore
gave no output. Reason being was tht the pattern was matched agains
the specified argument and not the output variable list.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Includes also magic number removal (return value 1 to EXIT_FAILURE),
and proper null assignment to end of string.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit fixes also peculiar behavior of
$ slabtop -d 0
which did not make sense. The fix is to disallow anything else but
positive integers, which includes zero as is is not positive (or
negative) number.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The vmstat used ULONG_MAX as definition of infinite updates. On a
computer with mighty uptime one will find that after 136 years
(assuming 1 second update interval) the vmstat exits, which is in
conflict with a promise of infinite.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>