[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.75,2.76

Tim Peters python-dev@python.org
Sun, 9 Jul 2000 01:02:24 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16442/python/dist/src/objects

Modified Files:
	stringobject.c 
Log Message:
Somebody started playing with const, so of course the outcome
was cascades of warnings about mismatching const decls.  Overall,
I think const creates lots of headaches and solves almost
nothing.  Added enough consts to shut up the warnings, but
this did require casting away const in one spot too (another
usual outcome of starting down this path):  the function
mymemreplace can't return const char*, but sometimes wants to
return its first argument as-is, which latter must be declared
const char* in order to avoid const warnings at mymemreplace's
call sites.  So, in the case the function wants to return the
first arg, that arg's declared constness must be subverted.


Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.75
retrieving revision 2.76
diff -C2 -r2.75 -r2.76
*** stringobject.c	2000/07/09 07:04:36	2.75
--- stringobject.c	2000/07/09 08:02:21	2.76
***************
*** 610,614 ****
  
  static PyObject *
! split_whitespace(char *s, int len, int maxsplit)
  {
  	int i, j, err;
--- 610,614 ----
  
  static PyObject *
! split_whitespace(const char *s, int len, int maxsplit)
  {
  	int i, j, err;
***************
*** 1413,1417 ****
  */
  static int 
! mymemfind(char *mem, int len, char *pat, int pat_len)
  {
  	register int ii;
--- 1413,1417 ----
  */
  static int 
! mymemfind(const char *mem, int len, const char *pat, int pat_len)
  {
  	register int ii;
***************
*** 1436,1440 ****
   */
  static int 
! mymemcnt(char *mem, int len, char *pat, int pat_len)
  {
  	register int offset = 0;
--- 1436,1440 ----
   */
  static int 
! mymemcnt(const char *mem, int len, const char *pat, int pat_len)
  {
  	register int offset = 0;
***************
*** 1472,1479 ****
  */
  static char *
! mymemreplace(char *str, int len,	/* input string */
!              char *pat, int pat_len,	/* pattern string to find */
!              char *sub, int sub_len,	/* substitution string */
!              int count,			/* number of replacements */
               int *out_len)
  {
--- 1472,1479 ----
  */
  static char *
! mymemreplace(const char *str, int len,		/* input string */
!              const char *pat, int pat_len,	/* pattern string to find */
!              const char *sub, int sub_len,	/* substitution string */
!              int count,				/* number of replacements */
               int *out_len)
  {
***************
*** 1527,1531 ****
    return_same:
  	*out_len = -1;
! 	return str;
  }
  
--- 1527,1531 ----
    return_same:
  	*out_len = -1;
! 	return (char*)str;	/* have to cast away constness here */
  }