# HG changeset patch # User Stefan Monnier # Date 1168401019 0 # Node ID ea255892b6fd876e73f2906fc7295e0d56163a62 # Parent cf3da57bf8a5e9b7d41505e86e8a01d58d8fa03c (Fformat): Allow integer-format to work with floats of size larger than most-positive-fixnum (but still smaller than MAXINT). diff -r cf3da57bf8a5 -r ea255892b6fd src/ChangeLog --- a/src/ChangeLog Wed Jan 10 03:44:49 2007 +0000 +++ b/src/ChangeLog Wed Jan 10 03:50:19 2007 +0000 @@ -1,5 +1,8 @@ 2007-01-10 Stefan Monnier + * editfns.c (Fformat): Allow integer-format to work with floats of size + larger than most-positive-fixnum (but still smaller than MAXINT). + * dired.c (Ffile_attributes): Use floats for large uids/gids. 2007-01-09 Eli Zaretskii diff -r cf3da57bf8a5 -r ea255892b6fd src/editfns.c --- a/src/editfns.c Wed Jan 10 03:44:49 2007 +0000 +++ b/src/editfns.c Wed Jan 10 03:50:19 2007 +0000 @@ -1,7 +1,7 @@ /* Lisp functions pertaining to editing. Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Free Software Foundation, Inc. + 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -3631,7 +3631,12 @@ if (*format != 'd' && *format != 'o' && *format != 'x' && *format != 'i' && *format != 'X' && *format != 'c') error ("Invalid format operation %%%c", *format); - args[n] = Ftruncate (args[n], Qnil); + /* This fails unnecessarily if args[n] is bigger than + most-positive-fixnum but smaller than MAXINT. + These cases are important because we sometimes use floats + to represent such integer values (typically such values + come from UIDs or PIDs). */ + /* args[n] = Ftruncate (args[n], Qnil); */ } /* Note that we're using sprintf to print floats, @@ -3799,8 +3804,15 @@ else sprintf (p, this_format, XUINT (args[n])); } + else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') + sprintf (p, this_format, XFLOAT_DATA (args[n])); + else if (format[-1] == 'd') + /* Maybe we should use "%1.0f" instead so it also works + for values larger than MAXINT. */ + sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); else - sprintf (p, this_format, XFLOAT_DATA (args[n])); + /* Don't sign-extend for octal or hex printing. */ + sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); if (p > buf && multibyte