Permalink
Browse files

Cleanup of autotools configuration.

  • Loading branch information...
1 parent b153790 commit 79c940a67cad16bdaf32e8accba668664c11c2e4 @mschuerig committed Jan 11, 2009
Showing with 89 additions and 62 deletions.
  1. +1 −1 Makefile.am
  2. +6 −0 autogen.sh
  3. +13 −4 configure.ac
  4. +1 −1 doc/Makefile.am
  5. +3 −3 po/de.po
  6. +5 −6 po/hangon.pot
  7. +60 −47 src/hangon.c
View
@@ -6,7 +6,7 @@ man_page = $(PACKAGE).1
man_MANS = $(man_page)
CLEANFILES = $(man_page)
-EXTRA_DIST = config.rpath m4/ChangeLog $(man_MANS)
+EXTRA_DIST = hangon.x m4/ChangeLog $(man_MANS)
# Create the man page from --help and --version output
View
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+set -e
+
+autoreconf --verbose --force --install
+gettextize --force
View
@@ -18,15 +18,19 @@ AC_ARG_ENABLE([debug],
if test "x$enable_debug" = "xyes"; then
# Add some heavy-weight pointer checking using mudflap
# See gcc(1) and <http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging>.
- CFLAGS="$CFLAGS -O0 -g -DDEBUG -fmudflap -lmudflap"
+ CPPFLAGS="$CPPFLAGS -DDEBUG"
+ CFLAGS="$CFLAGS -O0 -g -fmudflap"
+ LDFLAGS="$LDFLAGS -lmudflap"
else
- CFLAGS="$CFLAGS -DNDEBUG"
+ CPPFLAGS="$CPPFLAGS -DNDEBUG"
fi
# Use a libintl installed on the system.
AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.17])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_SRCDIR([src/hangon.c])
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in])
AC_CONFIG_TESTDIR([tests], [tests:src])
@@ -36,7 +40,12 @@ AC_CONFIG_FILES([tests/Makefile])
# but not required for simply building it.
# autom4te: used for merging tests into a suite
AM_MISSING_PROG([AUTOM4TE], [autom4te])
-# help2man: used for deriving man pages from --help and --version output
-AM_MISSING_PROG([HELP2MAN], [help2man])
+
+if test "x$cross_compiling" = "xno"; then
+ # help2man: used for deriving man pages from --help and --version output
+ AM_MISSING_PROG([HELP2MAN], [help2man])
+else
+ HELP2MAN=:
+fi
AC_OUTPUT
View
@@ -1,2 +1,2 @@
-tutorial_TEXINFOS = tutorial.texi
+info_TEXINFOS = tutorial.texi
View
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hangon 0.1\n"
"Report-Msgid-Bugs-To: michael@schuerig.de\n"
-"POT-Creation-Date: 2009-01-09 23:42+0100\n"
+"POT-Creation-Date: 2009-01-10 22:41+0100\n"
"PO-Revision-Date: 2009-01-09 23:47+0100\n"
"Last-Translator: Michael Schuerig <michael@schuerig.de>\n"
"Language-Team: German\n"
@@ -68,12 +68,12 @@ msgstr ""
"Dies ist freie Software: Sie können sie ändern und weitergeben.\n"
"Es gibt keinerlei Garantien, soweit wie es das Gesetz erlaubt.\n"
-#: src/hangon.c:210
+#: src/hangon.c:212
#, c-format
msgid "timeout must not be negative\n"
msgstr "die Timeout-Option darf nicht negativ sein\n"
-#: src/hangon.c:217
+#: src/hangon.c:219
#, c-format
msgid "retries must not be negative\n"
msgstr "die retries-Option darf nicht negativ sein\n"
View
@@ -1,5 +1,5 @@
# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR Free Software Foundation, Inc.
+# Copyright (C) YEAR Michael Schuerig
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hangon 0.1\n"
"Report-Msgid-Bugs-To: michael@schuerig.de\n"
-"POT-Creation-Date: 2009-01-09 23:42+0100\n"
+"POT-Creation-Date: 2009-01-10 22:41+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -52,18 +52,17 @@ msgstr ""
#: src/hangon.c:90
msgid ""
-"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl."
-"html>\n"
+"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
msgstr ""
-#: src/hangon.c:210
+#: src/hangon.c:212
#, c-format
msgid "timeout must not be negative\n"
msgstr ""
-#: src/hangon.c:217
+#: src/hangon.c:219
#, c-format
msgid "retries must not be negative\n"
msgstr ""
View
@@ -18,8 +18,13 @@
#define AUTHORS "Michael Schuerig"
#define COPYRIGHT_YEAR 2008
-#define _(msgid) gettext(msgid)
-#define N_(msgid) msgid
+#if ENABLE_NLS
+# define _(msgid) gettext(msgid)
+# define N_(msgid) msgid
+#else
+# define _(msgid) msgid
+# define N_(msgid) msgid
+#endif
#ifdef DEBUG
#define debug(format, ...) \
@@ -60,7 +65,7 @@ usage(int status)
fprintf(stdout, _("\
Usage: %s [OPTION]... -- COMMAND [COMMAND OPTION]...\n\
"),
- program_name);
+ program_name);
fputs(_("\
Restart an erratic COMMAND until it finishes cleanly.\n\
-q, --quiet suppress diagnostic messages\n\
@@ -92,7 +97,7 @@ License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n\
This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n\
"),
- stdout);
+ stdout);
}
static int
@@ -113,45 +118,51 @@ watch_command_stdout(pid_t pid, int fd)
switch (status) {
case -1:
if (errno == EINTR) {
- status = 0;
- continue;
+ status = 0;
+ continue;
}
break;
case 0: /* timeout */
debug("TIMEOUT\n");
status = COMMAND_TIMEOUT;
break;
default:
+ /* @beginexcerpt read_stdout */
status = 0;
if (FD_ISSET(fd, &rfds)) {
- ssize_t bytes_read = 0;
- debug("READ: ");
- bytes_read = read(fd, buffer, sizeof(buffer));
- debug("%.*s\n", bytes_read, buffer, sizeof(buffer[0]));
- if (bytes_read < 0) {
- if (errno == EINTR) {
- status = 0;
- continue;
- }
- status = -1;
- } else if (bytes_read == 0) {
- int command_status;
- if (waitpid(pid, &command_status, 0) != -1) {
- debug("COMMAND STATUS: %d\n", WEXITSTATUS(command_status));
- if (WIFEXITED(command_status) && WEXITSTATUS(command_status) != 0) {
- status = COMMAND_ERROR;
- }
- }
- if (status == 0) {
- status = COMMAND_DONE;
- }
- } else {
- debug("WRITE\n");
- if (write(STDOUT_FILENO, buffer, bytes_read) < 0) {
- status = -1;
- }
- }
+ /* @beginexcerpt read */
+ ssize_t bytes_read = 0;
+ debug("READ: ");
+ bytes_read = read(fd, buffer, sizeof(buffer));
+ debug("%.*s\n", bytes_read, buffer, sizeof(buffer[0]));
+ if (bytes_read < 0) {
+ if (errno == EINTR) { /* @callout EINTR read */
+ status = 0;
+ continue;
+ }
+ status = -1;
+ /* @endexcerpt read */
+ } else if (bytes_read == 0) {
+ /* @beginexcerpt wait_command */
+ int command_status;
+ if (waitpid(pid, &command_status, 0) != -1) { /* @callout waitpid */
+ debug("COMMAND STATUS: %d\n", WEXITSTATUS(command_status));
+ if (WIFEXITED(command_status) && WEXITSTATUS(command_status) != 0) {
+ status = COMMAND_ERROR;
+ }
+ }
+ /* @endexcerpt wait_command */
+ if (status == 0) {
+ status = COMMAND_DONE;
+ }
+ } else {
+ debug("WRITE\n");
+ if (write(STDOUT_FILENO, buffer, bytes_read) < 0) {
+ status = -1;
+ }
+ }
}
+ /* @endexcerpt read_stdout */
break;
}
}
@@ -198,24 +209,26 @@ main(int argc, char *argv[])
program_name = argv[0];
setlocale(LC_ALL, "");
+#if ENABLE_NLS
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+#endif
int optc;
while ((optc = getopt_long(argc, argv, "t:r:qdhv", long_options, NULL)) != -1) {
switch (optc) {
case 't':
timeout_secs = atoi(optarg);
if (timeout_secs < 0) {
- fprintf(stderr, _("timeout must not be negative\n"));
- exit(EXIT_FAILURE);
+ fprintf(stderr, _("timeout must not be negative\n"));
+ exit(EXIT_FAILURE);
}
break;
case 'r':
max_retries = atoi(optarg);
if (max_retries < 0) {
- fprintf(stderr, _("retries must not be negative\n"));
- exit(EXIT_FAILURE);
+ fprintf(stderr, _("retries must not be negative\n"));
+ exit(EXIT_FAILURE);
}
break;
case 'q':
@@ -241,7 +254,7 @@ main(int argc, char *argv[])
debug("OPTIONS: timeout %ds, %d retries\n", timeout_secs, max_retries);
- int hangon_status;
+ int hangon_status = 0;
int retries = 0;
if (optind < argc) {
@@ -252,13 +265,13 @@ main(int argc, char *argv[])
hangon_status = hangon();
debug("HANGON STATUS: %d\n", hangon_status);
if (hangon_status == COMMAND_TIMEOUT) {
- retries++;
- if (max_retries == 0 || retries < max_retries) {
- hangon_status = 0;
- if (!quiet) {
- fprintf(stderr, "Command timed out, retrying...\n");
- }
- }
+ retries++;
+ if (max_retries == 0 || retries < max_retries) {
+ hangon_status = 0;
+ if (!quiet) {
+ fprintf(stderr, "Command timed out, retrying...\n");
+ }
+ }
}
} while (hangon_status == 0);
@@ -273,9 +286,9 @@ main(int argc, char *argv[])
break;
case COMMAND_TIMEOUT:
if (max_retries != 0) {
- fprintf(stderr, "Command timed out too often.\n");
+ fprintf(stderr, "Command timed out too often.\n");
} else {
- fprintf(stderr, "Command timed out.\n");
+ fprintf(stderr, "Command timed out.\n");
}
break;
case COMMAND_ERROR:

0 comments on commit 79c940a

Please sign in to comment.