home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / os2 / diffs.os2 next >
Text File  |  1997-07-29  |  72KB  |  2,611 lines

  1. diff -rwuPB ..\nvi-1.79-dist/build/config.guess ./build/config.guess
  2. --- ..\nvi-1.79-dist/build/config.guess    Sun Aug 18 10:36:34 1996
  3. +++ ./build/config.guess    Fri Jun 20 18:21:20 1997
  4. @@ -430,6 +430,9 @@
  5.      mc68*:A/UX:*:*)
  6.      echo m68k-apple-aux${UNAME_RELEASE}
  7.      exit 0 ;;
  8. +    i?86:OS/2:2:2.[34]?)
  9. +        echo i386-ibm-os2
  10. +        exit 0 ;;
  11.  esac
  12.  
  13.  #echo '(No uname command or uname output not recognized.)' 1>&2
  14. diff -rwuPB ..\nvi-1.79-dist/build/config.sub ./build/config.sub
  15. --- ..\nvi-1.79-dist/build/config.sub    Sun May 19 10:02:20 1996
  16. +++ ./build/config.sub    Sat May 31 21:24:38 1997
  17. @@ -703,6 +703,9 @@
  18.          ;;
  19.      -none)
  20.          ;;
  21. +    -warp | -merlin | -os2*)
  22. +        os=-os2
  23. +        ;;
  24.      *)
  25.          # Get rid of the `-' at the beginning of $os.
  26.          os=`echo $os | sed 's/[^-]*-//'`
  27. diff -rwuPB ..\nvi-1.79-dist/build/configure ./build/configure
  28. --- ..\nvi-1.79-dist/build/configure    Wed Oct 23 08:53:06 1996
  29. +++ ./build/configure    Sun Jun 29 15:49:12 1997
  30. @@ -515,8 +515,8 @@
  31.  $CPP $CPPFLAGS'
  32.  ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
  33.  ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
  34. -ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
  35. -${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
  36. +ac_link='echo ${CC-cc} -o conftest$EXE $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
  37. +${CC-cc} -o conftest$EXE $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
  38.  
  39.  if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  40.    # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  41. @@ -552,6 +552,19 @@
  42.  ac_config_sub=$ac_aux_dir/config.sub
  43.  ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
  44.  
  45. +# Aside on compatibility:  it would be nice if this came *after* the system
  46. +# type check, so I could have EXE, CMD, and PATHSEP set right to begin with.
  47. +# (half-hearted check, fixed later...)
  48. +if test -d 'C:\\'; then
  49. +    EXE=.exe
  50. +    CMD=.cmd
  51. +    PATHSEP=;
  52. +else
  53. +    EXE=
  54. +    CMD=
  55. +    PATHSEP=:
  56. +fi
  57. +
  58.  # Find a good install program.  We prefer a C program (faster),
  59.  # so one script is as good as another.  But avoid the broken or
  60.  # incompatible versions:
  61. @@ -567,7 +580,7 @@
  62.  if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
  63.    echo $ac_n "(cached) $ac_c" 1>&6
  64.  else
  65. -    IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  66. +    IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  67.    for ac_dir in $PATH; do
  68.      # Account for people who put trailing slashes in PATH elements.
  69.      case "$ac_dir/" in
  70. @@ -575,7 +588,7 @@
  71.      *)
  72.        # OSF1 and SCO ODT 3.0 have their own names for install.
  73.        for ac_prog in ginstall installbsd scoinst install; do
  74. -        if test -f $ac_dir/$ac_prog; then
  75. +        if test -f $ac_dir/$ac_prog$EXE; then
  76.        if test $ac_prog = install &&
  77.              grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  78.          # AIX install.  It has an incompatible calling convention.
  79. @@ -678,6 +691,12 @@
  80.  
  81.  
  82.  
  83. +EXE=
  84. +CMD=
  85. +PATHSEP=:
  86. +vi_cv_DOSish=0
  87. +emxadds=
  88. +emxfix=:
  89.  case "$host_os" in
  90.  aix3.2.5)  OPTFLAG=${OPTFLAG-"-O"};;
  91.  aix4.1*)   CFLAGS=${CFLAGS-"-qstrict"}
  92. @@ -688,6 +707,15 @@
  93.  bsd4.4)    OPTFLAG=${OPTFLAG-"-O2"};;
  94.  bsdi*)       CC=${CC-"shlicc"}
  95.         OPTFLAG=${OPTFLAG-"-O2"};;
  96. +dos*|os2*|win*)
  97. +       vi_cv_DOSish=1
  98. +       emxadds="-DEMX_MOUSE -DEMX_KEYS -DEMX_TITLEBAR -DEMX_CURSOR"
  99. +       EXE=".exe"
  100. +       CMD=".cmd"
  101. +       OPTFLAG=${OPTFLAG-"-O2 -Zmt"}
  102. +       LDFLAGS=${LDFLAGS-"-Zmt"}
  103. +       emxfix=${EMX_FIX_CMD-"emxbind -a \$@ -h60"}
  104. +       PATHSEP=";";;
  105.  irix6*)       OPTFLAG=${OPTFLAG-"-O2"};;
  106.  irix*)       OPTFLAG=${OPTFLAG-"-O2"};;
  107.  lynxos*)   # Extract the first word of "gcc", so it can be a program name with args.
  108. @@ -699,10 +727,10 @@
  109.    if test -n "$CC"; then
  110.    ac_cv_prog_CC="$CC" # Let the user override the test.
  111.  else
  112. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  113. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS};"
  114.    for ac_dir in $PATH; do
  115.      test -z "$ac_dir" && ac_dir=.
  116. -    if test -f $ac_dir/$ac_word; then
  117. +    if test -f $ac_dir/$ac_word$EXE; then
  118.        ac_cv_prog_CC="gcc"
  119.        break
  120.      fi
  121. @@ -807,6 +835,7 @@
  122.  solaris*)  LIBS=${LIBS-"-lsocket -lnsl -ldl"}
  123.         RLIBS=yes;;
  124.  wgs*)       LIBS=${LIBS-"-lnsl"};;
  125. +os2)       LIBS=${LIBS-"-lsocket -lbsd -lsettitle"};;
  126.  esac
  127.  
  128.  case "$host_os" in
  129. @@ -840,7 +869,7 @@
  130.  main(){return(0);}
  131.  EOF
  132.  eval $ac_link
  133. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  134. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  135.    ac_cv_c_cross=no
  136.  else
  137.    ac_cv_c_cross=yes
  138. @@ -860,8 +889,8 @@
  139.  $CPP $CPPFLAGS'
  140.  ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
  141.  ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
  142. -ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
  143. -${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
  144. +ac_link='echo ${CC-cc} -o conftest$EXE $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
  145. +${CC-cc} -o conftest$EXE $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
  146.  
  147.    if test "$cross_compiling" = yes; then
  148.                 cat > conftest.$ac_ext <<EOF
  149. @@ -889,7 +918,7 @@
  150.  main() { exit(0); }
  151.  EOF
  152.  eval $ac_link
  153. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  154. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  155.    am_cv_prog_cc_works=yes
  156.  else
  157.    am_cv_prog_cc_works=no
  158. @@ -917,10 +946,10 @@
  159.    ac_cv_path_vi_cv_path_shell="$vi_cv_path_shell" # Let the user override the test with a path.
  160.    ;;
  161.    *)
  162. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  163. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  164.    for ac_dir in $PATH; do
  165.      test -z "$ac_dir" && ac_dir=.
  166. -    if test -f $ac_dir/$ac_word; then
  167. +    if test -f $ac_dir/$ac_word$EXE; then
  168.        ac_cv_path_vi_cv_path_shell="$ac_dir/$ac_word"
  169.        break
  170.      fi
  171. @@ -953,10 +982,10 @@
  172.    ac_cv_path_vi_cv_path_sendmail="$vi_cv_path_sendmail" # Let the user override the test with a path.
  173.    ;;
  174.    *)
  175. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  176. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  177.    for ac_dir in $PATH; do
  178.      test -z "$ac_dir" && ac_dir=.
  179. -    if test -f $ac_dir/$ac_word; then
  180. +    if test -f $ac_dir/$ac_word$EXE; then
  181.        ac_cv_path_vi_cv_path_sendmail="$ac_dir/$ac_word"
  182.        break
  183.      fi
  184. @@ -992,10 +1021,10 @@
  185.    ac_cv_path_vi_cv_path_perl="$vi_cv_path_perl" # Let the user override the test with a path.
  186.    ;;
  187.    *)
  188. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  189. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  190.    for ac_dir in $PATH; do
  191.      test -z "$ac_dir" && ac_dir=.
  192. -    if test -f $ac_dir/$ac_word; then
  193. +    if test -f $ac_dir/$ac_word$EXE; then
  194.        ac_cv_path_vi_cv_path_perl="$ac_dir/$ac_word"
  195.        break
  196.      fi
  197. @@ -1021,7 +1050,11 @@
  198.  if eval "test \"`echo '$''{'vi_cv_path_preserve'+set}'`\" = set"; then
  199.    echo $ac_n "(cached) $ac_c" 1>&6
  200.  else
  201. -      dirlist="/var/preserve /var/tmp /usr/tmp"
  202. +    if test "$vi_cv_DOSish" = 1; then
  203. +        dirlist="$prefix/preserve C:/preserve C:/temp C:/tmp C:/"
  204. +    else
  205. +        dirlist="/var/preserve /var/tmp /usr/tmp /tmp"
  206. +    fi
  207.      vi_cv_path_preserve=no
  208.      for i in $dirlist; do
  209.          if test -d $i/vi.recover; then
  210. @@ -1031,8 +1064,20 @@
  211.      done
  212.      if test "$vi_cv_path_preserve" = no; then
  213.          for i in $dirlist; do
  214. +            if test -d $i/recover.vi; then
  215. +                vi_cv_path_preserve=$i/recover.vi
  216. +                break;
  217. +            fi
  218. +        done
  219. +    fi
  220. +    if test "$vi_cv_path_preserve" = no; then
  221. +        for i in $dirlist; do
  222.              if test -d $i -a -w $i; then
  223. +                if [ $vi_cv_DOSish = 1 ]; then
  224. +                    vi_cv_path_preserve=$i/recover.vi
  225. +                    else
  226.                  vi_cv_path_preserve=$i/vi.recover
  227. +                fi
  228.                  break;
  229.              fi
  230.          done
  231. @@ -1057,10 +1103,10 @@
  232.    ac_cv_path_vi_cv_path_chmod="$vi_cv_path_chmod" # Let the user override the test with a path.
  233.    ;;
  234.    *)
  235. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  236. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  237.    for ac_dir in $PATH; do
  238.      test -z "$ac_dir" && ac_dir=.
  239. -    if test -f $ac_dir/$ac_word; then
  240. +    if test -f $ac_dir/$ac_word$EXE; then
  241.        ac_cv_path_vi_cv_path_chmod="$ac_dir/$ac_word"
  242.        break
  243.      fi
  244. @@ -1088,10 +1134,10 @@
  245.    ac_cv_path_vi_cv_path_cp="$vi_cv_path_cp" # Let the user override the test with a path.
  246.    ;;
  247.    *)
  248. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  249. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  250.    for ac_dir in $PATH; do
  251.      test -z "$ac_dir" && ac_dir=.
  252. -    if test -f $ac_dir/$ac_word; then
  253. +    if test -f $ac_dir/$ac_word$EXE; then
  254.        ac_cv_path_vi_cv_path_cp="$ac_dir/$ac_word"
  255.        break
  256.      fi
  257. @@ -1119,16 +1165,16 @@
  258.    ac_cv_path_vi_cv_path_ln="$vi_cv_path_ln" # Let the user override the test with a path.
  259.    ;;
  260.    *)
  261. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  262. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  263.    for ac_dir in $PATH; do
  264.      test -z "$ac_dir" && ac_dir=.
  265. -    if test -f $ac_dir/$ac_word; then
  266. +    if test -f $ac_dir/$ac_word$EXE; then
  267.        ac_cv_path_vi_cv_path_ln="$ac_dir/$ac_word"
  268.        break
  269.      fi
  270.    done
  271.    IFS="$ac_save_ifs"
  272. -  test -z "$ac_cv_path_vi_cv_path_ln" && ac_cv_path_vi_cv_path_ln="missing_ln"
  273. +  test -z "$ac_cv_path_vi_cv_path_ln" && ac_cv_path_vi_cv_path_ln="$vi_cv_path_cp"
  274.    ;;
  275.  esac
  276.  fi
  277. @@ -1150,10 +1196,10 @@
  278.    ac_cv_path_vi_cv_path_mkdir="$vi_cv_path_mkdir" # Let the user override the test with a path.
  279.    ;;
  280.    *)
  281. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  282. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  283.    for ac_dir in $PATH; do
  284.      test -z "$ac_dir" && ac_dir=.
  285. -    if test -f $ac_dir/$ac_word; then
  286. +    if test -f $ac_dir/$ac_word$EXE; then
  287.        ac_cv_path_vi_cv_path_mkdir="$ac_dir/$ac_word"
  288.        break
  289.      fi
  290. @@ -1181,10 +1227,10 @@
  291.    ac_cv_path_vi_cv_path_rm="$vi_cv_path_rm" # Let the user override the test with a path.
  292.    ;;
  293.    *)
  294. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  295. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  296.    for ac_dir in $PATH; do
  297.      test -z "$ac_dir" && ac_dir=.
  298. -    if test -f $ac_dir/$ac_word; then
  299. +    if test -f $ac_dir/$ac_word$EXE; then
  300.        ac_cv_path_vi_cv_path_rm="$ac_dir/$ac_word"
  301.        break
  302.      fi
  303. @@ -1212,10 +1258,10 @@
  304.    ac_cv_path_vi_cv_path_strip="$vi_cv_path_strip" # Let the user override the test with a path.
  305.    ;;
  306.    *)
  307. -  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  308. +  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
  309.    for ac_dir in $PATH; do
  310.      test -z "$ac_dir" && ac_dir=.
  311. -    if test -f $ac_dir/$ac_word; then
  312. +    if test -f $ac_dir/$ac_word$EXE; then
  313.        ac_cv_path_vi_cv_path_strip="$ac_dir/$ac_word"
  314.        break
  315.      fi
  316. @@ -1877,7 +1923,7 @@
  317.  
  318.  EOF
  319.  eval $ac_link
  320. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  321. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  322.    :
  323.  else
  324.    ac_cv_header_stdc=no
  325. @@ -1992,7 +2038,7 @@
  326.  }
  327.  EOF
  328.  eval $ac_link
  329. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  330. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  331.    ac_cv_c_bigendian=no
  332.  else
  333.    ac_cv_c_bigendian=yes
  334. @@ -2910,10 +2877,9 @@
  335.        exit(1);
  336.    exit(0);
  337.  }
  338. -
  339.  EOF
  340.  eval $ac_link
  341. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  342. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  343.    ac_cv_func_mmap=yes
  344.  else
  345.    ac_cv_func_mmap=no
  346. @@ -3107,7 +3055,7 @@
  347.  }
  348.  EOF
  349.  eval $ac_link
  350. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  351. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  352.    ac_cv_func_vfork=yes
  353.  else
  354.    ac_cv_func_vfork=no
  355. @@ -3640,7 +3521,7 @@
  356.  main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}
  357.  EOF
  358.  eval $ac_link
  359. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  360. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  361.    vi_cv_sprintf_count=yes
  362.  else
  363.    vi_cv_sprintf_count=no
  364. @@ -3841,7 +3703,7 @@
  365.  main(){exit(sizeof(unsigned char) != 1);}
  366.  EOF
  367.  eval $ac_link
  368. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  369. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  370.    vi_cv_uint8="unsigned char"
  371.  else
  372.    vi_cv_uint8=no
  373. @@ -3891,7 +3750,7 @@
  374.  main(){exit(sizeof(unsigned short) != 2);}
  375.  EOF
  376.  eval $ac_link
  377. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  378. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  379.    vi_cv_uint16="unsigned short"
  380.  else
  381.    if test "$cross_compiling" = yes; then
  382. @@ -3903,7 +3762,7 @@
  383.  main(){exit(sizeof(unsigned int) != 2);}
  384.  EOF
  385.  eval $ac_link
  386. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  387. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  388.    vi_cv_uint16="unsigned int"
  389.  else
  390.    vi_cv_uint16=no
  391. @@ -3956,7 +3812,7 @@
  392.  main(){exit(sizeof(short) != 2);}
  393.  EOF
  394.  eval $ac_link
  395. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  396. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  397.    vi_cv_int16="short"
  398.  else
  399.    if test "$cross_compiling" = yes; then
  400. @@ -3968,7 +3824,7 @@
  401.  main(){exit(sizeof(int) != 2);}
  402.  EOF
  403.  eval $ac_link
  404. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  405. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  406.    vi_cv_int16="int"
  407.  else
  408.    vi_cv_int16=no
  409. @@ -4021,7 +3874,7 @@
  410.  main(){exit(sizeof(unsigned int) != 4);}
  411.  EOF
  412.  eval $ac_link
  413. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  414. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  415.    vi_cv_uint32="unsigned int"
  416.  else
  417.    if test "$cross_compiling" = yes; then
  418. @@ -4033,7 +3886,7 @@
  419.  main(){exit(sizeof(unsigned long) != 4);}
  420.  EOF
  421.  eval $ac_link
  422. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  423. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  424.    vi_cv_uint32="unsigned long"
  425.  else
  426.    vi_cv_uint32=no
  427. @@ -4086,7 +3936,7 @@
  428.  main(){exit(sizeof(int) != 4);}
  429.  EOF
  430.  eval $ac_link
  431. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  432. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  433.    vi_cv_int32="int"
  434.  else
  435.    if test "$cross_compiling" = yes; then
  436. @@ -4098,7 +3948,7 @@
  437.  main(){exit(sizeof(long) != 4);}
  438.  EOF
  439.  eval $ac_link
  440. -if test -s conftest && (./conftest; exit) 2>/dev/null; then
  441. +if test -s conftest$EXE && (./conftest; exit) 2>/dev/null; then
  442.    vi_cv_int32="long"
  443.  else
  444.    vi_cv_int32=no
  445. @@ -4180,7 +4020,7 @@
  446.  echo creating $CONFIG_STATUS
  447.  rm -f $CONFIG_STATUS
  448.  cat > $CONFIG_STATUS <<EOF
  449. -#! /bin/sh
  450. +#! ${CONFIG_SHELL-/bin/sh}
  451.  # Generated automatically by configure.
  452.  # Run this file to recreate the current configuration.
  453.  # This directory was configured as follows,
  454. @@ -4206,18 +4045,15 @@
  455.    *) echo "\$ac_cs_usage"; exit 1 ;;
  456.    esac
  457.  done
  458. -
  459.  ac_given_srcdir=$srcdir
  460.  ac_given_INSTALL="$INSTALL"
  461. -
  462.  trap 'rm -fr `echo "Makefile port.h:port.h.in
  463. -    pathnames.h:pathnames.h.in recover:recover.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
  464. +    pathnames.h:pathnames.h.in recover$EXE:recover.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
  465.  EOF
  466.  cat >> $CONFIG_STATUS <<EOF
  467. -
  468.  # Protect against being on the right side of a sed subst in config.status.
  469.  sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
  470. - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
  471. + s/@@/%@/; s/@@/@%/; s/@g\$/%g/; s!\\\\\\\\!/!g' > conftest.subs <<\\CEOF
  472.  $ac_vpsub
  473.  $extrasub
  474.  s%@CFLAGS@%$CFLAGS%g
  475. @@ -4278,13 +4114,24 @@
  476.  s%@int16_decl@%$int16_decl%g
  477.  s%@u_int32_decl@%$u_int32_decl%g
  478.  s%@int32_decl@%$int32_decl%g
  479. +s%@CMD@%$CMD%g
  480. +s%@EXE@%$EXE%g
  481. +s%@PATHSEP@%$PATHSEP%g
  482. +s%@VI_DOSISH@%$vi_cv_DOSish%g
  483. +s%@emxadds@%$emxadds%g
  484. +s%@emxfix@%$emxfix%g
  485.  
  486.  CEOF
  487.  EOF
  488. +# @@@@ might try to distinguish between all-longname systems and per-FS
  489. +# @@@@ systems later...
  490.  cat >> $CONFIG_STATUS <<EOF
  491.  
  492. +host_os="$host_os"
  493. +CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
  494. +
  495.  CONFIG_FILES=\${CONFIG_FILES-"Makefile port.h:port.h.in
  496. -    pathnames.h:pathnames.h.in recover:recover.in"}
  497. +    pathnames.h:pathnames.h.in recover$CMD:recover.in"}
  498.  EOF
  499.  cat >> $CONFIG_STATUS <<\EOF
  500.  for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
  501. @@ -4329,6 +4172,8 @@
  502.    case "$ac_file" in
  503.    *Makefile*) ac_comsub="1i\\
  504.  # $configure_input" ;;
  505. +  *recover*) if test "$host_os" = "os2"; then ac_comsub="1i\\
  506. +extproc ${CONFIG_SHELL-/bin/sh}"; else ac_comsub= ; fi ;;
  507.    *) ac_comsub= ;;
  508.    esac
  509.    sed -e "$ac_comsub
  510. diff -rwuPB ..\nvi-1.79-dist/build/Makefile.in ./build/Makefile.in
  511. --- ..\nvi-1.79-dist/build/Makefile.in    Wed Oct 23 08:43:38 1996
  512. +++ ./build/Makefile.in    Sun Jun 29 15:39:30 1997
  513. @@ -3,7 +3,8 @@
  514.  srcdir=    @srcdir@/..
  515.  CC=    @CC@
  516.  OPTFLAG=@OPTFLAG@
  517. -CFLAGS=    -c $(OPTFLAG) @CFLAGS@ -I. -I$(srcdir)/include @CPPFLAGS@
  518. +CFLAGS=    -c $(OPTFLAG) @CFLAGS@ -I. -I$(srcdir)/include @CPPFLAGS@ \
  519. +    -DVI_DOSISH=@VI_DOSISH@ @emxadds@
  520.  LDFLAGS=@LDFLAGS@
  521.  PERL=    @vi_cv_path_perl@
  522.  PERLLIB=@vi_cv_perllib@
  523. @@ -43,13 +44,14 @@
  524.      v_zexit.o vi.o vs_line.o vs_msg.o vs_refresh.o vs_relative.o \
  525.      vs_smap.o vs_split.o
  526.  
  527. -all: nvi @tknvi@
  528. +all: nvi@EXE@ @tknvi@
  529.  
  530.  NVIALL=    $(CLOBJS) $(VIOBJS) @cobjs@ @LIBOBJS@
  531. -nvi nex: $(NVIALL)
  532. +nvi@EXE@ nex@EXE@: $(NVIALL)
  533.      $(SHRPENV) $(CC) $(LDFLAGS) -o $@ $(NVIALL) @LIBS@
  534. -    -rm -f nex
  535. -    ln $@ nex
  536. +    @emxfix@
  537. +    -rm -f nex@EXE@
  538. +    @vi_cv_path_ln@ $@ nex@EXE@
  539.  
  540.  TKALL=    $(TKOBJS) $(VIOBJS) @LIBOBJS@
  541.  tknvi: $(TKALL)
  542. @@ -78,17 +80,17 @@
  543.      @echo "Installing vi, ex, view: $(bindir) ..."
  544.      [ -d $(bindir) ] || \
  545.          ($(mkdir) $(bindir) && $(chmod) $(dmode) $(bindir))
  546. -    cd $(bindir) && $(rm) -f `echo vi | sed '$(transform)'`
  547. -    $(cp) nvi $(bindir)/`echo vi | sed '$(transform)'`
  548. -    cd $(bindir) && [ -f $(strip) ] && \
  549. -        $(strip) `echo vi | sed '$(transform)'`
  550. -    cd $(bindir) && $(chmod) $(emode) `echo vi | sed '$(transform)'`
  551. -    cd $(bindir) && $(rm) -f `echo ex | sed '$(transform)'`
  552. -    cd $(bindir) && $(rm) -f `echo view | sed '$(transform)'`
  553. +    cd $(bindir) && $(rm) -f `echo vi@EXE@ | sed '$(transform)'`
  554. +    $(cp) nvi@EXE@ $(bindir)/`echo vi@EXE@ | sed '$(transform)'`
  555. +    cd $(bindir) && [ -f $(strip)@EXE@ ] && \
  556. +        $(strip) `echo vi@EXE@ | sed '$(transform)'`
  557. +    cd $(bindir) && $(chmod) $(emode) `echo vi@EXE@ | sed '$(transform)'`
  558. +    cd $(bindir) && $(rm) -f `echo ex@EXE@ | sed '$(transform)'`
  559. +    cd $(bindir) && $(rm) -f `echo view@EXE@ | sed '$(transform)'`
  560.      cd $(bindir) && $(ln) \
  561. -        `echo vi | sed '$(transform)'` `echo ex | sed '$(transform)'`
  562. +        `echo vi@EXE@ | sed '$(transform)'` `echo ex@EXE@ | sed '$(transform)'`
  563.      cd $(bindir) && $(ln) \
  564. -        `echo vi | sed '$(transform)'` `echo view | sed '$(transform)'`
  565. +        `echo vi@EXE@ | sed '$(transform)'` `echo view@EXE@ | sed '$(transform)'`
  566.      [ -d $(mandir) ] || \
  567.          ($(mkdir) $(mandir) && $(chmod) $(dmode) $(mandir))
  568.      [ -d $(mandir)/cat1 ] || \
  569. @@ -119,11 +121,11 @@
  570.  
  571.  cat=    dutch english french german ru_SU.KOI8-R spanish swedish
  572.  install_common:
  573. -    [ -f $(chmod) ]
  574. -    [ -f $(cp) ]
  575. -    [ -f $(ln) ]
  576. -    [ -f $(mkdir) ]
  577. -    [ -f $(rm) ]
  578. +    [ -f $(chmod)@EXE@ ]
  579. +    [ -f $(cp)@EXE@ ]
  580. +    [ -f $(ln)@EXE@ ]
  581. +    [ -f $(mkdir)@EXE@ ]
  582. +    [ -f $(rm)@EXE@ ]
  583.      [ -d $(prefix) ] || \
  584.          ($(mkdir) $(prefix) && $(chmod) $(dmode) $(prefix))
  585.      [ -d $(exec_prefix) ] || \
  586. @@ -139,8 +141,8 @@
  587.          cd $(datadir)/vi/catalog && $(chmod) $(fmode) *)
  588.      @echo "Installing Perl scripts: $(datadir)/vi/perl ..."
  589.      $(mkdir) $(datadir)/vi/perl && $(chmod) $(dmode) $(datadir)/vi/perl
  590. -    [ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && \
  591. -        cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm)
  592. +    -[ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && \
  593. +        (cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm)
  594.      (cd $(srcdir)/perl_scripts && $(cp) *.pl $(datadir)/vi/perl && \
  595.          cd $(datadir)/vi/perl && $(chmod) $(fmode) *.pl)
  596.      @echo "Installing Tcl scripts: $(datadir)/vi/tcl ..."
  597. @@ -148,8 +150,8 @@
  598.      (cd $(srcdir)/tcl_scripts && $(cp) *.tcl $(datadir)/vi/tcl && \
  599.          cd $(datadir)/vi/tcl && $(chmod) $(fmode) *.tcl)
  600.      @echo "Installing recover script: $(datadir)/vi/recover ..."
  601. -    ($(cp) recover $(datadir)/vi/recover && \
  602. -        $(chmod) $(emode) $(datadir)/vi/recover)
  603. +    ($(cp) recover@CMD@ $(datadir)/vi/recover@CMD@ && \
  604. +        $(chmod) $(emode) $(datadir)/vi/recover@CMD@)
  605.  
  606.  uninstall:
  607.      $(rm) -rf $(datadir)/vi
  608. diff -rwuPB ..\nvi-1.79-dist/build/pathnames.h.in ./build/pathnames.h.in
  609. --- ..\nvi-1.79-dist/build/pathnames.h.in    Wed Jun 26 10:08:48 1996
  610. +++ ./build/pathnames.h.in    Sun Jun  1 19:23:42 1997
  611. @@ -29,7 +29,7 @@
  612.  #endif
  613.  
  614.  #ifndef    _PATH_SYSEXRC
  615. -#define    _PATH_SYSEXRC    "/etc/vi.exrc"
  616. +#define    _PATH_SYSEXRC    "@prefix@/etc/vi.exrc"
  617.  #endif
  618.  
  619.  #ifndef    _PATH_TAGS
  620. diff -rwuPB ..\nvi-1.79-dist/build/recover.in ./build/recover.in
  621. --- ..\nvi-1.79-dist/build/recover.in    Thu Oct 10 20:41:50 1996
  622. +++ ./build/recover.in    Tue Jun 24 14:56:14 1997
  623. @@ -10,8 +10,8 @@
  624.  echo 'Recovering nvi editor sessions.'
  625.  
  626.  # Check editor backup files.
  627. -vibackup=`echo $RECDIR/vi.*`
  628. -if [ "$vibackup" != "$RECDIR/vi.*" ]; then
  629. +vibackup=`echo $RECDIR/vi*`
  630. +if [ "$vibackup" != "$RECDIR/vi*" ]; then
  631.      for i in $vibackup; do
  632.          # Only test files that are readable.
  633.          if test ! -r $i; then
  634. @@ -28,8 +28,8 @@
  635.  
  636.  # It is possible to get incomplete recovery files, if the editor crashes
  637.  # at the right time.
  638. -virecovery=`echo $RECDIR/recover.*`
  639. -if [ "$virecovery" != "$RECDIR/recover.*" ]; then
  640. +virecovery=`echo $RECDIR/re*`
  641. +if [ "$virecovery" != "$RECDIR/re*" ]; then
  642.      for i in $virecovery; do
  643.          # Only test files that are readable.
  644.          if test ! -r $i; then
  645. diff -rwuPB ..\nvi-1.79-dist/cl/cl.h ./cl/cl.h
  646. --- ..\nvi-1.79-dist/cl/cl.h    Wed Oct 23 08:29:50 1996
  647. +++ ./cl/cl.h    Fri Jun 27 10:37:50 1997
  648. @@ -49,6 +49,17 @@
  649.  #define    CL_SIGWINCH    0x0100    /* SIGWINCH arrived. */
  650.  #define    CL_STDIN_TTY    0x0200    /* Talking to a terminal. */
  651.      u_int32_t flags;
  652. +#ifdef __EMX__
  653. +#ifdef EMX_MOUSE
  654. +    int mou_pipe;        /* Pipe to mouse event thread. */
  655. +    int mou_thr;        /* Mouse thread ID for shutdown. */
  656. +#endif
  657. +#ifdef EMX_CURSOR
  658. +    short cs1;        /* original cursor start scan line */
  659. +    short cs2;        /* original cursor end scan line */
  660. +    short csa;        /* original cursor attribute */
  661. +#endif
  662. +#endif
  663.  } CL_PRIVATE;
  664.  
  665.  #define    CLP(sp)        ((CL_PRIVATE *)((sp)->gp->cl_private))
  666. @@ -73,6 +84,20 @@
  667.  #endif
  668.  #ifndef FALSE
  669.  #define    FALSE    0
  670. +#endif
  671. +
  672. +#ifdef __EMX__
  673. +#ifdef EMX_MOUSE
  674. +struct msev
  675. +{
  676. +    unsigned short button;
  677. +#define MEV_B1        0x01
  678. +#define MEV_B2        0x02
  679. +#define MEV_B3        0x04
  680. +    unsigned short x;
  681. +    unsigned short y;
  682. +};
  683. +#endif
  684.  #endif
  685.  
  686.  #include "cl_extern.h"
  687. diff -rwuPB ..\nvi-1.79-dist/cl/cl_funcs.c ./cl/cl_funcs.c
  688. --- ..\nvi-1.79-dist/cl/cl_funcs.c    Wed Oct 23 08:29:50 1996
  689. +++ ./cl/cl_funcs.c    Tue Jul 29 15:59:42 1997
  690. @@ -31,6 +31,27 @@
  691.  #include "../vi/vi.h"
  692.  #include "cl.h"
  693.  
  694. +#if VI_DOSISH
  695. +#ifdef __EMX__
  696. +/*
  697. + * If you are rebuilding vi under something other than OS/2, you will need
  698. + * to comment this code out.  The check against _emx_env should prevent
  699. + * systems other than OS/2 from trying to execute the API calls, so it
  700. + * should be safe to *run* the resulting binary anywhere.
  701. + */
  702. +#undef ERR
  703. +#define INCL_WINSWITCHLIST
  704. +#define INCL_VIO
  705. +#include <os2.h>
  706. +#include <process.h>
  707. +#include <os2thunk.h>
  708. +#ifdef EMX_TITLEBAR
  709. +extern USHORT _THUNK_FUNCTION (Win16SetTitle)();
  710. +#endif
  711. +#define ERR (0)
  712. +#endif
  713. +#endif
  714. +
  715.  /*
  716.   * cl_addstr --
  717.   *    Add len bytes from the string at the cursor, advancing the cursor.
  718. @@ -509,6 +530,53 @@
  719.      char *name;
  720.      int on;
  721.  {
  722. +#ifdef __EMX__
  723. +#ifdef EMX_TITLEBAR
  724. +/*
  725. + * If you are rebuilding vi under something other than OS/2, you will need
  726. + * to comment this code out.  The check against _emx_env should prevent
  727. + * systems other than OS/2 from trying to execute the API calls.
  728. + */
  729. +/*#undef ERR*/
  730. +    static char oldname[MAXNAMEL];
  731. +    HSWITCH hsw;
  732. +    SWCNTRL swc;
  733. +
  734. +    if (_emx_env & 0x0200)
  735. +    {
  736. +        if (!sp && !oldname[0])
  737. +        return 0;
  738. +        if (!on && !oldname[0])
  739. +        return 0;
  740. +        /* find us --- hopefully we get the right one... */
  741. +        if ((hsw = WinQuerySwitchHandle(NULLHANDLE, (PID) getpid())))
  742. +        {
  743. +        WinQuerySwitchEntry(hsw, &swc);
  744. +        if (!oldname[0])
  745. +        {
  746. +            strncpy(oldname, swc.szSwtitle, MAXNAMEL);
  747. +            oldname[MAXNAMEL] = '\0';
  748. +        }
  749. +        if (!name)
  750. +            swc.szSwtitle[0] = '\0';
  751. +        else
  752. +            strcpy(swc.szSwtitle, "Vi: ");
  753. +        strncat(swc.szSwtitle, (name? name: oldname),
  754. +            MAXNAMEL - strlen(swc.szSwtitle));
  755. +        swc.szSwtitle[MAXNAMEL] = '\0';
  756. +        WinChangeSwitchEntry(hsw, &swc);
  757. +        /* look away... */
  758. +        (_THUNK_PROLOG(8);
  759. +         _THUNK_FAR16(NULLHANDLE);
  760. +         _THUNK_FLAT(swc.szSwtitle);
  761. +         _THUNK_CALL(Win16SetTitle));
  762. +        }
  763. +    }
  764. +/*#define ERR (0)*/
  765. +#else
  766. +    /* no can do; ignore it */
  767. +#endif
  768. +#else
  769.      GS *gp;
  770.      CL_PRIVATE *clp;
  771.      char *ttype;
  772. @@ -535,6 +603,7 @@
  773.              (void)printf(XTERM_RENAME, ttype);
  774.              (void)fflush(stdout);
  775.          }
  776. +#endif
  777.      return (0);
  778.  }
  779.  
  780. @@ -559,6 +628,12 @@
  781.      clp = CLP(sp);
  782.      *allowedp = 1;
  783.  
  784. +#if VI_DOSISH
  785. +    /* We'll need a shell. */
  786. +    if (opts_empty(sp, O_SHELL, 0))
  787. +        return (1);
  788. +#endif
  789. +
  790.      /*
  791.       * The ex implementation of this function isn't needed by screens not
  792.       * supporting ex commands that require full terminal canonical mode
  793. @@ -578,10 +653,24 @@
  794.                  TCSASOFT | TCSADRAIN, &clp->orig);
  795.          }
  796.  
  797. +#if !VI_DOSISH
  798.          /* Stop the process group. */
  799.          (void)kill(0, SIGTSTP);
  800.  
  801.          /* Time passes ... */
  802. +#else
  803. +        {
  804. +            char *name, *cmd = O_STR(sp, O_SHELL);
  805. +
  806. +            if ((name = strrchr(cmd, '/')) != NULL)
  807. +            ++name;
  808. +            else if ((name = strrchr(cmd, '\\')) != NULL)
  809. +            ++name;
  810. +            else
  811. +            name = cmd;
  812. +            (void)spawnl(P_WAIT, cmd, name, NULL);
  813. +        }
  814. +#endif
  815.  
  816.          /* Restore terminal settings. */
  817.          if (F_ISSET(clp, CL_STDIN_TTY))
  818. @@ -612,6 +701,22 @@
  819.      (void)tcgetattr(STDIN_FILENO, &t);
  820.  #endif
  821.  
  822. +#ifdef __EMX__
  823. +#ifdef EMX_CURSOR
  824. +    /* Restore the cursor */
  825. +    if ((_emx_env & 0x0200) && clp->cs1 != -1)
  826. +    {
  827. +        VIOCURSORINFO ci;
  828. +
  829. +        ci.yStart = clp->cs1;
  830. +        ci.cEnd = clp->cs2;
  831. +        ci.attr = clp->csa;
  832. +        ci.cx = 1;
  833. +        VioSetCurType(&ci, (HVIO) 0);
  834. +    }
  835. +#endif
  836. +#endif
  837. +
  838.      /* Restore the cursor keys to normal mode. */
  839.      (void)keypad(stdscr, FALSE);
  840.  
  841. @@ -632,10 +737,24 @@
  842.       */
  843.      (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
  844.  
  845. +#if !VI_DOSISH
  846.      /* Stop the process group. */
  847.      (void)kill(0, SIGTSTP);
  848.  
  849.      /* Time passes ... */
  850. +#else
  851. +    {
  852. +        char *name, *cmd = O_STR(sp, O_SHELL);
  853. +
  854. +        if ((name = strrchr(cmd, '/')) != NULL)
  855. +        ++name;
  856. +        else if ((name = strrchr(cmd, '\\')) != NULL)
  857. +        ++name;
  858. +        else
  859. +        name = cmd;
  860. +        (void)spawnl(P_WAIT, cmd, name, NULL);
  861. +    }
  862. +#endif
  863.  
  864.      /*
  865.       * If we received a killer signal, we're done.  Leave everything
  866. @@ -670,6 +789,38 @@
  867.          return (1);
  868.      if (changed)
  869.          F_SET(CLP(sp), CL_SIGWINCH);
  870. +
  871. +#ifdef __EMX__
  872. +#ifdef EMX_CURSOR
  873. +    /* enable block cursor */
  874. +    if (_emx_env & 0x200)
  875. +    {
  876. +        VIOCURSORINFO ci;
  877. +        USHORT rc;
  878. +
  879. +        if (clp->cs1 == -1)
  880. +        {
  881. +        rc = VioGetCurType(&ci, (HVIO) 0);
  882. +        if (rc != 0)
  883. +            fprintf(stderr, "[VGCT%d]\n", rc);
  884. +        clp->cs1 = ci.yStart;
  885. +        clp->cs2 = ci.cEnd;
  886. +        clp->csa = ci.attr;
  887. +        }
  888. +        ci.yStart = 0;
  889. +        /* I'm assuming it's sane... naughty naughty */
  890. +        if (clp->cs2)
  891. +        ci.cEnd = clp->cs2;
  892. +        else
  893. +        ci.cEnd = -100;
  894. +        ci.cx = 1;
  895. +        ci.attr = 0;
  896. +        rc = VioSetCurType(&ci, (HVIO) 0);
  897. +        if (rc != 0)
  898. +        fprintf(stderr, "[VSCT%d]\n", rc);
  899. +    }
  900. +#endif
  901. +#endif
  902.  
  903.      return (0);
  904.  }
  905. diff -rwuPB ..\nvi-1.79-dist/cl/cl_main.c ./cl/cl_main.c
  906. --- ..\nvi-1.79-dist/cl/cl_main.c    Mon Oct 14 14:04:52 1996
  907. +++ ./cl/cl_main.c    Sun Jun 29 15:31:44 1997
  908. @@ -34,6 +34,12 @@
  909.  #include "cl.h"
  910.  #include "pathnames.h"
  911.  
  912. +#ifdef __EMX__
  913. +#define INCL_DOSPROCESS
  914. +#define INCL_MOU
  915. +#include <os2.h>
  916. +#endif
  917. +
  918.  GS *__global_list;                /* GLOBAL: List of screens. */
  919.  sigset_t __sigblockset;                /* GLOBAL: Blocked signals. */
  920.  
  921. @@ -44,6 +50,11 @@
  922.  static int       setsig __P((int, struct sigaction *, void (*)(int)));
  923.  static void       sig_end __P((GS *));
  924.  static void       term_init __P((char *, char *));
  925. +#ifdef __EMX__
  926. +#ifdef EMX_MOUSE
  927. +static void       mou_proc __P((void *));
  928. +#endif
  929. +#endif
  930.  
  931.  /*
  932.   * main --
  933. @@ -65,6 +76,9 @@
  934.      if (reenter++)
  935.          abort();
  936.  
  937. +#ifdef __EMX__
  938. +    _wildcard(&argc, &argv);
  939. +#endif
  940.      /* Create and initialize the global structure. */
  941.      __global_list = gp = gs_init(argv[0]);
  942.  
  943. @@ -164,10 +178,15 @@
  944.       * XXX
  945.       * Reset the X11 xterm icon/window name.
  946.       */
  947. +#if VI_DOSISH
  948. +    /* this is invalid in Unix version, note... */
  949. +    (void)cl_rename(0, 0, 0);
  950. +#else
  951.      if (F_ISSET(clp, CL_RENAME)) {
  952.          (void)printf(XTERM_RENAME, ttype);
  953.          (void)fflush(stdout);
  954.      }
  955. +#endif
  956.  
  957.      /* If a killer signal arrived, pretend we just got it. */
  958.      if (clp->killersig) {
  959. @@ -243,9 +262,43 @@
  960.       * We expect that if we've lost our controlling terminal that the
  961.       * open() (but not the tcgetattr()) will fail.
  962.       */
  963. +#ifdef __EMX__
  964. +#ifdef EMX_MOUSE
  965. +    clp->mou_pipe = -1;
  966. +    clp->mou_thr = 0;
  967. +#endif
  968. +#ifdef EMX_CURSOR
  969. +    clp->cs1 = -1;
  970. +#endif
  971. +#endif
  972.      if (F_ISSET(clp, CL_STDIN_TTY)) {
  973.          if (tcgetattr(STDIN_FILENO, &clp->orig) == -1)
  974.              goto tcfail;
  975. +#ifdef __EMX__
  976. +#ifdef EMX_MOUSE
  977. +        /*
  978. +         * Start a thread to handle mouse input.  We do not display
  979. +         * a mouse pointer; we just accept mouse events and change
  980. +         * them into strings of vi commands.
  981. +         */
  982. +        if (_emx_env & 0x200)
  983. +        {
  984. +            int pi[2];
  985. +
  986. +            if (pipe(pi) != -1)
  987. +            {
  988. +            clp->mou_pipe = pi[0];
  989. +            if ((clp->mou_thr = _beginthread(mou_proc, 0, 24576,
  990. +                            (void *) pi[1])) == -1)
  991. +            {
  992. +                close(pi[0]);
  993. +                close(pi[1]);
  994. +                clp->mou_pipe = -1;
  995. +            }
  996. +            }
  997. +        }
  998. +#endif
  999. +#endif
  1000.      } else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) {
  1001.          if (tcgetattr(fd, &clp->orig) == -1) {
  1002.  tcfail:            perr(gp->progname, "tcgetattr");
  1003. @@ -469,3 +522,61 @@
  1004.      (void)fprintf(stderr, "%s\n", strerror(errno));
  1005.      exit(1);
  1006.  }
  1007. +
  1008. +#ifdef __EMX__
  1009. +#ifdef EMX_MOUSE
  1010. +/*
  1011. + * mou_proc --
  1012. + *    Process mouse events from a VDM.
  1013. + *    OS/2 only.
  1014. + */
  1015. +static void
  1016. +mou_proc(arg)
  1017. +    void *arg;
  1018. +{
  1019. +    int fd = (int) arg;
  1020. +    MOUEVENTINFO ev;
  1021. +    struct msev mev;
  1022. +    USHORT msk, rc;
  1023. +    HMOU hm;
  1024. +
  1025. +    if ((rc = MouOpen((PSZ) 0, &hm)) != 0)
  1026. +    {
  1027. +    close(fd);
  1028. +    _endthread();
  1029. +    }
  1030. +    msk = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;
  1031. +    if ((rc = MouSetEventMask(&msk, hm)) != 0)
  1032. +    {
  1033. +    MouClose(hm);
  1034. +    close(fd);
  1035. +    _endthread();
  1036. +    }
  1037. +    msk = 0; /* system draws pointer, return position in pels */
  1038. +    if ((rc = MouSetDevStatus(&msk, hm)) != 0)
  1039. +    {
  1040. +    MouClose(hm);
  1041. +    close(fd);
  1042. +    _endthread();
  1043. +    }
  1044. +    msk = MOU_WAIT;
  1045. +    while ((rc = MouReadEventQue(&ev, &msk, hm)) == 0)
  1046. +    {
  1047. +    if (!ev.fs)
  1048. +        continue;    /* we only want mouse-down events */
  1049. +    mev.button = 0;
  1050. +    if (ev.fs & MOUSE_BN1_DOWN)
  1051. +        mev.button |= MEV_B1;
  1052. +    if (ev.fs & MOUSE_BN2_DOWN)
  1053. +        mev.button |= MEV_B2;
  1054. +    if (ev.fs & MOUSE_BN3_DOWN)
  1055. +        mev.button |= MEV_B3;
  1056. +    mev.x = ev.col;
  1057. +    mev.y = ev.row;
  1058. +    write(fd, &mev, sizeof mev);
  1059. +    }
  1060. +    MouClose(hm);
  1061. +    close(fd);
  1062. +}
  1063. +#endif
  1064. +#endif
  1065. diff -rwuPB ..\nvi-1.79-dist/cl/cl_read.c ./cl/cl_read.c
  1066. --- ..\nvi-1.79-dist/cl/cl_read.c    Tue Sep 24 19:49:50 1996
  1067. +++ ./cl/cl_read.c    Fri Jun 27 10:36:34 1997
  1068. @@ -39,6 +39,12 @@
  1069.      u_int32_t, CHAR_T *, size_t, int *, struct timeval *));
  1070.  static int    cl_resize __P((SCR *, size_t, size_t));
  1071.  
  1072. +#ifdef __EMX__
  1073. +#ifdef EMX_MOUSE
  1074. +static int    mou_read __P((SCR *, char *, int));
  1075. +#endif
  1076. +#endif
  1077. +
  1078.  /*
  1079.   * cl_event --
  1080.   *    Return a single event.
  1081. @@ -221,16 +227,36 @@
  1082.       * It's ugly that we wait on scripting file descriptors here, but it's
  1083.       * the only way to keep from locking out scripting windows.
  1084.       */
  1085. +#if defined(__EMX__) && defined(EMX_MOUSE)
  1086. +    if ((clp->mou_pipe != -1 && !term_reset) || F_ISSET(gp, G_SCRWIN)) {
  1087. +#else
  1088.      if (F_ISSET(gp, G_SCRWIN)) {
  1089. +#endif
  1090.  loop:        FD_ZERO(&rdfd);
  1091.          FD_SET(STDIN_FILENO, &rdfd);
  1092.          maxfd = STDIN_FILENO;
  1093. +#ifdef __EMX__
  1094. +#ifdef EMX_MOUSE
  1095. +        if (clp->mou_pipe != -1)
  1096. +        {
  1097. +            FD_SET(clp->mou_pipe, &rdfd);
  1098. +            if (clp->mou_pipe > maxfd)
  1099. +            maxfd = clp->mou_pipe;
  1100. +        }
  1101. +#endif
  1102. +#endif
  1103.          for (tsp = gp->dq.cqh_first;
  1104.              tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
  1105.              if (F_ISSET(sp, SC_SCRIPT)) {
  1106. +#if VI_DOSISH
  1107. +                FD_SET(sp->script->sh_master >> 16, &rdfd);
  1108. +                if ((sp->script->sh_master >> 16) > maxfd)
  1109. +                    maxfd = sp->script->sh_master >> 16;
  1110. +#else
  1111.                  FD_SET(sp->script->sh_master, &rdfd);
  1112.                  if (sp->script->sh_master > maxfd)
  1113.                      maxfd = sp->script->sh_master;
  1114. +#endif
  1115.              }
  1116.          switch (select(maxfd + 1, &rdfd, NULL, NULL, NULL)) {
  1117.          case 0:
  1118. @@ -241,6 +267,25 @@
  1119.              break;
  1120.          }
  1121.          if (!FD_ISSET(STDIN_FILENO, &rdfd)) {
  1122. +#ifdef __EMX__
  1123. +#ifdef EMX_MOUSE
  1124. +            if (FD_ISSET(clp->mou_pipe, &rdfd))
  1125. +            {
  1126. +                if ((nr = mou_read(sp, bp, blen)) == -1)
  1127. +                {
  1128. +                close(clp->mou_pipe);
  1129. +                clp->mou_pipe = -1;
  1130. +                }
  1131. +                else if (nr > 0)
  1132. +                {
  1133. +                *nrp = nr;
  1134. +                clp->eof_count = 0;
  1135. +                return INP_OK;
  1136. +                }
  1137. +            }
  1138. +            else
  1139. +#endif
  1140. +#endif
  1141.              if (sscr_input(sp))
  1142.                  return (INP_ERR);
  1143.              goto loop;
  1144. @@ -332,3 +377,123 @@
  1145.          return (1);
  1146.      return (0);
  1147.  }
  1148. +
  1149. +#ifdef __EMX__
  1150. +#ifdef EMX_MOUSE
  1151. +/*
  1152. + * mou_read --
  1153. + *    Read a "digested" mouse event and return a command string.
  1154. + *    For now, all mouse buttons are equivalent and we only generate
  1155. + *    movement commands.  Said commands are not optimized.
  1156. + */
  1157. +static int mou_read(sp, bp, len)
  1158. +    SCR *sp;
  1159. +    char *bp;
  1160. +    int len;
  1161. +{
  1162. +    struct msev ev;
  1163. +    char xbuf[sizeof ev];
  1164. +    int c, f;
  1165. +    CL_PRIVATE *clp;
  1166. +    GS *gp;
  1167. +    SCR *n;
  1168. +
  1169. +    gp = sp->gp;
  1170. +    clp = CLP(sp);
  1171. +    c = 0;
  1172. +    while (c + (f = read(clp->mou_pipe, xbuf + c, sizeof ev - c)) < sizeof ev)
  1173. +    {
  1174. +    if (f == -1)
  1175. +        return -1;
  1176. +    c += f;
  1177. +    }
  1178. +    memcpy(&ev, xbuf, sizeof ev);
  1179. +    if (!F_SET(sp, SC_VI)) /* mouse actions only in vi */
  1180. +    return 0;
  1181. +    /*
  1182. +     * This gets fairly disgusting.  First, we have to escape out of any
  1183. +     * insert etc. mode.  Then we have to check to see if we're switching
  1184. +     * screens; then we have to position within the screen.  If this lands
  1185. +     * us in a prompt area, we push a colon command instead.  If not, we
  1186. +     * must reestablish the previous input mode.  And if we run out of space
  1187. +     * doing any of this, we beep and return 0.
  1188. +     *
  1189. +     * !!!
  1190. +     * No attempt is made to deal with mapped keys; we're called at too low
  1191. +     * a level.  Likewise, invoking this when a motion is expected to complete
  1192. +     * a command will fail.  Fixing this would pretty much require a new,
  1193. +     * magic "go directly to specified screen R/C" command and, again, we are
  1194. +     * at too low a level to pull it off.
  1195. +     */
  1196. +    c = 0;
  1197. +    if (sp->showmode != SM_COMMAND)
  1198. +    {
  1199. +    /* escape to command mode */
  1200. +    *bp++ = '\033';
  1201. +    len--;
  1202. +    c++;
  1203. +    }
  1204. +    for (n = sp, f = 0; n != sp || !f; n = n->q.cqe_next, f = 1)
  1205. +    {
  1206. +    if (n->woff <= ev.y && n->woff + n->rows > ev.y)
  1207. +        break;
  1208. +    if (!len)
  1209. +        break;
  1210. +    *bp++ = '\027';    /* ^W */
  1211. +    len--;
  1212. +    c++;
  1213. +    }
  1214. +    if (!len)
  1215. +    return 0;
  1216. +    if (n->woff + n->rows - 1 == ev.y)
  1217. +    {
  1218. +    /* enter command mode */
  1219. +    *bp = ':';
  1220. +    return c + 1;
  1221. +    }
  1222. +    /* now we have to figure out where in the window we are... */
  1223. +    /* getting current screen position is a lost cause, it seems */
  1224. +    ev.y -= n->woff - 1;
  1225. +    if (len < 1 + (ev.y == 1? 0: ev.y < 10? 1: ev.y < 100? 2: 3))
  1226. +    return 0;
  1227. +    if (ev.y != 1)
  1228. +    {
  1229. +    sprintf(bp, "%d", ev.y);
  1230. +    while (*bp)
  1231. +    {
  1232. +        bp++;
  1233. +        len--;
  1234. +        c++;
  1235. +    }
  1236. +    }
  1237. +    *bp++ = 'H';
  1238. +    len--;
  1239. +    c++;
  1240. +    /*
  1241. +     * The columns are really fun, because tabs and non-ASCII throw them off.
  1242. +     * And we can't "see" the file to know what to do.  :-(
  1243. +     * We just use '0' and/or '|' and hope.
  1244. +     */
  1245. +    ev.x++;
  1246. +    if (len < 1 + (ev.x == 1? 0: ev.x < 10? 1: ev.x < 100? 2: 3))
  1247. +    return 0;
  1248. +    if (ev.x == 1)
  1249. +    {
  1250. +    *bp++ = '0';
  1251. +    len--;
  1252. +    c++;
  1253. +    }
  1254. +    else
  1255. +    {
  1256. +    sprintf(bp, "%d|", ev.x);
  1257. +    while (*bp)
  1258. +    {
  1259. +        bp++;
  1260. +        len--;
  1261. +        c++;
  1262. +    }
  1263. +    }
  1264. +    return c;
  1265. +}
  1266. +#endif
  1267. +#endif
  1268. diff -rwuPB ..\nvi-1.79-dist/cl/cl_screen.c ./cl/cl_screen.c
  1269. --- ..\nvi-1.79-dist/cl/cl_screen.c    Wed Oct 23 08:29:52 1996
  1270. +++ ./cl/cl_screen.c    Fri Jun 27 10:32:12 1997
  1271. @@ -29,6 +29,12 @@
  1272.  #include "../common/common.h"
  1273.  #include "cl.h"
  1274.  
  1275. +#ifdef __EMX__
  1276. +#define INCL_DOSPROCESS
  1277. +#define INCL_VIO
  1278. +#include <os2.h>
  1279. +#endif
  1280. +
  1281.  static int    cl_ex_end __P((GS *));
  1282.  static int    cl_ex_init __P((SCR *));
  1283.  static void    cl_freecap __P((CL_PRIVATE *));
  1284. @@ -96,6 +102,21 @@
  1285.          }
  1286.          (void)move(RLNO(sp, sp->rows) - 1, 0);
  1287.          refresh();
  1288. +
  1289. +#ifdef __EMX__
  1290. +#ifdef EMX_CURSOR
  1291. +        if ((_emx_env & 0x0200) && clp->cs1 != -1)
  1292. +        {
  1293. +            VIOCURSORINFO ci;
  1294. +
  1295. +            ci.yStart = clp->cs1;
  1296. +            ci.cEnd = clp->cs2;
  1297. +            ci.attr = clp->csa;
  1298. +            ci.cx = 1;
  1299. +            VioSetCurType(&ci, (HVIO) 0);
  1300. +        }
  1301. +#endif
  1302. +#endif
  1303.      }
  1304.  
  1305.      /* Enter the requested mode. */
  1306. @@ -169,6 +190,30 @@
  1307.       */
  1308.      (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
  1309.  
  1310. +#ifdef __EMX__
  1311. +#ifdef EMX_MOUSE
  1312. +    /* If using a mouse thread (OS/2), end it. */
  1313. +    if (clp->mou_pipe != -1)
  1314. +    {
  1315. +        close(clp->mou_pipe);
  1316. +        DosKillThread((TID) clp->mou_thr);
  1317. +    }
  1318. +#endif
  1319. +#ifdef EMX_CURSOR
  1320. +    /* Restore the cursor */
  1321. +    if ((_emx_env & 0x0200) && clp->cs1 != -1)
  1322. +    {
  1323. +        VIOCURSORINFO ci;
  1324. +
  1325. +        ci.yStart = clp->cs1;
  1326. +        ci.cEnd = clp->cs2;
  1327. +        ci.attr = clp->csa;
  1328. +        ci.cx = 1;
  1329. +        VioSetCurType(&ci, (HVIO) 0);
  1330. +    }
  1331. +#endif
  1332. +#endif
  1333. +
  1334.      F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
  1335.      return (rval);
  1336.  }
  1337. @@ -291,6 +336,7 @@
  1338.       */
  1339.      clp->ti_te = TI_SENT;
  1340.  
  1341. +#if !VI_DOSISH
  1342.      /*
  1343.       * XXX
  1344.       * Historic implementations of curses handled SIGTSTP signals
  1345. @@ -308,6 +354,7 @@
  1346.       * we're doing The Right Thing.
  1347.       */
  1348.      (void)signal(SIGTSTP, SIG_DFL);
  1349. +#endif
  1350.  
  1351.      /*
  1352.       * If flow control was on, turn it back on.  Turn signals on.  ISIG
  1353. @@ -372,6 +419,39 @@
  1354.  err:        (void)cl_vi_end(sp->gp);
  1355.          return (1);
  1356.      }
  1357. +
  1358. +#ifdef __EMX__
  1359. +#ifdef EMX_CURSOR
  1360. +    /* enable block cursor */
  1361. +    if (_emx_env & 0x200)
  1362. +    {
  1363. +        VIOCURSORINFO ci;
  1364. +        USHORT rc;
  1365. +
  1366. +        if (clp->cs1 == -1)
  1367. +        {
  1368. +        rc = VioGetCurType(&ci, (HVIO) 0);
  1369. +        if (rc != 0)
  1370. +            fprintf(stderr, "[VGCT%d]\n", rc);
  1371. +        clp->cs1 = ci.yStart;
  1372. +        clp->cs2 = ci.cEnd;
  1373. +        clp->csa = ci.attr;
  1374. +        }
  1375. +        ci.yStart = 0;
  1376. +        /* I'm assuming it's sane... naughty naughty */
  1377. +        if (clp->cs2)
  1378. +        ci.cEnd = clp->cs2;
  1379. +        else
  1380. +        ci.cEnd = -100;
  1381. +        ci.cx = 1;
  1382. +        ci.attr = 0;
  1383. +        rc = VioSetCurType(&ci, (HVIO) 0);
  1384. +        if (rc != 0)
  1385. +        fprintf(stderr, "[VSCT%d]\n", rc);
  1386. +    }
  1387. +#endif
  1388. +#endif
  1389. +
  1390.      return (0);
  1391.  }
  1392.  
  1393. diff -rwuPB ..\nvi-1.79-dist/cl/cl_term.c ./cl/cl_term.c
  1394. --- ..\nvi-1.79-dist/cl/cl_term.c    Sun Sep 15 14:56:26 1996
  1395. +++ ./cl/cl_term.c    Sun Jun 29 14:56:56 1997
  1396. @@ -63,9 +63,35 @@
  1397.      {"kcuu1",    "k",    "cursor up"},
  1398.      {NULL},
  1399.  };
  1400. +#ifdef EMX_KEYS
  1401. +static const char *c_pclist[] = {
  1402. +    "L",
  1403. +    "S",
  1404. +    "P",
  1405. +    "",
  1406. +    "",
  1407. +    "O",
  1408. +    "G",
  1409. +    "R",
  1410. +    "",
  1411. +    "K",
  1412. +    "Q",
  1413. +    "I",
  1414. +    "",
  1415. +    "",
  1416. +    "M",
  1417. +    "H",
  1418. +    0,
  1419. +};
  1420. +#endif
  1421.  static TKLIST const m1_tklist[] = {    /* Input mappings (lookup). */
  1422.      {NULL},
  1423.  };
  1424. +#ifdef EMX_KEYS
  1425. +static const char *m1_pclist[] = {
  1426. +    0,
  1427. +};
  1428. +#endif
  1429.  static TKLIST const m2_tklist[] = {    /* Input mappings (set or delete). */
  1430.      {"kcud1",  "\033ja",    "cursor down"},            /* ^[ja */
  1431.      {"kcub1",  "\033ha",    "cursor left"},            /* ^[ha */
  1432. @@ -73,6 +99,15 @@
  1433.      {"kcuf1",  "\033la",    "cursor right"},        /* ^[la */
  1434.      {NULL},
  1435.  };
  1436. +#ifdef EMX_KEYS
  1437. +static const char *m2_pclist[] = {
  1438. +    "P",
  1439. +    "K",
  1440. +    "H",
  1441. +    "M",
  1442. +    0,
  1443. +};
  1444. +#endif
  1445.  
  1446.  /*
  1447.   * cl_term_init --
  1448. @@ -89,6 +124,65 @@
  1449.      TKLIST const *tkp;
  1450.      char *t;
  1451.  
  1452. +#ifdef EMX_KEYS
  1453. +    char b[2];
  1454. +    int k;
  1455. +
  1456. +    /*
  1457. +     * Default mappings; since PC keyboards return \0 as the first
  1458. +     * character of an extended key, these can't live in termcap until
  1459. +     * the termcap folks discover a clue and lose the C-string mentality.
  1460. +     */
  1461. +    b[0] = 0;
  1462. +    for (k = 0; c_tklist[k].name; k++)
  1463. +    {
  1464. +        if (c_pclist[k][0] != '\0')
  1465. +        {
  1466. +        b[1] = c_pclist[k][0];
  1467. +        if (seq_set(sp, c_tklist[k].name, strlen(c_tklist[k].name),
  1468. +                b, 2, c_tklist[k].output,
  1469. +                strlen(c_tklist[k].output), SEQ_COMMAND,
  1470. +                SEQ_NOOVERWRITE | SEQ_SCREEN))
  1471. +            break;
  1472. +        }
  1473. +    }
  1474. +    for (k = 0; m1_tklist[k].name; k++)
  1475. +    {
  1476. +        if (m1_pclist[k][0] != '\0')
  1477. +        {
  1478. +        b[1] = m1_pclist[k][0];
  1479. +        for (kp = keylist;; ++kp)
  1480. +            if (kp->value == tkp->value)
  1481. +                break;
  1482. +        if (kp == NULL)
  1483. +            continue;
  1484. +        if (seq_set(sp, m1_tklist[k].name, strlen(m1_tklist[k].name),
  1485. +                b, 2, &kp->ch, 1, SEQ_INPUT,
  1486. +                SEQ_NOOVERWRITE | SEQ_SCREEN))
  1487. +            break;
  1488. +        }
  1489. +    }
  1490. +    for (k = 0; m2_tklist[k].name; k++)
  1491. +    {
  1492. +        if (m2_pclist[k][0] != '\0')
  1493. +        {
  1494. +        b[1] = m2_pclist[k][0];
  1495. +        if (m2_tklist[k].output == NULL) {
  1496. +            if (seq_set(sp, m2_tklist[k].name,
  1497. +                strlen(m2_tklist[k].name),
  1498. +                b, 2, NULL, 0,
  1499. +                SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
  1500. +                break;
  1501. +        } else
  1502. +            if (seq_set(sp, m2_tklist[k].name,
  1503. +                strlen(m2_tklist[k].name),
  1504. +                b, 2, m2_tklist[k].output,
  1505. +                strlen(m2_tklist[k].output),
  1506. +                SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
  1507. +                break;
  1508. +        }
  1509. +    }
  1510. +#endif
  1511.      /* Command mappings. */
  1512.      for (tkp = c_tklist; tkp->name != NULL; ++tkp) {
  1513.          if ((t = tigetstr(tkp->ts)) == NULL || t == (char *)-1)
  1514. @@ -205,6 +299,9 @@
  1515.  {
  1516.      size_t nlen;
  1517.      char *p, keyname[64];
  1518. +#ifdef EMX_KEYS
  1519. +    size_t klen;
  1520. +#endif
  1521.  
  1522.      (void)snprintf(keyname, sizeof(keyname), "kf%d", atoi(from + 1));
  1523.      if ((p = tigetstr(keyname)) == NULL ||
  1524. @@ -215,10 +312,19 @@
  1525.          return (1);
  1526.      }
  1527.  
  1528. +#ifdef EMX_KEYS
  1529. +    klen = strlen(p);
  1530. +    if (p[0] == '\200')
  1531. +        p[0] = '\0';
  1532. +#endif
  1533.      nlen = snprintf(keyname,
  1534.          sizeof(keyname), "function key %d", atoi(from + 1));
  1535.      return (seq_set(sp, keyname, nlen,
  1536. +#ifdef EMX_KEYS
  1537. +        p, klen, to, tlen, stype, SEQ_NOOVERWRITE | SEQ_SCREEN));
  1538. +#else
  1539.          p, strlen(p), to, tlen, stype, SEQ_NOOVERWRITE | SEQ_SCREEN));
  1540. +#endif
  1541.  }
  1542.  
  1543.  /*
  1544. @@ -287,6 +393,7 @@
  1545.      struct stat sb;
  1546.      char *tty;
  1547.  
  1548. +#ifndef VI_DOSISH
  1549.      /* Find the tty, get the current permissions. */
  1550.      if ((tty = ttyname(STDERR_FILENO)) == NULL) {
  1551.          if (sp != NULL)
  1552. @@ -318,6 +425,7 @@
  1553.                      "045|messages not turned off: %s", tty);
  1554.              return (1);
  1555.          }
  1556. +#endif
  1557.      return (0);
  1558.  }
  1559.  
  1560. diff -rwuPB ..\nvi-1.79-dist/common/exf.c ./common/exf.c
  1561. --- ..\nvi-1.79-dist/common/exf.c    Thu Oct 10 20:33:54 1996
  1562. +++ ./common/exf.c    Tue Jun 24 16:16:28 1997
  1563. @@ -187,9 +187,18 @@
  1564.          (void)snprintf(tname, sizeof(tname),
  1565.              "%s/vi.XXXXXX", O_STR(sp, O_DIRECTORY));
  1566.          if ((fd = mkstemp(tname)) == -1) {
  1567. +#if VI_DOSISH
  1568. +            /* try a shorter name... */
  1569. +            (void)snprintf(tname, sizeof(tname),
  1570. +                "%s/VIXXXXXX", O_STR(sp, O_DIRECTORY));
  1571. +            if ((fd = mkstemp(tname)) == -1) {
  1572. +#endif
  1573.              msgq(sp, M_SYSERR,
  1574.                  "237|Unable to create temporary file");
  1575.              goto err;
  1576. +#if VI_DOSISH
  1577. +            }
  1578. +#endif
  1579.          }
  1580.          (void)close(fd);
  1581.  
  1582. @@ -658,7 +667,9 @@
  1583.       *
  1584.       * !!!
  1585.       * Re: FR_DONTDELETE, see the comment above in file_init().
  1586. +     * --- EMX: can't unlink an open file...
  1587.       */
  1588. +#ifndef VI_DOSISH
  1589.      if (!F_ISSET(frp, FR_DONTDELETE) && frp->tname != NULL) {
  1590.          if (unlink(frp->tname))
  1591.              msgq_str(sp, M_SYSERR, frp->tname, "240|%s: remove");
  1592. @@ -672,6 +683,7 @@
  1593.          }
  1594.          sp->frp = NULL;
  1595.      }
  1596. +#endif
  1597.  
  1598.      /*
  1599.       * Clean up the EXF structure.
  1600. @@ -684,6 +696,23 @@
  1601.          return (1);
  1602.      }
  1603.  
  1604. +#if VI_DOSISH
  1605. +    /* We couldn't do this while it was open (EACCES)... */
  1606. +    if (!F_ISSET(frp, FR_DONTDELETE) && frp->tname != NULL) {
  1607. +        if (unlink(frp->tname))
  1608. +            msgq_str(sp, M_SYSERR, frp->tname, "240|%s: remove");
  1609. +        free(frp->tname);
  1610. +        frp->tname = NULL;
  1611. +        if (F_ISSET(frp, FR_TMPFILE)) {
  1612. +            CIRCLEQ_REMOVE(&sp->gp->frefq, frp, q);
  1613. +            if (frp->name != NULL)
  1614. +                free(frp->name);
  1615. +            free(frp);
  1616. +        }
  1617. +        sp->frp = NULL;
  1618. +    }
  1619. +#endif
  1620. +
  1621.      /* COMMITTED TO THE CLOSE.  THERE'S NO GOING BACK... */
  1622.  
  1623.      /* Stop logging. */
  1624. @@ -700,17 +729,26 @@
  1625.       * Unlink backup file first, we can detect that the recovery file
  1626.       * doesn't reference anything when the user tries to recover it.
  1627.       * There's a race, here, obviously, but it's fairly small.
  1628. +     * --- EMX: if the file is open it cannot be unlink()ed; rearrange
  1629.       */
  1630. +#if VI_DOSISH
  1631. +    if (ep->fcntl_fd != -1)
  1632. +        (void)close(ep->fcntl_fd);
  1633. +    if (ep->rcv_fd != -1)
  1634. +        (void)close(ep->rcv_fd);
  1635. +#endif
  1636.      if (!F_ISSET(ep, F_RCV_NORM)) {
  1637.          if (ep->rcv_path != NULL && unlink(ep->rcv_path))
  1638.              msgq_str(sp, M_SYSERR, ep->rcv_path, "242|%s: remove");
  1639.          if (ep->rcv_mpath != NULL && unlink(ep->rcv_mpath))
  1640.              msgq_str(sp, M_SYSERR, ep->rcv_mpath, "243|%s: remove");
  1641.      }
  1642. +#ifndef VI_DOSISH
  1643.      if (ep->fcntl_fd != -1)
  1644.          (void)close(ep->fcntl_fd);
  1645.      if (ep->rcv_fd != -1)
  1646.          (void)close(ep->rcv_fd);
  1647. +#endif
  1648.      if (ep->rcv_path != NULL)
  1649.          free(ep->rcv_path);
  1650.      if (ep->rcv_mpath != NULL)
  1651. @@ -808,7 +846,9 @@
  1652.      else {
  1653.          if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
  1654.              (F_ISSET(ep, F_DEVSET) &&
  1655. +#if !VI_DOSISH
  1656.              (sb.st_dev != ep->mdev || sb.st_ino != ep->minode) ||
  1657. +#endif
  1658.              sb.st_mtime != ep->mtime)) {
  1659.              msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ?
  1660.  "250|%s: file modified more recently than this copy; use ! to override" :
  1661. diff -rwuPB ..\nvi-1.79-dist/common/options.c ./common/options.c
  1662. --- ..\nvi-1.79-dist/common/options.c    Mon Oct 14 13:56:28 1996
  1663. +++ ./common/options.c    Sun Jun 29 13:40:24 1997
  1664. @@ -327,8 +327,13 @@
  1665.      F_SET(&sp->opts[O_SECURE], OPT_GLOBAL);
  1666.  
  1667.      /* Initialize string values. */
  1668. +#if VI_DOSISH
  1669. +    (void)snprintf(b1, sizeof(b1),
  1670. +        "cdpath=%s", (s = getenv("CDPATH")) == NULL ? ";" : s);
  1671. +#else
  1672.      (void)snprintf(b1, sizeof(b1),
  1673.          "cdpath=%s", (s = getenv("CDPATH")) == NULL ? ":" : s);
  1674. +#endif
  1675.      OI(O_CDPATH, b1);
  1676.  
  1677.      /*
  1678. @@ -353,8 +358,23 @@
  1679.      (void)snprintf(b1, sizeof(b1), "recdir=%s", _PATH_PRESERVE);
  1680.      OI(O_RECDIR, b1);
  1681.      OI(O_SECTIONS, "sections=NHSHH HUnhsh");
  1682. +#if VI_DOSISH
  1683. +    /*
  1684. +     * Poorly-designed EMX hosts use COMSPEC for everything; more modern
  1685. +     * ones allow you to specify a noninteractive shell with known
  1686. +     * semantics and an interactive one that does whatever.  Not even Unix
  1687. +     * gets that one right, although it's mitigated by the guarantee that
  1688. +     * /bin/sh is always there...  (Until it isn't; I dislike hardcoded
  1689. +     * pathnames.)
  1690. +     */
  1691. +    s = getenv("OS2_SHELL");
  1692. +    if (!s) s = getenv("COMSPEC");
  1693. +    if (!s) s = _PATH_BSHELL;
  1694. +    (void)snprintf(b1, sizeof(b1), "shell=%s", s);
  1695. +#else
  1696.      (void)snprintf(b1, sizeof(b1),
  1697.          "shell=%s", (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s);
  1698. +#endif
  1699.      OI(O_SHELL, b1);
  1700.      OI(O_SHELLMETA, "shellmeta=~{[*?$`'\"\\");
  1701.      OI(O_SHIFTWIDTH, "shiftwidth=8");
  1702. diff -rwuPB ..\nvi-1.79-dist/common/recover.c ./common/recover.c
  1703. --- ..\nvi-1.79-dist/common/recover.c    Sun Sep 15 14:57:46 1996
  1704. +++ ./common/recover.c    Tue Jun 24 15:42:46 1997
  1705. @@ -150,6 +150,9 @@
  1706.              msgq(sp, M_SYSERR, "%s", dp);
  1707.              goto err;
  1708.          }
  1709. +#ifndef S_ISVTX
  1710. +#define S_ISVTX 0
  1711. +#endif
  1712.          (void)chmod(dp, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
  1713.      }
  1714.  
  1715. @@ -162,8 +165,16 @@
  1716.          }
  1717.  
  1718.      (void)snprintf(path, sizeof(path), "%s/vi.XXXXXX", dp);
  1719. +#if VI_DOSISH
  1720. +    /* Try the long name first, then the short. */
  1721. +    if ((fd = rcv_mktemp(sp, path, dp, S_IRUSR | S_IWUSR)) == -1) {
  1722. +        (void)snprintf(path, sizeof(path), "%s/VIXXXXXX", dp);
  1723. +#endif
  1724.      if ((fd = rcv_mktemp(sp, path, dp, S_IRWXU)) == -1)
  1725.          goto err;
  1726. +#if VI_DOSISH
  1727. +    }
  1728. +#endif
  1729.      (void)close(fd);
  1730.  
  1731.      if ((ep->rcv_path = strdup(path)) == NULL) {
  1732. @@ -299,8 +310,16 @@
  1733.              goto err;
  1734.          dp = O_STR(sp, O_RECDIR);
  1735.          (void)snprintf(buf, sizeof(buf), "%s/vi.XXXXXX", dp);
  1736. +#if VI_DOSISH
  1737. +        /* Try the long name first, then the short. */
  1738. +        if ((fd = rcv_mktemp(sp, buf, dp, S_IRUSR | S_IWUSR)) == -1) {
  1739. +            (void)snprintf(buf, sizeof(buf), "%s/VIXXXXXX", dp);
  1740. +#endif
  1741.          if ((fd = rcv_mktemp(sp, buf, dp, S_IRUSR | S_IWUSR)) == -1)
  1742.              goto err;
  1743. +#if VI_DOSISH
  1744. +        }
  1745. +#endif
  1746.          sp->gp->scr_busy(sp,
  1747.              "061|Copying file for recovery...", BUSY_ON);
  1748.          if (rcv_copy(sp, fd, ep->rcv_path) ||
  1749. @@ -363,8 +382,16 @@
  1750.          return (1);
  1751.      dp = O_STR(sp, O_RECDIR);
  1752.      (void)snprintf(mpath, sizeof(mpath), "%s/recover.XXXXXX", dp);
  1753. +#if VI_DOSISH
  1754. +    /* Again, try the long one first. */
  1755. +    if ((fd = rcv_mktemp(sp, mpath, dp, S_IRUSR | S_IWUSR)) == -1) {
  1756. +        (void)snprintf(mpath, sizeof(mpath), "%s/REXXXXXX", dp);
  1757. +#endif
  1758.      if ((fd = rcv_mktemp(sp, mpath, dp, S_IRUSR | S_IWUSR)) == -1)
  1759.          return (1);
  1760. +#if VI_DOSISH
  1761. +    }
  1762. +#endif
  1763.  
  1764.      /*
  1765.       * XXX
  1766. @@ -509,7 +536,11 @@
  1767.  
  1768.      /* Read the directory. */
  1769.      for (found = 0; (dp = readdir(dirp)) != NULL;) {
  1770. +#if VI_DOSISH
  1771. +        if (strnicmp(dp->d_name, "RE", 2))
  1772. +#else
  1773.          if (strncmp(dp->d_name, "recover.", 8))
  1774. +#endif
  1775.              continue;
  1776.  
  1777.          /*
  1778. @@ -617,7 +648,11 @@
  1779.      rec_mtime = 0;
  1780.      recp = pathp = NULL;
  1781.      for (found = requested = 0; (dp = readdir(dirp)) != NULL;) {
  1782. +#if VI_DOSISH
  1783. +        if (strnicmp(dp->d_name, "RE", 2))
  1784. +#else
  1785.          if (strncmp(dp->d_name, "recover.", 8))
  1786. +#endif
  1787.              continue;
  1788.          (void)snprintf(recpath,
  1789.              sizeof(recpath), "%s/%s", rp, dp->d_name);
  1790. @@ -815,7 +850,11 @@
  1791.          return (NULL);
  1792.      if ((p = strchr(buf, '\n')) == NULL)
  1793.          return (NULL);
  1794. +#ifdef O_BINARY
  1795. +    (void)lseek(fd, (off_t)((p - buf) + 2), SEEK_SET);
  1796. +#else
  1797.      (void)lseek(fd, (off_t)((p - buf) + 1), SEEK_SET);
  1798. +#endif
  1799.      return (buf);
  1800.  }
  1801.  
  1802. @@ -860,7 +899,19 @@
  1803.      struct stat sb;
  1804.      char buf[MAXPATHLEN * 2 + 20];
  1805.  
  1806. +#if VI_DOSISH
  1807. +    /* Different filename semantics.  (And yes, OS/2 has BSD sendmail.) */
  1808. +    /* @@@@ should accept UNC filenames, although I don't know if // is valid */
  1809. +    if (_PATH_SENDMAIL[1] != ':' || _PATH_SENDMAIL[2] != '/' ||
  1810. +         /*
  1811. +               * @@@@ use EXE suffix from "configure" script
  1812. +         * @@@@ should also check CMD suffix...
  1813. +         * @@@@ also handle .COM?
  1814. +         */
  1815. +        (sprintf(buf, "%s.exe", _PATH_SENDMAIL), stat(buf, &sb)))
  1816. +#else
  1817.      if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, &sb))
  1818. +#endif
  1819.          msgq_str(sp, M_SYSERR,
  1820.              _PATH_SENDMAIL, "071|not sending email: %s");
  1821.      else {
  1822. @@ -870,9 +921,15 @@
  1823.           * sendmail, the -t flag causes sendmail to read the message
  1824.           * for the recipients instead of specifying them some other
  1825.           * way.
  1826. +         * @@@@ OS/2 sendmail is disgustingly verbose.
  1827. +         * @@@@ Default config tries to deliver to Umail...
  1828.           */
  1829.          (void)snprintf(buf, sizeof(buf),
  1830.              "%s -t < %s", _PATH_SENDMAIL, fname);
  1831. +#if VI_DOSISH
  1832. +        (void)strcat(buf, ">NUL");
  1833. +        /* @@@@ OS/2 allows 2> syntax, and sendmail is noisy here */
  1834. +#endif
  1835.          (void)system(buf);
  1836.      }
  1837.  }
  1838. diff -rwuPB ..\nvi-1.79-dist/curses/tstp.c ./curses/tstp.c
  1839. --- ..\nvi-1.79-dist/curses/tstp.c    Wed May  4 08:25:30 1994
  1840. +++ ./curses/tstp.c    Sun Jun  1 11:21:30 1997
  1841. @@ -42,6 +42,8 @@
  1842.  
  1843.  #include "curses.h"
  1844.  
  1845. +#ifdef SIGTSTP
  1846. +
  1847.  /*
  1848.   * stop_signal_handler --
  1849.   *    Handle stop signals.
  1850. @@ -122,3 +124,19 @@
  1851.  {
  1852.      (void)signal(SIGTSTP, otstpfn);
  1853.  }
  1854. +
  1855. +#else
  1856. +
  1857. +void
  1858. +__set_stophandler()
  1859. +{
  1860. +    ;
  1861. +}
  1862. +
  1863. +void
  1864. +__restore_stophandler()
  1865. +{
  1866. +    ;
  1867. +}
  1868. +
  1869. +#endif
  1870. diff -rwuPB ..\nvi-1.79-dist/curses/tty.c ./curses/tty.c
  1871. --- ..\nvi-1.79-dist/curses/tty.c    Tue Jan 10 19:36:30 1995
  1872. +++ ./curses/tty.c    Sun Jun  1 11:22:14 1997
  1873. @@ -66,6 +66,10 @@
  1874.  #endif
  1875.  #endif
  1876.  
  1877. +#ifndef ONLCR
  1878. +#define ONLCR 0
  1879. +#endif
  1880. +
  1881.  /*
  1882.   * gettmode --
  1883.   *    Do terminal type initialization.
  1884. diff -rwuPB ..\nvi-1.79-dist/db/btree/bt_open.c ./db/btree/bt_open.c
  1885. --- ..\nvi-1.79-dist/db/btree/bt_open.c    Wed May 15 16:27:34 1996
  1886. +++ ./db/btree/bt_open.c    Sun Jun 29 15:51:38 1997
  1887. @@ -201,7 +201,10 @@
  1888.              goto einval;
  1889.          }
  1890.          
  1891. -        if ((t->bt_fd = open(fname, flags, mode)) < 0)
  1892. +#ifndef O_BINARY
  1893. +#define O_BINARY 0
  1894. +#endif
  1895. +        if ((t->bt_fd = open(fname, flags | O_BINARY, mode)) < 0)
  1896.              goto err;
  1897.  
  1898.      } else {
  1899. @@ -387,6 +390,32 @@
  1900.      return (RET_SUCCESS);
  1901.  }
  1902.  
  1903. +#ifdef VI_DOSISH
  1904. +struct zaplist
  1905. +{
  1906. +    char *path;
  1907. +    int fd;
  1908. +    struct zaplist *next;
  1909. +};
  1910. +static struct zaplist *zaplist;
  1911. +
  1912. +static void
  1913. +bt_zapper()
  1914. +{
  1915. +    struct zaplist *zp;
  1916. +
  1917. +    while (zaplist)
  1918. +    {
  1919. +    zp = zaplist->next;
  1920. +    (void) close(zaplist->fd);
  1921. +    (void) unlink(zaplist->path);
  1922. +    free(zaplist->path);
  1923. +    free(zaplist);
  1924. +    zaplist = zp;
  1925. +    }
  1926. +}
  1927. +#endif
  1928. +
  1929.  static int
  1930.  tmp()
  1931.  {
  1932. @@ -395,7 +424,12 @@
  1933.      char *envtmp;
  1934.      char path[MAXPATHLEN];
  1935.  
  1936. +#if VI_DOSISH
  1937. +    envtmp = getenv("TEMP");
  1938. +    if (!envtmp) envtmp = getenv("TMP");
  1939. +#else
  1940.      envtmp = getenv("TMPDIR");
  1941. +#endif
  1942.      (void)snprintf(path,
  1943.          sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp");
  1944.  
  1945. @@ -403,6 +437,36 @@
  1946.      (void)sigprocmask(SIG_BLOCK, &set, &oset);
  1947.      if ((fd = mkstemp(path)) != -1)
  1948.          (void)unlink(path);
  1949. +#if VI_DOSISH
  1950. +    else {
  1951. +        /* try with a shorter name */
  1952. +         (void)snprintf(path,
  1953. +            sizeof(path), "%s/btXXXXXX", envtmp ? envtmp : "/tmp");
  1954. +        if ((fd = mkstemp(path)) != -1)
  1955. +            (void)unlink(path);
  1956. +    }
  1957. +
  1958. +    /*
  1959. +     * the backing file sticks around because you can't unlink
  1960. +     * an open file.  use an atexit() function and a file list.
  1961. +     */
  1962. +    {
  1963. +        struct zaplist *zp;
  1964. +
  1965. +        if (fd != -1 && (zp = malloc(sizeof *zp)))
  1966. +        {
  1967. +        if (!zaplist)
  1968. +            atexit(bt_zapper);
  1969. +        zp->path = strdup(path);
  1970. +        zp->fd = fd;
  1971. +        zp->next = zaplist;
  1972. +        zaplist = zp;
  1973. +        }
  1974. +    }
  1975. +#endif
  1976. +#ifdef O_BINARY
  1977. +    if (fd != -1) setmode(fd, O_BINARY);
  1978. +#endif
  1979.      (void)sigprocmask(SIG_SETMASK, &oset, NULL);
  1980.      return(fd);
  1981.  }
  1982. diff -rwuPB ..\nvi-1.79-dist/db/recno/rec_open.c ./db/recno/rec_open.c
  1983. --- ..\nvi-1.79-dist/db/recno/rec_open.c    Fri Nov 18 15:31:44 1994
  1984. +++ ./db/recno/rec_open.c    Sun Jun  1 14:09:56 1997
  1985. @@ -68,7 +68,10 @@
  1986.      int rfd, sverrno;
  1987.  
  1988.      /* Open the user's file -- if this fails, we're done. */
  1989. -    if (fname != NULL && (rfd = open(fname, flags, mode)) < 0)
  1990. +#ifndef O_BINARY
  1991. +#define O_BINARY 0
  1992. +#endif
  1993. +    if (fname != NULL && (rfd = open(fname, flags|((dflags&R_FIXEDLEN)?O_BINARY:0), mode)) < 0)
  1994.          return (NULL);
  1995.  
  1996.      /* Create a btree in memory (backed by disk). */
  1997. diff -rwuPB ..\nvi-1.79-dist/ex/ex_cd.c ./ex/ex_cd.c
  1998. --- ..\nvi-1.79-dist/ex/ex_cd.c    Mon Aug 12 19:24:00 1996
  1999. +++ ./ex/ex_cd.c    Tue Jun 24 13:06:30 1997
  2000. @@ -50,8 +50,19 @@
  2001.       * been modified, unless its name begins with a leading '/' or the
  2002.       * force flag is set.
  2003.       */
  2004. +#if VI_DOSISH
  2005. +    /*
  2006. +     * ...which is an absolute B*TCH when a rooted path has either a drive
  2007. +     * letter or UNC, and you can use either / or \ as path separator....
  2008. +     * (Late note:  emx beat me to it!)
  2009. +     */
  2010. +    if (F_ISSET(sp->ep, F_MODIFIED) &&
  2011. +        !FL_ISSET(cmdp->iflags, E_C_FORCE) &&
  2012. +        !_fnisabs(sp->frp->name)) {
  2013. +#else
  2014.      if (F_ISSET(sp->ep, F_MODIFIED) &&
  2015.          !FL_ISSET(cmdp->iflags, E_C_FORCE) && sp->frp->name[0] != '/') {
  2016. +#endif
  2017.          msgq(sp, M_ERR,
  2018.      "120|File modified since last complete write; write or use ! to override");
  2019.          return (1);
  2020. @@ -82,7 +93,11 @@
  2021.       * a message, vi didn't historically, and it should be obvious to the
  2022.       * user where they are.
  2023.       */
  2024. +#ifdef __EMX__
  2025. +    if (!_chdir2(dir))
  2026. +#else
  2027.      if (!chdir(dir))
  2028. +#endif
  2029.          return (0);
  2030.  
  2031.      /*
  2032. @@ -98,7 +113,11 @@
  2033.  
  2034.      /* Try the O_CDPATH option values. */
  2035.      for (p = t = O_STR(sp, O_CDPATH);; ++p)
  2036. +#if VI_DOSISH
  2037. +        if (*p == '\0' || *p == ';') {
  2038. +#else
  2039.          if (*p == '\0' || *p == ':') {
  2040. +#endif
  2041.              /*
  2042.               * Empty strings specify ".".  The only way to get an
  2043.               * empty string is a leading colon, colons in a row,
  2044. @@ -113,8 +132,13 @@
  2045.                  (void)snprintf(buf,
  2046.                      sizeof(buf), "%s/%s", t, dir);
  2047.                  *p = savech;
  2048. +#ifdef __EMX__
  2049. +                if (!_chdir2(buf)) {
  2050. +                    if (_getcwd2(buf, sizeof(buf)) != NULL)
  2051. +#else
  2052.                  if (!chdir(buf)) {
  2053.                      if (getcwd(buf, sizeof(buf)) != NULL)
  2054. +#endif
  2055.          msgq_str(sp, M_INFO, buf, "122|New current directory: %s");
  2056.                      return (0);
  2057.                  }
  2058. diff -rwuPB ..\nvi-1.79-dist/ex/ex_filter.c ./ex/ex_filter.c
  2059. --- ..\nvi-1.79-dist/ex/ex_filter.c    Wed Oct 23 08:31:24 1996
  2060. +++ ./ex/ex_filter.c    Tue Jun 24 13:07:02 1997
  2061. @@ -51,6 +51,9 @@
  2062.      recno_t nread;
  2063.      int input[2], output[2], rval;
  2064.      char *name;
  2065. +#if VI_DOSISH
  2066. +    char *comspec;
  2067. +#endif
  2068.  
  2069.      rval = 0;
  2070.  
  2071. @@ -60,8 +63,13 @@
  2072.          rp->lno = 1;
  2073.  
  2074.      /* We're going to need a shell. */
  2075. +#if VI_DOSISH
  2076. +    if (!(comspec = getenv("COMSPEC")))
  2077. +        return (1);
  2078. +#else
  2079.      if (opts_empty(sp, O_SHELL, 0))
  2080.          return (1);
  2081. +#endif
  2082.  
  2083.      /*
  2084.       * There are three different processes running through this code.
  2085. @@ -136,12 +144,36 @@
  2086.          (void)close(output[0]);
  2087.          (void)close(output[1]);
  2088.  
  2089. +#if VI_DOSISH
  2090. +        /*
  2091. +         * This is expensive:  we have vi, %COMSPEC%, and the
  2092. +         * user pipeline hanging around.  Fie on whoever decided
  2093. +         * P_OVERLAY aka exec() wasn't needed (the "whoever" is
  2094. +         * Microsoft, naturally; P_OVERLAY has been defined but not
  2095. +         * implemented since at least MS-DOS 3).
  2096. +         *
  2097. +         * On the other hand, IBM should have had the intelligence
  2098. +         * to implement it....
  2099. +         *
  2100. +         * With current versions of EMX, we only get here on OS/2; the
  2101. +         * pipe() calls fail elsewhere.  I presume 95/NT can simulate
  2102. +         * real operating systems, but EMX doesn't so presume.
  2103. +         */
  2104. +        if ((name = strrchr(comspec, '/')) != NULL)
  2105. +            ++name;
  2106. +        else if ((name = strrchr(comspec, '\\')) != NULL)
  2107. +            ++name;
  2108. +        else
  2109. +            name = comspec;
  2110. +        execl(comspec, name, "/C", cmd, NULL);
  2111. +#else
  2112.          if ((name = strrchr(O_STR(sp, O_SHELL), '/')) == NULL)
  2113.              name = O_STR(sp, O_SHELL);
  2114.          else
  2115.              ++name;
  2116.  
  2117.          execl(O_STR(sp, O_SHELL), name, "-c", cmd, NULL);
  2118. +#endif
  2119.          msgq_str(sp, M_SYSERR, O_STR(sp, O_SHELL), "execl: %s");
  2120.          _exit (127);
  2121.          /* NOTREACHED */
  2122. diff -rwuPB ..\nvi-1.79-dist/ex/ex_init.c ./ex/ex_init.c
  2123. --- ..\nvi-1.79-dist/ex/ex_init.c    Mon Aug 12 19:24:00 1996
  2124. +++ ./ex/ex_init.c    Fri Jun 20 20:39:22 1997
  2125. @@ -351,15 +351,23 @@
  2126.      char *path;
  2127.      int rootown, rootid;
  2128.  {
  2129. +#ifndef VI_DOSISH
  2130.      enum { ROOTOWN, OWN, WRITER } etype;
  2131.      uid_t euid;
  2132.      int nf1, nf2;
  2133.      char *a, *b, buf[MAXPATHLEN];
  2134. +#endif
  2135.  
  2136.      /* Check for the file's existence. */
  2137.      if (stat(path, sbp))
  2138.          return (NOEXIST);
  2139.  
  2140. +    /*
  2141. +     * NT and OS/2 grok permissions, but not portably.  And it's a lost
  2142. +     * cause on PCs anyway (especially when NT raises insecure to a whole
  2143. +     * new level that makes 7th Edition UNIX look like a vault!).
  2144. +     */
  2145. +#ifndef VI_DOSISH
  2146.      /* Check ownership permissions. */
  2147.      euid = geteuid();
  2148.      if (!(rootown && sbp->st_uid == 0) &&
  2149. @@ -373,8 +381,10 @@
  2150.          etype = WRITER;
  2151.          goto denied;
  2152.      }
  2153. +#endif
  2154.      return (RCOK);
  2155.  
  2156. +#ifndef VI_DOSISH
  2157.  denied:    a = msg_print(sp, path, &nf1);
  2158.      if (strchr(path, '/') == NULL && getcwd(buf, sizeof(buf)) != NULL) {
  2159.          b = msg_print(sp, buf, &nf2);
  2160. @@ -414,4 +424,5 @@
  2161.      if (nf1)
  2162.          FREE_SPACE(sp, a, 0);
  2163.      return (NOPERM);
  2164. +#endif
  2165.  }
  2166. diff -rwuPB ..\nvi-1.79-dist/ex/ex_script.c ./ex/ex_script.c
  2167. --- ..\nvi-1.79-dist/ex/ex_script.c    Tue Sep 24 19:51:12 1996
  2168. +++ ./ex/ex_script.c    Sun Jun 29 14:42:06 1997
  2169. @@ -92,6 +92,10 @@
  2170.  {
  2171.      SCRIPT *sc;
  2172.      char *sh, *sh_path;
  2173. +#if VI_DOSISH
  2174. +    int ip[2], op[2];
  2175. +    int f;
  2176. +#endif
  2177.  
  2178.      /* We're going to need a shell. */
  2179.      if (opts_empty(sp, O_SHELL, 0))
  2180. @@ -119,6 +123,29 @@
  2181.      sc->sh_term.c_oflag &= ~OPOST;
  2182.      sc->sh_term.c_cflag &= ~(ECHO|ECHOE|ECHONL|ECHOK);
  2183.  
  2184. +#if VI_DOSISH
  2185. +    /*
  2186. +     * It's necessary to use ordinary pipes, not named pipes or other
  2187. +     * mechanisms, to do this.  To me, this seems wrong, but CMD.EXE
  2188. +     * at least refuses to run over a named pipe.  :-(
  2189. +     *
  2190. +     * The changes needed for separate pipes are moderately ugly....
  2191. +     */
  2192. +    if (pipe(ip) == -1)
  2193. +    {
  2194. +        msgq(sp, M_SYSERR, "pipe:i");
  2195. +        goto err;
  2196. +    }
  2197. +    if (pipe(op) == -1)
  2198. +    {
  2199. +        msgq(sp, M_SYSERR, "pipe:o");
  2200. +        goto err;
  2201. +    }
  2202. +    if (fcntl(op[0], F_SETFL, fcntl(op[0], F_GETFL) | O_NONBLOCK) == -1)
  2203. +        msgq(sp, M_SYSERR, "fcntl");
  2204. +    sc->sh_master = (op[0] << 16) | ip[1];
  2205. +    sc->sh_slave = (ip[0] << 16) | op[1];
  2206. +#else
  2207.  #ifdef TIOCGWINSZ
  2208.      if (ioctl(STDIN_FILENO, TIOCGWINSZ, &sc->sh_win) == -1) {
  2209.          msgq(sp, M_SYSERR, "tcgetattr");
  2210. @@ -137,6 +164,7 @@
  2211.          goto err;
  2212.      }
  2213.  #endif
  2214. +#endif
  2215.  
  2216.      /*
  2217.       * __TK__ huh?
  2218. @@ -147,9 +175,23 @@
  2219.      case -1:            /* Error. */
  2220.          msgq(sp, M_SYSERR, "fork");
  2221.  err:        if (sc->sh_master != -1)
  2222. +#if VI_DOSISH
  2223. +        {
  2224. +            (void)close(sc->sh_master >> 16);
  2225. +            (void)close(sc->sh_master & 0xFFFF);
  2226. +        }
  2227. +#else
  2228.              (void)close(sc->sh_master);
  2229. +#endif
  2230.          if (sc->sh_slave != -1)
  2231. +#if VI_DOSISH
  2232. +        {
  2233. +            (void)close(sc->sh_slave >> 16);
  2234. +            (void)close(sc->sh_slave & 0xFFFF);
  2235. +        }
  2236. +#else
  2237.              (void)close(sc->sh_slave);
  2238. +#endif
  2239.          return (1);
  2240.      case 0:                /* Utility. */
  2241.          /*
  2242. @@ -160,7 +202,9 @@
  2243.          (void)setenv("TERMCAP", "emacs:", 1);
  2244.          (void)setenv("EMACS", "t", 1);
  2245.  
  2246. +#ifndef VI_DOSISH
  2247.          (void)setsid();
  2248. +#endif
  2249.  #ifdef TIOCSCTTY
  2250.          /*
  2251.           * 4.4BSD allocates a controlling terminal using the TIOCSCTTY
  2252. @@ -170,19 +214,50 @@
  2253.           */
  2254.          (void)ioctl(sc->sh_slave, TIOCSCTTY, 0);
  2255.  #endif
  2256. +#if VI_DOSISH
  2257. +        (void)close(sc->sh_master >> 16);
  2258. +        (void)close(sc->sh_master & 0xFFFF);
  2259. +        (void)dup2(sc->sh_slave >> 16, STDIN_FILENO);
  2260. +        (void)dup2(sc->sh_slave & 0xFFFF, STDOUT_FILENO);
  2261. +        (void)dup2(sc->sh_slave & 0xFFFF, STDERR_FILENO);
  2262. +        (void)close(sc->sh_slave >> 16);
  2263. +        (void)close(sc->sh_slave & 0xFFFF);
  2264. +        /* (This is probably a general vi bug) */
  2265. +        /* Close all other fd's */
  2266. +        for (f = 0; ; f++)
  2267. +        {
  2268. +            if (f != STDIN_FILENO && f != STDOUT_FILENO &&
  2269. +            f != STDERR_FILENO)
  2270. +            {
  2271. +            if (close(f) == -1)
  2272. +                break;
  2273. +            }
  2274. +        }
  2275. +#else
  2276.          (void)close(sc->sh_master);
  2277.          (void)dup2(sc->sh_slave, STDIN_FILENO);
  2278.          (void)dup2(sc->sh_slave, STDOUT_FILENO);
  2279.          (void)dup2(sc->sh_slave, STDERR_FILENO);
  2280.          (void)close(sc->sh_slave);
  2281. +#endif
  2282.  
  2283.          /* Assumes that all shells have -i. */
  2284.          sh_path = O_STR(sp, O_SHELL);
  2285. +#if VI_DOSISH
  2286. +        if ((sh = strrchr(sh_path, '/')) != NULL)
  2287. +            ++sh;
  2288. +        else if ((sh = strrchr(sh_path, '\\')) != NULL)
  2289. +            ++sh;
  2290. +        else
  2291. +            sh = sh_path;
  2292. +        execl(sh_path, sh, "/Q", NULL);
  2293. +#else
  2294.          if ((sh = strrchr(sh_path, '/')) == NULL)
  2295.              sh = sh_path;
  2296.          else
  2297.              ++sh;
  2298.          execl(sh_path, sh, "-i", NULL);
  2299. +#endif
  2300.          msgq_str(sp, M_SYSERR, sh_path, "execl: %s");
  2301.          _exit(127);
  2302.      default:            /* Parent. */
  2303. @@ -223,8 +298,13 @@
  2304.      tv.tv_sec = 5;
  2305.      tv.tv_usec = 0;
  2306.      sc = sp->script;
  2307. +#if VI_DOSISH
  2308. +    FD_SET(sc->sh_master >> 16, &fdset);
  2309. +    switch (select((sc->sh_master >> 16) + 1, &fdset, NULL, NULL, &tv)) {
  2310. +#else
  2311.      FD_SET(sc->sh_master, &fdset);
  2312.      switch (select(sc->sh_master + 1, &fdset, NULL, NULL, &tv)) {
  2313. +#endif
  2314.      case -1:        /* Error or interrupt. */
  2315.          msgq(sp, M_SYSERR, "select");
  2316.          goto prompterr;
  2317. @@ -237,7 +317,11 @@
  2318.  
  2319.      /* Read the characters. */
  2320.  more:    len = sizeof(buf) - (endp - buf);
  2321. +#if VI_DOSISH
  2322. +    switch (nr = read(sc->sh_master >> 16, endp, len)) {
  2323. +#else
  2324.      switch (nr = read(sc->sh_master, endp, len)) {
  2325. +#endif
  2326.      case  0:            /* EOF. */
  2327.          msgq(sp, M_ERR, "Error: shell: EOF");
  2328.          goto prompterr;
  2329. @@ -269,7 +353,11 @@
  2330.      /* Wait up 1/10 of a second to make sure that we got it all. */
  2331.      tv.tv_sec = 0;
  2332.      tv.tv_usec = 100000;
  2333. +#if VI_DOSISH
  2334. +    switch (select((sc->sh_master >> 16) + 1, &fdset, NULL, NULL, &tv)) {
  2335. +#else
  2336.      switch (select(sc->sh_master + 1, &fdset, NULL, NULL, &tv)) {
  2337. +#endif
  2338.      case -1:        /* Error or interrupt. */
  2339.          msgq(sp, M_SYSERR, "select");
  2340.          goto prompterr;
  2341. @@ -344,10 +432,18 @@
  2342.  
  2343.      /* Push the line to the shell. */
  2344.      sc = sp->script;
  2345. +#if VI_DOSISH
  2346. +    if ((nw = write(sc->sh_master & 0xFFFF, p, len)) != len)
  2347. +#else
  2348.      if ((nw = write(sc->sh_master, p, len)) != len)
  2349. +#endif
  2350.          goto err2;
  2351.      rval = 0;
  2352. +#if VI_DOSISH
  2353. +    if (write(sc->sh_master & 0xFFFF, "\n", 1) != 1) {
  2354. +#else
  2355.      if (write(sc->sh_master, "\n", 1) != 1) {
  2356. +#endif
  2357.  err2:        if (nw == 0)
  2358.              errno = EIO;
  2359.          msgq(sp, M_SYSERR, "shell");
  2360. @@ -390,9 +486,15 @@
  2361.      /* Set up the input mask. */
  2362.      for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
  2363.          if (F_ISSET(sp, SC_SCRIPT)) {
  2364. +#if VI_DOSISH
  2365. +            FD_SET(sp->script->sh_master >> 16, &rdfd);
  2366. +            if ((sp->script->sh_master >> 16) > maxfd)
  2367. +                maxfd = sp->script->sh_master >> 16;
  2368. +#else
  2369.              FD_SET(sp->script->sh_master, &rdfd);
  2370.              if (sp->script->sh_master > maxfd)
  2371.                  maxfd = sp->script->sh_master;
  2372. +#endif
  2373.          }
  2374.  
  2375.      /* Check for input. */
  2376. @@ -409,7 +511,11 @@
  2377.      /* Read the input. */
  2378.      for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
  2379.          if (F_ISSET(sp, SC_SCRIPT) &&
  2380. +#if VI_DOSISH
  2381. +            FD_ISSET((sp->script->sh_master >> 16), &rdfd) && sscr_insert(sp))
  2382. +#else
  2383.              FD_ISSET(sp->script->sh_master, &rdfd) && sscr_insert(sp))
  2384. +#endif
  2385.              return (1);
  2386.      goto loop;
  2387.  }
  2388. @@ -443,7 +549,11 @@
  2389.      /* Read the characters. */
  2390.      rval = 1;
  2391.      sc = sp->script;
  2392. +#if VI_DOSISH
  2393. +more:    switch (nr = read(sc->sh_master >> 16, endp, MINREAD)) {
  2394. +#else
  2395.  more:    switch (nr = read(sc->sh_master, endp, MINREAD)) {
  2396. +#endif
  2397.      case  0:            /* EOF; shell just exited. */
  2398.          sscr_end(sp);
  2399.          rval = 0;
  2400. @@ -479,8 +589,13 @@
  2401.              tv.tv_sec = 0;
  2402.              tv.tv_usec = 100000;
  2403.              FD_ZERO(&rdfd);
  2404. +#if VI_DOSISH
  2405. +            FD_SET(sc->sh_master >> 16, &rdfd);
  2406. +            if (select((sc->sh_master >> 16) + 1,
  2407. +#else
  2408.              FD_SET(sc->sh_master, &rdfd);
  2409.              if (select(sc->sh_master + 1,
  2410. +#endif
  2411.                  &rdfd, NULL, NULL, &tv) == 1) {
  2412.                  memmove(bp, t, len);
  2413.                  endp = bp + len;
  2414. @@ -590,10 +705,23 @@
  2415.      sscr_check(sp);
  2416.  
  2417.      /* Close down the parent's file descriptors. */
  2418. +#if VI_DOSISH
  2419. +    if (sc->sh_master != -1)
  2420. +    {
  2421. +        (void)close(sc->sh_master >> 16);
  2422. +        (void)close(sc->sh_master & 0xFFFF);
  2423. +    }
  2424. +    if (sc->sh_slave != -1)
  2425. +    {
  2426. +        (void)close(sc->sh_slave >> 16);
  2427. +        (void)close(sc->sh_slave & 0xFFFF);
  2428. +    }
  2429. +#else
  2430.      if (sc->sh_master != -1)
  2431.          (void)close(sc->sh_master);
  2432.      if (sc->sh_slave != -1)
  2433.          (void)close(sc->sh_slave);
  2434. +#endif
  2435.  
  2436.      /* This should have killed the child. */
  2437.      (void)proc_wait(sp, (long)sc->sh_pid, "script-shell", 0, 0);
  2438. @@ -740,6 +868,7 @@
  2439.  }
  2440.  
  2441.  #else /* !HAVE_SYS5_PTY */
  2442. +#ifndef VI_DOSISH
  2443.  
  2444.  static int
  2445.  sscr_pty(amaster, aslave, name, termp, winp)
  2446. @@ -795,4 +924,5 @@
  2447.      errno = ENOENT;    /* out of ptys */
  2448.      return (-1);
  2449.  }
  2450. +#endif /* VI_DOSISH */
  2451.  #endif /* HAVE_SYS5_PTY */
  2452. diff -rwuPB ..\nvi-1.79-dist/ex/ex_shell.c ./ex/ex_shell.c
  2453. --- ..\nvi-1.79-dist/ex/ex_shell.c    Sun Sep 15 16:20:38 1996
  2454. +++ ./ex/ex_shell.c    Tue Jun 24 13:11:30 1997
  2455. @@ -28,6 +28,10 @@
  2456.  
  2457.  #include "../common/common.h"
  2458.  
  2459. +#if VI_DOSISH
  2460. +#include <process.h>
  2461. +#endif
  2462. +
  2463.  static const char *sigmsg __P((int));
  2464.  
  2465.  /*
  2466. @@ -49,11 +53,15 @@
  2467.      if (opts_empty(sp, O_SHELL, 0))
  2468.          return (1);
  2469.  
  2470. +#if VI_DOSISH
  2471. +    (void)snprintf(buf, sizeof(buf), "%s", O_STR(sp, O_SHELL));
  2472. +#else
  2473.      /*
  2474.       * XXX
  2475.       * Assumes all shells use -i.
  2476.       */
  2477.      (void)snprintf(buf, sizeof(buf), "%s -i", O_STR(sp, O_SHELL));
  2478. +#endif
  2479.  
  2480.      /* Restore the window name. */
  2481.      (void)sp->gp->scr_rename(sp, NULL, 0);
  2482. @@ -90,13 +98,21 @@
  2483.  {
  2484.      GS *gp;
  2485.      const char *name;
  2486. +#if VI_DOSISH
  2487. +    const char *comspec;
  2488. +#endif
  2489.      pid_t pid;
  2490.  
  2491.      gp = sp->gp;
  2492.  
  2493.      /* We'll need a shell. */
  2494. +#if VI_DOSISH
  2495. +    if (!(comspec = getenv("COMSPEC")))
  2496. +        return (1);
  2497. +#else
  2498.      if (opts_empty(sp, O_SHELL, 0))
  2499.          return (1);
  2500. +#endif
  2501.  
  2502.      /* Enter ex mode. */
  2503.      if (F_ISSET(sp, SC_VI)) {
  2504. @@ -117,6 +133,26 @@
  2505.      }
  2506.      (void)ex_fflush(sp);
  2507.  
  2508. +#if VI_DOSISH
  2509. +    /*
  2510. +     * "shell" defines the interactive shell; %COMSPEC% is noninteractive
  2511. +     * and not subject to user override.  This behavior is a tightrope
  2512. +     * walk between Unix, MS-whatsit, and OS/2 usage.  (MS uses COMSPEC for
  2513. +     * everything; OS/2 uses COMSPEC noninteractively and OS2_SHELL for
  2514. +     * interactive use, resolving the discrepancy between user shells and
  2515. +     * something programs can rely on behaving consistently.)
  2516. +     *
  2517. +     * We also handle both kinds of slashes, although not all EMX targets
  2518. +     * will tolerate / in COMSPEC.
  2519. +     */
  2520. +    if ((name = strrchr(comspec, '/')) != NULL)
  2521. +        ++name;
  2522. +    else if ((name = strrchr(comspec, '\\')) != NULL)
  2523. +        ++name;
  2524. +    else
  2525. +        name = comspec;
  2526. +    return (spawnl(P_WAIT, comspec, name, "/C", cmd, NULL));
  2527. +#else
  2528.      switch (pid = vfork()) {
  2529.      case -1:            /* Error. */
  2530.          msgq(sp, M_SYSERR, "vfork");
  2531. @@ -133,6 +169,7 @@
  2532.      default:            /* Parent. */
  2533.          return (proc_wait(sp, (long)pid, cmd, 0, 0));
  2534.      }
  2535. +#endif
  2536.      /* NOTREACHED */
  2537.  }
  2538.  
  2539. diff -rwuPB ..\nvi-1.79-dist/os2/recover.cmd ./os2/recover.cmd
  2540. --- ..\nvi-1.79-dist/os2/recover.cmd    Sun Feb  7 01:28:16 2106
  2541. +++ ./os2/recover.cmd    Sun Jun 29 15:49:50 1997
  2542. @@ -0,0 +1,50 @@
  2543. +extproc c:/gnu/bin/sh.exe
  2544. +#!/bin/sh -
  2545. +#
  2546. +#    @(#)recover.in    8.8 (Berkeley) 10/10/96
  2547. +#
  2548. +# Script to recover nvi edit sessions.
  2549. +
  2550. +RECDIR="C:/tmp/recover.vi"
  2551. +SENDMAIL="C:/TCPIP/BIN/sendmail"
  2552. +
  2553. +echo 'Recovering nvi editor sessions.'
  2554. +
  2555. +# Check editor backup files.
  2556. +vibackup=`echo $RECDIR/vi*`
  2557. +if [ "$vibackup" != "$RECDIR/vi*" ]; then
  2558. +    for i in $vibackup; do
  2559. +        # Only test files that are readable.
  2560. +        if test ! -r $i; then
  2561. +            continue
  2562. +        fi
  2563. +
  2564. +        # Unmodified nvi editor backup files either have the
  2565. +        # execute bit set or are zero length.  Delete them.
  2566. +        if test -x $i -o ! -s $i; then
  2567. +            rm $i
  2568. +        fi
  2569. +    done
  2570. +fi
  2571. +
  2572. +# It is possible to get incomplete recovery files, if the editor crashes
  2573. +# at the right time.
  2574. +virecovery=`echo $RECDIR/re*`
  2575. +if [ "$virecovery" != "$RECDIR/re*" ]; then
  2576. +    for i in $virecovery; do
  2577. +        # Only test files that are readable.
  2578. +        if test ! -r $i; then
  2579. +            continue
  2580. +        fi
  2581. +
  2582. +        # Delete any recovery files that are zero length, corrupted,
  2583. +        # or that have no corresponding backup file.  Else send mail
  2584. +        # to the user.
  2585. +        recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
  2586. +        if test -n "$recfile" -a -s "$recfile"; then
  2587. +            $SENDMAIL -t < $i
  2588. +        else
  2589. +            rm $i
  2590. +        fi
  2591. +    done
  2592. +fi
  2593. diff -rwuPB ..\nvi-1.79-dist/os2/settitle.def ./os2/settitle.def
  2594. --- ..\nvi-1.79-dist/os2/settitle.def    Sun Feb  7 01:28:16 2106
  2595. +++ ./os2/settitle.def    Tue Jun 24 12:02:10 1997
  2596. @@ -0,0 +1,3 @@
  2597. +LIBRARY PMSHAPI
  2598. +
  2599. +EXPORTS _16_Win16SetTitle @93
  2600. diff -rwuPB ..\nvi-1.79-dist/vi/v_ex.c ./vi/v_ex.c
  2601. --- ..\nvi-1.79-dist/vi/v_ex.c    Sun Sep 15 15:03:02 1996
  2602. +++ ./vi/v_ex.c    Thu Jun 26 12:35:06 1997
  2603. @@ -23,6 +23,7 @@
  2604.  #include <stdlib.h>
  2605.  #include <string.h>
  2606.  #include <unistd.h>
  2607. +#include <signal.h>        /* for SIGTSTP check */
  2608.  
  2609.  #include "../common/common.h"
  2610.  #include "vi.h"
  2611.