File: constchar

package info (click to toggle)
atom4 4.1-9
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 836 kB
  • ctags: 1,222
  • sloc: cpp: 4,451; makefile: 46; perl: 6
file content (56 lines) | stat: -rw-r--r-- 2,033 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Index: atom4-4.1/proglib/c++/exception.cc
===================================================================
--- atom4-4.1.orig/proglib/c++/exception.cc
+++ atom4-4.1/proglib/c++/exception.cc
@@ -19,7 +19,7 @@ void exception::out_of_memory() {
   abort();			// fatal: cannot create exception
 }
 
-void exception::varinit(char *fmt, va_list args) {
+void exception::varinit(const char *fmt, va_list args) {
   size_t bufsize, msglen;
 
   // Initial attempt to format message string
@@ -42,9 +42,9 @@ void exception::varinit(char *fmt, va_li
   }
 }
 
-exception::exception(char *error_msg, ...) : is_variable(*error_msg=='@') {
+exception::exception(const char *error_msg, ...) : is_variable(*error_msg=='@') {
   if (!is_variable) {			// Static exception
-    msg = error_msg;
+    msg = const_cast<char*>(error_msg);
   } else {				// Variable exception
     va_list args;
 
Index: atom4-4.1/proglib/c++/exception.h
===================================================================
--- atom4-4.1.orig/proglib/c++/exception.h
+++ atom4-4.1/proglib/c++/exception.h
@@ -41,22 +41,22 @@ class exception {
   char *msg;
 
   void out_of_memory();			// does not return
-  void varinit(char *msg, va_list args);
+  void varinit(const char *msg, va_list args);
 protected:
   // NOTE: the dummy argument is a dirty, cruel hack necessary because the
   // stdarg in glibc defines va_list as char*, and the bogonous C++ compiler
   // (g++) does not know how to find a next-better ctor match when this one
   // is protected. It's not my fault! Derived exception classes will just
   // have to cope.
-  exception(int dummy, char *error_msg, va_list args) :
+  exception(int dummy, const char *error_msg, va_list args) :
 	is_variable(*error_msg=='@') {
     if (is_variable)
       varinit(error_msg+1, args);
     else
-      msg=error_msg;
+      msg=const_cast<char*>(error_msg);
   }
 public:
-  exception(char *error_msg, ...);
+  exception(const char *error_msg, ...);
   exception(const exception &e);
   virtual ~exception();