From 6cc925329f22bb3b7a4beefadb2e7e73450a594b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rainer=20M=C3=BCller?= <raimue@codingfarm.de>
Date: Wed, 20 Feb 2013 18:31:48 +0100
Subject: [PATCH 1/4] configure: check for program_invocation_name
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.
The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
---
configure.ac | 8 ++++++++
free.c | 4 +++-
pgrep.c | 2 ++
pmap.c | 4 +++-
pwdx.c | 4 +++-
skill.c | 4 +++-
slabtop.c | 2 ++
sysctl.c | 2 ++
tload.c | 2 ++
uptime.c | 2 ++
vmstat.c | 2 ++
w.c | 2 ++
watch.c | 2 ++
13 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 711be2a..afb24ce 100644
a
|
b
|
dnl else |
137 | 137 | dnl ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu" |
138 | 138 | dnl fi |
139 | 139 | |
| 140 | AC_MSG_CHECKING(whether program_invocation_name is defined) |
| 141 | AC_TRY_COMPILE([#include <errno.h>], |
| 142 | [program_invocation_name = "test";], |
| 143 | AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME, 1, |
| 144 | [Define if program_invocation_name is defined]) |
| 145 | AC_MSG_RESULT(yes), |
| 146 | AC_MSG_RESULT(no)) |
| 147 | |
140 | 148 | AC_MSG_CHECKING(whether program_invocation_short_name is defined) |
141 | 149 | AC_TRY_COMPILE([#include <errno.h>], |
142 | 150 | [program_invocation_short_name = "test";], |
diff --git a/free.c b/free.c
index ecaeccd..ffc4b86 100644
a
|
b
|
int main(int argc, char **argv) |
223 | 223 | args.repeat_interval = 1000000; |
224 | 224 | args.repeat_counter = 0; |
225 | 225 | |
226 | | program_invocation_name = program_invocation_short_name; |
| 226 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
| 227 | program_invocation_name = program_invocation_short_name; |
| 228 | #endif |
227 | 229 | setlocale (LC_ALL, ""); |
228 | 230 | bindtextdomain(PACKAGE, LOCALEDIR); |
229 | 231 | textdomain(PACKAGE); |
diff --git a/pgrep.c b/pgrep.c
index f08d89f..e849f9e 100644
a
|
b
|
int main (int argc, char **argv) |
788 | 788 | struct el *procs; |
789 | 789 | int num; |
790 | 790 | |
| 791 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
791 | 792 | program_invocation_name = program_invocation_short_name; |
| 793 | #endif |
792 | 794 | setlocale (LC_ALL, ""); |
793 | 795 | bindtextdomain(PACKAGE, LOCALEDIR); |
794 | 796 | textdomain(PACKAGE); |
diff --git a/pmap.c b/pmap.c
index 79c17b2..fd0363b 100644
a
|
b
|
int main(int argc, char **argv) |
657 | 657 | {NULL, 0, NULL, 0} |
658 | 658 | }; |
659 | 659 | |
660 | | program_invocation_name = program_invocation_short_name; |
| 660 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
| 661 | program_invocation_name = program_invocation_short_name; |
| 662 | #endif |
661 | 663 | setlocale (LC_ALL, ""); |
662 | 664 | bindtextdomain(PACKAGE, LOCALEDIR); |
663 | 665 | textdomain(PACKAGE); |
diff --git a/pwdx.c b/pwdx.c
index 4aee389..214275a 100644
a
|
b
|
int main(int argc, char *argv[]) |
74 | 74 | {NULL, 0, 0, 0} |
75 | 75 | }; |
76 | 76 | |
77 | | program_invocation_name = program_invocation_short_name; |
| 77 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
| 78 | program_invocation_name = program_invocation_short_name; |
| 79 | #endif |
78 | 80 | setlocale (LC_ALL, ""); |
79 | 81 | bindtextdomain(PACKAGE, LOCALEDIR); |
80 | 82 | textdomain(PACKAGE); |
diff --git a/skill.c b/skill.c
index 03df229..fb57305 100644
a
|
b
|
static void skillsnice_parse(int argc, |
629 | 629 | /* main body */ |
630 | 630 | int main(int argc, char ** argv) |
631 | 631 | { |
632 | | program_invocation_name = program_invocation_short_name; |
| 632 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
| 633 | program_invocation_name = program_invocation_short_name; |
| 634 | #endif |
633 | 635 | struct run_time_conf_t run_time; |
634 | 636 | memset(&run_time, 0, sizeof(struct run_time_conf_t)); |
635 | 637 | my_pid = getpid(); |
diff --git a/slabtop.c b/slabtop.c
index 9e535d4..ebdae8d 100644
a
|
b
|
int main(int argc, char *argv[]) |
300 | 300 | { NULL, 0, NULL, 0 } |
301 | 301 | }; |
302 | 302 | |
| 303 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
303 | 304 | program_invocation_name = program_invocation_short_name; |
| 305 | #endif |
304 | 306 | setlocale (LC_ALL, ""); |
305 | 307 | bindtextdomain(PACKAGE, LOCALEDIR); |
306 | 308 | textdomain(PACKAGE); |
diff --git a/sysctl.c b/sysctl.c
index 0756878..2eeacd9 100644
a
|
b
|
int main(int argc, char *argv[]) |
675 | 675 | {NULL, 0, NULL, 0} |
676 | 676 | }; |
677 | 677 | |
| 678 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
678 | 679 | program_invocation_name = program_invocation_short_name; |
| 680 | #endif |
679 | 681 | setlocale(LC_ALL, ""); |
680 | 682 | bindtextdomain(PACKAGE, LOCALEDIR); |
681 | 683 | textdomain(PACKAGE); |
diff --git a/tload.c b/tload.c
index 765ed17..a5fe14a 100644
a
|
b
|
int main(int argc, char **argv) |
114 | 114 | {NULL, 0, NULL, 0} |
115 | 115 | }; |
116 | 116 | |
| 117 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
117 | 118 | program_invocation_name = program_invocation_short_name; |
| 119 | #endif |
118 | 120 | setlocale (LC_ALL, ""); |
119 | 121 | bindtextdomain(PACKAGE, LOCALEDIR); |
120 | 122 | textdomain(PACKAGE); |
diff --git a/uptime.c b/uptime.c
index ac4579c..2742189 100644
a
|
b
|
int main(int argc, char **argv) |
77 | 77 | {NULL, 0, NULL, 0} |
78 | 78 | }; |
79 | 79 | |
| 80 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
80 | 81 | program_invocation_name = program_invocation_short_name; |
| 82 | #endif |
81 | 83 | setlocale (LC_ALL, ""); |
82 | 84 | bindtextdomain(PACKAGE, LOCALEDIR); |
83 | 85 | textdomain(PACKAGE); |
diff --git a/vmstat.c b/vmstat.c
index a2627b8..6f95f09 100644
a
|
b
|
int main(int argc, char *argv[]) |
724 | 724 | {NULL, 0, NULL, 0} |
725 | 725 | }; |
726 | 726 | |
| 727 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
727 | 728 | program_invocation_name = program_invocation_short_name; |
| 729 | #endif |
728 | 730 | setlocale (LC_ALL, ""); |
729 | 731 | bindtextdomain(PACKAGE, LOCALEDIR); |
730 | 732 | textdomain(PACKAGE); |
diff --git a/w.c b/w.c
index 6352d69..5db1064 100644
a
|
b
|
int main(int argc, char **argv) |
483 | 483 | {NULL, 0, NULL, 0} |
484 | 484 | }; |
485 | 485 | |
| 486 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
486 | 487 | program_invocation_name = program_invocation_short_name; |
| 488 | #endif |
487 | 489 | setlocale (LC_ALL, ""); |
488 | 490 | bindtextdomain(PACKAGE, LOCALEDIR); |
489 | 491 | textdomain(PACKAGE); |
diff --git a/watch.c b/watch.c
index 0fe0a8f..5a22952 100644
a
|
b
|
int main(int argc, char *argv[]) |
590 | 590 | {0, 0, 0, 0} |
591 | 591 | }; |
592 | 592 | |
| 593 | #ifdef HAVE_PROGRAM_INVOCATION_NAME |
593 | 594 | program_invocation_name = program_invocation_short_name; |
| 595 | #endif |
594 | 596 | setlocale(LC_ALL, ""); |
595 | 597 | bindtextdomain(PACKAGE, LOCALEDIR); |
596 | 598 | textdomain(PACKAGE); |