diff --git a/cde/programs/ttsnoop/DtTt.C b/cde/programs/ttsnoop/DtTt.C index 51824f200..24d977071 100644 --- a/cde/programs/ttsnoop/DtTt.C +++ b/cde/programs/ttsnoop/DtTt.C @@ -34,11 +34,7 @@ #include #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif +#include #include #include
@@ -468,11 +464,10 @@ DtTtSetLabel( ) { Tt_status status = tt_ptr_error( val ); - std::ostrstream errStream; + std::ostringstream errStream; errStream << func << " = " << val << " (" << status << ")" << ends; - char *label = errStream.str(); + const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget, label ); - delete label; return status; } @@ -483,11 +478,10 @@ DtTtSetLabel( Tt_status status ) { - std::ostrstream errStream; + std::ostringstream errStream; errStream << func << " = " << status << ends; - char *label = errStream.str(); + const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget, label ); - delete label; return status; } @@ -498,11 +492,10 @@ DtTtSetLabel( int returnVal ) { - std::ostrstream errStream; + std::ostringstream errStream; errStream << func << " = " << returnVal << ends; - char *label = errStream.str(); + const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget, label ); - delete label; return returnVal; } @@ -519,7 +512,7 @@ _DtTtChoices( return 0; } for (int i = 0; i < count; i++) { - std::ostrstream itemStream; + std::ostringstream itemStream; itemStream << (void *)pPats[ i ]; char *name = (char *) tt_pattern_user( *pPats[ i ], _DtTtPatsNameKey ); @@ -528,9 +521,8 @@ _DtTtChoices( tt_free( name ); } itemStream << ends; - char *string = itemStream.str(); + char *string = const_cast(itemStream.str().c_str()); items[ i ] = XmStringCreateLocalized( string ); - delete string; } return items; } @@ -566,7 +558,7 @@ _DtTtChoices( } *itemCount = dtTtMessagesCount; for (i = 0; i < dtTtMessagesCount; i++) { - std::ostrstream itemStream; + std::ostringstream itemStream; itemStream << (void *)dtTtMessages[ i ]; char *op = tt_message_op( dtTtMessages[ i ] ); if (! tt_is_err( tt_ptr_error( op ))) { @@ -579,9 +571,8 @@ _DtTtChoices( tt_free( id ); } itemStream << ends; - char *string = itemStream.str(); + char *string = const_cast(itemStream.str().c_str()); items[ i ] = XmStringCreateLocalized( string ); - delete string; } return items; case DTTT_PATTERN: @@ -592,11 +583,10 @@ _DtTtChoices( } *itemCount = dtTtPatternsCount; for (i = 0; i < dtTtPatternsCount; i++) { - std::ostrstream itemStream; + std::ostringstream itemStream; itemStream << (void *)dtTtPatterns[ i ] << ends; items[ i ] = XmStringCreateLocalized( - itemStream.str() ); - delete itemStream.str(); + const_cast(itemStream.str().c_str()) ); } return items; case DTTT_DTSESSION: @@ -636,23 +626,19 @@ _DtOpen( ) { char *file = tempnam( 0, AIX_CONST_STRING tempnamTemplate ); - std::ostrstream cmdStream; + std::ostringstream cmdStream; cmdStream << cmd << " > " << file << ends; - int sysStat = system( cmdStream.str() ); + int sysStat = system( cmdStream.str().c_str() ); if (! WIFEXITED( sysStat )) { - std::ostrstream func; + std::ostringstream func; func << "system( \"" << cmdStream.str() << "\" )" << ends; - DtTtSetLabel( label, func.str(), sysStat ); - delete cmdStream.str(); - delete func.str(); + DtTtSetLabel( label, func.str().c_str(), sysStat ); return; } if (WEXITSTATUS( sysStat ) != 0) { - DtTtSetLabel( label, cmdStream.str(), WEXITSTATUS( sysStat )); - delete cmdStream.str(); + DtTtSetLabel( label, cmdStream.str().c_str(), WEXITSTATUS( sysStat )); return; } - delete cmdStream.str(); _DtOpen( label, file ); } @@ -662,17 +648,15 @@ _DtOpen( const char * file ) { - std::ostrstream labelStream; + std::ostringstream labelStream; labelStream << "dtaction Open " << file << ends; - DtTtSetLabel( label, labelStream.str() ); - delete labelStream.str(); + DtTtSetLabel( label, labelStream.str().c_str() ); - std::ostrstream cmd; + std::ostringstream cmd; cmd << "( unset TT_TRACE_SCRIPT; if dtaction Open " << file << "; then :; else textedit " << file << "; fi; sleep 600; rm -f " << file << " ) &" << ends; - system( cmd.str() ); - delete cmd.str(); + system( cmd.str().c_str() ); } void @@ -699,16 +683,14 @@ _DtMan( const char * topic ) { - std::ostrstream labelStream; + std::ostringstream labelStream; labelStream << "dtaction Dtmanpageview " << topic << ends; - DtTtSetLabel( label, labelStream.str() ); - delete labelStream.str(); + DtTtSetLabel( label, labelStream.str().c_str() ); - std::ostrstream cmd; + std::ostringstream cmd; cmd << "unset TT_TRACE_SCRIPT; if dtaction Dtmanpageview " << topic << "; then :; else cmdtool -c man " << topic << "; fi &" << ends; - system( cmd.str() ); - delete cmd.str(); + system( cmd.str().c_str() ); } Boolean diff --git a/cde/programs/ttsnoop/callbackChooser_stubs.C.src b/cde/programs/ttsnoop/callbackChooser_stubs.C.src index 3e7ba76f1..0b7acffc7 100644 --- a/cde/programs/ttsnoop/callbackChooser_stubs.C.src +++ b/cde/programs/ttsnoop/callbackChooser_stubs.C.src @@ -41,13 +41,8 @@ *** Add include files, types, macros, externs, and user functions here. ***/ -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#include -#else -#include -#include -#endif +#include #include "DtTt.h" diff --git a/cde/programs/ttsnoop/fileChooser_stubs.C.src b/cde/programs/ttsnoop/fileChooser_stubs.C.src index 8e21b587a..b0c9c0f72 100644 --- a/cde/programs/ttsnoop/fileChooser_stubs.C.src +++ b/cde/programs/ttsnoop/fileChooser_stubs.C.src @@ -39,13 +39,8 @@ #include #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#include -#else -#include -#include -#endif +#include #include "DtTt.h" #include "ttsnoop_ui.h" @@ -217,7 +212,7 @@ fileOkayed( XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, NULL ); FileChooserInfo *info = (FileChooserInfo *)xtPtr; Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label; - std::ostrstream script; + std::ostringstream script; switch (info->choice) { Tt_pattern *pats; Tt_message msg; @@ -297,19 +292,17 @@ fileOkayed( script << "numChars=`tt_type_comp -p \"" << path; script << "\" | wc -c`; if [ $numChars = 0 ]; " "then exit 1; else exit 0; fi" << endl; - ival = system( script.str() ); - delete script.str(); + ival = system( script.str().c_str() ); if (! WIFEXITED( ival )) { DtTtSetLabel( label, "system( \"tt_type_comp -p\" )", ival ); break; } if (WEXITSTATUS( ival ) != 0) { - std::ostrstream diagnosis; + std::ostringstream diagnosis; diagnosis << "tt_type_comp -p: syntax error in " << path << ends; - DtTtSetLabel( label, diagnosis.str() ); - delete diagnosis.str(); + DtTtSetLabel( label, diagnosis.str().c_str() ); break; } sess = tt_default_session(); diff --git a/cde/programs/ttsnoop/messageProps_stubs.C.src b/cde/programs/ttsnoop/messageProps_stubs.C.src index e759859cd..fa2e1ee76 100644 --- a/cde/programs/ttsnoop/messageProps_stubs.C.src +++ b/cde/programs/ttsnoop/messageProps_stubs.C.src @@ -41,11 +41,7 @@ *** Add include files, types, macros, externs, and user functions here. ***/ -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif +#include #include #include
@@ -621,12 +617,11 @@ DtTtMessageWidgetCreate( } } - std::ostrstream labelStream; + std::ostringstream labelStream; labelStream << "Tt_message " << (void *)msg; XtVaSetValues( instance->messageProps, - XmNtitle, labelStream.str(), + XmNtitle, labelStream.str().c_str(), NULL ); - delete labelStream.str(); _DtTtMessageWidgetUpdate( instance, msg, _DtTtMessageFullUpdate ); @@ -1409,7 +1404,7 @@ msgGenAction( /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/ /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ - std::ostrstream action; // XXX when to delete .str()? + std::ostringstream action; DtbMessagePropsMessagePropsInfo instance = (DtbMessagePropsMessagePropsInfo)clientData; Tt_message msg = messageProps2Msg( instance ); @@ -1457,10 +1452,9 @@ msgGenAction( } // XXX emit commented warnings for e.g. TT_OFFER, TT_HANDLER action << "}\n"; - // XtVaSetValues( instance->messageText, XmNvalue, action.str(), 0 ); - _DtOpen( instance->messageFooterLabel, (void *)action.str(), - action.pcount(), "actio" ); - delete action.str(); + // XtVaSetValues( instance->messageText, XmNvalue, action.str().c_str(), 0 ); + _DtOpen( instance->messageFooterLabel, (void *)action.str().c_str(), + action.str().size(), "actio" ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } @@ -1476,7 +1470,7 @@ msgGenC( /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/ /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ - std::ostrstream code; // XXX when to delete .str()? + std::ostringstream code; DtbMessagePropsMessagePropsInfo instance = (DtbMessagePropsMessagePropsInfo)clientData; Tt_message msg = messageProps2Msg( instance ); @@ -1602,10 +1596,9 @@ msgGenC( code << "}\n"; } tt_free( op ); - // XtVaSetValues( instance->messageText, XmNvalue, code.str(), 0 ); - _DtOpen( instance->messageFooterLabel, (void *)code.str(), - code.pcount(), "msgC" ); - delete code.str(); + // XtVaSetValues( instance->messageText, XmNvalue, code.str().c_str(), 0 ); + _DtOpen( instance->messageFooterLabel, (void *)code.str().c_str(), + code.str().size(), "msgC" ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } @@ -1879,7 +1872,7 @@ genObserver( /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/ /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ - std::ostrstream ptype; // XXX when to delete .str()? + std::ostringstream ptype; DtbMessagePropsMessagePropsInfo instance = (DtbMessagePropsMessagePropsInfo)clientData; Tt_message msg = messageProps2Msg( instance ); @@ -1941,10 +1934,9 @@ genObserver( ptype << "\t\t\t) => start opnum=1;\n"; ptype << "};\n"; // XXX contexts - // XtVaSetValues( instance->messageText, XmNvalue, ptype.str(), 0 ); - _DtOpen( instance->messageFooterLabel, (void *)ptype.str(), - ptype.pcount(), "ptype" ); - delete ptype.str(); + // XtVaSetValues( instance->messageText, XmNvalue, ptype.str().c_str(), 0 ); + _DtOpen( instance->messageFooterLabel, (void *)ptype.str().c_str(), + ptype.str().size(), "ptype" ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } diff --git a/cde/programs/ttsnoop/patternProps_stubs.C.src b/cde/programs/ttsnoop/patternProps_stubs.C.src index 4ae300ccb..e49d8f2a8 100644 --- a/cde/programs/ttsnoop/patternProps_stubs.C.src +++ b/cde/programs/ttsnoop/patternProps_stubs.C.src @@ -41,11 +41,7 @@ *** Add include files, types, macros, externs, and user functions here. ***/ -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif +#include #include #include "DtTt.h" @@ -372,12 +368,11 @@ DtTtPatternWidgetCreate( } } - std::ostrstream labelStream; + std::ostringstream labelStream; labelStream << "Tt_pattern " << (void *)pat << ends; XtVaSetValues( instance->patternProps, - XmNtitle, labelStream.str(), + XmNtitle, labelStream.str().c_str(), NULL ); - delete labelStream.str(); _DtTtPatternWidgetUpdate( instance, pat ); diff --git a/cde/programs/ttsnoop/sessionChooser_stubs.C.src b/cde/programs/ttsnoop/sessionChooser_stubs.C.src index fa3d78bda..a94d3dd8d 100644 --- a/cde/programs/ttsnoop/sessionChooser_stubs.C.src +++ b/cde/programs/ttsnoop/sessionChooser_stubs.C.src @@ -42,13 +42,8 @@ #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#include -#else -#include -#include -#endif +#include #include "DtTt.h" diff --git a/cde/programs/ttsnoop/stringChooser_stubs.C.src b/cde/programs/ttsnoop/stringChooser_stubs.C.src index 27f0fb22e..906242cd7 100644 --- a/cde/programs/ttsnoop/stringChooser_stubs.C.src +++ b/cde/programs/ttsnoop/stringChooser_stubs.C.src @@ -42,11 +42,7 @@ #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#else -#include -#endif #include "DtTt.h" diff --git a/cde/programs/ttsnoop/ttChooser_stubs.C.src b/cde/programs/ttsnoop/ttChooser_stubs.C.src index c6521bd24..9ef1c53ff 100644 --- a/cde/programs/ttsnoop/ttChooser_stubs.C.src +++ b/cde/programs/ttsnoop/ttChooser_stubs.C.src @@ -43,11 +43,7 @@ #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif +#include #include #include @@ -214,12 +210,11 @@ _DtTtChooserSet( XmTextFieldSetString( instance->chooserText, 0 ); XtVaSetValues( instance->chooser, XmNtitle, title, NULL ); - std::ostrstream valuesStream; + std::ostringstream valuesStream; valuesStream << itemCount << " " << valuesLabel; if (itemCount != 1) valuesStream << "s"; valuesStream << ends; - DtTtSetLabel( instance->chooserList_label, valuesStream.str() ); - delete valuesStream.str(); + DtTtSetLabel( instance->chooserList_label, valuesStream.str().c_str() ); // Remember dialog mode, entity XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL ); @@ -315,14 +310,13 @@ choiceSelected( break; } void *entity = DtTtNth( type, info->item_position - 1 ); - std::ostrstream entityName; + std::ostringstream entityName; if (isString) { entityName << (char *)entity << ends; } else { entityName << entity << ends; } - XmTextFieldSetString( instance->chooserText, entityName.str() ); - delete entityName.str(); + XmTextFieldSetString( instance->chooserText, const_cast(entityName.str().c_str()) ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } diff --git a/cde/programs/ttsnoop/ttsnoop.C.src b/cde/programs/ttsnoop/ttsnoop.C.src index fc1495b1b..4e51f528c 100644 --- a/cde/programs/ttsnoop/ttsnoop.C.src +++ b/cde/programs/ttsnoop/ttsnoop.C.src @@ -63,15 +63,9 @@ #include #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#include +#include #include -#else -#include -#include -#include -#endif #include
#include @@ -95,7 +89,7 @@ char * snoopFile = 0; Boolean unlinkSnoopFile = True; char * traceFile = 0; Boolean unlinkTraceFile = True; -char * traceScript = 0; +const char * traceScript = 0; int globalTimeout = 20000; unsigned int globalSaveLines = 5000; const char * globalVersionString = "1.0"; @@ -112,7 +106,7 @@ unsigned int snoopedArgsCount = 0; char * optTraceScript = 0; String apiTracerArgv[ 10 ]; String snooperArgv[ 10 ]; -std::ostrstream tttraceCmd; +std::ostringstream tttraceCmd; std::ofstream snoopStream; // Xt squats on -tf ?! XXX @@ -188,7 +182,7 @@ signalHandler( if ((child > 0) && WIFEXITED( status )) { snoopStream << endl << endl << "SIGCHLD: WEXITSTATUS==" << WEXITSTATUS(status) << ": " - << tttraceCmd.str() << endl << endl; + << tttraceCmd.str().c_str() << endl << endl; } break; case SIGCONT: @@ -666,14 +660,14 @@ main(int argc, char **argv) installSignalHandler(); if (snoopedArgsCount > 0) { DtTtSetLabel( dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label, - tttraceCmd.str() ); + tttraceCmd.str().c_str() ); } Tt_status status; snoopStream.open( snoopFile, ios::app ); - std::ostrstream envStr; + std::ostringstream envStr; envStr << "TT_TRACE_SCRIPT=> "; envStr << traceFile << ends; - traceScript = envStr.str(); + traceScript = envStr.str().c_str(); if (optImmediateTracing) { turnOnTracing( 0, 0, 0 ); } diff --git a/cde/programs/ttsnoop/ttsnoop_stubs.C.src b/cde/programs/ttsnoop/ttsnoop_stubs.C.src index ce7305275..f57104a4e 100644 --- a/cde/programs/ttsnoop/ttsnoop_stubs.C.src +++ b/cde/programs/ttsnoop/ttsnoop_stubs.C.src @@ -37,13 +37,8 @@ #include -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) #include -#include -#else -#include -#include -#endif +#include #include "apiTracer_ui.h" #include "DtTt.h" @@ -93,13 +88,12 @@ fork_tttrace( /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData; - std::ostrstream tttraceCmd; + std::ostringstream tttraceCmd; tttraceCmd << "unset TT_TRACE_SCRIPT; dtterm -sb -sl "; tttraceCmd << globalSaveLines; tttraceCmd << " -title tttrace -geometry 120x24 -e tttrace &"; DtTtSetLabel( instance->ttsnoopWin_label, "tttrace" ); - system( tttraceCmd.str() ); - delete tttraceCmd.str(); + system( tttraceCmd.str().c_str() ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } @@ -659,15 +653,14 @@ libcPause( /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ DtbTtsnoopTtsnoopWinInfo instance = (DtbTtsnoopTtsnoopWinInfo)clientData; - std::ostrstream advice; + std::ostringstream advice; advice << "pause(); /* kill -CONT " << getpid() << " */"; - DtTtSetLabel( instance->ttsnoopWin_label, advice.str() ); - delete advice.str(); + DtTtSetLabel( instance->ttsnoopWin_label, advice.str().c_str() ); // // run "(if dterror.ds blah blah; then kill -CONT pid; fi)&" // - std::ostrstream script; + std::ostringstream script; script << "(if dterror.ds "; // arg 1: text script << "\"kill -CONT " << getpid() << "\" "; @@ -677,8 +670,7 @@ libcPause( script << "CONT; then "; // After confirmation, invoke kill(1) script << "kill -CONT " << getpid() << "; fi)&"; - system( script.str() ); - delete script.str(); + system( script.str().c_str() ); // Run the event loop a few laps, to paint the footer tttk_block_while( XtWidgetToApplicationContext( widget ), 0, 50 ); @@ -1343,10 +1335,9 @@ toggleSnooping( if (! tt_is_err( status )) { snoopPatIsRegistered = ! snoopPatIsRegistered; } - std::ostrstream stream; + std::ostringstream stream; stream << func << (void *)snoopPat << ")" << ends; - DtTtSetLabel( instance->ttsnoopWin_label, stream.str(), status ); - delete stream.str(); + DtTtSetLabel( instance->ttsnoopWin_label, stream.str().c_str(), status ); DtTtSetLabel( instance->menubar_Snoop_item_Snoop_menu_items.Off_item, snoopPatIsRegistered ? "Off" : "On" ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/