changeset 5000:44d7bde26046

fix compile errors, fix revert-buffer bug on binary/Latin 1 files, Mule-ize some files -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-02-07 Ben Wing <ben@xemacs.org> * emacs.c (make_argc_argv): Cast to Wexttext * to fix compile error. * nt.c (init_user_info): Cast to CIbyte * to fix compile error. * nt.c (open_unc_volume): To fix compile error, store pathname into an Extbyte * variable then write into the dest, casting to LPTSTR. * emacs.c (debug_can_access_memory): * fileio.c (Fmake_temp_name): * fileio.c (a_write): * fns.c: * fns.c (check_losing_bytecode): * fns.c (plists_differ): * fns.c (internal_equal_trapping_problems): * fns.c (base64_value_to_char): * fns.c (base64_conversion_error): * fns.c (STORE_BYTE): * fns.c (vars_of_fns): * lisp.h: * nt.c (init_user_info): * nt.c (mswindows_readdir): * nt.c (mswindows_executable_type): Replace raw `char *' or `unsigned char *' with characterized type -- Rawbyte, Binbyte, Boolbyte, Ibyte or Ascbyte. This should fix at least one real bug -- in a_write(), the "speedy insert" code that checks for an unchanged region declared the file data read in as char[] but then compared the value to an Ichar. Hence, any chars in the range 128-255 would always appear changed -- in particular, this algorithm would fail completely with binary data.
author Ben Wing <ben@xemacs.org>
date Sun, 07 Feb 2010 05:21:40 -0600
parents 76af7fc13e81
children 714d854d00e9
files src/ChangeLog src/emacs.c src/fileio.c src/fns.c src/lisp.h src/nt.c
diffstat 6 files changed, 72 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/ChangeLog	Sun Feb 07 05:21:40 2010 -0600
@@ -1,3 +1,39 @@
+2010-02-07  Ben Wing  <ben@xemacs.org>
+
+	* emacs.c (make_argc_argv):
+	Cast to Wexttext * to fix compile error.
+	
+	* nt.c (init_user_info):
+	Cast to CIbyte * to fix compile error.
+	
+	* nt.c (open_unc_volume):
+	To fix compile error, store pathname into an Extbyte * variable
+	then write into the dest, casting to LPTSTR.
+
+	* emacs.c (debug_can_access_memory):
+	* fileio.c (Fmake_temp_name):
+	* fileio.c (a_write):
+	* fns.c:
+	* fns.c (check_losing_bytecode):
+	* fns.c (plists_differ):
+	* fns.c (internal_equal_trapping_problems):
+	* fns.c (base64_value_to_char):
+	* fns.c (base64_conversion_error):
+	* fns.c (STORE_BYTE):
+	* fns.c (vars_of_fns):
+	* lisp.h:
+	* nt.c (init_user_info):
+	* nt.c (mswindows_readdir):
+	* nt.c (mswindows_executable_type):
+	Replace raw `char *' or `unsigned char *' with characterized type --
+	Rawbyte, Binbyte, Boolbyte, Ibyte or Ascbyte.  This should fix at
+	least one real bug -- in a_write(), the "speedy insert" code that
+	checks for an unchanged region declared the file data read in as
+	char[] but then compared the value to an Ichar.  Hence, any chars
+	in the range 128-255 would always appear changed -- in particular,
+	this algorithm would fail completely with binary data.
+	
+
 2010-02-06  Ben Wing  <ben@xemacs.org>
 
 	* mule-wnnfns.c:
--- a/src/emacs.c	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/emacs.c	Sun Feb 07 05:21:40 2010 -0600
@@ -747,8 +747,9 @@
     {
       CHECK_STRING (XCAR (next));
 
-      (*argv)[i] = LISP_STRING_TO_EXTERNAL_MALLOC (XCAR (next),
-						   Qcommand_argument_encoding);
+      (*argv)[i] =
+	(Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC
+	(XCAR (next), Qcommand_argument_encoding);
     }
   (*argv) [n] = 0;
   *argc = i;
@@ -3011,13 +3012,14 @@
   run_temacs_argv = xnew_array (Wexttext *, nargs + 2);
 
   run_temacs_argv[0] =
-    LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args),
-				    Qcommand_argument_encoding);
+    (Wexttext *) LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args),
+						 Qcommand_argument_encoding);
   for (i = 0; i < nargs; i++)
     {
       CHECK_STRING (args[i]);
 
       run_temacs_argv[i + 1] =
+	(Wexttext *)
 	LISP_STRING_TO_EXTERNAL_MALLOC (args[i], Qcommand_argument_encoding);
     }
   run_temacs_argv[nargs + 1] = 0;
@@ -3414,7 +3416,7 @@
 	{
 	  /* We can't do the off-by-one trick with only one byte, so instead,
              we compare to a fixed-sized buffer. */
-	  char randval[1];
+	  Rawbyte randval[1];
 	  randval[0] = 0;
 	  dcam_saveval = memcmp (randval, ptr, len);
 	}
--- a/src/fileio.c	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/fileio.c	Sun Feb 07 05:21:40 2010 -0600
@@ -618,7 +618,7 @@
 */
        (prefix))
 {
-  static const char tbl[64] =
+  static const Ascbyte tbl[64] =
   {
     'A','B','C','D','E','F','G','H',
     'I','J','K','L','M','N','O','P',
@@ -1803,7 +1803,7 @@
 {
   /* This function can call Lisp.  GC checked 2000-07-28 ben */
   int ifd, ofd, n;
-  char buf[16 * 1024];
+  Rawbyte buf[16 * 1024];
   struct stat st, out_st;
   Lisp_Object handler;
   int speccount = specpdl_depth ();
@@ -3045,7 +3045,7 @@
 			     !NILP (visit) ? INSDEL_NO_LOCKING : 0);
       else
 	{
-	  char buffer[1 << 14];
+	  Rawbyte buffer[1 << 14];
 	  Charbpos same_at_start = BUF_BEGV (buf);
 	  Charbpos same_at_end = BUF_ZV (buf);
 	  int overlap;
@@ -3743,7 +3743,7 @@
 {
   Lisp_Object tem;
   int nextpos;
-  unsigned char largebuf[A_WRITE_BATCH_SIZE];
+  Ibyte largebuf[A_WRITE_BATCH_SIZE];
   Lstream *instr = XLSTREAM (instream);
   Lstream *outstr = XLSTREAM (outstream);
 
--- a/src/fns.c	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/fns.c	Sun Feb 07 05:21:40 2010 -0600
@@ -1,6 +1,6 @@
 /* Random utility Lisp functions.
    Copyright (C) 1985, 86, 87, 93, 94, 95 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003 Ben Wing.
+   Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003, 2010 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -218,7 +218,7 @@
 #endif /* LOSING_BYTECODE */
 
 void
-check_losing_bytecode (const char *function, Lisp_Object seq)
+check_losing_bytecode (const Ascbyte *function, Lisp_Object seq)
 {
   if (COMPILED_FUNCTIONP (seq))
     signal_ferror_with_frob
@@ -1988,7 +1988,7 @@
   int eqp = (depth == -1);	/* -1 as depth means use eq, not equal. */
   int la, lb, m, i, fill;
   Lisp_Object *keys, *vals;
-  char *flags;
+  Boolbyte *flags;
   Lisp_Object rest;
 
   if (NILP (a) && NILP (b))
@@ -2003,7 +2003,7 @@
   fill = 0;
   keys  = alloca_array (Lisp_Object, m);
   vals  = alloca_array (Lisp_Object, m);
-  flags = alloca_array (char, m);
+  flags = alloca_array (Boolbyte, m);
 
   /* First extract the pairs from A. */
   for (rest = a; !NILP (rest); rest = XCDR (XCDR (rest)))
@@ -2810,7 +2810,7 @@
 
 int
 internal_equal_trapping_problems (Lisp_Object warning_class,
-				  const char *warning_string,
+				  const Ascbyte *warning_string,
 				  int flags,
 				  struct call_trapping_problems_result *p,
 				  int retval,
@@ -3725,7 +3725,7 @@
   (IS_ASCII (Character) && base64_char_to_value[Character] >= 0)
 
 /* Table of characters coding the 64 values.  */
-static char base64_value_to_char[64] =
+static Ascbyte base64_value_to_char[64] =
 {
   'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',	/*  0- 9 */
   'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',	/* 10-19 */
@@ -3772,11 +3772,11 @@
    The octets are divided into 6 bit chunks, which are then encoded into
    base64 characters.  */
 
-static DECLARE_DOESNT_RETURN (base64_conversion_error (const char *,
+static DECLARE_DOESNT_RETURN (base64_conversion_error (const Ascbyte *,
 						       Lisp_Object));
 
 static DOESNT_RETURN
-base64_conversion_error (const char *reason, Lisp_Object frob)
+base64_conversion_error (const Ascbyte *reason, Lisp_Object frob)
 {
   signal_error (Qbase64_conversion_error, reason, frob);
 }
@@ -3859,7 +3859,7 @@
 } while (1)
 
 #define STORE_BYTE(pos, val, ccnt) do {					\
-  pos += set_itext_ichar (pos, (Ichar)((unsigned char)(val)));	\
+  pos += set_itext_ichar (pos, (Ichar)((Binbyte)(val)));		\
   ++ccnt;								\
 } while (0)
 
@@ -4204,7 +4204,7 @@
 The directory separator in search paths, as a string.
 */ );
   {
-    char c = SEPCHAR;
+    Ascbyte c = SEPCHAR;
     Vpath_separator = make_string ((Ibyte *) &c, 1);
   }
 }
--- a/src/lisp.h	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/lisp.h	Sun Feb 07 05:21:40 2010 -0600
@@ -5292,7 +5292,7 @@
 int internal_equal_0 (Lisp_Object, Lisp_Object, int, int);
 Lisp_Object bytecode_nconc2 (Lisp_Object *);
 int bytecode_arithcompare (Lisp_Object obj1, Lisp_Object obj2);
-void check_losing_bytecode (const char *, Lisp_Object);
+void check_losing_bytecode (const Ascbyte *, Lisp_Object);
 
 Lisp_Object add_suffix_to_symbol (Lisp_Object symbol,
 				  const Ascbyte *ascii_string);
--- a/src/nt.c	Sat Feb 06 04:27:47 2010 -0600
+++ b/src/nt.c	Sun Feb 07 05:21:40 2010 -0600
@@ -158,9 +158,9 @@
       && qxeLookupAccountSid (NULL, sidinfo.User.Sid, name, &length,
 			      domain, &dlength, &user_type))
     {
-      the_passwd.pw_name = TSTR_TO_ITEXT_MALLOC (name);
+      the_passwd.pw_name = (CIbyte *) TSTR_TO_ITEXT_MALLOC (name);
       /* Determine a reasonable uid value. */
-      if (qxestrcasecmp ("administrator", the_passwd.pw_name) == 0)
+      if (qxestrcasecmp ((Ibyte *) the_passwd.pw_name, "administrator") == 0)
 	{
 	  the_passwd.pw_uid = 0;
 	  the_passwd.pw_gid = 0;
@@ -202,8 +202,9 @@
        are running under Windows 95), fallback to this. */
   else if (qxeGetUserName (name, &length))
     {
-      the_passwd.pw_name = TSTR_TO_ITEXT_MALLOC (name);
-      if (qxestrcasecmp ("administrator", the_passwd.pw_name) == 0)
+      the_passwd.pw_name = (CIbyte *) TSTR_TO_ITEXT_MALLOC (name);
+      if (qxestrcasecmp_ascii ((Ibyte *) the_passwd.pw_name,
+			       "administrator") == 0)
 	the_passwd.pw_uid = 0;
       else
 	the_passwd.pw_uid = 123;
@@ -223,7 +224,7 @@
   DWORD length = UNLEN + 1;
   Extbyte name[MAX_XETCHAR_SIZE * (UNLEN + 1)];
   if (qxeGetUserName (name, &length))
-    the_passwd.pw_name = TSTR_TO_ITEXT_MALLOC (name);
+    the_passwd.pw_name = (CIbyte *) TSTR_TO_ITEXT_MALLOC (name);
   else
     the_passwd.pw_name = "unknown";
 #endif
@@ -238,7 +239,7 @@
 #endif
 
   /* Set dir from environment variables. */
-  the_passwd.pw_dir = (char *) qxestrdup (get_home_directory ());
+  the_passwd.pw_dir = (CIbyte *) qxestrdup (get_home_directory ());
   /* We used to set pw_shell here, but the order is wrong (SHELL gets
      initted in process.c, called later in the init process) and pw_shell
      is not used anywhere. */
@@ -940,7 +941,7 @@
       eilwr (found);
 
     namlen = min (eilen (found), sizeof (dir_static.d_name) - 1);
-    strncpy (dir_static.d_name, (char *) eidata (found), namlen);
+    qxestrncpy ((Ibyte *) dir_static.d_name, eidata (found), namlen);
     dir_static.d_name[namlen] = '\0';
     dir_static.d_namlen = (unsigned short) namlen;
   }
@@ -954,13 +955,15 @@
   NETRESOURCEW nr; 
   HANDLE henum;
   int result;
+  Extbyte *extpath;
 
   nr.dwScope = RESOURCE_GLOBALNET; 
   nr.dwType = RESOURCETYPE_DISK; 
   nr.dwDisplayType = RESOURCEDISPLAYTYPE_SERVER; 
   nr.dwUsage = RESOURCEUSAGE_CONTAINER; 
   nr.lpLocalName = NULL;
-  PATHNAME_CONVERT_OUT (path, nr.lpRemoteName);
+  PATHNAME_CONVERT_OUT (path, extpath);
+  nr.lpRemoteName = (LPTSTR) extpath;
   nr.lpComment = NULL; 
   nr.lpProvider = NULL;   
 
@@ -2002,7 +2005,7 @@
       if (exe_header->e_magic != DOSMAGIC)
 	goto unwind;
 
-      if ((char *) exe_header->e_lfanew > (char *) executable.size)
+      if ((Rawbyte *) exe_header->e_lfanew > (Rawbyte *) executable.size)
 	{
 	  /* Some dos headers (pkunzip) have bogus e_lfanew fields.  */
 	  *is_dos_app = TRUE;
@@ -2019,10 +2022,10 @@
       if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
 	goto unwind;
 	  
-      nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header +
+      nt_header = (PIMAGE_NT_HEADERS) ((Rawbyte *) dos_header +
 				       dos_header->e_lfanew);
 	  
-      if ((char *) nt_header > (char *) dos_header + executable.size) 
+      if ((Rawbyte *) nt_header > (Rawbyte *) dos_header + executable.size) 
 	{
 	  /* Some dos headers (pkunzip) have bogus e_lfanew fields.  */
 	  *is_dos_app = TRUE;