Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.7+dfsga-2) unstable; urgency=high
 .
   * more arm relocs supported;check default timezone dynamically;follow
     bash ~ semantics in user-homedir-pathname
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.7+dfsga.orig/lsp/gcl_mislib.lsp
+++ gcl-2.6.7+dfsga/lsp/gcl_mislib.lsp
@@ -58,8 +58,6 @@
 		 (/ ,gbc-time internal-time-units-per-second))))
        (values-list ,x))))
 
-
-(defconstant month-days-list '(31 28 31 30 31 30 31 31 30 31 30 31))
 (defconstant seconds-per-day #.(* 24 3600))
 
 (defun leap-year-p (y)
@@ -72,50 +70,62 @@
        (floor y1 4) (- (floor y1 100)) (floor y1 400)
        -460)))
 
-(defun decode-universal-time (ut &optional (tz *default-time-zone*))
-  (let (sec min h d m y dow)
-    (decf ut (* tz 3600))
-    (multiple-value-setq (d ut) (floor ut seconds-per-day))
-    (setq dow (mod d 7))
-    (multiple-value-setq (h ut) (floor ut 3600))
-    (multiple-value-setq (min sec) (floor ut 60))
-    (setq y (+ 1900 (floor d 366)))  ; Guess!
-    (do ((x))
-        ((< (setq x (- d (number-of-days-from-1900 y)))
-            (if (leap-year-p y) 366 365))
-         (setq d (1+ x)))
-      (incf y))
-    (when (leap-year-p y)
-          (when (= d 60)
-                (return-from decode-universal-time
-                             (values sec min h 29 2 y dow nil tz)))
-          (when (> d 60) (decf d)))
-    (do ((l month-days-list (cdr l)))
-        ((<= d (car l)) (setq m (- 13 (length l))))
-      (decf d (car l)))
-    (values sec min h d m y dow nil tz)))
-
-(defun encode-universal-time (sec min h d m y
-                              &optional (tz *default-time-zone*))
-  (incf h tz)
+(eval-when
+ (compile eval)
+ (defmacro mmd (n &optional lp 
+		  &aux (l '(31 28 31 30 31 30 31 31 30 31 30 31))
+		  (l (if lp (cons (pop l) (cons (1+ (pop l)) l)) l))(r 0)(s (mapcar (lambda (x) (incf r x)) l)))
+  `(defconstant ,n (make-array ,(length s) :element-type '(integer ,(car s) ,(car (last s))) :initial-contents ',s))))
+       
+(mmd +md+)
+(mmd +lmd+ t)
+
+(defun decode-universal-time (ut &optional (tz (current-timezone) tzp) 
+				 &aux (dstp (unless tzp (current-dstp))) (ut (- ut (* tz 3600))))
+  (declare (optimize (safety 2)))
+  (check-type ut (integer 0))
+  (check-type tz rational)
+  (multiple-value-bind
+   (d ut) (floor ut seconds-per-day)
+   (let* ((dow (mod d 7))(y (+ 1900 (floor d 366))))
+     (labels ((l (y dd &aux (lyp (leap-year-p y))(td (if lyp 366 365))(x (- d dd)))
+		 (if (< x td) (values (1+ x) y lyp) (l (1+ y) (+ dd td)))))
+	     (multiple-value-bind
+	      (d y lyp) (l y (number-of-days-from-1900 y))
+	      (let* ((l (if lyp +lmd+ +md+))
+		     (m (position d l :test '<=))
+		     (d (if (> m 0) (- d (aref l (1- m))) d)))
+		(multiple-value-bind
+		 (h ut) (floor ut 3600)
+		 (multiple-value-bind
+		  (min sec) (floor ut 60)
+		  (values sec min h d (1+ m) y dow dstp tz)))))))))
+
+(defun encode-universal-time (sec min h d m y &optional (tz (current-timezone)))
+  (declare (optimize (safety 2)))
+  (check-type sec (integer 0 59))
+  (check-type min (integer 0 59))
+  (check-type h (integer 0 23))
+  (check-type d (integer 1 31))
+  (check-type m (integer 1 12))
+  (check-type y (integer 1900))
+  (check-type tz rational)
   (when (<= 0 y 99)
-        (multiple-value-bind (sec min h d m y1 dow dstp tz)
-            (get-decoded-time)
-          (declare (ignore sec min h d m dow dstp tz))
-          (incf y (- y1 (mod y1 100)))
-          (cond ((< (- y y1) -50) (incf y 100))
-                ((>= (- y y1) 50) (decf y 100)))))
-  (unless (and (leap-year-p y) (> m 2)) (decf d 1))
-  (+ (* (apply #'+ d (number-of-days-from-1900 y)
-               (butlast month-days-list (- 13 m)))
+    (multiple-value-bind
+     (sec min h d m y1 dow dstp tz) (get-decoded-time)
+     (declare (ignore sec min h d m dow dstp tz))
+     (incf y (- y1 (mod y1 100)))
+     (cond ((< (- y y1) -50) (incf y 100))
+	   ((>= (- y y1) 50) (decf y 100)))))
+  (+ (* (+ (1- d) (number-of-days-from-1900 y) (if (> m 1) (aref (if (leap-year-p y) +lmd+ +md+) (- m 2)) 0))
         seconds-per-day)
-     (* h 3600) (* min 60) sec))
+     (* (+ h tz) 3600) (* min 60) sec))
 
 (defun compile-file-pathname (pathname)
 (make-pathname :defaults pathname :type "o"))
 (defun constantly (x)
 #'(lambda (&rest args)
-(declare (ignore args) (dynamic-extent args))
+    (declare (ignore args) (:dynamic-extent args))
 x))
 (defun complement (fn)
 #'(lambda (&rest args) (not (apply fn args))))
--- gcl-2.6.7+dfsga.orig/unixport/init_ansi_gcl.lsp.in
+++ gcl-2.6.7+dfsga/unixport/init_ansi_gcl.lsp.in
@@ -280,11 +280,6 @@
   (push :common-lisp *features*)
   (push :ansi-cl *features*)
   
-  (eval-when (load)
-	     (if (fboundp 'get-system-time-zone)
-		 (setf system:*default-time-zone* (get-system-time-zone))
-	       (setf system:*default-time-zone* 6)))
-  
   (if (fboundp 'si::user-init) (si::user-init))
   (si::set-up-top-level)
   
--- gcl-2.6.7+dfsga.orig/unixport/init_gcl.lsp.in
+++ gcl-2.6.7+dfsga/unixport/init_gcl.lsp.in
@@ -109,11 +109,6 @@
  (unintern 'user)
  (fmakunbound 'si::init-cmp-anon)
  
- (eval-when (load)
-	    (if (fboundp 'get-system-time-zone)
-		(setf system:*default-time-zone* (get-system-time-zone))
-	      (setf system:*default-time-zone* 6)))
- 
  (if (fboundp 'si::user-init) (si::user-init))
  (si::set-up-top-level)
  
--- gcl-2.6.7+dfsga.orig/unixport/init_pcl_gcl.lsp.in
+++ gcl-2.6.7+dfsga/unixport/init_pcl_gcl.lsp.in
@@ -121,11 +121,6 @@
   (unintern 'user)
   (fmakunbound 'si::init-cmp-anon)
   
-  (eval-when (load)
-	     (if (fboundp 'get-system-time-zone)
-		 (setf system:*default-time-zone* (get-system-time-zone))
-	       (setf system:*default-time-zone* 6)))
-  
   (if (fboundp 'si::user-init) (si::user-init))
   (si::set-up-top-level)
   
--- gcl-2.6.7+dfsga.orig/unixport/init_pre_gcl.lsp.in
+++ gcl-2.6.7+dfsga/unixport/init_pre_gcl.lsp.in
@@ -110,11 +110,6 @@
  (unintern 'user)
  (fmakunbound 'si::init-cmp-anon)
  
- (eval-when (load)
-	    (if (fboundp 'get-system-time-zone)
-		(setf system:*default-time-zone* (get-system-time-zone))
-	      (setf system:*default-time-zone* 6)))
- 
  (if (fboundp 'si::user-init) (si::user-init))
  (si::set-up-top-level)
  
--- gcl-2.6.7+dfsga.orig/o/unixfsys.c
+++ gcl-2.6.7+dfsga/o/unixfsys.c
@@ -171,7 +171,7 @@ getwd(char *buffer) {
 void
 coerce_to_filename(object pathname,char *p) {
 
-  object namestring = coerce_to_namestring(pathname);
+  object namestring=coerce_to_namestring(pathname);
   unsigned e=namestring->st.st_fillp;
   char *q=namestring->st.st_self,*qe=q+e;;
 
@@ -181,12 +181,16 @@ coerce_to_filename(object pathname,char
   if (*q=='~') {
 
     unsigned m=0;
-    char *s=++q;
+    char *s=++q,*c;
 
     for (;s<qe && *s!='/';s++);
-    
+
+    if (s==q && (c=getenv("HOME")))
+
+      pcopy(c,p,0,m=strlen(c));
+
 #if !defined(NO_PWD_H) && !defined(STATIC_LINKING)
-    {
+    else {
 #ifndef __STDC__
       extern struct passwd *getpwuid();
       extern struct passwd *getpwnam();
@@ -206,17 +210,12 @@ coerce_to_filename(object pathname,char
       pcopy(pwent->pw_dir,p,0,m=strlen(pwent->pw_dir));
       
     }
-#else
-    {
-      char *c=getenv("HOME");
-      if (!c || s>q)
-	FEerror("Can't expand pathname ~a",1,namestring);
-      pcopy(c,p,0,m=strlen(c));
-    }       
 #endif
+
     pcopy(s,p,m,qe-s);
     
   } else
+
     pcopy(q,p,0,e);
   
 #ifdef FIX_FILENAME
@@ -586,30 +585,13 @@ LFD(Lfile_author)(void)
 static void
 FFN(Luser_homedir_pathname)(void)
 {
-#if !defined(NO_PWD_H) && !defined(STATIC_LINKING)
-	struct passwd *pwent;
-	char filename[MAXPATHLEN];
-	register int i;
-#ifndef __STDC__
-	extern struct passwd *getpwuid();
-#endif
 
-	if (vs_top - vs_base > 1)
-		too_many_arguments();
-	pwent = getpwuid(getuid());
-	strcpy(filename, pwent->pw_dir);
-	i = strlen(filename);
-	if (filename[i-1] != '/') {
-		filename[i++] = '/';
-		filename[i] = '\0';
-	}
-#else
-	 char *filename= "~/" ;
-#endif	
-	vs_base[0] = make_simple_string(filename);
-	vs_top = vs_base+1;
-	vs_base[0] = coerce_to_pathname(vs_base[0]);
-	
+  char filename[MAXPATHLEN];
+
+  coerce_to_filename(make_simple_string("~/"),filename);
+  vs_base[0]=coerce_to_pathname(make_simple_string(filename));
+  vs_top = vs_base+1; 
+  
 }
 
 
--- gcl-2.6.7+dfsga.orig/o/makefun.c
+++ gcl-2.6.7+dfsga/o/makefun.c
@@ -103,13 +103,13 @@ DEFUN_NEW("SET-KEY-STRUCT",object,fSset_
      
 
 void
-SI_makefun(char *strg, object (*fn) (/* ??? */), unsigned int argd)
+SI_makefun(char *strg, void *fn, unsigned int argd)
 { object sym = make_si_ordinary(strg);
  fSfset(sym, fSmakefun(sym,fn,argd));
 }
 
 void
-LISP_makefun(char *strg, object (*fn) (/* ??? */), unsigned int argd)
+LISP_makefun(char *strg, void *fn, unsigned int argd)
 { object sym = make_ordinary(strg);
  fSfset(sym, fSmakefun(sym,fn,argd));
 }
--- gcl-2.6.7+dfsga.orig/o/unixtime.c
+++ gcl-2.6.7+dfsga/o/unixtime.c
@@ -63,8 +63,6 @@ int usleep ( unsigned int microseconds )
 
 #  endif
 
-static void FFN(siLget_system_time_zone)(void);
-
 #endif /* __MINGW32__ or  !defined NO_SYSTEM_TIME_ZONE */
 
 #ifdef BSD
@@ -234,32 +232,21 @@ DEFUN_NEW("GET-INTERNAL-REAL-TIME",objec
 #endif
 }
 
-#if defined __MINGW32__ || !defined NO_SYSTEM_TIME_ZONE
-DEFVAR("*DEFAULT-TIME-ZONE*",sSAdefault_time_zoneA,SI,make_fixnum ( system_time_zone_helper() ),"");
-#else
-DEFVAR("*DEFAULT-TIME-ZONE*",sSAdefault_time_zoneA,SI,make_fixnum(TIME_ZONE),"");
-#endif
 
 void
-gcl_init_unixtime(void)
-{
-/* #ifdef BSD */
-/* 	ftime(&beginning); */
-/* #endif */
+gcl_init_unixtime(void) {
 #ifdef ATT
-	beginning = time(0);
+  beginning = time(0);
 #endif
 #  if defined __MINGW32__
-        ftime(&t0);
+  ftime(&t0);
 #  endif        
+  
+  make_constant("INTERNAL-TIME-UNITS-PER-SECOND", make_fixnum(HZ1));
+  
+  make_function("SLEEP", Lsleep);
+  make_function("GET-INTERNAL-RUN-TIME", Lget_internal_run_time);
 
-	make_constant("INTERNAL-TIME-UNITS-PER-SECOND", make_fixnum(HZ1));
-
-	make_function("SLEEP", Lsleep);
-	make_function("GET-INTERNAL-RUN-TIME", Lget_internal_run_time);
-#if defined __MINGW32__   || !defined NO_SYSTEM_TIME_ZONE
-	make_si_function("GET-SYSTEM-TIME-ZONE", siLget_system_time_zone);
-#endif        
 }
 
 #ifdef __MINGW32__
@@ -269,46 +256,39 @@ int usleep ( unsigned int microseconds )
     return ( SleepEx ( milliseconds, TRUE ) );
 }
 
-int system_time_zone_helper(void)
-{
-    TIME_ZONE_INFORMATION tzi;
-    DWORD TZResult;
-    int tz=0;
+#endif
 
-    TZResult = GetTimeZoneInformation ( &tzi );
+DEFUN_NEW("CURRENT-TIMEZONE",fixnum,fScurrent_timezone,SI,0,0,NONE,IO,OO,OO,OO,(void),"") {
 
-    /* Now UTC = (local time + bias), in units of minutes, so */
-    /*fprintf ( stderr, "Bias = %ld\n", tzi.Bias );*/
-    tz = (int) (tzi.Bias / 60);
-    return ( tz );                                    
-}
-#endif
+#if defined(__MINGW32__)
 
-/* At GCC 3.2, Mingw struct tm does not include tm_gmtoff so avoid this version */
-#if !defined ( NO_SYSTEM_TIME_ZONE ) && !defined ( __MINGW32__ )
-int system_time_zone_helper(void){
+  TIME_ZONE_INFORMATION tzi;
+  DWORD TZResult;
   
-  struct tm *local;
-  time_t TIME;
-  int nsecs;
-
-  TIME = time(0);
-  local = localtime(&TIME);
-  nsecs = local->tm_gmtoff;
-  if (nsecs == 0)
-    return (nsecs);
-  else
-    return(- (nsecs / 60 / 60));
+  TZResult = GetTimeZoneInformation ( &tzi );
+  
+  /* Now UTC = (local time + bias), in units of minutes, so */
+  /*fprintf ( stderr, "Bias = %ld\n", tzi.Bias );*/
+  return tzi.Bias/60;                                    
+  
+#elif defined NO_SYSTEM_TIME_ZONE
+  return 0;
+#else
+  fixnum _t=time(0);
+  return -localtime(&_t)->tm_gmtoff/3600;
+#endif
 }
-#endif /* !defined NO_SYSTEM_TIME_ZONE */
 
-#if defined __MINGW32__ || !defined NO_SYSTEM_TIME_ZONE
+DEFUN_NEW("CURRENT-DSTP",object,fScurrent_dstp,SI,0,0,NONE,OO,OO,OO,OO,(void),"") {
 
-static void
-FFN(siLget_system_time_zone)(void)
-{
-  check_arg(0);
-  vs_push ( make_fixnum ( system_time_zone_helper() ) );
-}
+#if defined(__MINGW32__)
+
+  return Cnil;
 
-#endif /*__MINGW32__ or !defined NO_SYSTEM_TIME_ZONE */
+#elif defined NO_SYSTEM_TIME_ZONE /*solaris*/
+  return Cnil;
+#else
+  fixnum _t=time(0);
+  return localtime(&_t)->tm_isdst > 0 ? Ct : Cnil;
+#endif
+}
--- gcl-2.6.7+dfsga.orig/h/elf32_arm_reloc.h
+++ gcl-2.6.7+dfsga/h/elf32_arm_reloc.h
@@ -3,6 +3,8 @@
 #define R_ARM_V4BX 40
 #define R_ARM_THM_MOVW_ABS_NC 47
 #define R_ARM_THM_MOVW_ABS    48
+#define R_ARM_MOVW_ABS_NC 43
+#define R_ARM_MOVT_ABS    44
     case R_ARM_THM_CALL: 
       s+=a; 
       if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) s|=1; 
@@ -25,6 +27,18 @@
       s=((s>>12)&0xf)|(((s>>11)&0x1)<<10)|((s&0xff)<<16)|(((s>>8)&0x7)<<28);
       add_vals(where,~0L,s);
       break;
+    case R_ARM_MOVW_ABS_NC:
+      s+=a;
+      s&=0xffff;
+      s=(s&0xfff)|((s>>12)<<16);
+      add_vals(where,~0L,s);
+      break;
+    case R_ARM_MOVT_ABS:
+      s+=a;
+      s>>=16;
+      s=(s&0xfff)|((s>>12)<<16);
+      add_vals(where,~0L,s);
+      break;
     case R_ARM_CALL:
       add_vals(where,MASK(24),((long)(s+a-p))>>2);
       break;
--- gcl-2.6.7+dfsga.orig/h/protoize.h
+++ gcl-2.6.7+dfsga/h/protoize.h
@@ -309,8 +309,10 @@ typedef void (*funcvoid)(void);
 /* main.c:807:OF */ extern object fLlisp_implementation_version (void); /* () */
 /* makefun.c:10:OF */ extern object MakeAfun (object (*addr)(object,object), unsigned int argd, object data); /* (addr, argd, data) int (*addr)(); unsigned int argd; object data; */
 /* makefun.c:113:OF */ extern object fSset_key_struct (object key_struct_ind); /* (key_struct_ind) object key_struct_ind; */
-/* makefun.c:122:OF */ extern void SI_makefun (char *strg, object (*fn) (/* ??? */), unsigned int argd); /* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; */
-/* makefun.c:131:OF */ extern void LISP_makefun (char *strg, object (*fn) (/* ??? */), unsigned int argd); /* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; */
+/* /\* makefun.c:122:OF *\/ extern void SI_makefun (char *strg, object (*fn) (/\* ??? *\/), unsigned int argd); /\* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; *\/ */
+/* /\* makefun.c:131:OF *\/ extern void LISP_makefun (char *strg, object (*fn) (/\* ??? *\/), unsigned int argd); /\* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; *\/ */
+/* makefun.c:122:OF */ extern void SI_makefun (char *,void *,unsigned int); /* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; */
+/* makefun.c:131:OF */ extern void LISP_makefun (char *,void *,unsigned int); /* (strg, fn, argd) char *strg; object (*fn)(); unsigned int argd; */
 /* makefun.c:167:OF */ extern object fSinvoke (object x); /* (x) object x; */
 /* mapfun.c:324:OF */ extern void gcl_init_mapfun (void); /* () */
 /* multival.c:32:OF */ extern void Lvalues (void); /* () */
