Deal with the fact that modern compilers assume different scoping rules
authorJon Trulson <jon@radscan.com>
Thu, 9 Aug 2012 18:18:30 +0000 (12:18 -0600)
committerJon Trulson <jon@radscan.com>
Thu, 9 Aug 2012 18:18:30 +0000 (12:18 -0600)
Patch from Pascal Stumpf <Pascal.Stumpf@cubes.de>:

So here are all the patches that deal with the fact that modern
compilers assume different scoping rules for variables declared in for
loops.  On Linux, -fpermissive has been added as a compiler flag to
compensate for this old C code, but I think it is the wrong approach.

Sorry, couldn't help sneaking in a || defined(CSRG_BASED) and some casts
needed for other reasons ...

cde/lib/DtSvc/DtCodelibs/buf.C
cde/lib/tt/bin/ttdbserverd/dm_server.C
cde/programs/dtmail/dtmail/ComposeCmds.C
cde/programs/dtmail/dtmail/DmxPrintOptions.C
cde/programs/dtmail/dtmail/RoamMenuWindow.C
cde/programs/dtmail/libDtMail/RFC/V3BodyPart.C
cde/programs/dtsearchpath/libCliSrv/cstring.C

index 13abb899bd9a3afb99cd59bd5c7f238d4b8f589e..e13e202093515adc19ae7442416b8e5d018d92e5 100644 (file)
@@ -118,7 +118,8 @@ _SHXbuf::reset(boolean g, boolean comp)
 char **
 _SHXbuf::vector()
 {
-    for (int i = 0; i < vec.size(); i++)
+    int i;
+    for (i = 0; i < vec.size(); i++)
        vec[i] = &buf[long(vec[i])];
 
     vec[i] = NULL;
index bd0992724e78e02d2f0a98cec4a9ff2fccc258a0..0b4eb9c804a59867f3be00e23966605de8e1f550 100644 (file)
@@ -1079,7 +1079,8 @@ _tt_isopen_1(_Tt_isopen_args *args, SVCXPRT * /* transp */)
 
        int l = db_path.len();
        int tl = strlen("TT_DB");
-       for (int j = 0; j<l; j++) {
+       int j;
+       for (j = 0; j<l; j++) {
                if (0==strncmp((char *)db_path+j,"TT_DB",tl)) {
                        break;
                }
index bdb36ffa53a5556d57eea470e195085723b365ff..d3117b3599076df01ec1d207c818f2c989f53702 100644 (file)
@@ -289,8 +289,9 @@ char *
 ComposeFamily::valueToAddrString(DtMailValueSeq & value)
 {
     int max_len = 0;
+    int count;
 
-    for (int count = 0; count < value.length(); count++) {
+    for (count = 0; count < value.length(); count++) {
        max_len += strlen(*(value[count]));
     }
 
index 471ca5ce7b7dc543cff755248b9bec38a7648cee..15011af2037aa742c1c079924173e9cf55050d78 100644 (file)
@@ -210,6 +210,7 @@ DmxPrintOptions::DmxPrintOptions (
     char               **strings;
     void               **data;
     XmString           xms;
+    int                        i, j, nhdrftrs;
 
     _iom_array = new DtVirtArray<IndexedOptionMenu *>(10);
     _propui_array = new DtVirtArray<PropUiItem *>(10);
@@ -240,7 +241,7 @@ DmxPrintOptions::DmxPrintOptions (
     nitems = DMX_ARRAY_SIZE(hdrftr_values);;
     strings = (char **) XtMalloc( nitems * sizeof(char*) );
     data = (void **) XtMalloc( nitems * sizeof(void*) );
-    for (int i=0; i<nitems; i++)
+    for (i=0; i<nitems; i++)
     {
         data[i] = (void*) hdrftr_values[i].prop_string;
         strings[i] = GETMSG(
@@ -265,7 +266,7 @@ DmxPrintOptions::DmxPrintOptions (
     //
     menu_buttons = NULL;
     _DtPrintHdrFtrFrameMenuWidgets( _hdrftr_frame, NULL, NULL, &menu_buttons);
-    for (int j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
+    for (j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
     {
         w = _DtPrintHdrFtrFrameEnumToWidget(
                                _hdrftr_frame,
@@ -671,7 +672,7 @@ DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
     char       *marginSpec = NULL;
     XtEnum     parseError;
     Widget     text;
-#if defined(linux)
+#if defined(linux) || defined(CSRG_BASED)
     _DtPrintMarginEnum which = *((_DtPrintMarginEnum *) data);
 #else
     _DtPrintMarginEnum which = (_DtPrintMarginEnum) data;
index b28f702aa0ed60bd1ccbc13f5cd6a4332ba43d14..5636d1c5b09be82d0b7f599077d76008bb8fb35c 100644 (file)
 
 #include "SortCmd.hh"
 
-extern force( Widget );
+extern int force( Widget );
 
  static const char * NormalIcon = "DtMail";
  static const char * EmptyIcon = "DtMnone";
@@ -725,7 +725,7 @@ RoamMenuWindow::createWorkArea(Widget parent)
     printHelpId("form1", form1);
     /* add help callback */
     // XtAddCallback(form1, XmNhelpCallback, HelpCB, helpId);
-    XtAddCallback(form1, XmNhelpCallback, HelpCB, DTMAILWINDOWID);
+    XtAddCallback(form1, XmNhelpCallback, HelpCB, (void *)DTMAILWINDOWID);
 
     panedW = XtCreateManagedWidget("panedW", xmPanedWindowWidgetClass,
                                   form1, NULL, 0);
@@ -757,7 +757,7 @@ RoamMenuWindow::createWorkArea(Widget parent)
     /* add help callback */
     // XtAddCallback(_rowOfLabels, XmNhelpCallback, HelpCB, helpId);
     XtAddCallback(
-       _rowOfLabels, XmNhelpCallback, HelpCB, DTMAILWINDOWROWOFLABELSID);
+       _rowOfLabels, XmNhelpCallback, HelpCB, (void *)DTMAILWINDOWROWOFLABELSID);
 
     XtVaSetValues(_rowOfLabels, 
                  XmNrightAttachment,XmATTACH_FORM, 
@@ -792,7 +792,7 @@ RoamMenuWindow::createWorkArea(Widget parent)
 
     XtAddCallback(
        _list->get_scrolling_list(), XmNhelpCallback, 
-       HelpCB, DTMAILMSGLISTID);
+       HelpCB, (void *)DTMAILMSGLISTID);
 
     XtVaSetValues(_list->get_scrolling_list(), XmNuserData, this, NULL);
     _rowOfButtons =
@@ -2863,7 +2863,7 @@ RoamMenuWindow::addToRowOfButtons()
                                TRUE, this );
     ci  = new ButtonInterface (_rowOfButtons, _delete_button);
     w = ci->baseWidget();
-    XtAddCallback(w, XmNhelpCallback, HelpCB, DTMAILDELBTNID);
+    XtAddCallback(w, XmNhelpCallback, HelpCB, (void *)DTMAILDELBTNID);
     XtVaSetValues(w,
        XmNleftAttachment, XmATTACH_FORM,
        XmNtopAttachment, XmATTACH_FORM,
@@ -2880,7 +2880,7 @@ RoamMenuWindow::addToRowOfButtons()
                        TRUE, this );
     ci  = new ButtonInterface (_rowOfButtons, _next_button);
     w = ci->baseWidget();
-    XtAddCallback(w, XmNhelpCallback, HelpCB, DTMAILNEXTBTNID);
+    XtAddCallback(w, XmNhelpCallback, HelpCB, (void *)DTMAILNEXTBTNID);
     XtVaSetValues(w,
        XmNleftAttachment, XmATTACH_WIDGET,
        XmNleftWidget, prev_widget,
@@ -2899,7 +2899,7 @@ RoamMenuWindow::addToRowOfButtons()
                                TRUE, this );
     ci  = new ButtonInterface (_rowOfButtons, _previous_button);
     w = ci->baseWidget();
-    XtAddCallback(w, XmNhelpCallback, HelpCB, DTMAILPREVBTNID);
+    XtAddCallback(w, XmNhelpCallback, HelpCB, (void *)DTMAILPREVBTNID);
     XtVaSetValues(w,
        XmNleftAttachment, XmATTACH_WIDGET,
        XmNleftWidget, prev_widget,
@@ -2920,7 +2920,7 @@ RoamMenuWindow::addToRowOfButtons()
                                FALSE );
     ci  = new ButtonInterface (_rowOfButtons, _replySender_button);
     w = ci->baseWidget();
-    XtAddCallback(w, XmNhelpCallback, HelpCB, DTMAILREPLYBTNID);
+    XtAddCallback(w, XmNhelpCallback, HelpCB, (void *)DTMAILREPLYBTNID);
     XtVaSetValues(w,
        XmNleftAttachment, XmATTACH_WIDGET,
        XmNleftWidget, prev_widget,
@@ -2938,7 +2938,7 @@ RoamMenuWindow::addToRowOfButtons()
                                TRUE, TRUE, this);
     ci  = new ButtonInterface (_rowOfButtons, _print_button);
     w = ci->baseWidget();
-    XtAddCallback(w, XmNhelpCallback, HelpCB, DTMAILPRINTBTNID);
+    XtAddCallback(w, XmNhelpCallback, HelpCB, (void *)DTMAILPRINTBTNID);
     XtVaSetValues(w,
        XmNleftAttachment, XmATTACH_WIDGET,
        XmNleftWidget, prev_widget,
@@ -3292,7 +3292,7 @@ RoamMenuWindow::createContainerList()
 void
 RoamMenuWindow::createOpenContainerList(CmdList * open_container)
 {
-    int                        ncontainers;
+    int                        ncontainers, i;
     char               *container_name;
     ContainerMenuCmd   *container_cmd;
 
@@ -3327,7 +3327,7 @@ RoamMenuWindow::createOpenContainerList(CmdList * open_container)
     _open_container_containerlist =
       new DtVirtArray<ContainerMenuCmd*>(ncontainers);
 
-    for (int i=0; i<ncontainers; i++)
+    for (i=0; i<ncontainers; i++)
     {
        container_name = (*_user_containerlist)[i]->containerName();
        if (NULL != container_name)
@@ -3490,7 +3490,7 @@ RoamMenuWindow::construct_file_menu()
 void
 RoamMenuWindow::createCopyList(CmdList * copy_to)
 {
-    int                        ncontainers;
+    int                        ncontainers, i;
     char               *container_name;
     ContainerMenuCmd   *container_cmd;
 
@@ -3550,7 +3550,7 @@ RoamMenuWindow::createCopyList(CmdList * copy_to)
     _copyto_containerlist =
       new DtVirtArray<ContainerMenuCmd *> (ncontainers);
 
-    for (int i=0; i<ncontainers; i++)
+    for (i=0; i<ncontainers; i++)
     {
        container_name = (*_user_containerlist)[i]->containerName();
        if (NULL != container_name)
@@ -3930,7 +3930,7 @@ RoamMenuWindow::construct_compose_menu()
 void
 RoamMenuWindow::construct_move_menu()
 {
-    int                        ncontainers;
+    int                        ncontainers, i;
     char               *container_name;
     ContainerMenuCmd   *container_cmd;
 
@@ -3967,7 +3967,7 @@ RoamMenuWindow::construct_move_menu()
       delete _move_containerlist;
     _move_containerlist = new DtVirtArray<ContainerMenuCmd *> (ncontainers);
 
-    for (int i=0; i<ncontainers; i++)
+    for (i=0; i<ncontainers; i++)
     {
        container_name = (*_user_containerlist)[i]->containerName();
        if (NULL != container_name)
index 007d7261c271373ab8c1e1da0684fb7688b211b2..0d4fa1ba32e93cbb11f68d4cfe3398e81c8b1d5b 100644 (file)
@@ -328,9 +328,11 @@ V3BodyPart::checksum(DtMailEnv & error)
 static int
 countTypes(char ** types)
 {
+    int count;
+
     if (NULL == types) return 0;
 
-    for (int count = 0; *types; types++, count++) {
+    for (count = 0; *types; types++, count++) {
        continue;
     }
 
index be3067fccf02ddb26374e2c7ca62e87f069aa801..dc735e23e1e9ba63cc1a0ba63aaef3a9f9053656 100644 (file)
@@ -510,12 +510,14 @@ CTokenizedString::~CTokenizedString()
 CString CTokenizedString::next()
 {
 char * q  = 0;
+char * p;
+int i;
 
     if (cursor) {
        if (strlen(delimiter) == 1)
            q = strchr(cursor,delimiter[0]);
        else {
-           for (int i = 0; i < strlen(cursor); i++)
+           for (i = 0; i < strlen(cursor); i++)
                if (strchr(delimiter,cursor[i])) {
                    q = &cursor[i];
                    break;
@@ -533,7 +535,7 @@ char * q  = 0;
        // eliminate trailing white space
 
        if (skipWhiteSpace) {
-           for (char *p = q; isspace(*(p-1)); p--);
+           for (p = q; isspace(*(p-1)); p--);
            *p = 0;
        }
        CString result(cursor);