[Gmp-commit] /home/hgfiles/gmp: Add 'const' to variables pointing to characte...

mercurial at gmplib.org mercurial at gmplib.org
Wed Nov 10 17:31:00 CET 2010


details:   /home/hgfiles/gmp/rev/7e78776b0993
changeset: 13680:7e78776b0993
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Nov 10 17:30:56 2010 +0100
description:
Add 'const' to variables pointing to character strings.

diffstat:

 mpz/get_str.c           |   2 +-
 mpz/out_str.c           |   2 +-
 tests/amd64check.c      |   2 +-
 tests/misc/t-locale.c   |   4 +-
 tests/mpf/reuse.c       |  10 +++---
 tests/mpf/t-mul_ui.c    |   2 +-
 tests/mpn/t-bdiv.c      |   2 +-
 tests/mpn/t-div.c       |   2 +-
 tests/mpz/reuse.c       |  16 +++++-----
 tests/mpz/t-cdiv_ui.c   |   4 +-
 tests/mpz/t-fdiv_ui.c   |   4 +-
 tests/mpz/t-nextprime.c |   2 +-
 tests/mpz/t-tdiv_ui.c   |   4 +-
 tests/rand/t-rand.c     |  76 ++++++++++++++++++++++--------------------------
 tests/t-constants.c     |  24 +++++++-------
 tests/trace.c           |   2 +-
 16 files changed, 76 insertions(+), 82 deletions(-)

diffs (truncated from 465 to 300 lines):

diff -r 4c7883ebf326 -r 7e78776b0993 mpz/get_str.c
--- a/mpz/get_str.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/mpz/get_str.c	Wed Nov 10 17:30:56 2010 +0100
@@ -36,7 +36,7 @@
   char *return_str;
   size_t str_size;
   size_t alloc_size = 0;
-  char *num_to_text;
+  const char *num_to_text;
   int i;
   TMP_DECL;
 
diff -r 4c7883ebf326 -r 7e78776b0993 mpz/out_str.c
--- a/mpz/out_str.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/mpz/out_str.c	Wed Nov 10 17:30:56 2010 +0100
@@ -31,7 +31,7 @@
   size_t str_size;
   size_t i;
   size_t written;
-  char *num_to_text;
+  const char *num_to_text;
   TMP_DECL;
 
   if (stream == 0)
diff -r 4c7883ebf326 -r 7e78776b0993 tests/amd64check.c
--- a/tests/amd64check.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/amd64check.c	Wed Nov 10 17:30:56 2010 +0100
@@ -58,7 +58,7 @@
 } calling_conventions_fenv;
 
 
-char *regname[6] = {"rbx", "rbp", "r12", "r13", "r14", "r15"};
+const char *regname[6] = {"rbx", "rbp", "r12", "r13", "r14", "r15"};
 
 #define DIR_BIT(rflags)   (((rflags) & (1<<10)) != 0)
 
diff -r 4c7883ebf326 -r 7e78776b0993 tests/misc/t-locale.c
--- a/tests/misc/t-locale.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/misc/t-locale.c	Wed Nov 10 17:30:56 2010 +0100
@@ -57,7 +57,7 @@
 
 /* Replace the libc nl_langinfo with one we can manipulate. */
 #if HAVE_NL_LANGINFO
-char *
+const char *
 nl_langinfo (nl_item n)
 {
 #if defined (DECIMAL_POINT)
@@ -75,7 +75,7 @@
 void
 check_input (void)
 {
-  static char *point[] = {
+  static const char *point[] = {
     ".", ",", "WU", "STR", "ZTV***"
   };
 
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpf/reuse.c
--- a/tests/mpf/reuse.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpf/reuse.c	Wed Nov 10 17:30:56 2010 +0100
@@ -50,7 +50,7 @@
 #define EXPO 32
 #endif
 
-void dump_abort __GMP_PROTO ((char *, mpf_t, mpf_t));
+void dump_abort __GMP_PROTO ((const char *, mpf_t, mpf_t));
 
 typedef void (*dss_func) __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
 
@@ -59,7 +59,7 @@
   mpf_div, mpf_add, mpf_mul, mpf_sub,
 };
 
-char *dss_func_names[] =
+const char *dss_func_names[] =
 {
   "mpf_div", "mpf_add", "mpf_mul", "mpf_sub",
 };
@@ -72,7 +72,7 @@
   mpf_mul_2exp, mpf_div_2exp
 };
 
-char *dsi_func_names[] =
+const char *dsi_func_names[] =
 {
   "mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui",
   "mpf_mul_2exp", "mpf_div_2exp"
@@ -85,7 +85,7 @@
   mpf_ui_div, mpf_ui_sub,
 };
 
-char *dis_func_names[] =
+const char *dis_func_names[] =
 {
   "mpf_ui_div", "mpf_ui_sub",
 };
@@ -194,7 +194,7 @@
 }
 
 void
-dump_abort (char *name, mpf_t res1, mpf_t res2)
+dump_abort (const char *name, mpf_t res1, mpf_t res2)
 {
   printf ("failure in %s:\n", name);
   mpf_dump (res1);
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpf/t-mul_ui.c
--- a/tests/mpf/t-mul_ui.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpf/t-mul_ui.c	Wed Nov 10 17:30:56 2010 +0100
@@ -118,7 +118,7 @@
 check_various (void)
 {
   mpf_t  u, got, want;
-  char   *s;
+  const char   *s;
 
   mpf_init2 (u,    2*8*sizeof(long));
   mpf_init2 (got,  2*8*sizeof(long));
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpn/t-bdiv.c
--- a/tests/mpn/t-bdiv.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpn/t-bdiv.c	Wed Nov 10 17:30:56 2010 +0100
@@ -55,7 +55,7 @@
 
 void
 check_one (mp_ptr qp, mp_srcptr rp, mp_limb_t rh,
-	   mp_srcptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn, char *fname)
+	   mp_srcptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn, const char *fname)
 {
   mp_size_t qn;
   int cmp;
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpn/t-div.c
--- a/tests/mpn/t-div.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpn/t-div.c	Wed Nov 10 17:30:56 2010 +0100
@@ -56,7 +56,7 @@
 static void
 check_one (mp_ptr qp, mp_srcptr rp,
 	   mp_srcptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn,
-	   char *fname, mp_limb_t q_allowed_err)
+	   const char *fname, mp_limb_t q_allowed_err)
 {
   mp_size_t qn = nn - dn + 1;
   mp_ptr tp;
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpz/reuse.c
--- a/tests/mpz/reuse.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpz/reuse.c	Wed Nov 10 17:30:56 2010 +0100
@@ -48,7 +48,7 @@
 
 #else /* ! DLL_EXPORT */
 
-void dump __GMP_PROTO ((char *, mpz_t, mpz_t, mpz_t));
+void dump __GMP_PROTO ((const char *, mpz_t, mpz_t, mpz_t));
 
 typedef void (*dss_func) __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
 typedef void (*dsi_func) __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
@@ -74,7 +74,7 @@
   mpz_xinvert,
   mpz_gcd, mpz_lcm, mpz_and, mpz_ior, mpz_xor
 };
-char *dss_func_names[] =
+const char *dss_func_names[] =
 {
   "mpz_add", "mpz_sub", "mpz_mul",
   "mpz_cdiv_q", "mpz_cdiv_r", "mpz_fdiv_q", "mpz_fdiv_r", "mpz_tdiv_q", "mpz_tdiv_r",
@@ -93,7 +93,7 @@
   mpz_mul_2exp,
   mpz_pow_ui
 };
-char *dsi_func_names[] =
+const char *dsi_func_names[] =
 {
   "mpz_add_ui", "mpz_mul_ui", "mpz_sub_ui",
   "mpz_fdiv_q_2exp", "mpz_fdiv_r_2exp",
@@ -109,7 +109,7 @@
   mpz_fdiv_q_ui, mpz_fdiv_r_ui,
   mpz_tdiv_q_ui, mpz_tdiv_r_ui
 };
-char *dsi_div_func_names[] =
+const char *dsi_div_func_names[] =
 {
   "mpz_cdiv_q_ui", "mpz_cdiv_r_ui",
   "mpz_fdiv_q_ui", "mpz_fdiv_r_ui",
@@ -122,7 +122,7 @@
   mpz_fdiv_qr_ui,
   mpz_tdiv_qr_ui
 };
-char *ddsi_div_func_names[] =
+const char *ddsi_div_func_names[] =
 {
   "mpz_cdiv_qr_ui",
   "mpz_fdiv_qr_ui",
@@ -135,7 +135,7 @@
   mpz_fdiv_qr,
   mpz_tdiv_qr
 };
-char *ddss_div_func_names[] =
+const char *ddss_div_func_names[] =
 {
   "mpz_cdiv_qr",
   "mpz_fdiv_qr",
@@ -146,7 +146,7 @@
 {
   mpz_abs, mpz_com, mpz_neg, mpz_sqrt
 };
-char *ds_func_names[] =
+const char *ds_func_names[] =
 {
   "mpz_abs", "mpz_com", "mpz_neg", "mpz_sqrt"
 };
@@ -671,7 +671,7 @@
 }
 
 void
-dump (char *name, mpz_t in1, mpz_t in2, mpz_t in3)
+dump (const char *name, mpz_t in1, mpz_t in2, mpz_t in3)
 {
   printf ("failure in %s (", name);
   mpz_out_str (stdout, -16, in1);
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpz/t-cdiv_ui.c
--- a/tests/mpz/t-cdiv_ui.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpz/t-cdiv_ui.c	Wed Nov 10 17:30:56 2010 +0100
@@ -25,7 +25,7 @@
 #include "gmp-impl.h"
 #include "tests.h"
 
-void dump_abort __GMP_PROTO ((char *, mpz_t, unsigned long));
+void dump_abort __GMP_PROTO ((const char *, mpz_t, unsigned long));
 void debug_mp __GMP_PROTO ((mpz_t, int));
 
 int
@@ -144,7 +144,7 @@
 }
 
 void
-dump_abort (char *str, mpz_t dividend, unsigned long divisor)
+dump_abort (const char *str, mpz_t dividend, unsigned long divisor)
 {
   fprintf (stderr, "ERROR: %s\n", str);
   fprintf (stderr, "dividend = "); debug_mp (dividend, -16);
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpz/t-fdiv_ui.c
--- a/tests/mpz/t-fdiv_ui.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpz/t-fdiv_ui.c	Wed Nov 10 17:30:56 2010 +0100
@@ -25,7 +25,7 @@
 #include "gmp-impl.h"
 #include "tests.h"
 
-void dump_abort __GMP_PROTO ((char *, mpz_t, unsigned long));
+void dump_abort __GMP_PROTO ((const char *, mpz_t, unsigned long));
 void debug_mp __GMP_PROTO ((mpz_t, int));
 
 int
@@ -144,7 +144,7 @@
 }
 
 void
-dump_abort (char *str, mpz_t dividend, unsigned long divisor)
+dump_abort (const char *str, mpz_t dividend, unsigned long divisor)
 {
   fprintf (stderr, "ERROR: %s\n", str);
   fprintf (stderr, "dividend = "); debug_mp (dividend, -16);
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpz/t-nextprime.c
--- a/tests/mpz/t-nextprime.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpz/t-nextprime.c	Wed Nov 10 17:30:56 2010 +0100
@@ -34,7 +34,7 @@
 }
 
 void
-run (char *start, int reps, char *end, short diffs[])
+run (const char *start, int reps, const char *end, short diffs[])
 {
   mpz_t x, y;
   int i;
diff -r 4c7883ebf326 -r 7e78776b0993 tests/mpz/t-tdiv_ui.c
--- a/tests/mpz/t-tdiv_ui.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/mpz/t-tdiv_ui.c	Wed Nov 10 17:30:56 2010 +0100
@@ -25,7 +25,7 @@
 #include "gmp-impl.h"
 #include "tests.h"
 
-void dump_abort __GMP_PROTO ((char *, mpz_t, unsigned long));
+void dump_abort __GMP_PROTO ((const char *, mpz_t, unsigned long));
 void debug_mp __GMP_PROTO ((mpz_t, int));
 
 int
@@ -144,7 +144,7 @@
 }
 
 void
-dump_abort (char *str, mpz_t dividend, unsigned long divisor)
+dump_abort (const char *str, mpz_t dividend, unsigned long divisor)
 {
   fprintf (stderr, "ERROR: %s\n", str);
   fprintf (stderr, "dividend = "); debug_mp (dividend, -16);
diff -r 4c7883ebf326 -r 7e78776b0993 tests/rand/t-rand.c
--- a/tests/rand/t-rand.c	Wed Nov 10 16:28:01 2010 +0100
+++ b/tests/rand/t-rand.c	Wed Nov 10 17:30:56 2010 +0100
@@ -29,57 +29,57 @@
 
 /* These were generated by this very program.  Do not edit!  */
 /* Integers.  */
-char *z1[ENTS] = {"0", "1", "1", "1", "1", "0", "1", "1", "1", "1"};
-char *z2[ENTS] = {"0", "3", "1", "3", "3", "0", "3", "3", "3", "1"};


More information about the gmp-commit mailing list