diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C index 9c02b128e..000de4329 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C @@ -252,7 +252,7 @@ StringParser::brute_force(const char* text_in, int n_of_pats, } -char * +const char * StringParser::project_textrun(const char* org_textrun) { if (org_textrun == NULL || *org_textrun == '\0') @@ -325,11 +325,11 @@ StringParser::project_textrun(const char* org_textrun) ret_text << off << '\t' << len << '\n' << '\0'; - string rettstr = ret_text.str(); - return (char *)rettstr.c_str(); + static string rettstr = ret_text.str(); + return rettstr.c_str(); } -char * +const char * StringParser::hilite(const char* text, int n, const char* pats) { char* textrun = brute_force(text, n, pats); @@ -337,9 +337,10 @@ StringParser::hilite(const char* text, int n, const char* pats) if (textrun == NULL) return NULL; - char* prjed_textrun = project_textrun(textrun); delete[] textrun; + const char* prjed_textrun = project_textrun(textrun); + return prjed_textrun; } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.hh b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.hh index 837f3c366..1997b1882 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.hh +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.hh @@ -9,13 +9,13 @@ class StringParser { public: - static char * + static const char * hilite(const char* text, int n, const char* pats); static char * brute_force(const char* text, int, const char* pats, int sensitive = 0); - static char * + static const char * project_textrun(const char *); };