*os_390.txt*    For Vim version 6.0ar.  Last change: 2001 Jun 03


		  VIM REFERENCE MANUAL    by Bram Moolenaar


							*OS390* *os390*
This file contains the particularities for the OS/390 Unix version of Vim.

1) Your feedback is needed		|OS390-feedback|
2) Building VIM for OS/390 Unix		|OS390-building|
3) Xterm Problems			|OS390-xterm|
4) Motif Problems			|OS390-Motif|
5) Ctags				|OS390-ctags|
6) Known weaknesses			|OS390-weaknesses|
7) Changes				|OS390-changes|
8) Porting VIM to OS/390 Unix		|OS390-porting|

The port to OS/390 Unix was done by Ralf Schandl <schandl@de.ibm.com>.

DISCLAIMER:
Also I am an IBMer, IBM is not responsible for this port, this is my
private fun. If you have problems with this port, please contact me.

If you want to use more Open Source Software on OS/390 Unix have a look
at the following Redbook (www.redbooks.ibm.com):

    Mike MacIsaak et al
    "Open Source Software on OS/390 Unix"
    SG24-5944-00



							*OS390-feedback*
1) Your feedback is needed

A lot of changes had to be done to the code to get Vim on OS/390 Unix. As most
Unix programs it contained heavy ASCII dependencies. It might be, that I
missed a ASCII dependency or that a new one has been added with a new feature
or bug fix. Most programmers are simply not aware of possible ASCII/EBCDIC
problems. If you hit a problem, that seems related to this, feel free to
contact me at the email adress above.

Only if you report a bug, it is possible to fix it. Don't rely on someone else
reporting it! Also see the section |bug-reports|.

If you are happy with Vim on OS/390 Unix, drop me a mail too.


							*OS390-building*
2) Building VIM for OS/390 Unix

A word on debugging code first:

The normal run of configure adds the flag '-g' to the compiler options,
to include debugging information into the executable. This information
are normally removed from the executable with the strip command during
installation. On OS/390 Unix, it is not possible to remove this from
the executable. The strip command exists on OS/390 Unix and is called
during the installation, but in fact it just does nothing.

If you want to build Vim without debugging code, export the environment
variable CFLAGS set to an empty string, before you call configure.
>
	export CFLAGS=""
<


Building without X11:

If you build VIM without X11 support, compiling and building is
straightforward, but don't forget to export _CC_CCMODE=1 before calling
configure and make.
>
    $ export _CC_CCMODE=1
    $./configure --with-features=big --without-x --enable-gui=no
    $ make
    $ make test
<
	NOTE: Test 11 will fail, if you don't have gzip installed.
	Test 42 will fail, as VIM on OS/390 Unix doesn't support the multibyte
	feature.
	>

    $ make install
<


Building with X11:

There are two ways for building VIM with X11 support. You can link it
statically with the X11 libraries or can bind it with the X11 DLLs. The
statical link results in a huge executable (~13Mb), the dynamical linked
executable is mutch smaller (~4.5Mb).

One of the configure test for a library needed for X11 fails, and the SM and
ICE libraries are not included. This results in unresolved symbols during the
link. Fortunally configure is easy to convince, just do this: >

	export X_PRE_LIBS="-lSM -lICE"
<

Here is what you do, if you want Motif:

  a) Static link >
	$ export X_PRE_LIBS="-lSM -lICE"
	$ export LDFLAGS="-W l,dll"
	$ export _CC_CCMODE=1
	$ configure --with-features=big --enable-gui=motif
	$ make
<
     VIM is now linked statically with the X11 libraries.

  b) Dynamic link:
     Make VIM as described for the static link. Then change the contense of
     the 'auto/link.sed' file to the following: >
	s/-lXext  *//g
	s/-lXmu  *//g
	s/-lXt	*//g
	s%-lXm	*%/usr/lib/Xm.x %g
	s%-lX11  *%/usr/lib/X11.x %g
	s%-lSM	*%/usr/lib/SM.x %g
	s%-lICE  *%/usr/lib/ICE.x %g
<
     Then do: >
	$ rm vim
	$ make
<
     Now Vim is linked with the X11-DLLs.

     See the Makefile and the file link.sh on how link.sed is used.

							*OS390-xterm*
3) XTerm problems

At least one problem seems to exist with XTerm on OS390 Unix.  The terminal
code for moving the cursor to the left is wrong in the termlib database.
Perhaps not wrong, but it doesn't work with VIM syntax highlighting and
command line cursor movement.

If the highlighting is messed up while you type, but is ok after you refreshed
the screen with <C-L> or if you can't move to the left with the cursor key on
the command line, try adding >

	:set t_le=^H
<
to your .vimrc. NOTE: '^H' is one character, hit <C-V><C-H> to get it.

							*OS390-Motif*
4) Motif Problems

It seems that in the Motif library a translation from EBCDIC to ASCII for
Mnemonic chars of the menues were forgotten. Even after I tried some
conversion by hand, it still only works for opening menues (like <Alt-F> to
open the file menu), but doesn't work for the menue items (like <Alt-F>O to
open the file browser). No solution for this yet.

							*OS390-ctags*
5) Ctags

Vim 6.0 doesn't include ctags anymore. Known problems:

    1) Ctags doesn't support trigraphs.
       All system header files start with a ifdef section. This section
       doesn't use '#ifdef' but '??=ifdef'. '??=' is the trigraph sequence
       representing a '#'. If you use ctags to create a tag file in your
       system include directory, this file will not contain all tags.

       Btw: The native ctags delivered with OS/390 Unix also can't handle
       trigraphs.

       Update 17 Aug 2000:
       Darren sent me a patch he want to include in ctags. Tested on 390
       and it works fine.

    2) The sort order of the tags is ASCII but not EBCDIC.
       Ctags calls the external sort program and sets some environment
       variables to ensure ASCII sorting. This is obviously wrong if you are
       on a EBCDIC machine. For this reason Vim never assumes a sorted ctags
       file and always uses a liniar search. This is a little bit slower, but
       no real drawback.

       Solution:
       When calling the external sort program, ctags sets the environment
       variables LC_COLLATE and LC_ALL to the value 'C'. Because of this sort
       sorts by ASCII value. For OS/390 Unix this have to be changed to
       LC_COLLATE="s370" and LC_ALL="" (if LC_ALL is set to "s370" too, sort
       is extremly slow!).
       TODO: prepare a patch and send it to Darren



							*OS390-weaknesses*
6) Known weaknesses

- No binary search in tag files (see |OS390-ctags|).
- Multibyte support (utf-8) doesn't work, it's disabled at compile time.
  (|multibyte|)

- Perl interface never tried or tested		(|perl|)
- Hangul imput never tried or tested		(|hangul|)
- Cscope interface never tried or tested	(|cscope|)
- Encryption support never tested		(|encryption|)
- Langmap never tested				(|'langmap'|)
- Python support never tried or tested		(|Python|)
- Right-to-left mode never tested		(|'rightleft'|)
- SNiFF+ interface never tried or tested	(|sniff|)
- TCL interface never tried or tested		(|tcl|)

If you try on of this and it works

							*OS390-changes*
7) Changes

6.0q (alpha):
  Minor changes for nrformats=alpha (see |'nrformats'|).
  Problem with hardcoded keycode for the english pound sign. Added a define in
  ascii.h
  Disabled multibyte for EBCDIC in feature.h

6.0f (alpha):
  First compile of Vim 6 on OS/390 Unix. Some minor changes were needed.

  Finally found the reason why make from the toplevel didn't work (I must have
  been blind before!). The Makefile contained a list of targets in one target
  line. On all other Unixes the macro $@ evaluates to the first target in this
  list, only on OS/390 Unix it evaluates to the last one :-(.

5.6-390d:
  Cleaned up some hacks.

5.6-390c:

  I greped thru the source and examined every spot with a character
  involved in a operation (+-). I hope I now found all EBCDIC/ASCII
  stuff, but ....

  Fixed:
    - fixed warning message in do_fixdel()
    - fixed translation from Ctrl-Char to symbolic name (like ^h to CTRL-H)
	    for :help
    - fixed yank/delete/... into register
    - fixed :register command
    - fixed viminfo register storing
    - fixed quick-access table in findoptions()
    - fixed 'g^H' select mode
    - fixed tgetstr() 'get terminal capability string', ESC and
	    Ctrl chars where wrong. (Not used on OS 390 Unix)


  ctags:
    - added trigraphs support (used in prolog of system header files)
	    (get.c)
    - fixed sorting order with LC_COLLATE=S390 to force EBCDIC sorting.
	    (sort.c)


5.6-390b:
  Changed:
    - configure.in:
	- added test for OS/390 Unix
	- added special compiler and linker options if building with X11
    - configure:
	- after created via autoconf handedited it to make the test for
	  ICEConnectionNumber work. This is a autoconf problem. OS/390 Unix
	  needs -lX11 for this.
    - Makefile
	- Don't include the lib directories ('-L...') into the variable
	  ALL_LIBS. Use own variable ALL_LIB_DIRS instead. A fully POSIX
	  compliant compiler must not accept objects/libraries and options
	  mixed. Now we can call the linker like this:

	    $(CC) $(LDFLAGS) $(ALL_LIB_DIRS) $(OBJ) $(ALL_LIBS)

  Fixed:
    - Double quote couldn't be entered
      Missed ASCII dependencies while setting up terminal
      In ASCII 127 is the delete char, in EBCDIC codepage 1047 the value 127
      is the double quote.
    - fixed ':fixdel'

5.6-390a:
  first alpha release for OS/390 Unix.

  Addition:
    - For the internal script language I added the feature "ebcdic".
      This can be queried with the has()-function of the internal
      script language.


							*OS390-porting*
8) Porting VIM to OS/390 Unix

Here I give a very short and incomplete overview on the changes needed for Vim
5.7 on OS/390 Unix.

The main problem porting VIM were the heavy ASCII dependencies in the code.

To detect that the current machine uses EBCDIC a test was added to the
configure script:

    dnl This test for EBCDIC is shamelessly stolen from the Lynx
    dnl port to OS/390 Unix, done by Paul Gilmartin
    AC_MSG_CHECKING(if character set is EBCDIC)
    AC_TRY_COMPILE([ ],
    [ /* TryCompile function for CharSet.
    Treat any failure as ASCII for compatibility with existing art.
    Use compile-time rather than run-time tests for cross-compiler
    tolerance.  */
    #if '0'!=240
    make an error "Character set is not EBCDIC"
    #endif ],
    [ # TryCompile action if true
    cf_cv_ebcdic=yes ],
    [ # TryCompile action if false
    cf_cv_ebcdic=no])
    # end of TryCompile ])
    # end of CacheVal CvEbcdic
    AC_MSG_RESULT($cf_cv_ebcdic)
    case "$cf_cv_ebcdic" in  #(vi
	yes) AC_DEFINE(EBCDIC)
	    line_break='"\\\\025"'
	    ;;
	*)   line_break='"\\\\012"';;
    esac
    AC_SUBST(line_break)


With this the macro EBCDIC is defined in config.h and can be used for #ifdef's
in the code.

A problem was the way control characters are calculated:

    #define Ctrl(x) ((x) & 0x1f)

For a constant x this evaluates to a constant expression during compile time
and can hence be used in case lables. In EBCDIC there is no way to calculate
the control character from a given character, so a lookup table was needed:

    #define Ctrl(x) (CtrlTable[x])

As this doesn't evaluate to a constant expression, it can't be used in case
lables. For this we had to define Ctrl_A, Ctrl_B and so on. This constants are
also defined for ASCII, to minimize #ifdef's in the code.

We also added lookup tables to look up meta characters and to translate a
control character back to the corresponding character:

    #define CtrlChar(x) ((x<' ')?CtrlCharTable[x]:0)
    #define MetaChar(x) ((x<' ')?MetaCharTable[(x)]:0)

Example:
    Ctrl('A')      == 0x01
    CtrlChar(0x01) == 'A'


To calculate the position of a character in the alphabet be added the
following macro:

    #ifdef EBCDIC
    # define CharOrd__(c,a,j,s)		\
	    ((c)<(j)?(c)-(a):((c)<(s)?(c)-(a)-7:(c)-(a)-7-8))
    # define CharOrd(x)			\
	    (isupper(x)?CharOrd__((x),'A','J','S'):CharOrd__((x),'a','j','s'))
    #else
    # define CharOrd(x) (isupper(x)?(x)-'A':(x)-'a')
    #endif

Printable and nonprintable characters
in EBCDIC all characters above and including space (code 64) are printable for
VIM (they can be displayed as one character on the screen).

Digraphs
For EBCDIC a new digraph table has been added. This table is codepage
IBM-1047 dependent. Use the command :digraphs to see the actual characters.

Hardcoded character values
At a lot of places hardcoded character values where found in strings. Like:

    "\026x"

This are the chars Ctrl-V and 'x'. This kind of strings have be replaced by:

    #ifdef EBCDIC
    # define CTRL_V_STR "\062"
    #else
    # define CTRL_V_STR "\062"
    #endif

    CTRL_V_STR "x"

Remember that consecutive strings in the code are concatenated by the
compiler.

The same procedure was used for the often used character ESCAPE.

Eval
For the internal script language we added the feature "ebcdic". With you can
fix ASCII dependent scripts like this:

    if has("ebcdic")
	let space = 64
    else
	let space = 32
    endif

Tag search
VIM has the ability to do a binary search on a sorted tag file.As /bin/sort on
OS/390 Unix simulates a ASCII sort program, the lines are NOT sorted by the
EBCDIC character values, but by the ASCII character values. With this kind of
sorting the binary search doesn't work.

For this reason binary search is turned of if EBCDIC is detected. The tag
files are only searched linear, which is a bit slower. This might be a
permanent restriction.

Options
The default values for several options had to be changed for EBCDIC. Some of
these needs some rework.

The format for c89 error messages has been added to the 'errorformat' option.

Regular Expressions
As in EBCDIC the ranges a-z and A-Z contains nonalphabetic characters, the
code for this ranges was fixed to ignore the nonalphabetic characters.

Tests
The following tests had to be modified, as they contained ASCII character
values:
    test2
    test14
    test17
    test26

Configure
Before you run configure you have to do a few things:
    export CC=cc
    export CFLAGS="-D_ALL_SOURCE -W c,dll"
    export LDFLAGS="-W l,dll"


------------------------------------------------------------------------------
 vim:tw=78:fo=tcq2
