This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

Re: Remaining GNU C isms.


Fernando Nasser wrote:

> I have applied a patch from Philippe De Muyter that fixed that
> occurrence and 3 others (on cli-out.c).

Well, thanx.   Though this one is minor, the duplicated work is a bummer.

> > Also, language.c has the non-C89 'long long' in a few places.  Since
> > they're marked with "FIXME" comments, I assume someone is already on top
> > of this.

> Maybe you could send one to language.c (I am not the maintainer but I
> know it would be welcome).

I resisted the urge to get involved in the language.c fixes because this
code is sort of a mess.  The 'hex_string" functions somewhat overlap
several in utils.c that are more flexible.  The comments about "quick
fix" and "MERGEBUG" didn't fill me with inspiration.

Since one of the offenders had zero callers anywhere in the GDB tree, I
just nuked it.

	* language.c, language.h (longest_raw_hex_string): Delete unused 
	function.

longest_local_hex_string_custom() looked like this:

#ifndef CC_HAS_LONG_LONG
	call a function to do the conversion
	return;
#endif
#if defined PRINTF_HAS_LONG_LONG
	let sprintf do the deed.
	/* NOTE: are you sure that just becuase PRINTF has long long that
	 * SPRINTF has long long?   I think they're separate autoconf tests. 
	 */
	let sprintf do the deed
#else
	do some gunky stuff with long long.
#endif


Also, now that ANSI C is fair fame, I "fixed" the problem by taking
advantage of the mutual exclusion in the preprocessor.  If CC doesn't
have long long, we no longer attempt to compile that stuff that has
'long long' becuase it's guaranteed to fail.

	* language.c (longest_local_hex_string_custom): Don't compile 
	'long long' section if host doesn't have 'long long'.

So this patch to lanaguage.c allows compilation in a C89 environment
again.


Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 language.c
--- language.c	2000/02/02 00:21:08	1.1.1.8
+++ language.c	2000/02/20 20:47:27
@@ -545,24 +545,6 @@ local_hex_format_custom (pre)
   return form;
 }
 
-/* Converts a number to hexadecimal (without leading "0x") and stores it in a
-   static string.  Returns a pointer to this string. */
-
-char *
-longest_raw_hex_string (num)
-     LONGEST num;
-{
-  static char res_longest_raw_hex_string[50];
-  long long ll = num;		/* MERGEBUG ?? see below */
-  res_longest_raw_hex_string[0] = 0;
-  /* MERGEBUG ?? As a quick fix I am replacing this with sprintf 
-     strcat_address_numeric (num, 0, res_longest_raw_hex_string, 50); 
-   */
-
-  sprintf (res_longest_raw_hex_string, "%llx", ll);
-  return res_longest_raw_hex_string;
-}
-
 /* Converts a number to hexadecimal and stores it in a static
    string.  Returns a pointer to this string. */
 char *
@@ -624,9 +606,7 @@ longest_local_hex_string_custom (num, wi
      can use local_hex_string_custom 
    */
   return local_hex_string_custom ((unsigned long) num, width);
-#endif
-
-#if defined (PRINTF_HAS_LONG_LONG)
+#elif defined (PRINTF_HAS_LONG_LONG)
   /* Just use printf.  */
   strcpy (format, local_hex_format_prefix ());	/* 0x */
   strcat (format, "%");
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.1.1.6
diff -u -p -r1.1.1.6 language.h
--- language.h	2000/02/02 00:21:08	1.1.1.6
+++ language.h	2000/02/20 20:47:28
@@ -362,12 +362,6 @@ extern char *
 extern char *
   local_hex_format_custom PARAMS ((char *));	/* language.c */
 
-/* Return a string that contains the hex digits of the number.  No preceeding
-   "0x" */
-
-extern char *
-  longest_raw_hex_string PARAMS ((LONGEST));
-
 /* Return a string that contains a number formatted in one of the local
    (language-specific) formats.  Result is static and is overwritten by
    the next call.  Takes printf options like "08l" or "l".  */

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