Magellan Linux

Diff of /tags/mkinitrd-6_3_1/busybox/coreutils/basename.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC revision 1123 by niro, Wed Aug 18 21:56:57 2010 UTC
# Line 5  Line 5 
5   * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>   * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6   *   *
7   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  *  
8   */   */
9    
 /* BB_AUDIT SUSv3 compliant */  
 /* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */  
   
   
10  /* Mar 16, 2003      Manuel Novoa III   (mjn3@codepoet.org)  /* Mar 16, 2003      Manuel Novoa III   (mjn3@codepoet.org)
11   *   *
12   * Changes:   * Changes:
# Line 20  Line 15 
15   * 3) Save some space by using strcmp().  Calling strncmp() here was silly.   * 3) Save some space by using strcmp().  Calling strncmp() here was silly.
16   */   */
17    
18    /* BB_AUDIT SUSv3 compliant */
19    /* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
20    
21    //kbuild:lib-$(CONFIG_BASENAME) += basename.o
22    
23    //config:config BASENAME
24    //config: bool "basename"
25    //config: default y
26    //config: help
27    //config:  basename is used to strip the directory and suffix from filenames,
28    //config:  leaving just the filename itself. Enable this option if you wish
29    //config:  to enable the 'basename' utility.
30    
31  #include "libbb.h"  #include "libbb.h"
32    
33  /* This is a NOFORK applet. Be very careful! */  /* This is a NOFORK applet. Be very careful! */
# Line 30  int basename_main(int argc, char **argv) Line 38  int basename_main(int argc, char **argv)
38   size_t m, n;   size_t m, n;
39   char *s;   char *s;
40    
41   if (((unsigned int)(argc-2)) >= 2) {   if ((unsigned)(argc-2) >= 2) {
42   bb_show_usage();   bb_show_usage();
43   }   }
44    
# Line 40  int basename_main(int argc, char **argv) Line 48  int basename_main(int argc, char **argv)
48   m = strlen(s);   m = strlen(s);
49   if (*++argv) {   if (*++argv) {
50   n = strlen(*argv);   n = strlen(*argv);
51   if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {   if ((m > n) && (strcmp(s+m-n, *argv) == 0)) {
52   m -= n;   m -= n;
53   /*s[m] = '\0'; - redundant */   /*s[m] = '\0'; - redundant */
54   }   }

Legend:
Removed from v.816  
changed lines
  Added in v.1123