changeset 47:5f548e5957a8

* get rid of the "deprecated conversion from string constant to ‘char*’" warnings
author thib
date Wed, 15 Apr 2009 20:26:32 +0000
parents 3aa3d244ad90
children ed6c21dde840
files font/font_peer_ft2.cc font/font_peer_x11.cc music2/wavfile.cc scn2k/scn2k_cmd.cc scn2k/scn2k_text.cc system/file.cc system/file.h system/file_impl.h system/system_config.cc window/widget.cc
diffstat 10 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/font/font_peer_ft2.cc
+++ b/font/font_peer_ft2.cc
@@ -49,7 +49,7 @@ typedef struct _FontLibrary {
 
 static FontLibrary *library = NULL;
 
-static char *default_paths[] = {
+static const char *default_paths[] = {
   ".",
   "/",
   "/usr/X11R6/lib/X11/fonts/TrueType",
--- a/font/font_peer_x11.cc
+++ b/font/font_peer_x11.cc
@@ -212,7 +212,7 @@ void PeerX11::InitDisplay(Display* _d) {
 void PeerX11::OpenDisplay(void) {
 	if (display) return;
 
-	char* display_name = getenv("DISPLAY");
+	const char* display_name = getenv("DISPLAY");
 	if (display_name == 0) display_name = ":0";
 
 	display = XOpenDisplay(display_name);
--- a/music2/wavfile.cc
+++ b/music2/wavfile.cc
@@ -105,7 +105,7 @@ typedef  struct
 
 
 static void waveFormatCopy( WAVEFORMAT* wav, char *ptr );
-static char*  findchunk (char* s1, char* s2, size_t n) ;
+static char*  findchunk (char* s1, const char* s2, size_t n) ;
 
 static int  WaveHeaderCheck  (char *wave_buf,int* channels, u_long* samplerate, int* samplebits, u_long* samples,u_long* datastart)
 {	
@@ -176,7 +176,7 @@ static int  WaveHeaderCheck  (char *wave
 } ; /* WaveHeaderCheck*/
 
 
-static char* findchunk  (char* pstart, char* fourcc, size_t n)
+static char* findchunk  (char* pstart, const char* fourcc, size_t n)
 {	char	*pend ;
 	int		k, test ;
 
--- a/scn2k/scn2k_cmd.cc
+++ b/scn2k/scn2k_cmd.cc
@@ -721,7 +721,7 @@ int Cmd::GetLeftToken(const char*& d, Va
 	return value;
 }
 
-static char* op_str[70] = {
+static const char* op_str[70] = {
 //	 0      1      2      3      4      5      6      7      8     9
 	"+",   "-",   "*",   "/",   "%",   "&",   "|",   "^",   "<<",  ">>",	// +00
 	"err.","err.","err.","err.","err.","err.","err.","err.","err.","err.",	// +10
--- a/scn2k/scn2k_text.cc
+++ b/scn2k/scn2k_text.cc
@@ -1551,7 +1551,7 @@ void movebtn_drag(int from_x, int from_y
 	fprintf(stderr,"drag.\n");
 }
 #define BTNCNT 10
-static char* btnname[BTNCNT] = {
+static const char* btnname[BTNCNT] = {
 	"MOVE",
 	"CLEAR",
 	"READJUMP",
--- a/system/file.cc
+++ b/system/file.cc
@@ -94,7 +94,7 @@ FILESEARCH::ARCTYPE FILESEARCH::default_
 	ATYPE_DIR, ATYPE_DIR, ATYPE_DIR, ATYPE_DIR,
 	ATYPE_DIR, ATYPE_DIR
 };
-char* FILESEARCH::default_dirnames[TYPEMAX] = {
+const char* FILESEARCH::default_dirnames[TYPEMAX] = {
 	0, 0, "", "pdt", 
 	"seen.txt", "allanm.anl", "allard.ard", "allcur.cur", 
 	0, 0, "koe", "bgm", "mov", "gan"};
@@ -108,7 +108,7 @@ char* FILESEARCH::default_dirnames[TYPEM
 **	Find ¤·¤¿¤â¤Î¤òRead¤¹¤ë¤ÈÆâÍƤ¬ÆÀ¤é¤ì¤ë¡£
 */
 
-ARCFILE::ARCFILE(char* aname) {
+ARCFILE::ARCFILE(const char* aname) {
 	struct stat sb;
 	/* ÊÑ¿ô½é´ü²½ */
 	arcname = 0;
@@ -665,8 +665,7 @@ void FILESEARCH::SetFileInformation(FILE
 	/* ŬÅö¤Ë½é´ü²½ */
 	if (filenames[type] != 0 &&
 		filenames[type] != default_dirnames[type]) delete[] filenames[type];
-	filenames[type] = new char[strlen(filename)+1];
-	strcpy(filenames[type], filename);
+	filenames[type] = filename;
 	is_archived[type] = is_arc;
 	searcher[type] = MakeARCFILE(is_arc, filename);
 	if (searcher[type] && next_arc)
@@ -696,7 +695,7 @@ void FILESEARCH::AppendFileInformation(F
 	return;
 }
 
-ARCFILE* FILESEARCH::MakeARCFILE(ARCTYPE tp, char* filename) {
+ARCFILE* FILESEARCH::MakeARCFILE(ARCTYPE tp, const char* filename) {
 	ARCFILE* arc = 0;
 	char* file;
 	if (filename == 0) goto err;
--- a/system/file.h
+++ b/system/file.h
@@ -143,10 +143,10 @@ private:
 	ARCFILE* searcher[TYPEMAX];
 	/* ¥Õ¥¡¥¤¥ë¤Î¸ºß°ÌÃ֤Πinformation */
 	ARCTYPE is_archived[TYPEMAX];
-	char* filenames[TYPEMAX];
+	const char* filenames[TYPEMAX];
 	/* ¥Ç¥Õ¥©¥ë¥È¤Î information */
 	static ARCTYPE default_is_archived[TYPEMAX];
-	static char* default_dirnames[TYPEMAX];
+	static const char* default_dirnames[TYPEMAX];
 public:
 	FILESEARCH(void);
 	~FILESEARCH();
@@ -158,7 +158,7 @@ public:
 	/* Ê£¿ô¤Î¥Õ¥¡¥¤¥ë¤ò°ì¤Ä¤Î·¿¤Ë´ØÏ¢¤Å¤±¤ë */
 	void AppendFileInformation(FILETYPE type, ARCTYPE is_arc,
 		char* filename);
-	ARCFILE* MakeARCFILE(ARCTYPE tp, char* filename);
+	ARCFILE* MakeARCFILE(ARCTYPE tp, const char* filename);
 	/* fname ¤Ç»ØÄꤵ¤ì¤¿Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤ò¸¡º÷ */
 	class ARCINFO* Find(FILETYPE type, const char* fname, const char* ext=0);
 	/* ¤¢¤ë¼ïÎà¤Î¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤Æ¥ê¥¹¥È¥¢¥Ã¥×
--- a/system/file_impl.h
+++ b/system/file_impl.h
@@ -61,7 +61,7 @@ protected:
 	virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM&);
 	iterator SearchName(const char* f, const char* ext=0);
 public:
-	ARCFILE(char* fname);
+	ARCFILE(const char* fname);
 	void SetNext(ARCFILE* _next) { next = _next;}
 	ARCFILE* Next(void) { return next; }
 	void Init(void);
--- a/system/system_config.cc
+++ b/system/system_config.cc
@@ -212,7 +212,7 @@ public:
 		return;
 	}
 	const char* PatchOriginal(const char* data) {
-		static char* table = "?\"',.:;=<>";
+		static const char* table = "?\"',.:;=<>";
 		if (new_data) delete[] new_data;
 		if (old_data) delete[] old_data;
 		new_data = 0; old_data = 0;
--- a/window/widget.cc
+++ b/window/widget.cc
@@ -37,7 +37,7 @@ void DSurfaceMove(Surface* src, const Re
 
 //static char* wdefault_font_orig = "msgothic.ttc;times.ttf;";
 static std::map<int, XKFont::HorizLayout*> size_to_layout;
-static char* wdefault_font_orig = "times.ttf;msgothic.ttc";
+static const char* wdefault_font_orig = "times.ttf;msgothic.ttc";
 static std::string wdefault_font = wdefault_font_orig;
 
 void SetFont(const char* font) {