[SCM] Packaging for pynac branch, master, updated. debian/0.2.6-1-3-gb92cef7

Felix Salfelder felix at salfelder.org
Sun Jul 21 12:04:21 UTC 2013


The following commit has been merged in the master branch:
commit d409e026ae1ec9f0251981e837d6d5d47b6e28ed
Author: Felix Salfelder <felix at salfelder.org>
Date:   Sun Jul 21 13:48:03 2013 +0200

    Imported Upstream version 0.3.0

diff --git a/aclocal.m4 b/aclocal.m4
index b999cf5..b8719db 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -14,8 +14,8 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
-[m4_warning([this file was generated for autoconf 2.68.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
diff --git a/configure b/configure
index fce2c58..4dfb3ac 100755
--- a/configure
+++ b/configure
@@ -1,13 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for pynac 0.2.6.
+# Generated by GNU Autoconf 2.69 for pynac 0.3.0.
 #
 # Report bugs to <<pynac-devel at googlegroups.com>>.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -136,6 +134,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -169,7 +192,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -222,21 +246,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -339,6 +367,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -460,6 +496,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -494,16 +534,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -515,28 +555,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -570,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pynac'
 PACKAGE_TARNAME='pynac'
-PACKAGE_VERSION='0.2.6'
-PACKAGE_STRING='pynac 0.2.6'
+PACKAGE_VERSION='0.3.0'
+PACKAGE_STRING='pynac 0.3.0'
 PACKAGE_BUGREPORT='<pynac-devel at googlegroups.com>'
 PACKAGE_URL=''
 
@@ -1235,8 +1255,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1322,7 +1340,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures pynac 0.2.6 to adapt to many kinds of systems.
+\`configure' configures pynac 0.3.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1392,7 +1410,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pynac 0.2.6:";;
+     short | recursive ) echo "Configuration of pynac 0.3.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1502,10 +1520,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pynac configure 0.2.6
-generated by GNU Autoconf 2.68
+pynac configure 0.3.0
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1581,7 +1599,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1879,7 +1897,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1915,7 +1933,8 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) >= 0)];
-test_array [0] = 0
+test_array [0] = 0;
+return test_array [0];
 
   ;
   return 0;
@@ -1931,7 +1950,8 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0
+test_array [0] = 0;
+return test_array [0];
 
   ;
   return 0;
@@ -1957,7 +1977,8 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) < 0)];
-test_array [0] = 0
+test_array [0] = 0;
+return test_array [0];
 
   ;
   return 0;
@@ -1973,7 +1994,8 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) >= $ac_mid)];
-test_array [0] = 0
+test_array [0] = 0;
+return test_array [0];
 
   ;
   return 0;
@@ -2007,7 +2029,8 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0
+test_array [0] = 0;
+return test_array [0];
 
   ;
   return 0;
@@ -2170,8 +2193,8 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by pynac $as_me 0.2.6, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by pynac $as_me 0.3.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2590,7 +2613,7 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
 	  if test $ac_prog = install &&
 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
@@ -2759,7 +2782,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2799,7 +2822,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2850,7 +2873,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_prog in mkdir gmkdir; do
 	 for ac_exec_ext in '' $ac_executable_extensions; do
-	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
 	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
 	     'mkdir (GNU coreutils) '* | \
 	     'mkdir (coreutils) '* | \
@@ -2903,7 +2926,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2989,7 +3012,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pynac'
- VERSION='0.2.6'
+ VERSION='0.3.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3115,7 +3138,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3155,7 +3178,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3208,7 +3231,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3249,7 +3272,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -3307,7 +3330,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3351,7 +3374,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3797,8 +3820,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -4036,7 +4058,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4501,9 +4523,9 @@ AM_BACKSLASH='\'
 
 
 GINACLIB_MAJOR_VERSION=0
-GINACLIB_MINOR_VERSION=2
-GINACLIB_MICRO_VERSION=6
-GINACLIB_VERSION=0.2.6
+GINACLIB_MINOR_VERSION=3
+GINACLIB_MICRO_VERSION=0
+GINACLIB_VERSION=0.3.0
 
 
 
@@ -4529,7 +4551,7 @@ _ACEOF
 
 
 
-LT_VERSION_INFO="5:1:0"
+LT_VERSION_INFO="0:0:0"
 
 
 
@@ -4562,7 +4584,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4606,7 +4628,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5169,7 +5191,7 @@ do
     for ac_prog in sed gsed; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+      as_fn_executable_p "$ac_path_SED" || continue
 # Check for GNU ac_path_SED and select it if it is found.
   # Check for GNU $ac_path_SED
 case `"$ac_path_SED" --version 2>&1` in
@@ -5245,7 +5267,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -5311,7 +5333,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -5378,7 +5400,7 @@ do
     for ac_prog in fgrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+      as_fn_executable_p "$ac_path_FGREP" || continue
 # Check for GNU ac_path_FGREP and select it if it is found.
   # Check for GNU $ac_path_FGREP
 case `"$ac_path_FGREP" --version 2>&1` in
@@ -5634,7 +5656,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5678,7 +5700,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6097,7 +6119,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6137,7 +6159,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6443,7 +6465,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6483,7 +6505,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6586,7 +6608,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6630,7 +6652,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6755,7 +6777,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6795,7 +6817,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6854,7 +6876,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6894,7 +6916,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7529,7 +7551,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7569,7 +7591,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7649,7 +7671,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7689,7 +7711,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7741,7 +7763,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7781,7 +7803,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_NMEDIT="nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7833,7 +7855,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7873,7 +7895,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_LIPO="lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7925,7 +7947,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7965,7 +7987,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL="otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -8017,7 +8039,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -8057,7 +8079,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL64="otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15757,7 +15779,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AS="${ac_tool_prefix}as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15797,7 +15819,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AS="as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15849,7 +15871,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15889,7 +15911,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15941,7 +15963,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15981,7 +16003,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -16383,7 +16405,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_RM="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -16846,16 +16868,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -16915,28 +16937,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -16957,8 +16967,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by pynac $as_me 0.2.6, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by pynac $as_me 0.3.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -17023,11 +17033,11 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-pynac config.status 0.2.6
-configured by $0, generated by GNU Autoconf 2.68,
+pynac config.status 0.3.0
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -17118,7 +17128,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
diff --git a/configure.ac b/configure.ac
index 2970144..b2b718c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,12 +11,12 @@ dnl if backwards compatibility has been broken,
 dnl set ginac_binary_age and ginac_interface_age to 0.
 
 m4_define([ginac_major_version], [0])
-m4_define([ginac_minor_version], [2])
-m4_define([ginac_micro_version], [6])
+m4_define([ginac_minor_version], [3])
+m4_define([ginac_micro_version], [0])
 m4_define([ginac_version], [ginac_major_version.ginac_minor_version.ginac_micro_version])
 m4_define([ginac_release], [ginac_major_version.ginac_minor_version])
-m4_define([ginac_interface_age], [1])
-m4_define([ginac_binary_age], [1])
+m4_define([ginac_interface_age], [0])
+m4_define([ginac_binary_age], [0])
 
 AC_INIT([pynac], ginac_version, [<pynac-devel at googlegroups.com>])
 AC_PREREQ(2.59)
diff --git a/ginac/Makefile.am b/ginac/Makefile.am
index 26db0c4..3a9e6b6 100644
--- a/ginac/Makefile.am
+++ b/ginac/Makefile.am
@@ -9,7 +9,7 @@ libpynac_la_SOURCES = py_funcs.cpp add.cpp archive.cpp basic.cpp clifford.cpp co
   operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \
   pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \
   utils.cpp wildcard.cpp \
-  remember.h tostring.h utils.h compiler.h
+  remember.h tostring.h utils.h compiler.h order.cpp
 
 #The -no-undefined breaks Pynac on OS X 10.4.  See #9135
 if CYGWIN
@@ -26,5 +26,5 @@ ginacinclude_HEADERS = ginac.h py_funcs.h add.h archive.h assertion.h basic.h cl
   exprseq.h fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h \
   inifcns.h integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \
   power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \
-  symbol.h symmetry.h tensor.h version.h wildcard.h
+  symbol.h symmetry.h tensor.h version.h wildcard.h order.h
 EXTRA_DIST = version.h.in
diff --git a/ginac/Makefile.in b/ginac/Makefile.in
index 32da4f3..3dafc54 100644
--- a/ginac/Makefile.in
+++ b/ginac/Makefile.in
@@ -117,7 +117,7 @@ am_libpynac_la_OBJECTS = libpynac_la-py_funcs.lo libpynac_la-add.lo \
 	libpynac_la-pseries.lo libpynac_la-print.lo \
 	libpynac_la-symbol.lo libpynac_la-symmetry.lo \
 	libpynac_la-tensor.lo libpynac_la-utils.lo \
-	libpynac_la-wildcard.lo
+	libpynac_la-wildcard.lo libpynac_la-order.lo
 libpynac_la_OBJECTS = $(am_libpynac_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
@@ -322,7 +322,7 @@ libpynac_la_SOURCES = py_funcs.cpp add.cpp archive.cpp basic.cpp clifford.cpp co
   operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \
   pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \
   utils.cpp wildcard.cpp \
-  remember.h tostring.h utils.h compiler.h
+  remember.h tostring.h utils.h compiler.h order.cpp
 
 @CYGWIN_FALSE at libpynac_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
 
@@ -336,7 +336,7 @@ ginacinclude_HEADERS = ginac.h py_funcs.h add.h archive.h assertion.h basic.h cl
   exprseq.h fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h \
   inifcns.h integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \
   power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \
-  symbol.h symmetry.h tensor.h version.h wildcard.h
+  symbol.h symmetry.h tensor.h version.h wildcard.h order.h
 
 EXTRA_DIST = version.h.in
 all: all-am
@@ -444,6 +444,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-normal.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-numeric.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-operators.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-order.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-power.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-print.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpynac_la-pseries.Plo at am__quote@
@@ -758,6 +759,13 @@ libpynac_la-wildcard.lo: wildcard.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpynac_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libpynac_la-wildcard.lo `test -f 'wildcard.cpp' || echo '$(srcdir)/'`wildcard.cpp
 
+libpynac_la-order.lo: order.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpynac_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libpynac_la-order.lo -MD -MP -MF $(DEPDIR)/libpynac_la-order.Tpo -c -o libpynac_la-order.lo `test -f 'order.cpp' || echo '$(srcdir)/'`order.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpynac_la-order.Tpo $(DEPDIR)/libpynac_la-order.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='order.cpp' object='libpynac_la-order.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpynac_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libpynac_la-order.lo `test -f 'order.cpp' || echo '$(srcdir)/'`order.cpp
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/ginac/add.cpp b/ginac/add.cpp
index 689e5b5..b44e37f 100644
--- a/ginac/add.cpp
+++ b/ginac/add.cpp
@@ -31,6 +31,7 @@
 #include "constant.h"
 #include "infinity.h"
 #include "compiler.h"
+#include "order.h"
 
 #include <sstream>
 #include <iostream>
@@ -127,8 +128,9 @@ void add::print_add(const print_context & c, unsigned level, bool latex) const
 	numeric coeff;
 	bool first = true;
 
+	const epvector & sorted_seq = get_sorted_seq();
 	// Then proceed with the remaining factors
-	epvector::const_iterator it = seq.begin(), itend = seq.end();
+	epvector::const_iterator it = sorted_seq.begin(), itend = sorted_seq.end();
 	while (it != itend) {
 		std::stringstream tstream;
 		print_context *tcontext_p;
@@ -695,4 +697,25 @@ ex add::expand(unsigned options) const
 	return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
 }
 
+const epvector & add::get_sorted_seq() const
+{
+	if (seq_sorted.empty() and not seq.empty()) {
+		seq_sorted = epvector(seq.size());
+		partial_sort_copy(seq.begin(), seq.end(),
+				  seq_sorted.begin(), seq_sorted.end(),
+				  print_order_pair());
+	}
+	return expairseq::get_sorted_seq();
+}
+
+ex add::lead_coeff() const {
+	// if sorted_seq was computed before, we don't have to search
+	if (seq_sorted.empty() and not seq.empty()) {
+		return min_element(seq.begin(), seq.end(),
+				print_order_pair())->coeff;
+	} else {
+		return seq_sorted.begin()->coeff;
+	}
+}
+
 } // namespace GiNaC
diff --git a/ginac/add.h b/ginac/add.h
index c37625c..fb1d13d 100644
--- a/ginac/add.h
+++ b/ginac/add.h
@@ -63,6 +63,8 @@ public:
 	ex imag_part() const;
 	exvector get_free_indices() const;
 	ex eval_ncmul(const exvector & v) const;
+	const epvector & get_sorted_seq() const;
+	ex lead_coeff() const;
 protected:
 	ex derivative(const symbol & s) const;
 	unsigned return_type() const;
diff --git a/ginac/basic.cpp b/ginac/basic.cpp
index ce788df..3aa1415 100644
--- a/ginac/basic.cpp
+++ b/ginac/basic.cpp
@@ -588,7 +588,7 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
 
 		// Otherwise the subexpressions must match one-to-one
 		for (size_t i=0; i<nops(); i++)
-			if (!op(i).match(pattern.op(i), repl_lst))
+			if (!op(i).match(pattern.sorted_op(i), repl_lst))
 				return false;
 
 		// Looks similar enough, match found
@@ -832,53 +832,39 @@ int basic::compare(const basic & other) const
 #ifdef GINAC_COMPARE_STATISTICS
 	compare_statistics.total_basic_compares++;
 #endif
-	static const tinfo_t function_id = find_tinfo_key("function");
-	static const tinfo_t fderivative_id = find_tinfo_key("fderivative");
-	const tinfo_t typeid_this = tinfo();
-	const tinfo_t typeid_other = other.tinfo();
-
-	// SAGE: If we want orderings to make any sense, it only
-	// makes sense to compare using the hashes when the types
-	// are the same.  WARNING -- doing this *will* presumably
-	// have negative performance implications.
-	/*	if (typeid_this==typeid_other) {
-	  const unsigned hash_this = gethash();
-	  const unsigned hash_other = other.gethash();
-	  if (hash_this<hash_other) return -1;
-	  if (hash_this>hash_other) return 1;
-	}
-	*/
-
+	const unsigned hash_this = gethash();
+	const unsigned hash_other = other.gethash();
+	if (hash_this<hash_other) return -1;
+	if (hash_this>hash_other) return 1;
 #ifdef GINAC_COMPARE_STATISTICS
 	compare_statistics.compare_same_hashvalue++;
 #endif
 
-	if (typeid_this==typeid_other) {
-		GINAC_ASSERT(typeid(*this)==typeid(other));
-// 		int cmpval = compare_same_type(other);
-// 		if (cmpval!=0) {
-// 			std::cout << "hash collision, same type: " 
-// 			          << *this << " and " << other << std::endl;
-// 			this->print(print_tree(std::cout));
-// 			std::cout << " and ";
-// 			other.print(print_tree(std::cout));
-// 			std::cout << std::endl;
-// 		}
-// 		return cmpval;
+	const tinfo_t& typeid_this = tinfo();//typeid(*this);
+	const tinfo_t& typeid_other = other.tinfo();//typeid(other);
+	if (typeid_this == typeid_other) {
+//		int cmpval = compare_same_type(other);
+//		if (cmpval!=0) {
+//			std::cout << "hash collision, same type: " 
+//			          << *this << " and " << other << std::endl;
+//			this->print(print_tree(std::cout));
+//			std::cout << " and ";
+//			other.print(print_tree(std::cout));
+//			std::cout << std::endl;
+//		}
+//		return cmpval;
 #ifdef GINAC_COMPARE_STATISTICS
 		compare_statistics.compare_same_type++;
 #endif
 		return compare_same_type(other);
-	} else if (typeid_other == function_id ||
-			typeid_other == fderivative_id) {
-		return -1;
 	} else {
-// 		std::cout << "hash collision, different types: " 
-// 		          << *this << " and " << other << std::endl;
-// 		this->print(print_tree(std::cout));
-// 		std::cout << " and ";
-// 		other.print(print_tree(std::cout));
-// 		std::cout << std::endl;
+//		std::cout << "hash collision, different types: " 
+//		          << *this << " and " << other << std::endl;
+//		this->print(print_tree(std::cout));
+//		std::cout << " and ";
+//	 	other.print(print_tree(std::cout));
+//	 	std::cout << std::endl;
+		//return (typeid_this.before(typeid_other) ? -1 : 1);
 		return (typeid_this<typeid_other ? -1 : 1);
 	}
 }
diff --git a/ginac/basic.h b/ginac/basic.h
index 465dfb3..dbe258a 100644
--- a/ginac/basic.h
+++ b/ginac/basic.h
@@ -108,7 +108,8 @@ class basic : public refcounted
 	GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(basic, void)
 	
 	friend class ex;
-	
+	friend struct print_order;
+	friend struct print_order_pair;
 	// default constructor, destructor, copy constructor and assignment operator
 protected:
 	basic() : tinfo_key(&tinfo_static), flags(0) {}
diff --git a/ginac/container.h b/ginac/container.h
index ec5a1ba..948dee3 100644
--- a/ginac/container.h
+++ b/ginac/container.h
@@ -129,6 +129,8 @@ template <template <class T, class = std::allocator<T> > class C>
 class container : public basic, public container_storage<C> {
 	GINAC_DECLARE_REGISTERED_CLASS(container, basic)
 
+	friend struct print_order;
+
 protected:
 	typedef typename container_storage<C>::STLT STLT;
 
diff --git a/ginac/ex.cpp b/ginac/ex.cpp
index 555a94a..276ccf0 100644
--- a/ginac/ex.cpp
+++ b/ginac/ex.cpp
@@ -278,6 +278,13 @@ size_t ex::nsymbols() const
 	return res;
 }
 
+ex ex::sorted_op(size_t i) const
+{
+	if (is_a<expairseq>(*this))
+		return dynamic_cast<const expairseq&>(*bp).stable_op(i);
+	else
+		return bp->op(i);
+}
 // private
 
 /** Make this ex writable (if more than one ex handle the same basic) by 
@@ -597,5 +604,5 @@ basic & ex::construct_from_pyobject(PyObject* o)
 
 // none
 
-
+//
 } // namespace GiNaC
diff --git a/ginac/ex.h b/ginac/ex.h
index 4e954ee..d8122f5 100644
--- a/ginac/ex.h
+++ b/ginac/ex.h
@@ -83,6 +83,9 @@ class ex {
 	template<class T> friend inline bool is_a(const ex &);
 	template<class T> friend inline bool is_exactly_a(const ex &);
 	
+	friend struct print_order;
+	friend struct print_order_mul;
+	friend struct print_order_pair;
 	// default constructor, copy constructor and assignment operator
 public:
 	ex() throw();
@@ -142,6 +145,7 @@ public:
 	size_t nops() const { return bp->nops(); }
 	size_t nsymbols() const;
 	ex op(size_t i) const { return bp->op(i); }
+	ex sorted_op(size_t i) const;
 	ex operator[](const ex & index) const { return (*bp)[index]; }
 	ex operator[](size_t i) const { return (*bp)[i]; }
 	ex & let_op(size_t i);
@@ -706,6 +710,7 @@ struct ex_swap : public std::binary_function<ex, ex, void> {
 	void operator() (ex &lh, ex &rh) const { lh.swap(rh); }
 };
 
+
 // Make it possible to print exvectors and exmaps
 std::ostream & operator<<(std::ostream & os, const exvector & e);
 std::ostream & operator<<(std::ostream & os, const exset & e);
diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp
index 861ee0b..ebcb333 100644
--- a/ginac/expairseq.cpp
+++ b/ginac/expairseq.cpp
@@ -309,6 +309,15 @@ ex expairseq::op(size_t i) const
 	return overall_coeff;
 }
 
+ex expairseq::stable_op(size_t i) const
+{
+	if (i < seq.size()) {
+		return recombine_pair_to_ex(get_sorted_seq()[i]);
+	}
+	GINAC_ASSERT(!overall_coeff.is_equal(default_overall_coeff()));
+	return overall_coeff;
+}
+
 ex expairseq::map(map_function &f) const
 {
 	std::auto_ptr<epvector> v(new epvector);
@@ -392,9 +401,9 @@ bool expairseq::match(const ex & pattern, lst & repl_lst) const
 		bool has_global_wildcard = false;
 		ex global_wildcard;
 		for (size_t i=0; i<pattern.nops(); i++) {
-			if (is_exactly_a<wildcard>(pattern.op(i))) {
+			if (is_exactly_a<wildcard>(pattern.sorted_op(i))) {
 				has_global_wildcard = true;
-				global_wildcard = pattern.op(i);
+				global_wildcard = pattern.sorted_op(i);
 				break;
 			}
 		}
@@ -406,12 +415,12 @@ bool expairseq::match(const ex & pattern, lst & repl_lst) const
 		exvector ops;
 		ops.reserve(nops());
 		for (size_t i=0; i<nops(); i++)
-			ops.push_back(op(i));
+			ops.push_back(stable_op(i));
 
 		// Now, for every term of the pattern, look for a matching term in
 		// the expression and remove the match
 		for (size_t i=0; i<pattern.nops(); i++) {
-			ex p = pattern.op(i);
+			ex p = ex_to<expairseq>(pattern).stable_op(i);
 			if (has_global_wildcard && p.is_equal(global_wildcard))
 				continue;
 			exvector::iterator it = ops.begin(), itend = ops.end();
@@ -492,46 +501,48 @@ int expairseq::compare_same_type(const basic &other) const
 {
 	GINAC_ASSERT(is_a<expairseq>(other));
 	const expairseq &o = static_cast<const expairseq &>(other);
-	
+
 	int cmpval;
-	
+
 	// compare number of elements
 	if (seq.size() != o.seq.size())
 		return (seq.size()<o.seq.size()) ? -1 : 1;
 
+	// compare overall_coeff
+	cmpval = overall_coeff.compare(o.overall_coeff);
+	if (cmpval!=0)
+		return cmpval;
+
 #if EXPAIRSEQ_USE_HASHTAB
 	GINAC_ASSERT(hashtabsize==o.hashtabsize);
 	if (hashtabsize==0) {
 #endif // EXPAIRSEQ_USE_HASHTAB
+
 		epvector::const_iterator cit1 = seq.begin();
 		epvector::const_iterator cit2 = o.seq.begin();
 		epvector::const_iterator last1 = seq.end();
 		epvector::const_iterator last2 = o.seq.end();
 
 		for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
-			cmpval = (*cit2).compare(*cit1);
+			cmpval = (*cit1).compare(*cit2);
 			if (cmpval!=0) return cmpval;
 		}
 
 		GINAC_ASSERT(cit1==last1);
 		GINAC_ASSERT(cit2==last2);
-	
-		// compare overall_coeff
-		cmpval = overall_coeff.compare(o.overall_coeff);
-		if (cmpval!=0)
-			return cmpval;
-	
+
 		return 0;
+
 #if EXPAIRSEQ_USE_HASHTAB
 	}
-	
+
 	// compare number of elements in each hashtab entry
 	for (unsigned i=0; i<hashtabsize; ++i) {
 		unsigned cursize=hashtab[i].size();
 		if (cursize != o.hashtab[i].size())
 			return (cursize < o.hashtab[i].size()) ? -1 : 1;
 	}
-	
+
 	// compare individual (sorted) hashtab entries
 	for (unsigned i=0; i<hashtabsize; ++i) {
 		unsigned sz = hashtab[i].size();
@@ -549,7 +560,6 @@ int expairseq::compare_same_type(const basic &other) const
 			}
 		}
 	}
-	
 	return 0; // equal
 #endif // EXPAIRSEQ_USE_HASHTAB
 }
@@ -1770,6 +1780,15 @@ std::auto_ptr<epvector> expairseq::subschildren(const exmap & m, unsigned option
 	return std::auto_ptr<epvector>(0);
 }
 
+
+const epvector & expairseq::get_sorted_seq() const
+{
+	if (seq_sorted.empty())
+		return seq;
+	else
+		return seq_sorted;
+}
+
 //////////
 // static member variables
 //////////
diff --git a/ginac/expairseq.h b/ginac/expairseq.h
index 3dae409..fd4df4c 100644
--- a/ginac/expairseq.h
+++ b/ginac/expairseq.h
@@ -1,3 +1,4 @@
+
 /** @file expairseq.h
  *
  *  Interface to sequences of expression pairs. */
@@ -38,7 +39,7 @@ namespace GiNaC {
  *  combining n terms into one large sum (or n terms into one large product)
  *  from O(n*log(n)) to about O(n).  There are, however, several drawbacks.
  *  The constant in front of O(n) is quite large, when copying such an object
- *  one also has to copy the has table, comparison is quite expensive because
+ *  one also has to copy the hash table, comparison is quite expensive because
  *  there is no ordering any more, it doesn't help at all when combining two
  *  expairseqs because due to the presorted nature the behaviour would be
  *  O(n) anyways, the code is quite messy, etc, etc.  The code is here as
@@ -67,6 +68,7 @@ class expairseq : public basic
 {
 	GINAC_DECLARE_REGISTERED_CLASS(expairseq, basic)
 
+	friend struct print_order;
 	// other constructors
 public:
 	expairseq(const ex & lh, const ex & rh);
@@ -80,6 +82,7 @@ public:
 	bool info(unsigned inf) const;
 	size_t nops() const;
 	ex op(size_t i) const;
+	virtual ex stable_op(size_t i) const;
 	ex map(map_function & f) const;
 	ex eval(int level=0) const;
 	ex to_rational(exmap & repl) const;
@@ -88,6 +91,7 @@ public:
 	ex subs(const exmap & m, unsigned options = 0) const;
 	ex conjugate() const;
 	numeric calc_total_degree() const;
+	virtual const epvector & get_sorted_seq() const;
 protected:
 	bool is_equal_same_type(const basic & other) const;
 	unsigned return_type() const;
@@ -161,6 +165,7 @@ protected:
 	
 protected:
 	epvector seq;
+	mutable epvector seq_sorted;
 	ex overall_coeff;
 #if EXPAIRSEQ_USE_HASHTAB
 	epplistvector hashtab;
diff --git a/ginac/fderivative.h b/ginac/fderivative.h
index 4b598ec..184703f 100644
--- a/ginac/fderivative.h
+++ b/ginac/fderivative.h
@@ -40,6 +40,7 @@ class fderivative : public function
 {
 	GINAC_DECLARE_REGISTERED_CLASS(fderivative, function)
 
+	friend struct print_order;
 	// other constructors
 public:
 	/** Construct derivative with respect to one parameter.
diff --git a/ginac/function.cpp b/ginac/function.cpp
index cfe4084..0432471 100644
--- a/ginac/function.cpp
+++ b/ginac/function.cpp
@@ -1196,6 +1196,7 @@ ex function::derivative(const symbol & s) const
 	return result;
 }
 
+/*
 int function::compare(const basic& other) const
 {
 	static const tinfo_t function_id = find_tinfo_key("function");
@@ -1213,6 +1214,7 @@ int function::compare(const basic& other) const
 		return 1;
 	}
 }
+*/
 
 int function::compare_same_type(const basic & other) const
 {
@@ -1225,6 +1227,7 @@ int function::compare_same_type(const basic & other) const
 		return exprseq::compare_same_type(o);
 }
 
+
 bool function::is_equal_same_type(const basic & other) const
 {
 	GINAC_ASSERT(is_a<function>(other));
diff --git a/ginac/function.h b/ginac/function.h
index 42a3658..8e8f94b 100644
--- a/ginac/function.h
+++ b/ginac/function.h
@@ -310,6 +310,7 @@ class function : public exprseq
 {
 	GINAC_DECLARE_REGISTERED_CLASS(function, exprseq)
 
+	friend struct print_order;
 	// CINT has a linking problem
 #ifndef __MAKECINT__
 	friend void ginsh_get_ginac_functions();
@@ -347,7 +348,7 @@ public:
 	ex conjugate() const;
 	ex real_part() const;
 	ex imag_part() const;
-	int compare(const basic &other) const;
+	//int compare(const basic &other) const;
 protected:
 	ex derivative(const symbol & s) const;
 	bool is_equal_same_type(const basic & other) const;
diff --git a/ginac/mul.cpp b/ginac/mul.cpp
index a8456d1..4eadfab 100644
--- a/ginac/mul.cpp
+++ b/ginac/mul.cpp
@@ -34,12 +34,13 @@
 #include "infinity.h"
 #include "function.h"
 #include "inifcns.h"
+#include "order.h"
 
 #include <iostream>
 #include <vector>
+#include <cmath>
 #include <stdexcept>
 #include <limits>
-#include <cmath>
 #include <sstream>
 #ifdef DO_GINAC_ASSERT
 #  include <typeinfo>
@@ -261,7 +262,8 @@ void mul::do_print_rat_func(const print_context & c, unsigned level,
 
 	// Separate factors into those with negative numeric exponent
 	// and all others
-	epvector::const_iterator it = seq.begin(), itend = seq.end();
+	const epvector & sorted_seq = get_sorted_seq();
+	epvector::const_iterator it = sorted_seq.begin(), itend = sorted_seq.end();
 	exvector neg_powers, others;
 	while (it != itend) {
 		GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
@@ -694,9 +696,13 @@ ex mul::eval(int level) const
 			// XXX: What is the best way to check if the polynomial is a primitive? 
 			numeric c = i->rest.integer_content();
 			const numeric lead_coeff =
-				ex_to<numeric>(ex_to<add>(i->rest).seq.begin()->coeff).div(c);
+				ex_to<numeric>(ex_to<add>(i->rest).\
+						lead_coeff()).div(c);
 			const bool canonicalizable = lead_coeff.is_integer();
 
+			// The following comment is no longer true for pynac.
+			// We use the print order to determine the main variable
+			// This order is not random.
 			// XXX: The main variable is chosen in a random way, so this code 
 			// does NOT transform the term into the canonical form (thus, in some
 			// very unlucky event it can even loop forever). Hopefully the main
@@ -733,6 +739,7 @@ ex mul::eval(int level) const
 			primitive->setflag(status_flags::dynallocated);
 			primitive->clearflag(status_flags::hash_calculated);
 			primitive->overall_coeff = ex_to<numeric>(primitive->overall_coeff).div_dyn(c);
+			primitive->seq_sorted.resize(0);
 			for (epvector::iterator ai = primitive->seq.begin();
 					ai != primitive->seq.end(); ++ai)
 				ai->coeff = ex_to<numeric>(ai->coeff).div_dyn(c);
@@ -979,7 +986,8 @@ bool algebraic_match_mul_with_mul(const mul &e, const ex &pat, lst &repls,
 			continue;
 		lst newrepls = repls;
 		int newnummatches = nummatches;
-		if (tryfactsubs(e.op(i), pat.op(factor), newnummatches, newrepls)) {
+		if (tryfactsubs(e.op(i), pat.op(factor),
+					newnummatches, newrepls)) {
 			matched[i] = true;
 			if (algebraic_match_mul_with_mul(e, pat, newrepls, factor+1,
 					newnummatches, subsed, matched)) {
@@ -1127,6 +1135,8 @@ ex mul::derivative(const symbol & s) const
 	return (new add(addseq))->setflag(status_flags::dynallocated);
 }
 
+/** Total degree of a mul object.
+ Beware that symbolic exponents are wrapped inside pow objects with 1 as coeff. */
 double mul::total_degree() const
 {
 	if (flags & status_flags::tdegree_calculated) {
@@ -1142,118 +1152,9 @@ double mul::total_degree() const
 	return tdegree;
 }
 
-int mul::compare(const basic& other) const
-{
-	static const tinfo_t function_id = find_tinfo_key("function");
-	static const tinfo_t fderivative_id = find_tinfo_key("fderivative");
-	static const tinfo_t pow_id = find_tinfo_key("power");
-	static const tinfo_t symbol_id = find_tinfo_key("symbol");
-	const tinfo_t typeid_this = tinfo();
-	const tinfo_t typeid_other = other.tinfo();
-	if (typeid_this==typeid_other) {
-		GINAC_ASSERT(typeid(*this)==typeid(other));
-		return compare_same_type(other);
-	} else if (typeid_other == pow_id) {
-		return compare_pow(static_cast<const power&>(other));
-	} else if (typeid_other == symbol_id) {
-		return compare_symbol(static_cast<const symbol&>(other));
-	} else if (typeid_other == function_id ||
-			typeid_other == fderivative_id) {
-		return -1;
-	} else {
-		return (typeid_this<typeid_other ? -1 : 1);
-	}
-}
-
-int mul::compare_symbol(const symbol &other) const
-{
-	int cmpval;
-	double tdeg;
-	tdeg = total_degree();
-	if (tdeg == 1) {
-		cmpval = seq[0].rest.compare(other);
-		if (cmpval != 0) {
-			return cmpval;
-		}
-		cmpval = _ex1.compare(seq[0].coeff);
-		if (cmpval != 0) {
-			return cmpval;
-		}
-		return -1;
-	}
-	return tdeg > 1 ? -1 : 1;
-}
-
-// compare this to a pow object
-// first we compare degrees
-// if equal we compare the first item in the sequence to the base in other
-int mul::compare_pow(const power &other) const
-{
-	double my_deg = total_degree();
-	double odeg;
-	numeric oexp;
-	int cmpval = 0;
-	if (is_a<numeric>(other.exponent)) {
-		numeric oexp = ex_to<numeric>(other.exponent);
-		if (oexp.is_real()) {
-			odeg = oexp.to_double();
-		} else {
-			odeg = std::sqrt(std::pow(oexp.real().to_double(), 2) + 
-					std::pow(oexp.imag().to_double(), 2));
-		}
-		if (odeg != my_deg)
-			return my_deg < odeg ? 1 : -1;
-	} else {
-		cmpval = seq[0].coeff.compare(other.exponent);
-		if (cmpval != 0)
-			return cmpval;
-	}
-	cmpval = seq[0].rest.compare(other.basis);
-	if (cmpval != 0) {
-		return cmpval;
-	}
-	if (seq.size() == 1 && overall_coeff.is_equal(_ex1))
-		return 0;
-	return 1;
-}
-
-
 int mul::compare_same_type(const basic & other) const
 {
-	int cmpval;
-
-	const mul &o = static_cast<const mul &>(other);
-
-	// compare total degrees
-	double deg1 = total_degree();
-	double deg2 = o.total_degree();
-	if (deg1 != deg2)
-		return deg1 < deg2 ? 1 : -1;
-
-	// compare each item in this product to correnponding element in other
-	epvector::const_iterator cit1 = seq.begin();
-	epvector::const_iterator cit2 = o.seq.begin();
-	epvector::const_iterator last1 = seq.end();
-	epvector::const_iterator last2 = o.seq.end();
-
-	for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
-		cmpval = (*cit1).compare(*cit2);
-		if (cmpval != 0)
-			return cmpval;
-	}
-
-	// compare sizes
-	if (cit1 != last1) 
-		return 1;
-	else if (cit2 != last2)
-		return -1;
-
-	// compare overall_coeff
-	cmpval = overall_coeff.compare(o.overall_coeff);
-	if (cmpval!=0)
-		return cmpval;
-
-	return 0;
+	return inherited::compare_same_type(other);
 }
 
 unsigned mul::return_type() const
@@ -1595,6 +1496,17 @@ ex mul::expand(unsigned options) const
 	}
 }
 
+const epvector & mul::get_sorted_seq() const
+{
+	if (seq_sorted.empty() and not seq.empty()) {
+		seq_sorted = epvector(seq.size());
+		partial_sort_copy(seq.begin(), seq.end(),
+				  seq_sorted.begin(), seq_sorted.end(),
+				  print_order_pair_mul());
+	}
+	return expairseq::get_sorted_seq();
+}
+
   
 //////////
 // new virtual functions which can be overridden by derived classes
diff --git a/ginac/mul.h b/ginac/mul.h
index f3cefe7..a1639ad 100644
--- a/ginac/mul.h
+++ b/ginac/mul.h
@@ -33,6 +33,7 @@ class mul : public expairseq
 {
 	GINAC_DECLARE_REGISTERED_CLASS(mul, expairseq)
 	
+	friend struct print_order;
 	friend class add;
 	friend class ncmul;
 	friend class power;
@@ -85,7 +86,7 @@ protected:
 	bool can_make_flat(const expair & p) const;
 	ex expand(unsigned options=0) const;
 	void find_real_imag(ex&, ex&) const;
-	int compare(const basic& other) const;
+	//int compare(const basic& other) const;
 	
 	ex eval_infinity(epvector::const_iterator infinity_iter) const;
 	ex eval_exponentials() const;
@@ -97,8 +98,9 @@ protected:
 public:
 	ex algebraic_subs_mul(const exmap & m, unsigned options) const;
 	double total_degree() const;
-	int compare_symbol(const symbol &other) const;
-	int compare_pow(const power &other) const;
+	const epvector & get_sorted_seq() const;
+	//int compare_symbol(const symbol &other) const;
+	//int compare_pow(const power &other) const;
 protected:
 	void print_overall_coeff(const ex coeff_ex, const print_context & c,
 			const char *mul_sym, bool latex=false) const;
diff --git a/ginac/normal.cpp b/ginac/normal.cpp
index f1d0d02..4ce68b2 100644
--- a/ginac/normal.cpp
+++ b/ginac/normal.cpp
@@ -98,7 +98,7 @@ static bool get_first_symbol(const ex &e, ex &x)
 		return true;
 	} else if (is_exactly_a<add>(e) || is_exactly_a<mul>(e)) {
 		for (size_t i=0; i<e.nops(); i++)
-			if (get_first_symbol(e.op(i), x))
+			if (get_first_symbol(e.sorted_op(i), x))
 				return true;
 	} else if (is_exactly_a<power>(e)) {
 		if (get_first_symbol(e.op(0), x))
@@ -174,7 +174,7 @@ static void collect_symbols(const ex &e, sym_desc_vec &v)
 		add_symbol(e, v);
 	} else if (is_exactly_a<add>(e) || is_exactly_a<mul>(e)) {
 		for (size_t i=0; i<e.nops(); i++)
-			collect_symbols(e.op(i), v);
+			collect_symbols(e.sorted_op(i), v);
 	} else if (is_exactly_a<power>(e)) {
 		collect_symbols(e.op(0), v);
 	}
diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp
index df143e2..c641ef9 100644
--- a/ginac/numeric.cpp
+++ b/ginac/numeric.cpp
@@ -236,6 +236,7 @@ std::ostream& operator << (std::ostream& os, const Number_T& s) {
         return x.v._pyobject;
 
       default:
+	std::cout << x.t <<std::endl;
 	stub("Number_T_to_pyobject -- not able to do conversion to pyobject; everything else will be nonsense");
 	return 0;
       }
diff --git a/ginac/numeric.h b/ginac/numeric.h
index f054250..0040cae 100644
--- a/ginac/numeric.h
+++ b/ginac/numeric.h
@@ -208,7 +208,6 @@ namespace GiNaC {
   class numeric : public basic
   {
     GINAC_DECLARE_REGISTERED_CLASS(numeric, basic)
-	
     // member functions
 	
     // other constructors
diff --git a/ginac/order.cpp b/ginac/order.cpp
new file mode 100644
index 0000000..ec1b92f
--- /dev/null
+++ b/ginac/order.cpp
@@ -0,0 +1,675 @@
+/** @file order.cpp
+ *
+ *  Definitions of order used for printing. */
+
+/*
+ *   Copyright (C) 2011 Burcin Erocal <burcin at erocal.org>
+ *   Copyright (C) 2011 Jean-Pierre Flori <flori at enst.fr>
+ *
+ *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "order.h"
+#include "registrar.h"
+#include "utils.h"
+
+#include <cmath>
+#include <iostream>
+
+namespace GiNaC {
+
+double numeric_to_double(const numeric& exp)
+{
+	if (exp.is_real())
+		return exp.to_double();
+	else 
+		return std::sqrt(std::pow(exp.real().to_double(), 2) + 
+				 std::pow(exp.imag().to_double(), 2));
+}
+
+
+// Methods to get type id's. These cannot be const static because the
+// id's are set by another static initializer.
+  
+const tinfo_t & print_order::function_id() const
+{
+	static tinfo_t id = find_tinfo_key("function");
+	return id;
+}
+
+const tinfo_t & print_order::fderivative_id() const
+{
+	static tinfo_t id = find_tinfo_key("fderivative");
+	return id;
+}
+
+const tinfo_t & print_order::power_id() const
+{
+	static tinfo_t id = find_tinfo_key("power");
+	return id;
+}
+
+const tinfo_t & print_order::symbol_id() const
+{
+	static tinfo_t id = find_tinfo_key("symbol");
+	return id;
+}
+
+const tinfo_t & print_order::mul_id() const
+{
+	static tinfo_t id = find_tinfo_key("mul");
+	return id;
+}
+
+const tinfo_t & print_order::add_id() const
+{
+	static tinfo_t id = find_tinfo_key("add");
+	return id;
+}
+
+const tinfo_t & print_order::numeric_id() const
+{
+	static tinfo_t id = find_tinfo_key("numeric");
+	return id;
+}
+
+const tinfo_t & print_order::constant_id() const
+{
+	static tinfo_t id = find_tinfo_key("constant");
+	return id;
+}
+
+const tinfo_t & print_order::wildcard_id() const
+{
+	static tinfo_t id = find_tinfo_key("wildcard");
+	return id;
+}
+
+
+/** What Sage does for printing:
+ To print multivariate polynomials, SAGE uses "reversed" (bigger terms first)
+ 'degrevlex' order i.e. "reversed" graded reversed lexicographic order, the
+ lexicographic order is defined below.  The variables are ordered according to
+ their "creation" order i.e PR.<x,a,t> = PolynomialRing(QQ) gives x > a > t and
+ x+t+a is printed x + a + t
+*/
+
+/** Returns true if lhex > rhex for 'degrevlex' of Sage
+ i.e. graded reversed lexicographic order
+*/
+bool print_order::operator() (const ex &lhex, const ex &rhex) const 
+{
+	return compare(lhex, rhex) == 1;
+}
+
+int print_order::compare(const ex &lhex, const ex &rhex) const 
+{
+	return compare(*lhex.bp, *rhex.bp);
+}
+
+bool print_order_pair_mul::operator() (const expair &lhex, const expair &rhex) const
+{
+	int cmpval = print_order_mul().compare(lhex.rest, rhex.rest);
+	if (cmpval != 0) {
+		return cmpval == 1;
+	}
+	return compare_degrees(lhex, rhex);
+}
+
+bool print_order_pair::operator() (const expair &lhex, const expair &rhex) const
+{
+	// compare rests
+	int cmpval = print_order().compare(lhex.rest, rhex.rest);
+	if (cmpval != 0) {
+		return cmpval == 1;
+	}
+	return compare_degrees(lhex, rhex);
+}
+
+bool print_order_pair::compare_degrees(const expair &lhex, const expair &rhex) const
+{
+	// compare coeffs which are numerics
+	double lh_deg = numeric_to_double(ex_to<numeric>(lhex.coeff));
+	double rh_deg = numeric_to_double(ex_to<numeric>(rhex.coeff));
+
+	return lh_deg > rh_deg;	
+}
+
+/** Comparison functions:
+ They should implement 'degrevlex' of Sage
+ i.e. graded reversed lexicographic order
+ The lexicographic order is the "natural" one on strings:
+ a > b > ... > x > y > ... ?
+*/
+
+/** Return values for comparison functions :
+ compare(a,b) should return :
+ -1 if a < b
+ 0 if a == b
+ 1 if a > b
+ as <=> in Perl and GiNaC internal functions
+*/
+int print_order::compare(const basic &lh, const basic &rh) const 
+{
+	const tinfo_t typeid_lh = lh.tinfo();
+	const tinfo_t typeid_rh = rh.tinfo();
+
+	if (typeid_rh==typeid_lh)
+		if (typeid_rh == mul_id())
+			return compare_same_type_mul(static_cast<const mul&>(lh),
+						     static_cast<const mul&>(rh));
+		else if (typeid_rh == add_id())
+			return compare_same_type_add(
+						     static_cast<const add&>(lh),
+						     static_cast<const add&>(rh));
+		else if (typeid_rh == symbol_id())
+			return compare_same_type_symbol(static_cast<const symbol&>(lh),
+							static_cast<const symbol&>(rh));
+		else if (typeid_rh == power_id())
+			return compare_same_type_power(static_cast<const power&>(lh),
+						       static_cast<const power&>(rh));
+		else if (typeid_rh == function_id())
+			return compare_same_type_function(static_cast<const function&>(lh),
+							  static_cast<const function&>(rh));
+		else if (typeid_rh == fderivative_id())
+			return compare_same_type_fderivative(static_cast<const fderivative&>(lh),
+							     static_cast<const fderivative&>(rh));
+		else
+			// using GiNaC functions by default
+			return lh.compare_same_type(rh);
+		
+	// at present numerics are combined into overall_coefficient
+	// even when hold parameter is used
+	else if (typeid_lh == numeric_id())
+	 	//print numerics before anything else
+		return 1;
+	else if (typeid_rh == numeric_id())
+	 	//print numerics before anything else
+		return -1;
+	else if (typeid_lh == wildcard_id())
+	 	//print wildcards before anything else (but numerics)
+		return 1;
+	else if (typeid_rh == wildcard_id())
+	 	//print wildcards before anything else (but numerics)
+		return -1;
+	else if (typeid_lh == constant_id())
+	 	//print constants before anything else (but numerics, wildcards)
+		return 1;
+	else if (typeid_rh == constant_id())
+	 	//print constants before anything else (but numerics, wildcards)
+		return -1;
+	else if (typeid_lh == fderivative_id())
+		//print fderivatives after everything else
+		return -1;
+	else if (typeid_rh == fderivative_id())
+		//print fderivatives after everything esle
+		return 1;
+	else if (typeid_lh == function_id())
+		//print functions before fderivatives, after anything else
+		return -1;
+	else if (typeid_rh == function_id())
+		//print functions before fderivatives, after anything else
+		return 1;
+	else if (typeid_lh == mul_id())
+		if (typeid_rh == power_id())
+			return compare_mul_power(
+					static_cast<const mul&>(lh),
+					static_cast<const power&>(rh));
+		else if (typeid_rh == symbol_id())
+			return compare_mul_symbol(
+					static_cast<const mul&>(lh),
+					static_cast<const symbol&>(rh));
+		else if (typeid_rh == add_id())
+			return -compare_add_mul(
+					static_cast<const add&>(rh),
+					static_cast<const mul&>(lh));
+		else throw (std::runtime_error("comparing typeid's"));
+	else if (typeid_lh == add_id())
+		if (typeid_rh == power_id())
+			return compare_add_power(
+					static_cast<const add&>(lh),
+					static_cast<const power&>(rh));
+		else if (typeid_rh == symbol_id())
+			return compare_add_symbol(
+					static_cast<const add&>(lh),
+					static_cast<const symbol&>(rh));
+		else if (typeid_rh == mul_id())
+			return compare_add_mul(
+					static_cast<const add&>(lh),
+					static_cast<const mul&>(rh));
+		else throw (std::runtime_error("comparing typeid's"));
+	else if (typeid_lh == power_id())
+		if (typeid_rh == mul_id())
+			return -compare_mul_power(
+					static_cast<const mul&>(rh),
+					static_cast<const power&>(lh));
+		else if (typeid_rh == add_id())
+			return -compare_add_power(
+					static_cast<const add&>(rh),
+					static_cast<const power&>(lh));
+		else if (typeid_rh == symbol_id())
+			return compare_power_symbol(
+					static_cast<const power&>(lh),
+					static_cast<const symbol&>(rh));
+		else throw (std::runtime_error("comparing typeid's"));
+	else if (typeid_lh == symbol_id())
+		if (typeid_rh == mul_id())
+			return -compare_mul_symbol(
+					static_cast<const mul&>(rh),
+					static_cast<const symbol&>(lh));
+		else if (typeid_rh == add_id())
+			return -compare_add_symbol(
+					static_cast<const add&>(rh),
+					static_cast<const symbol&>(lh));
+		else if (typeid_rh == power_id())
+			return -compare_power_symbol(
+					static_cast<const power&>(rh),
+					static_cast<const symbol&>(lh));
+		else throw (std::runtime_error("comparing typeid's"));
+	throw (std::runtime_error("comparing typeid's"));
+}
+
+// compare a mul and a symbol objects
+// same behavior within mul and add objects:
+// the total degree of the symbol is 1
+// check total degree of mul then compare smallest item to symbol
+int print_order::compare_mul_symbol(const mul &lh, const symbol &rh) const
+{
+	int cmpval;
+
+	double tdeg;
+	tdeg = lh.total_degree();
+
+	if (tdeg != 1)
+		return tdeg > 1 ? 1 : -1;
+	
+	const expair smallest_item = lh.get_sorted_seq().back();
+
+	// compare bases
+	cmpval = compare(*smallest_item.rest.bp, rh);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	// compare exponents
+	cmpval = -compare(*smallest_item.coeff.bp, *_num1_p);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	if (lh.seq.size() == 1 && lh.overall_coeff.is_equal(_ex1))
+		return 0;
+
+	// there is something of total degree 0 in front of the mul object
+	return 1;
+}
+
+// compare a mul and a pow objects
+// same behavior within mul and add objects:
+// first we compare total degrees
+// if equal we compare the smallest basis in the sequence to the basis in other
+// then their exponents
+int print_order::compare_mul_power(const mul &lh, const power &rh) const
+{
+	int cmpval;
+
+	double lh_deg = lh.total_degree();
+	double rh_deg = 1;
+	numeric rh_exp;
+	if (is_a<numeric>(rh.exponent)) {
+		rh_deg = numeric_to_double(ex_to<numeric>(rh.exponent));
+	}
+	if (rh_deg != lh_deg)
+		return lh_deg < rh_deg ? -1 : 1;
+	// same total degree
+
+	// smallest item is at the end of the sorted sequence
+	const expair smallest_item = lh.get_sorted_seq().back();
+	
+	// compare bases
+	cmpval = compare(smallest_item.rest, rh.basis);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	// compare exponents
+	cmpval = -compare(smallest_item.coeff, rh.exponent);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	if (lh.seq.size() == 1 && lh.overall_coeff.is_equal(_ex1))
+		return 0;
+
+	// there is something of total degree 0 in front of the mul object
+	return 1;
+}
+
+// compare two mul objects
+// same behavior wihtin mul and add objects:
+// first we compare total degrees
+// if equal we compare the basis of the smallest items
+// then their exponents
+// and so on
+int print_order::compare_same_type_mul(const mul &lh, const mul &rh) const
+{
+	int cmpval;
+	
+	// compare total degrees
+	double lh_deg = lh.total_degree();
+	double rh_deg = rh.total_degree();
+	if (lh_deg != rh_deg)
+		return lh_deg < rh_deg ? -1 : 1;
+	
+	// compare each item in lh to corresponding element in rh
+	const epvector & sorted_seq1 = lh.get_sorted_seq();
+	const epvector & sorted_seq2 = rh.get_sorted_seq();
+	epvector::const_reverse_iterator cit1 = sorted_seq1.rbegin();
+	epvector::const_reverse_iterator cit2 = sorted_seq2.rbegin();
+	epvector::const_reverse_iterator last1 = sorted_seq1.rend();
+	epvector::const_reverse_iterator last2 = sorted_seq2.rend();
+
+	for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
+		// compare bases
+	  cmpval = compare(cit1->rest, cit2->rest);
+		if (cmpval != 0) {
+			return cmpval;
+		}
+
+		// compare exponents
+		cmpval = -compare(cit1->coeff, cit2->coeff);
+		if (cmpval != 0) {
+			return cmpval;
+		}
+	}
+
+	// compare sizes
+	if (cit1 != last1) 
+		return 1;
+	else if (cit2 != last2)
+		return -1;
+
+	// compare overall_coeff
+	cmpval = compare(lh.overall_coeff, rh.overall_coeff);
+
+	return cmpval;
+}
+
+// compare an add and a symbol objects
+// same behavior wihtin mul and add objects:
+// the coefficient of the symbol is 1
+int print_order::compare_add_symbol(const add &lh, const symbol &rh) const
+{
+	int cmpval;
+
+	const expair biggest_item = lh.get_sorted_seq().front();
+
+	// compare bases
+	cmpval = print_order().compare(*biggest_item.rest.bp, rh);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	// compare coefficients
+	cmpval = compare(*biggest_item.coeff.bp, *_num1_p);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	if (lh.seq.size() == 1 && lh.overall_coeff.is_equal(_ex0))
+		return 0;
+
+	// there is something at the end of the add object
+	return 1;
+}
+
+// compare an add and a mul objects
+// same behavior within mul and add objects:
+// the coefficient of the mul object is 1
+int print_order::compare_add_mul(const add &lh,
+				 const mul &rh) const
+{
+	int cmpval;
+	const expair biggest_item = lh.get_sorted_seq().front();
+
+	// compare bases
+	cmpval = print_order().compare(*biggest_item.rest.bp, rh);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	// compare coefficients
+	cmpval = compare(*biggest_item.coeff.bp, *_num1_p);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	if (lh.seq.size() == 1 && lh.overall_coeff.is_equal(_ex0))
+		return 0;
+
+	// there is something at the end of the object
+	return 1;
+}
+
+// compare an add and a pow objects
+// same behavior wihtin mul and add objects:
+// the coefficient of the power object is 1
+int print_order::compare_add_power(const add &lh,
+		const power &rh) const
+{
+	int cmpval;
+	const expair biggest_item = lh.get_sorted_seq().front();
+
+	// compare bases
+	cmpval = print_order().compare(*biggest_item.rest.bp, rh);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	// compare coefficients
+	cmpval = compare(*biggest_item.coeff.bp, *_num1_p);
+	if (cmpval != 0) {
+		return cmpval;
+	}
+
+	if (lh.seq.size() == 1 && lh.overall_coeff.is_equal(_ex0))
+		return 0;
+
+	// there is something at the end of the object
+	return 1;
+}
+
+// compare two add objects
+// same behavior wihtin mul and add objects:
+// first we compare the basis of the biggest items
+// then their coefficients
+// and so on
+int print_order::compare_same_type_add(const add &lh, const add &rh) const
+{
+	int cmpval;
+
+	const epvector & sorted_seq1 = lh.get_sorted_seq();
+	const epvector & sorted_seq2 = rh.get_sorted_seq();
+	epvector::const_iterator cit1 = sorted_seq1.begin();
+	epvector::const_iterator cit2 = sorted_seq2.begin();
+	epvector::const_iterator last1 = sorted_seq1.end();
+	epvector::const_iterator last2 = sorted_seq2.end();
+
+	for (; (cit1!=last1)&&(cit2!=last2); ++cit1, ++cit2) {
+		// compare bases
+		cmpval = print_order().compare(cit1->rest, cit2->rest);
+		if (cmpval != 0) {
+			return cmpval;
+		}
+
+		// compare coefficients
+		cmpval = compare(cit1->coeff, cit2->coeff);
+		if (cmpval != 0) {
+			return cmpval;
+		}
+	}
+
+	// compare sizes
+	if (cit1 != last1) 
+		return 1;
+	else if (cit2 != last2)
+		return -1;
+
+	// compare overall_coeff
+	cmpval = compare(lh.overall_coeff, rh.overall_coeff);
+	
+	return cmpval;
+}
+
+// compare a power and a symbol objects
+// does not behave the same way inside add or mul
+// in mul object:
+// first we compare bases
+// then exponents
+// in add object:
+// first exponents
+// then bases
+int print_order_mul::compare_power_symbol
+(const power &lh, const symbol &rh) const
+{
+	int cmpval;
+	cmpval = compare(*lh.basis.bp, rh);
+	if (cmpval != 0)
+		  return cmpval;
+	
+	cmpval = compare(*lh.exponent.bp, *_num1_p);
+	
+	return cmpval;
+}
+
+int print_order::compare_power_symbol(const power &lh,
+		const symbol &rh) const
+{
+	int cmpval;
+
+	// We are in an add object
+	if (is_a<numeric>(lh.exponent)) {
+		double lh_deg = numeric_to_double(ex_to<numeric>(lh.exponent));
+		if (lh_deg != 1)
+			return lh_deg < 1 ? -1 : 1;
+	}
+
+	cmpval = compare(*lh.basis.bp, rh);
+
+	return cmpval;
+}
+
+// compare two power objects
+// does not behave the same way inside add or mul
+// in mul object:
+// fist we compare bases
+// then exponents
+// in add object:
+// first exponents
+// then bases
+int print_order_mul::compare_same_type_power(const power &lh, const power &rh) const
+{
+	int cmpval;
+	cmpval = compare(lh.basis, rh.basis);
+	if (cmpval != 0)
+		  return cmpval;
+	cmpval = compare(lh.exponent, rh.exponent);
+	
+	return cmpval;
+}
+
+
+int print_order::compare_same_type_power(const power &lh, const power &rh) const
+{
+	int cmpval;
+
+	double lh_deg = 1;
+	double rh_deg = 1;
+	if (is_a<numeric>(lh.exponent)) {
+		lh_deg = numeric_to_double(ex_to<numeric>(lh.exponent));
+	}
+	if (is_a<numeric>(rh.exponent)) {
+		rh_deg = numeric_to_double(ex_to<numeric>(rh.exponent));
+	}
+	if (rh_deg != lh_deg)
+		return lh_deg < rh_deg ? -1 : 1;
+
+	cmpval = compare(lh.basis, rh.basis);
+	if (cmpval != 0)
+		return cmpval;
+
+	if (is_a<numeric>(lh.exponent) && is_a<numeric>(rh.exponent))
+		return 0;
+	return compare(lh.exponent, rh.exponent);
+}
+
+// compare two symbol objects
+// same behavior wihtin mul and add objects:
+// we compare names
+int print_order::compare_same_type_symbol(const symbol &lh, const symbol &rh) const
+{
+	/* Reversed ordering on char encoding (i.e. "a" < "b") then length
+	 * (i.e. "abc" < "abcd")
+	   i.e. "x" > "y" and "xyz" > "xyzt" */
+	if (lh.serial==rh.serial) return 0;
+	return lh.name < rh.name ? 1 : -1;
+}
+
+// compare two containers of the same type
+template <template <class T, class = std::allocator<T> > class C>
+int print_order::compare_same_type_container(const container<C> &lh,
+					     const container<C> &rh) const
+{
+	typename C<ex>::const_iterator it1 = lh.seq.begin(), it1end = lh.seq.end(),
+			      it2 = rh.seq.begin(), it2end = rh.seq.end();
+
+	while (it1 != it1end && it2 != it2end) {
+		int cmpval = compare(*it1, *it2);
+		if (cmpval)
+			return cmpval;
+		++it1; ++it2;
+	}
+
+	return (it1 == it1end) ? (it2 == it2end ? 0 : -1) : 1;
+}
+
+// compare two function objects
+// same behavior wihtin mul and add objects:
+// we compare names
+int print_order::compare_same_type_function(const function &lh,
+					    const function &rh) const
+{
+
+	if (lh.serial==rh.serial)
+		return compare_same_type_container(lh, rh);
+	return lh.get_name() < rh.get_name() ? 1 : -1;	
+
+}
+
+// compare two fderivative objects
+// same behavior wihtin mul and add objects:
+// we compare names
+int print_order::compare_same_type_fderivative(const fderivative &lh,
+					       const fderivative &rh) const
+{
+	int cmpval = compare_same_type_function(lh, rh);
+	if (cmpval != 0)
+		return cmpval;
+	if (lh.parameter_set != rh.parameter_set)
+		return lh.parameter_set < rh.parameter_set ? 1 : -1;
+	return 0;
+}
+
+} // namespace GiNaC
diff --git a/ginac/order.h b/ginac/order.h
new file mode 100644
index 0000000..f59f12e
--- /dev/null
+++ b/ginac/order.h
@@ -0,0 +1,110 @@
+/** @file order.h
+ *
+ *  Definitions of order used for printing. */
+
+/*
+ *   Copyright (C) 2011 Burcin Erocal <burcin at erocal.org>
+ *   Copyright (C) 2011 Jean-Pierre Flori <flori at enst.fr>
+ *
+ *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GINAC_ORDER_H__
+#define __GINAC_ORDER_H__
+
+#include "ex.h"
+#include "basic.h"
+#include "mul.h"
+#include "power.h"
+#include "add.h"
+#include "symbol.h"
+#include "function.h"
+#include "fderivative.h"
+
+namespace GiNaC {
+
+class print_order : public std::binary_function<ex, ex, bool> {
+private:
+	const tinfo_t& function_id() const;
+	const tinfo_t& fderivative_id() const;
+	const tinfo_t& power_id() const;
+	const tinfo_t& symbol_id() const;
+	const tinfo_t& mul_id() const;
+	const tinfo_t& add_id() const;
+	const tinfo_t& numeric_id() const;
+	const tinfo_t& constant_id() const;
+	const tinfo_t& wildcard_id() const;
+
+public:
+	bool operator() (const ex &lh, const ex &rh) const;
+	int compare(const ex &lh, const ex &rh) const;
+
+protected:
+	friend class print_order_pair;
+
+	//	int compare(const ptr<basic> &lh, const ptr<basic> &rh) const;
+
+	// all other compare() methods dispatch to this one
+	int compare(const basic &lh, const basic &rh) const;
+
+	// mul objects
+	int compare_mul_symbol(const mul &lh, const symbol &rh) const;
+	int compare_mul_power(const mul &lh, const power &rh) const;
+	int compare_same_type_mul(const mul &lh, const mul &rh) const;
+	// add objects
+	int compare_add_symbol(const add &lh, const symbol &rh) const;
+	int compare_add_power(const add &lh, const power &rh) const;
+	int compare_add_mul(const add &lh, const mul &rh) const;
+	int compare_same_type_add(const add &lh, const add &rh) const;
+	// power objects
+	virtual int compare_power_symbol(const power &lh, const symbol &rh) const;
+	virtual int compare_same_type_power(const power &lh, const power &rh) const;
+	// symbol objects
+	int compare_same_type_symbol(const symbol &lh, const symbol &rh) const;
+	// container objects
+	template <template <class T, class = std::allocator<T> > class C>
+	int compare_same_type_container(const container<C> &lh, const container<C> &rh) const;
+	// function objects
+	int compare_same_type_function(const function &lh, const function &rh) const;
+	// fderivative objects
+	int compare_same_type_fderivative(const fderivative &lh, const fderivative &rh) const;
+};
+
+
+class print_order_mul : public print_order {
+	int compare_power_symbol(const power &lh, const symbol &rh) const;
+	int compare_same_type_power(const power &lh, const power &rh) const;
+};
+
+
+// We have to define the following class to sort held expressions
+// E.g. 3*x+2*x which does not get simplified to 5*x.
+class print_order_pair : 
+	public std::binary_function<expair, expair, bool>
+{
+public:
+	bool operator() (const expair &lh, const expair &rh) const;
+	bool compare_degrees(const expair &lhex, const expair &rhex) const;
+};
+
+
+class print_order_pair_mul : public print_order_pair
+{
+public:
+	bool operator() (const expair &lh, const expair &rh) const;
+};
+
+} // namespace GiNaC
+#endif // ndef __GINAC_ORDER_H__
diff --git a/ginac/power.cpp b/ginac/power.cpp
index fe3fcef..a9a8ff3 100644
--- a/ginac/power.cpp
+++ b/ginac/power.cpp
@@ -637,7 +637,8 @@ ex power::eval(int level) const
 		if (num_exponent->is_integer() && is_exactly_a<add>(ebasis)) {
 			numeric icont = ebasis.integer_content();
 			const numeric lead_coeff = 
-				ex_to<numeric>(ex_to<add>(ebasis).seq.begin()->coeff).div(icont);
+				ex_to<numeric>(ex_to<add>(ebasis).\
+						lead_coeff()).div(icont);
 
 			const bool canonicalizable = lead_coeff.is_integer();
 			const bool unit_normal = lead_coeff.is_pos_integer();
@@ -650,6 +651,7 @@ ex power::eval(int level) const
 				addp->setflag(status_flags::dynallocated);
 				addp->clearflag(status_flags::hash_calculated);
 				addp->overall_coeff = ex_to<numeric>(addp->overall_coeff).div_dyn(icont);
+				addp->seq_sorted.resize(0);
 				for (epvector::iterator i = addp->seq.begin(); i != addp->seq.end(); ++i)
 					i->coeff = ex_to<numeric>(i->coeff).div_dyn(icont);
 
@@ -675,6 +677,7 @@ ex power::eval(int level) const
 						mulp->setflag(status_flags::dynallocated);
 						mulp->clearflag(status_flags::evaluated);
 						mulp->clearflag(status_flags::hash_calculated);
+						mulp->seq_sorted.resize(0);
 						return (new mul(power(*mulp,exponent),
 						                power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
 					} else {
@@ -685,6 +688,7 @@ ex power::eval(int level) const
 							mulp->setflag(status_flags::dynallocated);
 							mulp->clearflag(status_flags::evaluated);
 							mulp->clearflag(status_flags::hash_calculated);
+							mulp->seq_sorted.resize(0);
 							return (new mul(power(*mulp,exponent),
 							                power(abs(num_coeff),*num_exponent)))->setflag(status_flags::dynallocated);
 						}
@@ -900,39 +904,6 @@ ex power::derivative(const symbol & s) const
 	}
 }
 
-int power::compare(const basic& other) const
-{
-	static const tinfo_t mul_id = find_tinfo_key("mul");
-	static const tinfo_t symbol_id = find_tinfo_key("symbol");
-	static const tinfo_t function_id = find_tinfo_key("function");
-	static const tinfo_t fderivative_id = find_tinfo_key("fderivative");
-	const tinfo_t typeid_this = tinfo();
-	const tinfo_t typeid_other = other.tinfo();
-	if (typeid_this==typeid_other) {
-		GINAC_ASSERT(typeid(*this)==typeid(other));
-		return compare_same_type(other);
-	} else if (typeid_other == mul_id) {
-		return -static_cast<const mul&>(other).compare_pow(*this);
-	} else if (typeid_other == symbol_id) {
-		return compare_symbol(static_cast<const symbol&>(other));
-	} else if (typeid_other == function_id ||
-			typeid_other == fderivative_id) {
-		return -1;
-	} else {
-		return (typeid_this<typeid_other ? -1 : 1);
-	}
-}
-
-int power::compare_symbol(const symbol & other) const
-{
-	int cmpval;
-	cmpval = _ex1.compare(exponent);
-	if (cmpval != 0) {
-		return cmpval;
-	}
-	return basis.compare(other);
-}
-
 int power::compare_same_type(const basic & other) const
 {
 	GINAC_ASSERT(is_exactly_a<power>(other));
@@ -942,11 +913,7 @@ int power::compare_same_type(const basic & other) const
 	if (cmpval)
 		return cmpval;
 	else
-	  // SAGE -- I changed the sign below for consistency with standard
-	  // mathematics and all other math software (except mathematica).
-	  // This makes it so x^5 + x^2 prints correctly instead of 
-	  // as x^2 + x^5.   -- William Stein
-		return -exponent.compare(o.exponent);
+		return exponent.compare(o.exponent);
 }
 
 unsigned power::return_type() const
diff --git a/ginac/power.h b/ginac/power.h
index 6cb46dc..306a9db 100644
--- a/ginac/power.h
+++ b/ginac/power.h
@@ -40,6 +40,8 @@ class power : public basic
 {
 	GINAC_DECLARE_REGISTERED_CLASS(power, basic)
 	
+	friend struct print_order;
+	friend struct print_order_mul;
 	friend class mul;
 	
 // member functions
@@ -72,8 +74,8 @@ public:
 	ex conjugate() const;
 	ex real_part() const;
 	ex imag_part() const;
-	int compare(const basic& other) const;
-	int compare_symbol(const symbol& other) const;
+	//int compare(const basic& other) const;
+	//int compare_symbol(const symbol& other) const;
 protected:
 	ex derivative(const symbol & s) const;
 	ex eval_ncmul(const exvector & v) const;
diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp
index 2ea7add..9c821a4 100644
--- a/ginac/symbol.cpp
+++ b/ginac/symbol.cpp
@@ -283,6 +283,7 @@ ex symbol::derivative(const symbol & s) const
 		return _ex1;
 }
 
+/*
 int symbol::compare(const basic& other) const
 {
 	static const tinfo_t pow_id = find_tinfo_key("power");
@@ -305,26 +306,14 @@ int symbol::compare(const basic& other) const
 		return (typeid_this<typeid_other ? -1 : 1);
 	}
 }
+*/
 
 int symbol::compare_same_type(const basic & other) const
 {
 	GINAC_ASSERT(is_a<symbol>(other));
 	const symbol *o = static_cast<const symbol *>(&other);
 	if (serial==o->serial) return 0;
-	
-	// SAGE/Pynac: Sorting based on creation order doesn't work for Sage.
-	// instead we sort on variable name. -- William Stein
-
-	return name < (o->name) ? -1 : 1;
-	
-	// This is what Ginac used to return.  It fits with their
-	// philosophy that symbols names have no intrinsic meaning,
-	// only the order of creation of symbols matters.  Also, they
-	// allow multiple symbols with the same name.  Our Pynac
-	// wrapper does not allow for this, and we find the behavior
-	// way too confusing and ad hoc with this convention. 
-
-	// return serial < o->serial ? -1 : 1;
+        return serial < o->serial ? -1 : 1;
 }
 
 bool symbol::is_equal_same_type(const basic & other) const
diff --git a/ginac/symbol.h b/ginac/symbol.h
index dbd85b7..39f428e 100644
--- a/ginac/symbol.h
+++ b/ginac/symbol.h
@@ -43,6 +43,7 @@ class symbol : public basic
 
 	friend class realsymbol;
 	friend class possymbol;
+	friend struct print_order;
 
 // types
 	
@@ -58,8 +59,8 @@ public:
 	
 	// functions overriding virtual functions from base classes
 public:
-	//	int compare_same_type(const basic & other) const;
-	int compare(const basic &other) const;
+	//int compare_same_type(const basic & other) const;
+	//int compare(const basic &other) const;
 	bool info(unsigned inf) const;
 	ex eval(int level = 0) const;
 	ex evalf(int level = 0) const { return *this; } // overwrites basic::evalf() for performance reasons
diff --git a/ginac/version.h b/ginac/version.h
index 7469332..e370c6b 100644
--- a/ginac/version.h
+++ b/ginac/version.h
@@ -25,8 +25,8 @@
 
 /* Major, minor, and micro version number of the GiNaC library. */
 #define GINACLIB_MAJOR_VERSION 0
-#define GINACLIB_MINOR_VERSION 2
-#define GINACLIB_MICRO_VERSION 6
+#define GINACLIB_MINOR_VERSION 3
+#define GINACLIB_MICRO_VERSION 0
 
 namespace GiNaC {
 
diff --git a/pynac.pc b/pynac.pc
index 284d437..e453dcd 100644
--- a/pynac.pc
+++ b/pynac.pc
@@ -1,11 +1,11 @@
-prefix=/home/burcin/sage/sage-5.5.rc0/local
+prefix=/home/burcin/sage/sage-5.10.beta2/local
 exec_prefix=${prefix}
-libdir=/home/burcin/sage/sage-5.5.rc0/local/lib
+libdir=/home/burcin/sage/sage-5.10.beta2/local/lib
 includedir=${prefix}/include,$SAGE_LOCAL/include
 
 Name: pynac
 Description: C++/Python library for symbolic calculations
-Version: 0.2.6
+Version: 0.3.0
 Requires: python >= 2.5
 Libs: -L${libdir} -lpython
 Cflags: -I${includedir}
diff --git a/pynac.spec b/pynac.spec
index 0aad403..fd0b307 100644
--- a/pynac.spec
+++ b/pynac.spec
@@ -1,5 +1,5 @@
 %define name pynac
-%define version 0.2.6
+%define version 0.3.0
 %define release 1
 
 Summary: C++ library for symbolic calculations

-- 
Packaging for pynac



More information about the debian-science-commits mailing list