Updated to compile on MacOSX 10.10

Pascal J. Bourguignon [2015-08-29 17:32]
Updated to compile on MacOSX 10.10
Filename
ascii-utilities/sources/capitalize.c
ascii-utilities/sources/encoding.c
ascii-utilities/sources/sortchars.c
encoding/sources/encoding.c
environment/sources/environment.c
line-utilities/sources/lines.c
mpa/sources/make-person-aliases.c
random-stat/sources/random-stat.cc
diff --git a/ascii-utilities/sources/capitalize.c b/ascii-utilities/sources/capitalize.c
index 552348d..a39548e 100644
--- a/ascii-utilities/sources/capitalize.c
+++ b/ascii-utilities/sources/capitalize.c
@@ -6,7 +6,7 @@ int main(int argc,char** argv)
     int i;
     for(i=1;i<argc;i++){
         if(isalpha(argv[i][0])){
-            argv[i][0]=toupper(argv[i][0]);
+            argv[i][0]=(char)toupper(argv[i][0]);
         }
         printf("%s\n",argv[i]);
     }
diff --git a/ascii-utilities/sources/encoding.c b/ascii-utilities/sources/encoding.c
index 899875b..0d04295 100644
--- a/ascii-utilities/sources/encoding.c
+++ b/ascii-utilities/sources/encoding.c
@@ -109,19 +109,19 @@ LEGAL
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libgen.h>
+
+#include <unistd.h>

-#if defined(NeXT)
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#if defined(NeXT)
 #include <libc.h>
 #endif
-#if defined(AIX)
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-#if defined(linux)
-#include <unistd.h>
-#include <sys/stat.h>
+
+#if defined(linux) || defined(MACOSX)
+#include <errno.h>
 #endif

 #include <concatenate.h>
diff --git a/ascii-utilities/sources/sortchars.c b/ascii-utilities/sources/sortchars.c
index a0cd600..f5102ab 100644
--- a/ascii-utilities/sources/sortchars.c
+++ b/ascii-utilities/sources/sortchars.c
@@ -129,7 +129,7 @@ int main(int argc,char** argv)
                 int             ii;
                 for(ii=0;ii<len;ii++){
                     if(isupper(buffer[ii])){
-                        buffer[ii]=tolower(buffer[ii]);
+                        buffer[ii]=(char)tolower(buffer[ii]);
                     }
                 }
             }
diff --git a/encoding/sources/encoding.c b/encoding/sources/encoding.c
index e77ca5c..626a75d 100644
--- a/encoding/sources/encoding.c
+++ b/encoding/sources/encoding.c
@@ -109,6 +109,8 @@ LEGAL
 #include <string.h>
 #include <libgen.h>

+#include <unistd.h>
+
 #include <sys/types.h>
 #include <sys/stat.h>

@@ -116,13 +118,7 @@ LEGAL
 #include <libc.h>
 #endif

-#if defined(AIX)
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-
-#if defined(linux) || defined(MacOSX)
-#include <unistd.h>
+#if defined(linux) || defined(MACOSX)
 #include <errno.h>
 #else
 extern int      errno;
@@ -398,7 +394,6 @@ int main(int argc,char** argv,char** envp)
     FILE*               fout;
     int                 i;
     int                 err;
-    struct stat         filestatus;
     char                TempName[256];
     BOOLEAN             nooption;
     BOOLEAN             fromIsDetermined;
@@ -613,6 +608,7 @@ int main(int argc,char** argv,char** envp)
                         if(err==0){
                             err=link(TempName,argv[i]);
                             if(err==0){
+                                struct stat filestatus;
                                 err=stat("temp[nema]",&filestatus);
                                 if(err==0){
                                     int r=chown(argv[i],filestatus.st_uid,
diff --git a/environment/sources/environment.c b/environment/sources/environment.c
index 796a6f6..a63473b 100644
--- a/environment/sources/environment.c
+++ b/environment/sources/environment.c
@@ -36,11 +36,13 @@ LEGAL
 ******************************************************************************/
 #include <stdio.h>
 #include <string.h>
-#include <malloc.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <pwd.h>
+#ifndef MACOSX
+#include <malloc.h>
+#endif

     const char* pname="environment"; /*default name*/

diff --git a/line-utilities/sources/lines.c b/line-utilities/sources/lines.c
index 204d091..bb2b6aa 100644
--- a/line-utilities/sources/lines.c
+++ b/line-utilities/sources/lines.c
@@ -67,7 +67,7 @@ LEGAL
             i++;
         }
         if(i>0){
-            strcmp(line,line+i);
+            strcpy(line,line+i);
         }
     }/*chop_nl*/

diff --git a/mpa/sources/make-person-aliases.c b/mpa/sources/make-person-aliases.c
index a89253e..165380c 100644
--- a/mpa/sources/make-person-aliases.c
+++ b/mpa/sources/make-person-aliases.c
@@ -367,7 +367,7 @@ static void string_tolower(char* word)
 {
     while(*word!='\0'){
         if(isupper(*word)){
-            *word=tolower(*word);
+            *word=(char)tolower(*word);
         }
         word++;
     }
@@ -377,7 +377,7 @@ static void string_tolower(char* word)
 static void string_capitalize(char* word)
 {
     if(islower(*word)){
-        *word=toupper(*word);
+        *word=(char)toupper(*word);
     }
     string_tolower(word+1);
 }/*string_capitalize*/
diff --git a/random-stat/sources/random-stat.cc b/random-stat/sources/random-stat.cc
index eee1b95..afc0e17 100644
--- a/random-stat/sources/random-stat.cc
+++ b/random-stat/sources/random-stat.cc
@@ -35,9 +35,12 @@ LEGAL

 extern "C"{
 #include <stdio.h>
+#include <limits.h>
+#ifndef MACOSX
 #include <values.h>
+#endif
+#define BIT_PER_BYTE    (CHAR_BIT)
 }
-#define BIT_PER_BYTE    (CHARBITS)

 // typedef char bool;
 #define true ((bool)(0==0))
ViewGit