Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37483313
en ru br
Репозитории ALT
S:1.0.8-alt2
5.1: 1.0.6-alt1
4.1: 1.0.6-alt0.M40.1
4.0: 1.0.6-alt0.M40.1
+updates:1.0.5-alt2
3.0: 1.0.3-alt5
www.altlinux.org/Changes

Группа :: Архивирование/Сжатие
Пакет: bzip2

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: bzip2-1.0.3-alt-const.patch
Скачать


# Replace Char* with const Char* where appropriate.
# Declare functions which doesn't return as NORETURN.
# Change -h/-L/-V options behaviour to output to stdout
# instead of stderr and cause program exit without
# processing any more options.
# Trim usage text to bare minimum.
diff -upk.orig bzip2-1.0.3.orig/bzip2.c bzip2-1.0.3/bzip2.c
--- bzip2-1.0.3.orig/bzip2.c	2005-02-15 16:25:35 +0000
+++ bzip2-1.0.3/bzip2.c	2005-05-17 21:30:45 +0000
@@ -302,15 +302,18 @@ Char    progNameReally[FILE_NAME_LEN];
 FILE    *outputHandleJustInCase;
 Int32   workFactor;
 
-static void    panic                 ( Char* )   NORETURN;
+static void    panic             ( const Char* ) NORETURN;
 static void    ioError               ( void )    NORETURN;
 static void    outOfMemory           ( void )    NORETURN;
 static void    configError           ( void )    NORETURN;
 static void    crcError              ( void )    NORETURN;
 static void    cleanUpAndFail        ( Int32 )   NORETURN;
 static void    compressedStreamEOF   ( void )    NORETURN;
+static void    license               ( void )    NORETURN;
+static void    showHelp         ( const Char * ) NORETURN;
+static void    usage            ( const Char * ) NORETURN;
 
-static void    copyFileName ( Char*, Char* );
+static void    copyFileName ( Char*, const Char* );
 static void*   myMalloc     ( Int32 );
 
 
@@ -826,7 +829,7 @@ void cleanUpAndFail ( Int32 ec )
 
 /*---------------------------------------------*/
 static 
-void panic ( Char* s )
+void panic ( const Char* s )
 {
    fprintf ( stderr,
              "\n%s: PANIC -- internal consistency error:\n"
@@ -988,7 +991,7 @@ void configError ( void )
 
 /*---------------------------------------------*/
 static 
-void pad ( Char *s )
+void pad ( const Char* s )
 {
    Int32 i;
    if ( (Int32)strlen(s) >= longestFileName ) return;
@@ -999,7 +1002,7 @@ void pad ( Char *s )
 
 /*---------------------------------------------*/
 static 
-void copyFileName ( Char* to, Char* from ) 
+void copyFileName ( Char* to, const Char* from ) 
 {
    if ( strlen(from) > FILE_NAME_LEN-10 )  {
       fprintf (
@@ -1020,7 +1023,7 @@ void copyFileName ( Char* to, Char* from
 
 /*---------------------------------------------*/
 static 
-Bool fileExists ( Char* name )
+Bool fileExists ( const Char* name )
 {
    FILE *tmp   = fopen ( name, "rb" );
    Bool exists = (tmp != NULL);
@@ -1039,7 +1042,7 @@ Bool fileExists ( Char* name )
    For non-Unix platforms, if we are not worrying about
    security issues, simple this simply behaves like fopen.
 */
-FILE* fopen_output_safely ( Char* name, const char* mode )
+FILE* fopen_output_safely ( const Char* name, const char* mode )
 {
 #  if BZ_UNIX
    FILE*     fp;
@@ -1060,7 +1063,7 @@ FILE* fopen_output_safely ( Char* name, 
   if in doubt, return True
 --*/
 static 
-Bool notAStandardFile ( Char* name )
+Bool notAStandardFile ( const Char* name )
 {
    IntNative      i;
    struct MY_STAT statBuf;
@@ -1077,7 +1080,7 @@ Bool notAStandardFile ( Char* name )
   rac 11/21/98 see if file has hard links to it
 --*/
 static 
-Int32 countHardLinks ( Char* name )
+Int32 countHardLinks ( const Char* name )
 {  
    IntNative      i;
    struct MY_STAT statBuf;
@@ -1117,7 +1120,7 @@ struct MY_STAT fileMetaInfo;
 #endif
 
 static 
-void saveInputFileMetaInfo ( Char *srcName )
+void saveInputFileMetaInfo ( const Char* srcName )
 {
 #  if BZ_UNIX
    IntNative retVal;
@@ -1129,7 +1132,7 @@ void saveInputFileMetaInfo ( Char *srcNa
 
 
 static 
-void applySavedMetaInfoToOutputFile ( Char *dstName )
+void applySavedMetaInfoToOutputFile ( const Char* dstName )
 {
 #  if BZ_UNIX
    IntNative      retVal;
@@ -1154,7 +1157,7 @@ void applySavedMetaInfoToOutputFile ( Ch
 
 /*---------------------------------------------*/
 static 
-Bool containsDubiousChars ( Char* name )
+Bool containsDubiousChars ( const Char* name )
 {
 #  if BZ_UNIX
    /* On unix, files can contain any characters and the file expansion
@@ -1175,13 +1178,13 @@ Bool containsDubiousChars ( Char* name )
 /*---------------------------------------------*/
 #define BZ_N_SUFFIX_PAIRS 4
 
-Char* zSuffix[BZ_N_SUFFIX_PAIRS] 
+const Char* zSuffix[BZ_N_SUFFIX_PAIRS] 
    = { ".bz2", ".bz", ".tbz2", ".tbz" };
-Char* unzSuffix[BZ_N_SUFFIX_PAIRS] 
+const Char* unzSuffix[BZ_N_SUFFIX_PAIRS] 
    = { "", "", ".tar", ".tar" };
 
 static 
-Bool hasSuffix ( Char* s, Char* suffix )
+Bool hasSuffix ( const Char* s, const Char* suffix )
 {
    Int32 ns = strlen(s);
    Int32 nx = strlen(suffix);
@@ -1192,7 +1195,7 @@ Bool hasSuffix ( Char* s, Char* suffix )
 
 static 
 Bool mapSuffix ( Char* name, 
-                 Char* oldSuffix, Char* newSuffix )
+                 const Char* oldSuffix, const Char* newSuffix )
 {
    if (!hasSuffix(name,oldSuffix)) return False;
    name[strlen(name)-strlen(oldSuffix)] = 0;
@@ -1203,7 +1206,7 @@ Bool mapSuffix ( Char* name, 
 
 /*---------------------------------------------*/
 static 
-void compress ( Char *name )
+void compress ( const Char* name )
 {
    FILE  *inStr;
    FILE  *outStr;
@@ -1384,7 +1387,7 @@ void compress ( Char *name )
 
 /*---------------------------------------------*/
 static 
-void uncompress ( Char *name )
+void uncompress ( const Char* name )
 {
    FILE  *inStr;
    FILE  *outStr;
@@ -1582,7 +1585,7 @@ void uncompress ( Char *name )
 
 /*---------------------------------------------*/
 static 
-void testf ( Char *name )
+void testf ( const Char* name )
 {
    FILE *inStr;
    Bool allOK;
@@ -1670,11 +1673,10 @@ void testf ( Char *name )
 
 
 /*---------------------------------------------*/
-static 
+static
 void license ( void )
 {
-   fprintf ( stderr,
-
+   printf (
     "bzip2, a block-sorting file compressor.  "
     "Version %s.\n"
     "   \n"
@@ -1691,15 +1693,15 @@ void license ( void )
     "   \n",
     BZ2_bzlibVersion()
    );
+   exit ( 0 );
 }
 
 
 /*---------------------------------------------*/
 static 
-void usage ( Char *fullProgName )
+void showHelp ( const Char* fullProgName )
 {
-   fprintf (
-      stderr,
+   printf (
       "bzip2, a block-sorting file compressor.  "
       "Version %s.\n"
       "\n   usage: %s [flags and input files in any order]\n"
@@ -1735,12 +1737,25 @@ void usage ( Char *fullProgName )
       BZ2_bzlibVersion(),
       fullProgName
    );
+   exit ( 0 );
+}
+
+
+/*---------------------------------------------*/
+static 
+void usage ( const Char* fullProgName )
+{
+   fprintf (
+      stderr,
+      "Try `%s --help' for more information.\n", fullProgName
+   );
+   exit ( 1 );
 }
 
 
 /*---------------------------------------------*/
 static 
-void redundant ( Char* flag )
+void redundant ( const Char* flag )
 {
    fprintf ( 
       stderr, 
@@ -1799,7 +1814,7 @@ Cell *mkCell ( void )
 
 /*---------------------------------------------*/
 static 
-Cell *snocString ( Cell *root, Char *name )
+Cell *snocString ( Cell *root, const Char* name )
 {
    if (root == NULL) {
       Cell *tmp = mkCell();
@@ -1817,7 +1832,7 @@ Cell *snocString ( Cell *root, Char *nam
 
 /*---------------------------------------------*/
 static 
-void addFlagsFromEnvVar ( Cell** argList, Char* varName ) 
+void addFlagsFromEnvVar ( Cell** argList, const Char* varName ) 
 {
    Int32 i, j, k;
    Char *envbase, *p;
@@ -1965,13 +1980,11 @@ IntNative main ( IntNative argc, Char *a
                case 'V':
                case 'L': license();            break;
                case 'v': verbosity++; break;
-               case 'h': usage ( progName );
-                         exit ( 0 );
+               case 'h': showHelp ( progName );
                          break;
                default:  fprintf ( stderr, "%s: Bad flag `%s'\n",
                                    progName, aa->name );
                          usage ( progName );
-                         exit ( 1 );
                          break;
             }
          }
@@ -1997,12 +2010,11 @@ IntNative main ( IntNative argc, Char *a
       if (ISFLAG("--fast"))              blockSize100k = 1;          else
       if (ISFLAG("--best"))              blockSize100k = 9;          else
       if (ISFLAG("--verbose"))           verbosity++;                else
-      if (ISFLAG("--help"))              { usage ( progName ); exit ( 0 ); }
+      if (ISFLAG("--help"))              showHelp ( progName );
          else
          if (strncmp ( aa->name, "--", 2) == 0) {
             fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name );
             usage ( progName );
-            exit ( 1 );
          }
    }
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin