diff --git a/top/top.c b/top/top.c index 10586a04..0a0503d9 100644 --- a/top/top.c +++ b/top/top.c @@ -1341,60 +1341,61 @@ static FLD_t Fieldstab[] = { P_CPU, L_stat - never filled by libproc, but requires times (pcpu) P_CMD, L_stat - may yet require L_CMDLINE in calibrate_fields (cmd/cmdline) L_EITHER - must L_status, else L_stat == 64-bit math (__udivdi3) on 32-bit ! - .head .width .scale .align .sort .lflg - --------- ------ ------ ------- -------- -------- */ - { "PID", 0, -1, A_right, SF(PID), L_NONE }, - { "PPID", 0, -1, A_right, SF(PPD), L_EITHER }, - { "UID", 5, -1, A_right, SF(UED), L_NONE }, - { "USER", 8, -1, A_left, SF(UEN), L_EUSER }, - { "RUID", 5, -1, A_right, SF(URD), L_status }, - { "RUSER", 8, -1, A_left, SF(URN), L_OUSER }, - { "SUID", 5, -1, A_right, SF(USD), L_status }, - { "SUSER", 8, -1, A_left, SF(USN), L_OUSER }, - { "GID", 5, -1, A_right, SF(GID), L_NONE }, - { "GROUP", 8, -1, A_left, SF(GRP), L_EGROUP }, - { "PGRP", 0, -1, A_right, SF(PGD), L_stat }, - { "TTY", 8, -1, A_left, SF(TTY), L_stat }, - { "TPGID", 0, -1, A_right, SF(TPG), L_stat }, - { "SID", 0, -1, A_right, SF(SID), L_stat }, - { "PR", 3, -1, A_right, SF(PRI), L_stat }, - { "NI", 3, -1, A_right, SF(NCE), L_stat }, - { "nTH", 3, -1, A_right, SF(THD), L_EITHER }, - { "P", 0, -1, A_right, SF(CPN), L_stat }, - { "%CPU", 0, -1, A_right, SF(CPU), L_stat }, - { "TIME", 6, -1, A_right, SF(TME), L_stat }, - { "TIME+", 9, -1, A_right, SF(TME), L_stat }, + + .width .scale .align .sort .lflg + ------ ------ -------- -------- -------- */ + { 0, -1, A_right, SF(PID), L_NONE }, + { 0, -1, A_right, SF(PPD), L_EITHER }, + { 5, -1, A_right, SF(UED), L_NONE }, + { 8, -1, A_left, SF(UEN), L_EUSER }, + { 5, -1, A_right, SF(URD), L_status }, + { 8, -1, A_left, SF(URN), L_OUSER }, + { 5, -1, A_right, SF(USD), L_status }, + { 8, -1, A_left, SF(USN), L_OUSER }, + { 5, -1, A_right, SF(GID), L_NONE }, + { 8, -1, A_left, SF(GRP), L_EGROUP }, + { 0, -1, A_right, SF(PGD), L_stat }, + { 8, -1, A_left, SF(TTY), L_stat }, + { 0, -1, A_right, SF(TPG), L_stat }, + { 0, -1, A_right, SF(SID), L_stat }, + { 3, -1, A_right, SF(PRI), L_stat }, + { 3, -1, A_right, SF(NCE), L_stat }, + { 3, -1, A_right, SF(THD), L_EITHER }, + { 0, -1, A_right, SF(CPN), L_stat }, + { 0, -1, A_right, SF(CPU), L_stat }, + { 6, -1, A_right, SF(TME), L_stat }, + { 9, -1, A_right, SF(TME), L_stat }, #ifdef PERCENTBOOST - { "%MEM", 5, -1, A_right, SF(RES), L_statm }, + { 5, -1, A_right, SF(RES), L_statm }, #else - { "%MEM", 4, -1, A_right, SF(RES), L_statm }, + { 4, -1, A_right, SF(RES), L_statm }, #endif - { "VIRT", 5, SK_Kb, A_right, SF(VRT), L_statm }, - { "SWAP", 4, SK_Kb, A_right, SF(SWP), L_status }, - { "RES", 4, SK_Kb, A_right, SF(RES), L_statm }, - { "CODE", 4, SK_Kb, A_right, SF(COD), L_statm }, - { "DATA", 4, SK_Kb, A_right, SF(DAT), L_statm }, - { "SHR", 4, SK_Kb, A_right, SF(SHR), L_statm }, - { "nMaj", 4, SK_no, A_right, SF(FL1), L_stat }, - { "nMin", 4, SK_no, A_right, SF(FL2), L_stat }, - { "nDRT", 4, SK_no, A_right, SF(DRT), L_statm }, - { "S", 1, -1, A_right, SF(STA), L_EITHER }, - { "COMMAND", -1, -1, A_left, SF(CMD), L_EITHER }, - { "WCHAN", -1, -1, A_left, SF(WCH), L_stat }, - { "Flags", 8, -1, A_left, SF(FLG), L_stat }, - { "CGROUPS", -1, -1, A_left, SF(CGR), L_CGROUP }, - { "SUPGIDS", -1, -1, A_left, SF(SGD), L_status }, - { "SUPGRPS", -1, -1, A_left, SF(SGN), L_SUPGRP }, - { "TGID", 0, -1, A_right, SF(TGD), L_status }, + { 5, SK_Kb, A_right, SF(VRT), L_statm }, + { 4, SK_Kb, A_right, SF(SWP), L_status }, + { 4, SK_Kb, A_right, SF(RES), L_statm }, + { 4, SK_Kb, A_right, SF(COD), L_statm }, + { 4, SK_Kb, A_right, SF(DAT), L_statm }, + { 4, SK_Kb, A_right, SF(SHR), L_statm }, + { 4, SK_no, A_right, SF(FL1), L_stat }, + { 4, SK_no, A_right, SF(FL2), L_stat }, + { 4, SK_no, A_right, SF(DRT), L_statm }, + { 1, -1, A_right, SF(STA), L_EITHER }, + { -1, -1, A_left, SF(CMD), L_EITHER }, + { -1, -1, A_left, SF(WCH), L_stat }, + { 8, -1, A_left, SF(FLG), L_stat }, + { -1, -1, A_left, SF(CGR), L_CGROUP }, + { -1, -1, A_left, SF(SGD), L_status }, + { -1, -1, A_left, SF(SGN), L_SUPGRP }, + { 0, -1, A_right, SF(TGD), L_status }, #ifdef OOMEM_ENABLE #define L_oom PROC_FILLOOM - { "Adj", 3, -1, A_right, SF(OOA), L_oom }, - { "Badness", 8, -1, A_right, SF(OOM), L_oom }, + { 3, -1, A_right, SF(OOA), L_oom }, + { 8, -1, A_right, SF(OOM), L_oom }, #undef L_oom #endif - { "ENVIRON", -1, -1, A_left, SF(ENV), L_ENVIRON }, - { "vMj", 3, SK_no, A_right, SF(FV1), L_stat }, - { "vMn", 3, SK_no, A_right, SF(FV2), L_stat } + { -1, -1, A_left, SF(ENV), L_ENVIRON }, + { 3, SK_no, A_right, SF(FV1), L_stat }, + { 3, SK_no, A_right, SF(FV2), L_stat } #undef SF #undef A_left #undef A_right @@ -1740,7 +1741,7 @@ static void display_fields (int focus, int extend) { , b ? w->cap_bold : Cap_norm , e , i == focus ? w->capclr_hdr : "" - , Fieldstab[f].head + , N_col(f) , Cap_norm , b ? w->cap_bold : "" , e @@ -1781,7 +1782,7 @@ static void fields_utility (void) { spewFI do { - if (!h) h = Fieldstab[f].head; + if (!h) h = N_col(f); display_fields(i, (p != NULL)); putp(Cap_home); show_special(1, fmtmk(N_unq(FIELD_header_fmt) diff --git a/top/top.h b/top/top.h index 45e4417d..a068a766 100644 --- a/top/top.h +++ b/top/top.h @@ -202,7 +202,6 @@ typedef int (*QFP_t)(const void *, const void *); /* This structure consolidates the information that's used in a variety of display roles. */ typedef struct FLD_t { - const char *head; // name for col heads + toggle/reorder fields int width; // field width, if applicable const int scale; // scale_unum type, if applicable const int align; // the default column alignment flag diff --git a/top/top_nls.c b/top/top_nls.c index 0526f8d7..6c17b8bd 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -75,13 +75,24 @@ // /* - * These are our three string tables with the following contents: + * These are our string tables with the following contents: + * Head : column headings with varying size limits * Desc : fields descriptions not to exceed 20 screen positions * Norm : regular text possibly also containing c-format specifiers * Uniq : show_special specially formatted strings * * The latter table presents the greatest translation challenge ! + * + * We go to the trouble of creating the nls string tables to achieve + * these objectives: + * + the overhead of repeated runtime calls to gettext() + * will be avoided + * + the order of the strings in the template (.pot) file + * can be completely controlled + * + none of the important translator only comments will + * clutter and obscure the main program */ +const char *Head_nlstab[P_MAXPFLGS]; const char *Desc_nlstab[P_MAXPFLGS]; const char *Norm_nlstab[norm_MAX]; const char *Uniq_nlstab[uniq_MAX]; @@ -91,66 +102,157 @@ const char *Uniq_nlstab[uniq_MAX]; * This routine builds the nls table containing plain text only * used as the field descriptions. Each translated line MUST be * kept to a maximum of 20 characters or less! */ -static void build_desc_nlstab (void) { +static void build_two_nlstabs (void) { /* Translation Notes ------------------------------------------------ . It is strongly recommend that the --no-wrap command line option . be used with all supporting translation tools, when available. . - . The following single lines contain only plain text used as the - . descriptions under Field Management when the 'f' key is typed. + . The following line pairs contain only plain text and consist of: + . 1) a field name/column header - mostly upper case + . 2) the related description - both upper and lower case + . + . To avoid truncation at runtime, each column header is noted with + . its maximum size and the following description must not exceed + . 20 characters. Fewer characters are ok. . - . To avoid truncation, each translated line MUST be kept to a - . length of 20 characters or less. . */ +/* Translation Hint: maximum 'PID' = 5 */ + Head_nlstab[P_PID] = _("PID"); Desc_nlstab[P_PID] = _("Process Id"); +/* Translation Hint: maximum 'PPID' = 5 */ + Head_nlstab[P_PPD] = _("PPID"); Desc_nlstab[P_PPD] = _("Parent Process pid"); +/* Translation Hint: maximum 'UID' = 5 */ + Head_nlstab[P_UED] = _("UID"); Desc_nlstab[P_UED] = _("Effective User Id"); +/* Translation Hint: maximum 'USER' = 8 */ + Head_nlstab[P_UEN] = _("USER"); Desc_nlstab[P_UEN] = _("Effective User Name"); +/* Translation Hint: maximum 'RUID' = 5 */ + Head_nlstab[P_URD] = _("RUID"); Desc_nlstab[P_URD] = _("Real User Id"); +/* Translation Hint: maximum 'RUSER' = 8 */ + Head_nlstab[P_URN] = _("RUSER"); Desc_nlstab[P_URN] = _("Real User Name"); +/* Translation Hint: maximum 'SUID' = 5 */ + Head_nlstab[P_USD] = _("SUID"); Desc_nlstab[P_USD] = _("Saved User Id"); +/* Translation Hint: maximum 'SUSER' = 8 */ + Head_nlstab[P_USN] = _("SUSER"); Desc_nlstab[P_USN] = _("Saved User Name"); +/* Translation Hint: maximum 'GID' = 5 */ + Head_nlstab[P_GID] = _("GID"); Desc_nlstab[P_GID] = _("Group Id"); +/* Translation Hint: maximum 'GROUP' = 8 */ + Head_nlstab[P_GRP] = _("GROUP"); Desc_nlstab[P_GRP] = _("Group Name"); +/* Translation Hint: maximum 'PGRP' = 5 */ + Head_nlstab[P_PGD] = _("PGRP"); Desc_nlstab[P_PGD] = _("Process Group Id"); +/* Translation Hint: maximum 'TTY' = 8 */ + Head_nlstab[P_TTY] = _("TTY"); Desc_nlstab[P_TTY] = _("Controlling Tty"); +/* Translation Hint: maximum 'TPGID' = 5 */ + Head_nlstab[P_TPG] = _("TPGID"); Desc_nlstab[P_TPG] = _("Tty Process Grp Id"); +/* Translation Hint: maximum 'SID' = 5 */ + Head_nlstab[P_SID] = _("SID"); Desc_nlstab[P_SID] = _("Session Id"); +/* Translation Hint: maximum 'PR' = 3 */ + Head_nlstab[P_PRI] = _("PR"); Desc_nlstab[P_PRI] = _("Priority"); +/* Translation Hint: maximum 'NI' = 3 */ + Head_nlstab[P_NCE] = _("NI"); Desc_nlstab[P_NCE] = _("Nice Value"); +/* Translation Hint: maximum 'nTH' = 3 */ + Head_nlstab[P_THD] = _("nTH"); Desc_nlstab[P_THD] = _("Number of Threads"); +/* Translation Hint: maximum 'P' = 1 */ + Head_nlstab[P_CPN] = _("P"); Desc_nlstab[P_CPN] = _("Last Used Cpu (SMP)"); +/* Translation Hint: maximum '%CPU' = 4 */ + Head_nlstab[P_CPU] = _("%CPU"); Desc_nlstab[P_CPU] = _("CPU Usage"); +/* Translation Hint: maximum '' = 6 */ + Head_nlstab[P_TME] = _("TIME"); Desc_nlstab[P_TME] = _("CPU Time"); +/* Translation Hint: maximum 'TIME+' = 9 */ + Head_nlstab[P_TM2] = _("TIME+"); Desc_nlstab[P_TM2] = _("CPU Time, hundredths"); +/* Translation Hint: maximum '%MEM' = 4 */ + Head_nlstab[P_MEM] = _("%MEM"); Desc_nlstab[P_MEM] = _("Memory Usage (RES)"); +/* Translation Hint: maximum 'VIRT' = 5 */ + Head_nlstab[P_VRT] = _("VIRT"); Desc_nlstab[P_VRT] = _("Virtual Image (KiB)"); +/* Translation Hint: maximum 'SWAP' = 4 */ + Head_nlstab[P_SWP] = _("SWAP"); Desc_nlstab[P_SWP] = _("Swapped Size (KiB)"); +/* Translation Hint: maximum 'RES' = 4 */ + Head_nlstab[P_RES] = _("RES"); Desc_nlstab[P_RES] = _("Resident Size (KiB)"); +/* Translation Hint: maximum 'CODE' = 4 */ + Head_nlstab[P_COD] = _("CODE"); Desc_nlstab[P_COD] = _("Code Size (KiB)"); +/* Translation Hint: maximum 'DATA' = 4 */ + Head_nlstab[P_DAT] = _("DATA"); Desc_nlstab[P_DAT] = _("Data+Stack (KiB)"); +/* Translation Hint: maximum 'SHR' = 4 */ + Head_nlstab[P_SHR] = _("SHR"); Desc_nlstab[P_SHR] = _("Shared Memory (KiB)"); +/* Translation Hint: maximum 'nMaj' = 4 */ + Head_nlstab[P_FL1] = _("nMaj"); Desc_nlstab[P_FL1] = _("Major Page Faults"); +/* Translation Hint: maximum 'nMin' = 4 */ + Head_nlstab[P_FL2] = _("nMin"); Desc_nlstab[P_FL2] = _("Minor Page Faults"); +/* Translation Hint: maximum 'nDRT' = 4 */ + Head_nlstab[P_DRT] = _("nDRT"); Desc_nlstab[P_DRT] = _("Dirty Pages Count"); +/* Translation Hint: maximum 'S' = 1 */ + Head_nlstab[P_STA] = _("S"); Desc_nlstab[P_STA] = _("Process Status"); +/* Translation Hint: maximum 'COMMAND' = 7 */ + Head_nlstab[P_CMD] = _("COMMAND"); Desc_nlstab[P_CMD] = _("Command Name/Line"); +/* Translation Hint: maximum 'WCHAN' = 7 */ + Head_nlstab[P_WCH] = _("WCHAN"); Desc_nlstab[P_WCH] = _("Sleeping in Function"); +/* Translation Hint: maximum 'Flags' = 8 */ + Head_nlstab[P_FLG] = _("Flags"); Desc_nlstab[P_FLG] = _("Task Flags "); +/* Translation Hint: maximum 'CGROUPS' = 7 */ + Head_nlstab[P_CGR] = _("CGROUPS"); Desc_nlstab[P_CGR] = _("Control Groups"); +/* Translation Hint: maximum 'SUPGIDS' = 7 */ + Head_nlstab[P_SGD] = _("SUPGIDS"); Desc_nlstab[P_SGD] = _("Supp Groups IDs"); +/* Translation Hint: maximum 'SUPGRPS' = 7 */ + Head_nlstab[P_SGN] = _("SUPGRPS"); Desc_nlstab[P_SGN] = _("Supp Groups Names"); +/* Translation Hint: maximum 'TGID' = 5 */ + Head_nlstab[P_TGD] = _("TGID"); Desc_nlstab[P_TGD] = _("Thread Group Id"); #ifdef OOMEM_ENABLE +/* Translation Hint: maximum 'Adj' = 3 */ + Head_nlstab[P_OOA] = _("Adj"); Desc_nlstab[P_OOA] = _("oom_adjustment (2^X)"); +/* Translation Hint: maximum 'Badness' = 8 */ + Head_nlstab[P_OOM] = _("Badness"); Desc_nlstab[P_OOM] = _("oom_score (badness)"); #endif -/* Translation Hint: The abbreviation 'vars' below is shorthand for +/* Translation Hint: maximum 'ENVIRON' = 7 */ + Head_nlstab[P_ENV] = _("ENVIRON"); +/* Translation Hint: the abbreviation 'vars' below is shorthand for 'variables' */ Desc_nlstab[P_ENV] = _("Environment vars"); +/* Translation Hint: maximum 'vMj' = 3 */ + Head_nlstab[P_FV1] = _("vMj"); Desc_nlstab[P_FV1] = _("Major Faults delta"); +/* Translation Hint: maximum 'vMn' = 3 */ + Head_nlstab[P_FV2] = _("vMn"); Desc_nlstab[P_FV2] = _("Minor Faults delta"); } @@ -472,13 +574,19 @@ void initialize_nls (void) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + memset(Head_nlstab, 0, sizeof(Head_nlstab)); memset(Desc_nlstab, 0, sizeof(Desc_nlstab)); - build_desc_nlstab(); - for (i = 0; i < P_MAXPFLGS; i++) + build_two_nlstabs(); + for (i = 0; i < P_MAXPFLGS; i++) { + if (!Head_nlstab[i]) { + fprintf(stderr, nls_err, "Head", i); + exit(1); + } if (!Desc_nlstab[i]) { fprintf(stderr, nls_err, "Desc", i); exit(1); } + } memset(Norm_nlstab, 0, sizeof(Norm_nlstab)); build_norm_nlstab(); for (i = 0; i < norm_MAX; i++) @@ -498,7 +606,7 @@ void initialize_nls (void) { bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - build_desc_nlstab(); + build_two_nlstabs(); build_norm_nlstab(); build_uniq_nlstab(); #endif diff --git a/top/top_nls.h b/top/top_nls.h index a3f03d20..22b6e651 100644 --- a/top/top_nls.h +++ b/top/top_nls.h @@ -20,7 +20,8 @@ #define _Itop_nls /* - * These are our three string tables with the following contents: + * These are our string tables with the following contents: + * Head : column headings with varying size limits * Desc : field descriptions not to exceed 20 screen positions * Norm : regular text possibly also containing c-format specifiers * Uniq : show_special specially formatted strings @@ -36,6 +37,7 @@ * + none of the important translator only comments will * clutter and obscure the main program */ +extern const char *Head_nlstab[]; extern const char *Desc_nlstab[]; extern const char *Norm_nlstab[]; extern const char *Uniq_nlstab[]; @@ -45,14 +47,16 @@ extern const char *Uniq_nlstab[]; * The N_txt and N_fmt macros are interchangeable but * highlight the two types of strings found in Norm_nlstable. */ +#define N_col(e) Head_nlstab[e] #define N_fld(e) Desc_nlstab[e] #define N_txt(e) Norm_nlstab[e] #define N_fmt(e) Norm_nlstab[e] #define N_unq(e) Uniq_nlstab[e] /* - * These enums are the means to access two of our three tables. - * The Desc_nlstab is accessed with standard top pflag enums. + * These enums are the means to access two of our four tables. + * The Head_nlstab and Desc_nlstab are accessed with standard + * top pflag enums. * * The norm_nls enums carry a suffix distinguishing plain text * from any text also containiing c-format specifiers.