From ace412b5a2ee9c1177c4652081ec97b352c54963 Mon Sep 17 00:00:00 2001
From: johti17 <johti17@tlvm-4-4-1.ad.liu.se>
Date: Fri, 20 Oct 2023 14:04:57 +0200
Subject: [PATCH] Kill C++ Warnings, setting char* to const char*

---
 lab2/lab2.hh | 4 ++--
 lab2/lex.cc  | 8 ++++----
 lab2/lex.hh  | 8 ++++----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lab2/lab2.hh b/lab2/lab2.hh
index 892c4d0..ca7d04d 100644
--- a/lab2/lab2.hh
+++ b/lab2/lab2.hh
@@ -24,10 +24,10 @@ public:
 class Trace
 {
     static int indent;
-    char *name;
+    const char *name;
 
 public:
-    Trace(char *s)
+    Trace(const char *s)
     {
         name = s;
         cerr.width(indent);
diff --git a/lab2/lex.cc b/lab2/lex.cc
index 272efdf..5702079 100644
--- a/lab2/lex.cc
+++ b/lab2/lex.cc
@@ -8,7 +8,7 @@
 // Human-readable representations of token types
 //
 
-static char *kTokenTypeNames[] =
+static const char *kTokenTypeNames[] =
 {
     "uninitialized",
     "number",
@@ -238,7 +238,7 @@ Token Scanner::Scan(void)
 // multiple-character token.
 //
 
-void Scanner::Accumulate(char c)
+void Scanner::Accumulate(const char c)
 {
     if (position >= kMaxTokenLength)
     {
@@ -312,12 +312,12 @@ ostream& operator<<(ostream& s, ScannerError& e)
 // no argument version returns the type of the token.
 //
 
-char *Token::Lookup(void)
+const char *Token::Lookup(void)
 {
     return kTokenTypeNames[type];
 }
 
-char *Token::Lookup(TokenType t)
+const char *Token::Lookup(TokenType t)
 {
     return kTokenTypeNames[t];
 }
diff --git a/lab2/lex.hh b/lab2/lex.hh
index ac3dc03..d24cf4d 100644
--- a/lab2/lex.hh
+++ b/lab2/lex.hh
@@ -30,11 +30,11 @@ class ScannerError
 {
 public:
     char errorCharacter;
-    char *message;
+    const char *message;
     int  state;
 
     ScannerError(char c, int s) : errorCharacter(c), state(s) {};
-    ScannerError(char *s) : message(s) {};
+    ScannerError(const char *s) : message(s) {};
     ScannerError()       : errorCharacter(0) {};
 };
 
@@ -86,8 +86,8 @@ public:
     double          numberValue;
     char           *symbolValue;
 
-    char *Lookup(TokenType);
-    char *Lookup(void);
+    const char *Lookup(TokenType);
+    const char *Lookup(void);
     Token() : type(kUninitialized) {};
     Token(TokenType t) : type(t) {};
     Token(TokenType t, double x) : type(t), numberValue(x) {};
-- 
GitLab