From aef2830df2bee3fe622ef54ac3feead02aa619db Mon Sep 17 00:00:00 2001 From: Ulrich Wilkens Date: Wed, 28 Aug 2013 19:45:57 +0200 Subject: [PATCH] dtinfo subdirectory dtinfo --- cde/programs/dtinfo/dtinfo/Imakefile | 6 +- cde/programs/dtinfo/dtinfo/install/Imakefile | 6 +- .../dtinfo/src/Agents/AddLibraryAgentMotif.C | 14 +- .../dtinfo/src/Agents/AddLibraryAgentMotif.hh | 2 +- .../dtinfo/dtinfo/src/Agents/AnchorCanvas.C | 5 +- .../dtinfo/dtinfo/src/Agents/BookTabMotif.C | 4 +- .../dtinfo/src/Agents/GraphicAgentMotif.C | 17 +- .../dtinfo/src/Agents/GraphicAgentMotif.hh | 4 +- .../dtinfo/dtinfo/src/Agents/HelpAgent.C | 1 - .../dtinfo/dtinfo/src/Agents/IcccmAgent.C | 10 +- .../dtinfo/dtinfo/src/Agents/IcccmAgent.hh | 2 +- .../dtinfo/dtinfo/src/Agents/LibraryAgent.res | 6 +- .../dtinfo/src/Agents/LibraryAgentMotif.C | 70 ++--- .../dtinfo/src/Agents/LibraryAgentMotif.hh | 8 +- .../dtinfo/dtinfo/src/Agents/ListViewMotif.C | 7 +- .../dtinfo/dtinfo/src/Agents/ListViewMotif.hh | 2 +- .../dtinfo/dtinfo/src/Agents/MapAgentMotif.C | 3 +- .../dtinfo/dtinfo/src/Agents/MarkCanvas.hh | 4 +- .../dtinfo/dtinfo/src/Agents/MarkIconMotif.C | 2 - .../dtinfo/dtinfo/src/Agents/MarkIconMotif.hh | 2 +- .../dtinfo/dtinfo/src/Agents/MarkListView.C | 6 +- .../dtinfo/dtinfo/src/Agents/MarkListView.hh | 2 +- .../dtinfo/src/Agents/MessageAgentMotif.C | 7 +- .../src/Agents/NodeHistoryAgentMotif.hh | 2 +- .../dtinfo/dtinfo/src/Agents/NodePrintAgent.C | 7 +- .../dtinfo/src/Agents/NodeWindowAgentMotif.C | 91 +++--- .../dtinfo/src/Agents/NodeWindowAgentMotif.hh | 2 +- .../dtinfo/src/Agents/OutlineListViewMotif.C | 36 ++- .../dtinfo/src/Agents/OutlineListViewMotif.hh | 2 +- .../dtinfo/dtinfo/src/Agents/PrefAgentMotif.C | 6 +- .../dtinfo/dtinfo/src/Agents/Preferences.res | 4 +- .../dtinfo/src/Agents/PrintPanelAgentMotif.C | 38 ++- .../dtinfo/dtinfo/src/Agents/ScopeMenu.C | 13 +- .../dtinfo/dtinfo/src/Agents/ScopeMenu.hh | 6 +- .../src/Agents/SearchHistoryListViewMotif.C | 2 +- .../src/Agents/SearchResultsAgentMotif.C | 10 +- .../dtinfo/src/Agents/SearchScopeAgentMotif.C | 65 ++--- .../src/Agents/SearchScopeAgentMotif.hh | 10 +- .../dtinfo/src/Agents/SearchScopeList.C | 40 +-- .../dtinfo/dtinfo/src/Agents/UrlAgentMotif.C | 19 +- .../dtinfo/dtinfo/src/Agents/UrlAgentMotif.hh | 2 +- .../dtinfo/dtinfo/src/Basic/Atomizer.C | 7 +- .../dtinfo/dtinfo/src/Basic/BitField.C | 6 +- cde/programs/dtinfo/dtinfo/src/Basic/Buffer.C | 8 +- .../dtinfo/dtinfo/src/Basic/FString.C | 7 +- .../dtinfo/dtinfo/src/Basic/FolioObject.C | 6 +- .../dtinfo/dtinfo/src/Basic/HashTable.C | 5 +- .../dtinfo/dtinfo/src/Basic/HashTbl.C | 2 +- cde/programs/dtinfo/dtinfo/src/Basic/List.C | 4 +- .../dtinfo/dtinfo/src/Basic/NodeID.hh | 5 +- .../dtinfo/dtinfo/src/Basic/NodeViewInfo.C | 22 +- .../dtinfo/dtinfo/src/Basic/OString.C | 5 +- .../dtinfo/dtinfo/src/Basic/OrderList.C | 10 +- .../dtinfo/dtinfo/src/Basic/OutlineElement.hh | 2 +- .../dtinfo/dtinfo/src/Basic/OutlineList.C | 12 +- .../dtinfo/dtinfo/src/Basic/OutlineString.hh | 5 +- .../dtinfo/dtinfo/src/Basic/ParseTree.C | 5 +- .../dtinfo/dtinfo/src/Basic/StringHash.C | 5 +- .../dtinfo/src/Graphics/PixmapGraphic.C | 4 +- cde/programs/dtinfo/dtinfo/src/Imakefile | 14 +- .../dtinfo/dtinfo/src/Managers/CatMgr.C | 33 ++- .../dtinfo/dtinfo/src/Managers/EnvMgr.C | 44 +-- .../dtinfo/dtinfo/src/Managers/GraphicsMgr.C | 4 +- .../dtinfo/dtinfo/src/Managers/GraphicsMgr.hh | 2 +- .../dtinfo/dtinfo/src/Managers/LibraryMgr.C | 10 +- .../dtinfo/dtinfo/src/Managers/MarkMgr.C | 8 +- .../dtinfo/dtinfo/src/Managers/MessageMgr.C | 5 +- .../dtinfo/dtinfo/src/Managers/NodeMgr.C | 4 +- .../dtinfo/dtinfo/src/Managers/PrintMgr.C | 2 - .../dtinfo/dtinfo/src/Managers/SearchMgr.C | 8 +- .../dtinfo/dtinfo/src/Managers/SearchMgr.hh | 2 +- .../dtinfo/dtinfo/src/Managers/ServiceMgrX.C | 24 +- .../dtinfo/dtinfo/src/Managers/SessionMgr.C | 21 +- .../dtinfo/src/Managers/StyleSheetMgr.C | 4 +- .../dtinfo/dtinfo/src/Managers/TtIpcMgr.C | 24 +- .../dtinfo/dtinfo/src/Marks/MarkBase_mmdb.C | 2 +- .../dtinfo/dtinfo/src/Marks/Mark_mmdb.C | 5 +- .../dtinfo/dtinfo/src/Marks/Mark_mmdb.hh | 2 +- .../dtinfo/src/OnlineRender/CanvasRenderer.C | 265 +++++++++--------- .../dtinfo/src/OnlineRender/CanvasRenderer.hh | 2 +- .../dtinfo/src/OnlineRender/FeatureSupport.C | 35 ++- .../dtinfo/src/OnlineRender/FontCache.C | 23 +- .../dtinfo/dtinfo/src/OnlineRender/Imakefile | 2 +- .../dtinfo/src/Other/WindowSystemMotif.C | 49 ++-- cde/programs/dtinfo/dtinfo/src/Other/vroot.h | 6 +- .../dtinfo/src/Preferences/BooleanPref.C | 4 +- .../dtinfo/src/Preferences/IntegerPref.C | 2 +- .../dtinfo/src/Preferences/UserPreference.C | 19 +- .../src/Preferences/WindowGeometryPref.C | 2 +- .../dtinfo/dtinfo/src/Query/QueryEditor.C | 4 +- .../dtinfo/dtinfo/src/Query/QueryGroup.C | 33 ++- .../dtinfo/dtinfo/src/Query/QueryTerm.C | 5 +- .../dtinfo/dtinfo/src/Query/QueryTerm.hh | 4 +- .../dtinfo/dtinfo/src/Query/QueryTermView.C | 5 +- .../dtinfo/dtinfo/src/Query/QueryTermView.hh | 16 +- .../dtinfo/src/Support/UtilityFunctions.C | 4 +- .../dtinfo/src/UAS/Base/UAS_BookcaseEntry.C | 15 +- .../dtinfo/src/UAS/Base/UAS_BookcaseEntry.hh | 1 + .../dtinfo/dtinfo/src/UAS/Base/UAS_Buffer.C | 9 +- .../dtinfo/dtinfo/src/UAS/Base/UAS_Common.C | 2 +- .../dtinfo/dtinfo/src/UAS/Base/UAS_Factory.C | 4 +- .../dtinfo/dtinfo/src/UAS/Base/UAS_List.C | 8 +- .../dtinfo/src/UAS/Base/UAS_OQLParser.C | 9 +- .../dtinfo/src/UAS/Base/UAS_OQLParser.hh | 4 +- .../dtinfo/src/UAS/Base/UAS_SearchResults.hh | 2 +- .../dtinfo/src/UAS/Base/UAS_SearchScope.C | 12 +- .../dtinfo/dtinfo/src/UAS/Base/UAS_String.C | 2 +- .../dtinfo/src/UAS/DtSR/DtSR_BookcaseEntry.C | 8 +- .../dtinfo/dtinfo/src/UAS/DtSR/DtSR_Parser.C | 8 +- .../dtinfo/src/UAS/DtSR/DtSR_SearchEngine.C | 19 +- .../dtinfo/src/UAS/DtSR/DtSR_SearchResults.C | 14 +- .../src/UAS/DtSR/DtSR_SearchResultsEntry.C | 4 +- .../dtinfo/dtinfo/src/UAS/DtSR/TextParser.C | 15 +- .../dtinfo/dtinfo/src/UAS/DtSR/TextTest.C | 2 +- .../dtinfo/src/UAS/DtSR/Util_Classes/Dict.C | 2 +- cde/programs/dtinfo/dtinfo/src/UAS/Imakefile | 6 +- .../dtinfo/dtinfo/src/UAS/MMDB/MMDB_Factory.C | 15 +- .../dtinfo/dtinfo/src/UAS/MMDB/MMDB_Library.C | 8 +- .../dtinfo/src/UAS/MMDB/MMDB_StyleSheet.C | 6 +- .../dtinfo/src/UAS/Test/UserPreference.C | 4 +- .../dtinfo/dtinfo/src/UAS/Test/sdrv.C | 11 +- .../dtinfo/dtinfo/src/UAS/Test/uasdrv.C | 2 +- .../dtinfo/dtinfo/src/Widgets/Panner.c | 8 +- .../dtinfo/dtinfo/src/Widgets/Pixmap.c | 3 +- .../dtinfo/dtinfo/src/Widgets/Restraint.c | 10 +- .../dtinfo/dtinfo/src/Widgets/Simple.c | 4 +- .../dtinfo/dtinfo/src/Widgets/TabButton.c | 13 +- .../dtinfo/dtinfo/src/Widgets/TabButton.h | 11 + .../dtinfo/dtinfo/src/Widgets/WXmOpButton.h | 4 +- cde/programs/dtinfo/dtinfo/src/cgm/cgm.h | 15 +- cde/programs/dtinfo/dtinfo/src/cgm/cgmcmds.c | 241 ++++++++-------- .../dtinfo/dtinfo/src/cgm/cgmcommon.c | 4 +- cde/programs/dtinfo/dtinfo/src/cgm/cgmio.c | 14 +- cde/programs/dtinfo/dtinfo/src/cgm/cgmtext.c | 4 +- cde/programs/dtinfo/dtinfo/src/cgm/getcgm.c | 2 - .../dtinfo/dtinfo/src/external-api/comm.c | 9 +- .../dtinfo/dtinfo/src/external-api/init.c | 2 +- .../dtinfo/dtinfo/src/external-api/oliasmsg.c | 5 +- cde/programs/dtinfo/dtinfo/src/main.C | 16 +- cde/programs/dtinfo/dtinfo/wwl/Imakefile | 6 +- cde/programs/dtinfo/dtinfo/wwl/src/WArgList.C | 4 +- .../dtinfo/dtinfo/wwl/src/WXmString.C | 8 +- 142 files changed, 1040 insertions(+), 898 deletions(-) diff --git a/cde/programs/dtinfo/dtinfo/Imakefile b/cde/programs/dtinfo/dtinfo/Imakefile index 32e89d1c..02d0dedd 100644 --- a/cde/programs/dtinfo/dtinfo/Imakefile +++ b/cde/programs/dtinfo/dtinfo/Imakefile @@ -8,9 +8,9 @@ SUBDIRS=wwl src install XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' MakeSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtinfo/dtinfo/install/Imakefile b/cde/programs/dtinfo/dtinfo/install/Imakefile index 28992c64..1a985d03 100644 --- a/cde/programs/dtinfo/dtinfo/install/Imakefile +++ b/cde/programs/dtinfo/dtinfo/install/Imakefile @@ -8,9 +8,9 @@ SUBDIRS = lib XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.C index 71f13aa4..19860531 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.C @@ -207,6 +207,7 @@ AddLibraryAgent::pick_dir () { if( !f_file_sel ) { Arg args[20]; + unsigned int len, slen; int n; XmString title_str = XmStringCreateLocalized( @@ -217,20 +218,23 @@ AddLibraryAgent::pick_dir () { XmString infolibs_str = XmStringCreateLocalized( (char*)"Infolibs" ); // default initial directory on first entry - char *buf = new char[256]; + unsigned int buflen = 256; + char *buf = new char[buflen]; // Note: infolibs need to be placed in platform-portably-named // LANG-type subdirectories, so the normalized CDE language // string can be used for lookup. For now, must assume the // user environment LANG is OK ... char *tmpstr; - if( tmpstr = getenv("LANG") ) - sprintf( buf, "/usr/dt/infolib/%s/", tmpstr ); + if( (tmpstr = getenv("LANG")) ) + snprintf( buf, buflen, "/usr/dt/infolib/%s/", tmpstr ); else - sprintf( buf, "/usr/dt/infolib/%s/", env().lang() ); + snprintf( buf, buflen, "/usr/dt/infolib/%s/", env().lang() ); // XmString basedir_str = XmStringCreateLocalized( buf ); - strcat( buf, "*.dti" ); + slen = strlen(buf); + len = MIN(5, buflen - 1 - slen); + *((char *) memcpy(buf + slen, "*.dti", len) + len) = '\0'; XmString initdir_str = XmStringCreateLocalized( buf ); delete [] buf; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.hh index 939b1880..038ef9f1 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/AddLibraryAgentMotif.hh @@ -32,7 +32,7 @@ class AddLibraryAgent: public WWL { WXmForm f_form; WXmPushButton f_ok; WXmPushButton f_clr; - Widget f_file_sel; bool f_done; bool f_cancelled; + Widget f_file_sel; }; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/AnchorCanvas.C b/cde/programs/dtinfo/dtinfo/src/Agents/AnchorCanvas.C index 7f559a68..a3861c72 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/AnchorCanvas.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/AnchorCanvas.C @@ -82,13 +82,14 @@ AnchorCanvas::AnchorCanvas (const char *locator, MarkInfo& mi) /* -------- Now form the anchor string -------- */ - for (int i = 0; i < mi.length(); i++) { + for (unsigned int i = 0; i < mi.length(); i++) { UAS_Pointer mui_t = mi[i]; MarkUnitInfo& mui = *mui_t; char buf[64]; if (i > 0) location = location + ","; - sprintf(buf, "%u\t%u\t%u", mui.vcc(), mui.offset(), mui.length()); + snprintf(buf, sizeof(buf), + "%u\t%u\t%u", mui.vcc(), mui.offset(), mui.length()); location = location + buf; } diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/BookTabMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/BookTabMotif.C index 7ddf562e..a9a79f31 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/BookTabMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/BookTabMotif.C @@ -78,8 +78,8 @@ BookTab::BookTab (const WComposite &parent) BookTab::BookTab (NodeWindowAgent *nwa, const WComposite &parent, UAS_Pointer &tab_ptr) -: f_node_window_agent (nwa), - WXyzTab ((Widget) NULL), +: WXyzTab ((Widget) NULL), + f_node_window_agent (nwa), f_selected (FALSE) { widget = XyzCreateTabButton (parent, "tab", NULL, 0); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.C index 73daa3f2..d504568e 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.C @@ -500,7 +500,7 @@ GraphicAgent::create_ui() else { #if !defined(VF_DEBUG) - for (int i = 0 ; i < view_menu.NumChildren(); i++) + for (unsigned int i = 0 ; i < view_menu.NumChildren(); i++) WRect(view_menu.Children()[i]).SetSensitive(False); #endif mtfstring = CATGETS(Set_GraphicAgent, 3, @@ -637,9 +637,12 @@ GraphicAgent::visit_node() extern char g_top_locator[]; extern bool g_scroll_to_locator; const char *glocator = f_graphic->locator(); + int len = 0; + ON_DEBUG (printf ("Graphic jumping to <%s>\n", glocator)); ON_DEBUG (printf (" copying to %p\n", g_top_locator)); - strcpy (g_top_locator, &glocator[8]); + len = MIN(strlen(&glocator[8]), 4096 - 1); + *((char *) memcpy(g_top_locator, &glocator[8], len) + len) = '\0'; g_scroll_to_locator = TRUE; f_node_ptr->retrieve(); } @@ -827,8 +830,10 @@ GraphicAgent::zoom_callback(WCallback *wcb) { ON_DEBUG (puts ("GraphicAgent::zoom_callback() called")); WXmToggleButton button(wcb->GetWidget()); +#if DEBUG XmToggleButtonCallbackStruct &cbs = *(XmToggleButtonCallbackStruct*)wcb->CallData(); +#endif ON_DEBUG(cerr << "cbs.set = " << cbs.set << endl); ON_DEBUG(cerr << "cbs.rsn = " << cbs.reason << endl); @@ -862,7 +867,7 @@ GraphicAgent::zoom_callback(WCallback *wcb) (Widget)f_shell); ON_DEBUG(cerr << "scale value is " << scale << endl); - if (scale == -1) + if ((int)scale == -1) { // unset Custom option in list if (((Widget)*f_scale_button) != ((Widget)button)) @@ -949,14 +954,17 @@ GraphicAgent::fit_graphic_to_window_callback(WCallback *) Dimension gr_width; Dimension gr_height; int wscale, hscale; +#if 0 unsigned int scale_factor; + int dx, dy; +#endif // get size of graphic gr_width = f_graphic->pixmap_graphic()->width(); gr_height = f_graphic->pixmap_graphic()->height(); - int dx, dy; WXawPorthole porthole(XtParent(*f_pixmap_widget)); +#if 0 dx = abs(porthole.Width() - f_graphic->pixmap_graphic()->width()); dy = abs(porthole.Height() - f_graphic->pixmap_graphic()->height()); if (dx < dy) @@ -965,6 +973,7 @@ GraphicAgent::fit_graphic_to_window_callback(WCallback *) else scale_factor = (100 * porthole.Height()) / f_graphic->pixmap_graphic()->height(); +#endif wscale = (100 * porthole.Width()) / gr_width; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.hh index 994681b6..e4cd65e4 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/GraphicAgentMotif.hh @@ -91,9 +91,9 @@ private: void unset_scale_buttons(); private: - UAS_Pointer f_node_ptr ; - UAS_Pointer f_graphic ; WTopLevelShell f_shell; + UAS_Pointer f_node_ptr ; + UAS_Pointer f_graphic ; WXawPanner *f_panner; WXmLabel *f_label; WPixmap *f_pixmap_widget ; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/HelpAgent.C b/cde/programs/dtinfo/dtinfo/src/Agents/HelpAgent.C index 11e9099c..e51be833 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/HelpAgent.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/HelpAgent.C @@ -408,7 +408,6 @@ HelpAgent::get_locator_id(const Widget w) res.default_type = XtRString; res.default_addr = (void*)NULL_LOCATORID; - char *wname = XtName(w); // Just for gdb String string; XtGetApplicationResources(w, &string, &res, 1, NULL, 0); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/IcccmAgent.C b/cde/programs/dtinfo/dtinfo/src/Agents/IcccmAgent.C index 8fb51aa4..a7c912b1 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/IcccmAgent.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/IcccmAgent.C @@ -158,12 +158,14 @@ IcccmAgent::value_handler(Widget w, XtPointer ia, Atom *selection, prop.format = 8; prop.nitems = *length; char** string_list; - int count; + int count, len, slen; XmbTextPropertyToTextList(XtDisplay(w), &prop, &string_list, &count); char *mbs = strdup(""); for (int i=0; iCallData(); +#endif char *text = XmTextGetString(wcb->GetWidget()); if (*text != '\0') @@ -1077,9 +1079,9 @@ LibraryAgent::search_help (Widget, XtPointer client_data, UAS_SearchScope *scope = agent->f_scope_menu->current_scope(); char buffer[128]; if (scope != NULL) - sprintf (buffer, help_text, (char *) scope->name()); + snprintf (buffer, sizeof(buffer), help_text, (char *) scope->name()); else - sprintf (buffer, help_text, default_scope); + snprintf (buffer, sizeof(buffer), help_text, default_scope); // Finally, display it in the quick help field. XmTextFieldSetString(agent->f_status_text, buffer); @@ -1161,6 +1163,7 @@ int LibraryAgent::add_library(char* newLib, Widget parent) { int sts = ID_SUCCESS ; + int bufferlen; if( (newLib == NULL) || ((newLib != NULL) && ( *newLib == '\0' )) ) @@ -1183,9 +1186,9 @@ LibraryAgent::add_library(char* newLib, Widget parent) else if( *newLib == '/' ) { // assume given absolute path to an infolib. // construct the fully-qualified form and pass it on. - char *buffer = - new char[strlen("mmdb:INFOLIB=") + strlen(newLib) + 1]; - sprintf (buffer, "mmdb:INFOLIB=%s", newLib); + bufferlen = strlen("mmdb:INFOLIB=") + strlen(newLib) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:INFOLIB=%s", newLib); d = UAS_Common::create (buffer); delete [] buffer; } @@ -1197,9 +1200,9 @@ LibraryAgent::add_library(char* newLib, Widget parent) if (pathname != NULL) { // construct the fully-qualified form and pass it on. - char *buffer = - new char[strlen("mmdb:INFOLIB=") + strlen(pathname) + 1]; - sprintf (buffer, "mmdb:INFOLIB=%s", pathname); + bufferlen = strlen("mmdb:INFOLIB=") + strlen(pathname) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:INFOLIB=%s", pathname); XtFree(pathname); d = UAS_Common::create (buffer); delete [] buffer; @@ -1338,7 +1341,7 @@ LibraryAgent::entry_selected (void *, u_int notify_type) int removeSensitive = 0; if (rootList.length() > 1) { // don't let 'em remove the last one... if (((TOC_Element *) f_oe)->toc()->type() == UAS_LIBRARY) { - for (int i = 0; i < rootList.length(); i ++) { + for (unsigned int i = 0; i < rootList.length(); i ++) { if (((TOC_Element *) f_oe)->toc() == ((TOC_Element *) rootList[i])->toc()) { removeSensitive = 1; @@ -1376,9 +1379,9 @@ LibraryAgent::entry_selected (void *, u_int notify_type) { // Get the list of selections. List *select_list = f_doc_tree_view->selected_item_list(); - Xassert (selected_item_count == select_list->length()); + Xassert (selected_item_count == (int) select_list->length()); - for (int i = 0; i < select_list->length(); i++) + for (unsigned int i = 0; i < select_list->length(); i++) { if (((TOC_Element *) (*select_list)[i])->toc()->data_length() == 0) { @@ -1442,7 +1445,7 @@ LibraryAgent::print_asCB(Widget w, XtPointer client_data, XtPointer) List *select_list = agent->f_doc_tree_view->selected_item_list(); xList > * print_list = new xList >; - for (int i = 0; i < select_list->length(); i++) { + for (unsigned int i = 0; i < select_list->length(); i++) { print_list->append (((TOC_Element *) (*select_list)[i])->toc()); } @@ -1480,7 +1483,7 @@ LibraryAgent::printCB(Widget w, XtPointer client_data, XtPointer) List *select_list = agent->f_doc_tree_view->selected_item_list(); xList > * print_list = new xList >; - for (int i = 0; i < select_list->length(); i++) { + for (unsigned int i = 0; i < select_list->length(); i++) { print_list->append (((TOC_Element *) (*select_list)[i])->toc()); } @@ -1547,17 +1550,21 @@ LibraryAgent::track_to (UAS_Pointer &node_ptr) OutlineList &rootList = *(f_doc_tree_view->list()); bool in_subtree = FALSE; UAS_Pointer doc_root = node_ptr; +#ifdef DEBUG int inum; +#endif // Trace up to the root. free_tracking_hierarchy(); while (doc_root != (const int)NULL && !in_subtree) { f_tracking_hierarchy = new TrackingEntry(doc_root, f_tracking_hierarchy); - for (int i = 0; i < rootList.length(); i ++) { + for (unsigned int i = 0; i < rootList.length(); i ++) { if (doc_root == ((TOC_Element *) rootList[i])->toc()) { in_subtree = TRUE; +#ifdef DEBUG inum = i; +#endif break; } } @@ -1598,9 +1605,9 @@ LibraryAgent::track (bool scroll) // that we can ultimately highlight the right entry in the list. unsigned int list_location = 0; // Make sure the roots match up, just to be safe. - TrackingEntry *t; - OutlineElement *oe; - for (int cnt = 0; cnt < rootList.length(); cnt ++) { + TrackingEntry *t = NULL; + OutlineElement *oe = NULL; + for (unsigned int cnt = 0; cnt < rootList.length(); cnt ++) { list_location ++; t = f_tracking_hierarchy->f_child; oe = (OutlineElement *) rootList[cnt]; @@ -1624,7 +1631,7 @@ LibraryAgent::track (bool scroll) // If the entry is expanded, it MUST have children. Xassert (oe->has_children()); OutlineList &kids = *(oe->children()); - int i; + unsigned int i; for (i = 0; i < kids.length(); i++) { // Keep track of how many expanded items we skip over. @@ -1677,18 +1684,18 @@ LibraryAgent::track (bool scroll) ON_DEBUG (printf ("top = %d, bottom = %d, old = %d\n", top_position, bottom_position, old_selection)); - if (list_location < top_position || - list_location > bottom_position) + if ((int)list_location < top_position || + (int)list_location > bottom_position) { ON_DEBUG (puts ("* About to scroll list")); - if (old_selection == top_position && - list_location == top_position - 1) + if ((int)old_selection == top_position && + (int)list_location == top_position - 1) { // Scroll up one item. f_doc_tree_view->TopItemPosition (top_position - 1); } - else if (old_selection == bottom_position && - list_location == bottom_position + 1) + else if ((int)old_selection == bottom_position && + (int)list_location == bottom_position + 1) { // Scroll down one item. f_doc_tree_view->TopItemPosition (top_position + 1); @@ -1748,7 +1755,7 @@ void LibraryAgent::library_removed (UAS_Pointer lib) { OutlineList &rootList = *(f_doc_tree_view->list()); - int i; + unsigned int i; for (i = rootList.length() - 1; i >= 0; i --) { TOC_Element *te = (TOC_Element *) rootList[i]; if (te->toc()->get_library() == lib) { @@ -1767,7 +1774,6 @@ LibraryAgent::library_removed (UAS_Pointer lib) //BitHandle handle = rootList.get_data_handle(); BitHandle handle = f_doc_tree_view->data_handle(); - int level = ((OutlineElement *) rootList[0])->level(); for (i = 0; i < rootList.length(); i ++) { ((OutlineElement *) rootList[i])->set_expanded (handle); @@ -1778,7 +1784,7 @@ LibraryAgent::library_removed (UAS_Pointer lib) List *bclist = oe->children(); - for(int b = 0; b < bclist->length(); b++) + for(unsigned int b = 0; b < bclist->length(); b++) { OutlineElement *coe = (OutlineElement *)(*bclist)[b]; if (coe->is_expanded(handle)) @@ -2020,7 +2026,7 @@ LibraryAgent::copy_to_clipbd() Wait_Cursor bob; UAS_String nl("\n"); - for (int i = 0; i < select_list->length(); i++) + for (unsigned int i = 0; i < select_list->length(); i++) { UAS_Pointer toc; toc = ((TOC_Element *) (*select_list)[i])->toc(); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/LibraryAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/LibraryAgentMotif.hh index f305af62..78ecb891 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/LibraryAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/LibraryAgentMotif.hh @@ -103,6 +103,10 @@ private: // variables Widget f_shell; OutlineListView *f_doc_tree_view; OutlineElement *f_oe; + bool f_keep_forever; + WCallback *f_wm_delete_callback; + TrackingEntry *f_tracking_hierarchy; + bool f_popped_down; Widget f_close; Widget f_copy; Widget f_detach; @@ -115,10 +119,6 @@ private: // variables Widget f_remove; Widget f_remove2; Widget f_auto_track; - bool f_keep_forever; - WCallback *f_wm_delete_callback; - TrackingEntry *f_tracking_hierarchy; - bool f_popped_down; bool f_close_sensitive; Widget f_status_text; ScopeMenu *f_scope_menu; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.C index 356e9117..9ba7c542 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.C @@ -154,8 +154,9 @@ ListView::create_ui_objects() (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 48, "Help")), NULL); // 7/30/93 rtp - bear with this hack, it's a little bogus - char *help_name = new char[strlen(f_name) + strlen("_help") + 1]; - sprintf(help_name, "%s%s", f_name, "_help"); + int help_namelen = strlen(f_name) + strlen("_help") + 1; + char *help_name = new char[help_namelen]; + snprintf(help_name, help_namelen, "%s%s", f_name, "_help"); // What i've done is appended '_help' to the widget name and added // a help callback to the help button that will reference this name help_agent().add_activate_help (help, help_name); @@ -212,7 +213,7 @@ ListView::display_list() if (f_shell == NULL || f_the_list == NULL) return; - int i; + unsigned int i; // NOTE: There should be a wwl object for string tables!! 6/19/92 djb XmStringTable st = (XmStringTable) diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.hh index cf8f4464..c4fb5113 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/ListViewMotif.hh @@ -74,8 +74,8 @@ protected: // view variables List *f_the_list; protected: // ui variables - char *f_name; WTopLevelShell *f_shell; + char *f_name; WXmList *f_list; WCallback *f_wm_delete_callback; int f_selected_item; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MapAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/MapAgentMotif.C index 266e82f0..f47a8ef9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MapAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MapAgentMotif.C @@ -92,6 +92,7 @@ class MapButton : public WWL public: MapButton (WComposite &parent, const UAS_Pointer &doc_ptr, MapButton *ancestor); + virtual ~MapButton() {} void activate(); void expand(); @@ -193,7 +194,7 @@ MapButton::expand() // Create a button for each child. UAS_List kids (f_doc_ptr->children()); WXawTree tree (XtParent (f_form)); - for (int i = 0; i < kids.length(); i++) + for (unsigned int i = 0; i < kids.length(); i++) new MapButton (tree, kids[i], this); ON_DEBUG (puts ("managing kids")); MapButton::ManageKids(); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MarkCanvas.hh b/cde/programs/dtinfo/dtinfo/src/Agents/MarkCanvas.hh index 925d507d..9e7a144e 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MarkCanvas.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MarkCanvas.hh @@ -38,7 +38,7 @@ class MarkCanvas : public Destructable, public: MarkCanvas (UAS_Pointer, Agent *agent, unsigned int offset, unsigned int ypos); - ~MarkCanvas(); + virtual ~MarkCanvas(); STATIC_SENDER_HH (MarkSelectionChanged); @@ -78,8 +78,8 @@ private: // functions private: // variables UAS_Pointer f_mark_ptr; - unsigned int f_full_offset; MarkIcon *f_mark_icon; + unsigned int f_full_offset; unsigned int f_y_position ; Agent *f_agent ; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.C index 6b9b72f7..357668e5 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.C @@ -84,8 +84,6 @@ using namespace std; WTimeOut *g_timeout; -static void register_actions(); - // ///////////////////////////////////////////////////////////////// // class constructor diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.hh index aa597206..d5e59dc1 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MarkIconMotif.hh @@ -39,7 +39,7 @@ class MarkIcon : public WWL, public WXmPushButton public: MarkIcon (Widget parent, Widget chooser_parent, MarkCanvas *, int ypos, int scrollbar_offset); - ~MarkIcon(); + virtual ~MarkIcon(); void append (MarkCanvas *); void insert (MarkCanvas *); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.C b/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.C index b7d525b5..7be58310 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.C @@ -283,7 +283,7 @@ MarkListView::view() { Xassert (f_selected_item > 0); - Xassert (f_selected_item <= f_mark_list.length()); + Xassert (f_selected_item <= (int) f_mark_list.length()); List_Iterator > m (f_mark_list); int i = 1; @@ -311,7 +311,7 @@ void MarkListView::remove() { Xassert (f_selected_item > 0); - Xassert (f_selected_item <= f_mark_list.length()); + Xassert (f_selected_item <= (int) f_mark_list.length()); List_Iterator > m (f_mark_list); int i = 1; @@ -335,7 +335,7 @@ void MarkListView::edit() { Xassert (f_selected_item > 0); - Xassert (f_selected_item <= f_mark_list.length()); + Xassert (f_selected_item <= (int) f_mark_list.length()); List_Iterator > m (f_mark_list); int i = 1; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.hh b/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.hh index c0c959c5..63605a39 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MarkListView.hh @@ -43,7 +43,7 @@ class MarkListView : public WWL, public: MarkListView(); - ~MarkListView(); + virtual ~MarkListView(); void display(); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/MessageAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/MessageAgentMotif.C index 46834a23..510ae98f 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/MessageAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/MessageAgentMotif.C @@ -143,9 +143,9 @@ MessageAgent::position_dialog (WCallback *) int win_x, win_y; unsigned int mask; +#ifdef BOGUS static int sizesSet = 0; -#ifdef BOGUS if (!sizesSet) { WXmDialogShell theShell (XtParent (*f_dialog)); theShell.MinHeight (theShell.Height()); @@ -600,7 +600,7 @@ MessageAgent::get_integer (const char *message, const char* title, mtfstring = CATGETS(Set_AgentLabel, 162, "Cancel"); XtVaSetValues((Widget)f_dialog->CancelPB(), XmNlabelString, (XmString)mtfstring, NULL); - sprintf (buffer, "%d", default_value); + snprintf (buffer, sizeof(buffer), "%d", default_value); f_text->Value (buffer); f_text->Manage(); @@ -734,7 +734,8 @@ MessageAgent::get_string (const char *msg, const char* title, g_active = FALSE; f_text->Unmanage(); char *value = f_text->Value(); - strcpy (buffer, value); + int len = MIN(strlen(value), 256 - 1); + *((char *) memcpy(buffer, value, len) + len) = '\0'; ON_DEBUG (printf ("User entered <%s>\n", value)); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/NodeHistoryAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/NodeHistoryAgentMotif.hh index 73c755e6..2fbe757b 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/NodeHistoryAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/NodeHistoryAgentMotif.hh @@ -40,7 +40,7 @@ public: // functions NodeHistoryAgent() : f_shell (NULL), f_selected_item (0) { } - ~NodeHistoryAgent(); + virtual ~NodeHistoryAgent(); void display(); private: // functions diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/NodePrintAgent.C b/cde/programs/dtinfo/dtinfo/src/Agents/NodePrintAgent.C index 1a5a7c6b..0f74ef40 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/NodePrintAgent.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/NodePrintAgent.C @@ -124,6 +124,7 @@ using namespace std; #include "Registration.hh" // for DtCanvas Help stuff +#include #include #include #include @@ -364,7 +365,7 @@ NodePrintAgent::create_ui(Widget parent) // Create a right attached label for the book number - sprintf(buf, "%d", 1); + snprintf(buf, sizeof(buf), "%d", 1); label = XmStringCreate(buf, XmFONTLIST_DEFAULT_TAG); n = 0; XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++; @@ -417,7 +418,7 @@ NodePrintAgent::display(UAS_Pointer &node_ptr) // ui if ((f_help_dsp_area == NULL) || (gHelpDisplayArea == 0)) { - DtHelpDispAreaStruct *displayArea = create_ui(f_print_shell); + create_ui(f_print_shell); first_time = TRUE; } @@ -433,7 +434,7 @@ NodePrintAgent::display(UAS_Pointer &node_ptr) // update page number in footer n = 0; - sprintf(buf, "%d", 1); + snprintf(buf, sizeof(buf), "%d", 1); label = XmStringCreate(buf, XmFONTLIST_DEFAULT_TAG); XtSetArg(args[n], XmNlabelString, label); n++; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C index caa33314..936bcdd4 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C @@ -133,6 +133,7 @@ using namespace std; #include "Registration.hh" // for DtCanvas Help stuff +#include #include #include #include @@ -461,7 +462,7 @@ NodeWindowAgent::popup_menu(XButtonPressedEvent* event) gr_type++; char buff[40]; - sprintf(buff,"%s graphic",gr_type); + snprintf(buff, sizeof(buff), "%s graphic", gr_type); XmTextFieldSetString(f_status_text, buff); break; @@ -499,16 +500,15 @@ NodeWindowAgent::popup_menu(XButtonPressedEvent* event) char preview_buffer[256]; UAS_String pt = doc_ptr->title(); - strncpy (title, (char *) pt, 127); - title[127] = '\0'; + *((char *) memcpy(title, (char *) pt, 127) + 127) = '\0'; UAS_String bn = doc_ptr->book_name(UAS_SHORT_TITLE); const char *book_name = (char *) bn; if (book_name != NULL && *book_name != '\0') - sprintf (preview_buffer, CATGETS(Set_Messages, 8, "Link to %s: %s"), - book_name, title); + snprintf (preview_buffer, sizeof(preview_buffer), + CATGETS(Set_Messages, 8, "Link to %s: %s"), book_name, title); else - sprintf (preview_buffer, CATGETS(Set_Messages, 9, "Link to %s"), - title); + snprintf (preview_buffer, sizeof(preview_buffer), + CATGETS(Set_Messages, 9, "Link to %s"), title); WXmLabel lb = WXmLabel(f_preview_label); lb.LabelString(WXmString(title)); @@ -692,16 +692,16 @@ public: NULL)); } } - ~Ancestor() + virtual ~Ancestor() { f_button.Destroy(); } void update (const char *title, UAS_Pointer toc_ptr); void activate(); + NodeWindowAgent *f_node_window_agent; WXmPushButton f_button; UAS_Pointer f_toc_ptr; - NodeWindowAgent *f_node_window_agent; }; void @@ -765,21 +765,21 @@ Ancestor::activate() // ///////////////////////////////////////////////////////////////// NodeWindowAgent::NodeWindowAgent (u_int serial_no) -: f_shell (NULL), - f_help_dsp_area (NULL), +: IcccmAgent((void*)this,(data_handler_t)&NodeWindowAgent::do_search_selection), f_node_view_info (NULL), + f_shell (NULL), + f_help_dsp_area (NULL), + f_close(NULL), + f_current_ancestor (NULL), + f_form(NULL), f_preview_timeout (NULL), f_serial_number(serial_no), - f_current_ancestor (NULL), f_history_display (FALSE), - f_form(NULL), - f_graphics_handler(NULL), - IcccmAgent((void*)this, (data_handler_t)&NodeWindowAgent::do_search_selection), - f_close(NULL), - f_close_sensitive(FALSE), f_vscrollbar_offset(0), f_hscrollbar_offset(0), - f_graphic_segment(NULL) + f_graphic_segment(NULL), + f_graphics_handler(NULL), + f_close_sensitive(FALSE) { UAS_Common::request ((UAS_Receiver *) this); @@ -2155,7 +2155,8 @@ NodeWindowAgent::do_search_selection (const char* value, unsigned long) { buflen += 16 ; char *newbuf = new char[buflen] ; - strcpy(newbuf, buffer); + int len = buflen - 1; + *((char *) memcpy(newbuf, buffer, len) + len) = '\0'; int depth = dest - buffer ; delete buffer ; buffer = newbuf ; @@ -2228,7 +2229,7 @@ NodeWindowAgent::search_on_selectionCB(Widget, XtPointer client_data, void NodeWindowAgent::text_callback(WCallback *wcb) { - XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct*)wcb->CallData(); + (XmAnyCallbackStruct*)wcb->CallData(); char *text = XmTextGetString(wcb->GetWidget()); if (text == NULL) return; @@ -2298,9 +2299,9 @@ NodeWindowAgent::search_help (Widget, XtPointer client_data, UAS_SearchScope *scope = agent->f_scope_menu->current_scope(); char buffer[128]; if (scope != NULL) - sprintf (buffer, help_text, (char *) scope->name()); + snprintf (buffer, sizeof(buffer), help_text, (char *) scope->name()); else - sprintf (buffer, help_text, default_scope); + snprintf (buffer, sizeof(buffer), help_text, default_scope); // Finally, display it in the quick help field. XmTextFieldSetString(agent->f_status_text, buffer); @@ -2959,16 +2960,15 @@ NodeWindowAgent::preview (WTimeOut *) char preview_buffer[256]; UAS_String pt = f_preview_document->title(); - strncpy (title, (char *) pt, 127); - title[127] = '\0'; + *((char *) memcpy(title, (char *) pt, 127) + 127) = '\0'; UAS_String bn = f_preview_document->book_name(UAS_SHORT_TITLE); const char *book_name = (char *) bn; if (book_name != NULL && *book_name != '\0') - sprintf (preview_buffer, CATGETS(Set_Messages, 8, "Link to %s: %s"), - book_name, title); + snprintf (preview_buffer, sizeof(preview_buffer), + CATGETS(Set_Messages, 8, "Link to %s: %s"), book_name, title); else - sprintf (preview_buffer, CATGETS(Set_Messages, 9, "Link to %s"), - title); + snprintf (preview_buffer, sizeof(preview_buffer), + CATGETS(Set_Messages, 9, "Link to %s"), title); XmTextFieldSetString(f_status_text, preview_buffer); f_preview_timeout = NULL; f_preview_document = NULL; @@ -3128,7 +3128,7 @@ NodeWindowAgent::make_bookmark (Boolean edit, MarkCanvas* refmark) unsigned int length = 0; unsigned int offset = 0; - int i; + unsigned int i; for (i = 0; segs[i]; i++) { _DtCvSegPts* segpts = segs[i]; @@ -3431,7 +3431,7 @@ NodeWindowAgent::select_mark_in_canvas(MarkCanvas *mark_to_show, bool show_it) } point_info.client_data = mark_to_show; - _DtCvStatus status2 = + _DtCanvasActivatePts (f_help_dsp_area->canvas, _DtCvACTIVATE_MARK_ON, // mask &point_info, // info @@ -3696,7 +3696,7 @@ NodeWindowAgent::show_locator() //const char *locator = f_node_ptr->locator(); UAS_String locator_str = f_node_ptr->id(); const char *locator = (const char *)locator_str; - sprintf (buffer, + snprintf (buffer, sizeof(buffer), CATGETS(Set_NodeWindowAgent, 4, "The locator for this section is %s"), locator); XmTextFieldSetString(f_status_text, buffer); @@ -3893,10 +3893,11 @@ NodeWindowAgent::display (UAS_Pointer &node_ptr) f_node_view_info->comp_pixel_values( XtDisplay(f_help_dsp_area->dispWid), f_help_dsp_area->colormap + ); _DtCvTopicInfo *topic = f_node_view_info->topic(); - SetTopic(f_node_view_info->topic()); + SetTopic(topic); initialize_controls(); @@ -3914,10 +3915,11 @@ NodeWindowAgent::display (UAS_Pointer &node_ptr) char buffer[256]; - strcpy (buffer, "Dtinfo: "); - strncat (buffer, - f_node_view_info->node_ptr()->book_name (UAS_LONG_TITLE), - 127); + *((char *) memcpy(buffer, "Dtinfo: ", 8) + 8) = '\0'; + int slen = strlen(buffer); + *((char *) memcpy(buffer + slen, + f_node_view_info->node_ptr()->book_name (UAS_LONG_TITLE), + 127) + 127) = '\0'; f_shell->Title (buffer); f_shell->IconName (buffer); @@ -4410,8 +4412,7 @@ NodeWindowAgent::SetTopic(_DtCvTopicPtr topic) if (g_top_locator[0] != 0) topic->id_str = g_top_locator ; - _DtCvStatus status; - status = _DtCanvasSetTopic(f_help_dsp_area->canvas, topic, _DtCvFALSE, + _DtCanvasSetTopic(f_help_dsp_area->canvas, topic, _DtCvFALSE, &ret_width, &ret_height, &ret_y); #ifdef CV_HYPER_DEBUG cerr << "top locator=" << topic->id_str << ' ' @@ -4562,7 +4563,7 @@ NodeWindowAgent::create_canvas_mark(_DtCvHandle canvas, UAS_List marks_loc_list; marks_loc_list = marks_loc.splitFields(','); - int i; + unsigned int i; for (i = 0; i < marks_loc_list.length(); i++) { UAS_String& mark_loc = *marks_loc_list[i]; @@ -4713,7 +4714,8 @@ NodeWindowAgent::link_to (const char *locator) if (target) { node_mgr().set_preferred_window (this); - strcpy(g_top_locator, (char*)loc); + int len = MIN(strlen((char*)loc), 4096 - 1); + *((char *) memcpy(g_top_locator, (char*)loc, len) + len) = '\0'; target->retrieve() ; } @@ -4793,14 +4795,14 @@ NodeWindowAgent::layout_mark_icons() List_Iterator m (f_mark_list); MarkIcon *mark_icon = NULL; - MarkCanvas *jump_to = NULL; +//MarkCanvas *jump_to = NULL; while (m) { if (g_view_mark() == m.item()->mark_ptr()) { g_view_mark() = NULL; - jump_to = m.item(); +// jump_to = m.item(); } MarkIcon *mi = NULL; @@ -4820,7 +4822,7 @@ NodeWindowAgent::layout_mark_icons() } if (mi == NULL) { - MarkIcon *mark_icon = + mark_icon = new MarkIcon (XtParent (XtParent (f_help_dsp_area->dispWid)), *f_shell, m.item(), m.item()->y_position(), f_vscrollbar_offset); @@ -5236,8 +5238,7 @@ NodeWindowAgent::replace(UAS_Pointer &gr) // inform our canvas that it needs to re-render _DtCvUnit width = 0, height = 0; - _DtCvStatus status; - status = _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas, + _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas, _DtCvTRUE, &width, &height); // There's no C/RE APIs provided to set maxYpos correctly // after canvas reformatting contents, so dtinfo manually diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.hh index 9821259d..512a7423 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.hh @@ -354,7 +354,7 @@ class GraphicsHandler : public UAS_Receiver, { public: GraphicsHandler(NodeWindowAgent *agent); - ~GraphicsHandler(); + virtual ~GraphicsHandler(); void receive(DetachGraphic &, void *client_data); void receive(ReAttachGraphic &, void *client_data); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C index af237935..3bea3352 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C @@ -91,9 +91,10 @@ using namespace std; extern "C" { void _Xm_dump_external(XmString); } +#ifdef NotDefined static XmString XmStringCreateComponent (XmStringComponentType tag, void *data, u_int length); -static void register_actions(); +#endif enum { XmSTRING_COMPONENT_POINTER = XmSTRING_COMPONENT_USER_BEGIN }; @@ -238,11 +239,12 @@ OutlineListView::set_list (OutlineList *list, BitHandle handle) if (f_list != NULL && f_list != list ) list->free_data_handle (f_data_handle); f_list = list; - if (list != NULL) + if (list != NULL) { if (handle != 0) f_data_handle = handle ; else f_data_handle = list->get_data_handle(); + } // Determine the base level. f_base_level = 0; if (list->length() > 0) { @@ -465,6 +467,7 @@ OutlineListView::generate_table (OutlineList *list, XmStringTable &table, } +#ifdef NotDefined // ///////////////////////////////////////////////////////////////// // XmStringCreateComponent // ///////////////////////////////////////////////////////////////// @@ -505,6 +508,7 @@ XmStringCreateComponent (XmStringComponentType tag, #endif return (string); } +#endif // ///////////////////////////////////////////////////////////////// @@ -529,7 +533,7 @@ OutlineListView::y_to_outline_element (Position y) #endif // Another Motif 1.2 bug. YToPos should return 0 for bogus position, // but it doesn't check the range. - if (f_item_pos < 0 || f_item_pos >= ItemCount()) + if (f_item_pos < 0 || (int) f_item_pos >= ItemCount()) return (NULL); oe = item_at (f_item_pos); @@ -833,7 +837,7 @@ OutlineListView::printConvertCallback(WCallback *wcb) char filepath[MAXPATHLEN]; OutlineElement *oe = NULL; FILE * fp; - int n; + int n, len, slen; Atom FILE_NAME = XInternAtom(XtDisplay(w), XmSFILE_NAME, False); Atom TARGETS = XInternAtom(XtDisplay(w), XmSTARGETS, False); @@ -904,8 +908,12 @@ OutlineListView::printConvertCallback(WCallback *wcb) ( S_IRUSR|S_IRGRP|S_IWUSR|S_IWGRP), &fp); #else - strcpy(filepath, getenv("HOME")); - strcat(filepath, "/.dt/tmp/file.itp"); + len = MIN(strlen(getenv("HOME")), MAXPATHLEN - 1); + *((char *) memcpy(filepath, getenv("HOME"), len) + len) = '\0'; + slen = len; + len = MIN(strlen("/.dt/tmp/file.itp"), MAXPATHLEN - 1); + *((char *) memcpy(filepath + slen, + "/.dt/tmp/file.itp", len) + len) = '\0'; #endif // print on on debug @@ -919,7 +927,7 @@ OutlineListView::printConvertCallback(WCallback *wcb) // write out each element in the list - for (int i = 0; i < f_selected_item_count; i++) { + for (unsigned int i = 0; i < f_selected_item_count; i++) { oe = item_at(selectedPositions[i] - 1) ; TOC_Element *te = (TOC_Element *)oe; @@ -966,7 +974,6 @@ void OutlineListView::select (WCallback *wcb) { XmListCallbackStruct *lcs = (XmListCallbackStruct *) wcb->CallData(); - XmStringTable items = Items(); OutlineElement *oe = NULL; DEBUGF (("**** select: item count = %d, pos = %d, selected = %s\n", @@ -986,7 +993,7 @@ OutlineListView::select (WCallback *wcb) printf ("selected # = %d\n", f_selected_item_count); printf (" # = %d\n", SelectedItemCount()); #endif - for (int i = 0; i < f_selected_item_count; i++) + for (unsigned int i = 0; i < f_selected_item_count; i++) { DEBUGF (("M-> extracting at %d\n", lcs->selected_item_positions[i])); oe = item_at(lcs->selected_item_positions[i] - 1) ; @@ -1079,7 +1086,6 @@ void OutlineListView::activate (WCallback *wcb) { XmListCallbackStruct *lcs = (XmListCallbackStruct *) wcb->CallData(); - XmStringTable items = Items(); OutlineElement *oe; int expanded = False; @@ -1263,7 +1269,7 @@ void OutlineListView::update_highlighting_recursive (OutlineList *list, u_int &item_pos) { - for (int i = 0; i < list->length(); i++) + for (unsigned int i = 0; i < list->length(); i++) { // Select it, do not call the select callback. if (OUTLINE_ELEMENT(i)->is_selected (f_data_handle)) @@ -1346,12 +1352,13 @@ void OutlineListView::track_to (OutlineElement *oe, u_int position, char icon) { // Remove the old tracking icon, if any set. - if (f_tracking_position > 0) + if (f_tracking_position > 0) { if (window_system().nofonts()) set_track_icon (f_tracking_element, f_tracking_position, ' '); else set_track_icon (f_tracking_element, f_tracking_position, OLIAS_PLACEHOLDER_ICON); + } // Set the new tracking icon. set_track_icon (oe, position, icon); @@ -1363,12 +1370,13 @@ OutlineListView::track_to (OutlineElement *oe, u_int position, char icon) void OutlineListView::untrack() { - if (f_tracking_position > 0) + if (f_tracking_position > 0) { if (window_system().nofonts()) set_track_icon (f_tracking_element, f_tracking_position, ' '); else set_track_icon (f_tracking_element, f_tracking_position, OLIAS_PLACEHOLDER_ICON); + } f_tracking_position = 0; } @@ -1382,8 +1390,6 @@ OutlineListView::set_track_icon (OutlineElement *oe, u_int position, char icon) { xmstring (oe, 1, icon); - XmStringTable items = Items(); - // Tell the list about the change XmString item = (XmString) oe->xm_string(); bool selected = PosSelected (position); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.hh index 50e49c1a..109f6d14 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.hh @@ -126,8 +126,8 @@ protected: // view variables unsigned short f_base_level; unsigned char f_selection_policy; u_int f_serial_number; - u_int f_selected_item_count; OutlineElement *f_current_selection; + u_int f_selected_item_count; unsigned char f_tracking_possible; u_int f_tracking_position; OutlineElement *f_tracking_element; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/PrefAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/PrefAgentMotif.C index 6da54568..e5013271 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/PrefAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/PrefAgentMotif.C @@ -982,7 +982,7 @@ void PrefAgent::set_geometry (WXmTextField &field, WindowGeometry &wg) { static char buf[16]; - sprintf (buf, "%dx%d", wg.width, wg.height); + snprintf (buf, sizeof(buf), "%dx%d", wg.width, wg.height); field.Value (buf); SET_VALUE (field, WindowGeometry, wg); } @@ -996,7 +996,7 @@ void PrefAgent::set_integer (WXmTextField &field, int i) { static char buf[16]; - sprintf (buf, "%d", i); + snprintf (buf, sizeof(buf), "%d", i); field.Value (buf); SET_VALUE (field, Integer, i); } @@ -1062,7 +1062,7 @@ void PrefAgent::get_geometry (WCallback *wcb) { WXmTextField text_field ((Widget)wcb->ClientData()); - char *shell_name; + char *shell_name = NULL; if (text_field == f_map_geo) shell_name = (char*)"map"; else if (text_field == f_browse_geo) diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/Preferences.res b/cde/programs/dtinfo/dtinfo/src/Agents/Preferences.res index a6444812..6bb8de54 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/Preferences.res +++ b/cde/programs/dtinfo/dtinfo/src/Agents/Preferences.res @@ -182,8 +182,8 @@ Dtinfo ! Default Preference values. These are only the initial values! ! Once changed with the Preferences dialog they are no longer used. -Dtinfo*BrowseGeometry: 500x630 -Dtinfo*FontScale: 0 +Dtinfo*BrowseGeometry: 640x720 +Dtinfo*FontScale: 1 Dtinfo*BrowseLock: off Dtinfo*MapGeometry: 520x350 Dtinfo*MapAutoUpdate: true diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/PrintPanelAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/PrintPanelAgentMotif.C index 210ed792..ea7a856f 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/PrintPanelAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/PrintPanelAgentMotif.C @@ -194,8 +194,8 @@ reset_ui(AppPrintData *p) // Set up the "Number of Nodes" labels. static char buffer[24]; - - sprintf (buffer, "%d", print_list.length()); + + snprintf (buffer, sizeof(buffer), "%d", print_list.length()); f_selected_field.LabelString (WXmString (buffer)); f_to_print_field.LabelString (WXmString (buffer)); @@ -244,8 +244,8 @@ customizePrintSetupBox(AppPrintData *p) Widget print_dialog = p->f_print_dialog; RCS_DEBUG("customizePrintSetupBox called.\n"); - Widget row, how_many_frame, how_many_title, how_many_form, selected_label, print_panel; - Widget to_print_label, what_frame, what_title, what_form, selected_field, to_print_field; + Widget how_many_frame, how_many_form, selected_label, print_panel; + Widget what_frame, what_form, selected_field, to_print_field; Widget print_nodes; // Create the app-specific top work area @@ -273,7 +273,7 @@ customizePrintSetupBox(AppPrintData *p) label = XmStringGenerate(CATGETS(Set_AgentLabel, 205, "Number of Sections"), NULL, XmCHARSET_TEXT, NULL); - how_many_title = XtVaCreateManagedWidget("how_many_title", + XtVaCreateManagedWidget("how_many_title", xmLabelWidgetClass, how_many_frame, XmNchildType, XmFRAME_TITLE_CHILD, @@ -315,7 +315,7 @@ customizePrintSetupBox(AppPrintData *p) label = XmStringGenerate(CATGETS(Set_AgentLabel, 207, "To Be Printed:"), NULL, XmCHARSET_TEXT, NULL); - to_print_label = XtVaCreateManagedWidget("to_print_label", + XtVaCreateManagedWidget("to_print_label", xmLabelWidgetClass, how_many_form, XmNlabelString, label, @@ -358,7 +358,7 @@ customizePrintSetupBox(AppPrintData *p) label = XmStringGenerate(CATGETS(Set_AgentLabel, 209, "What to Print"), NULL, XmCHARSET_TEXT, NULL); - what_title = XtVaCreateManagedWidget("what_title", + XtVaCreateManagedWidget("what_title", xmLabelWidgetClass, what_frame, XmNlabelString, label, @@ -435,7 +435,6 @@ PdmNotifyCB(Widget pr_shell, XtPointer client_data, XtPointer call_data) XmPrintShellCallbackStruct* pr_cbs = (XmPrintShellCallbackStruct*) call_data; - AppPrintData * p = (AppPrintData *) client_data ; if ((pr_cbs->reason == XmCR_PDM_NONE) || (pr_cbs->reason == XmCR_PDM_START_ERROR) || @@ -494,7 +493,8 @@ CreatePrintShell(Widget widget, AppPrintData* p) // set default print medium if specified on command line if (window_system().videoShell()->paper_size != NULL) { - sprintf(buf, "*default-medium: %s\n", window_system().videoShell()->paper_size); + snprintf(buf, sizeof(buf), "*default-medium: %s\n", + window_system().videoShell()->paper_size); XpSetAttributes( p->f_print_data->print_display, p->f_print_data->print_context, @@ -725,8 +725,6 @@ PrintCB(Widget print_dialog, XtPointer client_data, XtPointer call_data) void QuickPrintCB(Widget pr_button, XtPointer client_data, XtPointer call_data) { - char *msg; - RCS_DEBUG("QuickPrintCB called.\n"); AppPrintData *p = (AppPrintData*)client_data; @@ -969,8 +967,10 @@ PrintOneUASCommon(UAS_Pointer &doc, Widget pshell, int *cur_pageP) // set print orientation to either landscape or portrait (if set) if (f_printOrientation != NULL) { - sprintf(buf, "*content-orientation: %s\n", f_printOrientation); - XpSetAttributes(XtDisplay(pshell), XpGetContext(XtDisplay(pshell)), XPPageAttr, buf, XPAttrMerge); + snprintf(buf, sizeof(buf), + "*content-orientation: %s\n", f_printOrientation); + XpSetAttributes(XtDisplay(pshell), XpGetContext(XtDisplay(pshell)), + XPPageAttr, buf, XPAttrMerge); } for (gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible = 0; @@ -981,7 +981,7 @@ PrintOneUASCommon(UAS_Pointer &doc, Widget pshell, int *cur_pageP) XpStartPage(XtDisplay(pshell), XtWindow(pshell)); - sprintf(buf, "%d", *cur_pageP); + snprintf(buf, sizeof(buf), "%d", *cur_pageP); label = XmStringCreateLocalized(buf); n = 0; @@ -1000,7 +1000,7 @@ PrintOneUASCommon(UAS_Pointer &doc, Widget pshell, int *cur_pageP) // Print chidren if appropriate if (print_hierarchy) { - int i; + unsigned int i; UAS_List kids = doc->children(); for (i = 0; i < kids.length(); i++) @@ -1028,7 +1028,6 @@ PrintCloseDisplayCB( { RCS_DEBUG("PrintCloseDisplayCB called.\n"); - DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data; AppPrintData *p = (AppPrintData*)client_data; if (p->f_print_shell) @@ -1062,7 +1061,6 @@ ToggleWhatCB( { RCS_DEBUG("ToggleWhatCB called.\n"); - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct *) call_data; AppPrintData * p = (AppPrintData *)client_data; xList > &print_list = *(p->f_print_list); @@ -1089,7 +1087,7 @@ ToggleWhatCB( if (active == f_print_nodes) { - sprintf (buffer, "%d", print_list.length()); + snprintf (buffer, sizeof(buffer), "%d", print_list.length()); print_hierarchy = False; } else // active == f_print_hierarchy @@ -1099,11 +1097,11 @@ ToggleWhatCB( if (subtree_size != 0) { - sprintf (buffer, "%d", subtree_size); + snprintf (buffer, sizeof(buffer), "%d", subtree_size); } else { - strcpy (buffer, "?"); + *((char *) memcpy(buffer, "?", 1) + 1) = '\0'; } print_hierarchy = True; } diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.C b/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.C index 8ce103dd..214461ae 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.C @@ -176,8 +176,6 @@ ScopeMenu::fill_menu() void ScopeMenu::set_scope (WCallback *wcb) { - CALL_DATA (XmToggleButtonCallbackStruct,tbcs); - f_current_scope = (UAS_SearchScope *) WXmPushButtonGadget(wcb->GetWidget()).UserData(); } @@ -284,7 +282,7 @@ ScopeMenu::receive (ScopeDeleted &msg, void *client_data) XtSetArg(args[n], XmNchildren, &kids); n++; XtGetValues(f_pull_menu, args, n); - int i; + unsigned int i; for (i = 0; i < num_kids; i++) { if (XmIsSeparator (kids[i])) @@ -300,7 +298,7 @@ ScopeMenu::receive (ScopeDeleted &msg, void *client_data) // It had better be in the list! theKid = i; - Xassert (theKid != num_kids); + Xassert (theKid != (int) num_kids); ON_DEBUG (printf ("widget #%d is the button\n", theKid)); // if it is selected, select first w/ callback called @@ -322,7 +320,7 @@ ScopeMenu::receive (ScopeDeleted &msg, void *client_data) ON_DEBUG (printf ("ScopeMenu: sep pos = %d, num_kids = %d (%d)\n", separator_pos, num_kids, num_kids -1 -2)); // - 1 for deleted widget - if (separator_pos == (num_kids - 1)) + if (separator_pos == (int) (num_kids - 1)) { ON_DEBUG (puts (" destroying separator")); XtDestroyWidget (kids[separator_pos-1]); @@ -339,14 +337,13 @@ ScopeMenu::receive (ScopeRenamed &msg, void *client_data) int n; Cardinal num_kids; WidgetList kids; - int separator_pos = -1; n = 0; XtSetArg(args[n], XmNnumChildren, &num_kids); n++; XtSetArg(args[n], XmNchildren, &kids); n++; XtGetValues(f_pull_menu, args, n); - int i; + unsigned int i; for (i = 0; i < num_kids; i++) { if (XmIsPushButtonGadget (kids[i]) && @@ -405,7 +402,7 @@ ScopeMenu::receive (UpdateMenu &msg, void *client_data) XtGetValues(f_pull_menu, args, n); // destroy all toggle buttons in menu - for (int i = 0; i < num_kids; i++) + for (unsigned int i = 0; i < num_kids; i++) { XtUnmanageChild (kids[i]); XtDestroyWidget (kids[i]); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.hh b/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.hh index 3631fcda..6f27c87a 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/ScopeMenu.hh @@ -51,7 +51,7 @@ class ScopeMenu : public WWL, { public: ScopeMenu (Widget option_menu, bool requires_current_section = FALSE); - ~ScopeMenu(); + virtual ~ScopeMenu(); UAS_SearchScope *current_scope() { return (f_current_scope); } @@ -67,8 +67,8 @@ private: void receive (UpdateMenu &, void *client_data); private: - Widget f_option_menu; - Widget f_pull_menu; UAS_SearchScope *f_current_scope; bool f_use_current_section ; + Widget f_option_menu; + Widget f_pull_menu; }; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/SearchHistoryListViewMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/SearchHistoryListViewMotif.C index 99e2d5ee..77cd8fdf 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/SearchHistoryListViewMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/SearchHistoryListViewMotif.C @@ -88,7 +88,7 @@ SearchHistoryListView::display_value(FolioObject *object) ResultID &rid = *(ResultID*)object; char buf[8]; - sprintf(buf, "%d", rid.ndocs()); + snprintf(buf, sizeof(buf), "%d", rid.ndocs()); WXmString matchString = buf; UAS_Pointer results = rid.results(); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/SearchResultsAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/SearchResultsAgentMotif.C index 4cd16585..73da2458 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/SearchResultsAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/SearchResultsAgentMotif.C @@ -283,7 +283,7 @@ SearchResultsAgent::display (ResultID *results) f_results = results; - UAS_SearchEngine &se = search_mgr().search_engine(); + // UAS_SearchEngine &se = search_mgr().search_engine(); // get window up quick @@ -319,10 +319,10 @@ SearchResultsAgent::display (ResultID *results) /* -------- Display the number of hits. -------- */ char buffer[80]; - sprintf (buffer, "%d of %d sections", + snprintf (buffer, sizeof(buffer), "%d of %d sections", f_docs_to_display, results->ndocs()); f_hits_label->LabelString (buffer); - sprintf (buffer, "%s", + snprintf (buffer, sizeof(buffer), "%s", (char *)*(UAS_String*)(results->results()->scope_name())); f_scope_label->LabelString (buffer); @@ -379,8 +379,8 @@ SearchResultsAgent::fill_list(UAS_List& rlist) static XmString string_table[INITIAL_FILL_SIZE]; XmString *t = string_table; - int string_count = 0 ; - int i; + unsigned int string_count = 0 ; + unsigned int i; for (i = 0; i < rlist.length(); i ++) { string_count++ ; *t++ = form_result_string (rlist[i]); diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.C index d91a8c12..220631bb 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.C @@ -220,7 +220,9 @@ ScopeOutlineListView::select(WCallback *wcb) } else { // first get item that was selected +#ifdef JBM XmStringTable items = Items(); +#endif XmListCallbackStruct *lcs = (XmListCallbackStruct *)wcb->CallData(); OutlineElement *oe ; @@ -287,7 +289,7 @@ ScopeOutlineListView::find_parent(OutlineElement *parent, if (parent->has_children() && parent->children_cached()) { OutlineList *olist = parent->children() ; - for (int i = 0 ; i < olist->length(); i++) + for (unsigned int i = 0 ; i < olist->length(); i++) { current = (OutlineElement*)(*olist)[i] ; if (current == element) @@ -331,7 +333,7 @@ ScopeOutlineListView::lid_to_index(const UAS_String &lid) { OutlineList *ol = list(); OutlineElement *oe; - for (int i = 0; i < ol->length(); i++) + for (unsigned int i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); @@ -347,7 +349,7 @@ ScopeOutlineListView::lid_to_name(UAS_String &lid) { OutlineList *ol = list(); OutlineElement *oe; - for (int i = 0; i < ol->length(); i++) + for (unsigned int i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); @@ -364,7 +366,7 @@ ScopeOutlineListView::name_to_lid(UAS_String &name) { OutlineList *ol = list(); OutlineElement *oe; - for (int i = 0; i < ol->length(); i++) + for (unsigned int i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); @@ -576,7 +578,7 @@ SearchScopeAgent::create_ui() #else UAS_List rootList = UAS_Common::rootLocators (); OutlineList *ol = new OutlineList(rootList.length()); - for (int i = 0; i < rootList.length(); i ++) { + for (unsigned int i = 0; i < rootList.length(); i ++) { UAS_Pointer d = UAS_Common::create(*(UAS_String *)rootList[i]); UAS_Pointer cd = (UAS_Collection *) ((UAS_Common *) d); ol->append (new TOC_Element (cd->root())); @@ -663,7 +665,7 @@ SearchScopeAgent::scope_name_prompt() default_name = new char[len + 1] ; default_name_len = len ; } - strcpy (default_name, scope_name); + *((char *) memcpy(default_name, scope_name, len) + len) = '\0'; message_mgr().set_max_length(default_name_len); scope_name = message_mgr().get_string( (char*)UAS_String(CATGETS(Set_SearchScopeAgent, 2, @@ -1001,7 +1003,7 @@ SearchScopeAgent::rename_scope() // Make sure old scope name preference isn't saved by NULLing out // it's value. This should really happen in a ScopeListMgr object. DJB char scratch[64]; - sprintf (scratch, "Scope.%s", f_current_scope->name()); + snprintf (scratch, sizeof(scratch), "Scope.%s", f_current_scope->name()); StringPref (scratch).value (""); f_current_scope->set_name (name); f_scope_list.save(); @@ -1319,7 +1321,7 @@ SearchScopeAgent::bookcase_list (BitHandle handle) // Iterate over the infolibs looking for selected entries. assert (handle != 0); - for (infolib = 0; infolib < ol->length(); infolib++) + for (infolib = 0; infolib < (int) ol->length(); infolib++) { // // See if the infolib is selected. @@ -1329,7 +1331,7 @@ SearchScopeAgent::bookcase_list (BitHandle handle) if (oe->is_selected (handle)) { // get all bookcases and append them to the selected list - for (bookcase = 0; bookcase < bclist->length(); bookcase++) + for (bookcase = 0; bookcase < (int) bclist->length(); bookcase++) { oe = ((OutlineElement *)(*bclist)[bookcase]); common = ((TOC_Element*)oe)->toc(); @@ -1350,7 +1352,7 @@ SearchScopeAgent::bookcase_list (BitHandle handle) // Get children of the infolib. // If the bookcase is selected, create a BookcaseEntry and // append it to the list. - for (bookcase = 0; bookcase < bclist->length(); bookcase++) + for (bookcase = 0; bookcase < (int) bclist->length(); bookcase++) { oe = ((OutlineElement *)(*bclist)[bookcase]); if (oe->is_selected (handle)) @@ -1378,7 +1380,7 @@ SearchScopeAgent::bookcase_list (BitHandle handle) // List *books = oe->children(); // (1-based book, since that's how they're indexed in Fulcrum.) - for (int book_num = 1; book_num <= books->length(); book_num++) + for (int book_num = 1; book_num <= (int)books->length(); book_num++) { ON_DEBUG (printf ("Checking Book #%d: ", book_num)); if (((OutlineElement*)(*books)[book_num-1])->is_selected (handle)) @@ -1422,12 +1424,12 @@ SearchScopeAgent::bookcase_list() OutlineList *ol = f_infolib_list->list(); OutlineElement *oe; - for (int i = 0; i < ol->length(); i++) + for (unsigned int i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); UAS_List kids = infolib->children(); - for (int j = 0; j < kids.length(); j++) + for (unsigned int j = 0; j < kids.length(); j++) { if (kids[j]->type() == UAS_BOOKCASE) { @@ -1457,7 +1459,7 @@ SearchScopeAgent::bookcase_list(UAS_String &lid) UAS_BookcaseEntry *bce; UAS_List kids = infolib->children(); - for (int j = 0; j < kids.length(); j++) + for (unsigned int j = 0; j < kids.length(); j++) { if (kids[j]->type() == UAS_BOOKCASE) { @@ -1585,7 +1587,7 @@ SearchScopeAgent::delete_scope() // Make sure old scope name preference isn't saved by NULLing out // it's value. This should really happen in a ScopeListMgr object. DJB char scratch[64]; - sprintf (scratch, "Scope.%s", scope->name()); + snprintf (scratch, sizeof(scratch), "Scope.%s", scope->name()); StringPref (scratch).value (""); delete scope; @@ -1598,16 +1600,14 @@ void SearchScopeAgent::add_infolib(UAS_Pointer &lib) { // get infolib list and append new infolib to the list - char scratch[256]; OutlineList *ol = f_infolib_list->list(); OutlineElement *oe; - int infolib_num; - + UAS_String temp_lid; // See if infolib is already in list--if it's there, // don't add it again. - int i; + unsigned int i; for (i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); @@ -1635,8 +1635,6 @@ SearchScopeAgent::add_infolib(UAS_Pointer &lib) break; } - infolib_num = i; // next insertion point in list - // Create search scope for new infolib UAS_String newLib_lid(newLib->lid()); UAS_SearchScope *scope = create_infolib_scope(newLib_lid); @@ -1671,7 +1669,6 @@ SearchScopeAgent::remove_infolib(UAS_Pointer &lib) { // get infolib list and remove infolib from the list OutlineList *ol = f_infolib_list->list(); - OutlineElement *oe; int infolib_num; // Get index of infolib in infobase list @@ -1687,7 +1684,7 @@ SearchScopeAgent::remove_infolib(UAS_Pointer &lib) BitHandle handle = f_infolib_list->data_handle(); f_infolib_list->clear(); - int i; + unsigned int i; for (i = 0; i < ol->length(); i ++) ((OutlineElement *) (*ol)[i])->set_expanded (handle); @@ -1710,7 +1707,7 @@ SearchScopeAgent::remove_infolib(UAS_Pointer &lib) break; } char scratch[128]; - sprintf(scratch, "Infolib %s", (char *)kids[i]->id()); + snprintf(scratch, sizeof(scratch), "Infolib %s", (char *)kids[i]->id()); #endif // remove search scope associated with infolib @@ -1725,7 +1722,7 @@ SearchScopeAgent::remove_infolib(UAS_Pointer &lib) // it's value. This should really happen in a ScopeListMgr // object. DJB char scratch[128]; - sprintf (scratch, "Scope.%s", scope->name()); + snprintf (scratch, sizeof(scratch), "Scope.%s", scope->name()); StringPref (scratch).value (""); #endif @@ -1766,7 +1763,6 @@ SearchScopeAgent::update_current_scope() WidgetList kids; Cardinal num_kids; UAS_SearchScope* scope; - UAS_SearchScope* current_scope=NULL; n = 0; XtSetArg(args[n], XmNnumChildren, &num_kids); n++; @@ -1775,7 +1771,7 @@ SearchScopeAgent::update_current_scope() if(f_current_scope != NULL) { - for (int i = 1; i < num_kids; i++) + for (unsigned int i = 1; i < num_kids; i++) { WXmPushButton btn (kids[i]); scope = (UAS_SearchScope*)btn.UserData(); @@ -1869,7 +1865,7 @@ SearchScopeAgent::update_option_menu(UAS_String &scope_name) // destroy all toggle buttons in menu except // the unnamed button. - for (int i = 1; i < num_kids; i++) + for (unsigned int i = 1; i < num_kids; i++) { XtUnmanageChild (kids[i]); XtDestroyWidget (kids[i]); @@ -1945,7 +1941,7 @@ SearchScopeAgent::list() OutlineList *ol = f_infolib_list->list(); OutlineElement *oe; - for (int i = 0; i < ol->length(); i++) + for (unsigned int i = 0; i < ol->length(); i++) { oe = ((OutlineElement *) (*ol)[i]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); @@ -1971,7 +1967,7 @@ SearchScopeAgent::list(UAS_String &lid) // get infolibs children--only save bookcases UAS_List kids = infolib->children(); - for (int i = 0; i < kids.length(); i++) + for (unsigned int i = 0; i < kids.length(); i++) if (kids[i]->type() == UAS_BOOKCASE) rval.insert_item(kids[i]); return rval; @@ -2009,7 +2005,7 @@ SearchScopeAgent::create_infolib_scope(UAS_String &lid) // entry for each one. // UAS_List kids = list(lid); - for (int i = 0; i < kids.length(); i++) + for (unsigned int i = 0; i < kids.length(); i++) { bce = new UAS_BookcaseEntry(kids[i]); bcases.append(bce); @@ -2017,7 +2013,8 @@ SearchScopeAgent::create_infolib_scope(UAS_String &lid) #ifdef EAM char scratch[128]; - sprintf(scratch, "Infolib %s", (char *)kids[first_base_num]->id()); + snprintf(scratch, sizeof(scratch), "Infolib %s", + (char *)kids[first_base_num]->id()); #endif // create search scope for infolib using the infolib name as @@ -2059,7 +2056,7 @@ SearchScopeAgent::bid_to_index(UAS_String &lid, UAS_String &bid) OutlineElement *oe = ((OutlineElement *) (*ol)[index]); UAS_Pointer infolib = ((TOC_Element *)oe)->toc(); UAS_List kids = infolib->children(); - for (int i = 0; i < kids.length(); i++) + for (unsigned int i = 0; i < kids.length(); i++) { if (kids[i]->bid() == bid) return i; @@ -2094,8 +2091,6 @@ SearchScopeAgent::get_search_scope(UAS_Pointer &infolib) xList &scopes = f_scope_list; List_Iterator iter (scopes); UAS_SearchScope *scope; - int scope_idx=0; - int maxScope=0; // max scope index iter++; // skip "Current Section" scope iter++; // skip "All Libraries" scope diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.hh index e663083c..681812f6 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeAgentMotif.hh @@ -125,17 +125,19 @@ private: // functions private: // variables + WTopLevelShell f_shell; SearchScopeList f_scope_list; + + bool f_first_time; + bool f_auto_expand; + QueryEditor *f_option_menu; + UAS_SearchScope *f_current_scope; - WTopLevelShell f_shell; WXmOptionMenu f_scope_option; WXmPushButton f_unnamed; OutlineListView *f_infolib_list; OutlineListView *f_component_list; WXmPushButton f_new, f_save, f_rename, f_delete, f_reset; - bool f_first_time; - bool f_auto_expand; - QueryEditor *f_option_menu; }; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeList.C b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeList.C index 455ea6a1..fffdfa29 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeList.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/SearchScopeList.C @@ -108,20 +108,23 @@ SimpleBuffer::~SimpleBuffer () void SimpleBuffer::write (char *new_data) { + int slen, len = 0; int new_len = 0; if (f_data) - new_len = strlen (f_data); + len = new_len = strlen (f_data); new_len += strlen (new_data); // manual realloc char *new_buf = new char [new_len + 1]; if (f_data) - (void) strcpy (new_buf, f_data); + *((char *) memcpy(new_buf, f_data, len) + len) = '\0'; else *new_buf = 0; delete [] f_data; f_data = new_buf; - (void) strcat (f_data, new_data); + slen = len; + len = strlen(new_data); + *((char *) memcpy(f_data + slen, new_data, len) + len) = '\0'; } char * @@ -159,7 +162,7 @@ SearchScopeList::save() buffer.reset(); // Store the scope component mask. - sprintf (scratch, "%d;", scope->search_zones().zones()); + snprintf (scratch, sizeof(scratch), "%d;", scope->search_zones().zones()); buffer.write (scratch, sizeof (char), strlen (scratch)); // get the list of bookcases for the current scope @@ -187,9 +190,9 @@ SearchScopeList::save() const char *name = bce->name(); const char *bid = bce->bid(); if (bc > 0) - sprintf (scratch, "&%s(%s)", bid, name); + snprintf (scratch, sizeof(scratch), "&%s(%s)", bid, name); else - sprintf (scratch, "%s(%s)", bid, name); + snprintf (scratch, sizeof(scratch), "%s(%s)", bid, name); buffer.write(scratch, sizeof (char), strlen(scratch)); if(env().debug()) @@ -204,7 +207,7 @@ SearchScopeList::save() { for (int bk = 0; bk < booklist.numItems(); bk++) { - sprintf (scratch, ",%d", booklist[bk]); + snprintf (scratch, sizeof(scratch), ",%d", booklist[bk]); buffer.write(scratch, sizeof (char), strlen(scratch)); } if(env().debug()) @@ -214,7 +217,7 @@ SearchScopeList::save() buffer.write ("\0", sizeof (char), 1); // Get the right preference object. - sprintf (scratch, "Scope.%s", scope->name()); + snprintf (scratch, sizeof(scratch), "Scope.%s", scope->name()); StringPref store (scratch); // Update its value. @@ -278,9 +281,7 @@ SearchScopeList::save() void SearchScopeList::restore() { - char scratch[1024]; - char basename[256]; - int i; + unsigned int i; UAS_SearchScope *s; // get the list of bookcase names @@ -352,13 +353,13 @@ SearchScopeList::create_named_scopes() } // retrieve scopes from preference file and validate each one - for (int sname = 0; sname < scope_names.length(); sname++) + for (int sname = 0; sname < (int) scope_names.length(); sname++) { is_scope_valid = True; // Get the specified scope from preferences. UAS_String ss = *(UAS_String*) scope_names[sname]; - sprintf (scratch, "Scope.%s", (char*)ss); + snprintf (scratch, sizeof(scratch), "Scope.%s", (char*)ss); StringPref scope (scratch); // Grab the component mask. @@ -389,7 +390,7 @@ SearchScopeList::create_named_scopes() // loop once for each bookcase in search scope. create a // bookcase entry for each valid bookcase. if bookcase // is invalid, invalidate the scope. - for (int bname = 0; bname < bookcases.length(); bname++) + for (int bname = 0; bname < (int) bookcases.length(); bname++) { UAS_String str = *(UAS_String*)bookcases[bname]; UAS_Listbc_list = str.splitFields (','); @@ -410,14 +411,13 @@ SearchScopeList::create_named_scopes() UAS_String sn = *(UAS_String*)scope_names[sname]; if(is_scope_valid) { - UAS_SearchScope *s = f_search_scope_agent->create_scope ( - sn, bookcase_list, mask, False); + f_search_scope_agent->create_scope (sn, bookcase_list, mask, False); } else { // rtp - 4/24/95 : otherwise store its name for use later; // see SearchScopeList::save routine above - sprintf(scratch, "%s%s", (char*)sn, ","); + snprintf(scratch, sizeof(scratch), "%s%s", (char*)sn, ","); f_buffer->write (scratch); } // reset list for next turn @@ -433,10 +433,10 @@ SearchScopeList::validate_bookcase(UAS_String &bid) // validate bookcase id UAS_List libs = f_search_scope_agent->list(); - for (int i = 0; i < libs.length(); i++) + for (unsigned int i = 0; i < libs.length(); i++) { UAS_List kids = libs[i]->children(); - for (int j = 0; j < kids.length(); j++) + for (unsigned int j = 0; j < kids.length(); j++) { if(kids[j]->bid() == bid) { @@ -483,7 +483,7 @@ SearchScopeList::create_bcase_entry(UAS_List &bc_list) int book_num; UAS_ObjList booklist; - for (int book = 1; book < bc_list.length(); book++) + for (int book = 1; book < (int) bc_list.length(); book++) { UAS_String abook = *(UAS_String*)bc_list[book]; if(sscanf ((char*)abook, "%d", &book_num) == 1) diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.C index dccfa465..ede222c0 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.C @@ -114,6 +114,7 @@ UrlAgent::document( char *locator, Boolean new_window ) { int sts = ID_SUCCESS ; + int len, bufferlen; if( (locator == NULL) || ((locator != NULL) && ( *locator == '\0' )) ) @@ -136,9 +137,9 @@ UrlAgent::document( char *locator, // assume given a unique locator ID for the target. // construct a fully-qualified form and pass it on. - char *buffer = - new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create( buffer ) ; delete [] buffer; @@ -166,7 +167,8 @@ UrlAgent::document( char *locator, // (evil hack alert) g_scroll_to_locator = TRUE; - strcpy( g_top_locator, locator ) ; + len = MIN(strlen(locator), 4096 - 1); + *((char *) memcpy(g_top_locator, locator, len) + len) = '\0'; d->retrieve(); } @@ -208,7 +210,9 @@ CloseProgramCB( XtPointer client_data, XtPointer /*call_data*/) { +#if 0 AppPrintData * p = (AppPrintData *) client_data ; +#endif /* we want to wait for the current job to complete before exiting */ // If a job is running, just unmap the windows and install itself @@ -235,6 +239,7 @@ int UrlAgent::print_document(char *locator) { int sts = ID_SUCCESS ; + int bufferlen; // set up for printing AppPrintData* p = window_system().GetAppPrintData(); @@ -263,9 +268,9 @@ UrlAgent::print_document(char *locator) // assume given a unique locator ID for the target. // construct a fully-qualified form and pass it on. - char *buffer = - new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create( buffer ) ; delete [] buffer; diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.hh b/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.hh index c725f643..4dc8693f 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.hh +++ b/cde/programs/dtinfo/dtinfo/src/Agents/UrlAgentMotif.hh @@ -12,7 +12,7 @@ class UrlAgent: public WWL { // Constructors, Destructor public: UrlAgent (); - ~UrlAgent (); + virtual ~UrlAgent (); // Public Member Functions public: diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/Atomizer.C b/cde/programs/dtinfo/dtinfo/src/Basic/Atomizer.C index 501b4fde..344f675c 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/Atomizer.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/Atomizer.C @@ -60,8 +60,9 @@ class PoolString : public FolioObject public: // functions PoolString (const char *string) { - f_string = new char[strlen(string) + 1]; - strcpy (f_string, string); + int len = strlen(string); + f_string = new char[len + 1]; + *((char *) memcpy(f_string, string, len) + len) = '\0'; } ~PoolString () @@ -81,7 +82,7 @@ public: // variables Atomizer::Atomizer (const char *string) { // Try to find the string in the pool of strings - register int i; + register unsigned int i; for (i = 0; i < f_pool.length(); i++) if (((PoolString *)f_pool[i])->equals (string)) diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C b/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C index 635b430e..5980e88d 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C @@ -93,7 +93,7 @@ BitField::BitField(unsigned long initial_bits) f_bits_in_use = new unsigned long [ f_num_words ] ; // zero bit arrays - for (int i = 0 ; i < f_num_words; i++){ + for (unsigned int i = 0 ; i < f_num_words; i++){ f_words[i] = 0 ; } // reserve first (0) bit @@ -115,7 +115,7 @@ BitField::check_allocation (unsigned long word) unsigned long *new_words = new unsigned long [word + 1]; unsigned long *new_use = new unsigned long [word + 1]; - int i; + unsigned int i; for (i = 0 ; i < f_num_words ; i++) { // copy old info @@ -146,7 +146,7 @@ BitField::get_handle() // find first free bit // first find first free word - int word; + unsigned int word; for (word = 0 ; word < f_num_words ; word++ ) if ( word_has_zero_bit(f_bits_in_use[word]) ) break; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/Buffer.C b/cde/programs/dtinfo/dtinfo/src/Basic/Buffer.C index e244db73..ad8d5b22 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/Buffer.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/Buffer.C @@ -145,7 +145,7 @@ Buffer::write (const int integer) // Convert bytes from native to MSB first ordering. g_int = 0; - for (int i = 0; i < sizeof (int); i++) + for (unsigned int i = 0; i < sizeof (int); i++) if (g_byte_pos[i] != 0) g_intbuf[g_byte_pos[i]-1] = inbuf[i]; @@ -158,7 +158,7 @@ Buffer::read (int *integer) *integer = 0; // Convert from MSB first ordering to native. - for (int i = 0; i < sizeof (int); i++) + for (unsigned int i = 0; i < sizeof (int); i++) if (g_byte_pos[i] != 0) ((char *) integer)[i] = f_point[g_byte_pos[i]-1]; @@ -217,7 +217,7 @@ Buffer::write (const char *bytes, u_int size, u_int length) ON_DEBUG(printf ("Writing %d bytes to buffer @ %p\n", size * length, f_point)); int num_bytes = size * length; check_space (num_bytes); - for (int i = 0; i < size * length; i++) + for (unsigned int i = 0; i < size * length; i++) ON_DEBUG(printf ("%02X ", (unsigned char) bytes[i])); ON_DEBUG(printf ("\n")); memcpy (f_point, bytes, num_bytes); @@ -232,7 +232,7 @@ Buffer::read (char **bytes, u_int size, u_int length) ON_DEBUG(printf ("Reading %d bytes from buffer @ %p\n", num_bytes, f_point)); assert (f_point + num_bytes <= f_end_of_data); *bytes = f_point; - for (int i = 0; i < size * length; i++) + for (unsigned int i = 0; i < size * length; i++) ON_DEBUG(printf ("%02X ", (unsigned int) (*bytes)[i])); ON_DEBUG(printf ("\n")); f_point += num_bytes; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/FString.C b/cde/programs/dtinfo/dtinfo/src/Basic/FString.C index a646a5eb..b6fc088d 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/FString.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/FString.C @@ -57,13 +57,14 @@ extern "C" { extern size_t strlen(const char *); - extern char *strcpy(char *, const char *); + extern void* memcpy(void *dst, const void *src, size_t len); } FString::FString(const char *string) { - f_string = new char[ strlen (string) + 1 ] ; - strcpy(f_string, string); + int len = strlen(string); + f_string = new char[ len + 1 ] ; + *((char *) memcpy(f_string, string, len) + len) = '\0'; } FString::~FString() diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/FolioObject.C b/cde/programs/dtinfo/dtinfo/src/Basic/FolioObject.C index 3b2e6ed6..411c0231 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/FolioObject.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/FolioObject.C @@ -67,13 +67,13 @@ public: f_handler (handler), f_notify_type (notify_type), f_dependent_data (dependent_data) { if (next) next->f_pre_next = &f_next; } + Dependent **f_pre_next; + Dependent *f_next; FolioObject *f_dependent; FolioObject *f_folio_object; notify_handler_t f_handler; u_int f_notify_type; void *f_dependent_data; - Dependent **f_pre_next; - Dependent *f_next; void release(); void call (FolioObject *obj, void *notify_data); }; @@ -101,8 +101,8 @@ public: : f_next (next), f_dependent_obj (d) { } void delete_dependent(); - Dependent *f_dependent_obj; DependOnList *f_next; + Dependent *f_dependent_obj; }; inline void diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/HashTable.C b/cde/programs/dtinfo/dtinfo/src/Basic/HashTable.C index 08e90704..08952013 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/HashTable.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/HashTable.C @@ -77,8 +77,9 @@ HashObject::HashObject(const char *key, FolioObject *object) assert(key != NULL); assert(object != NULL); - f_key = new char[strlen(key) + 1] ; - strcpy(f_key, key); + int len = strlen(key); + f_key = new char[len + 1] ; + *((char *) memcpy(f_key, key, len) + len) = '\0'; } HashObject::~HashObject() diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/HashTbl.C b/cde/programs/dtinfo/dtinfo/src/Basic/HashTbl.C index b1e81ed7..c5060944 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/HashTbl.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/HashTbl.C @@ -182,7 +182,7 @@ HashTbl::remove (const Hashable &element) void HashTbl::remove_all (bool delete_elements) { - for (int i = 0; i < f_num_buckets; i++) + for (unsigned int i = 0; i < f_num_buckets; i++) if (f_hash_bucket[i] != NULL) { if (delete_elements) diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/List.C b/cde/programs/dtinfo/dtinfo/src/Basic/List.C index 5243f23e..279d6d44 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/List.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/List.C @@ -194,7 +194,7 @@ List::insert (unsigned int location, FolioObject *element) abort(); // Shift the array forward to make room for new insertion. - for (int i = f_length; i > location; i--) + for (unsigned int i = f_length; i > location; i--) f_list_element[i] = f_list_element[i-1]; // Insert the new element in the list. @@ -233,7 +233,7 @@ List::copy() const // NOTE: use length() instead of f_length because it may be more general List *retlist = new List(length()); - for (int i = 0 ; i < length(); i++) + for (unsigned int i = 0 ; i < length(); i++) retlist->append((*this)[i]); return retlist ; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/NodeID.hh b/cde/programs/dtinfo/dtinfo/src/Basic/NodeID.hh index a99e196e..f0c37c75 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/NodeID.hh +++ b/cde/programs/dtinfo/dtinfo/src/Basic/NodeID.hh @@ -37,8 +37,9 @@ class NodeID { inline NodeID::NodeID(const char *filename) { - f_filename = new char[strlen(filename) + 1] ; - strcpy(f_filename, filename); + int len = strlen(filename); + f_filename = new char[len + 1] ; + *((char *) memcpy(f_filename, filename, len) + len) = '\0'; } inline diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/NodeViewInfo.C b/cde/programs/dtinfo/dtinfo/src/Basic/NodeViewInfo.C index ef417d7f..535782b9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/NodeViewInfo.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/NodeViewInfo.C @@ -374,7 +374,7 @@ chop_segment(_DtCvSegment* seg, unsigned int nc) if (widec) { wchar_t* src = (wchar_t*)seg->handle.string.string + nc; wchar_t* dest = new wchar_t[seg_nc - nc + 1]; - for (int i = 0; i < seg_nc - nc; i++) + for (unsigned int i = 0; i < seg_nc - nc; i++) dest[i] = src[i]; dest[seg_nc - nc] = '\0'; nseg_str = (void*)dest; @@ -385,7 +385,7 @@ chop_segment(_DtCvSegment* seg, unsigned int nc) else { char* src = (char*)seg->handle.string.string + nc; char* dest = new char[seg_nc - nc + 1]; - for (int i = 0; i < seg_nc - nc; i++) + for (unsigned int i = 0; i < seg_nc - nc; i++) dest[i] = src[i]; dest[seg_nc - nc] = '\0'; nseg_str = (void*)dest; @@ -510,21 +510,23 @@ highlight_search_hit(_DtCvSegment* seg, unsigned int vcc, unsigned int len) if (widec) { wchar_t* src = (wchar_t*)sibling->handle.string.string; wchar_t* dst = (wchar_t*)seg->handle.string.string; - int len = wcslen(dst) + wcslen(src); + int slen = wcslen(dst); + int len = wcslen(src); seg->handle.string.string = (void*) realloc(seg->handle.string.string, - sizeof(wchar_t) * (len + 1)); + sizeof(wchar_t) * (slen + len + 1)); dst = (wchar_t*)seg->handle.string.string; - wcscat(dst, src); + *((char *) memcpy(dst + slen, src, len) + len) = '\0'; } else { char* src = (char*)sibling->handle.string.string; char* dst = (char*)seg->handle.string.string; - int len = strlen(dst) + strlen(dst); + int slen = strlen(dst); + int len = strlen(src); seg->handle.string.string = (void*) - realloc(seg->handle.string.string, len + 1); + realloc(seg->handle.string.string, slen + len + 1); dst = (char*)seg->handle.string.string; - strcat(dst, src); + *((char *) memcpy(dst + slen, src, len) + len) = '\0'; } DtCvStrVcLenSync(seg); @@ -596,7 +598,7 @@ traverse_for_vcc(_DtCvSegment* seg, unsigned int vcc) else if (seg_ptype == _DtCvTABLE) { _DtCvSegment** cell = seg->handle.table.cells; for (; *cell; cell++) { - if (therein = traverse_for_vcc(*cell, vcc)) + if ((therein = traverse_for_vcc(*cell, vcc))) break; } } @@ -709,7 +711,7 @@ NodeViewInfo::set_search_hits(UAS_Pointer >& hits) assert( (seg->type & _DtCvPRIMARY_MASK) == _DtCvSTRING ); - if (seg = highlight_search_hit(seg, hit->offset(), hit->length())) { + if ((seg = highlight_search_hit(seg, hit->offset(), hit->length()))) { #ifdef DEBUG fprintf(stderr, "(DEBUG) highlight_search_hit succeeded, " "offset=%d\n", hit->offset()); diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/OString.C b/cde/programs/dtinfo/dtinfo/src/Basic/OString.C index 0dbd8d16..a1f1bb53 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/OString.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/OString.C @@ -54,8 +54,9 @@ OString::string (const char *s, copy_t copy) if (s != NULL && copy == COPY) { - f_string = new char [strlen(s) + 1]; - strcpy ((char *) f_string, (char *) s); + int len = strlen(s); + f_string = new char [len + 1]; + *((char *) memcpy((char *)f_string, (char *)s, len) + len) = '\0'; f_delete_string = TRUE; } else diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/OrderList.C b/cde/programs/dtinfo/dtinfo/src/Basic/OrderList.C index f9880051..14abe5db 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/OrderList.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/OrderList.C @@ -66,8 +66,6 @@ OrderList::clear() int OrderList::add(ListEntry *node, AddCode where, bool mvcursor) { - int status = OLIST_OK; - if (node != NULL) { if (f_cursor == NULL) insertNew(node); @@ -149,26 +147,26 @@ ListEntry * OrderList::extract() { ListEntry *node; - int status = OLIST_OK; +// int status = OLIST_OK; node = f_cursor; if ((node == f_head) && (node == f_tail)) { f_head = NULL; f_cursor = NULL; f_tail = NULL; - status = OLIST_LAST_REMOVD; +// status = OLIST_LAST_REMOVD; } else if (node == f_head) { f_head = node->f_next; f_cursor = node->f_next; f_cursor->f_prev = NULL; - status = OLIST_HEAD_REMOVD; +// status = OLIST_HEAD_REMOVD; } else if (node == f_tail) { f_tail = node->f_prev; f_cursor = node->f_prev; f_cursor->f_next = NULL; - status = OLIST_TAIL_REMOVD; +// status = OLIST_TAIL_REMOVD; } else { node->f_prev->f_next = node->f_next; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineElement.hh b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineElement.hh index e5877085..e2bdc12e 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineElement.hh +++ b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineElement.hh @@ -117,7 +117,6 @@ protected: // functions protected: // variables OutlineList *f_children; // Each outline element may have a list of children - unsigned char f_level; // Level this element is at, zero-based BitField f_selected ; BitField f_expanded ; @@ -130,6 +129,7 @@ protected: // variables u_int f_string_creator; unsigned char f_display_flag; // Able to be displayed on activate [rtp] + unsigned char f_level; // Level this element is at, zero-based }; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineList.C b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineList.C index c26fb52f..76ba9cd9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineList.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineList.C @@ -98,7 +98,7 @@ OutlineList::count_expanded (BitHandle data_handle) void OutlineList::copy_selected(BitHandle src, BitHandle dest) { - for (int i = 0 ; i < length(); i++) + for (unsigned int i = 0 ; i < length(); i++) { if (OUTLINE_ELEMENT(i)->is_selected(src)) OUTLINE_ELEMENT(i)->set_selected(dest) ; @@ -119,7 +119,7 @@ OutlineList::copy_selected(BitHandle src, BitHandle dest) void OutlineList::copy_expanded (BitHandle src, BitHandle dest) { - for (int i = 0 ; i < length(); i++) + for (unsigned int i = 0 ; i < length(); i++) { if (OUTLINE_ELEMENT(i)->is_expanded (src)) OUTLINE_ELEMENT(i)->set_expanded (dest); @@ -140,7 +140,7 @@ OutlineList::copy_expanded (BitHandle src, BitHandle dest) void OutlineList::recursive_select(BitHandle data_handle) { - for (int i = 0 ; i < length() ; i++ ) + for (unsigned int i = 0 ; i < length() ; i++ ) if (OUTLINE_ELEMENT(i)->children_cached() && OUTLINE_ELEMENT(i)->has_children()) { @@ -159,7 +159,7 @@ OutlineList::recursive_select(BitHandle data_handle) void OutlineList::select_all(BitHandle data_handle) { - for (int i = 0 ; i < length(); i++) + for (unsigned int i = 0 ; i < length(); i++) { OUTLINE_ELEMENT(i)->set_selected(data_handle); if (OUTLINE_ELEMENT(i)->children_cached() && @@ -177,7 +177,7 @@ OutlineList::select_all(BitHandle data_handle) void OutlineList::deselect_all(BitHandle data_handle) { - for (int i = 0 ; i < length(); i++) + for (unsigned int i = 0 ; i < length(); i++) { OUTLINE_ELEMENT(i)->unset_selected(data_handle); if (OUTLINE_ELEMENT(i)->children_cached() && @@ -231,7 +231,7 @@ OutlineList::selected_items (BitHandle data_handle, List *l) if (l == NULL) l = new List (8, 8, List::GROW_MULTIPLY); - for (int i = 0; i < length(); i++) + for (unsigned int i = 0; i < length(); i++) { if (OUTLINE_ELEMENT(i)->is_selected (data_handle)) l->append (OUTLINE_ELEMENT(i)); diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineString.hh b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineString.hh index 0217a54a..cc064cdd 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/OutlineString.hh +++ b/cde/programs/dtinfo/dtinfo/src/Basic/OutlineString.hh @@ -34,8 +34,9 @@ public: // functions { if (string != NULL) { - f_string = new char [strlen(string) + 1]; - strcpy (f_string, string); + int len = strlen(string); + f_string = new char [len + 1]; + *((char *) memcpy(f_string, string, len) + len) = '\0'; } else f_string = NULL; diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/ParseTree.C b/cde/programs/dtinfo/dtinfo/src/Basic/ParseTree.C index 656d5fe2..a7911240 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/ParseTree.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/ParseTree.C @@ -113,8 +113,9 @@ PText::PText (PNode *parent, PNode *previous, PNode *next, char *str) else f_symbol_space = f_symbol_len; - f_symbol = (char *) malloc (sizeof(char) * (f_symbol_space + 1)); - strcpy (f_symbol, str); + int len = sizeof(char) * f_symbol_space; + f_symbol = (char *) malloc (len + sizeof(char)); + *((char *) memcpy(f_symbol, str, len) + len) = '\0'; } diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/StringHash.C b/cde/programs/dtinfo/dtinfo/src/Basic/StringHash.C index d0bc7265..2566873e 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/StringHash.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/StringHash.C @@ -79,8 +79,9 @@ string_hash (const char *key) register u_int pos, sum = 0; register char c; - for (pos = 0; c = *key++; pos++) - sum = (sum << 5) + (sum >> (sizeof(int) * 8 - 6)) + (c ^ lookup_table[c]); + for (pos = 0; (c = *key++); pos++) + sum = (sum << 5) + (sum >> (sizeof(int) * 8 - 6)) + + (c ^ lookup_table[(int)c]); // was: // sum = c ^ lookup_table [(pos * c) % 256]; diff --git a/cde/programs/dtinfo/dtinfo/src/Graphics/PixmapGraphic.C b/cde/programs/dtinfo/dtinfo/src/Graphics/PixmapGraphic.C index dc3183b7..24ebaded 100644 --- a/cde/programs/dtinfo/dtinfo/src/Graphics/PixmapGraphic.C +++ b/cde/programs/dtinfo/dtinfo/src/Graphics/PixmapGraphic.C @@ -80,11 +80,11 @@ PixmapGraphic::PixmapGraphic(Pixmap pixmap, Dimension width, Dimension height, f_width (width), f_height (height), f_flag (flag), + f_agent(0), f_colormap(0), f_num_colors(0), f_colors(NULL), - f_tiff_context(NULL), - f_agent(0) + f_tiff_context(NULL) { } diff --git a/cde/programs/dtinfo/dtinfo/src/Imakefile b/cde/programs/dtinfo/dtinfo/src/Imakefile index fd839ee4..b9dc5039 100644 --- a/cde/programs/dtinfo/dtinfo/src/Imakefile +++ b/cde/programs/dtinfo/dtinfo/src/Imakefile @@ -28,9 +28,9 @@ SUBDIRS=Widgets $(CLASSLIBS) Messages cgm XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' DependSubdirs($(SUBDIRS)) @@ -42,8 +42,10 @@ SYS_LIBRARIES=-lm -liconv /usr/lib/libpthreads.a -blibpath:/usr/dt/lib:/X11/lib: SYS_LIBRARIES=-lm -lfs #elif defined(HPArchitecture) SYS_LIBRARIES=$(DYNAMIC) -lm -#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) || defined(OpenBSDArchitecture) +#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) SYS_LIBRARIES=-lm -L$(XPROJECTROOT)/lib +#elif defined(OpenBSDArchitecture) +SYS_LIBRARIES=-lm -L$(XPROJECTROOT)/lib -L$(MPROJECTROOT)/lib #else SYS_LIBRARIES=-lm #endif @@ -311,7 +313,7 @@ all:: Prelude.h dfiles messages Dtinfo includes:: Prelude.h dfiles messages -#if defined(HPArchitecture) ||defined (AIXArchitecture) || defined(UXPArchitecture) || (defined(SunArchitecture) && CplusplusCompilerMajorVersion < 4) || defined(AlphaArchitecture) || defined(USLArchitecture) || defined(FreeBSDArchitecture) +#if defined(HPArchitecture) ||defined (AIXArchitecture) || defined(UXPArchitecture) || (defined(SunArchitecture) && CplusplusCompilerMajorVersion < 4) || defined(AlphaArchitecture) || defined(USLArchitecture) || defined(FreeBSDArchitecture) || defined(OpenBSDArchitecture) # ifndef Dont_Use_Templates_Repository # define Dont_Use_Templates_Repository UAS_INCLUDES=-I./UAS/Base @@ -336,7 +338,7 @@ SpecialCPlusPlusObjectRule(Templates.o,,-ptf $(SUBDIR_TEMPL_INCLUDES)) SpecialCPlusPlusExpandRule(Templates..c,,-ptf -DMakeOperatorNewPublic) #elif defined(DoLicenseManagement) SpecialCPlusPlusObjectRule(Templates.o,,-ptf $(LICENSE_L_INCLUDES)) -#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) +#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) || defined(OpenBSDArchitecture) SpecialCPlusPlusObjectRule(Templates.o,,$(SUBDIR_TEMPL_INCLUDES)) SpecialCPlusPlusExpandRule(Templates..c,,-DMakeOperatorNewPublic) #else diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/CatMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/CatMgr.C index 30825dd6..5bfc693f 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/CatMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/CatMgr.C @@ -44,6 +44,8 @@ CatMgr* CatMgr::f_msg_catalog_mgr = NULL; CatMgr::CatMgr() : f_msg(NULL), f_default(NULL) { + int len; + #ifdef DEBUG char* nlspath = getenv("NLSPATH"); if (nlspath) @@ -61,8 +63,9 @@ CatMgr::CatMgr() : f_msg(NULL), f_default(NULL) #endif char* msg = ::catgets(f_catd, Set_CatMgr, DEFAULT_MSG, "default message not found."); - f_default = new char[strlen(msg) + 1]; - strcpy(f_default, msg); + len = strlen(msg); + f_default = new char[len + 1]; + *((char *) memcpy(f_default, msg, len) + len) = '\0'; } else { #ifdef DEBUG @@ -71,8 +74,9 @@ CatMgr::CatMgr() : f_msg(NULL), f_default(NULL) #else static char* cat_not_found = (char*)""; #endif - f_default = new char[strlen(cat_not_found) + 1]; - strcpy(f_default, cat_not_found); + len = strlen(cat_not_found); + f_default = new char[len + 1]; + *((char *) memcpy(f_default, cat_not_found, len) + len) = '\0'; } #ifdef DEBUG cerr << "(DEBUG) default msg=" << f_default << '\n' << flush; @@ -91,15 +95,17 @@ CatMgr::~CatMgr() if (is_open(f_catd)) { int status = catclose(f_catd); -#ifdef DEBUG if (status < 0) { +#ifdef DEBUG cerr << "(ERROR) catclose failed." << '\n' << flush; abort(); +#endif } else { +#ifdef DEBUG cerr << "(DEBUG) catclose succeeded" << '\n' << flush; - } #endif + } } #ifdef DEBUG else { @@ -111,6 +117,8 @@ CatMgr::~CatMgr() char* CatMgr::catgets(int set_num, int msg_num, const char* def) { + int len; + if (f_msg) delete[] f_msg; @@ -126,6 +134,7 @@ CatMgr::catgets(int set_num, int msg_num, const char* def) for (; *msg == ' ' || *msg == '\t'; msg++); #endif int msglen = strlen(msg); + len = msglen; f_msg = new char[msglen + 1]; #if defined(UXPDS) && defined(GENCAT_BUG) #ifdef DEBUG @@ -144,16 +153,18 @@ CatMgr::catgets(int set_num, int msg_num, const char* def) msglen--; } #endif - strcpy(f_msg, msg); + *((char *) memcpy(f_msg, msg, len) + len) = '\0'; } else { if (def) { - f_msg = new char[strlen(def) + 1]; - strcpy(f_msg, def); + len = strlen(def); + f_msg = new char[len + 1]; + *((char *) memcpy(f_msg, def, len) + len) = '\0'; } else { - f_msg =new char[strlen(f_default) + 1]; - strcpy(f_msg, f_default); + len = strlen(f_default); + f_msg =new char[len + 1]; + *((char *) memcpy(f_msg, f_default, len) + len) = '\0'; } } diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/EnvMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/EnvMgr.C index 48692628..95bf699a 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/EnvMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/EnvMgr.C @@ -75,6 +75,8 @@ using namespace std; #include "Managers/CatMgr.hh" #include "Prelude.h" +#include "utility/funcs.h" +#undef debug LONG_LIVED_CC(EnvMgr, env); @@ -87,8 +89,8 @@ bool g_debug; #define SLSEP ',' -EnvMgr::EnvMgr() : f_argv(NULL), - f_argc(0), +EnvMgr::EnvMgr() : f_argc(0), + f_argv(NULL), f_lang(NULL), f_secondary(False), f_verbose(False), @@ -116,7 +118,7 @@ EnvMgr::EnvMgr() : f_argv(NULL), #ifdef LCX_DEBUG fprintf(stderr, "(DEBUG) standard locale=\"%s\"\n", std_locale); #endif - f_lang = XtNewString(std_locale); + f_lang = XtsNewString(std_locale); free(std_locale); } } @@ -127,18 +129,18 @@ EnvMgr::EnvMgr() : f_argv(NULL), // If OpToStd conversion failed, use non-std name if (f_lang == NULL) - f_lang = XtNewString(lang); + f_lang = XtsNewString(lang); // tell mmdb info_lib to load info_base only if it matches to f_lang static char mmdb_lang[_POSIX_PATH_MAX]; - sprintf(mmdb_lang, "MMDB_LANG=%s", f_lang); + snprintf(mmdb_lang, _POSIX_PATH_MAX, "MMDB_LANG=%s", f_lang); putenv (mmdb_lang); - f_home = XtNewString( getenv("HOME") ); + f_home = XtsNewString( getenv("HOME") ); char dirname[256]; - sprintf (dirname, "%s/.dt/dtinfo/%s", f_home, f_lang); - f_user_path = XtNewString(dirname); + snprintf (dirname, sizeof(dirname), "%s/.dt/dtinfo/%s", f_home, f_lang); + f_user_path = XtsNewString(dirname); // if $HOME/.dt/dtinfo/$LANG does not exist, create it, @@ -146,7 +148,7 @@ EnvMgr::EnvMgr() : f_argv(NULL), if(!check_user_path()) { create_user_path(); - help_agent().display_help ((char*)"doc_list_help"); +// help_agent().display_help ((char*)"doc_list_help"); } UAS_Collection::request( @@ -218,14 +220,15 @@ EnvMgr::init(int argc_i, char** argv_i) { // link up indirect paths to mmdb code... ;-) static char buffer[256]; - sprintf (buffer, "MMDB_PATH=%s", (char *)f_infolibsStr ); + snprintf (buffer, sizeof(buffer), "MMDB_PATH=%s", (char *)f_infolibsStr ); putenv (buffer); char *where = getenv ("DTINFO_MARKSPECPATH"); if (where == NULL) { static char markref[256]; - sprintf (markref, "DTINFO_MARKSPECPATH=%s", "/usr/dt/infolib/etc" ); + snprintf (markref, sizeof(markref), "DTINFO_MARKSPECPATH=%s", + "/usr/dt/infolib/etc" ); putenv (markref); } } @@ -868,21 +871,21 @@ EnvMgr::arglist() f_argv = (char **)XtMalloc( p_argc*sizeof(char *) ) ; int ia = 0 ; - f_argv[ia++] = XtNewString( "dtinfo" ) ; + f_argv[ia++] = XtsNewString( "dtinfo" ) ; if( secondary() ) { - f_argv[ia++] = XtNewString( "-secondary" ) ; + f_argv[ia++] = XtsNewString( "-secondary" ) ; } - f_argv[ia++] = XtNewString( "-l" ) ; + f_argv[ia++] = XtsNewString( "-l" ) ; tmp = (char *)(infolibsArg()) ; - f_argv[ia++] = XtNewString( tmp ) ; + f_argv[ia++] = XtsNewString( tmp ) ; // always insert the -sect key and its arg, even if the arg // is zero length. This saves us from any re-malloc and copy. - f_argv[ia++] = XtNewString( "-sect" ) ; + f_argv[ia++] = XtsNewString( "-sect" ) ; tmp = (char *)(sectionsArg()) ; // can be empty here - f_argv[ia++] = XtNewString( tmp ) ; + f_argv[ia++] = XtsNewString( tmp ) ; f_argc = p_argc ; } @@ -897,14 +900,14 @@ EnvMgr::arglist() { XtFree( f_argv[++i] ) ; tmp = (char *)(infolibsArg()) ; - f_argv[i] = XtNewString( tmp ) ; + f_argv[i] = XtsNewString( tmp ) ; il = i ; } else if( strcmp(f_argv[i], "-sect") == 0 ) { XtFree( f_argv[++i] ) ; tmp = (char *)(sectionsArg()) ; - f_argv[i] = XtNewString( tmp ) ; + f_argv[i] = XtsNewString( tmp ) ; is = i ; } } @@ -931,7 +934,8 @@ EnvMgr::mkdirs(char *pathname) { char buffer[256]; char *c; - strcpy(buffer, pathname); + int len = MIN(strlen(pathname), 256 - 1); + *((char *) memcpy(buffer, pathname, len) + len) = '\0'; if(mkdir(buffer, 0777) == -1) { diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.C index 00e7cb91..abb06f43 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.C @@ -305,7 +305,7 @@ GraphicsMgr::get_graphic (const UAS_String &imdata, printf( "Insufficient color cells for graphic. Retry with degraded colors.\n" ); #endif - _DtGrLoadStatus status = + status = _DtGrLoad(&gr_stream, // image &image_type, screen, @@ -412,7 +412,7 @@ GraphicsMgr::detach (UAS_Pointer &node_ptr, // ViewportAgent will actually remove it from display gr->set_detached(TRUE); - PixmapGraphic *pgraphic = gr->pixmap_graphic(); + //PixmapGraphic *pgraphic = gr->pixmap_graphic(); GraphicAgent *ga = new GraphicAgent(node_ptr, gr); //gr->set_agent(ga); diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.hh b/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.hh index a745f213..2c09fbfc 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.hh +++ b/cde/programs/dtinfo/dtinfo/src/Managers/GraphicsMgr.hh @@ -182,9 +182,9 @@ class Graphic: public UAS_Base { GraphicAgent *get_agent() { return fagent; } private: - unsigned int fDetached; PixmapGraphic * fPixmap; PixmapGraphic * fDetachedPixmap; + unsigned int fDetached; UAS_Pointer fObj; GraphicAgent *fagent; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/LibraryMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/LibraryMgr.C index 4815ede3..c1041da8 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/LibraryMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/LibraryMgr.C @@ -173,7 +173,7 @@ LibraryMgr::display (UAS_Pointer &toc) // First, check to see if the object to display is already // in our list. // - int i; + unsigned int i; for (i = 0; i < fObjList.length(); i ++) { if (fObjList[i] == toc) @@ -309,7 +309,7 @@ LibraryMgr::undisplay (OutlineElement *root) { UAS_Pointer rootDoc = ((TOC_Element *) root)->toc(); if (rootDoc->type() != UAS_LIBRARY) throw (CASTEXCEPT Exception()); - int i; + unsigned int i; for (i = 0; i < fObjList.length(); i ++) { if (fObjList[i] == rootDoc) { break; @@ -328,7 +328,7 @@ LibraryMgr::remove (UAS_Pointer lib) { for (; l; l++) { l.item()->library_removed (lib); } - for (int i = 0; i < fObjList.length(); i ++) { + for (unsigned int i = 0; i < fObjList.length(); i ++) { if (fObjList[i] == lib) { fObjList.remove_item(i); break; @@ -416,7 +416,7 @@ LibraryMgr::library() void LibraryMgr::init(UAS_List &infolibpaths) { - int i; + unsigned int i; UAS_Common::initialize(infolibpaths); @@ -450,7 +450,7 @@ LibraryMgr::init(UAS_List &infolibpaths) bool LibraryMgr::lib_exist(UAS_String& lid) { - for (int i = 0; i < fObjList.length(); i ++) { + for (unsigned int i = 0; i < fObjList.length(); i ++) { if (fObjList[i]->lid() == lid) return True; } diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/MarkMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/MarkMgr.C index 4006c60b..9e34e4c8 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/MarkMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/MarkMgr.C @@ -132,10 +132,10 @@ MarkMgr::MarkMgr() { // the marks directory needs to be in sync with mmdb (user_base.cc) buffer = new char[MAXPATHLEN]; - sprintf (buffer, "%s/marks/default", env().user_path()); + snprintf (buffer, MAXPATHLEN, "%s/marks/default", env().user_path()); #if EAM - sprintf (buffer, "%s/.dt/dtinfo/%s/marks/default", + snprintf (buffer, MAXPATHLEN, "%s/.dt/dtinfo/%s/marks/default", env().home(), env().lang()); #endif filename = buffer; @@ -249,7 +249,9 @@ MarkMgr::create_mark (UAS_Pointer &doc_ptr, const Anchor &anchor, char* trimmed_name; int size = strlen(name) + 1; int n = mbstowcs(new_name, name, size); - assert( n >= 0 ); + if( n >= 0 ) { + assert( n >= 0 ); + } while (*start != (wchar_t)'\0' && iswspace(*start)) start++; if (*start != (wchar_t)'\0') { diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/MessageMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/MessageMgr.C index 2b5d2467..3c6a9f98 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/MessageMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/MessageMgr.C @@ -210,7 +210,8 @@ MessageMgr::cancel_cb() void MessageMgr::show_it(Widget dialog) { - Widget parent, shell; + Widget parent = NULL; + Widget shell = NULL; XtManageChild(dialog); @@ -548,7 +549,7 @@ MessageMgr::assert_failed (char *statement, char *file, { char buffer[512]; - sprintf (buffer, + snprintf (buffer, sizeof(buffer), "An internal error has occured.\n\ The current operation cannot be completed.\n\ Please file a bug report with this information:\n\ diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/NodeMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/NodeMgr.C index 4b016466..bb48503f 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/NodeMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/NodeMgr.C @@ -316,13 +316,13 @@ NodeMgr::set_font_scale(int value) NodeViewInfo * NodeMgr::load(UAS_Pointer &node_ptr) { - static int first = 0; - extern int styleparse(); extern void stylerestart(FILE *); extern NodeViewInfo *gNodeViewInfo; #ifdef FILE_STYLE_SHEET + static int first = 0; + StyleSheet ss ; { extern istream *g_stylein; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/PrintMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/PrintMgr.C index 81929e7c..35a206c2 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/PrintMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/PrintMgr.C @@ -201,8 +201,6 @@ PrintMgr::set_font_scale(int value) NodeViewInfo * PrintMgr::load(UAS_Pointer &node_ptr) { - static int first = 0; - extern int styleparse(); extern void stylerestart(FILE *); extern NodeViewInfo *gNodeViewInfo; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.C index 8d2d88f6..7c00cb17 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.C @@ -142,7 +142,7 @@ SearchMgr::init() { UAS_List rootLocs = UAS_Common::rootLocators (); - int i; + unsigned int i; for (i = 0; i < rootLocs.length(); i ++) { UAS_Pointer theDoc = UAS_Common::create(*(UAS_String*)rootLocs[i]); @@ -308,8 +308,6 @@ SearchMgr::parse_and_search (char *query, UAS_SearchScope *scope) { void SearchMgr::display_message (SearchMessageType msg, int) { - char *msg_str; - switch( msg ){ case NO_HITS: message_mgr().info_dialog ( @@ -336,7 +334,7 @@ SearchMgr::current_hits() void SearchMgr::add_root(UAS_Pointer& root) { - int i; + unsigned int i; for (i = 0; i < f_roots.length(); i++) { if (f_roots[i] == root) break; @@ -352,7 +350,7 @@ SearchMgr::add_root(UAS_Pointer& root) void SearchMgr::remove_root(UAS_Pointer& root) { - int i; + unsigned int i; for (i = 0; i < f_roots.length(); i++) { if (f_roots[i] == root) break; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.hh b/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.hh index 781346d9..cee43e04 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.hh +++ b/cde/programs/dtinfo/dtinfo/src/Managers/SearchMgr.hh @@ -69,8 +69,8 @@ private: List *ibase_list(); protected: // variables - QueryEditor *f_query_editor; UAS_Pointer f_search_engine ; + QueryEditor *f_query_editor; HistoryList f_search_history_list; ListView *f_search_history_list_view; UAS_String f_search_section; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C b/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C index 411f4ffa..db5c2d5a 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C @@ -245,7 +245,7 @@ ServiceMgr::process_olias_event (Window client, return; unsigned char event_type = *stream++; - char *infobase; + int len, bufferlen; char *locator; // NOTE: make fixed width and add "mmdb:" to // front ? Should eventually go into calling // program to determine doc type. @@ -258,7 +258,6 @@ ServiceMgr::process_olias_event (Window client, // Skip over the defunct infobase name. // NOTE: It should be removed from the olias api. DJB - infobase = (char *) stream; while (*stream != '\0') stream++; stream++; @@ -273,14 +272,16 @@ ServiceMgr::process_olias_event (Window client, } else { - char *buffer = new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create (buffer); if (d != (const int)NULL) { // (evil hack alert) g_scroll_to_locator = TRUE; - strcpy (g_top_locator, locator); + len = MIN(strlen(locator), 4096 - 1); + *((char *) memcpy(g_top_locator, locator, len) + len) = '\0'; } delete [] buffer; } @@ -398,6 +399,7 @@ olias_send_event (Widget, OliasEvent *event) { char *buffer = NULL; char *locator; + int len, bufferlen; UAS_Pointer d; switch (event->type) @@ -416,8 +418,9 @@ olias_send_event (Widget, OliasEvent *event) } else { - buffer = new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create (buffer); delete [] buffer; if (d != (const int)NULL) @@ -425,11 +428,12 @@ olias_send_event (Widget, OliasEvent *event) // (evil hack alert) if (locator == NULL) return (OLIAS_TIMEOUT); - ON_DEBUG (printf (">>> g_top_locator = %p\n", g_top_locator)); + ON_DEBUG(printf(">>> g_top_locator = %p\n", g_top_locator)); if (g_top_locator == NULL) return (OLIAS_TIMEOUT); g_scroll_to_locator = TRUE; - strcpy (g_top_locator, locator); + len = MIN(strlen(locator), 4096 - 1); + *((char *) memcpy(g_top_locator, locator, len) +len) = '\0'; } } } @@ -459,4 +463,6 @@ olias_send_event (Widget, OliasEvent *event) default: return (OLIAS_TIMEOUT); } + + return (OLIAS_LOCATOR_NOT_FOUND); } diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/SessionMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/SessionMgr.C index 04496c21..fb25c278 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/SessionMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/SessionMgr.C @@ -52,6 +52,7 @@ #define L_Managers #include "Prelude.h" +#include "utility/funcs.h" LONG_LIVED_CC( SessionMgr, session ); @@ -65,9 +66,9 @@ SaveSession_cb( Widget w, } -SessionMgr::SessionMgr() : prior_session(NULL), - session_path(NULL), - sid(NULL) +SessionMgr::SessionMgr() : sid(NULL), + session_path(NULL), + prior_session(NULL) { // get session id & the place to save special startup info (future) DtSessionSavePath( window_system().toplevel(), &session_path, &sid ); @@ -94,7 +95,7 @@ SessionMgr::~SessionMgr() void SessionMgr::file( char *savefile ) { - prior_session = XtNewString( savefile ); + prior_session = XtsNewString( savefile ); } @@ -137,19 +138,19 @@ SessionMgr::setWmCommand() // insert a -session arg and its value into the arg list wm_command = (char **) XtMalloc((in_cnt+2) * sizeof(char*)); - wm_command[0] = XtNewString( main_argv[0] ); - wm_command[1] = XtNewString( "-session" ); + wm_command[0] = XtsNewString( main_argv[0] ); + wm_command[1] = XtsNewString( "-session" ); - if( sid ) wm_command[2] = XtNewString( sid ); - else if( session_path ) wm_command[2] = XtNewString( session_path ); - else wm_command[2] = XtNewString( "dtinfo_session" ); + if( sid ) wm_command[2] = XtsNewString( sid ); + else if( session_path ) wm_command[2] = XtsNewString( session_path ); + else wm_command[2] = XtsNewString( "dtinfo_session" ); #ifdef DEBUG printf( "session id = %s input arg count = %d\n", wm_command[2], in_cnt ); #endif for (i = 1, j = 3; i < in_cnt; i++) { - wm_command[j] = XtNewString(main_argv[i]); + wm_command[j] = XtsNewString(main_argv[i]); j++; } // actually register the command line with the window system diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/StyleSheetMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/StyleSheetMgr.C index d14ff81a..90b94e22 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/StyleSheetMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/StyleSheetMgr.C @@ -129,7 +129,7 @@ void StyleSheetMgr::initOnlineStyleSheet (UAS_Pointer &doc) { UAS_List ssList = doc->style_sheet_list (); UAS_Pointer onlineSS; - for (int i = 0; i < ssList.length(); i ++) { + for (unsigned int i = 0; i < ssList.length(); i ++) { if (ssList[i]->style_sheet_type() == SS_ONLINE) { onlineSS = ssList[i]; break; @@ -187,7 +187,7 @@ void StyleSheetMgr::initPrintStyleSheet (UAS_Pointer &doc) { UAS_List ssList = doc->style_sheet_list (); UAS_Pointer printSS; - for (int i = 0; i < ssList.length(); i ++) { + for (unsigned int i = 0; i < ssList.length(); i ++) { if (ssList[i]->style_sheet_type() == SS_HARDCOPY) { printSS = ssList[i]; break; diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/TtIpcMgr.C b/cde/programs/dtinfo/dtinfo/src/Managers/TtIpcMgr.C index ceb950e3..373eb1ed 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/TtIpcMgr.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/TtIpcMgr.C @@ -65,6 +65,7 @@ #include "Registration.hh" #include "utility/mmdb_exception.h" +#include "utility/funcs.h" #include #include @@ -135,15 +136,17 @@ LogToolTalkMessage ( char * errfmt; char * statmsg; char * errmsg; + int errmsglen; - if (! tt_is_err(status)) return XtNewString("");; + if (! tt_is_err(status)) return XtsNewString("");; errfmt = CATGETS(Set_TtIpcMgr, msg_num, dflt_txt); statmsg = tt_status_message(status); - errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2); + errmsglen = strlen(errfmt) + strlen(statmsg) + 2; + errmsg = XtMalloc(errmsglen); if (! strlen(errfmt)) errfmt = (char*)"%s"; - sprintf(errmsg, errfmt, statmsg); + snprintf(errmsg, errmsglen, errfmt, statmsg); DtMsgLogMessage ("Dtinfo", msg_type, errfmt, errmsg); return errmsg; @@ -301,7 +304,7 @@ TtIpcMgr::ipc_init_wp1( XtPointer theIpcObj ) // actually join the "default" session for all previously // registered patterns to take effect there-in - Tt_pattern *sess_patterns = + // Tt_pattern *sess_patterns = ttdt_session_join( NULL, NULL, window_system().toplevel(), theIpcObj, True ) ; // invoke msg handler explicitly in case a message already queued @@ -320,7 +323,7 @@ TtIpcMgr::ipc_init_wp1( XtPointer theIpcObj ) TtIpcMgr::~TtIpcMgr() { - char *dfile; + // char *dfile; // send a Dtinfo_Quit message to whomever may be observing notify_quit() ; @@ -401,12 +404,11 @@ TtIpcMgr::do_locator( char *locator, int TtIpcMgr::do_print(Tt_message msg) { - - int sts = ID_SUCCESS ; UAS_Pointer d = NULL ; char *filepath = tt_message_file(msg); FILE *fp; char locator[512]; + int bufferlen; fprintf(stderr, "TtIpcMgr::do_print: filepath = %s.\n", filepath); @@ -433,10 +435,10 @@ TtIpcMgr::do_print(Tt_message msg) { // assume given a unique locator ID for the target. // construct a fully-qualified form and pass it on. - - char *buffer = - new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create (buffer); delete [] buffer; } diff --git a/cde/programs/dtinfo/dtinfo/src/Marks/MarkBase_mmdb.C b/cde/programs/dtinfo/dtinfo/src/Marks/MarkBase_mmdb.C index 149d079b..72b1ca7b 100644 --- a/cde/programs/dtinfo/dtinfo/src/Marks/MarkBase_mmdb.C +++ b/cde/programs/dtinfo/dtinfo/src/Marks/MarkBase_mmdb.C @@ -91,7 +91,7 @@ MarkBase_mmdb::open (const char *filename, bool read_only) char buffer[256]; struct stat file_info; - sprintf (buffer, "%s/mmdb.names", filename); + snprintf (buffer, sizeof(buffer), "%s/names.mmdb", filename); int status = stat (buffer, &file_info); if (status == -1) diff --git a/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.C b/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.C index 5f3eb27c..f6a3bd71 100644 --- a/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.C +++ b/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.C @@ -240,15 +240,14 @@ Mark_mmdb::restore() end_try; // NOTE: Need better guard against corrupt mark data!! - if (f_user_mark->mark_value()->size() == 0) + if (sz == 0) { ON_DEBUG (puts ("*** ZERO LENGTH MARK ***")); throw (CASTEXCEPT Exception()); } // Suck the data out of the mmdb mark object. g_buffer.reset(); - g_buffer.write (f_user_mark->mark_value()->get(), sizeof (char), - f_user_mark->mark_value()->size()); + g_buffer.write (str, sizeof (char), sz); // Read the fields out of the buffer. int mark_version; diff --git a/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.hh b/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.hh index 1ccc646c..7b247a13 100644 --- a/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.hh +++ b/cde/programs/dtinfo/dtinfo/src/Marks/Mark_mmdb.hh @@ -72,8 +72,8 @@ private: // functions private: UAS_Pointer f_doc_ptr; Anchor f_anchor; + MarkBase_mmdb &f_mark_base; char *f_name; char *f_notes; mark_smart_ptr *f_user_mark; - MarkBase_mmdb &f_mark_base; }; diff --git a/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.C b/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.C index 1aced9eb..566e0153 100644 --- a/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.C +++ b/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.C @@ -87,87 +87,87 @@ struct s_entry static struct s_entry symbols[] = { - GRAPHIC_attr, "GRAPHIC", - INLGRAPHIC, "INLGRAPHIC", - ISMAP, "ISMAP", - OLID, "OL-ID", - OLIDREF, "OL-IDREF", - REMOTE, "REMOTE", - TABLE, "TABLE", - TERMS, "TERMS", - ALIGN, "ALIGN", - BOTTOM, "BOTTOM", - LINEBREAK, "LINEBREAK", - CHARSETS, "CHARSET", - SET, "SET", - BGCOLOR, "BGCOLOR", - FGCOLOR, "FGCOLOR", - FONT, "FONT", - FONTCATALOG, "FONTCATALOG", - FONTFAMILY, "FONTFAMILY", - HIGHLIGHT, "HIGHLIGHT", - IGNORE, "IGNORE", - LEFT, "LEFT", - MARGIN, "MARGIN", - SUFFIX, "SUFFIX", - PREFIX, "PREFIX", - PREVIEW, "PREVIEW", - RIGHT, "RIGHT", - TABSTOPS, "TABSTOP", - CONTENT, "CONTENT", - TOP, "TOP", - OVERLINE, "OVERLINE", - STRIKETHROUGH,"STRIKETHROUGH", - UNDERLINE, "UNDERLINE", - WRAP, "WRAP", - XLFD, "XLFD", - GRAPHIC_feature,"GRAPHIC", - FAMILY, "FAMILY", - WEIGHT, "WEIGHT", - SLANT, "SLANT", - SIZE, "SIZE", - CHARSET, "CHARSET", - REVERSEVIDEO, "REVERSE-VIDEO", - AT, "AT", - EVERY, "EVERY", - POSITION, "POSITION", - HORIZ, "HORIZ", - VERT, "VERT", - LAYOUT, "LAYOUT", - ASPACE, "ASPACE", - BSPACE, "BSPACE", - LEADING, "LEADING", - FINDENT, "FINDENT", - LINDENT, "LINDENT", - RINDENT, "RINDENT", - FLOW, "FLOW", - JUSTIFY, "JUSTIFY", - VJUSTIFY, "VJUSTIFY", - BORDER, "BORDER", - THICKNESS, "THICKNESS", - ROW, "ROW", - COLS, "COLS", - COLFORMAT, "COLFORMAT", - CHARALIGN, "CHARALIGN", - SPANCOLS, "SPANCOLS", - MOREROWS, "MOREROWS", - CELL, "CELL", - WIDTH, "WIDTH", - FALLBACK, "FALLBACK", - FOUNDRY, "FOUNDRY", - NAME, "NAME", - DISPLAY, "DISPLAY", - COLREF, "COLREF", - SUBSUPER, "POSITION", - COLSEP, "COLSEP", - ROWSEP, "ROWSEP", - TGROUP, "TGROUP", - FRAME, "FRAME", - MEDIA, "MEDIUM", - PAGEBREAK, "PAGEBREAK", - FOOTERS, "FOOTERS", - HEADERS, "HEADERS", - ORIENTATION, "ORIENTATION" + { GRAPHIC_attr, "GRAPHIC" }, + { INLGRAPHIC, "INLGRAPHIC" }, + { ISMAP, "ISMAP" }, + { OLID, "OL-ID" }, + { OLIDREF, "OL-IDREF" }, + { REMOTE, "REMOTE" }, + { TABLE, "TABLE" }, + { TERMS, "TERMS" }, + { ALIGN, "ALIGN" }, + { BOTTOM, "BOTTOM" }, + { LINEBREAK, "LINEBREAK" }, + { CHARSETS, "CHARSET" }, + { SET, "SET" }, + { BGCOLOR, "BGCOLOR" }, + { FGCOLOR, "FGCOLOR" }, + { FONT, "FONT" }, + { FONTCATALOG, "FONTCATALOG" }, + { FONTFAMILY, "FONTFAMILY" }, + { HIGHLIGHT, "HIGHLIGHT" }, + { IGNORE, "IGNORE" }, + { LEFT, "LEFT" }, + { MARGIN, "MARGIN" }, + { SUFFIX, "SUFFIX" }, + { PREFIX, "PREFIX" }, + { PREVIEW, "PREVIEW" }, + { RIGHT, "RIGHT" }, + { TABSTOPS, "TABSTOP" }, + { CONTENT, "CONTENT" }, + { TOP, "TOP" }, + { OVERLINE, "OVERLINE" }, + { STRIKETHROUGH,"STRIKETHROUGH" }, + { UNDERLINE, "UNDERLINE" }, + { WRAP, "WRAP" }, + { XLFD, "XLFD" }, + { GRAPHIC_feature,"GRAPHIC" }, + { FAMILY, "FAMILY" }, + { WEIGHT, "WEIGHT" }, + { SLANT, "SLANT" }, + { SIZE, "SIZE" }, + { CHARSET, "CHARSET" }, + { REVERSEVIDEO, "REVERSE-VIDEO" }, + { AT, "AT" }, + { EVERY, "EVERY" }, + { POSITION, "POSITION" }, + { HORIZ, "HORIZ" }, + { VERT, "VERT" }, + { LAYOUT, "LAYOUT" }, + { ASPACE, "ASPACE" }, + { BSPACE, "BSPACE" }, + { LEADING, "LEADING" }, + { FINDENT, "FINDENT" }, + { LINDENT, "LINDENT" }, + { RINDENT, "RINDENT" }, + { FLOW, "FLOW" }, + { JUSTIFY, "JUSTIFY" }, + { VJUSTIFY, "VJUSTIFY" }, + { BORDER, "BORDER" }, + { THICKNESS, "THICKNESS" }, + { ROW, "ROW" }, + { COLS, "COLS" }, + { COLFORMAT, "COLFORMAT" }, + { CHARALIGN, "CHARALIGN" }, + { SPANCOLS, "SPANCOLS" }, + { MOREROWS, "MOREROWS" }, + { CELL, "CELL" }, + { WIDTH, "WIDTH" }, + { FALLBACK, "FALLBACK" }, + { FOUNDRY, "FOUNDRY" }, + { NAME, "NAME" }, + { DISPLAY, "DISPLAY" }, + { COLREF, "COLREF" }, + { SUBSUPER, "POSITION" }, + { COLSEP, "COLSEP" }, + { ROWSEP, "ROWSEP" }, + { TGROUP, "TGROUP" }, + { FRAME, "FRAME" }, + { MEDIA, "MEDIUM" }, + { PAGEBREAK, "PAGEBREAK" }, + { FOOTERS, "FOOTERS" }, + { HEADERS, "HEADERS" }, + { ORIENTATION, "ORIENTATION" } }; // supported features @@ -231,11 +231,11 @@ print_justify (unsigned value) CanvasRenderer::CanvasRenderer(int font_scale) : Renderer(), - fBogusSymbol(gElemSymTab->intern("%BOGUS")), - f_font_scale(font_scale), + f_current_tgroup (0), f_font (0), f_link_idx (-1), - f_current_tgroup (0), + f_font_scale(font_scale), + fBogusSymbol(gElemSymTab->intern("%BOGUS")), f_level(0) { // make symbols @@ -993,10 +993,10 @@ CanvasRenderer::handle_olias_attributes(ElementFeatures &features, if (grattr) { +#ifdef GRAPHIC_DEBUG const Feature *graphic_display_type = complete.deep_lookup("GRAPHIC", "ALIGN", 0); -#ifdef GRAPHIC_DEBUG cerr << "GRAPHIC" << endl; cerr << "Graphic( " << element.gi() << "): (" ; @@ -1225,7 +1225,8 @@ CanvasRenderer::handle_olias_attributes(ElementFeatures &features, else { char buf[100] ; - sprintf(buf, "Graphic \"%s\" unavailable", graphic); + snprintf(buf, sizeof(buf), + "Graphic \"%s\" unavailable", graphic); #ifdef TML_NO_THIS_ASSIGNMENT new_gnode = new (the_model) gnode(the_model); #else @@ -1377,7 +1378,7 @@ new_segment(unsigned long type) unsigned size = sizeof(segment->handle); //cerr << "Handle size = " << size << endl; char *p = (char *)&(segment->handle) ; - for (int i = 0; i < size; i++, p++) + for (unsigned int i = 0; i < size; i++, p++) *p = 0; } @@ -1493,7 +1494,7 @@ CanvasRenderer::insert_string (_DtCvSegment *container, // find the newlines, and make a string segment up to that point, // then advance our start pointer beyond that point - for (; newline = strchr(start, '\n'); start = newline + 1) { + for (; (newline = strchr(start, '\n')); start = newline + 1) { seg = really_insert_string(container, font, start, (newline - start), count_vcc); _DtCvSegment *lbseg = insert_break(container, _DtCvNEW_LINE); @@ -1541,7 +1542,7 @@ CanvasRenderer::really_insert_string (_DtCvSegment *container, f_current_displayable = strseg ; - int ret_indx ; + long ret_indx ; // calculate dthelp font index { // WARNING: this routine keeps the ptr to the xlfd_spec @@ -1582,7 +1583,7 @@ CanvasRenderer::really_insert_string (_DtCvSegment *container, #endif unsigned char* strp; - while (strp = (unsigned char*)strchr(string, '\015')) { + while ((strp = (unsigned char*)strchr(string, '\015'))) { #ifdef CR_JP_DEBUG cerr << " found..."; #endif @@ -1800,12 +1801,12 @@ CanvasRenderer::setup_container(_DtCvSegment *container, ElementFeatures &featur PartialElementFeatures::PartialElementFeatures(CanvasRenderer* renderer) : f_text (0), f_font(0), + f_subsuper(baseline), f_linebreak(0), f_pagebreak(PAGEBREAK_NONE), + f_layout(renderer), f_graphic (0), - f_subsuper(baseline), f_ignore(0), - f_layout(renderer), f_orientation("portrait") { @@ -1814,13 +1815,13 @@ PartialElementFeatures::PartialElementFeatures(CanvasRenderer* renderer) PartialElementFeatures::PartialElementFeatures (PartialElementFeatures &features) : f_text (features.f_text), f_font (features.f_font), + f_subsuper (features.f_subsuper), f_highlight (features.f_highlight), f_linebreak (features.f_linebreak), f_pagebreak (features.f_pagebreak), f_position (features.f_position), f_layout (features.f_layout), f_graphic (features.f_graphic), - f_subsuper (features.f_subsuper), f_ignore (features.f_ignore), f_orientation (features.f_orientation) { @@ -1834,17 +1835,17 @@ PartialElementFeatures::~PartialElementFeatures() ElementFeatures::ElementFeatures(CanvasRenderer* renderer) : PartialElementFeatures(renderer), f_row (NULL), - f_border (_DtCvBORDER_NONE), f_graphic (0), - f_locator (0), - f_link_idx (-1), + f_border (_DtCvBORDER_NONE), + f_border_width(-1), // invalid border width f_table (NULL), f_tgroup (NULL), f_colformat (NULL), - f_border_width(-1), // invalid border width - f_xref(NULL), f_prefix(renderer), - f_suffix(renderer) + f_suffix(renderer), + f_locator (0), + f_xref(NULL), + f_link_idx (-1) {} ElementFeatures::~ElementFeatures() @@ -1911,8 +1912,8 @@ Layout::Layout(CanvasRenderer* renderer) f_aspace (0), f_bspace (0), f_leading (-1), f_findent (0), f_rindent(0), f_lindent (0), f_flow (_DtCvOPTION_BAD), - f_wrap (_DtCvOPTION_BAD), - f_justify (_DtCvOPTION_BAD) + f_justify (_DtCvOPTION_BAD), + f_wrap (_DtCvOPTION_BAD) { } @@ -1922,11 +1923,11 @@ Layout::Layout (Layout &layout) f_bspace (layout.f_bspace), f_leading (layout.f_leading), f_findent (layout.f_findent), - f_lindent (layout.f_lindent), f_rindent (layout.f_rindent), + f_lindent (layout.f_lindent), f_flow (layout.f_flow), - f_wrap (layout.f_wrap), - f_justify (layout.f_justify) + f_justify (layout.f_justify), + f_wrap (layout.f_wrap) { } @@ -2076,14 +2077,17 @@ TGDefn::add (ColDefn *cd) } } +#if 0 static void add_id(char **cell_ids, unsigned row, unsigned number, _DtCvSegment *segment) { char *id = segment->handle.container.id; char idstr[64]; + int cell_idslen; + if (id == NULL) { - sprintf(idstr,"id%d", number); + snprintf(idstr, sizeof(idstr), "id%d", number); id = idstr ; segment->handle.container.id = strdup (id); @@ -2095,17 +2099,19 @@ add_id(char **cell_ids, unsigned row, unsigned number, _DtCvSegment *segment) else { char *orig = cell_ids[row] ; - cell_ids[row] = new char [ strlen (orig) + 1 + strlen (id) + 1 ] ; - sprintf(cell_ids[row], "%s %s", orig, id); + cell_idslen = strlen (orig) + 1 + strlen (id) + 1 ; + cell_ids[row] = new char [ cell_idslen ] ; + snprintf(cell_ids[row], cell_idslen, "%s %s", orig, id); } } +#endif ColFormat::ColFormat() : f_char_align ('.'), + f_name(NULL), f_justify (_DtCvOPTION_BAD), f_width (1), - f_name(NULL), f_colsep(CRSEP_NOT_SPECIFIED), f_rowsep(CRSEP_NOT_SPECIFIED) {} @@ -2142,7 +2148,7 @@ _DtCvSegment *ensure_id(_DtCvSegment *segment) if (segment->handle.container.id == NULL) { char buffer[16] ; - sprintf(buffer, "id%d", id_count++); + snprintf(buffer, sizeof(buffer), "id%d", id_count++); segment->handle.container.id = strdup (buffer); } return segment ; @@ -2188,7 +2194,7 @@ TGDefn::find_format(const char *name, int* index) void TGDefn::build() { - unsigned i ; + unsigned i, len, slen, lent, leng; unsigned num_cells = 0; // # of virtual cells unsigned num_rows = 0; // # of physical rows unsigned num_columns = 0; // # of physical columns @@ -2290,7 +2296,7 @@ TGDefn::build() for (i = 0 ; i < num_rows ; i++) { grid[i] = new _DtCvSegment *[num_columns] ; - for (int c = 0 ; c < num_columns; c++) + for (unsigned int c = 0 ; c < num_columns; c++) grid[i][c] = NULL ; } @@ -2342,9 +2348,9 @@ TGDefn::build() int spancols = 1; ColFormat* msformat; // most significant format ColFormat* lsformat; // least significant format - if (msformat = find_format(colcell->colstart(), &start_index)) { + if ((msformat = find_format(colcell->colstart(), &start_index))) { int end_index; - if (lsformat = find_format(colcell->colend(), &end_index)) { + if ((lsformat = find_format(colcell->colend(), &end_index))) { if (start_index > end_index) { int anonym = start_index; start_index = end_index; @@ -2370,7 +2376,7 @@ TGDefn::build() setup_cell(segment, colcell, row_cursor.key(), msformat, lsformat); for (int i = 0 ; i < spancols; i++) { - for (int j = 0; j < colcell->spanrows(); j++) { + for (unsigned int j = 0; j < colcell->spanrows(); j++) { // if there's entrenchment from above rows, skip it. if (grid[current_row + j][start_index + i]) continue; @@ -2383,7 +2389,6 @@ TGDefn::build() columns.removeAt(kept); } - unsigned current_column = 0 ; count = columns.entries(); for (vc = 0, kept = 0; vc < count; vc++) // iterate for virtual cells { @@ -2401,7 +2406,7 @@ TGDefn::build() } end_try; - int i, start_index; + unsigned int i, start_index; for (i = 0; i < num_columns; i++) { if (grid[current_row][i] == NULL) { start_index = i; @@ -2434,7 +2439,7 @@ TGDefn::build() columns.removeAt(kept); } - for (int c = 0; c < num_columns; c++) + for (unsigned int c = 0; c < num_columns; c++) { if (grid[current_row][c] == NULL) { @@ -2458,7 +2463,7 @@ TGDefn::build() #ifdef TABLE_DEBUG fprintf(stderr, "(DEBUG) blank spot found in the table.\n"); #endif - int col; + unsigned int col; if (c == 0) { @@ -2471,7 +2476,7 @@ TGDefn::build() { _DtCvSegment* filler = grid[r][col]; - for (int i = c; i < col; i++) + for (unsigned int i = c; i < col; i++) grid[r][i] = filler; } } @@ -2501,7 +2506,7 @@ TGDefn::build() for (r = 0 ; r < num_rows ; r++) { - for (int c = 0 ; c < num_columns ; c++) + for (unsigned int c = 0 ; c < num_columns ; c++) { if (c == 0) { @@ -2512,11 +2517,13 @@ TGDefn::build() { // subsequent items, append space separated id - unsigned len = strlen (table->cell_ids[r]) + strlen (grid[r][c]->handle.container.id); - char *new_ids = new char [len + 2] ; - strcpy(new_ids, table->cell_ids[r]) ; - strcat(new_ids, " "); - strcat(new_ids, grid[r][c]->handle.container.id); + lent = strlen (table->cell_ids[r]); + leng = strlen (grid[r][c]->handle.container.id); + char *new_ids = new char [lent + leng + 2] ; + *((char *) memcpy(new_ids, table->cell_ids[r], lent) +lent) ='\0'; + *((char *) memcpy(new_ids + lent, " ", 1) + 1) = '\0'; + *((char *) memcpy(new_ids + lent + 1, + grid[r][c]->handle.container.id, leng) + leng) = '\0'; delete table->cell_ids[r] ; table->cell_ids[r] = new_ids ; } @@ -2534,7 +2541,7 @@ TGDefn::build() justify_chars[0] = 0 ; - for (int i = 0 ; i < num_columns ; i++) + for (unsigned int i = 0 ; i < num_columns ; i++) { justify[i] = _DtCvOPTION_BAD; col_widths[i] = NULL; @@ -2547,7 +2554,7 @@ TGDefn::build() justify[i] = format->justify(); - sprintf(buffer, "%d", format->width()); + snprintf(buffer, sizeof(buffer), "%d", format->width()); col_widths[i] = strdup(buffer); if (format->justify() == _DtCvJUSTIFY_CHAR) @@ -2555,7 +2562,9 @@ TGDefn::build() char buf[2] ; buf[0] = format->char_align() ; buf[1] = 0 ; - strcat(justify_chars, buf); + slen = strlen(buf); + len = MIN(strlen(buf), num_columns - slen); + *((char *) memcpy(justify_chars + slen, buf, len) + len) = '\0'; } } table->col_justify = justify ; diff --git a/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.hh b/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.hh index e9e6cd14..b8bdaca9 100644 --- a/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.hh +++ b/cde/programs/dtinfo/dtinfo/src/OnlineRender/CanvasRenderer.hh @@ -347,7 +347,7 @@ class PartialElementFeatures public: PartialElementFeatures(CanvasRenderer *); PartialElementFeatures (PartialElementFeatures &); - ~PartialElementFeatures(); + virtual ~PartialElementFeatures(); virtual int requires_container(int affix); virtual int ignore_linebreak(int affix); diff --git a/cde/programs/dtinfo/dtinfo/src/OnlineRender/FeatureSupport.C b/cde/programs/dtinfo/dtinfo/src/OnlineRender/FeatureSupport.C index 182fc47b..59cb6040 100644 --- a/cde/programs/dtinfo/dtinfo/src/OnlineRender/FeatureSupport.C +++ b/cde/programs/dtinfo/dtinfo/src/OnlineRender/FeatureSupport.C @@ -137,7 +137,6 @@ CanvasRenderer::get_pattern(const char *fallback, const char *weight, const char const char *family_str = "*"; const char *weight_str = weight; const char *slant_str = slant; - const char *setwidth_name_str = "*"; const char *style_str = "*"; int point_size = size; const char *spacing_str = "*"; @@ -378,8 +377,9 @@ pattern_done: char pattern[256]; // -dt-application-medium-r-normal-sans-8-80-75-75-p-46-iso8859-1 - sprintf ( + snprintf ( pattern, + sizeof(pattern), "-%s-%s-%s-%s-normal-%s-*-%d-*-*-%s-*-%s", foundry_str ? foundry_str : "*", family_str ? family_str : "*", @@ -417,8 +417,9 @@ pattern_done: printf("point size = %d.\n", point_size); #endif - sprintf ( + snprintf ( pattern, + sizeof(pattern), "-%s-%s-%s-%s-normal-%s-*-%d-*-*-%s-*-%s", foundry_str ? foundry_str : "*", family_str ? family_str : "*", @@ -462,11 +463,12 @@ pattern_done: char* CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) { + int len, slen; const char *fallback = NULL; const Feature *fallbackF = fs.lookup(symbols[FALLBACK]); if (fallbackF) { - if (fallback = *fallbackF->value()) { + if ((fallback = *fallbackF->value())) { if (strcasecmp(fallback, "sans") == 0) fallback = f_sans ; else if (strcasecmp(fallback, "serif") == 0) @@ -492,14 +494,17 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) const Feature *slantF = fs.lookup(symbols[SLANT]); const Feature *sizeF = fs.lookup(symbols[SIZE]); - const char *name = NULL, *foundry = NULL, *charset = NULL; + const char *name = NULL, *charset = NULL; +#ifdef JBM_FONT_DEBUG + const char *foundry = NULL; +#endif // need to add something for spacing here //const Feature *spacingF = fs.lookup(symbols[SPACING]); const char* font; char* xlfd = NULL; - int i; + unsigned int i; for (i = 0; i < fs.entries(); i++) { Feature* entry; @@ -525,10 +530,12 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) continue; } +#ifdef JBM_FONT_DEBUG const Feature* foundryF = familyFS->lookup(symbols[FOUNDRY]); if (foundryF) { foundry = *foundryF->value(); } +#endif const Feature* charsetF = familyFS->lookup(symbols[CHARSET]); if (charsetF) charset = *charsetF->value(); @@ -566,9 +573,11 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) // if xlfd already defined, create a font list if (xlfd) { - xlfd = (char*)realloc(xlfd, strlen(xlfd) + strlen(font) + 3); - strcat(xlfd, ","); - strcat(xlfd, font); + slen = strlen(xlfd); + len = strlen(font); + xlfd = (char*)realloc(xlfd, slen + len + 3); + *((char *) memcpy(xlfd + slen, ",", 1) + 1) = '\0'; + *((char *) memcpy(xlfd + slen + 1, ",", len) + len) = '\0'; } // otherwise, just dup the font streing else { @@ -587,7 +596,8 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) // list so append a colon to the end of the font list string if (strchr(xlfd, ',')) { - strcat(xlfd, ":"); + slen = strlen(xlfd); + *((char *) memcpy(xlfd + slen, ":", 1) + 1) = '\0'; } } @@ -629,10 +639,9 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols) // p points to comma or end of string if (*p == ',') { - int len = p - family ; + len = p - family ; fallback = new char[len + 1] ; - strncpy(fallback, family, len); - fallback[len] = 0 ; + *((char *) memcpy(fallback, family, len) + len) = '\0'; do p++; while (isspace(*p)); family = p ; diff --git a/cde/programs/dtinfo/dtinfo/src/OnlineRender/FontCache.C b/cde/programs/dtinfo/dtinfo/src/OnlineRender/FontCache.C index e071bf0a..402ea638 100644 --- a/cde/programs/dtinfo/dtinfo/src/OnlineRender/FontCache.C +++ b/cde/programs/dtinfo/dtinfo/src/OnlineRender/FontCache.C @@ -160,13 +160,16 @@ FontCache::getxlfd(const char *family, int bold, // get cache of font family static char pattern[256]; if (charset && *charset) { - sprintf(pattern, "-*-%s-*-*-*-*-*-*-*-*-*-*-%s", family, charset); + snprintf(pattern, sizeof(pattern), + "-*-%s-*-*-*-*-*-*-*-*-*-*-%s", family, charset); } else if (family && *family) { - sprintf(pattern, "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*", family); + snprintf(pattern, sizeof(pattern), + "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*", family); } else { - strcpy(pattern, fallback); + int len = MIN(strlen(fallback), 256 - 1); + *((char *) memcpy(pattern, fallback, len) + len) = '\0'; } CC_String _l_pattern(pattern); @@ -177,8 +180,8 @@ FontCache::getxlfd(const char *family, int bold, #if DO_SCALEABLE_FONTS // first check for scalable char scaled_pattern[256]; - sprintf(scaled_pattern, "-*-%s-%s-%s-*-*-0-0-*-*-*-*-*-*", - family, weight, slant); + snprintf(scaled_pattern, sizeof(scaled_pattern), + "-*-%s-%s-%s-*-*-0-0-*-*-*-*-*-*", family, weight, slant); newfont = XLoadQueryFont(display, pattern); #endif @@ -218,8 +221,8 @@ FontCache::getxlfd(const char *family, int bold, #ifdef DO_SCALEABLE_FONTS if (fontlist->scaleable()) { - sprintf(pattern, "-*-%s-%s-%s-*-*-%d-*-*-*-*-*-*-*", - family, weight, slant, size); + snprintf(pattern, sizeof(pattern), + "-*-%s-%s-%s-*-*-%d-*-*-*-*-*-*-*", family, weight, slant, size); return pattern ; } @@ -243,7 +246,7 @@ FontCache::getxlfd(const char *family, int bold, (scan = strchr(scan+1, '-'))){ if(bold == (strncmp(scan + 1, "medium", 6) == 0)) score += 500; //HEURISTIC - if(scan = strchr(scan+1, '-')){ + if((scan = strchr(scan+1, '-'))){ if(italic == (strncmp(scan+1, "r", 1) == 0)) score += 500; //HEURISTIC if((scan = strchr(scan+1, '-')) && @@ -286,8 +289,8 @@ FontCache::getxlfd(const char *family, int bold, FontList::FontList(int count, const char **names) -: f_count(count), - f_names(names) +: f_names(names), + f_count(count) { } FontList::~FontList() diff --git a/cde/programs/dtinfo/dtinfo/src/OnlineRender/Imakefile b/cde/programs/dtinfo/dtinfo/src/OnlineRender/Imakefile index 76437b8a..2e9e0cca 100644 --- a/cde/programs/dtinfo/dtinfo/src/OnlineRender/Imakefile +++ b/cde/programs/dtinfo/dtinfo/src/OnlineRender/Imakefile @@ -33,7 +33,7 @@ dfiles: #ifdef UXPArchitecture SpecialCPlusPlusObjectRule(ORTemplates.o,, +Tall_tmpls -DEXPAND_TEMPLATES) SpecialCPlusPlusExpandRule(ORTemplates..c,ORTemplates.C,+Tall_tmpls -DEXPAND_TEMPLATES) -#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) +#elif defined(LinuxArchitecture) || defined(FreeBSDArchitecture) || defined(OpenBSDArchitecture) SpecialCPlusPlusObjectRule(ORTemplates.o,,-DEXPAND_TEMPLATES) SpecialCPlusPlusExpandRule(ORTemplates..c,ORTemplates.C,-DEXPAND_TEMPLATES) #endif diff --git a/cde/programs/dtinfo/dtinfo/src/Other/WindowSystemMotif.C b/cde/programs/dtinfo/dtinfo/src/Other/WindowSystemMotif.C index 7025be70..802229e3 100644 --- a/cde/programs/dtinfo/dtinfo/src/Other/WindowSystemMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Other/WindowSystemMotif.C @@ -225,8 +225,8 @@ class Shell_Info { public: Shell_Info (Widget w) : f_shell (w), - f_restore (False), - f_size_hints (NULL) + f_size_hints (NULL), + f_restore (False) { } public: @@ -244,12 +244,12 @@ public: // ///////////////////////////////////////////////////////////////// WindowSystem::WindowSystem (int &argc, char *argv[]) -: f_shell_list (20), +: f_printing(False), f_default_pixmap (0), f_defpix_width (0), f_defpix_height (0), - f_printing(False), f_detached_pixmap(0), + f_shell_list (20), f_cursor_stack_pos(-1), f_dtinfo_font(NULL), f_dtinfo_space_font(NULL) @@ -275,7 +275,7 @@ WindowSystem::WindowSystem (int &argc, char *argv[]) } /* Reference the scale widget so Veritas Replay Xt lib can link. */ - WidgetClass xxx = xmScaleWidgetClass; + /* WidgetClass xxx = xmScaleWidgetClass; */ int count; char **names = XListFonts(window_system().display(), @@ -540,9 +540,6 @@ xevent_error_aborter(Display *display, XErrorEvent* error_event) void WindowSystem::init() { - Arg args[8]; - int i = 0; - XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); _DtEnvControl(DT_ENV_SET); @@ -872,7 +869,7 @@ WindowSystem::set_cursor (Cursor cursor, Widget exception) { Widget shell; // ON_DEBUG (printf ("Cursor change <%d>\n", f_cursor_stack_pos)); - for (int i = 0; i < f_shell_list.length(); i++) + for (unsigned int i = 0; i < f_shell_list.length(); i++) { shell = ((Shell_Info *) f_shell_list[i])->f_shell; if (shell != exception && XtWindow (shell) != 0) @@ -904,14 +901,14 @@ WindowSystem::reset_cursor (WCallback *wcb) Widget shell; Widget exception = wcb ? wcb->GetWidget() : NULL; f_cursor_stack_pos--; - Cursor cursor; + Cursor cursor = 0; if (f_cursor_stack_pos >= 0) cursor = f_cursor_stack[f_cursor_stack_pos].cursor; - for (int i = 0; i < f_shell_list.length(); i++) + for (unsigned int i = 0; i < f_shell_list.length(); i++) { shell = ((Shell_Info *) f_shell_list[i])->f_shell; - if (shell != exception && XtWindow (shell) != 0) + if (shell != exception && XtWindow (shell) != 0) { // Reset the previous cursor if there's one on the stack, revert // to default cursor if the stack is empty. // printf ("Resetting cursor on %s\n", XtName(shell)); @@ -920,6 +917,7 @@ WindowSystem::reset_cursor (WCallback *wcb) XDefineCursor (f_display, XtWindow (shell), cursor); else XUndefineCursor (f_display, XtWindow (shell)); + } } XFlush (f_display); } @@ -957,10 +955,11 @@ WindowSystem::create_cursor (const char *filename) Cursor cursor; Pixmap cursor_bits, cursor_mask; Screen *screen = DefaultScreenOfDisplay (f_display); - static XColor white = { 0, ~0, ~0, ~0, DoRed | DoGreen | DoBlue }; + unsigned short c = ~0; + static XColor white = { 0, c, c, c, DoRed | DoGreen | DoBlue }; static XColor black = { 0, 0, 0, 0, DoRed | DoGreen | DoBlue }; int hot_x, hot_y; - int depth; + int depth, len; Boolean success; // Get the cursor pixmap. @@ -978,12 +977,15 @@ WindowSystem::create_cursor (const char *filename) &hot_x, &hot_y, // 0, 0); // width, height - assert (success); + if(!success) { + assert (success); + } // Get the cursor mask pixmap. - char *mask_filename = new char [strlen(filename) + 2]; - strcpy (mask_filename, filename); - strcat (mask_filename, "m"); + len = strlen(filename); + char *mask_filename = new char [len + 2]; + *((char *) memcpy(mask_filename, filename, len) + len) = '\0'; + *((char *) memcpy(mask_filename + len, "m", 1) + 1) = '\0'; cursor_mask = XmGetPixmapByDepth (screen, mask_filename, 1, 0, 1); if (cursor_mask == XmUNSPECIFIED_PIXMAP) { @@ -1098,11 +1100,10 @@ WindowSystem::default_pixmap (Dimension *width, Dimension *height) temp_width = default_width; temp_height = default_height; #else - int status ; XpmAttributes xpm_attr ; xpm_attr.valuemask = 0 ; - status = XmeXpmCreatePixmapFromData(f_display, + XmeXpmCreatePixmapFromData(f_display, XtWindow((Widget)toplevel()), (char**)graphic_unavailable_data, &temp_pixmap, @@ -1197,7 +1198,8 @@ WindowSystem::read_pixmap(const char *pname, xpm_attributes.valuemask = 0; - strcpy(fname, pname); + int len = MIN(strlen(pname), 255 - 1); + *((char *) memcpy(fname, pname, len) + len) = '\0'; #ifdef UseDlOpen status = xpm_lib().ReadFileToPixmap (f_display, XtWindow ((Widget)toplevel()), @@ -1349,7 +1351,8 @@ WindowSystem::get_message (const char *message_name) XtGetApplicationResources (toplevel(), &string, resource, 1, NULL, 0); if (string == default_message) - sprintf (string, "%s (Message description not found)", message_name); + snprintf (string, sizeof(default_message), + "%s (Message description not found)", message_name); return (string); } @@ -1499,7 +1502,7 @@ WindowSystem::show_all_windows() Shell_Info *si; Boolean waiting_for_wm; - for (int i = 0; i < f_shell_list.length(); i++) + for (unsigned int i = 0; i < f_shell_list.length(); i++) { si = (Shell_Info *) f_shell_list[i]; if (si->f_restore) diff --git a/cde/programs/dtinfo/dtinfo/src/Other/vroot.h b/cde/programs/dtinfo/dtinfo/src/Other/vroot.h index c1a990aa..b7c4d43b 100644 --- a/cde/programs/dtinfo/dtinfo/src/Other/vroot.h +++ b/cde/programs/dtinfo/dtinfo/src/Other/vroot.h @@ -80,13 +80,14 @@ #define _VROOT_H_ #if !defined(lint) && !defined(SABER) -static char vroot_rcsid[] = "$XConsortium: vroot.h /main/3 1996/06/11 16:30:45 cde-hal $"; +static const char vroot_rcsid[] = "$XConsortium: vroot.h /main/3 1996/06/11 16:30:45 cde-hal $"; #endif #include #include #include +#if 0 static Window VirtualRootWindowOfScreen(Screen *screen) { @@ -97,7 +98,7 @@ VirtualRootWindowOfScreen(Screen *screen) { Display *dpy = DisplayOfScreen(screen); Atom __SWM_VROOT = None; - int i; + unsigned int i; Window rootReturn, parentReturn, *children; unsigned int numChildren; @@ -139,6 +140,7 @@ VirtualRootWindowOfScreen(Screen *screen) return (root); } +#endif /* Need original macros to figure out if there is a virtual root. */ diff --git a/cde/programs/dtinfo/dtinfo/src/Preferences/BooleanPref.C b/cde/programs/dtinfo/dtinfo/src/Preferences/BooleanPref.C index eb66b0dd..f1b0c161 100644 --- a/cde/programs/dtinfo/dtinfo/src/Preferences/BooleanPref.C +++ b/cde/programs/dtinfo/dtinfo/src/Preferences/BooleanPref.C @@ -71,9 +71,9 @@ void BooleanPref::save() { if (f_value == 0) - strcpy (g_buffer, "false"); + *((char *) memcpy(g_buffer, "false", 6) + 6) = '\0'; else - strcpy (g_buffer, "true"); + *((char *) memcpy(g_buffer, "true", 5) + 5) = '\0'; set_value (g_buffer); } diff --git a/cde/programs/dtinfo/dtinfo/src/Preferences/IntegerPref.C b/cde/programs/dtinfo/dtinfo/src/Preferences/IntegerPref.C index 613fa4bd..f0ed69b0 100644 --- a/cde/programs/dtinfo/dtinfo/src/Preferences/IntegerPref.C +++ b/cde/programs/dtinfo/dtinfo/src/Preferences/IntegerPref.C @@ -63,7 +63,7 @@ void IntegerPref::save() { - sprintf (g_buffer, "%d", f_value); + snprintf (g_buffer, sizeof(g_buffer), "%d", f_value); set_value (g_buffer); } diff --git a/cde/programs/dtinfo/dtinfo/src/Preferences/UserPreference.C b/cde/programs/dtinfo/dtinfo/src/Preferences/UserPreference.C index b4148fe3..81be16e0 100644 --- a/cde/programs/dtinfo/dtinfo/src/Preferences/UserPreference.C +++ b/cde/programs/dtinfo/dtinfo/src/Preferences/UserPreference.C @@ -111,7 +111,8 @@ PreferenceRecord::form_filename() static char filename[256]; if (filename[0] == '\0') { - sprintf (filename, "%s/preferences", env().user_path()); + snprintf (filename, sizeof(filename), + "%s/preferences", env().user_path()); #if EAM const char *home = env().home(); if (home == NULL) @@ -120,8 +121,8 @@ PreferenceRecord::form_filename() if (lang == NULL) throw (CASTEXCEPT Exception()); - sprintf (filename, "%s/.dt/dtinfo/%s/preferences", - home, lang); + snprintf (filename, sizeof(filename), + "%s/.dt/dtinfo/%s/preferences", home, lang); #endif } @@ -134,8 +135,8 @@ revert_from_backup (const char *filename) { int ret; // Failed, so look for the backup file. - char backup[256], original[256]; - sprintf (backup, "%s.bak", filename); + char backup[256]; + snprintf (backup, sizeof(backup), "%s.bak", filename); struct stat file_info; if (stat (backup, &file_info) != -1 && @@ -143,6 +144,7 @@ revert_from_backup (const char *filename) { unlink (filename); ret = link (backup, filename); + if(ret == 0) throw (CASTEXCEPT Exception()); } } @@ -155,11 +157,13 @@ read_version (FILE *stream) // Make sure the file is valid. char V = '-'; ret1 = fread (&V, 1, 1, stream); + if(ret1 == 0) throw (CASTEXCEPT Exception()); if (V != 'V') return (0); // Nab the version from the file. int version = 0; ret2 = fscanf (stream, "%d", &version); + if(ret2 == 0) throw (CASTEXCEPT Exception()); return (version); } @@ -172,6 +176,7 @@ read_update_count (FILE *stream) int update_count; ret = fgets (buffer, 256, stream); + if(ret == NULL) throw (CASTEXCEPT Exception()); p = buffer; while (*p != ',' && *p != '\0') p++; @@ -290,7 +295,7 @@ PreferenceRecord::write_prefs() backup[0] = '\0'; if (status == 0) { - sprintf (backup, "%s.bak", filename); + snprintf (backup, sizeof(backup), "%s.bak", filename); unlink (backup); if (rename (filename, backup) == -1) throw (CASTEXCEPT Exception()); @@ -298,7 +303,7 @@ PreferenceRecord::write_prefs() else // Make sure the parent directory exists. { char dirname[256]; - sprintf (dirname, "%s", env().user_path()); + snprintf (dirname, sizeof(dirname), "%s", env().user_path()); status = stat (dirname, &file_info); if (status == -1) { diff --git a/cde/programs/dtinfo/dtinfo/src/Preferences/WindowGeometryPref.C b/cde/programs/dtinfo/dtinfo/src/Preferences/WindowGeometryPref.C index 27d9d4af..40d666ef 100644 --- a/cde/programs/dtinfo/dtinfo/src/Preferences/WindowGeometryPref.C +++ b/cde/programs/dtinfo/dtinfo/src/Preferences/WindowGeometryPref.C @@ -63,7 +63,7 @@ void WindowGeometryPref::save() { - sprintf (g_buffer, "%dx%d+%d+%d", + snprintf (g_buffer, sizeof(g_buffer), "%dx%d+%d+%d", f_value.width, f_value.height, f_value.ulx, f_value.uly); set_value (g_buffer); } diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryEditor.C b/cde/programs/dtinfo/dtinfo/src/Query/QueryEditor.C index 77f0d342..60ffb597 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryEditor.C +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryEditor.C @@ -102,9 +102,9 @@ QueryEditor *QueryEditor::f_query_editor; // ///////////////////////////////////////////////////////////////// QueryEditor::QueryEditor(UAS_SearchEngine& search_engine) -: f_shell (NULL), - f_query (NULL), +: f_query (NULL), f_query_view (NULL), + f_shell (NULL), f_null_terms (0) { f_query_editor = this; diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryGroup.C b/cde/programs/dtinfo/dtinfo/src/Query/QueryGroup.C index aea5d34c..09a09211 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryGroup.C +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryGroup.C @@ -99,11 +99,13 @@ static const char *infix_formats[] = "%s weight %%s", "%s scope %s", "not %s", "%s*", "\"%s\"" }; #endif +#if 0 static const char *infix_pformats[] = { "", "(%s or %s%)", "(%s xor %s%)", "(%s and %s)", "(%s near %s%%s)", "(%s before %s%%s)", // %%s is loc to insert proximity " within %s", // proximity string to insert "%%s weight %s", "%s scope %s", "not %s", "%s*", "\"%s\"" }; +#endif // Order of these correspond to query_type_t enum in QueryGroup.hh static const char **formats[] = { fulcrum_formats, infix_formats }; @@ -387,15 +389,17 @@ QueryGroup::format (query_type_t query_type, QueryTerm *term) static char *buf[2]; // 48 is enough space to handle phrase, not, weight, and completion. int n = 48 + strlen (term->term_string()); + int buflen = n; buf[0] = (char *) malloc (n); buf[1] = (char *) malloc (n); n = 0; - s = strcpy (buf[n++], s); + int len = strlen(s); + *((char *) memcpy(buf[n++], s, len) + len) = '\0'; if (term->prefix() & QueryTerm::PFX_COMPLETE_BITS){ char * p = buf [n++ % 2]; - sprintf (p, formats[query_type][OPT_COMPLETE], s); + snprintf (p, buflen, formats[query_type][OPT_COMPLETE], s); s = p; } // If there's any interal spaces, we need to use the phase operator. @@ -404,13 +408,13 @@ QueryGroup::format (query_type_t query_type, QueryTerm *term) for (; *cp > 0x20; cp++); // looking for control chars if (*cp != '\0') { char *p = buf [n++ % 2]; - sprintf (p, infix_formats[OPT_PHRASE], s); + snprintf (p, buflen, infix_formats[OPT_PHRASE], s); s = p; /// alternating } if (term->prefix() & QueryTerm::PFX_NOT_BITS) { char *p = buf [n++ % 2]; - sprintf (p, formats[query_type][OPT_NOT], s); + snprintf (p, buflen, formats[query_type][OPT_NOT], s); s = p; } #else @@ -423,13 +427,13 @@ QueryGroup::format (query_type_t query_type, QueryTerm *term) if (TRUE || *t != '\0') { char *p = buf [n++ % 2]; - sprintf (p, formats[query_type][OPT_PHRASE], s); + snprintf (p, buflen, formats[query_type][OPT_PHRASE], s); s = p; } if (term->prefix() & QueryTerm::PFX_NOT_BITS) { char *p = buf [n++ % 2]; - sprintf (p, formats[query_type][OPT_NOT], s); + snprintf (p, buflen, formats[query_type][OPT_NOT], s); s = p; } #endif @@ -442,10 +446,10 @@ QueryGroup::format (query_type_t query_type, QueryTerm *term) { // First plug in the weight format string, then add the weight to it. char *p = buf [n++ % 2]; - sprintf (p, formats[query_type][OPT_WEIGHT], s); + snprintf (p, buflen, formats[query_type][OPT_WEIGHT], s); s = p; p = buf [n++ % 2]; - sprintf (p, s, term->weight()); + snprintf (p, buflen, s, term->weight()); s = p; } @@ -457,7 +461,7 @@ QueryGroup::format (query_type_t query_type, QueryTerm *term) { char *p = buf [n % 2]; - sprintf (p, s, term->term_string()); + snprintf (p, buflen, s, term->term_string()); s = p; } // Rember the point, since it will change after the write. @@ -499,16 +503,17 @@ QueryGroup::reduce (query_type_t query_type, if (opt == C_XOR) opsize *= 2; int fmt_length = strlen (formats[query_type][opt]) + strlen (formats[query_type][OPT_PROXIMITY]); - char *buf = (char*) malloc (fmt_length + opsize + 1); + int buflen = fmt_length + opsize + 1; + char *buf = (char*) malloc (buflen); - sprintf (buf, formats[query_type][opt], op1, op2, op1, op2); + snprintf (buf, buflen, formats[query_type][opt], op1, op2, op1, op2); // Take care of proximity if necessary. if (opt == C_NEAR || opt == C_BEFORE) { - char *b2 = (char *) malloc (fmt_length + opsize + 1); - sprintf (b2, buf, formats[query_type][OPT_PROXIMITY]); - sprintf (buf, b2, proximity); + char *b2 = (char *) malloc (buflen); + snprintf (b2, buflen, buf, formats[query_type][OPT_PROXIMITY]); + snprintf (buf, buflen, b2, proximity); free (b2); } diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.C b/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.C index 783662a7..229a86ae 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.C +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.C @@ -172,7 +172,7 @@ QueryTerm::cleanup_term_string() wclen = mbstowcs(wcbuf, f_term_string, length + 1); assert( *(wcbuf + wclen) == (TML_CHAR_TYPE)'\0' ); #else - strcpy((char *) wcbuf, f_term_string); + *((char *) memcpy((char *) wcbuf, f_term_string, length) + length) = '\0'; wclen = length ; #endif @@ -200,7 +200,8 @@ QueryTerm::cleanup_term_string() #ifdef UseWideChars wcstombs(f_term_string, first, length + 1); #else - strcpy(f_term_string, (const char *) first); + *((char *) memcpy(f_term_string, + (const char *) first, length) + length) = '\0'; #endif } delete[] wcbuf; diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.hh b/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.hh index 60576b7b..acfa21b0 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.hh +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryTerm.hh @@ -87,17 +87,17 @@ private: QueryGroup *f_parent; QueryTerm *f_previous; QueryTerm *f_next; - u_char f_type; union { QueryGroup *f_group_term; char *f_term_string; }; u_char f_prefix; u_char f_connective; - char *f_proximity; char *f_weight; + char *f_proximity; char *f_scope; bool f_term_string_fixed; + u_char f_type; // may need some way to verify the scope... static unsigned int f_caps; diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.C b/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.C index 0f9e4be0..cfcdcd89 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.C +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.C @@ -327,8 +327,7 @@ QueryTermView::create_ui() void QueryTermView::select_toggle (WCallback *wcb) { - XmToggleButtonCallbackStruct *tbcs = - (XmToggleButtonCallbackStruct *) wcb->CallData(); + (XmToggleButtonCallbackStruct *) wcb->CallData(); // notify someone about selection state... invert_colors(); @@ -716,7 +715,7 @@ QueryTermView::weight_changed() cursor_pos = w = 0; else cursor_pos = f_weight_field.GetInsertionPosition(); - sprintf(weight_string, "%d", w); + snprintf(weight_string, sizeof(weight_string), "%d", w); f_weight_field.SetString(weight_string); f_weight_field.SetInsertionPosition(cursor_pos); } diff --git a/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.hh b/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.hh index d442d35d..99be39d9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.hh +++ b/cde/programs/dtinfo/dtinfo/src/Query/QueryTermView.hh @@ -97,10 +97,13 @@ private: private: #ifdef UseQSearch QueryTerm *f_query_term; + WXmForm f_form; + WXmForm f_pws_form; + WXmTextField f_weight_field; + WXmLabelGadget f_weight_label; QueryGroupView *f_parent; QueryTermView *f_previous; QueryTermView *f_next; - WXmForm f_form; WXmOptionMenu f_prefix; union { WXmTextField *f_term_field; @@ -109,15 +112,15 @@ private: }; WXmArrowButton f_pw_button; WXmOptionMenu f_connective; - WXmForm f_pws_form; - WXmLabelGadget f_weight_label; - WXmTextField f_weight_field; #else QueryTerm *f_query_term; + WXmForm f_form; + WXmForm f_pws_form; + WXmLabelGadget f_proximity_label; + WXmTextField f_proximity_field; QueryGroupView *f_parent; QueryTermView *f_previous; QueryTermView *f_next; - WXmForm f_form; WXmToggleButton f_select_toggle; // What is this for? - 6/28/94 kamiya WXmOptionMenu f_prefix; union { @@ -127,9 +130,6 @@ private: }; WXmArrowButton f_pw_button; WXmOptionMenu f_connective; - WXmForm f_pws_form; - WXmLabelGadget f_proximity_label; - WXmTextField f_proximity_field; WXmTextField f_weight_field; WXmTextField f_scope_field; #endif diff --git a/cde/programs/dtinfo/dtinfo/src/Support/UtilityFunctions.C b/cde/programs/dtinfo/dtinfo/src/Support/UtilityFunctions.C index a9bb5320..9f80e9c5 100644 --- a/cde/programs/dtinfo/dtinfo/src/Support/UtilityFunctions.C +++ b/cde/programs/dtinfo/dtinfo/src/Support/UtilityFunctions.C @@ -29,7 +29,7 @@ UAS_List bookcaseList () { UAS_List rval; UAS_List rootLocs = UAS_Common::rootLocators (); - int i; + unsigned int i; for (i = 0; i < rootLocs.length(); i ++) { UAS_Pointer curDoc (UAS_Common::create (*(UAS_String*)rootLocs[i])); @@ -42,7 +42,7 @@ bookcaseList () { if (curDoc->type() == UAS_LIBRARY) { UAS_List kids = curDoc->children(); - for (int j = 0; j < kids.length(); j ++) { + for (unsigned int j = 0; j < kids.length(); j ++) { if (kids[j]->type() == UAS_BOOKCASE) { rval.insert_item(kids[j]); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.C index e2c21d87..2703c600 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.C @@ -54,7 +54,10 @@ UAS_BookcaseEntry::UAS_BookcaseEntry(UAS_Pointer &bookcase, f_name(0), f_base_num(-1) { - const char *bc_path = bookcase->id(); + int len; + + f_bookcase_name = bookcase->id(); + const char *bc_path = f_bookcase_name; if (! bc_path) { f_name = f_path = NULL; } @@ -62,11 +65,13 @@ UAS_BookcaseEntry::UAS_BookcaseEntry(UAS_Pointer &bookcase, const char *bc_name = UASbasename(bc_path); - f_name = new char[strlen(bc_name)+1]; - strcpy(f_name, bc_name); + len = strlen(bc_name); + f_name = new char[len + 1]; + *((char *) memcpy(f_name, bc_name, len) + len) = '\0'; - f_path = new char[strlen(bc_path)+1]; - strcpy (f_path, bc_path); + len = strlen(bc_path); + f_path = new char[len + 1]; + *((char *) memcpy(f_path, bc_path, len) + len) = '\0'; } f_infolib_id = bookcase->lid(); diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.hh b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.hh index d575a296..5bd418e8 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.hh +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_BookcaseEntry.hh @@ -47,6 +47,7 @@ class UAS_BookcaseEntry : public UAS_Base UAS_String f_infolib_id; // infolib id where bookcase resides UAS_String f_bookcase_id; // bookcase id + UAS_String f_bookcase_name;// infolib name where bookcase resides }; #endif diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Buffer.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Buffer.C index a9f7644d..7199023e 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Buffer.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Buffer.C @@ -23,6 +23,7 @@ // $XConsortium: UAS_Buffer.cc /main/3 1996/06/11 16:36:44 cde-hal $ #include #include +#include #include "UAS_Buffer.hh" // If necessary in the future, we can rework UAS_Buffer class to provide @@ -118,7 +119,7 @@ UAS_Buffer::write (const ssize_t integer) // Convert bytes from native to MSB first ordering. g_int = 0; - for (int i = 0; i < sizeof (int); i++) + for (unsigned int i = 0; i < sizeof (int); i++) if (g_byte_pos[i] != 0) g_intbuf[g_byte_pos[i]-1] = inbuf[i]; @@ -131,7 +132,7 @@ UAS_Buffer::read (int *integer) *integer = 0; // Convert from MSB first ordering to native. - for (int i = 0; i < sizeof (int); i++) + for (unsigned int i = 0; i < sizeof (int); i++) if (g_byte_pos[i] != 0) ((char *) integer)[i] = f_point[g_byte_pos[i]-1]; @@ -183,7 +184,7 @@ UAS_Buffer::write (const char *bytes, unsigned int size, unsigned int length) { int num_bytes = size * length; check_space (num_bytes); - for (int i = 0; i < size * length; i++) + for (unsigned int i = 0; i < size * length; i++) memcpy (f_point, bytes, num_bytes); f_point += num_bytes; f_end_of_data = f_point; @@ -194,7 +195,7 @@ UAS_Buffer::read (char **bytes, unsigned int size, unsigned int length) { int num_bytes = size * length; *bytes = f_point; - for (int i = 0; i < size * length; i++) + for (unsigned int i = 0; i < size * length; i++) f_point += num_bytes; } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Common.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Common.C index ce84fe3a..feab3d5d 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Common.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Common.C @@ -245,7 +245,7 @@ UAS_Common::subtree_size() int tree_size = 1; - for (int i = 0; i < num_kids; i++) { + for (unsigned int i = 0; i < num_kids; i++) { if (! (kids[i] == (const int)NULL)) tree_size += kids[i]->subtree_size(); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Factory.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Factory.C index 65376c31..cded1290 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Factory.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_Factory.C @@ -117,7 +117,7 @@ UAS_Factory::create (const UAS_String &locator) { UAS_Factory *theFactory = UAS_Factory::lookup(access); if (theFactory == 0) { char buf[BUFSIZ]; - (void) sprintf (buf, CATGETS(Set_UAS_Base, 2, + (void) snprintf (buf, sizeof(buf), CATGETS(Set_UAS_Base, 2, "Don't know how to create %s: objects"), (char*)access); @@ -165,7 +165,7 @@ UAS_Factory::getRootLocators () { UAS_PtrList&theList = *gFactoryList; for (int i = 0; i < theList.numItems(); i ++) { UAS_List cur = theList[i]->factory()->rootLocators(); - for (int j = 0; j < cur.length(); j ++) { + for (unsigned int j = 0; j < cur.length(); j ++) { rval.insert_item (cur[j]); } } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_List.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_List.C index 7c77d18f..d9bedb29 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_List.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_List.C @@ -84,7 +84,7 @@ UAS_List::length () const { template UAS_Pointer & UAS_List::item(unsigned int index) { - if (index >= fNumItems) { + if (index >= (unsigned int)fNumItems) { abort (); } return fItems[index]; @@ -163,7 +163,7 @@ UAS_List::insert_item (const T& theItem, int index) { template int UAS_List::set_item (const UAS_Pointer& theItem, unsigned int index) { - if (index >= fNumItems) + if (index >= (unsigned int)fNumItems) return 0; fItems[index] = theItem; return 1; @@ -180,7 +180,7 @@ UAS_List::set_item (const T& theItem, unsigned int index) { template int UAS_List::remove_item (unsigned int index) { - if (index >= fNumItems) + if (index >= (unsigned int)fNumItems) return 0; for (int i = index + 1; i < fNumItems; i ++) fItems[i - 1] = fItems[i]; @@ -191,7 +191,7 @@ UAS_List::remove_item (unsigned int index) { template int UAS_List::remove_item (const UAS_Pointer& theItem) { - for (unsigned int i = 0; i < fNumItems; i ++) { + for (unsigned int i = 0; i < (unsigned int)fNumItems; i ++) { if (fItems[i] == theItem) { return remove_item (i); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.C index 94f95e5b..70b07d70 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.C @@ -304,12 +304,13 @@ UAS_OQLParser::QRecognize() } char *tmpstr = new char [len + 1] ; - strcpy(tmpstr, fBuffer); + len = strlen(fBuffer); + *((char *) memcpy(tmpstr, fBuffer, len) + len) = '\0'; if (insert_completion) { tmpstr[fIndx - 1] = 0 ; // get rid of the * - strcat(tmpstr, "\\C-w"); + *((char *) memcpy(tmpstr + len - 1, "\\C-w", 4) + 4) = '\0'; } f_stack.push(tmpstr); @@ -414,7 +415,7 @@ UAS_OQLParser::GetNumber() while (*f_input_ptr == ' ') // skip whitespace f_input_ptr++ ; - while (c = *f_input_ptr){ + while ((c = *f_input_ptr)){ f_input_ptr++ ; if ((c < '0') || (c > '9')){ @@ -453,7 +454,7 @@ UAS_OQLParser::GetSymbol() c = *f_input_ptr ; } - while (c = *f_input_ptr) { + while ((c = *f_input_ptr)) { f_input_ptr++ ; if (c == '\\') diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.hh b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.hh index 30fd709c..34d07756 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.hh +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_OQLParser.hh @@ -75,10 +75,10 @@ private: private: // variables - const char* f_input_ptr; // olias query language string - OQL_Token fSymbol; + const char* f_input_ptr; // olias query language string + char fBuffer[1024]; unsigned int fIndx; diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchResults.hh b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchResults.hh index 6904a371..5d698c14 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchResults.hh +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchResults.hh @@ -32,10 +32,10 @@ class UAS_SearchResults : public UAS_Base { int num_docs() const { return f_ndocs; } protected: - int f_ndocs; UAS_Pointer f_query; UAS_Pointer f_scope_name; UAS_List f_results; + int f_ndocs; }; #endif diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchScope.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchScope.C index 8a04dd5e..65195aaa 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchScope.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_SearchScope.C @@ -43,8 +43,9 @@ UAS_SearchScope::UAS_SearchScope (const char *name, f_read_only (ro), f_infolib(NULL) { - f_name = new char[strlen(name) + 1 ]; - strcpy(f_name, name); + int len = strlen(name); + f_name = new char[len + 1]; + *((char *) memcpy(f_name, name, len) + len) = '\0'; f_bcases = bcases; @@ -83,7 +84,7 @@ UAS_SearchScope::name(const char *newname) delete f_name ; u_int len = strlen(newname); f_name = new char[len + 1] ; - strcpy(f_name,newname); + *((char *) memcpy(f_name, newname, len) + len) = '\0'; return name(); } @@ -91,8 +92,9 @@ void UAS_SearchScope::set_name (const char *name) { delete f_name; - f_name = new char[strlen(name) + 1 ]; - strcpy(f_name, name); + int len = strlen(name); + f_name = new char[len + 1]; + *((char *) memcpy(f_name, name, len) + len) = '\0'; static ScopeRenamed rename_msg; rename_msg.f_search_scope = this; send_message (rename_msg, 0); diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_String.C b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_String.C index 0375d14b..1aa4914b 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_String.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Base/UAS_String.C @@ -175,7 +175,7 @@ operator == (const UAS_String &s1, const char *cp) { if (!cp) { return s1.length() == 0; } - if (strlen (cp) != s1.length()) + if (strlen (cp) != (size_t)s1.length()) return 0; return !memcmp (cp, (char *) s1, s1.length()); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_BookcaseEntry.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_BookcaseEntry.C index 5ba3a691..b019a96c 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_BookcaseEntry.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_BookcaseEntry.C @@ -64,17 +64,17 @@ DtSR_BookcaseSearchEntry::DtSR_BookcaseSearchEntry( } int status; - if (status = DtSearchGetKeytypes((char*)*f_dbname, + if ((status = DtSearchGetKeytypes((char*)*f_dbname, &f_ktcount, - &f_keytypes)) { + &f_keytypes))) { #ifdef DEBUG fprintf(stderr, "(ERROR) DtSearchGetKeytypes failed\n"); abort(); #endif } - int i; #ifdef DEBUG + int i; printf("(DEBUG) ktcount = %d\n", f_ktcount); for (i = 0; i < f_ktcount; i++) { printf(" kt[%d]=%c,%s\n", i, f_keytypes[i].ktchar, f_keytypes[i].name); @@ -123,7 +123,7 @@ DtSR_BookcaseSearchEntry::search_zones(UAS_SearchZones& search_zones) return; } - int i; + unsigned int i; for (i = 0; i < bcases().length(); i++) { DtSR_BookcaseSearchEntry* bce = bcases()[i]; bce->_search_zones(search_zones); diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_Parser.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_Parser.C index ccf46737..51325f9e 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_Parser.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_Parser.C @@ -128,7 +128,7 @@ DtSR_Parser::se_construct(OQL_Token token, UAS_String str = CATGETS(Set_DtSR_Parser, 1, "The ``%s'' Search feature is not supported."); UAS_String opstr = CATGETS(Set_DtSR_Parser, 3, "weight"); - sprintf(msg, (char*)str, (char*)opstr); + snprintf(msg, sizeof(msg), (char*)str, (char*)opstr); UAS_String uas_msg = msg; throw(UAS_Search_Feature_Unavailable(uas_msg)); #endif @@ -169,7 +169,7 @@ DtSR_Parser::se_construct(OQL_Token token, UAS_String str = CATGETS(Set_DtSR_Parser, 1, "The ``%s'' Search feature is not supported."); UAS_String opstr = CATGETS(Set_DtSR_Parser, 2, "quoted phrase"); - sprintf(msg, (char*)str, (char*)opstr); + snprintf(msg, sizeof(msg), (char*)str, (char*)opstr); UAS_String uas_msg = msg; throw(UAS_Search_Feature_Unavailable(uas_msg)); @@ -190,7 +190,7 @@ DtSR_Parser::se_construct(OQL_Token token, UAS_String str = CATGETS(Set_DtSR_Parser, 1, "The ``%s'' Search feature is not supported."); UAS_String opstr = CATGETS(Set_DtSR_Parser, 4, "proximity"); - sprintf(msg, (char*)str, (char*)opstr); + snprintf(msg, sizeof(msg), (char*)str, (char*)opstr); UAS_String uas_msg = msg; throw(UAS_Search_Feature_Unavailable(uas_msg)); #endif @@ -231,7 +231,7 @@ DtSR_Parser::se_construct(OQL_Token token, UAS_String str = CATGETS(Set_DtSR_Parser, 1, "The ``%s'' Search feature is not supported."); UAS_String opstr = CATGETS(Set_DtSR_Parser, 5, "xor"); - sprintf(msg, (char*)str, (char*)opstr); + snprintf(msg, sizeof(msg), (char*)str, (char*)opstr); UAS_String uas_msg = msg; throw(UAS_Search_Feature_Unavailable(uas_msg)); #endif diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchEngine.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchEngine.C index fef2f6ff..da2ab01a 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchEngine.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchEngine.C @@ -270,7 +270,11 @@ DtSR_SearchEngine::~DtSR_SearchEngine() DtSR_SearchEngine::DtSR_SearchEngine() : f_dbnames(NULL), f_dbcount(0), f_valid_bc_map(0) { - char* ocf_path = mktemp((char*)".DtSR_XXXXXX"); + string ocf_tmpl = "/tmp/.DtSR_XXXXXX"; + int len = ocf_tmpl.size(); + char* ocf_path = new char [len + 1]; + *((char *) memcpy(ocf_path, ocf_tmpl.c_str(), len) + len) = '\0'; + ocf_path = mktemp(ocf_path); f_config_path = ocf_path; if (ocf_path) @@ -289,7 +293,8 @@ DtSR_SearchEngine::init(UAS_PtrList *bcases) if (bcases->numItems() == 0 || *(char*)f_config_path == '\0') return; - if (bcases->numItems() == DtSR_BookcaseSearchEntry::bcases().length()) { + if (bcases->numItems() == + (int) DtSR_BookcaseSearchEntry::bcases().length()) { // if sets of bookcases are same, you do not have to (re)init } @@ -442,8 +447,10 @@ apply_scope(DtSrResult* res, fine_scopes scope, const char* id, long &count) #endif DtSrResult *item = (DtSrResult *)malloc(sizeof(DtSrResult)); *item = *iter; // copy as it is - item->abstractp = (char*)malloc(strlen(iter->abstractp) + 1); - strcpy(item->abstractp, iter->abstractp); + int len = strlen(iter->abstractp); + item->abstractp = (char*)malloc(len + 1); + *((char *) memcpy(item->abstractp, + iter->abstractp, len) + len) = '\0'; item->link = NULL; if (rval == NULL) rval = tail = item; @@ -652,7 +659,7 @@ DtSR_SearchEngine::search(UAS_String oql, UAS_SearchScope& scope, bookid_dict[bookid] = True; } - for (i = 0; i < res->length(); i++) { + for (i = 0; i < (int) res->length(); i++) { // all these temporary variables are needed to get this // code to compile on novell @@ -675,7 +682,7 @@ DtSR_SearchEngine::search(UAS_String oql, UAS_SearchScope& scope, res->set_item(NULL, i); } - for (i = 0; i < res->length(); i++) { + for (i = 0; i < (int) res->length(); i++) { if (res->item(i) == (int)NULL) res->remove_item(i--); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResults.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResults.C index 94b3fb8c..3218f68c 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResults.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResults.C @@ -43,7 +43,7 @@ DtSR_SearchResults::DtSR_SearchResults UAS_List& list = *(UAS_List*)res; - for (int i = 0; i < list.length(); i++) { + for (unsigned int i = 0; i < list.length(); i++) { UAS_Pointer crude_ptr = list[i]; UAS_SearchResultsEntry &cptr2 = *crude_ptr; @@ -60,8 +60,8 @@ DtSR_SearchResults::sort(UAS_Pointer > res) *(UAS_List*)res; unsigned int list_length = Ref_list.length(); - for (int i = 0; i < list_length; i++) { - for (int j = i+1; j < list_length; j++) { + for (unsigned int i = 0; i < list_length; i++) { + for (unsigned int j = i+1; j < list_length; j++) { #ifdef USL // this line does nothing, but if you remove it @@ -83,7 +83,7 @@ UAS_Pointer > DtSR_SearchResults::create_results(int index, int nres) { // garbage input - if (nres == 0 || index >= f_results.length()) + if (nres == 0 || index >= (int) f_results.length()) return NULL; int n; @@ -122,7 +122,7 @@ DtSR_SearchResults::merge(UAS_Pointer & res) } f_ndocs = res->f_ndocs; - for (i = 0; i < res->f_stems_list.length(); i++) { + for (i = 0; i < (int) res->f_stems_list.length(); i++) { f_stems_list.insert_item(res->f_stems_list[i]); } res = NULL; @@ -177,7 +177,7 @@ DtSR_SearchResults::merge(UAS_Pointer & res) } // merge stems list - for (i = 0; i < res->f_stems_list.length(); i++) { + for (i = 0; i < (int) res->f_stems_list.length(); i++) { f_stems_list.insert_item(res->f_stems_list[i]); } @@ -193,7 +193,7 @@ DtSR_SearchResults::stems(int dbn) if (dbn < 0 || dbn >= db_count) return NULL; - int i; + unsigned int i; for (i = 0; i < f_stems_list.length(); i++) { if (f_stems_list[i]->dbn() == dbn) break; diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResultsEntry.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResultsEntry.C index 51e25940..088324e2 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResultsEntry.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/DtSR_SearchResultsEntry.C @@ -126,7 +126,7 @@ DtSR_SearchResultsEntry::overlay_proximity(DtSR_SearchZones::uas_zones uas_zone, if (uas_zone > UAS_SearchZones::uas_all) // range error return Beyond_Range; - if (f_zone & 0x01< 0; npat++, n_of_pats--) { char* del = (char *)strchr(patterns, '\n'); if (del != NULL) { // more pattern specified - pat_tbl[npat] = new char[del - patterns + 1]; - strncpy(pat_tbl[npat], patterns, del - patterns); - pat_tbl[npat][del - patterns] = '\0'; + len = del - patterns; + pat_tbl[npat] = new char[len + 1]; + *((char *) memcpy(pat_tbl[npat], patterns, len) + len) = '\0'; patterns = del + 1; } else { - pat_tbl[npat] = new char[strlen(patterns) + 1]; - strcpy(pat_tbl[npat], patterns); + int len = strlen(patterns); + pat_tbl[npat] = new char[len + 1]; + *((char *) memcpy(pat_tbl[npat], patterns, len) + len) = '\0'; patterns += strlen(patterns); assert( *patterns == '\0' ); } @@ -88,7 +89,7 @@ StringParser::brute_force(const char* text_in, int n_of_pats, // remove null and too long patterns int i; for (i = 0 ; pat_tbl[i]; i++) { - if (*(pat_tbl[i]) == '\0' || text_len < strlen(pat_tbl[i])) { + if (*(pat_tbl[i]) == '\0' || text_len < (int) strlen(pat_tbl[i])) { delete[] pat_tbl[i]; pat_tbl[i] = NULL; npat--; diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextTest.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextTest.C index 83194e52..d95b7199 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextTest.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextTest.C @@ -55,7 +55,7 @@ main(int argc, char** argv) size += 256; patterns = (char*) realloc(patterns, size); } - sprintf(patterns, "%s%s\n", patterns, argv[i]); + snprintf(patterns, size, "%s%s\n", patterns, argv[i]); } ostringstream text; diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/Util_Classes/Dict.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/Util_Classes/Dict.C index 598d8068..b9b2b3ed 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/Util_Classes/Dict.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/Util_Classes/Dict.C @@ -65,7 +65,7 @@ Dict::Dict() : def_key(kdef()), def_val(vdef()), head(NULL) template -Dict::Dict(const K& k, const V& v) : def_key(k), def_val(v), head(NULL) +Dict::Dict(const K& k, const V& v) : head(NULL), def_key(k), def_val(v) { init(); } diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Imakefile b/cde/programs/dtinfo/dtinfo/src/UAS/Imakefile index 37b3e4fd..b5ab8a2d 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Imakefile +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Imakefile @@ -9,9 +9,9 @@ LIBNAME=UAS XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' DependSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Factory.C b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Factory.C index f4146c12..d87da872 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Factory.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Factory.C @@ -70,7 +70,7 @@ MMDB_Factory::createMMDB (const UAS_String &infoLibPath) { if (!olias_db().validInfoLibPath(infoLibPath)) { UAS_ErrorMsg badPath; char buf[BUFSIZ]; - (void) sprintf (buf, CATGETS(Set_UAS_MMDB, 2, + (void) snprintf (buf, sizeof(buf), CATGETS(Set_UAS_MMDB, 2, "Invalid Infolib path: %s"), (char *) infoLibPath); badPath.fErrorMsg = buf; @@ -83,7 +83,7 @@ MMDB_Factory::createMMDB (const UAS_String &infoLibPath) { } mcatch_any() { #if 0 char buf[BUFSIZ]; - (void) sprintf (buf, CATGETS(Set_UAS_MMDB, 3, + (void) snprintf (buf, sizeof(buf), CATGETS(Set_UAS_MMDB, 3, "Ignoring invalid Infolib path: %s"), (char *) infoLibPath); UAS_ErrorMsg theError; @@ -122,8 +122,8 @@ MMDB_Factory::resolveLocator (const UAS_String &loc, returnMMDB = 0; returnInfoBase = 0; for (int i = 0; i < fMMDBList.numItems(); i ++) { - if (returnInfoBase = fMMDBList[i]->infolib()-> - getInfobaseByComponent(loc, info_lib::LOC)) { + if ((returnInfoBase = fMMDBList[i]->infolib()-> + getInfobaseByComponent(loc, info_lib::LOC))) { returnMMDB = fMMDBList[i]; return; } @@ -280,7 +280,7 @@ MMDB_Factory::initializeFactory (UAS_List& libs) { //for (int i = 0; i < fields.length(); i ++) { //(void) getMMDB (*(UAS_String*)fields[i]); //} - for (int i = 0; i < libs.length(); i ++) { + for (unsigned int i = 0; i < libs.length(); i ++) { // If this call doesn't create a new MMDB, it sends // an error message to the application. (void) getMMDB (*(UAS_String*)libs[i]); @@ -350,7 +350,8 @@ UAS_String MMDB_Factory::genInfolibName () { static int counter = 0; char buf[BUFSIZ]; - (void) sprintf (buf, CATGETS(Set_UAS_MMDB, 4, "DtMmdb Library %d"), ++counter); + (void) snprintf (buf, sizeof(buf), + CATGETS(Set_UAS_MMDB, 4, "DtMmdb Library %d"), ++counter); return UAS_String (buf); } @@ -414,7 +415,7 @@ MMDB_URL::locator (const UAS_String &in) { UAS_String access, rest; in.split (':', access, rest); UAS_List pairs = rest.splitFields ('&'); - for (int i = 0; i < pairs.length(); i ++) { + for (unsigned int i = 0; i < pairs.length(); i ++) { UAS_String key, value; pairs[i]->split ('=', key, value); installPair (key, value); diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Library.C b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Library.C index 9acfec81..ed0b3d6c 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Library.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_Library.C @@ -117,7 +117,7 @@ MMDB_Library::name () { if (f_name == "") { UAS_List kids = children(); - int i; + unsigned int i; for (i = 0; i < kids.length(); i++) { if (kids[i]->type() == UAS_BOOKCASE) @@ -126,8 +126,8 @@ MMDB_Library::name () { if (i < kids.length()) { char scratch[128]; - sprintf(scratch, CATGETS(Set_UAS_MMDB, 6, "File a Bug"), - (char *)kids[i]->id()); + snprintf(scratch, sizeof(scratch), + CATGETS(Set_UAS_MMDB, 6, "File a Bug"), (char *)kids[i]->id()); f_name = UAS_String(scratch); } } @@ -160,7 +160,7 @@ MMDB_Library::search_engine() { UAS_List bookcases = bookcaseList(); UAS_PtrList cList; - int i; + unsigned int i; #ifdef DEBUG for (i = 0; i < bookcases.length(); i++) fprintf(stderr, "(DEBUG) bookcases %d=%s\n", diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_StyleSheet.C b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_StyleSheet.C index df8ea618..6d8b1c55 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_StyleSheet.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/MMDB/MMDB_StyleSheet.C @@ -29,10 +29,10 @@ MMDB_StyleSheet::MMDB_StyleSheet (MMDB &theMMDB, info_base *ib, const oid_t &ssid, StyleSheetType sstype): - MMDB_Common (theMMDB, ib), UAS_StyleSheet (sstype), - fSSID (ssid), - fStyleSheet (ib, ssid) { + MMDB_Common (theMMDB, ib), + fStyleSheet (ib, ssid), + fSSID (ssid) { } MMDB_StyleSheet::~MMDB_StyleSheet () { diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Test/UserPreference.C b/cde/programs/dtinfo/dtinfo/src/UAS/Test/UserPreference.C index 994ee6c6..672cd436 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Test/UserPreference.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Test/UserPreference.C @@ -113,7 +113,7 @@ PreferenceRecord::form_filename() if (home == NULL) throw (Exception()); - sprintf (filename, "%s/.olias/preferences", home); + snprintf (filename, sizeof(filename), "%s/.olias/preferences", home); } return (filename); @@ -125,7 +125,7 @@ revert_from_backup (const char *filename) { // Failed, so look for the backup file. char backup[256], original[256]; - sprintf (backup, "%s.bak", filename); + snprintf (backup, sizeof(backup), "%s.bak", filename); struct stat file_info; if (stat (backup, &file_info) != -1 && diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Test/sdrv.C b/cde/programs/dtinfo/dtinfo/src/UAS/Test/sdrv.C index 49d70974..ea46b416 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Test/sdrv.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Test/sdrv.C @@ -138,8 +138,9 @@ config_environment( int argc, char **argv ) if (!ilib) print_usage_and_exit(argv[0], NULL); else { - tbuf = new char[128]; - sprintf(tbuf, "DTINFO_INFOLIB_PATH=%s", ilib); + int buflen = 128; + tbuf = new char[buflen]; + snprintf(tbuf, buflen, "DTINFO_INFOLIB_PATH=%s", ilib); putenv(tbuf); } } @@ -165,7 +166,7 @@ loadBasepathList(UAS_PtrList &basepathList) for (int i = 0; i < fields.length(); i ++) { ilib_path = (char *)*(fields[i]); - sprintf(names_buf, "%s/names.mmdb", ilib_path); + snprintf(names_buf, sizeof(names_buf), "%s/names.mmdb", ilib_path); if (stat(names_buf, &stat_buf) == -1) { cout << "\n\nWarning: library does not appear to be valid;\n"; cout << " couldn't stat file: " << names_buf << ";\n"; @@ -185,7 +186,7 @@ loadBasepathList(UAS_PtrList &basepathList) if (base_name[0] != '#') { new_len = strlen(ilib_path) + 1 + strlen(base_name) + 1; new_buf = new char[new_len]; - sprintf(new_buf, "%s/%s", ilib_path, base_name); + snprintf(new_buf, new_len, "%s/%s", ilib_path, base_name); basepathList.append(new_buf); } } @@ -434,7 +435,7 @@ readScopesFromPrefs(UAS_PtrList &baseList, } assert( strlen(name) > 0 ); // Get the specified preference. - sprintf (scratch, "Scope.%s", name); + snprintf (scratch, sizeof(scratch), "Scope.%s", name); StringPref scope (scratch); ON_DEBUG (printf ("RESTORING scope: %s\n", name)); ON_DEBUG (printf (" value = %s\n", scope.value())); diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/Test/uasdrv.C b/cde/programs/dtinfo/dtinfo/src/UAS/Test/uasdrv.C index b767b290..27768bf7 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/Test/uasdrv.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/Test/uasdrv.C @@ -60,7 +60,7 @@ printLocs (UAS_Pointer doc, int level) { if (level >= 2) { char buf[1024]; UAS_String loc = doc->id(); - (void) sprintf (buf, "mmdb:LOCATOR=%s", (char *) loc); + (void) snprintf (buf, sizeof(buf), "mmdb:LOCATOR=%s", (char *) loc); UAS_Pointer theDoc = UAS_Common::create(buf); cerr << (char *) theLoc << ", " << (char *) theDoc->title() << endl; } else { diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/Panner.c b/cde/programs/dtinfo/dtinfo/src/Widgets/Panner.c index fd56a80b..112c86e8 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/Panner.c +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/Panner.c @@ -72,14 +72,20 @@ #include /* for XawInitializeWidgetSet */ #include /* us */ #include /* for Min */ +#include /* for XmuDistinguishableColors() */ +#include /* for XmuCreateStippledPixmap */ #include /* for Motif */ #include /* for isascii() etc. */ -#include /* for atof() */ +#include /* for atof() */ #if defined(ISC) && defined(SYSV) && defined(SYSV386) && __STDC__ extern double atof(char *); #endif +extern void _XmDrawShadow (Display *display, Drawable d, GC top_GC, + GC bottom_GC, int size, int x, int y, + int width, int height); + static char defaultTranslations[] = ": start() \n\ : move() \n\ diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/Pixmap.c b/cde/programs/dtinfo/dtinfo/src/Widgets/Pixmap.c index 96b684a5..7aef1874 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/Pixmap.c +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/Pixmap.c @@ -42,9 +42,8 @@ static void Resize(); static void ReDisplay(); static XtGeometryResult QueryGeometry(); -static char *defaultTranslations[] = {""}; - /* +static char *defaultTranslations[] = {""}; static XtActionsRec actions[] = { }; diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/Restraint.c b/cde/programs/dtinfo/dtinfo/src/Widgets/Restraint.c index 866daabf..18f5ae4b 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/Restraint.c +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/Restraint.c @@ -391,10 +391,12 @@ GeometryManager (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) /* Only allow width changes to the width of the restraint. */ if (request->request_mode & CWWidth) - if (request->width == restraint->core.width) - yes = True; - else - almost = True; + { + if (request->width == restraint->core.width) + yes = True; + else + almost = True; + } /* Allow any height changes */ if (request->request_mode & CWHeight) diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/Simple.c b/cde/programs/dtinfo/dtinfo/src/Widgets/Simple.c index bd033102..1a46fe0b 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/Simple.c +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/Simple.c @@ -163,7 +163,7 @@ static void ClassPartInitialize(class) if (c->simple_class.change_sensitive == NULL) { char buf[BUFSIZ]; - sprintf(buf, + snprintf(buf, sizeof(buf), "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.", c->core_class.class_name); XtWarning(buf); @@ -179,7 +179,7 @@ static void Realize(w, valueMask, attributes) Mask *valueMask; XSetWindowAttributes *attributes; { - Pixmap border_pixmap; + Pixmap border_pixmap = 0; if (!XtIsSensitive(w)) { /* change border to gray; have to remember the old one, diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.c b/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.c index e3d73aed..0e898aa9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.c +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.c @@ -44,6 +44,8 @@ #include "TabButtonP.h" #include #include +#include +#include /* ************************************************************** * constant and type declarations @@ -402,10 +404,10 @@ ActivateCommon (Widget w, XEvent *event, String *params, Cardinal *num_params) /* If the event was a button event, make sure it occured within the tab. (The user could have released outside the tab.) */ if (event->type != ButtonRelease || - event->xbutton.x >= (int) -bw && - event->xbutton.y >= (int) -bw && - event->xbutton.x < (int) (tabw->core.width + bw) && - event->xbutton.y < (int) (tabw->core.height + bw)) + (event->xbutton.x >= (int) -bw && + event->xbutton.y >= (int) -bw && + event->xbutton.x < (int) (tabw->core.width + bw) && + event->xbutton.y < (int) (tabw->core.height + bw))) { /* Bail out if this is a multiple click and we're ignoring them. */ if (tabw->tab.click_count > 1 && @@ -745,7 +747,6 @@ static Boolean SetValues (Widget cw, Widget rw, Widget nw, ArgList args, Cardinal *num_args) { XyzTabButtonWidget current = (XyzTabButtonWidget) cw; - XyzTabButtonWidget request = (XyzTabButtonWidget) rw; Boolean redisplay = False; if (tabw->tab.arm_pixmap != current->tab.arm_pixmap && @@ -1035,7 +1036,7 @@ draw_shadow (Widget w) static void get_label_rect (Widget w, rect_t *rect) { - int dx, adjust; + int dx; short fill = 0; /* Make some room between shadows and label area if the colors are diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.h b/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.h index fdeed1c7..2a2e1ba7 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.h +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/TabButton.h @@ -84,5 +84,16 @@ extern char _XtSCRadius[]; } #endif +_XFUNCPROTOBEGIN + +extern void _XmCalcLabelDimensions(Widget wid); + +extern Boolean _XmFontListSearch (XmFontList fontlist, XmStringCharSet charset, + short *indx, XFontStruct **font_struct); + +extern Boolean _XmDifferentBackground (Widget w, Widget parent); + +_XFUNCPROTOEND + #endif /* _TabButton_h */ /* DO NOT ADD ANY LINES AFTER THIS #endif */ diff --git a/cde/programs/dtinfo/dtinfo/src/Widgets/WXmOpButton.h b/cde/programs/dtinfo/dtinfo/src/Widgets/WXmOpButton.h index 52423d5e..4ae0a8e9 100644 --- a/cde/programs/dtinfo/dtinfo/src/Widgets/WXmOpButton.h +++ b/cde/programs/dtinfo/dtinfo/src/Widgets/WXmOpButton.h @@ -63,10 +63,10 @@ public: protected: void insert_op (WCallback *wcb); - long &f_position; PRoot *&f_root; - insert_op_func_t f_insert; + long &f_position; is_sensitive_func_t f_is_sensitive; + insert_op_func_t f_insert; bool f_sensitive; }; diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/cgm.h b/cde/programs/dtinfo/dtinfo/src/cgm/cgm.h index 03ea10b5..29a2c922 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/cgm.h +++ b/cde/programs/dtinfo/dtinfo/src/cgm/cgm.h @@ -29,10 +29,10 @@ #include /* Xt toolkit */ #include "GraphicsP.h" -extern open_cgm_file(_DtGrStream *stream); /* in cgmio.c */ -extern open_cgm_buffer(_DtGrStream *stream); /* in cgmio.c */ +extern int open_cgm_file(_DtGrStream *stream); /* in cgmio.c */ +extern int open_cgm_buffer(_DtGrStream *stream); /* in cgmio.c */ /* in cgmcmds.c */ -extern xl_setup(Screen*, Display*, Window, int, Colormap, Visual*, GC, +extern int xl_setup(Screen*, Display*, Window, int, Colormap, Visual*, GC, Dimension*, Dimension*, Pixel**, int*, Pixmap*, unsigned short); /* the external entry point */ @@ -348,6 +348,7 @@ struct cmd_info_s { int byte_no; /* its byte position in file */ int p_len; /* its parameter length */ }; +#if 0 /* now put in the strings we will use for diagnostics and listings */ /* use B_ATTRSIZE since it is the largest Class (of 8) */ static char *cgm_name[8][B_ATTRSIZE] = { @@ -474,12 +475,14 @@ static char *cgm_name[8][B_ATTRSIZE] = { "Application Data" } }; +#endif + extern unsigned char *get_b_cmd(struct cmd_info_s*, _DtGrStream *stream); /* in cgmio.c */ -extern do_b_cmd(struct cmd_info_s*, unsigned char*,cgm_s_type*); +extern int do_b_cmd(struct cmd_info_s*, unsigned char*,cgm_s_type*); /* in cgmcmds.c */ -extern cgm_defs(cgm_s_type*), - cgm_assign(cgm_s_type*, cgm_s_type*); /* in cgmcommon.c */ +extern int cgm_defs(cgm_s_type*); /* in cgmcommon.c */ +extern int cgm_assign(cgm_s_type*, cgm_s_type*); /* in cgmcommon.c */ /* structure for the description of partial text pieces */ struct partialTextStruct { char *text; diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/cgmcmds.c b/cde/programs/dtinfo/dtinfo/src/cgm/cgmcmds.c index f8f90d95..95739b65 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/cgmcmds.c +++ b/cde/programs/dtinfo/dtinfo/src/cgm/cgmcmds.c @@ -37,9 +37,11 @@ static Visual *vis; static int visualClass, visualID, colormap_size, bits_per_rgb; static unsigned long redMask, greenMask, blueMask; static unsigned int visualDepth; +#ifdef DEBUG_VISUAL /* in case we need this for error messages */ static char *visualNames[6] = {"StaticGrey", "GrayScale", "StaticColor", "PseudoColor", "TrueColor", "DirectColor"}; +#endif static Dimension *ret_width; static Dimension *ret_height; static XColor my_colrs[MAXCOLRS]; @@ -74,7 +76,7 @@ static float ScaleFactor; /* all of these routines take the address of a pointer and step the pointer */ /* forward before they return */ /* the general Binary format string */ -static b_str(unsigned char **in_ptr, char **out_ptr) +static int b_str(unsigned char **in_ptr, char **out_ptr) { int p_len, data_left, i; unsigned char *my_ptr; @@ -240,10 +242,10 @@ static double b_real(dat_ptr, rprec) } /* XLib specific functions */ /* the setup routine */ -xl_setup(Screen *screen, Display *inDisplay, Window inWin, int inDepth, - Colormap inCmap, Visual *inVis, GC inGC, Dimension *in_width, - Dimension *in_height, Pixel **in_colrs, int *in_number, - Pixmap *inPixmap, unsigned short sf) +int xl_setup(Screen *screen, Display *inDisplay, Window inWin, int inDepth, + Colormap inCmap, Visual *inVis, GC inGC, Dimension *in_width, + Dimension *in_height, Pixel **in_colrs, int *in_number, + Pixmap *inPixmap, unsigned short sf) { XVisualInfo myTemp, *myInfo; int tmp; @@ -361,7 +363,6 @@ static Pixel getPixel(cgm_s_type *cgm_s, int iColrs[3]) Pixel bestPixel = 0; float dColrs[3]; float fDiv; - unsigned short r, g, b; int i, bestI; unsigned int bestDif, tempDif; /* normalize colours for X routines */ @@ -456,35 +457,35 @@ static void setIndex(cgm_s_type *cgm_s, int index, GC inGC) /* now the functions that do the work */ /* Delimiters */ /* Begin Metafile */ -static bmf(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int bmf(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* nothing for now */ return 1; } /* End Metafile */ -static emf(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int emf(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* nothing for now */ return 1; } /* Begin Picture */ -static bpic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int bpic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* nothing for now */ return 1; } /* Begin Picture Body */ -static bpicbody(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int bpicbody(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { XPoint myClipRect[4]; GC clearGC; /* look at VDC extent and figure out Pixmap size and scaling */ float x0, x1, y0, y1, w, h, maxWH; - int i; + if (cgm_s->vdctype) { /* real VDC's */ x0 = cgm_s->vdcextent[0].r; y0 = cgm_s->vdcextent[1].r; @@ -553,8 +554,8 @@ static bpicbody(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return(1); } /* End Picture */ -static epic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int epic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* need to fill out the pixels array */ int i; @@ -565,7 +566,7 @@ static epic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, } /* Metafile Descriptors */ /* Metafile Version */ -static mfversion(dat_ptr, cmd_ptr, cgm_s) +static int mfversion(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -574,7 +575,7 @@ static mfversion(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Metafile Descriptor */ -static mfdescrip(dat_ptr, cmd_ptr, cgm_s) +static int mfdescrip(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -583,7 +584,7 @@ static mfdescrip(dat_ptr, cmd_ptr, cgm_s) return 1; } /* VDC type */ -static vdctype(dat_ptr, cmd_ptr, cgm_s) +static int vdctype(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -595,7 +596,7 @@ static vdctype(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Integer Precision */ -static intprec(dat_ptr, cmd_ptr, cgm_s) +static int intprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -604,7 +605,7 @@ static intprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Real Precision */ -static realprec(dat_ptr, cmd_ptr, cgm_s) +static int realprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -616,7 +617,7 @@ static realprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Index Precision */ -static indexprec(dat_ptr, cmd_ptr, cgm_s) +static int indexprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -625,7 +626,7 @@ static indexprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Colour Precision */ -static colprec(dat_ptr, cmd_ptr, cgm_s) +static int colprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -634,7 +635,7 @@ static colprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Colour Index Precision */ -static cindprec(dat_ptr, cmd_ptr, cgm_s) +static int cindprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -643,7 +644,7 @@ static cindprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Maximum Colour Index */ -static maxcind(dat_ptr, cmd_ptr, cgm_s) +static int maxcind(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -652,7 +653,7 @@ static maxcind(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Colour Value Extent */ -static cvextent(dat_ptr, cmd_ptr, cgm_s) +static int cvextent(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -670,7 +671,7 @@ static cvextent(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Metafile Element List */ -static mfellist(dat_ptr, cmd_ptr, cgm_s) +static int mfellist(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -687,13 +688,13 @@ static mfellist(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Metafile Defaults Replacement, a complex element */ -static mfdefrep(dat_ptr, cmd_ptr, cgm_s) +static int mfdefrep(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; { struct cmd_info_s new_cmd; /* for the new commands */ - int i, ret = 1, new_len, b_to_move, data_left; + int i, new_len, b_to_move, data_left; unsigned char *out_ptr, *end_ptr, *new_ptr, *start_ptr; /* in this element, many other elements can be encoded in its */ @@ -760,7 +761,7 @@ static mfdefrep(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Font List, store the data, but ignored for now */ -static fontlist(dat_ptr, cmd_ptr, cgm_s) +static int fontlist(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -782,7 +783,7 @@ static fontlist(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Character Set List, stored but ignored */ -static charlist(dat_ptr, cmd_ptr, cgm_s) +static int charlist(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -807,7 +808,7 @@ static charlist(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Character Announcer */ -static charannounce(dat_ptr, cmd_ptr, cgm_s) +static int charannounce(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -817,7 +818,7 @@ static charannounce(dat_ptr, cmd_ptr, cgm_s) } /* Picture Descriptors */ /* Scaling Mode */ -static scalmode(dat_ptr, cmd_ptr, cgm_s) +static int scalmode(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -830,7 +831,7 @@ static scalmode(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Colour Selection Mode */ -static colselmode(dat_ptr, cmd_ptr, cgm_s) +static int colselmode(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -840,7 +841,7 @@ static colselmode(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Line Width Specification Mode */ -static lwidspecmode(dat_ptr, cmd_ptr, cgm_s) +static int lwidspecmode(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -849,7 +850,7 @@ static lwidspecmode(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Marker Size Specification Mode */ -static marksizspecmode(dat_ptr, cmd_ptr, cgm_s) +static int marksizspecmode(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -858,7 +859,7 @@ static marksizspecmode(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Edge Width Specification Mode */ -static edwidspecmode(dat_ptr, cmd_ptr, cgm_s) +static int edwidspecmode(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -867,7 +868,7 @@ static edwidspecmode(dat_ptr, cmd_ptr, cgm_s) return 1; } /* VDC Extent */ -static vdcextent(dat_ptr, cmd_ptr, cgm_s) +static int vdcextent(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -885,7 +886,7 @@ static vdcextent(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Background Colour */ -static backcolr(dat_ptr, cmd_ptr, cgm_s) +static int backcolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -898,7 +899,7 @@ static backcolr(dat_ptr, cmd_ptr, cgm_s) } /* Control Elements */ /* VDC Integer Precision */ -static vdcintprec(dat_ptr, cmd_ptr, cgm_s) +static int vdcintprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -907,7 +908,7 @@ static vdcintprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* VDC Real Precision */ -static vdcrprec(dat_ptr, cmd_ptr, cgm_s) +static int vdcrprec(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -919,7 +920,7 @@ static vdcrprec(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Auxiliary Colour */ -static auxcolr(dat_ptr, cmd_ptr, cgm_s) +static int auxcolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -935,7 +936,7 @@ static auxcolr(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Transparency */ -static transp(dat_ptr, cmd_ptr, cgm_s) +static int transp(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -973,8 +974,8 @@ unsigned int getXPoints(unsigned char *dat_ptr, return noPts; } /* Clipping Rectangle */ -static cliprect(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int cliprect(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { int noPts; XPoint *myPtr = NULL, myClipRect[4]; @@ -1010,10 +1011,9 @@ static cliprect(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return 1; } /* Clipping Indicator */ -static clipindic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int clipindic(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { - Region r; cgm_s->clipindic = b_gsint(&dat_ptr, 16); if (cgm_s->clipindic) { XSetRegion(display, lineGC, clipRegion); @@ -1061,7 +1061,7 @@ unsigned int getXSegments(unsigned char *dat_ptr, return noSegments; } /* Polyline */ -static polyline(dat_ptr, cmd_ptr, cgm_s) +static int polyline(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -1074,10 +1074,10 @@ static polyline(dat_ptr, cmd_ptr, cgm_s) return(1); } /* Disjoint Polyline, on/off segments */ -static dispoly(dat_ptr, cmd_ptr, cgm_s) - unsigned char *dat_ptr; - struct cmd_info_s *cmd_ptr; - cgm_s_type *cgm_s; +static int dispoly(dat_ptr, cmd_ptr, cgm_s) +unsigned char *dat_ptr; +struct cmd_info_s *cmd_ptr; +cgm_s_type *cgm_s; { int noSegments; XSegment *myPtr = NULL; @@ -1089,7 +1089,7 @@ static dispoly(dat_ptr, cmd_ptr, cgm_s) return(1); } /* Polymarker */ -static polymarker(dat_ptr, cmd_ptr, cgm_s) +static int polymarker(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -1158,13 +1158,12 @@ void doText(cgm_s_type *cgm_s) textX = textY = textW = textH = 0; } /* Regular Text */ -static text(dat_ptr, cmd_ptr, cgm_s) +static int text(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; { int final_flag; - unsigned char *out_ptr; partialText *newPtr, *myPtr; /* clean up in case we didn't get a final flag (e.g., old NCAR) */ if (textPtr) doText(cgm_s); @@ -1199,7 +1198,7 @@ static text(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Restricted Text */ -static restext(dat_ptr, cmd_ptr, cgm_s) +static int restext(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -1239,17 +1238,14 @@ static restext(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Appended Text */ -static apptext(dat_ptr, cmd_ptr, cgm_s) +static int apptext(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; { - int i, ret, final_flag; partialText *newPtr, *myPtr; - if (!textPtr) return; /* can't append if there's nothing started ! */ + if (!textPtr) return 0; /* can't append if there's nothing started ! */ - /* first the final/not final flag */ - final_flag = b_gsint(&dat_ptr, 16); /* make some memory */ newPtr = (partialText *) malloc(sizeof(partialText)); newPtr->text = NULL; @@ -1271,7 +1267,7 @@ static apptext(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Polygon */ -static polygon(dat_ptr, cmd_ptr, cgm_s) +static int polygon(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -1292,12 +1288,12 @@ static polygon(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Polyset */ -static polyset(dat_ptr, cmd_ptr, cgm_s) +static int polyset(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; { - int i, j, noPts, *vPtr, lastFill; + int i, noPts, *vPtr, lastFill; XPoint *myPtr; /* get the number of pts */ @@ -1376,10 +1372,11 @@ case 1: if(!(temp=(((done + 1) * prec) % 8))) out = *ptr++ & 1; \ else out = (*ptr >> (8 - temp)) & 1; break;} /* get a packed list */ static void getListPixels(unsigned char *datPtr, cgm_s_type *cgm_s, - int nx, int ny, int prec, Pixel *retPtr) + int nx, int ny, int prec, Pixel *retPtr) { unsigned char *startPtr; - int rowSize, i, j, k, maxCol, done, iCol, iColrs[3]; + int rowSize, i, j, k, done, iColrs[3]; + int iCol = 0; /* may be in direct colour mode or indexed colour mode */ switch (cgm_s->colselmode) { case D_C_M: /* direct colour */ @@ -1417,12 +1414,13 @@ static void getListPixels(unsigned char *datPtr, cgm_s_type *cgm_s, } /* get a run-length encoded list */ static void getRLPixels(unsigned char *dat_ptr, cgm_s_type *cgm_s, - int nx, int ny, int prec, Pixel *retPtr) + int nx, int ny, int prec, Pixel *retPtr) { static unsigned char bitMask[8] = {255, 127, 63, 31, 15, 7, 3, 1}; unsigned char *rowPtr; Pixel myPixel; - int i, j, k, done, iCol, iColrs[3], bitOffset,count; + int i, j, k, done, iColrs[3], bitOffset,count; + int iCol = 0; Pixel tP; for (i=0; iltype, lineGC); } /* Line Width */ -static lwidth(dat_ptr, cmd_ptr, cgm_s) +static int lwidth(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2191,7 +2188,7 @@ static lwidth(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Line Colour */ -static lcolr(dat_ptr, cmd_ptr, cgm_s) +static int lcolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2212,7 +2209,7 @@ static lcolr(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Marker Type */ -static mtype(dat_ptr, cmd_ptr, cgm_s) +static int mtype(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2223,7 +2220,7 @@ static mtype(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Marker Size */ -static msize(dat_ptr, cmd_ptr, cgm_s) +static int msize(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2244,7 +2241,7 @@ static msize(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Marker Colour */ -static mcolr(dat_ptr, cmd_ptr, cgm_s) +static int mcolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2263,8 +2260,8 @@ static mcolr(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Text Font Index, ignored at the moment */ -static tfindex(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int tfindex(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* get the text font index */ cgm_s->tfindex = b_gsint(&dat_ptr, cgm_s->indexprec); @@ -2272,8 +2269,8 @@ static tfindex(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return 1; } /* Text Precision, ignored at the moment; stroke everything */ -static tprec(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int tprec(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* get the text font index */ cgm_s->tprec = b_gsint(&dat_ptr, 16); @@ -2281,24 +2278,24 @@ static tprec(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return 1; } /* Character Expansion Factor */ -static cexpfac(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int cexpfac(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { cgm_s->cexpfac = b_real(&dat_ptr, &(cgm_s->realprec)); return 1; } /* Character Space */ -static cspace(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int cspace(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { cgm_s->cspace = b_real(&dat_ptr, &(cgm_s->realprec)); return 1; } /* Text Colour */ -static tcolr(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int tcolr(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { int i, index; @@ -2321,16 +2318,16 @@ static tcolr(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return 1; } /* Character Height */ -static cheight(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int cheight(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { /* just 1 VDC to grab */ cgm_s->cheight.i = getVDC(&dat_ptr, cgm_s); return 1; } /* Character Orientation */ -static corient(unsigned char *dat_ptr,struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int corient(unsigned char *dat_ptr,struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { int i; @@ -2346,16 +2343,16 @@ static corient(unsigned char *dat_ptr,struct cmd_info_s *cmd_ptr, return 1; } /* Text Path */ -static tpath(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int tpath(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { cgm_s->tpath = b_gsint(&dat_ptr, 16); return 1; } /* Text Alignment */ -static talign(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, - cgm_s_type *cgm_s) +static int talign(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, + cgm_s_type *cgm_s) { int i; @@ -2368,7 +2365,7 @@ static talign(unsigned char *dat_ptr, struct cmd_info_s *cmd_ptr, return 1; } /* Character Set Index */ -static csetindex(dat_ptr, cmd_ptr, cgm_s) +static int csetindex(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2378,7 +2375,7 @@ static csetindex(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Alternate Character Set Index */ -static altcsetindex(dat_ptr, cmd_ptr, cgm_s) +static int altcsetindex(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2388,7 +2385,7 @@ static altcsetindex(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Interior Style */ -static intstyle(dat_ptr, cmd_ptr, cgm_s) +static int intstyle(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2412,7 +2409,7 @@ static intstyle(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Fill Colour */ -static fillcolr(dat_ptr, cmd_ptr, cgm_s) +static int fillcolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2433,7 +2430,7 @@ static fillcolr(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Hatch Index */ -static hatchindex(dat_ptr, cmd_ptr, cgm_s) +static int hatchindex(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2443,7 +2440,7 @@ static hatchindex(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Pattern Index */ -static patindex(dat_ptr, cmd_ptr, cgm_s) +static int patindex(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2453,7 +2450,7 @@ static patindex(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Edge Type */ -static etype(dat_ptr, cmd_ptr, cgm_s) +static int etype(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2462,7 +2459,7 @@ static etype(dat_ptr, cmd_ptr, cgm_s) return setLineType(cgm_s->etype, edgeGC); } /* Edge Width */ -static ewidth(dat_ptr, cmd_ptr, cgm_s) +static int ewidth(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2487,7 +2484,7 @@ static ewidth(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Edge Colour */ -static ecolr(dat_ptr, cmd_ptr, cgm_s) +static int ecolr(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2508,7 +2505,7 @@ static ecolr(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Edge Visibility */ -static evis(dat_ptr, cmd_ptr, cgm_s) +static int evis(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2522,7 +2519,7 @@ static evis(dat_ptr, cmd_ptr, cgm_s) return 1; } /* Colour Table */ -static coltab(dat_ptr, cmd_ptr, cgm_s) +static int coltab(dat_ptr, cmd_ptr, cgm_s) unsigned char *dat_ptr; struct cmd_info_s *cmd_ptr; cgm_s_type *cgm_s; @@ -2546,8 +2543,8 @@ static coltab(dat_ptr, cmd_ptr, cgm_s) return 1; } /* this is the external entry point */ -do_b_cmd(struct cmd_info_s *cmd_ptr, unsigned char *dat_ptr, - cgm_s_type *cgm_s) +int do_b_cmd(struct cmd_info_s *cmd_ptr, unsigned char *dat_ptr, + cgm_s_type *cgm_s) { /* for convenience define and argument list macro */ #define ARG_LIST dat_ptr,cmd_ptr, cgm_s diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/cgmcommon.c b/cde/programs/dtinfo/dtinfo/src/cgm/cgmcommon.c index 1f273c9d..b233b2a1 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/cgmcommon.c +++ b/cde/programs/dtinfo/dtinfo/src/cgm/cgmcommon.c @@ -24,7 +24,7 @@ /* this is the module of common routines for the CGM interpreter */ #include "cgm.h" /* our defs */ /* this routine sets a cgm state variable to its defaults */ -cgm_defs(cgm_s_type *cgm_s) +int cgm_defs(cgm_s_type *cgm_s) { int i; @@ -142,7 +142,7 @@ cgm_defs(cgm_s_type *cgm_s) return(1); } /* this routine sets one cgm state equal to another */ -cgm_assign(cgm_s_type *cgm_1, cgm_s_type *cgm_2) +int cgm_assign(cgm_s_type *cgm_1, cgm_s_type *cgm_2) { int i; diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/cgmio.c b/cde/programs/dtinfo/dtinfo/src/cgm/cgmio.c index 34930834..2971ef86 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/cgmio.c +++ b/cde/programs/dtinfo/dtinfo/src/cgm/cgmio.c @@ -37,9 +37,9 @@ static unsigned char *begin_ptr, *endin_ptr, *in_ptr; static int io_debug = 0, recs_got, bytes_read; /* function to get an input record, return no of bytes read */ -static get_cgm_rec(unsigned char *start_ptr, - int buffer_size, - _DtGrStream *cgmptr) +static int get_cgm_rec(unsigned char *start_ptr, + int buffer_size, + _DtGrStream *cgmptr) { int bytes_got; @@ -51,7 +51,7 @@ static get_cgm_rec(unsigned char *start_ptr, } /* function to open the CGM file */ /* stream is a file stream */ -open_cgm_file(_DtGrStream *stream) +int open_cgm_file(_DtGrStream *stream) { int bytes_got; fprintf(stderr, "Attempting to open file, %s\n", stream->source.file.filename); @@ -76,7 +76,7 @@ open_cgm_file(_DtGrStream *stream) /* function to prepare the CGM buffer */ /* stream is a buffer stream */ -open_cgm_buffer(_DtGrStream *stream) +int open_cgm_buffer(_DtGrStream *stream) { int bytes_got; @@ -92,8 +92,8 @@ open_cgm_buffer(_DtGrStream *stream) } /* function to get a number of binary format bytes */ -static get_b_bytes(unsigned char *out_ptr, - int bytes_wanted, _DtGrStream *stream) +static int get_b_bytes(unsigned char *out_ptr, + int bytes_wanted, _DtGrStream *stream) { int bytes_got, i; if (!begin_ptr) { diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/cgmtext.c b/cde/programs/dtinfo/dtinfo/src/cgm/cgmtext.c index 8ed71d4d..c0bb0502 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/cgmtext.c +++ b/cde/programs/dtinfo/dtinfo/src/cgm/cgmtext.c @@ -168,7 +168,7 @@ void draw_cgm_text(Display *inDis, Drawable inDraw, GC inGC, partialText *inText) { XPoint myPts[128]; /* should be plenty */ - int offset, noPts, w1, w2, x, y, w = 0, h = 0; + int offset, noPts, w1, w2, x, y, w = 0; unsigned char *hPtr; char *inS; float charSize, cMod = 1; @@ -221,7 +221,7 @@ void draw_cgm_text(Display *inDis, Drawable inDraw, GC inGC, inS = myText->text; charSize = cMod * myText->cheight / 24.0; /* chars are in a 24 pt box */ while (*inS) { /* step thru the string */ - if ((*inS < 0) || ((offset = h_array[*inS]) < 0)) + if ((*inS < 0) || ((offset = h_array[(int)*inS]) < 0)) { /* illegal character */ ++inS; /* step over */ continue; diff --git a/cde/programs/dtinfo/dtinfo/src/cgm/getcgm.c b/cde/programs/dtinfo/dtinfo/src/cgm/getcgm.c index 9d65680f..05f394a3 100644 --- a/cde/programs/dtinfo/dtinfo/src/cgm/getcgm.c +++ b/cde/programs/dtinfo/dtinfo/src/cgm/getcgm.c @@ -49,7 +49,6 @@ processCGM( int *ret_num_colors, _DtGrContext *context) { - int thisPage; unsigned char *dat_ptr; /* declare two CGM state variables, one active, one for defaults */ static cgm_s_type cgm_act, cgm_def, *cgm_s_ptr; @@ -94,7 +93,6 @@ processCGM( cgm_def.tPixel = BlackPixelOfScreen(screen); /* now go thru the input file */ - thisPage = 0; do { /* get next command */ dat_ptr = get_b_cmd(&cmd_info, stream); diff --git a/cde/programs/dtinfo/dtinfo/src/external-api/comm.c b/cde/programs/dtinfo/dtinfo/src/external-api/comm.c index 5223de31..4c9c6fb8 100644 --- a/cde/programs/dtinfo/dtinfo/src/external-api/comm.c +++ b/cde/programs/dtinfo/dtinfo/src/external-api/comm.c @@ -71,6 +71,7 @@ encode_display_event (OliasDisplayEvent *event, XtPointer *value, unsigned long *length, int *format) { unsigned char *stream; + int len; *length = 1 + strlen (event->infobase) + strlen (event->locator) + 2; /* Xt will free this memory. */ @@ -80,9 +81,11 @@ encode_display_event (OliasDisplayEvent *event, /* Encode event in packed byte format. */ *stream++ = (unsigned char) event->type; - strcpy (stream, event->infobase); - stream += strlen (event->infobase) + 1; - strcpy (stream, event->locator); + len = strlen (event->infobase); + *((char *) memcpy(stream, event->infobase, len) + len) = '\0'; + stream += len + 1; + len = strlen (event->locator); + *((char *) memcpy(stream, event->locator, len) + len) = '\0'; } diff --git a/cde/programs/dtinfo/dtinfo/src/external-api/init.c b/cde/programs/dtinfo/dtinfo/src/external-api/init.c index 8273266d..9907a850 100644 --- a/cde/programs/dtinfo/dtinfo/src/external-api/init.c +++ b/cde/programs/dtinfo/dtinfo/src/external-api/init.c @@ -75,7 +75,7 @@ _olias_initialize (Widget toplevel) /* -------- Create a unique selection property for this client. -------- */ - sprintf (buf, OLIAS_CLIENT_ATOM_FMT, XtWindow (toplevel)); + snprintf (buf, sizeof(buf), OLIAS_CLIENT_ATOM_FMT, XtWindow (toplevel)); _olias_client_atom = XInternAtom (XtDisplay (toplevel), buf, False); /* -------- Set up communication handling routines. -------- */ diff --git a/cde/programs/dtinfo/dtinfo/src/external-api/oliasmsg.c b/cde/programs/dtinfo/dtinfo/src/external-api/oliasmsg.c index c7568d32..88e8061c 100644 --- a/cde/programs/dtinfo/dtinfo/src/external-api/oliasmsg.c +++ b/cde/programs/dtinfo/dtinfo/src/external-api/oliasmsg.c @@ -83,7 +83,7 @@ print_usage_and_exit (char *pname, char *arg) static void parse_args (int argc, char *argv[]) { - int i; + int i. len; if (argc == 1) print_usage_and_exit (argv[0], NULL); @@ -102,7 +102,8 @@ parse_args (int argc, char *argv[]) print_usage_and_exit(argv[0], argv[i]); } else - strcpy (loc_buf, argv[i]); + len = MIN(strlen(argv[i]), BUFSIZE -1); + *((char *) memcpy (loc_buf, argv[i], len) + len) = '\0'; } diff --git a/cde/programs/dtinfo/dtinfo/src/main.C b/cde/programs/dtinfo/dtinfo/src/main.C index f05c2745..32509644 100644 --- a/cde/programs/dtinfo/dtinfo/src/main.C +++ b/cde/programs/dtinfo/dtinfo/src/main.C @@ -180,7 +180,7 @@ DisplayDocList( UAS_List docs ) // set up to display the documents - for (int i = 0; i < docs.length(); i++) + for (unsigned int i = 0; i < docs.length(); i++) { (*(docs[i])).split( '-', start_doc, end_doc ) ; doc_locator = start_doc.length() ? start_doc : end_doc ; @@ -191,9 +191,10 @@ DisplayDocList( UAS_List docs ) // allocate memory for a normal c string to pass // through to the work proc - document = new char[doc_locator.length()]; + int len = doc_locator.length(); + document = new char[len + 1]; temp = (char *)doc_locator; - strcpy(document, temp); + *((char *) memcpy(document, temp, len) + len) = '\0'; XtAppAddWorkProc( window_system().app_context(), DisplayNode_wp, document) ; @@ -223,15 +224,16 @@ PrintDocList( UAS_List docs ) char *document; char *temp; - for (int i = 0; i < docs.length(); i++) + for (unsigned int i = 0; i < docs.length(); i++) { (*(docs[i])).split( '-', start_doc, end_doc ) ; doc_locator = start_doc.length() ? start_doc : end_doc ; // only print cares about a range of locators; - document = new char[doc_locator.length()]; + int len = doc_locator.length(); + document = new char[len + 1]; temp = (char *)doc_locator; - strcpy(document, temp); + *((char *) memcpy(document, temp, len) + len) = '\0'; // ... needs expansion of range here if present ... XtAppAddWorkProc( window_system().app_context(), @@ -318,7 +320,7 @@ main(int argc, char **argv) mcatch (Exception &, e) { char buffer[256]; - sprintf (buffer, + snprintf (buffer, sizeof(buffer), "Internal Error: Exception got away.\nFile: %s, Line: %d", #ifdef C_API e.file(), e.line()); diff --git a/cde/programs/dtinfo/dtinfo/wwl/Imakefile b/cde/programs/dtinfo/dtinfo/wwl/Imakefile index e2a61a92..60b462da 100644 --- a/cde/programs/dtinfo/dtinfo/wwl/Imakefile +++ b/cde/programs/dtinfo/dtinfo/wwl/Imakefile @@ -7,9 +7,9 @@ SUBDIRS=src XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtinfo/dtinfo/wwl/src/WArgList.C b/cde/programs/dtinfo/dtinfo/wwl/src/WArgList.C index 62323297..07d6583e 100644 --- a/cde/programs/dtinfo/dtinfo/wwl/src/WArgList.C +++ b/cde/programs/dtinfo/dtinfo/wwl/src/WArgList.C @@ -157,7 +157,7 @@ WArgList::WArgList (String name, XtArgVal value, ...) Add (name, value); va_list argv; va_start (argv, value); - while (str = va_arg(argv, String)) + while ((str = va_arg(argv, String))) Add (str, va_arg (argv, XtArgVal)); va_end (argv); } @@ -204,7 +204,7 @@ WArgList::Add (String name, XtArgVal value) Boolean found = False; // Loop til a matching name is found or we get to the end of the array - for (int i=0; !found && iname, name) == 0 ) { found = True; diff --git a/cde/programs/dtinfo/dtinfo/wwl/src/WXmString.C b/cde/programs/dtinfo/dtinfo/wwl/src/WXmString.C index aae5a91e..d42163dc 100644 --- a/cde/programs/dtinfo/dtinfo/wwl/src/WXmString.C +++ b/cde/programs/dtinfo/dtinfo/wwl/src/WXmString.C @@ -107,7 +107,8 @@ XmStringUngenerate(XmString string, XmStringCharSet tag, char** ret) while (XmStringGetNextSegment(context, &text, &tag, &dir, &sep)) { if (text) { - int textlen = strlen(text) + (sep? 1 : 0); + len = strlen(text); + int textlen = len + (sep? 1 : 0); { // buffer size adjustment int bufsize_required = bufsize; while (buflen + textlen > bufsize_required) @@ -117,9 +118,10 @@ XmStringUngenerate(XmString string, XmStringCharSet tag, char** ret) bufsize = bufsize_required; } } - strcat(buf, text); + slen = strlen(buf); + *((char *) memcpy(buf + slen, text, len) + len) = '\0'; if (sep) - strcat(buf, "\n"); + *((char *) memcpy(buf + slen + 1, "\n", 1) + 1) = '\0'; buflen += textlen; XtFree(text); -- 2.25.1