aboutsummaryrefslogtreecommitdiff
path: root/fastjar
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-25 04:26:34 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-25 04:26:34 +0000
commit71887121eeaf91b1eb56b4480349129b887f48cd (patch)
tree5621df8f2a3cbd2033c203e78e152cd9a3d81cbf /fastjar
parent42be37ca6dca3440cf7b0582abbd268d0fc9f8b0 (diff)
Merge with basic-improvements as of 2002-11-20.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@59448 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'fastjar')
-rw-r--r--fastjar/ChangeLog20
-rw-r--r--fastjar/config.h.in3
-rwxr-xr-xfastjar/configure2
-rw-r--r--fastjar/configure.in2
-rw-r--r--fastjar/dostime.c150
-rw-r--r--fastjar/dostime.h3
-rw-r--r--fastjar/jartool.c5
7 files changed, 79 insertions, 106 deletions
diff --git a/fastjar/ChangeLog b/fastjar/ChangeLog
index c85058ed47c..2cb0ed66797 100644
--- a/fastjar/ChangeLog
+++ b/fastjar/ChangeLog
@@ -1,3 +1,23 @@
+2002-11-11 Tom Tromey <tromey@redhat.com>
+
+ * dostime.c (dos2unixtime): Mask for seconds is 0x1f. Correctly
+ compute month.
+ (unix2dostime): Handle years before 1980. Correctly compute month
+ and day of month.
+
+2002-11-10 Jakub Jelinek <jakub@redhat.com>
+
+ * jartool.c (add_to_jar): Only compare file to jarfile if jarfile is
+ non-NULL.
+
+ * configure.in (AC_CHECK_HEADERS): Add limits.h.
+ * configure, config.h.in: Rebuilt.
+
+2002-11-07 Tom Tromey <tromey@redhat.com>
+
+ * dostime.c: Rewrote from scratch.
+ * dostime.h (dostime): Removed.
+
2002-10-20 Tom Tromey <tromey@redhat.com>
* jartool.c: Use mode 0666 when opening new file.
diff --git a/fastjar/config.h.in b/fastjar/config.h.in
index ae4fb96c5cb..05d0c6ec1f5 100644
--- a/fastjar/config.h.in
+++ b/fastjar/config.h.in
@@ -21,6 +21,9 @@
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
+/* Define if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
/* Define if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H
diff --git a/fastjar/configure b/fastjar/configure
index 719d3e32b05..4cc1b926a70 100755
--- a/fastjar/configure
+++ b/fastjar/configure
@@ -1691,7 +1691,7 @@ EOF
fi
-for ac_hdr in fcntl.h unistd.h sys/param.h stdlib.h
+for ac_hdr in fcntl.h unistd.h sys/param.h stdlib.h limits.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
diff --git a/fastjar/configure.in b/fastjar/configure.in
index c2e686e0f8c..a1e4676a7dc 100644
--- a/fastjar/configure.in
+++ b/fastjar/configure.in
@@ -24,7 +24,7 @@ dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_STRUCT_TM
-AC_CHECK_HEADERS(fcntl.h unistd.h sys/param.h stdlib.h)
+AC_CHECK_HEADERS(fcntl.h unistd.h sys/param.h stdlib.h limits.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T
diff --git a/fastjar/dostime.c b/fastjar/dostime.c
index 834ef4284aa..5117a82014e 100644
--- a/fastjar/dostime.c
+++ b/fastjar/dostime.c
@@ -1,129 +1,79 @@
-/*
- dostime.c - routines for converting UNIX time to MS-DOS time.
-
- Borrowed from Info-zip's unzip
+/* dostime.c - convert dos time to/from time_t.
- Copyright (C) 1999 Bryan Burns
+ Copyright (C) 2002 Free Software Foundation
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
of the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* $Id: dostime.c,v 1.1 2000/12/09 03:08:23 apbianco Exp $
-
- $Log: dostime.c,v $
- Revision 1.1 2000/12/09 03:08:23 apbianco
- 2000-12-08 Alexandre Petit-Bianco <apbianco@cygnus.com>
-
- * fastjar: Imported.
-
- Revision 1.1.1.1 1999/12/06 03:09:12 toast
- initial checkin..
-
-
-
- Revision 1.6 1999/05/10 08:32:26 burnsbr
- added dos2unixtime
-
- Revision 1.5 1999/04/27 10:03:50 burnsbr
- configure support
-
- Revision 1.4 1999/04/26 21:55:19 burnsbr
- switched from sys/time.h to time.h for better portability
-
- Revision 1.3 1999/04/20 08:54:30 burnsbr
- added GPL comment
-
- Revision 1.2 1999/04/20 05:10:53 burnsbr
- added RCS tags
+#include <config.h>
-
-*/
-#include "config.h"
-
-#ifdef TM_IN_SYS_TIME
-#include <sys/time.h>
-#else
#include <time.h>
-#endif
#include "dostime.h"
/*
-
- Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly,
- Kai Uwe Rommel, Onno van der Linden and Igor Mandrichenko.
- Permission is granted to any individual or institution to use, copy, or
- redistribute this software so long as all of the original files are included,
- that it is not sold for profit, and that this copyright notice is retained.
-
-*/
-
-
-time_t dos2unixtime(dostime)
- unsigned long dostime; /* DOS time to convert */
- /* Return the Unix time_t value (GMT/UTC time) for the DOS format (local)
- * time dostime, where dostime is a four byte value (date in most
- * significant word, time in least significant word), see dostime()
- * function.
- */
+ * The specification to which this was written. From Joe Buck.
+ * The DOS format appears to have only 2 second resolution. It is an
+ * unsigned long, and ORs together
+ *
+ * (year-1980)<<25
+ * month<<21 (month is tm_mon + 1, 1=Jan through 12=Dec)
+ * day<<16 (day is tm_mday, 1-31)
+ * hour<<11 (hour is tm_hour, 0-23)
+ * min<<5 (min is tm_min, 0-59)
+ * sec>>1 (sec is tm_sec, 0-59, that's right, we throw away the LSB)
+ *
+ * DOS uses local time, so the localtime() call is used to turn the time_t
+ * into a struct tm.
+ */
+
+time_t
+dos2unixtime (unsigned long dostime)
{
- struct tm *t; /* argument for mktime() */
- time_t clock = time(NULL);
+ struct tm ltime;
+ time_t now = time (NULL);
- t = localtime(&clock);
- t->tm_isdst = -1; /* let mktime() determine if DST is in effect */
- /* Convert DOS time to UNIX time_t format */
- t->tm_sec = (((int)dostime) << 1) & 0x3e;
- t->tm_min = (((int)dostime) >> 5) & 0x3f;
- t->tm_hour = (((int)dostime) >> 11) & 0x1f;
- t->tm_mday = (int)(dostime >> 16) & 0x1f;
- t->tm_mon = ((int)(dostime >> 21) & 0x0f) - 1;
- t->tm_year = ((int)(dostime >> 25) & 0x7f) + 80;
+ /* Call localtime to initialize timezone in TIME. */
+ ltime = *localtime (&now);
- return mktime(t);
-}
+ ltime.tm_year = (dostime >> 25) + 80;
+ ltime.tm_mon = ((dostime >> 21) & 0x0f) - 1;
+ ltime.tm_mday = (dostime >> 16) & 0x1f;
+ ltime.tm_hour = (dostime >> 11) & 0x0f;
+ ltime.tm_min = (dostime >> 5) & 0x3f;
+ ltime.tm_sec = (dostime & 0x1f) << 1;
-unsigned long dostime(y, n, d, h, m, s)
-int y; /* year */
-int n; /* month */
-int d; /* day */
-int h; /* hour */
-int m; /* minute */
-int s; /* second */
-/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
- time (date in high two bytes, time in low two bytes allowing magnitude
- comparison). */
-{
- return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) :
- (((unsigned long)y - 1980) << 25) | ((unsigned long)n << 21) |
- ((unsigned long)d << 16) | ((unsigned long)h << 11) |
- ((unsigned long)m << 5) | ((unsigned long)s >> 1);
-}
+ ltime.tm_wday = -1;
+ ltime.tm_yday = -1;
+ ltime.tm_isdst = -1;
+ return mktime (&ltime);
+}
-unsigned long unix2dostime(t)
-time_t *t; /* unix time to convert */
-/* Return the Unix time t in DOS format, rounded up to the next two
- second boundary. */
+unsigned long
+unix2dostime (time_t *time)
{
- time_t t_even;
- struct tm *s; /* result of localtime() */
-
- t_even = (*t + 1) & (~1); /* Round up to even seconds. */
- s = localtime(&t_even); /* Use local time since MSDOS does. */
- return dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
- s->tm_hour, s->tm_min, s->tm_sec);
+ struct tm *ltime = localtime (time);
+ int year = ltime->tm_year - 80;
+ if (year < 0)
+ year = 0;
+
+ return (year << 25
+ | (ltime->tm_mon + 1) << 21
+ | ltime->tm_mday << 16
+ | ltime->tm_hour << 11
+ | ltime->tm_min << 5
+ | ltime->tm_sec >> 1);
}
-
diff --git a/fastjar/dostime.h b/fastjar/dostime.h
index 6f6931f4c21..822c8e0e83f 100644
--- a/fastjar/dostime.h
+++ b/fastjar/dostime.h
@@ -1,6 +1,6 @@
/*
dostime.h - function prototypes
- Copyright (C) 1999 Bryan Burns
+ Copyright (C) 1999, 2002 Bryan Burns
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -18,5 +18,4 @@
*/
time_t dos2unixtime(unsigned long dostime);
-unsigned long dostime(int, int, int, int, int, int);
unsigned long unix2dostime(time_t*);
diff --git a/fastjar/jartool.c b/fastjar/jartool.c
index dc247ad77cb..e6a00089eb8 100644
--- a/fastjar/jartool.c
+++ b/fastjar/jartool.c
@@ -840,7 +840,7 @@ int add_to_jar(int fd, const char *new_dir, const char *file){
}
}
- if(!strcmp(file, jarfile)){
+ if(jarfile && !strcmp(file, jarfile)){
if(verbose)
printf("skipping: %s\n", file);
return 0; /* we don't want to add ourselves.. */
@@ -921,7 +921,8 @@ int add_to_jar(int fd, const char *new_dir, const char *file){
while(!use_explicit_list_only && (de = readdir(dir)) != NULL){
if(de->d_name[0] == '.')
continue;
- if(!strcmp(de->d_name, jarfile)){ /* we don't want to add ourselves. Believe me */
+ if(jarfile && !strcmp(de->d_name, jarfile)){
+ /* we don't want to add ourselves. Believe me */
if(verbose)
printf("skipping: %s\n", de->d_name);
continue;