]> Dogcows Code - chaz/tar/blobdiff - src/buffer.c
Update
[chaz/tar] / src / buffer.c
index f1034636b6de70a13eec147bc791580268135080..f99dcca1b2829bb978073d12657829fb5277df8b 100644 (file)
@@ -1,13 +1,13 @@
 /* Buffer management for tar.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
 /* Buffer management for tar.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
-   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
    Written by John Gilmore, on 1985-08-25.
 
    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 the
 
    Written by John Gilmore, on 1985-08-25.
 
    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 the
-   Free Software Foundation; either version 2, or (at your option) any later
+   Free Software Foundation; either version 3, or (at your option) any later
    version.
 
    This program is distributed in the hope that it will be useful, but
    version.
 
    This program is distributed in the hope that it will be useful, but
@@ -26,7 +26,6 @@
 
 #include <closeout.h>
 #include <fnmatch.h>
 
 #include <closeout.h>
 #include <fnmatch.h>
-#include <getline.h>
 #include <human.h>
 #include <quotearg.h>
 
 #include <human.h>
 #include <quotearg.h>
 
@@ -235,14 +234,16 @@ check_compressed_archive ()
 {
   struct zip_magic const *p;
   bool sfr;
 {
   struct zip_magic const *p;
   bool sfr;
-
+  bool short_file = false;
+  
   /* Prepare global data needed for find_next_block: */
   record_end = record_start; /* set up for 1st record = # 0 */
   sfr = read_full_records;
   read_full_records = true; /* Suppress fatal error on reading a partial
                               record */
   /* Prepare global data needed for find_next_block: */
   record_end = record_start; /* set up for 1st record = # 0 */
   sfr = read_full_records;
   read_full_records = true; /* Suppress fatal error on reading a partial
                               record */
-  find_next_block ();
-
+  if (find_next_block () == 0)
+    short_file = true;
+  
   /* Restore global values */
   read_full_records = sfr;
 
   /* Restore global values */
   read_full_records = sfr;
 
@@ -254,6 +255,9 @@ check_compressed_archive ()
     if (memcmp (record_start->buffer, p->magic, p->length) == 0)
       return p->type;
 
     if (memcmp (record_start->buffer, p->magic, p->length) == 0)
       return p->type;
 
+  if (short_file)
+    ERROR ((0, 0, _("This does not look like a tar archive")));
+
   return ct_none;
 }
 
   return ct_none;
 }
 
@@ -586,7 +590,7 @@ _open_archive (enum access_mode wanted_access)
 }
 
 static void
 }
 
 static void
-do_checkpoint (bool write)
+do_checkpoint (bool do_write)
 {
   if (checkpoint_option && !(++checkpoint % checkpoint_option))
     {
 {
   if (checkpoint_option && !(++checkpoint % checkpoint_option))
     {
@@ -598,7 +602,7 @@ do_checkpoint (bool write)
          break;
 
        case checkpoint_text:
          break;
 
        case checkpoint_text:
-         if (write)
+         if (do_write)
            /* TRANSLATORS: This is a ``checkpoint of write operation'',
             *not* ``Writing a checkpoint''.
             E.g. in Spanish ``Punto de comprobaci@'on de escritura'',
            /* TRANSLATORS: This is a ``checkpoint of write operation'',
             *not* ``Writing a checkpoint''.
             E.g. in Spanish ``Punto de comprobaci@'on de escritura'',
@@ -1132,22 +1136,22 @@ try_new_volume ()
 {
   size_t status;
   union block *header;
 {
   size_t status;
   union block *header;
-  int access;
+  enum access_mode acc;
   
   switch (subcommand_option)
     {
     case APPEND_SUBCOMMAND:
     case CAT_SUBCOMMAND:
     case UPDATE_SUBCOMMAND:
   
   switch (subcommand_option)
     {
     case APPEND_SUBCOMMAND:
     case CAT_SUBCOMMAND:
     case UPDATE_SUBCOMMAND:
-      access = ACCESS_UPDATE;
+      acc = ACCESS_UPDATE;
       break;
 
     default:
       break;
 
     default:
-      access = ACCESS_READ;
+      acc = ACCESS_READ;
       break;
     }
 
       break;
     }
 
-  if (!new_volume (access))
+  if (!new_volume (acc))
     return true;
   
   while ((status = rmtread (archive, record_start->buffer, record_size))
     return true;
   
   while ((status = rmtread (archive, record_start->buffer, record_size))
This page took 0.027548 seconds and 4 git commands to generate.