/* Read context, if supposed to. */
if (read_context) {
+ int allow_version_check = 1;
+ int check_older_version = 0;
+ char *cp;
+
context_read();
- /* Check to see if the user is running a different version of nmh
- than they had last run, and notify them if so. But only if
- they seem to be running an interactive program. */
- if (isatty (fileno (stdin)) && isatty (fileno (stdout)) &&
- strcmp (invo_name, "ap") &&
- strcmp (invo_name, "dp") &&
- strcmp (invo_name, "fmtdump") &&
- strcmp (invo_name, "install-mh") &&
- strcmp (invo_name, "mhbuild") &&
- strcmp (invo_name, "mhfixmsg") &&
- strcmp (invo_name, "mhl") &&
- strcmp (invo_name, "mhparam") &&
- strcmp (invo_name, "mhpath") &&
- strcmp (invo_name, "mkstemp") &&
- strcmp (invo_name, "post") &&
- strcmp (invo_name, "prompter") &&
- strncmp (invo_name, "rcv", 3) &&
- strcmp (invo_name, "slocal") &&
- strcmp (invo_name, "viamail") &&
- strcmp (invo_name, "whatnow") &&
- strcmp (invo_name, "whom")) {
-
- if (nmh_version_changed ()) {
- fprintf (stderr, "==========================================="
- "============================\n");
- fprintf (stderr, "Welcome to nmh version %s\n\n", VERSION);
- fprintf (stderr, "See the release notes in %s/NEWS .\n\n",
+ if (read_context != 1 ||
+ ((cp = context_find ("Welcome")) && strcasecmp (cp, "disable") == 0)) {
+ allow_version_check = 0;
+ } else if ((cp = getenv ("MHCONTEXT")) != NULL && *cp != '\0') {
+ /* Context file comes from $MHCONTEXT, so only print the message
+ if the context file has an older version. If it does, or if it
+ doesn't have a version at all, update the version. */
+ check_older_version = 1;
+ }
+
+ /* Check to see if the user is running a different (or older, if
+ specified) version of nmh than they had run bfore, and notify them
+ if so. But only if read_context was set to a value to enable. */
+ if (allow_version_check && isatty (fileno (stdin)) &&
+ isatty (fileno (stdout)) && isatty (fileno (stderr))) {
+ if (nmh_version_changed (check_older_version)) {
+ printf ("==================================================="
+ "=====================\n");
+ printf ("Welcome to nmh version %s\n\n", VERSION);
+ printf ("See the release notes in %s/NEWS\n\n",
mhdocdir);
- print_intro (stderr, 1);
- fprintf (stderr, "\nThis message will not be repeated until "
+ print_intro (stdout, 1);
+ printf ("\nThis message will not be repeated until "
"nmh is next updated.\n");
- fprintf (stderr, "==========================================="
- "============================\n\n\n");
+ printf ("==================================================="
+ "=====================\n\n");
+
+ fputs ("Press enter to continue: ", stdout);
+ (void) read_line ();
+ putchar ('\n');
}
}
/*
- * Check stored version, and if out-of-date or non-existent, notify the user
- * and update.
+ * Check stored version, and return 1 if out-of-date or non-existent.
+ * Because the output of "mhparam version" is prefixed with "nmh-",
+ * use that prefix here.
*/
int
-nmh_version_changed () {
- const char *const old_version = context_find("Version");
-
- /* mhparam version includes the nmh- prefix, so be consistent with that. */
- if (old_version == NULL || strcmp(old_version, "nmh-" VERSION) != 0) {
- context_replace ("Version", "nmh-" VERSION);
+nmh_version_changed (int older) {
+ const char *const context_version = context_find("Version");
+
+ if (older) {
+ /* Convert the version strings to floats and compare them. This will
+ break for versions with multiple decimal points, etc. */
+ const float current_version = strtof (VERSION, NULL);
+ const float old_version =
+ context_version && strncmp (context_version, "nmh-", 4) == 0
+ ? strtof (context_version + 4, NULL)
+ : 99999999;
+
+ if (context_version == NULL || old_version < current_version) {
+ context_replace ("Version", "nmh-" VERSION);
+ }
- return 1;
+ return old_version < current_version ? 1 : 0;
} else {
- return 0;
+ if (context_version == NULL || strcmp(context_version, "nmh-" VERSION) != 0) {
+ context_replace ("Version", "nmh-" VERSION);
+
+ return 1;
+ } else {
+ return 0;
+ }
}
}
return 0;
}
+
+
+/*
+ * See if input has any 8-bit bytes.
+ */
+int
+scan_input (int fd, int *eightbit) {
+ int state;
+ char buf[BUFSIZ];
+
+ *eightbit = 0;
+ lseek (fd, (off_t) 0, SEEK_SET);
+
+ while ((state = read (fd, buf, sizeof buf)) > 0) {
+ if (contains8bit (buf, buf + state)) {
+ *eightbit = 1;
+ return OK;
+ }
+ }
+
+ return state == NOTOK ? NOTOK : OK;
+}