Use POSIX macros for linux
[oweals/cde.git] / cde / programs / dtstyle / Backdrop.c
index cc7dc8c6e258b6d1a9456679006b9b9c8ace4df0..2168a13a1d8b5f9df81bf220195035e6d7226a8e 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  * Floor, Boston, MA 02110-1301 USA
  */
@@ -594,10 +594,12 @@ static
   
   /* read the directory $HOME/.dt/backdrops */
   string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops") + 1);
-  sprintf(string, "%s/.dt/backdrops", style.home);
-  ReadBitmapDirectory(string);
   if (string != NULL)
+  {
+    sprintf(string, "%s/.dt/backdrops", style.home);
+    ReadBitmapDirectory(string);
     XtFree(string);
+  }
 
   if (backdrops.tmpNumBitmaps == 0)
     {
@@ -737,12 +739,20 @@ ReadBitmapDirectory(
             filep = readdir(dirp);
             continue; 
         }
-
        
-        /* strip suffix off filename */
         name = (char *) XtMalloc(strlen(filep->d_name) + 1);
         strcpy (name, filep->d_name);
-        (void)strtok(name, ".");
+
+        /* strip suffix off filename if it's a .pm or .bm
+         * motif requires other formats like jpg, png etc to
+         * have the extension on to work with the XmGetPixmap() calls */
+        if(strlen(name) > 3
+           && (0 == strcmp(name + strlen(name) - 3, ".pm")
+               || 0 == strcmp(name + strlen(name) - 3, ".bm")))
+        {
+          (void)strtok(name, ".");
+        }
+
 
         /* check for duplicates */
         duplicate = 0;