home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rcs567s.zip / rcsfront / patches.os2 < prev    next >
Text File  |  1994-07-04  |  24KB  |  862 lines

  1. *** cio.c.orig    Wed Mar 23 15:33:46 1994
  2. --- cio.c    Wed Mar 23 15:28:06 1994
  3. ***************
  4. *** 63,72 ****
  5.   #include <sys/stat.h>
  6.   #include <errno.h>
  7.   #include <signal.h>
  8.   
  9. ! /*--------------------------------------------------- externals ------------*/
  10. ! extern int errno;              /* error code set by system library routines */
  11.   
  12.   extern FILE *fopen();               /* open a stream (should be in stdio.h) */
  13.   extern FILE *popen();                 /* open a pipe (should be in stdio.h) */
  14.   extern char *getenv();                      /* read an environment variable */
  15. --- 63,80 ----
  16.   #include <sys/stat.h>
  17.   #include <errno.h>
  18.   #include <signal.h>
  19. + #include <fcntl.h>
  20.   
  21. ! #ifdef __EMX__
  22. ! #define getcwd _getcwd2
  23. ! #endif
  24.   
  25. + #ifndef OS2
  26. + #define stricmp   strcmp
  27. + #define strnicmp  strncmp
  28. + #endif
  29. + /*--------------------------------------------------- externals ------------*/
  30.   extern FILE *fopen();               /* open a stream (should be in stdio.h) */
  31.   extern FILE *popen();                 /* open a pipe (should be in stdio.h) */
  32.   extern char *getenv();                      /* read an environment variable */
  33. ***************
  34. *** 187,199 ****
  35.       register int in;
  36.       register char *cp;        /* used in string updates. */
  37.   
  38.       prognam = justname(argv[0]);    /* program name */
  39.       getdir();            /* go get the enviroment pointers. */
  40.   
  41.       /*
  42.        * figure what the user wants us to be by reading program name
  43.        */
  44. !     if (!strcmp("ciitest", prognam) || !strcmp("cootest", prognam))
  45.       {
  46.           getrcsdir(final, currentdir);    /* setup variables. */
  47.           /*
  48. --- 195,217 ----
  49.       register int in;
  50.       register char *cp;        /* used in string updates. */
  51.   
  52. + #ifdef __EMX__
  53. +     _response(&argc, &argv);
  54. +     _wildcard(&argc, &argv);
  55. +       _emxload_env("RCSLOAD");
  56. + #endif
  57.       prognam = justname(argv[0]);    /* program name */
  58. + #ifdef OS2
  59. +         if ( stricmp(prognam + 3, ".exe") == 0 )
  60. +           prognam[3] = 0;
  61. + #endif
  62.       getdir();            /* go get the enviroment pointers. */
  63.   
  64.       /*
  65.        * figure what the user wants us to be by reading program name
  66.        */
  67. !     if (!stricmp("ciitest", prognam) || !stricmp("cootest", prognam))
  68.       {
  69.           getrcsdir(final, currentdir);    /* setup variables. */
  70.           /*
  71. ***************
  72. *** 211,224 ****
  73.           (void) printf("Final dir:%s:\n", final);
  74.           return(0);
  75.       }
  76. !     if (!strcmp("cii", prognam))    /* this is input.. */
  77.           cii = TRUE;        /* show we are inputs. */
  78. !     else if (strcmp("coo", prognam))/* it's not this either.. */
  79.       {
  80.           (void) printf("Just what did you think this program was, anyway??\n");
  81.           return(-1);
  82.       }
  83.   
  84.       if (!(user_id = geteuid())) /* we are a root process.. */
  85.       {
  86.           (void) umask(027); /* set general mask to private modes. */
  87. --- 228,242 ----
  88.           (void) printf("Final dir:%s:\n", final);
  89.           return(0);
  90.       }
  91. !     if (!stricmp("cii", prognam))    /* this is input.. */
  92.           cii = TRUE;        /* show we are inputs. */
  93. !     else if (stricmp("coo", prognam))/* it's not this either.. */
  94.       {
  95.           (void) printf("Just what did you think this program was, anyway??\n");
  96.           return(-1);
  97.       }
  98.   
  99. + #ifndef OS2        
  100.       if (!(user_id = geteuid())) /* we are a root process.. */
  101.       {
  102.           (void) umask(027); /* set general mask to private modes. */
  103. ***************
  104. *** 234,243 ****
  105.       }
  106.       else
  107.           real_user_id = user_id;    /* else they should match. */
  108.   
  109.       /* prepare for disasters */
  110. !     (void) signal(SIGINT, (int (*)()) sigcleanup);
  111. !     (void) signal(SIGQUIT, (int (*)()) sigcleanup);
  112.   
  113.       cp = cioopt;
  114.       title[0] = '\0';  /* make sure no titles are required. */
  115. --- 252,275 ----
  116.       }
  117.       else
  118.           real_user_id = user_id;    /* else they should match. */
  119. + #else 
  120. +     real_user_id = 1;    /* else they should match. */
  121. + #endif
  122.   
  123.       /* prepare for disasters */
  124. !     (void) signal(SIGINT, sigcleanup);
  125. ! #ifndef OS2
  126. !     (void) signal(SIGQUIT, sigcleanup);
  127. ! #else
  128. !     (void) signal(SIGBREAK, sigcleanup); /* OS/2 */
  129. !     (void) signal(SIGTERM, sigcleanup);  /* signals */
  130. ! #endif
  131. !         if ( argc <= 1 )
  132. !         {
  133. !             usage();
  134. !             return(0);
  135. !         }
  136.   
  137.       cp = cioopt;
  138.       title[0] = '\0';  /* make sure no titles are required. */
  139. ***************
  140. *** 281,287 ****
  141.   #else
  142.           case 'y':        /* they gave us one */
  143.   #endif
  144. !             (void) strcpy(logstr, &argv[in][1]); /* copy across. */
  145.               break;
  146.           case 't':        /* user gave us one */
  147.               (void) strcpy(title, &argv[in][1]);
  148. --- 313,320 ----
  149.   #else
  150.           case 'y':        /* they gave us one */
  151.   #endif
  152. !             (void) strcpy(logstr, " -");
  153. !             (void) strcat(logstr, &argv[in][1]); /* copy across. */
  154.               break;
  155.           case 't':        /* user gave us one */
  156.               (void) strcpy(title, &argv[in][1]);
  157. ***************
  158. *** 374,380 ****
  159.           }
  160.           for ( ; in < argc; in++)
  161.           {
  162. !             (void) sprintf(entry, "%s/%s", currentdir, argv[in]);
  163.   #ifdef DEBUG
  164.               (void) printf("Processing %s\n", entry);
  165.   #endif
  166. --- 407,416 ----
  167.           }
  168.           for ( ; in < argc; in++)
  169.           {
  170. ! #ifdef OS2
  171. !                         UnixFileName(argv[in]);
  172. ! #endif
  173. !             (void) sprintf(entry, "%s%s", currentdir, argv[in]);
  174.   #ifdef DEBUG
  175.               (void) printf("Processing %s\n", entry);
  176.   #endif
  177. ***************
  178. *** 406,412 ****
  179.               ;
  180.           for ( ; in < argc; in++)
  181.           {
  182. !             (void) sprintf(ep, "/%s", argv[in]);
  183.   #ifdef DEBUG
  184.               (void) printf("Processing %s\n", entry);
  185.   #endif
  186. --- 442,451 ----
  187.               ;
  188.           for ( ; in < argc; in++)
  189.           {
  190. ! #ifdef OS2
  191. !                         UnixFileName(argv[in]);
  192. ! #endif
  193. !             (void) sprintf(ep, "%s", argv[in]);
  194.   #ifdef DEBUG
  195.               (void) printf("Processing %s\n", entry);
  196.   #endif
  197. ***************
  198. *** 438,444 ****
  199. --- 477,489 ----
  200.       FILE *pp;
  201.       char *cmd, *entry;
  202.   
  203. +         if ( dir[strlen(dir) - 1] == '/' )
  204. +           dir[strlen(dir) - 1] = 0;
  205. + #ifdef OS2
  206. +     (void) sprintf(cmd = memalloc(strlen(dir) + 10), "dir /b \"%s\"", dir);
  207. + #else
  208.       (void) sprintf(cmd = memalloc(strlen(dir) + 4), "ls %s", dir);
  209. + #endif
  210.       pp = popen(cmd, "r");
  211.       free(cmd);
  212.       if (!pp)
  213. ***************
  214. *** 506,512 ****
  215.           if (noexec)
  216.           {
  217.               (void) printf("Logfile entry bypassed.\n");
  218. !             (void) strcpy(logstr, " ");    /* fake it */
  219.           }
  220.           else if (!getfinput(titlest, TYPE_LOG)) /* if we entered anything */
  221.           {
  222. --- 551,557 ----
  223.           if (noexec)
  224.           {
  225.               (void) printf("Logfile entry bypassed.\n");
  226. !             (void) strcpy(logstr, "");    /* fake it */
  227.           }
  228.           else if (!getfinput(titlest, TYPE_LOG)) /* if we entered anything */
  229.           {
  230. ***************
  231. *** 570,576 ****
  232.           if (access(final, 0))    /* it's not here... */
  233.               if (!makedir(final))    /* so try and make it. */
  234.               {
  235. !                 (void) printf("Could not create directory :%s:\n", final);
  236.                   return(FALSE);
  237.               }
  238.           *st = '/';    /* restore the rest of the file name. */
  239. --- 615,621 ----
  240.           if (access(final, 0))    /* it's not here... */
  241.               if (!makedir(final))    /* so try and make it. */
  242.               {
  243. !                 (void) printf("Could not create directory: %s:\n", final);
  244.                   return(FALSE);
  245.               }
  246.           *st = '/';    /* restore the rest of the file name. */
  247. ***************
  248. *** 625,634 ****
  249.               (void) printf("%s already exists.  Overwrite? (yes) ", final);
  250.               (void) strrd(cmdbuf, 20, stdin);
  251.               (void) strlwr(cmdbuf);
  252. !             if (strncmp(cmdbuf, "yes", strlen(cmdbuf)))
  253.                   return(TRUE);
  254.           }
  255. !         (void) sprintf(cmdbuf, "cp %s %s", filename, final); /* copy command */
  256.       }
  257.       else if (cii)
  258.       {
  259. --- 670,679 ----
  260.               (void) printf("%s already exists.  Overwrite? (yes) ", final);
  261.               (void) strrd(cmdbuf, 20, stdin);
  262.               (void) strlwr(cmdbuf);
  263. !             if (strnicmp(cmdbuf, "yes", strlen(cmdbuf)))
  264.                   return(TRUE);
  265.           }
  266. !         (void) sprintf(cmdbuf, "cp -p %s %s", filename, final); /* copy command */
  267.       }
  268.       else if (cii)
  269.       {
  270. ***************
  271. *** 712,718 ****
  272.               if (!*st)
  273.                   (void) strcpy(st, "yes");
  274.               (void) strlwr(st);
  275. !             if (!strncmp(st, "yes", strlen(st))) {
  276.                   done = TRUE;
  277.                   (void) system(cmdbuf);    /* do it. */
  278.               }
  279. --- 757,763 ----
  280.               if (!*st)
  281.                   (void) strcpy(st, "yes");
  282.               (void) strlwr(st);
  283. !             if (!strnicmp(st, "yes", strlen(st))) {
  284.                   done = TRUE;
  285.                   (void) system(cmdbuf);    /* do it. */
  286.               }
  287. ***************
  288. *** 725,731 ****
  289.                   (void) printf("?       Print this message\n");
  290.                   (void) printf("\n");
  291.               }
  292. !             else if (!strncmp(st, "view", strlen(st)))
  293.               {
  294.                   (void) printf("Not implemented yet!\n\n");
  295.               }
  296. --- 770,776 ----
  297.                   (void) printf("?       Print this message\n");
  298.                   (void) printf("\n");
  299.               }
  300. !             else if (!strnicmp(st, "view", strlen(st)))
  301.               {
  302.                   (void) printf("Not implemented yet!\n\n");
  303.               }
  304. ***************
  305. *** 737,743 ****
  306.       {
  307.   #endif /* INTERACTIVE */
  308.           if (verbose)
  309. !             (void) printf("%s command :%s:\n", prognam, cmdbuf);
  310.           if (!noexec)
  311.           {
  312.               if (do_copy && !verbose)
  313. --- 782,788 ----
  314.       {
  315.   #endif /* INTERACTIVE */
  316.           if (verbose)
  317. !             (void) printf("%s command: %s:\n", prognam, cmdbuf);
  318.           if (!noexec)
  319.           {
  320.               if (do_copy && !verbose)
  321. ***************
  322. *** 749,765 ****
  323.   #ifdef INTERACTIVE
  324.       }
  325.   #endif /* INTERACTIVE */
  326.       if (updsrcdir)            /* update source directory */
  327.       {
  328.           getsrcdir(final, filename);
  329. !         (void) sprintf(cmdbuf, "cp %s %s", filename, final);
  330.           if (noexec)        /* don't actual do it */
  331.               (void) printf("%s\n", cmdbuf);
  332.           else
  333.           {
  334.               if (verbose)    /* speak, yo wise one! */
  335. !                 (void) printf("%s command :%s:\n", prognam, cmdbuf);
  336. !             if (!strcmp(filename, final))
  337.                   (void) printf("Source and destination identical.  Not updated.\n");
  338.               else
  339.               {
  340. --- 794,824 ----
  341.   #ifdef INTERACTIVE
  342.       }
  343.   #endif /* INTERACTIVE */
  344.       if (updsrcdir)            /* update source directory */
  345.       {
  346.           getsrcdir(final, filename);
  347. !             if (st = strrchr(final, '/'))    /* if this has a sub dir. */
  348. !             {
  349. !                 *st = '\0';    /* terminate it at the directoy level. */
  350. !                 if (access(final, 0))    /* it's not here... */
  351. !                     if (!makedir(final))    /* so try and make it. */
  352. !                     {
  353. !                         (void) printf("Could not create directory: %s:\n", final);
  354. !                         return(FALSE);
  355. !                     }
  356. !                 *st = '/';    /* restore the rest of the file name. */
  357. !             }
  358. !         (void) sprintf(cmdbuf, "cp -p %s %s", filename, final);
  359.           if (noexec)        /* don't actual do it */
  360.               (void) printf("%s\n", cmdbuf);
  361.           else
  362.           {
  363.               if (verbose)    /* speak, yo wise one! */
  364. !                 (void) printf("%s command: %s:\n", prognam, cmdbuf);
  365. !             if (!stricmp(filename, final))
  366.                   (void) printf("Source and destination identical.  Not updated.\n");
  367.               else
  368.               {
  369. ***************
  370. *** 852,874 ****
  371.           char *header;        /* header template file name. */
  372.       } ftype[] = {
  373.   #ifdef V_RCS
  374. !         { "c program",    ".rcshead.c"    },    /* FTYPE_C */
  375. !         { "assembler",    ".rcshead.s"    },    /* FTYPE_S */
  376. !         { "command",    ".rcshead.sh"    },    /* FTYPE_SH */
  377. !         { "roff, tbl",    ".rcshead.roff"    },    /* FTYPE_ROFF */
  378. !         { "fortran",    ".rcshead.f"    },    /* FTYPE_F */
  379. !         { 0,        ".rcshead"    },    /* FTYPE_DEFAULT */
  380. !         { 0,        ".rcshead.mk"    },    /* FTYPE_MK */
  381. !         { 0,        ".rcshead.h"    } };    /* FTYPE_H */
  382. ! #else
  383. !         { "c program",    ".sccshead.c"    },    /* FTYPE_C */
  384. !         { "assembler",    ".sccshead.s"    },    /* FTYPE_S */
  385. !         { "command",    ".sccshead.sh"    },    /* FTYPE_SH */
  386. !         { "roff, tbl",    ".sccshead.roff"},    /* FTYPE_ROFF */
  387. !         { "fortran",    ".sccshead.f"    },    /* FTYPE_F */
  388. !         { 0,        ".sccshead"    },    /* FTYPE_DEFAULT */
  389. !         { 0,        ".sccshead.mk"    },    /* FTYPE_MK */
  390. !         { 0,        ".sccshead.h"    } };    /* FTYPE_H */
  391.   #endif /* V_RCS */
  392.       static struct _fext {
  393.           char *name;
  394. --- 911,933 ----
  395.           char *header;        /* header template file name. */
  396.       } ftype[] = {
  397.   #ifdef V_RCS
  398. !         { "c program",    "rcshead.c"    },    /* FTYPE_C */
  399. !         { "assembler",    "rcshead.s"    },    /* FTYPE_S */
  400. !         { "command",    "rcshead.sh"    },    /* FTYPE_SH */
  401. !         { "roff, tbl",    "rcshead.rof"    },    /* FTYPE_ROFF */
  402. !         { "fortran",    "rcshead.f"    },    /* FTYPE_F */
  403. !         { 0,        "rcshead"    },    /* FTYPE_DEFAULT */
  404. !         { 0,        "rcshead.mk"    },    /* FTYPE_MK */
  405. !         { 0,        "rcshead.h"    } };    /* FTYPE_H */
  406. ! #else
  407. !         { "c program",    "sccshead.c"    },    /* FTYPE_C */
  408. !         { "assembler",    "sccshead.s"    },    /* FTYPE_S */
  409. !         { "command",    "sccshead.sh"    },    /* FTYPE_SH */
  410. !         { "roff, tbl",    "sccshead.rof"},    /* FTYPE_ROFF */
  411. !         { "fortran",    "sccshead.f"    },    /* FTYPE_F */
  412. !         { 0,        "sccshead"    },    /* FTYPE_DEFAULT */
  413. !         { 0,        "sccshead.mk"    },    /* FTYPE_MK */
  414. !         { 0,        "sccshead.h"    } };    /* FTYPE_H */
  415.   #endif /* V_RCS */
  416.       static struct _fext {
  417.           char *name;
  418. ***************
  419. *** 933,939 ****
  420.           if (ext = strrchr(fname, '.'))
  421.           {
  422.               for (i = 0; fext[i].name; i++)
  423. !                 if (!strcmp(ext, fext[i].name))
  424.                       ft = fext[i].type;
  425.           }
  426.           else
  427. --- 992,998 ----
  428.           if (ext = strrchr(fname, '.'))
  429.           {
  430.               for (i = 0; fext[i].name; i++)
  431. !                 if (!stricmp(ext, fext[i].name))
  432.                       ft = fext[i].type;
  433.           }
  434.           else
  435. ***************
  436. *** 946,952 ****
  437.       }
  438.       else if (ft == FTYPE_C)        /* see if source or header */
  439.       {
  440. !         if ((ext = strrchr(fname, '.')) && !strcmp(ext, ".h"))
  441.               ft = FTYPE_H;
  442.       }
  443.       if (verbose)            /* is this necessary */
  444. --- 1005,1011 ----
  445.       }
  446.       else if (ft == FTYPE_C)        /* see if source or header */
  447.       {
  448. !         if ((ext = strrchr(fname, '.')) && !stricmp(ext, ".h"))
  449.               ft = FTYPE_H;
  450.       }
  451.       if (verbose)            /* is this necessary */
  452. ***************
  453. *** 965,971 ****
  454.       strcpy(tempfile, t_name);
  455.       ext = justname(tempfile); /* find end of path. */
  456.       *ext = '\0'; /* and terminate path there. */
  457. !     (void) strcat(tempfile, "ciotmp._XXXXXX"); /* add tmp name */
  458.       (void) mktemp(tempfile);        /* generate temp file name */
  459.       if (!(ofp = fopen(tempfile, "w")))    /* open temp file */
  460.       {
  461. --- 1024,1030 ----
  462.       strcpy(tempfile, t_name);
  463.       ext = justname(tempfile); /* find end of path. */
  464.       *ext = '\0'; /* and terminate path there. */
  465. !     (void) strcat(tempfile, "ctXXXXXX"); /* add tmp name */
  466.       (void) mktemp(tempfile);        /* generate temp file name */
  467.       if (!(ofp = fopen(tempfile, "w")))    /* open temp file */
  468.       {
  469. ***************
  470. *** 997,1007 ****
  471. --- 1056,1072 ----
  472.   */
  473.       if(!err && !unlink(t_name))    /* 'mv tempfile fname' */
  474.       {           
  475. + #ifndef OS2                
  476.           if(!link(tempfile, t_name)) /* 'cp tempfile t_name' */
  477.               (void) unlink(tempfile);        /* 'rm tempfile' */
  478.           else
  479.               (void) printf("Link of %s and %s failed after removing %s.\n%s not removed.\n",
  480.                   tempfile, t_name, t_name, tempfile);
  481. + #else
  482. +         if(!rename(tempfile, t_name)) /* 'cp tempfile t_name' */
  483. +             (void) printf("Rename of %s to %s failed after removing %s.\n%s not removed.\n",
  484. +                 tempfile, t_name, t_name, tempfile);
  485. + #endif
  486.       }
  487.       else
  488.       {
  489. ***************
  490. *** 1024,1040 ****
  491.       register char *st, *cp;
  492.   
  493.       if(!*newpath) return(FALSE); /* skip last directory attempt. */
  494. -     cp = memalloc(strlen(newpath) + 24);
  495. -     (void) sprintf(cp, "/bin/mkdir %s 2>/dev/null", newpath);
  496. -     if(verbose)
  497. -         (void) printf("calling mkdir: %s\n", cp);
  498.       if (noexec)
  499.       {
  500. !         (void) printf("%s\n", cp);
  501. !         free(cp);
  502.           return(TRUE);
  503.       }
  504. !     if (system(cp))            /* it failed.. */
  505.       {
  506.           (void) strcpy(cp, newpath);    /* get current one. */
  507.           st = strrchr(cp, '/'); /* remove one more layer.. */
  508. --- 1089,1105 ----
  509.       register char *st, *cp;
  510.   
  511.       if(!*newpath) return(FALSE); /* skip last directory attempt. */
  512.       if (noexec)
  513.       {
  514. !         (void) printf("mkdir: %s\n", newpath);
  515.           return(TRUE);
  516.       }
  517. !     else if(verbose)
  518. !         (void) printf("mkdir: %s\n", newpath);
  519. !     cp = memalloc(strlen(newpath) + 24);
  520. !     if (mkdir(newpath))            /* it failed.. */
  521.       {
  522.           (void) strcpy(cp, newpath);    /* get current one. */
  523.           st = strrchr(cp, '/'); /* remove one more layer.. */
  524. ***************
  525. *** 1043,1055 ****
  526.           {
  527.               free(cp);
  528.               return(FALSE);
  529. !         } /* ok, so.. it passed on back. Try this again. */
  530. !         else if(makedir(newpath) == FALSE)
  531.           {
  532.               free(cp);
  533.               return(FALSE);
  534.           }
  535.       }
  536.       free(cp);
  537.       return(TRUE);
  538.   }
  539. --- 1108,1122 ----
  540.           {
  541.               free(cp);
  542.               return(FALSE);
  543. !         }
  544. !                 /* ok, so.. it passed on back. Try this again. */
  545. !         if(mkdir(newpath))
  546.           {
  547.               free(cp);
  548.               return(FALSE);
  549.           }
  550.       }
  551.       free(cp);
  552.       return(TRUE);
  553.   }
  554. ***************
  555. *** 1057,1062 ****
  556. --- 1124,1130 ----
  557.   /*--------------------------------------------------- strstr() --------------
  558.   / find a substring within a string
  559.   /---------------------------------------------------------------------------*/
  560. + #ifndef OS2
  561.   char *
  562.   strstr(s1, s2)
  563.   register char *s1, *s2;
  564. ***************
  565. *** 1084,1089 ****
  566. --- 1152,1158 ----
  567.               *s = _tolower(*s);
  568.       return(op);
  569.   }
  570. + #endif
  571.   
  572.   /*--------------------------------------------------- asciifile() -----------
  573.   / check if passed file is an ascii file using file(1) command
  574. ***************
  575. *** 1095,1100 ****
  576. --- 1164,1183 ----
  577.       char cmdstr[256];
  578.       register FILE *fp;
  579.   
  580. + #ifdef OS2
  581. +         int file, cnt, i;
  582. +     if ((file = open(fn, O_RDONLY|O_BINARY)) == -1)
  583. +         return(FALSE);
  584. +     cnt = read(file, cmdstr, sizeof(cmdstr)); /* get a block. */
  585. +     close(file);    /* and done. */
  586. +         for ( i = 0; i < cnt; i++ )
  587. +                 if ( cmdstr[i] == 0 || cmdstr[i] == 127 )
  588. +                     return(FALSE);
  589. +         return(TRUE);
  590. + #else /* OS2 */
  591.       (void) sprintf(cmdstr, "file %s", fn);
  592.       if (!(fp = popen(cmdstr, "r")))
  593.           return(FALSE);
  594. ***************
  595. *** 1106,1111 ****
  596. --- 1189,1195 ----
  597.       if (strstr(ftypestr, "text"))
  598.           return(TRUE);
  599.       return(FALSE);
  600. + #endif /* OS2 */
  601.   }
  602.   
  603.   /*--------------------------------------------------- rcsfile() -------------
  604. ***************
  605. *** 1118,1123 ****
  606. --- 1202,1218 ----
  607.       char cmdstr[256];
  608.       register FILE *fp;
  609.   
  610. + #ifdef OS2
  611. +     if (!(fp = fopen(fn, "r")))
  612. +         return(FALSE);
  613. +     (void) strrd(ftypestr, 80, fp); /* get a line. */
  614. +     (void) fclose(fp);    /* and done. */
  615. + #ifdef DEBUG
  616. +     (void) printf("%s\n", cmdstr);
  617. + #endif
  618. +     if (strcmp(ftypestr, "head     "))
  619. +         return(TRUE);
  620. + #else /* OS2 */
  621.       (void) sprintf(cmdstr, "file %s", fn);
  622.       if (!(fp = popen(cmdstr, "r")))
  623.           return(FALSE);
  624. ***************
  625. *** 1132,1137 ****
  626. --- 1227,1233 ----
  627.       if (strstr(ftypestr, "sccs"))
  628.   #endif
  629.           return(TRUE);
  630. + #endif /* OS2 */
  631.       return(FALSE);
  632.   }
  633.   
  634. ***************
  635. *** 1263,1268 ****
  636. --- 1359,1369 ----
  637.           (void) fprintf(stderr, "Cannot get working dir.\n");
  638.           exit(-1);
  639.       }
  640. + #ifdef OS2
  641. +         /* strcpy(currentdir, currentdir + 2); */
  642. +         UnixFileName(currentdir);
  643. + #endif
  644. +         strcat(currentdir, "/");
  645.       s_currentdir = strlen(currentdir);
  646.   }
  647.   
  648. ***************
  649. *** 1280,1285 ****
  650. --- 1381,1390 ----
  651.       register char *cp, *dp;
  652.       register int was_slash = FALSE;
  653.   
  654. + #ifdef OS2
  655. +         UnixFileName(cs);
  656. + #endif
  657.       cp = dp = cs;
  658.       while (isspace(*cp))        /* remove leading white spaces */
  659.           cp++;
  660. ***************
  661. *** 1324,1333 ****
  662.   {
  663.       register char *cp = sdir;
  664.   
  665. !     if(rcswrk && !strncmp(rcswrk, cp, s_rcswrk))
  666.           cp += s_rcswrk;
  667. !     if(homedir && !strncmp(homedir, cp, s_homedir))
  668.           cp += s_homedir;
  669.       /*
  670.        * build the final directory name
  671.        */
  672. --- 1429,1444 ----
  673.   {
  674.       register char *cp = sdir;
  675.   
  676. !     if(rcswrk && !strnicmp(rcswrk, cp, s_rcswrk))
  677.           cp += s_rcswrk;
  678. !     if(homedir && !strnicmp(homedir, cp, s_homedir))
  679.           cp += s_homedir;
  680. + #ifdef OS2
  681. +         if(isalpha(cp[0]) && cp[1] == ':')
  682. +                 cp += 2;
  683. + #endif
  684. +         if(cp[0] == '/')
  685. +                 cp++;
  686.       /*
  687.        * build the final directory name
  688.        */
  689. ***************
  690. *** 1343,1350 ****
  691.   {
  692.       register char *cp = sdir;
  693.   
  694. !     if (rcsdir && !strncmp(rcsdir, cp, s_rcsdir))
  695.           cp += s_rcsdir;
  696.       (void) sprintf(tdir, "%s%s", rcswrk ? rcswrk : homedir, cp);
  697.   }
  698.   
  699. --- 1454,1467 ----
  700.   {
  701.       register char *cp = sdir;
  702.   
  703. !     if (rcsdir && !strnicmp(rcsdir, cp, s_rcsdir))
  704.           cp += s_rcsdir;
  705. + #ifdef OS2
  706. +         if(isalpha(cp[0]) && cp[1] == ':')
  707. +                 cp += 2;
  708. + #endif
  709. +         if(cp[0] == '/')
  710. +                 cp++;
  711.       (void) sprintf(tdir, "%s%s", rcswrk ? rcswrk : homedir, cp);
  712.   }
  713.   
  714. ***************
  715. *** 1357,1366 ****
  716.   {
  717.       register char *cp = sdir;
  718.   
  719. !     if (rcsdir && !strncmp(rcsdir, cp, s_rcsdir))
  720. !         cp += s_rcsdir;
  721. !     if(homedir && !strncmp(homedir, cp, s_homedir))
  722.           cp += s_homedir;
  723.       (void) sprintf(tdir, "%s%s", srcdir ? srcdir : homedir, cp);
  724.   }
  725.   
  726. --- 1474,1489 ----
  727.   {
  728.       register char *cp = sdir;
  729.   
  730. !     if (rcswrk && !strnicmp(rcswrk, cp, s_rcswrk))
  731. !         cp += s_rcswrk;
  732. !     if(homedir && !strnicmp(homedir, cp, s_homedir))
  733.           cp += s_homedir;
  734. + #ifdef OS2
  735. +         if(isalpha(cp[0]) && cp[1] == ':')
  736. +                 cp += 2;
  737. + #endif
  738. +         if(cp[0] == '/')
  739. +                 cp++;
  740.       (void) sprintf(tdir, "%s%s", srcdir ? srcdir : homedir, cp);
  741.   }
  742.   
  743. ***************
  744. *** 1375,1380 ****
  745. --- 1498,1504 ----
  746.       int stat_loc;
  747.   
  748.       (void) strcpy(name, tmpnam(editfile));
  749. + #ifndef OS2
  750.       if (fork())
  751.       {    /* parent just waits for the child to finish */
  752.           (void) wait(&stat_loc);
  753. ***************
  754. *** 1383,1397 ****
  755.       {    /* child does his/her stuff */
  756.           (void) signal(SIGINT, SIG_DFL);
  757.           (void) signal(SIGQUIT, SIG_DFL);
  758.           exit(child_getfinput(name, type) == TRUE ? 0 : -1);
  759.       }
  760.       return((stat_loc >> 8) & 0xff);
  761.   }
  762.   
  763.   /*--------------------------------------------------- child_getfinput() -----
  764.   / actual get title file.
  765.   /---------------------------------------------------------------------------*/
  766. ! static int
  767.   child_getfinput(name, type)
  768.   char *name;        /* buffer to put file name into. */
  769.   int type;        /* what data we want. */
  770. --- 1507,1526 ----
  771.       {    /* child does his/her stuff */
  772.           (void) signal(SIGINT, SIG_DFL);
  773.           (void) signal(SIGQUIT, SIG_DFL);
  774. +         (void) signal(SIGBREAK, SIG_DFL);
  775. +         (void) signal(SIGTERM, SIG_DFL);
  776.           exit(child_getfinput(name, type) == TRUE ? 0 : -1);
  777.       }
  778.       return((stat_loc >> 8) & 0xff);
  779. + #else
  780. +     return child_getfinput(name, type) == TRUE ? 0 : -1;
  781. + #endif
  782.   }
  783.   
  784.   /*--------------------------------------------------- child_getfinput() -----
  785.   / actual get title file.
  786.   /---------------------------------------------------------------------------*/
  787. ! int
  788.   child_getfinput(name, type)
  789.   char *name;        /* buffer to put file name into. */
  790.   int type;        /* what data we want. */
  791. ***************
  792. *** 1402,1408 ****
  793. --- 1531,1539 ----
  794.       int c, done = FALSE;
  795.       char buf[82];            /* just larger than input buffer. */
  796.                     
  797. + #ifndef OS2
  798.       (void) setuid(real_user_id);        /* user's real user id */
  799. + #endif        
  800.       if((fp = fopen(name, "w")) == NULL) /* failed open. */
  801.       {
  802.           (void) unlink(name);        /* remove it. */
  803. ***************
  804. *** 1410,1416 ****
  805.           (void) printf("Unable to create tmp file.\n");
  806.           return(FALSE);
  807.       }
  808. !     (void) printf("Enter %s message, <ret>.<ret> or Control-D to end:\n",
  809.           input_type[type]);
  810.       while (!done)
  811.       {
  812. --- 1541,1547 ----
  813.           (void) printf("Unable to create tmp file.\n");
  814.           return(FALSE);
  815.       }
  816. !     (void) printf("Enter %s message, <ret>.<ret> or Control-Z to end:\n",
  817.           input_type[type]);
  818.       while (!done)
  819.       {
  820. ***************
  821. *** 1535,1540 ****
  822. --- 1666,1674 ----
  823.   {
  824.       register char *cp;
  825.   
  826. + #ifdef OS2
  827. +         UnixFileName(fpath);
  828. + #endif
  829.       if (cp = strrchr(fpath, '/'))
  830.           return(++cp);
  831.   
  832. ***************
  833. *** 1617,1619 ****
  834. --- 1751,1764 ----
  835.   }
  836.   
  837.   /*----------------------------- End of cio.c -------------------------------*/
  838. + #ifdef OS2
  839. + UnixFileName(char *name)
  840. + {
  841. +   /* strlwr(name); */
  842. +   for ( ; *name; name++ )
  843. +     if ( *name == '\\' )
  844. +       *name = '/';
  845. + }
  846. + #endif
  847.