Merge bk://oe-devel.bkbits.net/openembedded
authornslu2-linux.adm@bkbits.net <nslu2-linux.adm@bkbits.net>
Tue, 28 Dec 2004 00:40:06 +0000 (00:40 +0000)
committernslu2-linux.adm@bkbits.net <nslu2-linux.adm@bkbits.net>
Tue, 28 Dec 2004 00:40:06 +0000 (00:40 +0000)
into bkbits.net:/repos/n/nslu2-linux/openembedded

2004/12/28 00:56:43+01:00 handhelds.org!zecke
BusyBox getkey:
-More Cish and goto an error handler instead of directly returning a value

2004/12/28 00:40:54+01:00 handhelds.org!zecke
Merge bk://oe-devel@oe-devel.bkbits.net/openembedded
into handhelds.org:/home/ich/programming/oe/openembedded

2004/12/28 00:40:37+01:00 handhelds.org!zecke
BusyBox getkey applet patch:
-Make it more robust and check if STDIN_FILENO is a terminal
-Place braces on a new line (hopefully the right way of making it consistent)

BKrev: 41d0ab66AxH6f5YekH41lUKHGimJBw

packages/busybox/busybox-1.00/add-getkey-applet.patch

index 54b5893..6ce0df2 100644 (file)
@@ -5,7 +5,7 @@
 
 --- /dev/null
 +++ busybox-1.00/console-tools/getkey.c
-@@ -0,0 +1,75 @@
+@@ -0,0 +1,94 @@
 +/* vi: set sw=4 ts=4: */
 +/*
 + * getkey.c - Michael 'Mickey' Lauer
 +{
 +    int status = EXIT_FAILURE;
 +
-+    if ( argc < 2 ) {
-+        bb_show_usage();
++    if ( argc < 2 )
++    {
++      bb_show_usage();
++    }
++
++    /*
++     * If no terminal is attached it is quite useless
++     * to treat it like one.
++     */
++    if( !isatty(STDIN_FILENO) )
++    {
++      goto error_hard;
 +    }
 +
 +    //bb_printf( "DEBUG: time = '%s'\n", argv[1] );
 +    struct termios attr;
 +
 +    if ( tcgetattr(STDIN_FILENO, &orig) == -1 )
-+      return EXIT_FAILURE;
-+      
++    {
++      goto error_hard;
++    }
++
 +    attr = orig;
 +    attr.c_cc[VMIN] = 0;
 +    attr.c_cc[VTIME] = 0;
@@ -51,7 +63,9 @@
 +    attr.c_cflag &= ~PARENB;
 +    attr.c_lflag &= ~(ICANON/*|ECHO*/);
 +    if ( tcsetattr(STDIN_FILENO,TCSANOW,&attr) == -1 )
-+      return EXIT_FAILURE;
++    {
++      goto error_hard;
++    }
 +
 +    fd_set rfds;
 +    struct timeval tv;
 +
 +    if ( argc == 3 )
 +    {
-+        bb_printf( argv[2], tv.tv_sec );
-+        bb_printf( "\n" );
-+        fflush(stdout);
++      bb_printf( argv[2], tv.tv_sec );
++      bb_printf( "\n" );
++      fflush(stdout);
 +    }
 +    retval = select(1, &rfds, NULL, NULL, &tv);
 +    if (retval > 0)
 +    {
-+        status = EXIT_SUCCESS;
++      status = EXIT_SUCCESS;
 +    }
 +
 +    if (tcsetattr(STDIN_FILENO,TCSANOW,&orig) == -1 )
-+      return EXIT_FAILURE;
-+      
++    {
++      goto error_hard;
++    }
++
 +    return status;
++
++error_hard   :
++    return EXIT_FAILURE;
 +};
 +
 --- busybox-1.00/console-tools/Makefile.in~add-getkey-applet.patch