dtcm: Resolve CID 87408
[oweals/cde.git] / cde / programs / dtcm / dtcm / find.c
index ad81a662c820bece2bc6bb9ac50cea7598dba947..f413ef82c56b3e92ac8488b862f3df64ff78ebb3 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $XConsortium: find.c /main/9 1996/11/21 19:42:36 drk $ */
 /*
  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
@@ -38,6 +60,9 @@
 
 #define XOS_USE_XT_LOCKING
 #define X_INCLUDE_TIME_H
+#if defined(linux)
+#undef SVR4
+#endif
 #include <X11/Xos_r.h>
 
 static void layout_labels(Widget, Widget, Widget, Widget);
@@ -562,8 +587,8 @@ XmPushButtonCallbackStruct *cbs;
 
        astr = XmTextGetString(f->apptstr);
 
-        if (astr == NULL || *astr == NULL) {
-               sprintf(message, catgets(c->DT_catd, 1, 290, "Specify Appt String to Match."));
+        if (astr == NULL || *astr == '\0') {
+               sprintf(message, "%s", catgets(c->DT_catd, 1, 290, "Specify Appt String to Match."));
                set_message(f->find_message, message);
                 return;
         }
@@ -588,12 +613,12 @@ XmPushButtonCallbackStruct *cbs;
                if (start == DATE_BBOT)
                        start = get_bot();
                else if (start == DATE_AEOT) {
-                        sprintf(message,  catgets(c->DT_catd, 1, 810, "Please enter a start date after 1/1/1970"));
+                        sprintf(message, "%s", catgets(c->DT_catd, 1, 810, "Please enter a start date after 1/1/1970"));
                         set_message(f->find_message, message);
                         return;
                 }
                else if (start <= 0) {
-                        sprintf(message,  catgets(c->DT_catd, 1, 811, "Malformed start date"));
+                        sprintf(message, "%s", catgets(c->DT_catd, 1, 811, "Malformed start date"));
                         set_message(f->find_message, message);
                         return;
                 }
@@ -604,18 +629,18 @@ XmPushButtonCallbackStruct *cbs;
                if (end_of_time == DATE_AEOT)
                        end_of_time = real_eot;
                else if (end_of_time == DATE_BBOT) {
-                        sprintf(message,  catgets(c->DT_catd, 1, 812, "Please enter an end date before 1/1/2038"));
+                        sprintf(message, "%s", catgets(c->DT_catd, 1, 812, "Please enter an end date before 1/1/2038"));
                         set_message(f->find_message, message);
                         return;
                 }
                else if (end_of_time <= 0) {
-                        sprintf(message,  catgets(c->DT_catd, 1, 813, "Malformed end date"));
+                        sprintf(message, "%s", catgets(c->DT_catd, 1, 813, "Malformed end date"));
                         set_message(f->find_message, message);
                         return;
                 }
 
                if (start >= end_of_time) {
-                       sprintf(message, catgets(c->DT_catd, 1, 713, "You must choose a begin date before the end date."));
+                       sprintf(message, "%s", catgets(c->DT_catd, 1, 713, "You must choose a begin date before the end date."));
                        set_message(f->find_message, message);
                        return;
                }
@@ -641,7 +666,7 @@ XmPushButtonCallbackStruct *cbs;
        _DtTurnOnHourGlass(f->frame);
         for (; stop <= end_of_time;) {
                setup_range(&range_attrs, &ops, &range_count, start, stop,
-                           CSA_TYPE_EVENT, NULL, B_FALSE, c->general->version);
+                           CSA_TYPE_EVENT, 0, B_FALSE, c->general->version);
                stat = csa_list_entries(c->cal_handle, range_count, range_attrs, ops, &num_entries, &entries, NULL);
 
                if (stat != CSA_SUCCESS) {
@@ -659,7 +684,7 @@ XmPushButtonCallbackStruct *cbs;
                                return;
                        }
 
-                       for (j = 0; appt->what->value->item.string_value[j] != NULL; j++)
+                       for (j = 0; appt->what->value->item.string_value[j] != '\0'; j++)
                                if (strncasecmp(astr, &(appt->what->value->item.string_value[j]),
                                        comparison_length) == 0) {
                                        new_tick = (Tick_list *) ckalloc(sizeof(Tick_list));
@@ -727,7 +752,7 @@ XmPushButtonCallbackStruct *cbs;
         }  /* end for range.end loop */
 
        if (match_total == 0)
-               sprintf(message, catgets(c->DT_catd, 1, 291, "Appointment Not Found."));
+               sprintf(message, "%s", catgets(c->DT_catd, 1, 291, "Appointment Not Found."));
        else if (match_total == 1)
                sprintf(message, catgets(c->DT_catd, 1, 631, "%d match found"), match_total);
        else