This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: improve type safety wrt unsignedness for java


Please CC java-patches@gcc.gnu.org also on Java patches.

Thanks,
Ranjit.


Mike Stump wrote:

> Java fails to be as portable as it should be in that it relies on an 
> overly lax compiler, this fixes it up.  The changes come in two 
> flavors, the cast version, which is very safe, and the change the data 
> from unsigned to signed, or from signed to unsigned, which is slightly 
> more risky.  I've chosen the first method for more instances, except 
> where it was exceedingly simple and obvious.
> 
> Note, in theory there can be other bits of the java compiler that are 
> compiled on other platforms that are not safe that will need fixing 
> post my other checkin.  If anyone spots such a flaw, I'd be happy to 
> fix it, just let me know.
> 
> Ok?
> 
> reg tested on powerpc-apple-darwin7.4.0.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 2004-07-13  Mike Stump  <mrs@apple.com>
> 
> 	* boehm.c (set_bit): Improve type safety wrt unsignedness.
> 	* gjavah.c (throwable_p, decode_signature_piece,
> 	print_full_cxx_name, print_include, add_namelet, add_class_decl,
> 	process_file): Likewise.
> 	* jcf-dump.c (main): Likewise.
> 	* jcf-io.c (read_zip_member): Likewise.
> 	* jcf-parse.c (HANDLE_CONSTANT_Utf8, get_constant,
> 	give_name_to_class, get_class_constant): Likewise.
> 	* jcf-write.c (find_constant_wide, push_long_const,
> 	generate_classfile): Likewise.
> 	* lex.c (java_new_lexer, java_read_char, cxx_keyword_p): Likewise.
> 	* parse.y (read_import_dir): Likewise.
> 	* typeck.c (parse_signature_type): Likewise.
> 	* verify.c (verify_jvm_instructions): Likewise.
> 	* zextract.c (find_zip_file_start, read_zip_archive): Likewise.
> 
> Doing diffs in .:
> *** ./java/boehm.c.~1~	Wed Jan 29 15:21:09 2003
> --- ./java/boehm.c	Mon Jul 12 17:22:04 2004
> *************** set_bit (unsigned HOST_WIDE_INT *low, un
> *** 51,60 ****
>     if (n >= HOST_BITS_PER_WIDE_INT)
>       {
>         n -= HOST_BITS_PER_WIDE_INT;
> !       which = high;
>       }
>     else
> !     which = low;
>   
>     *which |= (HOST_WIDE_INT) 1 << n;
>   }
> --- 51,60 ----
>     if (n >= HOST_BITS_PER_WIDE_INT)
>       {
>         n -= HOST_BITS_PER_WIDE_INT;
> !       which = (HOST_WIDE_INT *) high;
>       }
>     else
> !     which = (HOST_WIDE_INT *) low;
>   
>     *which |= (HOST_WIDE_INT) 1 << n;
>   }
> *** ./java/gjavah.c.~1~	Sat Jun  5 00:01:57 2004
> --- ./java/gjavah.c	Mon Jul 12 17:32:55 2004
> *************** throwable_p (const unsigned char *clname
> *** 1145,1155 ****
>   				    (htab_del) free);
>   
>         /* Make sure the root classes show up in the tables.  */
> !       str = xstrdup ("java.lang.Throwable");
>         slot = htab_find_slot (throw_hash, str, INSERT);
>         *slot = str;
>   
> !       str = xstrdup ("java.lang.Object");
>         slot = htab_find_slot (non_throw_hash, str, INSERT);
>         *slot = str;
>   
> --- 1145,1155 ----
>   				    (htab_del) free);
>   
>         /* Make sure the root classes show up in the tables.  */
> !       str = (unsigned char *) xstrdup ("java.lang.Throwable");
>         slot = htab_find_slot (throw_hash, str, INSERT);
>         *slot = str;
>   
> !       str = (unsigned char *) xstrdup ("java.lang.Object");
>         slot = htab_find_slot (non_throw_hash, str, INSERT);
>         *slot = str;
>   
> *************** throwable_p (const unsigned char *clname
> *** 1176,1182 ****
>         void **slot;
>         unsigned char *super, *tmp;
>         int super_length = -1;
> !       const char *classfile_name = find_class (current, strlen (current),
>   					       &jcf, 0);
>   
>         if (! classfile_name)
> --- 1176,1182 ----
>         void **slot;
>         unsigned char *super, *tmp;
>         int super_length = -1;
> !       const char *classfile_name = find_class ((char *) current, strlen ((const char *) current),
>   					       &jcf, 0);
>   
>         if (! classfile_name)
> *************** decode_signature_piece (FILE *stream, co
> *** 1322,1331 ****
>         if (flag_jni)
>   	{
>   	  /* We know about certain types and special-case their names.  */
> ! 	  if (! strncmp (signature, "Ljava/lang/String;",
>   			 sizeof ("Ljava/lang/String;") -1))
>   	    ctype = "jstring";
> ! 	  else if (! strncmp (signature, "Ljava/lang/Class;",
>   			      sizeof ("Ljava/lang/Class;") - 1))
>   	    ctype = "jclass";
>   	  /* Skip leading 'L' for throwable_p call.  */
> --- 1322,1331 ----
>         if (flag_jni)
>   	{
>   	  /* We know about certain types and special-case their names.  */
> ! 	  if (! strncmp ((const char *) signature, "Ljava/lang/String;",
>   			 sizeof ("Ljava/lang/String;") -1))
>   	    ctype = "jstring";
> ! 	  else if (! strncmp ((const char *) signature, "Ljava/lang/Class;",
>   			      sizeof ("Ljava/lang/Class;") - 1))
>   	    ctype = "jclass";
>   	  /* Skip leading 'L' for throwable_p call.  */
> *************** print_full_cxx_name (FILE* stream, JCF* 
> *** 1470,1476 ****
>         int sig_len = JPOOL_UTF_LENGTH (jcf, signature_index);
>         if (overloaded_jni_method_exists_p (JPOOL_UTF_DATA (jcf, name_index),
>   					  JPOOL_UTF_LENGTH (jcf, name_index),
> ! 					  signature, sig_len))
>   	{
>   	  /* If this method is overloaded by another native method,
>   	     then include the argument information in the mangled
> --- 1470,1476 ----
>         int sig_len = JPOOL_UTF_LENGTH (jcf, signature_index);
>         if (overloaded_jni_method_exists_p (JPOOL_UTF_DATA (jcf, name_index),
>   					  JPOOL_UTF_LENGTH (jcf, name_index),
> ! 					  (const char *) signature, sig_len))
>   	{
>   	  /* If this method is overloaded by another native method,
>   	     then include the argument information in the mangled
> *************** print_include (FILE *out, const unsigned
> *** 1744,1762 ****
>       return;
>   
>     if (len == -1)
> !     len = strlen (utf8);
>   
>     for (incl = all_includes; incl; incl = incl->next)
>       {
>         /* We check the length because we might have a proper prefix.  */
>         if (len == (int) strlen (incl->name)
> ! 	  && ! strncmp (incl->name, utf8, len))
>   	return;
>       }
>   
>     incl = xmalloc (sizeof (struct include));
>     incl->name = xmalloc (len + 1);
> !   strncpy (incl->name, utf8, len);
>     incl->name[len] = '\0';
>     incl->next = all_includes;
>     all_includes = incl;
> --- 1744,1762 ----
>       return;
>   
>     if (len == -1)
> !     len = strlen ((const char *) utf8);
>   
>     for (incl = all_includes; incl; incl = incl->next)
>       {
>         /* We check the length because we might have a proper prefix.  */
>         if (len == (int) strlen (incl->name)
> ! 	  && ! strncmp (incl->name, (const char *) utf8, len))
>   	return;
>       }
>   
>     incl = xmalloc (sizeof (struct include));
>     incl->name = xmalloc (len + 1);
> !   strncpy (incl->name, (const char *) utf8, len);
>     incl->name[len] = '\0';
>     incl->next = all_includes;
>     all_includes = incl;
> *************** add_namelet (const unsigned char *name, 
> *** 1815,1825 ****
>   #define JAVAIO "java/io/"
>   #define JAVAUTIL "java/util/"
>         if ((name_limit - name >= (int) sizeof (JAVALANG) - 1
> ! 	   && ! strncmp (name, JAVALANG, sizeof (JAVALANG) - 1))
>   	  || (name_limit - name >= (int) sizeof (JAVAUTIL) - 1
> ! 	      && ! strncmp (name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
>   	  || (name_limit - name >= (int) sizeof (JAVAIO) - 1
> ! 	      && ! strncmp (name, JAVAIO, sizeof (JAVAIO) - 1)))
>   	return;
>       }
>   
> --- 1815,1825 ----
>   #define JAVAIO "java/io/"
>   #define JAVAUTIL "java/util/"
>         if ((name_limit - name >= (int) sizeof (JAVALANG) - 1
> ! 	   && ! strncmp ((const char *) name, JAVALANG, sizeof (JAVALANG) - 1))
>   	  || (name_limit - name >= (int) sizeof (JAVAUTIL) - 1
> ! 	      && ! strncmp ((const char *) name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
>   	  || (name_limit - name >= (int) sizeof (JAVAIO) - 1
> ! 	      && ! strncmp ((const char *) name, JAVAIO, sizeof (JAVAIO) - 1)))
>   	return;
>       }
>   
> *************** add_namelet (const unsigned char *name, 
> *** 1831,1837 ****
>       {
>         /* We check the length because we might have a proper prefix.  */
>         if ((int) strlen (np->name) == p - name &&
> ! 	  ! strncmp (name, np->name, p - name))
>   	{
>   	  n = np;
>   	  break;
> --- 1831,1837 ----
>       {
>         /* We check the length because we might have a proper prefix.  */
>         if ((int) strlen (np->name) == p - name &&
> ! 	  ! strncmp ((const char *) name, np->name, p - name))
>   	{
>   	  n = np;
>   	  break;
> *************** add_namelet (const unsigned char *name, 
> *** 1842,1848 ****
>       {
>         n = xmalloc (sizeof (struct namelet));
>         n->name = xmalloc (p - name + 1);
> !       strncpy (n->name, name, p - name);
>         n->name[p - name] = '\0';
>         n->is_class = (p == name_limit);
>         n->subnamelets = NULL;
> --- 1842,1848 ----
>       {
>         n = xmalloc (sizeof (struct namelet));
>         n->name = xmalloc (p - name + 1);
> !       strncpy (n->name, (const char *) name, p - name);
>         n->name[p - name] = '\0';
>         n->is_class = (p == name_limit);
>         n->subnamelets = NULL;
> *************** add_class_decl (FILE *out, JCF *jcf, JCF
> *** 1924,1930 ****
>         /* If we see an array, then we include the array header.  */
>         if (s[i] == '[')
>   	{
> ! 	  print_include (out, "gcj/array", -1);
>   	  continue;
>   	}
>   
> --- 1924,1930 ----
>         /* If we see an array, then we include the array header.  */
>         if (s[i] == '[')
>   	{
> ! 	  print_include (out, (const unsigned char *) "gcj/array", -1);
>   	  continue;
>   	}
>   
> *************** process_file (JCF *jcf, FILE *out)
> *** 2095,2107 ****
>   	  for (i = 0; i < len; ++i)
>   	    name[i] = jcf->classname[i] == '.' ? '/' : jcf->classname[i];
>   	  name[i] = '\0';
> ! 	  print_include (out, name, len);
>   	  free (name);
>   
>   	  if (! flag_jni)
>   	    {
> ! 	      print_include (out, "gcj/cni", -1);
> ! 	      print_include (out, "java/lang/UnsupportedOperationException",
>   			     -1);
>   	    }
>   	}
> --- 2095,2107 ----
>   	  for (i = 0; i < len; ++i)
>   	    name[i] = jcf->classname[i] == '.' ? '/' : jcf->classname[i];
>   	  name[i] = '\0';
> ! 	  print_include (out, (const unsigned char *) name, len);
>   	  free (name);
>   
>   	  if (! flag_jni)
>   	    {
> ! 	      print_include (out, (const unsigned char *) "gcj/cni", -1);
> ! 	      print_include (out, (const unsigned char *) "java/lang/UnsupportedOperationException",
>   			     -1);
>   	    }
>   	}
> *** ./java/jcf-dump.c.~1~	Tue Mar 23 18:33:53 2004
> --- ./java/jcf-dump.c	Mon Jul 12 17:33:47 2004
> *************** main (int argc, char** argv)
> *** 1080,1086 ****
>   		  if (jcf->read_end - jcf->read_ptr < total_length)
>   		    jcf_trim_old_input (jcf);
>   		  JCF_FILL (jcf, total_length);
> ! 		  filename = jcf->read_ptr;
>   		  JCF_SKIP (jcf, filename_length);
>   		  JCF_SKIP (jcf, extra_length);
>   		  if (filename_length > 0
> --- 1080,1086 ----
>   		  if (jcf->read_end - jcf->read_ptr < total_length)
>   		    jcf_trim_old_input (jcf);
>   		  JCF_FILL (jcf, total_length);
> ! 		  filename = (const char *) jcf->read_ptr;
>   		  JCF_SKIP (jcf, filename_length);
>   		  JCF_SKIP (jcf, extra_length);
>   		  if (filename_length > 0
> *** ./java/jcf-io.c.~1~	Sat Apr 10 09:04:09 2004
> --- ./java/jcf-io.c	Mon Jul 12 16:53:12 2004
> *************** read_zip_member (JCF *jcf,  ZipDirectory
> *** 215,221 ****
>         jcf->read_ptr = jcf->buffer;
>         jcf->read_end = jcf->buffer_end;
>         buffer = ALLOC (zipd->size);
> !       d_stream.next_in = buffer;
>         d_stream.avail_in = zipd->size;
>         if (lseek (zipf->fd, zipd->filestart, 0) < 0
>   	  || read (zipf->fd, buffer, zipd->size) != (long) zipd->size)
> --- 215,221 ----
>         jcf->read_ptr = jcf->buffer;
>         jcf->read_end = jcf->buffer_end;
>         buffer = ALLOC (zipd->size);
> !       d_stream.next_in = (unsigned char *) buffer;
>         d_stream.avail_in = zipd->size;
>         if (lseek (zipf->fd, zipd->filestart, 0) < 0
>   	  || read (zipf->fd, buffer, zipd->size) != (long) zipd->size)
> *** ./java/jcf-parse.c.~1~	Wed Jul  7 17:09:20 2004
> --- ./java/jcf-parse.c	Mon Jul 12 16:59:05 2004
> *************** The Free Software Foundation is independ
> *** 64,70 ****
>       text = (JCF)->read_ptr; \
>       save = text[LENGTH]; \
>       text[LENGTH] = 0; \
> !     (JCF)->cpool.data[INDEX].t = get_identifier (text); \
>       text[LENGTH] = save; \
>       JCF_SKIP (JCF, LENGTH); } while (0)
>   
> --- 64,70 ----
>       text = (JCF)->read_ptr; \
>       save = text[LENGTH]; \
>       text[LENGTH] = 0; \
> !     (JCF)->cpool.data[INDEX].t = get_identifier ((const char *) text); \
>       text[LENGTH] = save; \
>       JCF_SKIP (JCF, LENGTH); } while (0)
>   
> *************** get_constant (JCF *jcf, int index)
> *** 273,279 ****
>       case CONSTANT_Long:
>         {
>   	unsigned HOST_WIDE_INT num = JPOOL_UINT (jcf, index);
> ! 	HOST_WIDE_INT lo, hi;
>   	lshift_double (num, 0, 32, 64, &lo, &hi, 0);
>   	num = JPOOL_UINT (jcf, index+1);
>   	add_double (lo, hi, num, 0, &lo, &hi);
> --- 273,280 ----
>       case CONSTANT_Long:
>         {
>   	unsigned HOST_WIDE_INT num = JPOOL_UINT (jcf, index);
> ! 	unsigned HOST_WIDE_INT lo;
> ! 	HOST_WIDE_INT hi;
>   	lshift_double (num, 0, 32, 64, &lo, &hi, 0);
>   	num = JPOOL_UINT (jcf, index+1);
>   	add_double (lo, hi, num, 0, &lo, &hi);
> *************** give_name_to_class (JCF *jcf, int i)
> *** 411,417 ****
>         tree this_class;
>         int j = JPOOL_USHORT1 (jcf, i);
>         /* verify_constant_pool confirmed that j is a CONSTANT_Utf8. */
> !       tree class_name = unmangle_classname (JPOOL_UTF_DATA (jcf, j),
>   					    JPOOL_UTF_LENGTH (jcf, j));
>         this_class = lookup_class (class_name);
>         input_filename = DECL_SOURCE_FILE (TYPE_NAME (this_class));
> --- 412,418 ----
>         tree this_class;
>         int j = JPOOL_USHORT1 (jcf, i);
>         /* verify_constant_pool confirmed that j is a CONSTANT_Utf8. */
> !       tree class_name = unmangle_classname ((const char *) JPOOL_UTF_DATA (jcf, j),
>   					    JPOOL_UTF_LENGTH (jcf, j));
>         this_class = lookup_class (class_name);
>         input_filename = DECL_SOURCE_FILE (TYPE_NAME (this_class));
> *************** get_class_constant (JCF *jcf, int i)
> *** 439,449 ****
>       {
>         int name_index = JPOOL_USHORT1 (jcf, i);
>         /* verify_constant_pool confirmed that name_index is a CONSTANT_Utf8. */
> !       const char *name = JPOOL_UTF_DATA (jcf, name_index);
>         int nlength = JPOOL_UTF_LENGTH (jcf, name_index);
>   
>         if (name[0] == '[')  /* Handle array "classes". */
> ! 	  type = TREE_TYPE (parse_signature_string (name, nlength));
>         else
>           { 
>             tree cname = unmangle_classname (name, nlength);
> --- 440,450 ----
>       {
>         int name_index = JPOOL_USHORT1 (jcf, i);
>         /* verify_constant_pool confirmed that name_index is a CONSTANT_Utf8. */
> !       const char *name = (const char *) JPOOL_UTF_DATA (jcf, name_index);
>         int nlength = JPOOL_UTF_LENGTH (jcf, name_index);
>   
>         if (name[0] == '[')  /* Handle array "classes". */
> ! 	  type = TREE_TYPE (parse_signature_string ((const unsigned char *) name, nlength));
>         else
>           { 
>             tree cname = unmangle_classname (name, nlength);
> *** ./java/jcf-write.c.~1~	Wed Jul  7 17:09:21 2004
> --- ./java/jcf-write.c	Mon Jul 12 17:20:11 2004
> *************** static int
> *** 772,778 ****
>   find_constant_wide (HOST_WIDE_INT lo, HOST_WIDE_INT hi,
>   		    struct jcf_partial *state)
>   {
> !   HOST_WIDE_INT w1, w2;
>     lshift_double (lo, hi, -32, 64, &w1, &w2, 1);
>     return find_constant2 (&state->cpool, CONSTANT_Long,
>   			 (jword)(w1 & 0xFFFFFFFF), (jword)(lo & 0xFFFFFFFF));
> --- 772,779 ----
>   find_constant_wide (HOST_WIDE_INT lo, HOST_WIDE_INT hi,
>   		    struct jcf_partial *state)
>   {
> !   unsigned HOST_WIDE_INT w1;
> !   HOST_WIDE_INT w2;
>     lshift_double (lo, hi, -32, 64, &w1, &w2, 1);
>     return find_constant2 (&state->cpool, CONSTANT_Long,
>   			 (jword)(w1 & 0xFFFFFFFF), (jword)(lo & 0xFFFFFFFF));
> *************** find_constant_index (tree value, struct 
> *** 822,828 ****
>   static void
>   push_long_const (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state)
>   {
> !   HOST_WIDE_INT highpart, dummy;
>     jint lowpart = WORD_TO_INT (lo);
>   
>     rshift_double (lo, hi, 32, 64, &highpart, &dummy, 1);
> --- 823,830 ----
>   static void
>   push_long_const (HOST_WIDE_INT lo, HOST_WIDE_INT hi, struct jcf_partial *state)
>   {
> !   unsigned HOST_WIDE_INT highpart;
> !   HOST_WIDE_INT dummy;
>     jint lowpart = WORD_TO_INT (lo);
>   
>     rshift_double (lo, hi, 32, 64, &highpart, &dummy, 1);
> *************** push_long_const (HOST_WIDE_INT lo, HOST_
> *** 833,839 ****
>         OP1(OPCODE_lconst_0 + lowpart);
>       }
>     else if ((highpart == 0 && lowpart > 0 && lowpart < 32768) 
> ! 	   || (highpart == -1 && lowpart < 0 && lowpart >= -32768))
>         {
>           push_int_const (lowpart, state);
>           RESERVE (1);
> --- 835,842 ----
>         OP1(OPCODE_lconst_0 + lowpart);
>       }
>     else if ((highpart == 0 && lowpart > 0 && lowpart < 32768) 
> ! 	   || (highpart == (unsigned HOST_WIDE_INT)-1
> ! 	       && lowpart < 0 && lowpart >= -32768))
>         {
>           push_int_const (lowpart, state);
>           RESERVE (1);
> *************** generate_classfile (tree clas, struct jc
> *** 2913,2923 ****
>   {
>     struct chunk *cpool_chunk;
>     const char *source_file, *s;
> !   char *ptr;
>     int i;
> !   char *fields_count_ptr;
>     int fields_count = 0;
> !   char *methods_count_ptr;
>     int methods_count = 0;
>     tree part;
>     int total_supers
> --- 2916,2926 ----
>   {
>     struct chunk *cpool_chunk;
>     const char *source_file, *s;
> !   unsigned char *ptr;
>     int i;
> !   unsigned char *fields_count_ptr;
>     int fields_count = 0;
> !   unsigned char *methods_count_ptr;
>     int methods_count = 0;
>     tree part;
>     int total_supers
> *************** generate_classfile (tree clas, struct jc
> *** 3063,3069 ****
>   	  int code_attributes_count = 0;
>   	  static tree Code_node = NULL_TREE;
>   	  tree t;
> ! 	  char *attr_len_ptr;
>   	  struct jcf_handler *handler;
>   	  if (Code_node == NULL_TREE)
>   	    Code_node = get_identifier ("Code");
> --- 3066,3072 ----
>   	  int code_attributes_count = 0;
>   	  static tree Code_node = NULL_TREE;
>   	  tree t;
> ! 	  unsigned char *attr_len_ptr;
>   	  struct jcf_handler *handler;
>   	  if (Code_node == NULL_TREE)
>   	    Code_node = get_identifier ("Code");
> *** ./java/lex.c.~1~	Sat Jun  5 00:01:58 2004
> --- ./java/lex.c	Mon Jul 12 16:39:44 2004
> *************** java_new_lexer (FILE *finput, const char
> *** 264,270 ****
>   	      in[1] = 0xbb;
>   	      in[2] = 0xbf;
>   
> ! 	      inp = in;
>   	      inc = 3;
>   	      outp = (char *) &result;
>   	      outc = 2;
> --- 264,270 ----
>   	      in[1] = 0xbb;
>   	      in[2] = 0xbf;
>   
> ! 	      inp = (char *) in;
>   	      inc = 3;
>   	      outp = (char *) &result;
>   	      outc = 2;
> *************** java_read_char (java_lexer *lex)
> *** 377,383 ****
>   	      in_save = inbytesleft;
>   	      out_save = out_count;
>   	      inp = &lex->buffer[lex->first];
> ! 	      outp = &lex->out_buffer[lex->out_last];
>   	      ir = iconv (lex->handle, (ICONV_CONST char **) &inp,
>   			  &inbytesleft, &outp, &out_count);
>   
> --- 377,383 ----
>   	      in_save = inbytesleft;
>   	      out_save = out_count;
>   	      inp = &lex->buffer[lex->first];
> ! 	      outp = (char *) &lex->out_buffer[lex->out_last];
>   	      ir = iconv (lex->handle, (ICONV_CONST char **) &inp,
>   			  &inbytesleft, &outp, &out_count);
>   
> *************** cxx_keyword_p (const char *name, int len
> *** 2031,2037 ****
>       {
>         int kwl = strlen (cxx_keywords[mid]);
>         int min_length = kwl > length ? length : kwl;
> !       int r = utf8_cmp (name, min_length, cxx_keywords[mid]);
>   
>         if (r == 0)
>   	{
> --- 2031,2037 ----
>       {
>         int kwl = strlen (cxx_keywords[mid]);
>         int min_length = kwl > length ? length : kwl;
> !       int r = utf8_cmp ((const unsigned char *) name, min_length, cxx_keywords[mid]);
>   
>         if (r == 0)
>   	{
> *** ./java/parse.y.~1~	Wed Jul  7 17:09:21 2004
> --- ./java/parse.y	Mon Jul 12 16:38:56 2004
> *************** read_import_dir (tree wfl)
> *** 6913,6919 ****
>   	  buffer_grow (filename, entry_length);
>   	  memcpy (filename->data, entry_name, entry_length - 1);
>   	  filename->data[entry_length-1] = '\0';
> ! 	  zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
>   	  if (zipf == NULL)
>   	    error ("malformed .zip archive in CLASSPATH: %s", entry_name);
>   	  else
> --- 6913,6919 ----
>   	  buffer_grow (filename, entry_length);
>   	  memcpy (filename->data, entry_name, entry_length - 1);
>   	  filename->data[entry_length-1] = '\0';
> ! 	  zipf = opendir_in_zip ((const char *) filename->data, jcf_path_is_system (entry));
>   	  if (zipf == NULL)
>   	    error ("malformed .zip archive in CLASSPATH: %s", entry_name);
>   	  else
> *************** read_import_dir (tree wfl)
> *** 6933,6939 ****
>   		  int current_entry_len = zipd->filename_length;
>   
>   		  if (current_entry_len >= BUFFER_LENGTH (filename)
> ! 		      && strncmp (filename->data, current_entry,
>   				  BUFFER_LENGTH (filename)) != 0)
>   		    continue;
>   		  found |= note_possible_classname (current_entry,
> --- 6933,6939 ----
>   		  int current_entry_len = zipd->filename_length;
>   
>   		  if (current_entry_len >= BUFFER_LENGTH (filename)
> ! 		      && strncmp ((const char *) filename->data, current_entry,
>   				  BUFFER_LENGTH (filename)) != 0)
>   		    continue;
>   		  found |= note_possible_classname (current_entry,
> *************** read_import_dir (tree wfl)
> *** 6945,6951 ****
>   	{
>   	  BUFFER_RESET (filename);
>   	  buffer_grow (filename, entry_length + package_length + 4);
> ! 	  strcpy (filename->data, entry_name);
>   	  filename->ptr = filename->data + entry_length;
>   	  for (k = 0; k < package_length; k++)
>   	    {
> --- 6945,6951 ----
>   	{
>   	  BUFFER_RESET (filename);
>   	  buffer_grow (filename, entry_length + package_length + 4);
> ! 	  strcpy ((char *) filename->data, entry_name);
>   	  filename->ptr = filename->data + entry_length;
>   	  for (k = 0; k < package_length; k++)
>   	    {
> *************** read_import_dir (tree wfl)
> *** 6954,6960 ****
>   	    }
>   	  *filename->ptr = '\0';
>   
> ! 	  dirp = opendir (filename->data);
>   	  if (dirp == NULL)
>   	    continue;
>   	  *filename->ptr++ = '/';
> --- 6954,6960 ----
>   	    }
>   	  *filename->ptr = '\0';
>   
> ! 	  dirp = opendir ((const char *) filename->data);
>   	  if (dirp == NULL)
>   	    continue;
>   	  *filename->ptr++ = '/';
> *************** read_import_dir (tree wfl)
> *** 6968,6975 ****
>   	      d_name = direntp->d_name;
>   	      len = strlen (direntp->d_name);
>   	      buffer_grow (filename, len+1);
> ! 	      strcpy (filename->ptr, d_name);
> ! 	      found |= note_possible_classname (filename->data + entry_length,
>   						package_length+len+1);
>   	    }
>   	  if (dirp)
> --- 6968,6975 ----
>   	      d_name = direntp->d_name;
>   	      len = strlen (direntp->d_name);
>   	      buffer_grow (filename, len+1);
> ! 	      strcpy ((char *) filename->ptr, d_name);
> ! 	      found |= note_possible_classname ((const char *) filename->data + entry_length,
>   						package_length+len+1);
>   	    }
>   	  if (dirp)
> *** ./java/typeck.c.~1~	Wed Jul  7 17:09:21 2004
> --- ./java/typeck.c	Mon Jul 12 16:44:02 2004
> *************** parse_signature_type (const unsigned cha
> *** 496,502 ****
>   	      break;
>   	  }
>   	*ptr = str+1;
> ! 	type = lookup_class (unmangle_classname (start, str - start));
>   	break;
>         }
>       default:
> --- 496,502 ----
>   	      break;
>   	  }
>   	*ptr = str+1;
> ! 	type = lookup_class (unmangle_classname ((const char *) start, str - start));
>   	break;
>         }
>       default:
> *** ./java/verify.c.~1~	Wed Jul  7 17:09:21 2004
> --- ./java/verify.c	Mon Jul 12 16:49:35 2004
> *************** verify_jvm_instructions (JCF* jcf, const
> *** 1093,1099 ****
>   
>   	    self_is_interface = CLASS_INTERFACE (TYPE_NAME (self_type));
>   	    method_name = COMPONENT_REF_NAME (&current_jcf->cpool, index);
> ! 	    method_type = parse_signature_string (IDENTIFIER_POINTER (sig),
>   						  IDENTIFIER_LENGTH (sig));
>   
>   	    if (TREE_CODE (method_type) != FUNCTION_TYPE)
> --- 1093,1099 ----
>   
>   	    self_is_interface = CLASS_INTERFACE (TYPE_NAME (self_type));
>   	    method_name = COMPONENT_REF_NAME (&current_jcf->cpool, index);
> ! 	    method_type = parse_signature_string ((const unsigned char *) IDENTIFIER_POINTER (sig),
>   						  IDENTIFIER_LENGTH (sig));
>   
>   	    if (TREE_CODE (method_type) != FUNCTION_TYPE)
> *** ./java/zextract.c.~1~	Wed Jul  7 17:09:21 2004
> --- ./java/zextract.c	Mon Jul 12 16:48:51 2004
> *************** find_zip_file_start (int fd, long offset
> *** 264,270 ****
>     if (read (fd, buffer, LREC_SIZE + 4) != LREC_SIZE + 4)
>       return -1;
>   
> !   if (buffer[0] != 'P' || strncmp (&buffer[1], LOCAL_HDR_SIG, 3))
>       return -1;
>   
>     filename_length = makeword (&buffer[4 + L_FILENAME_LENGTH]);
> --- 264,270 ----
>     if (read (fd, buffer, LREC_SIZE + 4) != LREC_SIZE + 4)
>       return -1;
>   
> !   if (buffer[0] != 'P' || strncmp ((const char *) &buffer[1], LOCAL_HDR_SIG, 3))
>       return -1;
>   
>     filename_length = makeword (&buffer[4 + L_FILENAME_LENGTH]);
> *************** read_zip_archive (ZipFile *zipf)
> *** 287,294 ****
>       return -1;
>     if (read (zipf->fd, buffer, ECREC_SIZE+4) != ECREC_SIZE+4)
>       return -2;
> !   zipf->count = makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]);
> !   zipf->dir_size = makelong(&buffer[SIZE_CENTRAL_DIRECTORY]);
>   #define ALLOC xmalloc
>     /* Allocate 1 more to allow appending '\0' to last filename. */
>     zipf->central_directory = ALLOC (zipf->dir_size+1);
> --- 287,294 ----
>       return -1;
>     if (read (zipf->fd, buffer, ECREC_SIZE+4) != ECREC_SIZE+4)
>       return -2;
> !   zipf->count = makeword((const uch *) &buffer[TOTAL_ENTRIES_CENTRAL_DIR]);
> !   zipf->dir_size = makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]);
>   #define ALLOC xmalloc
>     /* Allocate 1 more to allow appending '\0' to last filename. */
>     zipf->central_directory = ALLOC (zipf->dir_size+1);
> *************** read_zip_archive (ZipFile *zipf)
> *** 306,314 ****
>     printf ("total_entries_central_dir = %d\n",
>           makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]));
>     printf ("size_central_directory = %d\n",
> !         makelong(&buffer[SIZE_CENTRAL_DIRECTORY]));
>     printf ("offset_start_central_directory = %d\n",
> !         makelong(&buffer[OFFSET_START_CENTRAL_DIRECTORY]));
>     printf ("zipfile_comment_length = %d\n",
>           makeword(&buffer[ZIPFILE_COMMENT_LENGTH]));
>   #endif
> --- 306,314 ----
>     printf ("total_entries_central_dir = %d\n",
>           makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]));
>     printf ("size_central_directory = %d\n",
> !         makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]));
>     printf ("offset_start_central_directory = %d\n",
> !         makelong((const uch *) &buffer[OFFSET_START_CENTRAL_DIRECTORY]));
>     printf ("zipfile_comment_length = %d\n",
>           makeword(&buffer[ZIPFILE_COMMENT_LENGTH]));
>   #endif
> *************** read_zip_archive (ZipFile *zipf)
> *** 319,329 ****
>       {
>         ZipDirectory *zipd = (ZipDirectory*)(dir_ptr + dir_last_pad);
>         int compression_method = (int) dir_ptr[4+C_COMPRESSION_METHOD];
> !       long size = makelong (&dir_ptr[4+C_COMPRESSED_SIZE]);
> !       long uncompressed_size = makelong (&dir_ptr[4+C_UNCOMPRESSED_SIZE]);
> !       long filename_length = makeword (&dir_ptr[4+C_FILENAME_LENGTH]);
> !       long extra_field_length = makeword (&dir_ptr[4+C_EXTRA_FIELD_LENGTH]);
> !       long file_offset = makelong (&dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]);
>         int unpadded_direntry_length;
>         if ((dir_ptr-zipf->central_directory)+filename_length+CREC_SIZE+4>zipf->dir_size)
>   	return -1;
> --- 319,329 ----
>       {
>         ZipDirectory *zipd = (ZipDirectory*)(dir_ptr + dir_last_pad);
>         int compression_method = (int) dir_ptr[4+C_COMPRESSION_METHOD];
> !       long size = makelong ((const uch *) &dir_ptr[4+C_COMPRESSED_SIZE]);
> !       long uncompressed_size = makelong ((const uch *) &dir_ptr[4+C_UNCOMPRESSED_SIZE]);
> !       long filename_length = makeword ((const uch *) &dir_ptr[4+C_FILENAME_LENGTH]);
> !       long extra_field_length = makeword ((const uch *) &dir_ptr[4+C_EXTRA_FIELD_LENGTH]);
> !       long file_offset = makelong ((const uch *) &dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]);
>         int unpadded_direntry_length;
>         if ((dir_ptr-zipf->central_directory)+filename_length+CREC_SIZE+4>zipf->dir_size)
>   	return -1;
> --------------


-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]