[Python-checkins] CVS: distutils/misc install.c,1.10,1.11

Thomas Heller theller@users.sourceforge.net
Mon, 09 Apr 2001 11:03:14 -0700


Update of /cvsroot/python/distutils/misc
In directory usw-pr-cvs1:/tmp/cvs-serv31286

Modified Files:
	install.c 
Log Message:
Python 2.1 changed the repr of strings.
This did break the installer (which did inplace conversion
of these strings).


Index: install.c
===================================================================
RCS file: /cvsroot/python/distutils/misc/install.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** install.c	2001/03/16 20:42:49	1.10
--- install.c	2001/04/09 18:03:11	1.11
***************
*** 118,147 ****
  static BOOL notify (int code, char *fmt, ...);
  
! static void unescape (char *str)
  {
-     char *dst = str;
-     char *src = str;
      char *eon;
      char ch;
  
!     while (src && *src) {
  	if (*src == '\\') {
  	    switch (*++src) {
  	    case 'n':
! 		*dst++ = '\n';
  		*dst++ = '\r';
  		break;
  	    case 'r':
  		*dst++ = '\r';
  		break;
  	    case '0': case '1': case '2': case '3':
  		ch = (char)strtol (src, &eon, 8);
! 		if (ch == '\n')
  		    *dst++ = '\r';
  		*dst++ = ch;
  		src = eon;
  	    }
! 	} else
  	    *dst++ = *src++;
      }
      *dst = '\0';
--- 118,154 ----
  static BOOL notify (int code, char *fmt, ...);
  
! static void unescape (char *dst, char *src, unsigned size)
  {
      char *eon;
      char ch;
  
!     while (src && *src && (size > 2)) {
  	if (*src == '\\') {
  	    switch (*++src) {
  	    case 'n':
! 		++src;
  		*dst++ = '\r';
+ 		*dst++ = '\n';
+ 		size -= 2;
  		break;
  	    case 'r':
+ 		++src;
  		*dst++ = '\r';
+ 		--size;
  		break;
  	    case '0': case '1': case '2': case '3':
  		ch = (char)strtol (src, &eon, 8);
! 		if (ch == '\n') {
  		    *dst++ = '\r';
+ 		    --size;
+ 		}
  		*dst++ = ch;
+ 		--size;
  		src = eon;
  	    }
! 	} else {
  	    *dst++ = *src++;
+ 	    --size;
+ 	}
      }
      *dst = '\0';
***************
*** 1047,1058 ****
  int DoInstall(void)
  {
      /* Read installation information */
!     GetPrivateProfileString ("Setup", "title", "", title,
! 			     sizeof (title), ini_file);
!     unescape (title);
! 
!     GetPrivateProfileString ("Setup", "info", "", info,
! 			     sizeof (info), ini_file);
!     unescape (info);
  
      GetPrivateProfileString ("Setup", "build_info", "", build_info,
--- 1054,1067 ----
  int DoInstall(void)
  {
+     char ini_buffer[4096];
+ 
      /* Read installation information */
!     GetPrivateProfileString ("Setup", "title", "", ini_buffer,
! 			     sizeof (ini_buffer), ini_file);
!     unescape (title, ini_buffer, sizeof(title));
! 
!     GetPrivateProfileString ("Setup", "info", "", ini_buffer,
! 			     sizeof (ini_buffer), ini_file);
!     unescape (info, ini_buffer, sizeof(info));
  
      GetPrivateProfileString ("Setup", "build_info", "", build_info,