home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / rcs / rcs56src / source / rcsfront / patches.os2 < prev    next >
Encoding:
Text File  |  1992-02-23  |  22.5 KB  |  823 lines

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