This is the mail archive of the gdb-patches@sources.redhat.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]
Other format: [Raw text]

[patch] use phex_nz() not sprintf()


FYI,

Peter Schauer send me this (I was having mental blanks as to how to 
portably fix it).

I've checked it in.

Andrew
2002-01-12  Andrew Cagney  <ac131313@redhat.com>

	From Peter Schauer:
	* language.c (longest_local_hex_string_custom): Use phex_nz to
	convert NUM to a hex string.

Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.18
diff -p -r1.18 language.c
*** language.c	2002/01/12 05:19:10	1.18
--- language.c	2002/01/12 19:47:31
*************** longest_local_hex_string_custom (LONGEST
*** 662,682 ****
    sprintf (res2, format, num);
    return res2;
  #else /* !defined (PRINTF_HAS_LONG_LONG) */
!   /* Use strcat_address_numeric to print the number into a string, then
       build the result string from local_hex_format_prefix, padding and 
       the hex representation as indicated by "width".  */
! 
!   temp_nbr_buf[0] = 0;
!   /* With use_local == 0, we don't get the leading "0x" prefix. */
!   /* MERGEBUG ?? As a quick fix I am replacing this call to
!      strcat_address_numeric with sprintf
!      strcat_address_numeric(num, 0, temp_nbr_buf, RESULT_BUF_LEN);
!    */
! 
!   {
!     long long ll = num;
!     sprintf (temp_nbr_buf, "%llx", ll);
!   }
    /* parse width */
    parse_ptr = width;
    pad_on_left = 1;
--- 662,671 ----
    sprintf (res2, format, num);
    return res2;
  #else /* !defined (PRINTF_HAS_LONG_LONG) */
!   /* Use phex_nz to print the number into a string, then
       build the result string from local_hex_format_prefix, padding and 
       the hex representation as indicated by "width".  */
!   strcpy (temp_nbr_buf, phex_nz (num, sizeof (num)));
    /* parse width */
    parse_ptr = width;
    pad_on_left = 1;

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