Ticket #38137: 0001-configure-check-for-program_invocation_name.patch

File 0001-configure-check-for-program_invocation_name.patch, 6.3 KB (added by raimue (Rainer Müller), 12 years ago)
  • configure.ac

    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 
    137137dnl     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"
    138138dnl fi
    139139
     140AC_MSG_CHECKING(whether program_invocation_name is defined)
     141AC_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
    140148AC_MSG_CHECKING(whether program_invocation_short_name is defined)
    141149AC_TRY_COMPILE([#include <errno.h>],
    142150                [program_invocation_short_name = "test";],
  • free.c

    diff --git a/free.c b/free.c
    index ecaeccd..ffc4b86 100644
    a b int main(int argc, char **argv) 
    223223        args.repeat_interval = 1000000;
    224224        args.repeat_counter = 0;
    225225
    226     program_invocation_name = program_invocation_short_name;
     226#ifdef HAVE_PROGRAM_INVOCATION_NAME
     227        program_invocation_name = program_invocation_short_name;
     228#endif
    227229        setlocale (LC_ALL, "");
    228230        bindtextdomain(PACKAGE, LOCALEDIR);
    229231        textdomain(PACKAGE);
  • pgrep.c

    diff --git a/pgrep.c b/pgrep.c
    index f08d89f..e849f9e 100644
    a b int main (int argc, char **argv) 
    788788        struct el *procs;
    789789        int num;
    790790
     791#ifdef HAVE_PROGRAM_INVOCATION_NAME
    791792        program_invocation_name = program_invocation_short_name;
     793#endif
    792794        setlocale (LC_ALL, "");
    793795        bindtextdomain(PACKAGE, LOCALEDIR);
    794796        textdomain(PACKAGE);
  • pmap.c

    diff --git a/pmap.c b/pmap.c
    index 79c17b2..fd0363b 100644
    a b int main(int argc, char **argv) 
    657657                {NULL, 0, NULL, 0}
    658658        };
    659659
    660     program_invocation_name = program_invocation_short_name;
     660#ifdef HAVE_PROGRAM_INVOCATION_NAME
     661        program_invocation_name = program_invocation_short_name;
     662#endif
    661663        setlocale (LC_ALL, "");
    662664        bindtextdomain(PACKAGE, LOCALEDIR);
    663665        textdomain(PACKAGE);
  • pwdx.c

    diff --git a/pwdx.c b/pwdx.c
    index 4aee389..214275a 100644
    a b int main(int argc, char *argv[]) 
    7474                {NULL, 0, 0, 0}
    7575        };
    7676
    77     program_invocation_name = program_invocation_short_name;
     77#ifdef HAVE_PROGRAM_INVOCATION_NAME
     78        program_invocation_name = program_invocation_short_name;
     79#endif
    7880        setlocale (LC_ALL, "");
    7981        bindtextdomain(PACKAGE, LOCALEDIR);
    8082        textdomain(PACKAGE);
  • skill.c

    diff --git a/skill.c b/skill.c
    index 03df229..fb57305 100644
    a b static void skillsnice_parse(int argc, 
    629629/* main body */
    630630int main(int argc, char ** argv)
    631631{
    632     program_invocation_name = program_invocation_short_name;
     632#ifdef HAVE_PROGRAM_INVOCATION_NAME
     633        program_invocation_name = program_invocation_short_name;
     634#endif
    633635        struct run_time_conf_t run_time;
    634636        memset(&run_time, 0, sizeof(struct run_time_conf_t));
    635637        my_pid = getpid();
  • slabtop.c

    diff --git a/slabtop.c b/slabtop.c
    index 9e535d4..ebdae8d 100644
    a b int main(int argc, char *argv[]) 
    300300                {  NULL, 0, NULL, 0 }
    301301        };
    302302
     303#ifdef HAVE_PROGRAM_INVOCATION_NAME
    303304        program_invocation_name = program_invocation_short_name;
     305#endif
    304306        setlocale (LC_ALL, "");
    305307        bindtextdomain(PACKAGE, LOCALEDIR);
    306308        textdomain(PACKAGE);
  • sysctl.c

    diff --git a/sysctl.c b/sysctl.c
    index 0756878..2eeacd9 100644
    a b int main(int argc, char *argv[]) 
    675675                {NULL, 0, NULL, 0}
    676676        };
    677677
     678#ifdef HAVE_PROGRAM_INVOCATION_NAME
    678679        program_invocation_name = program_invocation_short_name;
     680#endif
    679681        setlocale(LC_ALL, "");
    680682        bindtextdomain(PACKAGE, LOCALEDIR);
    681683        textdomain(PACKAGE);
  • tload.c

    diff --git a/tload.c b/tload.c
    index 765ed17..a5fe14a 100644
    a b int main(int argc, char **argv) 
    114114                {NULL, 0, NULL, 0}
    115115        };
    116116 
     117#ifdef HAVE_PROGRAM_INVOCATION_NAME
    117118        program_invocation_name = program_invocation_short_name;
     119#endif
    118120        setlocale (LC_ALL, "");
    119121        bindtextdomain(PACKAGE, LOCALEDIR);
    120122        textdomain(PACKAGE);
  • uptime.c

    diff --git a/uptime.c b/uptime.c
    index ac4579c..2742189 100644
    a b int main(int argc, char **argv) 
    7777                {NULL, 0, NULL, 0}
    7878        };
    7979
     80#ifdef HAVE_PROGRAM_INVOCATION_NAME
    8081        program_invocation_name = program_invocation_short_name;
     82#endif
    8183        setlocale (LC_ALL, "");
    8284        bindtextdomain(PACKAGE, LOCALEDIR);
    8385        textdomain(PACKAGE);
  • vmstat.c

    diff --git a/vmstat.c b/vmstat.c
    index a2627b8..6f95f09 100644
    a b int main(int argc, char *argv[]) 
    724724                {NULL, 0, NULL, 0}
    725725        };
    726726
     727#ifdef HAVE_PROGRAM_INVOCATION_NAME
    727728        program_invocation_name = program_invocation_short_name;
     729#endif
    728730        setlocale (LC_ALL, "");
    729731        bindtextdomain(PACKAGE, LOCALEDIR);
    730732        textdomain(PACKAGE);
  • w.c

    diff --git a/w.c b/w.c
    index 6352d69..5db1064 100644
    a b int main(int argc, char **argv) 
    483483                {NULL, 0, NULL, 0}
    484484        };
    485485
     486#ifdef HAVE_PROGRAM_INVOCATION_NAME
    486487        program_invocation_name = program_invocation_short_name;
     488#endif
    487489        setlocale (LC_ALL, "");
    488490        bindtextdomain(PACKAGE, LOCALEDIR);
    489491        textdomain(PACKAGE);
  • watch.c

    diff --git a/watch.c b/watch.c
    index 0fe0a8f..5a22952 100644
    a b int main(int argc, char *argv[]) 
    590590                {0, 0, 0, 0}
    591591        };
    592592
     593#ifdef HAVE_PROGRAM_INVOCATION_NAME
    593594        program_invocation_name = program_invocation_short_name;
     595#endif
    594596        setlocale(LC_ALL, "");
    595597        bindtextdomain(PACKAGE, LOCALEDIR);
    596598        textdomain(PACKAGE);