Applied vodz' patches #49 and #50 (with a small correction in runshell.c)

#49: I found one memory overflow and memory leak in "ln" applet.
Last patch reduced also 54 bytes. ;)

#50: I found bug in loginutils/Makefile.in.
New patch have also new function to libbb and
aplied this to applets and other cosmetic changes.
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 95ecba6..2390f30 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -96,9 +96,7 @@
                 free(BUFFER);
 
         if (!quote) { /* Just copy arg */
-                BUFFER=xmalloc(strlen(arg)+1);
-
-                strcpy(BUFFER,arg);
+               BUFFER=xstrdup(arg);
                 return BUFFER;
         }
 
@@ -204,7 +202,6 @@
 /* Register a long option. The contents of name is copied. */
 void add_longopt(const char *name,int has_arg)
 {
-        char *tmp;
         if (!name) { /* init */
                 free(long_options);
                 long_options=NULL;
@@ -228,9 +225,7 @@
                 long_options[long_options_nr-1].has_arg=has_arg;
                 long_options[long_options_nr-1].flag=NULL;
                 long_options[long_options_nr-1].val=LONG_OPT;
-                tmp = xmalloc(strlen(name)+1);
-                strcpy(tmp,name);
-                long_options[long_options_nr-1].name=tmp;
+               long_options[long_options_nr-1].name=xstrdup(name);
         }
         long_options_nr++;
 }
@@ -326,7 +321,7 @@
                         /* For some reason, the original getopt gave no error
                            when there were no arguments. */
                         printf(" --\n");
-                        exit(0);
+                       return 0;
                 } else
                         error_msg_and_die("missing optstring argument");
         }
@@ -336,7 +331,7 @@
                 optstr=xmalloc(strlen(argv[1])+1);
                 strcpy(optstr,argv[1]+strspn(argv[1],"-+"));
                 argv[1]=argv[0];
-                exit(generate_output(argv+1,argc-1,optstr,long_options));
+               return (generate_output(argv+1,argc-1,optstr,long_options));
         }
 
         while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF)
@@ -347,8 +342,7 @@
                 case 'o':
                         if (optstr)
                                 free(optstr);
-                        optstr=xmalloc(strlen(optarg)+1);
-                        strcpy(optstr,optarg);
+                       optstr=xstrdup(optarg);
                         break;
                 case 'l':
                         add_long_options(optarg);
@@ -356,8 +350,7 @@
                 case 'n':
                         if (name)
                                 free(name);
-                        name=xmalloc(strlen(optarg)+1);
-                        strcpy(name,optarg);
+                       name=xstrdup(optarg);
                         break;
                 case 'q':
                         quiet_errors=1;
@@ -369,7 +362,7 @@
                         set_shell(optarg);
                         break;
                 case 'T':
-                        exit(4);
+                       return 4;
                 case 'u':
                         quote=0;
                         break;
@@ -381,8 +374,7 @@
                 if (optind >= argc)
                         error_msg_and_die("missing optstring argument");
                 else {
-                        optstr=xmalloc(strlen(argv[optind])+1);
-                        strcpy(optstr,argv[optind]);
+                       optstr=xstrdup(argv[optind]);
                         optind++;
                 }
         }
@@ -390,7 +382,7 @@
                 argv[optind-1]=name;
         else
                 argv[optind-1]=argv[0];
-        exit(generate_output(argv+optind-1,argc-optind+1,optstr,long_options));
+       return (generate_output(argv+optind-1,argc-optind+1,optstr,long_options));
 }
 
 /*