chiark / gitweb /
Build system overhaul.
[misc] / xtitle.c
index 94e9af63e4b0ab7b95963b8441455c444665e8ac..ea55663937e34294de5d0828d3f00b1336315f8b 100644 (file)
--- a/xtitle.c
+++ b/xtitle.c
@@ -6,34 +6,15 @@
 #include <string.h>
 #include <fcntl.h>
 
-#ifdef BASH_BUILTIN
-#include "bash/config.h"
-#include "bash/shell.h"
-#include "bash/builtins.h"
-#include "bash/builtins/common.h"
-#include "bash/builtins/bashgetopt.h"
-#endif
-
-#ifdef BASH_BUILTIN
-int xtitle_builtin(WORD_LIST *list)
-#else
 int main(int argc, char *argv[])
-#endif
 {
   int query = 0;
   int fd;
   int openned = 0;
+  int i;
 
-#ifdef BASH_BUILTIN
-  reset_internal_getopt();
-#endif
   for (;;) {
-#ifdef BASH_BUILTIN
-    int i;
-    i = internal_getopt(list, "q");
-#else
-    int i = getopt(argc, argv, "q");
-#endif
+    i = getopt(argc, argv, "q");
     if (i < 0)
       break;
     switch (i) {
@@ -41,20 +22,12 @@ int main(int argc, char *argv[])
        query = 1;
        break;
       default:
-#ifdef BASH_BUILTIN
-       builtin_usage();
-#else
-       fprintf(stderr, "usage: xtitle [-q] [string]\n");
-#endif
+       fprintf(stderr, "usage: xtitle [-q] [STRING]\n");
        return (1);
     }
   }
 
-#ifdef BASH_BUILTIN
-  if (!query && loptend == 0) {
-#else
   if (!query && optind == argc) {
-#endif
     fprintf(stderr, "xtitle: no string to set\n");
     return (1);
   }
@@ -77,19 +50,6 @@ int main(int argc, char *argv[])
   }
 
   if (!query) {
-#ifdef BASH_BUILTIN
-    WORD_LIST *l = loptend;
-    char sp = ' ';
-    write(fd, "\33]0;", 4);
-    while (l) {
-      write(fd, l->word->word, strlen(l->word->word));
-      if (l->next)
-       write(fd, &sp, 1);
-      l = l->next;
-    }
-    write(fd, "\7", 2);
-#else
-    int i;
     char sp = ' ';
     write(fd, "\33]0;", 4);
     for (i = optind; i < argc; i++) {
@@ -98,7 +58,6 @@ int main(int argc, char *argv[])
        write(fd, &sp, 1);
     }
     write(fd, "\7", 2);
-#endif
   } else {
     struct termios o, n;
     char hack;
@@ -145,25 +104,3 @@ int main(int argc, char *argv[])
 
   return (0);
 }
-
-
-#ifdef BASH_BUILTIN
-
-static char *xtitle_doc[] = {
-  "Either set or read the title of the current xterm window.  With the",
-  "-q option, writes the current xterm title to standard output.  Without",
-  "the -q option, sets the xterm title to be the arguments given,",
-  "separated by space characters.  [By Mark Wooding, mdw@nsict.org]",
-  0
-};
-
-struct builtin xtitle_struct = {
-  "xtitle",
-  xtitle_builtin,
-  BUILTIN_ENABLED,
-  xtitle_doc,
-  "xtitle [-q] [arguments]",
-  0
-};
-
-#endif