This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Constify libdecnumber


None of libdecnumber's APIs seem to have been constified, leaving
e.g. gcc/dfp.c with lots of gratuitous -Wcast-qual warnings where one
has to cast away constness.  Since 4.2 is the first release of
libdecnumber, I'd like to get the APIs fixed before it gets out in the
wild.  This patch constifies the string patameters, I'll do other
types next.

Bootstrapped on sparc-sun-solaris2.10, okay for mainline?

		Thanks,
		--Kaveh


2006-08-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* decContext.c (decContextSetStatusFromString): Constify.
	* decContext.h (decContextSetStatusFromString): Likewise.
	* decNumber.c (decNumberFromString): Likewise.
	* decNumber.h (decNumberFromString): Likewise.
	* decimal128.c (decimal128FromString): Likewise.
	* decimal128.h (decimal128FromString): Likewise.
	* decimal32.c (decimal32FromString): Likewise.
	* decimal32.h (decimal32FromString): Likewise.
	* decimal64.c (decimal64FromString): Likewise.
	* decimal64.h (decimal64FromString): Likewise.

diff -rup orig/egcc-SVN20060816/libdecnumber/decContext.c egcc-SVN20060816/libdecnumber/decContext.c
--- orig/egcc-SVN20060816/libdecnumber/decContext.c	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decContext.c	2006-08-18 08:54:31.033599216 -0400
@@ -162,7 +162,7 @@ decContextStatusToString (decContext * c
 /*    returned.                                                       */
 /* ------------------------------------------------------------------ */
 decContext *
-decContextSetStatusFromString (decContext * context, char *string)
+decContextSetStatusFromString (decContext * context, const char *string)
 {
   if (strcmp (string, DEC_Condition_CS) == 0)
     return decContextSetStatus (context, DEC_Conversion_syntax);
diff -rup orig/egcc-SVN20060816/libdecnumber/decContext.h egcc-SVN20060816/libdecnumber/decContext.h
--- orig/egcc-SVN20060816/libdecnumber/decContext.h	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decContext.h	2006-08-18 08:54:33.769076693 -0400
@@ -173,6 +173,6 @@ typedef struct
 decContext *decContextDefault (decContext *, int32_t);
 decContext *decContextSetStatus (decContext *, uint32_t);
 const char *decContextStatusToString (decContext *);
-decContext *decContextSetStatusFromString (decContext *, char *);
+decContext *decContextSetStatusFromString (decContext *, const char *);
 
 #endif
diff -rup orig/egcc-SVN20060816/libdecnumber/decNumber.c egcc-SVN20060816/libdecnumber/decNumber.c
--- orig/egcc-SVN20060816/libdecnumber/decNumber.c	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decNumber.c	2006-08-18 08:43:35.660839982 -0400
@@ -339,7 +339,7 @@ decNumberToEngString (decNumber * dn, ch
 /* If bad syntax is detected, the result will be a quiet NaN.         */
 /* ------------------------------------------------------------------ */
 decNumber *
-decNumberFromString (decNumber * dn, char chars[], decContext * set)
+decNumberFromString (decNumber * dn, const char chars[], decContext * set)
 {
   Int exponent = 0;		/* working exponent [assume 0] */
   uByte bits = 0;		/* working flags [assume +ve] */
@@ -348,11 +348,11 @@ decNumberFromString (decNumber * dn, cha
   Unit *allocres = NULL;	/* -> allocated result, iff allocated */
   Int need;			/* units needed for result */
   Int d = 0;			/* count of digits found in decimal part */
-  char *dotchar = NULL;		/* where dot was found */
-  char *cfirst;			/* -> first character of decimal part */
-  char *last = NULL;		/* -> last digit of decimal part */
-  char *firstexp;		/* -> first significant exponent digit */
-  char *c;			/* work */
+  const char *dotchar = NULL;	/* where dot was found */
+  const char *cfirst;		/* -> first character of decimal part */
+  const char *last = NULL;	/* -> last digit of decimal part */
+  const char *firstexp;		/* -> first significant exponent digit */
+  const char *c;		/* work */
   Unit *up;			/* .. */
 #if DECDPUN>1
   Int i;			/* .. */
diff -rup orig/egcc-SVN20060816/libdecnumber/decNumber.h egcc-SVN20060816/libdecnumber/decNumber.h
--- orig/egcc-SVN20060816/libdecnumber/decNumber.h	2006-06-23 20:01:26.000000000 -0400
+++ egcc-SVN20060816/libdecnumber/decNumber.h	2006-08-18 08:42:18.442139646 -0400
@@ -129,7 +129,7 @@ typedef struct
 #endif
 
   /* Conversions */
-decNumber *decNumberFromString (decNumber *, char *, decContext *);
+decNumber *decNumberFromString (decNumber *, const char *, decContext *);
 char *decNumberToString (decNumber *, char *);
 char *decNumberToEngString (decNumber *, char *);
 
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal128.c egcc-SVN20060816/libdecnumber/decimal128.c
--- orig/egcc-SVN20060816/libdecnumber/decimal128.c	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal128.c	2006-08-18 08:50:07.874694862 -0400
@@ -296,7 +296,7 @@ decimal128ToEngString (decimal128 * d128
 /* If an error occurs, the result will be a valid decimal128 NaN.     */
 /* ------------------------------------------------------------------ */
 decimal128 *
-decimal128FromString (decimal128 * result, char *string, decContext * set)
+decimal128FromString (decimal128 * result, const char *string, decContext * set)
 {
   decContext dc;		/* work */
   decNumber dn;			/* .. */
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal128.h egcc-SVN20060816/libdecnumber/decimal128.h
--- orig/egcc-SVN20060816/libdecnumber/decimal128.h	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal128.h	2006-08-18 08:50:10.017148077 -0400
@@ -102,7 +102,7 @@ typedef struct
 #endif
 
   /* String conversions */
-decimal128 *decimal128FromString (decimal128 *, char *, decContext *);
+decimal128 *decimal128FromString (decimal128 *, const char *, decContext *);
 char *decimal128ToString (decimal128 *, char *);
 char *decimal128ToEngString (decimal128 *, char *);
 
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal32.c egcc-SVN20060816/libdecnumber/decimal32.c
--- orig/egcc-SVN20060816/libdecnumber/decimal32.c	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal32.c	2006-08-18 08:52:07.845011858 -0400
@@ -288,7 +288,7 @@ decimal32ToEngString (decimal32 * d32, c
 /* If an error occurs, the result will be a valid decimal32 NaN.      */
 /* ------------------------------------------------------------------ */
 decimal32 *
-decimal32FromString (decimal32 * result, char *string, decContext * set)
+decimal32FromString (decimal32 * result, const char *string, decContext * set)
 {
   decContext dc;		/* work */
   decNumber dn;			/* .. */
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal32.h egcc-SVN20060816/libdecnumber/decimal32.h
--- orig/egcc-SVN20060816/libdecnumber/decimal32.h	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal32.h	2006-08-18 08:52:23.093338124 -0400
@@ -92,7 +92,7 @@ typedef struct
 #endif
 
 /* String conversions.  */
-decimal32 *decimal32FromString (decimal32 *, char *, decContext *);
+decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
 char *decimal32ToString (decimal32 *, char *);
 char *decimal32ToEngString (decimal32 *, char *);
 
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal64.c egcc-SVN20060816/libdecnumber/decimal64.c
--- orig/egcc-SVN20060816/libdecnumber/decimal64.c	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal64.c	2006-08-18 08:52:55.853150514 -0400
@@ -287,7 +287,7 @@ decimal64ToEngString (decimal64 * d64, c
 /* If an error occurs, the result will be a valid decimal64 NaN.      */
 /* ------------------------------------------------------------------ */
 decimal64 *
-decimal64FromString (decimal64 * result, char *string, decContext * set)
+decimal64FromString (decimal64 * result, const char *string, decContext * set)
 {
   decContext dc;		/* work */
   decNumber dn;			/* .. */
diff -rup orig/egcc-SVN20060816/libdecnumber/decimal64.h egcc-SVN20060816/libdecnumber/decimal64.h
--- orig/egcc-SVN20060816/libdecnumber/decimal64.h	2006-01-22 23:25:41.000000000 -0500
+++ egcc-SVN20060816/libdecnumber/decimal64.h	2006-08-18 08:52:57.709696881 -0400
@@ -96,7 +96,7 @@ typedef struct
 #endif
 
   /* String conversions */
-decimal64 *decimal64FromString (decimal64 *, char *, decContext *);
+decimal64 *decimal64FromString (decimal64 *, const char *, decContext *);
 char *decimal64ToString (decimal64 *, char *);
 char *decimal64ToEngString (decimal64 *, char *);


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