Use an int to hold the result of fgetc (bug noted by David Kimdon).
[oweals/busybox.git] / coreutils / basename.c
index e98197dd420241c3c356b4a47efaac4e1937e102..bdbcec17abd0e09a0f5dbee09a3aad812d9d35df 100644 (file)
@@ -2,8 +2,8 @@
 /*
  * Mini basename implementation for busybox
  *
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,9 +44,9 @@ extern int basename_main(int argc, char **argv)
                argv++;
                n = strlen(*argv);
                m = strlen(s);
-               if (m>=n && strncmp(s+m-n, *argv, n)==0)
+               if (m>n && strncmp(s+m-n, *argv, n)==0)
                        s[m-n] = '\0';
        }
-       printf("%s\n", s);
+       puts(s);
        return EXIT_SUCCESS;
 }