+ return 1;
+}
+
+static char *
+resolve_editor(editor, argc_out, argv_out)
+ char *editor;
+ int *argc_out;
+ char ***argv_out;
+{
+ char *cp, **nargv, *editor_path = NULL;
+ int ac, nargc, wasblank;
+
+ editor = estrdup(editor); /* becomes part of argv_out */
+
+ /*
+ * Split editor into an argument vector; editor is reused (do not free).
+ * The EDITOR and VISUAL environment variables may contain command
+ * line args so look for those and alloc space for them too.
+ */
+ nargc = 1;
+ for (wasblank = FALSE, cp = editor; *cp != '\0'; cp++) {
+ if (isblank((unsigned char) *cp))
+ wasblank = TRUE;
+ else if (wasblank) {
+ wasblank = FALSE;
+ nargc++;
+ }
+ }
+ /* If we can't find the editor in the user's PATH, give up. */
+ cp = strtok(editor, " \t");
+ if (cp == NULL ||
+ find_path(cp, &editor_path, NULL, getenv("PATH"), 0) != FOUND) {
+ efree(editor);
+ return NULL;
+ }
+ nargv = (char **) emalloc2(nargc + 1, sizeof(char *));
+ for (ac = 0; cp != NULL && ac < nargc; ac++) {
+ nargv[ac] = cp;
+ cp = strtok(NULL, " \t");
+ }
+ nargv[ac] = NULL;
+
+ *argc_out = nargc;
+ *argv_out = nargv;
+ return editor_path;