[Python-checkins] CVS: python/dist/src/Objects longobject.c,1.53,1.54

Fred L. Drake fdrake@weyr.cnri.reston.va.us
Thu, 23 Dec 1999 10:41:31 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Objects
In directory weyr:/home/fdrake/projects/python/Objects

Modified Files:
	longobject.c 
Log Message:

long_format():  Now takes a third parameter, addL; iff true, a
                trailing 'L' is appended to the representation,
                otherwise not.

                All existing call sites are modified to pass true for
                addL.

                Remove incorrect statement about external use of this
                function from elsewhere; it's static!

long_str():     Handler for the tp_str slot in the type object.
                Identical to long_repr(), but passes false as the addL 
                parameter of long_format().


Index: longobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/longobject.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -r1.53 -r1.54
*** longobject.c	1999/10/11 22:34:41	1.53
--- longobject.c	1999/12/23 15:41:28	1.54
***************
*** 48,52 ****
  static PyLongObject *muladd1 Py_PROTO((PyLongObject *, wdigit, wdigit));
  static PyLongObject *divrem1 Py_PROTO((PyLongObject *, wdigit, digit *));
! static PyObject *long_format Py_PROTO((PyObject *aa, int base));
  
  static int ticker;	/* XXX Could be shared with ceval? */
--- 48,52 ----
  static PyLongObject *muladd1 Py_PROTO((PyLongObject *, wdigit, wdigit));
  static PyLongObject *divrem1 Py_PROTO((PyLongObject *, wdigit, digit *));
! static PyObject *long_format Py_PROTO((PyObject *aa, int base, int addL));
  
  static int ticker;	/* XXX Could be shared with ceval? */
***************
*** 571,581 ****
  /* Convert a long int object to a string, using a given conversion base.
     Return a string object.
!    If base is 8 or 16, add the proper prefix '0' or '0x'.
!    External linkage: used in bltinmodule.c by hex() and oct(). */
  
  static PyObject *
! long_format(aa, base)
  	PyObject *aa;
  	int base;
  {
  	register PyLongObject *a = (PyLongObject *)aa;
--- 571,581 ----
  /* Convert a long int object to a string, using a given conversion base.
     Return a string object.
!    If base is 8 or 16, add the proper prefix '0' or '0x'. */
  
  static PyObject *
! long_format(aa, base, addL)
  	PyObject *aa;
  	int base;
+         int addL;
  {
  	register PyLongObject *a = (PyLongObject *)aa;
***************
*** 600,604 ****
  		i >>= 1;
  	}
! 	i = 6 + (size_a*SHIFT + bits-1) / bits;
  	str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i);
  	if (str == NULL)
--- 600,604 ----
  		i >>= 1;
  	}
! 	i = 5 + (addL ? 1 : 0) + (size_a*SHIFT + bits-1) / bits;
  	str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i);
  	if (str == NULL)
***************
*** 606,610 ****
  	p = PyString_AS_STRING(str) + i;
  	*p = '\0';
! 	*--p = 'L';
  	if (a->ob_size < 0)
  		sign = '-';
--- 606,611 ----
  	p = PyString_AS_STRING(str) + i;
  	*p = '\0';
!         if (addL)
!                 *--p = 'L';
  	if (a->ob_size < 0)
  		sign = '-';
***************
*** 975,981 ****
  	PyObject *v;
  {
! 	return long_format(v, 10);
  }
  
  static int
  long_compare(a, b)
--- 976,989 ----
  	PyObject *v;
  {
! 	return long_format(v, 10, 1);
  }
  
+ static PyObject *
+ long_str(v)
+ 	PyObject *v;
+ {
+ 	return long_format(v, 10, 0);
+ }
+ 
  static int
  long_compare(a, b)
***************
*** 1757,1761 ****
  	PyObject *v;
  {
! 	return long_format(v, 8);
  }
  
--- 1765,1769 ----
  	PyObject *v;
  {
! 	return long_format(v, 8, 1);
  }
  
***************
*** 1764,1768 ****
  	PyObject *v;
  {
! 	return long_format(v, 16);
  }
  
--- 1772,1776 ----
  	PyObject *v;
  {
! 	return long_format(v, 16, 1);
  }
  
***************
*** 1818,1820 ****
--- 1826,1830 ----
  	(long (*) Py_FPROTO((PyObject *)))
  	(hashfunc)long_hash, /*tp_hash*/
+         0,              /*tp_call*/
+         (reprfunc)long_str, /*tp_str*/
  };