From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:08:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7E0EA2FC for ; Tue, 9 Jul 2013 07:08:54 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 62A271C44 for ; Tue, 9 Jul 2013 07:08:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6978sMW091691 for ; Tue, 9 Jul 2013 07:08:54 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6978sgl091684 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:08:54 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:08:54 GMT Message-Id: <201307090708.r6978sgl091684@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254449 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:08:54 -0000 Author: dpl Date: Tue Jul 9 07:08:54 2013 New Revision: 254449 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254449 Log: Final touches with bzip2. It now works on any directory. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 9 06:51:41 2013 (r254448) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 9 07:08:54 2013 (r254449) @@ -92,6 +92,7 @@ # include # if __FreeBSD_version >= 900041 # define CAPSICUM +# include # include # include # include @@ -225,11 +226,9 @@ #define IN_FILENO fileno(inStr) #define OUT_FILENO fileno(outStr) void limitfd(int); -const Char * getdir(Char* file); -const Char * getfilename(Char* file); FILE *inStr; FILE *outStr; -int cwd; /* Where is the file (fd) */ +int cwd; /* Dir where is the file */ #endif static void panic ( const Char* ) NORETURN; @@ -687,46 +686,6 @@ exit(exitValue); } } - - -/*---------------------------------------------*/ -const Char * -getdir(Char *file) -{ - Char * slashPos; - Char * ret; - - slashPos = strrchr(file, (int)'/'); - if ( slashPos == 0 ) - return( "." ); - if ( (ret = strndup( file, (slashPos - file + 1)) ) == NULL){ - setExit(1); - exit(exitValue); - } - return(ret); - -} - - -/*---------------------------------------------*/ -const Char * -getfilename(Char *file) -{ - Char * slashPos; - Char * ret; - int slashIndex; - - slashPos = strrchr(file, (int)'/'); - if ( slashPos == 0 ) - return( file ); - slashIndex = slashPos - file; - if ( (ret = strndup( slashPos + 1, (strlen(file) - slashIndex) )) == NULL){ - setExit(1); - exit(exitValue); - } - return(ret); - -} #endif /*---------------------------------------------*/ @@ -781,7 +740,7 @@ progName, outName ); if (outputHandleJustInCase != NULL) fclose ( outputHandleJustInCase ); - retVal = unlinkat ( cwd, getfilename(inName), 0 ); + retVal = unlinkat ( cwd, basename(inName), 0 ); if (retVal != 0) fprintf ( stderr, "%s: WARNING: deletion of output file " @@ -1287,7 +1246,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, getfilename(inName), 0 ); + unlinkat ( cwd, basename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1403,7 +1362,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1500,7 +1459,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, getfilename(inName), 0 ); + unlinkat ( cwd, basename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1616,7 +1575,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1624,7 +1583,7 @@ unzFailsExist = True; deleteOutputOnInterrupt = False; if ( srcMode == SM_F2F ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -2112,7 +2071,7 @@ if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; # ifdef CAPSICUM - cwd = open ( getdir(aa->name) , O_DIRECTORY ); + cwd = open ( dirname(aa->name) , O_DIRECTORY ); # endif compress ( aa->name ); } @@ -2131,7 +2090,7 @@ if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; # ifdef CAPSICUM - cwd = open ( getdir(aa->name) , 0 ); + cwd = open ( dirname(aa->name) , 0 ); # endif uncompress ( aa->name ); }