delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/12/28/15:56:26

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1/Zq85JzLXZ92DNty1caypbwjYvaLSKEASvoCFcZq
nsivZZclEc5aJp
Message-ID: <50DE0762.1000108@gmx.de>
Date: Fri, 28 Dec 2012 21:56:02 +0100
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Fixing test-cases (patch 1/3)
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

The patch below will fix the warning:
   deprecated conversion from string constant to 'char*' [-Wwrite-strings]
in /tests/libclink.

Regards,
Juan M. Guerrero


diff -aprNU5 djgpp.orig/tests/libclink/check.cc djgpp/tests/libclink/check.cc
--- djgpp.orig/tests/libclink/check.cc    2004-12-31 12:21:48 +0000
+++ djgpp/tests/libclink/check.cc    2012-12-28 21:03:34 +0000
@@ -10,19 +10,19 @@
  #include "slist.h"
  #include "objs.h"

  //-----------------------------------------------------------------------------

-char *predefs[] = { "main", "edata", "end", "etext", "_environ",
+const char *predefs[] = { "main", "edata", "end", "etext", "_environ",
              "__udivdi3", "__umoddi3", "__divdi3",
              "__moddi3", "__cmpdi2", 0 };

  /* Note: tzname is POSIX, but we list it here because it is a datum,
     not a function, and we can't stub it.  ctime() sets tzname, and
     ctime is ANSI and tzname is POSIX.  Sigh. */

-char *ansi_c89_fns[] = { "abort", "abs", "acos", "asctime", "asin",
+const char *ansi_c89_fns[] = { "abort", "abs", "acos", "asctime", "asin",
  "atan", "atan2", "atexit", "atof", "atoi", "atol", "bsearch",
  "calloc", "ceil", "clearerr", "clock", "cos", "cosh", "ctime",
  "difftime", "div", "errno", "exit", "exp", "fabs", "fclose", "feof",
  "ferror", "fflush", "fgetc", "fgetpos", "fgets", "floor", "fmod",
  "fopen", "fprintf", "fputc", "fputs", "fread", "free", "freopen",
@@ -42,11 +42,11 @@ char *ansi_c89_fns[] = { "abort", "abs",
  "strtok", "strtol", "strtoul", "strxfrm", "system", "tan", "tanh",
  "time", "tmpfile", "tmpnam", "tolower", "toupper", "tzname", "ungetc",
  "vfprintf", "vprintf", "vsprintf", "wcstombs", "wctomb", 0
  };

-char *ansi_c99_fns[] = { "_Exit", "acosf", "acosh", "acoshf",
+const char *ansi_c99_fns[] = { "_Exit", "acosf", "acosh", "acoshf",
  "acoshl", "acosl", "asinf", "asinh", "asinhf", "asinhl", "asinl",
  "atan2f", "atan2l", "atanf", "atanh", "atanhf", "atanhl", "atanl",
  "atoll", "btowc", "cabs", "cabsf", "cabsl", "cacos", "cacosf",
  "cacosh", "cacoshf", "cacoshl", "cacosl", "carg", "cargf", "cargl",
  "casin", "casinf", "casinh", "casinhf", "casinhl", "casinl", "catan",
@@ -98,11 +98,11 @@ char *ansi_c99_fns[] = { "_Exit", "acosf
  "wcstold", "wcstoll", "wcstoul", "wcstoull", "wcstoumax", "wcsxfrm",
  "wctob", "wctrans", "wctype", "wmemchr", "wmemcmp", "wmemcpy",
  "wmemmove", "wmemset", "wprintf", "wscanf", 0
  };

-char *posix_fns[] = { "_exit", "_longjmp", "_setjmp",
+const char *posix_fns[] = { "_exit", "_longjmp", "_setjmp",
  "_tolower", "_toupper", "a64l", "accept", "access", "alarm",
  "asctime_r", "basename", "bcmp", "bcopy", "bind", "bzero",
  "catclose", "catgets", "catopen",
  "cfgetispeed", "cfgetospeed", "cfsetispeed", "cfsetospeed",
  "chdir", "chmod", "chown", "close", "closedir", "closelog",
@@ -386,11 +386,11 @@ void propogate_obj(Object *o, int Plf=0)
    indent--;
  }

  //-----------------------------------------------------------------------------

-void do_missing(char *which, char **fns, StringList &all_defs)
+void do_missing(const char *which, const char **fns, StringList &all_defs)
  {
    int n = 1;
    int w = 0;
    int i;

diff -aprNU5 djgpp.orig/tests/libclink/objs.cc djgpp/tests/libclink/objs.cc
--- djgpp.orig/tests/libclink/objs.cc    1994-11-29 08:24:16 +0000
+++ djgpp/tests/libclink/objs.cc    2012-12-28 21:03:34 +0000
@@ -4,11 +4,11 @@
  #include "slist.h"
  #include "objs.h"

  Object *Object::first = 0;

-Object::Object(char *Pname)
+Object::Object(const char *Pname)
  {
    name = new char[strlen(Pname)+1];
    strcpy(name, Pname);
    df = rf = lf = busy = 0;
    next = first;
diff -aprNU5 djgpp.orig/tests/libclink/objs.h djgpp/tests/libclink/objs.h
--- djgpp.orig/tests/libclink/objs.h    1994-11-29 08:24:06 +0000
+++ djgpp/tests/libclink/objs.h    2012-12-28 21:03:34 +0000
@@ -9,11 +9,11 @@ class ObjList {
    void add(Object *o);
  };

  class Object {
   public:
-  Object(char *name);
+  Object(const char *name);
    ~Object();
    StringList defs, refs;
    int df, rf, lf, busy;
    ObjList deps;
    Object *next;
diff -aprNU5 djgpp.orig/tests/libclink/slist.cc djgpp/tests/libclink/slist.cc
--- djgpp.orig/tests/libclink/slist.cc    1997-09-07 22:54:34 +0000
+++ djgpp/tests/libclink/slist.cc    2012-12-28 21:03:34 +0000
@@ -36,11 +36,11 @@ char *StringList::operator[](int i)
    if (i >= count || i < 0)
      return 0;
    return data[i];
  }

-void StringList::add(char *s)
+void StringList::add(const char *s)
  {
    if (has(s))
      return;
    if (maxc >= max)
    {
@@ -51,22 +51,22 @@ void StringList::add(char *s)
    strcpy(data[maxc], s);
    count++;
    maxc++;
  }

-void StringList::del(char *s)
+void StringList::del(const char *s)
  {
    int i;
    for (i=0; i<maxc; i++)
      if (data[i] && strcmp(data[i], s) == 0)
      {
        data[i] = 0;
        count--;
      }
  }

-int StringList::has(char *s)
+int StringList::has(const char *s)
  {
    int i;
    for (i=0; i<maxc; i++)
      if (data[i] && (strcmp(data[i], s) == 0))
        return 1;
diff -aprNU5 djgpp.orig/tests/libclink/slist.h djgpp/tests/libclink/slist.h
--- djgpp.orig/tests/libclink/slist.h    1995-02-23 09:52:30 +0000
+++ djgpp/tests/libclink/slist.h    2012-12-28 21:03:34 +0000
@@ -2,13 +2,13 @@ class StringList {
   public:
    StringList();
    ~StringList();
    int count;
    char *operator[](int);
-  void add(char *);
-  void del(char *);
-  int  has(char *);
+  void add(const char *);
+  void del(const char *);
+  int  has(const char *);
    void flush(void);
    void sort(void);
   private:
    int maxc;
    int max;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019