@@ -24,37 +24,25 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2424
2525/* POSIX module implementation */
2626
27- #ifdef _M_IX86
28- #define NT
29- /* NT may be defined externally as well. If it is defined, the module is
30- actually called 'nt', not 'posix', and some functions don't exist. */
31- #endif
32-
3327#include "allobjects.h"
3428#include "modsupport.h"
3529#include "ceval.h"
3630
3731#include <string.h>
3832#include <errno.h>
39-
40- #ifndef macintosh
4133#include <sys/types.h>
4234#include <sys/stat.h>
43- #endif
4435
4536#include "mytime.h" /* For clock_t on some systems */
4637
4738#ifdef HAVE_FCNTL_H
4839#include <fcntl.h>
49- #endif
40+ #endif /* HAVE_FCNTL_H */
5041
42+ #ifndef NT
5143#ifdef HAVE_UNISTD_H
5244#include <unistd.h>
5345#else /* !HAVE_UNISTD_H */
54-
55- #ifdef macintosh
56- #include "macdefs.h"
57- #else
5846extern int mkdir PROTO ((const char * , mode_t ));
5947extern int chdir PROTO ((const char * ) );
6048extern int rmdir PROTO ((const char * ) );
@@ -69,40 +57,40 @@ extern int unlink PROTO((const char *));
6957extern int pclose PROTO ((FILE * ) );
7058#ifdef HAVE_SYMLINK
7159extern int symlink PROTO ((const char * , const char * ) );
72- #endif
60+ #endif / _ HAVE_SYMLINK * /
7361#ifdef HAVE_LSTAT
7462extern int lstat PROTO ((const char * , struct stat * ) );
75- #endif
76- #endif /* macintosh */
63+ #endif /* HAVE_LSTAT */
7764#endif /* !HAVE_UNISTD_H */
65+ #endif /* !NT */
7866
79- #if 1
67+ #ifndef NT
8068/* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */
8169extern int rename ();
8270extern int pclose ();
8371extern int lstat ();
8472extern int symlink ();
85- #endif
73+ #endif /* !NT */
8674
8775#ifdef HAVE_UTIME_H
8876#include <utime.h>
89- #endif
77+ #endif /* HAVE_UTIME_H */
9078
9179#ifdef HAVE_SYS_TIMES_H
9280#include <sys/times.h>
93- #endif
81+ #endif /* HAVE_SYS_TIMES_H */
9482
9583#ifdef HAVE_SYS_PARAM_H
9684#include <sys/param.h>
97- #endif
85+ #endif /* HAVE_SYS_PARAM_H */
9886
9987#ifdef HAVE_SYS_UTSNAME_H
10088#include <sys/utsname.h>
101- #endif
89+ #endif /* HAVE_SYS_UTSNAME_H */
10290
10391#ifndef MAXPATHLEN
10492#define MAXPATHLEN 1024
105- #endif
93+ #endif /* MAXPATHLEN */
10694
10795/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
10896#if defined(DIRENT ) || defined(_POSIX_VERSION )
@@ -132,11 +120,13 @@ extern int symlink();
132120
133121#ifdef OS2
134122#include <io.h>
135- #endif
123+ #endif /* OS2 */
136124
137125/* Return a dictionary corresponding to the POSIX environment table */
138126
127+ #ifndef NT
139128extern char * * environ ;
129+ #endif /* !NT */
140130
141131static object *
142132convertenviron ()
@@ -306,7 +296,7 @@ posix_chown(self, args)
306296{
307297 return posix_strintint (args , chown );
308298}
309- #endif
299+ #endif /* HAVE_CHOWN */
310300
311301static object *
312302posix_getcwd (self , args )
@@ -333,14 +323,15 @@ posix_link(self, args)
333323{
334324 return posix_2str (args , link );
335325}
336- #endif
326+ #endif /* HAVE_LINK */
337327
338- #ifdef NT
339328static object *
340329posix_listdir (self , args )
341330 object * self ;
342331 object * args ;
343332{
333+ #ifdef NT
334+
344335 char * name ;
345336 int len ;
346337 object * d , * v ;
@@ -389,13 +380,9 @@ posix_listdir(self, args)
389380 }
390381
391382 return d ;
392- }
393- #else /* ! NT */
394- static object *
395- posix_listdir (self , args )
396- object * self ;
397- object * args ;
398- {
383+
384+ #else /* !NT */
385+
399386 char * name ;
400387 object * d , * v ;
401388 DIR * dirp ;
@@ -431,8 +418,9 @@ posix_listdir(self, args)
431418 END_SAVE
432419
433420 return d ;
421+
422+ #endif /* !NT */
434423}
435- #endif /* ! NT */
436424
437425static object *
438426posix_mkdir (self , args )
@@ -558,12 +546,12 @@ posix_utime(self, args)
558546#define ATIME buf.actime
559547#define MTIME buf.modtime
560548#define UTIME_ARG &buf
561- #else
549+ #else /* HAVE_UTIME_H */
562550 time_t buf [2 ];
563551#define ATIME buf[0]
564552#define MTIME buf[1]
565553#define UTIME_ARG buf
566- #endif
554+ #endif /* HAVE_UTIME_H */
567555
568556 if (!getargs (args , "(s(ll))" , & path , & ATIME , & MTIME ))
569557 return NULL ;
@@ -637,9 +625,9 @@ posix_execv(self, args)
637625
638626#ifdef BAD_EXEC_PROTOTYPES
639627 execv (path , (const char * * ) argvlist );
640- #else
628+ #else /* BAD_EXEC_PROTOTYPES */
641629 execv (path , argvlist );
642- #endif
630+ #endif /* BAD_EXEC_PROTOTYPES */
643631
644632 /* If we get here it's definitely an error */
645633
@@ -724,9 +712,9 @@ posix_execve(self, args)
724712
725713#ifdef BAD_EXEC_PROTOTYPES
726714 execve (path , (const char * * )argvlist , envlist );
727- #else
715+ #else /* BAD_EXEC_PROTOTYPES */
728716 execve (path , argvlist , envlist );
729- #endif
717+ #endif /* BAD_EXEC_PROTOTYPES */
730718
731719 /* If we get here it's definitely an error */
732720
@@ -806,9 +794,9 @@ posix_getpgrp(self, args)
806794 return NULL ;
807795#ifdef GETPGRP_HAVE_ARG
808796 return newintobject ((long )getpgrp (0 ));
809- #else
797+ #else /* GETPGRP_HAVE_ARG */
810798 return newintobject ((long )getpgrp ());
811- #endif
799+ #endif /* GETPGRP_HAVE_ARG */
812800}
813801#endif /* HAVE_GETPGRP */
814802
@@ -822,9 +810,9 @@ posix_setpgrp(self, args)
822810 return NULL ;
823811#ifdef GETPGRP_HAVE_ARG
824812 if (setpgrp (0 , 0 ) < 0 )
825- #else
813+ #else /* GETPGRP_HAVE_ARG */
826814 if (setpgrp () < 0 )
827- #endif
815+ #endif /* GETPGRP_HAVE_ARG */
828816 return posix_error ();
829817 INCREF (None );
830818 return None ;
@@ -897,7 +885,7 @@ posix_setuid(self, args)
897885 INCREF (None );
898886 return None ;
899887}
900- #endif
888+ #endif /* HAVE_SETUID */
901889
902890#ifdef HAVE_SETGID
903891static object *
@@ -913,7 +901,7 @@ posix_setgid(self, args)
913901 INCREF (None );
914902 return None ;
915903}
916- #endif
904+ #endif /* HAVE_SETGID */
917905
918906#ifdef HAVE_WAITPID
919907static object *
@@ -994,7 +982,7 @@ posix_symlink(self, args)
994982#ifdef HAVE_TIMES
995983#ifndef HZ
996984#define HZ 60 /* Universal constant :-) */
997- #endif
985+ #endif /* HZ */
998986static object *
999987posix_times (self , args )
1000988 object * self ;
@@ -1169,7 +1157,7 @@ posix_lseek(self, args)
11691157 case 1 : how = SEEK_CUR ; break ;
11701158 case 2 : how = SEEK_END ; break ;
11711159 }
1172- #endif
1160+ #endif /* SEEK_END */
11731161 BGN_SAVE
11741162 res = lseek (fd , pos , how );
11751163 END_SAVE
@@ -1289,38 +1277,36 @@ static struct methodlist posix_methods[] = {
12891277 {"chmod" , posix_chmod },
12901278#ifdef HAVE_CHOWN
12911279 {"chown" , posix_chown },
1292- #endif
1280+ #endif /* HAVE_CHOWN */
12931281 {"getcwd" , posix_getcwd },
12941282#ifdef HAVE_LINK
12951283 {"link" , posix_link },
1296- #endif
1284+ #endif /* HAVE_LINK */
12971285 {"listdir" , posix_listdir },
12981286 {"lstat" , posix_lstat },
12991287 {"mkdir" , posix_mkdir },
13001288#ifdef HAVE_NICE
13011289 {"nice" , posix_nice },
1302- #endif
1290+ #endif /* HAVE_NICE */
13031291#ifdef HAVE_READLINK
13041292 {"readlink" , posix_readlink },
1305- #endif
1293+ #endif /* HAVE_READLINK */
13061294 {"rename" , posix_rename },
13071295 {"rmdir" , posix_rmdir },
13081296 {"stat" , posix_stat },
13091297#ifdef HAVE_SYMLINK
13101298 {"symlink" , posix_symlink },
1311- #endif
1299+ #endif /* HAVE_SYMLINK */
13121300 {"system" , posix_system },
13131301 {"umask" , posix_umask },
13141302#ifdef HAVE_UNAME
13151303 {"uname" , posix_uname },
1316- #endif
1304+ #endif /* HAVE_UNAME */
13171305 {"unlink" , posix_unlink },
1318- #ifndef NT
13191306 {"utime" , posix_utime },
1320- #endif /* ! NT */
13211307#ifdef HAVE_TIMES
13221308 {"times" , posix_times },
1323- #endif
1309+ #endif /* HAVE_TIMES */
13241310 {"_exit" , posix__exit },
13251311 {"execv" , posix_execv },
13261312 {"execve" , posix_execve },
@@ -1329,44 +1315,44 @@ static struct methodlist posix_methods[] = {
13291315 {"getegid" , posix_getegid },
13301316 {"geteuid" , posix_geteuid },
13311317 {"getgid" , posix_getgid },
1332- #endif /* ! NT */
1318+ #endif /* !NT */
13331319 {"getpid" , posix_getpid },
13341320#ifdef HAVE_GETPGRP
13351321 {"getpgrp" , posix_getpgrp },
1336- #endif
1322+ #endif /* HAVE_GETPGRP */
13371323#ifndef NT
13381324 {"getppid" , posix_getppid },
13391325 {"getuid" , posix_getuid },
13401326 {"kill" , posix_kill },
1341- #endif /* ! NT */
1327+ #endif /* !NT */
13421328 {"popen" , posix_popen },
13431329#ifdef HAVE_SETUID
13441330 {"setuid" , posix_setuid },
1345- #endif
1331+ #endif /* HAVE_SETUID */
13461332#ifdef HAVE_SETGID
13471333 {"setgid" , posix_setgid },
1348- #endif
1334+ #endif /* HAVE_SETGID */
13491335#ifdef HAVE_SETPGRP
13501336 {"setpgrp" , posix_setpgrp },
1351- #endif
1337+ #endif /* HAVE_SETPGRP */
13521338#ifndef NT
13531339 {"wait" , posix_wait },
1354- #endif /* ! NT */
1340+ #endif /* !NT */
13551341#ifdef HAVE_WAITPID
13561342 {"waitpid" , posix_waitpid },
1357- #endif
1343+ #endif /* HAVE_WAITPID */
13581344#ifdef HAVE_SETSID
13591345 {"setsid" , posix_setsid },
1360- #endif
1346+ #endif /* HAVE_SETSID */
13611347#ifdef HAVE_SETPGID
13621348 {"setpgid" , posix_setpgid },
1363- #endif
1349+ #endif /* HAVE_SETPGID */
13641350#ifdef HAVE_TCGETPGRP
13651351 {"tcgetpgrp" , posix_tcgetpgrp },
1366- #endif
1352+ #endif /* HAVE_TCGETPGRP */
13671353#ifdef HAVE_TCSETPGRP
13681354 {"tcsetpgrp" , posix_tcsetpgrp },
1369- #endif
1355+ #endif /* HAVE_TCSETPGRP */
13701356 {"open" , posix_open },
13711357 {"close" , posix_close },
13721358 {"dup" , posix_dup },
@@ -1378,7 +1364,7 @@ static struct methodlist posix_methods[] = {
13781364 {"fdopen" , posix_fdopen },
13791365#ifndef NT
13801366 {"pipe" , posix_pipe },
1381- #endif /* ! NT */
1367+ #endif /* !NT */
13821368
13831369 {NULL , NULL } /* Sentinel */
13841370};
@@ -1404,7 +1390,7 @@ initnt()
14041390 if (PosixError == NULL || dictinsert (d , "error" , PosixError ) != 0 )
14051391 fatal ("can't define nt.error" );
14061392}
1407- #else /* ! NT */
1393+ #else /* !NT */
14081394void
14091395initposix ()
14101396{
@@ -1424,4 +1410,4 @@ initposix()
14241410 if (PosixError == NULL || dictinsert (d , "error" , PosixError ) != 0 )
14251411 fatal ("can't define posix.error" );
14261412}
1427- #endif /* ! NT */
1413+ #endif /* !NT */
0 commit comments