• Stars
    star
    158
  • Rank 237,061 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created almost 3 years ago
  • Updated 8 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OpenVi: Portable OpenBSD vi for UNIX systems

OpenVi

OpenVi โ€” Portable OpenBSD vi / ex

Table of Contents

Overview

OpenVi is an enhanced and portable implementation of the Berkeley vi / ex text editor, originally developed by Bill Joy.

OpenVi is a fork of the vi / ex editor included with OpenBSD, which is derived from version 1.79 of the nvi editor originally distributed as part of the Fourth Berkeley Software Distribution (4BSD).

The nvi editor was developed by Keith Bostic of the Computer Systems Research Group (CSRG) at the University of California, Berkeley, Sven Verdoolaege, and other contributors. Nvi itself was derived from Steve Kirkendall's Elvis editor.

Why?

Why would you want to use OpenVi instead of AnotherVi?

  • Derived from the (extensively audited) OpenBSD base system code
    • Focus on readability, simplicity, and correctness of implementation
    • Adherence to OpenBSD's standard secure coding practices
      • Uses secure functions (e.g. strlcpy, snprintf, mkstemp, pledge)
    • Reduced complexity for hopefully fewer program defects
  • Clean source code, distributed under a permissive 3-clause BSD license
    • Some support code is distributed under the (more permissive) ISC license
  • Mostly conforming to relevant standards (POSIX, SUS), where applicable
    • Enhancements, non-standard behaviors, and new features are conservatively and sanely implemented with care taken to balance user expectations, complexity, and historical accuracy
  • Extensions such as bserase, expandtab, imctrl, visibletab, etc.
  • Build requires only GNU Make and standard POSIX utilities
    • Easy integration with embedded, minimal, or iteratively bootstrapped environments and distributions (such as Linux From Scratch builds)
  • No compile-time or build-time configuration options
    • Single standard build configuration with no incompatible variants
    • No configuration-specific bugs resulting from untested combinations or rarely exercised code paths
    • Concise and understandable documentation; no subtle platform variations
  • Consistent user interface, script, and map behavior across all platforms
  • Utilizes OpenBSD's extended Spencer-based regular expression engine (also adopted by LLVM, Tcl, etc.) on all supported systems
  • Single, compact, self-contained binary
    • No external data files required at run-time
    • No external library dependencies (other than curses)
      • Suitable for static linking and emergency โ€œrescueโ€ usage
  • All the various tweaks, fixes, improvements, and clean-ups accumulated over 25+ years as part of the OpenBSD base system

Why not?

So, why might you not want to use OpenVi, then?

Some of these points might be desirable features, depending on your point of view.

  • Internationalization support is currently lacking
    • No support for Unicode / UTF-8 / wide character display
      • Multibyte characters are shown as individual bytes, rather than glyphs
      • Multibyte support is planned, but is unfortunately non-trivial, see:
        • Schwarze, I. (2016, September 25). Keep multibyte character support simple [Conference presentation]. EuroBSDCon 2016 Convention, Belgrade, Serbia. [pdf:OpenBSD]
        • Jun-ichiro itojun Hagino [KAME Project] and Yoshitaka Tokugawa [WIDE Project]. (1999, 6 June). Multilingual vi clones: past, now and the future [Conference presentation]. In Proceedings of the annual conference on USENIX, Annual Technical Conference (USENIX ATEC '99). USENIX Association, Monterey, CA, USA, Page 45. [doi:10.5555/1268708.1268753], [abstract:USENIX] (legacy)
    • No support for bidirectional text
    • No support for regional localization or message translation
  • Inefficient handling of extremely large (e.g. multi-GB) files
  • No support for syntax highlighting, context-aware code completion, code folding, or โ€œlanguage serverโ€ integrations
  • No interactive macro recording and debugging functionality
  • No advanced scripting support (no BASIC, COBOL, JavaScript, Lua, Perl, PHP, Python, REXX, Ruby, S-Lang, Tcl, or anything else)
  • Only curses-based visual-mode and line-based ex-mode interfaces available
    • No support for X11/Wayland, OpenGL/Vulkan, Neuralink, augmented / virtual reality, or any other graphical user interfaces

Building

Prerequisites

Required prerequisites

  • POSIX.1-2008 environment: POSIX shell (sh) and utilities, Awk (mawk, nawk), etc.
  • GNU Make (version 3.81 or later)
  • C99 compiler (e.g. xlc, suncc, clang, gcc, etc.)
  • Curses (ncurses, NetBSD curses V8+, PDCurses V2.8+, PDCursesMod, etc.)

Optional prerequisites

  • Perl 5+
  • C shell (csh, tcsh, etc.)
  • nroff, groff, etc.

Supported platforms

  • OpenVi is easily portable to most platforms with UNIX-like operating systems that are mostly conforming to the programming interface described by IEEE Std 1003.1-2008 and user environment described by IEEE Std 1003.2-2008, also known as POSIX.1-2008 and POSIX.2-2008, respectively.

  • The following operating systems are fully supported and regularly tested using ix86/AMD64, ARM/AArch64, m68k, MIPS, POWER, and RISC-V processors:

    • IBM AIX 7.1+
    • Apple Darwin (macOS / Mac OS X) (ARM64, Intel, PowerPC)
    • FreeBSD 12.3+
    • GNU/Linux distributions (glibc, musl)
    • illumos OpenIndiana Hipster
    • NetBSD 9+
    • OpenBSD 6.9+
    • Oracle Solaris 11+
    • Microsoft Windows (Cygwin, Midipix, MSYS2, WSL)
  • The following compilers are fully supported and regularly tested:

    • LLVM Clang (BSD, Darwin, illumos, Linux, Solaris, Windows) V6+
    • AMD Optimizing C/C++ (Linux) V3+
    • GNU GCC (AIX, BSD, Darwin, illumos, Linux, Solaris, Windows) V4.6+
    • IBM Advance Toolchain (Linux on POWER) V14.0+
    • IBM Open XL C/C++ (AIX) V17.1+
    • IBM XL C/C++ (AIX, Linux) V16.1+
    • Intel oneAPI DPC++/C++ (Linux) V2021+
    • Intel C Compiler Classic (Darwin, Linux) V19.1+
    • Oracle Developer Studio (Linux, Solaris) V12.6+
    • PCC Portable C Compiler (NetBSD) V1.0.0+

Newer or older operating system and compiler releases, within reason, should work. The versions listed above are those regularly tested and known working.

Unsupported platforms
  • The following platforms are not currently supported, but support is planned for a future release:
    • Haiku Walter
    • SGI IRIX

User contributions to enhance platform support are welcomed.

Compilation

  • Compilation can be performed by invoking GNU Make (usually gmake or make) from the top-level directory of a source release or git checkout.
  • GNU Make's -j N flag may be used to parallelize the compilation, where N is a positive integer representing the number of parallel jobs requested.
  • The following environment variables influence compilation and installation:
    • CC - C compiler to use
      • (e.g. CC=gcc)
    • OPTLEVEL - Optimization flags
      • (e.g. OPTLEVEL=-O2)
    • CFLAGS - Flags to pass to the C compiler
      • (e.g. CFLAGS="-Wall -pipe")
    • LIBS - Libraries (overriding defaults) to pass to the linker
      • (e.g. LIBS="-lpdcurses -lflock")
    • LDFLAGS - Flags to pass to the linker
      • (e.g. LDFLAGS="-L/lib/path -static")
    • V - Set to enable verbose compilation output
      • (e.g. V=1)
    • DEBUG - Set to compile a debugging build
      • (e.g. DEBUG=1)
    • LGC - Set to enable link-time garbage collection
      • (e.g. LGC=1)
    • LTO - Set to enable link-time optimization
      • (e.g. LTO=1)
    • EXTRA_LIBS - Extra libraries for linking
      • (e.g. EXTRA_LIBS=-lmtmalloc)
    • PREFIX - Directory prefix for use with install and uninstall targets
      • (e.g. PREFIX=/opt/OpenVi)
  • The usual targets (all, strip, superstrip, clean, distclean, install, install-strip, uninstall, upx, etc.) are available; review the GNUmakefile to see all the available targets and options.

For example, to compile an aggressively size-optimized build, enabling link-time optimization and link-time garbage collection, explicitly using GCC:

env CC=gcc OPTLEVEL=-Os LGC=1 LTO=1 gmake sstrip

or, to verbosely compile a debugging build, explicitly using Clang:

env CC=clang DEBUG=1 V=1 gmake

For systems with GNU Make as make (e.g. GNU/Linux), basic compilation should succeed without any options or additional configuration needed:

make

With the appropriate privileges to manipulate files within the chosen PREFIX (using doas, sudo, su, etc.), the compiled executable may be installed โ€” as-is or stripped โ€” using an invocation such as:

doas gmake install-strip

or

sudo env PREFIX=/usr/local make install

Platform Specifics

The following sections document only platform specific differences, and are not intended to be a general or exhaustive reference. For installation of prerequisite software packages or other system configuration, consult the vendor's documentation.

AIX
  • Before building OpenVi on AIX, install the ncurses libraries and headers. IBM provides the necessary packages, ncurses and ncurses-devel, in RPM format as part of the AIX Toolbox for Linux and Open Source Software. With the appropriate permissions (e.g. root), these packages are installable on most systems using the dnf or yum utilities, for example:

    dnf install ncurses ncurses-devel

    or

    yum install ncurses ncurses-devel

    The IBM AIX base system (and PASE for i, an integrated runtime environment for AIX applications on the IBM i operating system) provides libxcurses, an XPG4/XSI Extended Curses implementation derived from AT&T System V, which is not yet supported for use with OpenVi.

  • Compilation is supported using IBM XL C/C++ V16.1+ (gxlc or xlclang), IBM Open XL C/C++ V17.1+ (ibm-clang), or GNU GCC (usually gcc, gcc-8, gcc-9, gcc-10, gcc-11):

    • Link-time optimization (LTO=1) requires Open XL C/C++ V17.1+. The IBM (AIX Toolbox) and Bull/Atos (Bull Freeware) GCC packages, and IBM XL C/C++ versions earlier than V17.1 are not LTO-enabled.
    • Link-time garbage collection (LGC=1) is not supported on IBM AIX.
    • A 64-bit build is the default on systems operating in 64-bit mode; for a 32-bit build, set the value of the MAIXBITS environment variable to 32 (e.g. export MAIXBITS=32).
    • The value of the CC environment variable must be set to the full path of the compiler (e.g. /opt/freeware/bin/gcc, /opt/IBM/xlC/16.1.0/bin/gxlc, /opt/IBM/openxlC/17.1.0/bin/ibm-clang, etc.) unless the compiler directory is already part of the current PATH.
  • File locking (via flock() as provided by the AIX libbsd library) is non-functional; this will be investigated and corrected in a future release.

  • OpenVi man pages are authored with mandoc and require conversion before use with the AIX man software (which is derived from AT&T UNIX System V.)

NetBSD
  • On NetBSD installations, the default OpenVi builds use the BSD curses library provided by the NetBSD base system. To use ncurses instead, set the values of the CFLAGS, LDFLAGS, and CURSESLIB environment variables appropriately (i.e. CFLAGS=-I/usr/pkg/include LDFLAGS=-L/usr/pkg/lib CURSESLIB=-lncurses).

  • The LLVM LLD linker is required for link-time optimization (LTO=1) using Clang. It is available as an installable package (i.e. pkgin install lld).

illumos
  • Before building OpenVi on an illumos distribution (i.e. OpenIndiana), install the ncurses libraries and headers. The OpenIndiana distribution provides the necessary ncurses package in IPS format. With the appropriate permissions (e.g. root), the package can be installed using the OpenIndiana pkg utility, for example:

    pkg install ncurses

    The OpenIndiana base system provides libcurses, an XPG4/XSI Extended Curses implementation derived from AT&T System V, which is not yet supported for use with OpenVi.

  • Link-time garbage collection (LGC=1) is not supported on OpenIndiana.

Solaris
  • Before building OpenVi on Oracle Solaris 11, install the ncurses libraries and headers. Oracle provides provides the necessary ncurses package for Solaris 11 in IPS format. With the appropriate permissions (e.g. root), the package can be installed using the Solaris pkg utility, for example:

    pkg install ncurses

    The base Oracle Solaris system provides libcurses, an XPG4/XSI Extended Curses implementation derived from AT&T System V, which is not yet supported for use with OpenVi.

  • Compilation is supported using Oracle Developer Studio, GCC, and Clang:

    • When using Oracle Developer Studio, invoke the compiler as suncc or set the value of the _OSLCC environment variable to 1.
    • Link-time optimization (LTO=1) is currently supported only when using GCC or Clang.
    • Link-time garbage collection (LGC=1) is not supported on Solaris.
    • When using the Oracle Developer Studio (suncc) compiler, a 64-bit build is the default on systems operating in 64-bit mode; for a 32-bit build, set the value of the SUNBITS environment variable to 32 (e.g. export SUNBITS=32).
  • File locking is unavailable due to the absence of flock() on Solaris. This will be addressed by supporting System V-style fcntl() locking in a future release.

Windows
  • Microsoft Windows supports various development and runtime environments, including MSVC, Cygwin, Midipix, MSYS2, UWIN, the Git Bash environment, and others. Care must be taken to avoid mixing incompatible libraries and tools.
Cygwin
  • Compilation problems in the Cygwin environment are often caused by incomplete or interrupted package installations, or by the installation of packages using non-standard tools (e.g. apt-cyg), which can result in missing files and dangling or missing symbolic links.
  • Before compiling OpenVi under Cygwin, it is highly recommended to:
    • Update the Cygwin setup.exe application to the latest available version.
    • Update all installed packages using the new Cygwin setup.exe application.
    • Install the required prerequisite packages (i.e. make, gcc, ncurses, ncurses-devel) using the Cygwin setup.exe application.
    • Invoke the cygcheck utility (i.e. cygcheck -cv | grep -v "OK$") to verify the integrity of all currently installed packages.

Availability

Source Code

Packages

OpenVi is available to Linux and macOS users via the Homebrew package manager.

brew install openvi

Versioning

The OpenVi version number is based on the version of the corresponding OpenBSD release, followed by the OpenVi release number. The version command can be used to display this information in the format shown below.

Version 7.0.1 (OpenVi) 10/25/2021.

This message indicates the editor in use is OpenVi, release 1, derived from OpenBSD version 7.0, and is fully synchronized with the OpenBSD versions of vi, ex, db, and regex as of 10/25/2021 (October 25th 2021).

Changes not derived from OpenBSD commits do not advance this date. New OpenBSD releases do not reset the OpenVi release number.

History

License

  • OpenVi is distributed under the terms of a 3-clause BSD license.
  • See the LICENSE.md file for the full license and distribution terms.

Acknowledgements

  • rqsd of Libera.Chat for the idea that inspired the project and testing.
  • S. V. Nickolas, Jason Stevens, and the Virtually Fun Discord community, for support and feedback.
  • From the original vi acknowledgements (by Bill Joy & Mark Horton):
    • Bruce Englar encouraged the early development of this display editor.
    • Peter Kessler helped bring sanity to version 2's command layout.
    • Bill Joy wrote version 1, versions 2.0 through 2.7, and created the framework that users see in the present editor.
    • Mark Horton added macros and other features, and made the editor work on a large number of terminals and UNIX systems.
    • The financial support of UUNET Communications Services is gratefully acknowledged.

Similar Projects

  • Martin Guy's Xvi, an enhanced fork of Tim Thompson's STEVIE
  • S. V. Nickolas' Sivle, a cleaned-up fork of Steve Kirkendall's Elvis
  • Andy Valencia's Vim57, a simplified fork of version 5.7 of Bram Moolenaar's Vim

See Also

  • Carsten Kunze's vi is a currently maintained fork of the original (1BSD/2BSD) branch of the vi / ex editor, derived from Gunnar Ritter's enhanced version of the traditional vi editor.
  • Nvi2 is a currently maintained feature branch of the new (4BSD) version of the nvi / nex editor, with a focus on extensibility and new features.
  • Nvi1 (version 1.8+) is the currently maintained traditional branch of the new (4BSD) version of the nvi / nex editor, now developed by Sven Verdoolaege.

More Repositories

1

duma

duma: Detect Unintended Memory Access (D.U.M.A.) - A Red-Zone memory allocator
C
86
star
2

NeXTROM

NeXTROM
C
77
star
3

NeXTSrc

NeXTSrc
C
52
star
4

pmince

pmince: Portable MINCE (MINCE is Not Complete[ly] EMACS)
C
32
star
5

g

g: A portable general purpose programmable text editor with calculator and macro facility.
C
31
star
6

NeXTDPS

NeXTDPS
C
29
star
7

matlab

matlab: MATLAB (with FORTRAN source code)
Fortran
29
star
8

NeXTMach

NexTMach
C
28
star
9

NeXTDSP

NeXTDSP
C
22
star
10

NeXTDimension

NeXTDimension
C
19
star
11

cpm-vax

cpm-vax: CP/M-VAX is a port of CP/M-68K to the VAXstation 2000 by Roger Ivie
C
17
star
12

ynetd

ynetd: a small (< 400 lines of C) server for binding programs to TCP ports
C
15
star
13

com-cpm

com-cpm: COM, a CP/M-80 simulator (in portable C and 68000 assembly flavors) by Jim Cathey
Assembly
15
star
14

sgs-68k

sgs-68k: AT&T (Software Generation System) SGS for Motorola 68000, including compilers (C, FORTRAN-77, RATFOR, EFL) and tools (SCCS, cflow, ctrace, cxref, lint, prof, lex, yacc)
C
15
star
15

NeXTEmacs

NextEmacs: NeXT GNU Emacs 18.55.122 (emacs-12, October 1990)
C
14
star
16

vlarn

vlarn: a classic multi-platform roguelike dungeon-crawl adventure
C
13
star
17

AncientXinu

AncientXinu: Early Xinu / Xinu68k releases
C
13
star
18

cdos-68k

cdos-68k: Concurrent DOS 68K Developer Kit
C
12
star
19

xinu68k

xinu68k: Xinu for the Motorola MECB, AT&T PC 7300, AT&T UNIX PC, AT&T/Olivetti 3B1, Convergent Technologies S/50, and Sun Microsystems Sun-2 & Sun-3
C
12
star
20

AIX5-IA64

AIX5-IA64: A modest collection of compiled software for IBM AIX 5.1L for Itanium (IA-64), previously known as Project Monterey.
11
star
21

cpm-m3

cpm-m3: CP/M-M3 is a port of CP/M-68K to the ARM Cortex-M3 by Roger Ivie
C
11
star
22

tvx

tvx: TVX is a portable full-screen editor for CP/M, MS-DOS, GEMDOS, RT-11, RSX-11, VAX/VMS, and UNIX, written in C by Bruce E. Wampler
C
10
star
23

gfcptun

gfcptun: A fast and low-latency tunnel using GFCP over UDP
Go
10
star
24

exchange

exchange: Exchange is a (user space) UNIX port of CP/M-68K by Roger Ivie, useful for manipulating DRI (8" SSSD) or P112 (3.5" DSDD) format CP/M disk images
C
9
star
25

emacs11

emacs11: EMACS11 (for PDP/RSX and VAX/VMS) in TECO-11 by Fred Fish
8
star
26

amacs

amacs: AMACS extensible editor in 6502 assembly by Brian Fox
Assembly
8
star
27

gfpsgo

gfpsgo: Fork of psgo, an IBM AIX-compatible ps(1) utility (and Go library) extended with various descriptors useful for displaying container-related data on Linux
Go
8
star
28

bviplusplus

bviplusplus: bvi++ hex editor
C
7
star
29

decmate-ii-rom

decmate-ii-rom: Charles J. Lasner's DECmate-II ROM disassembly
7
star
30

sim68k

sim68k
C
7
star
31

third

third: THIRD is a non-standard portable FORTH system by Roger Ivie (with Z80 and PDP-8 ports included)
C
6
star
32

gfsmux

gfsmux: Efficient stream multiplexing for Go
Go
6
star
33

xlp

IBM AIX XL Pascal Compiler/6000
6
star
34

nulib

nulib: NuLib NuFile eXchange (NuFX) Archive Utility (for ShrinkIt/BinaryII/NuFX)
C
5
star
35

layers

layers: The "Layers" window manager for the AT&T Blit programmable bitmap graphics terminal
C
5
star
36

graft

graft: a package management utility by Peter R. Samuel <[email protected]>. Mirrored from http://peters.gormand.com.au/Home/tools/graft
Perl
5
star
37

AIXinfo

aixinfo: The AIXinfo Wiki!
5
star
38

rh

rh: rh is a find(1)-like utility, but with C syntax.
C
5
star
39

cws-ed

cws-ed: ED, a portable EDT look-alike editor, by Rush Record and Charles W. Sandmann
C
5
star
40

cpulatency

cpulatency: Set CPU Power Management Quality of Service DMA latency constraints
C
4
star
41

Open-DCL-Lite

Open-DCL-Lite: Historical archive of Accelr8 Open DCL Lite distributions
Shell
4
star
42

rvi

rvi: rvi is an interface to RCS that attempts to make the process of using RCS simple. (Maintained version of original from https://www.cs.ru.ac.za/research/g98t4414/static/home/rvi/)
C++
4
star
43

jleveldb

jleveldb: JLevelDB is an implementation of the LevelDB key/value database in the Go programming language, based on GoLevelDB
Go
4
star
44

isnewer

isnewer: A utility to compare file modification dates; re-implementation of AT&T Research UNIX V8 newer(1)
Makefile
3
star
45

altoschat

altoschat: Altger Altos Chat
C
3
star
46

udd

udd: UNIX DND in C โ€” https://en.wikipedia.org/wiki/DND_(video_game)
C
3
star
47

k5jb

K5JB: KA9Q-based TCP/IP package
C
3
star
48

OX153

OX153: The Oxford 153 Entitlement: Mark I - a new, unique, non-free, and strongly proprietary software license
Shell
3
star
49

tp

C
2
star
50

txtelite

txtelite: Text Elite 1.5 (with bug fixes)
C
2
star
51

c11threads

C
2
star
52

quicklz

C
2
star
53

pcc

pcc: Portable C Compiler (20230730) Use https://github.com/johnsonjh/pcc-revived/tree/johnsonjh/rawhide instead!
C
2
star
54

gapi

gapi: Shell script for GitLab API calls
Shell
2
star
55

pc

C
2
star
56

oa8signverify

oa8signverify: OpenSSL-based RSA-16384 + SHA3-512 + ASCII85 (Base85) package signing tool
Shell
2
star
57

pcpm4

pcpm: P-CP/M 4
2
star
58

dotfiles

dotfiles: These are my dotfiles. There are many like them, but these are mine.
Shell
2
star
59

cbexec

cbexec: A universal shebang wrapper, switching based on file extension
Shell
2
star
60

FastLZ

C
2
star
61

leaktestfe

leaktestfe: A convenience library and front-end for Uber's goleak
Go
2
star
62

krc

Kent Recursive Calculator
C
2
star
63

luadns

luadns: LuaDNS configuration
2
star
64

AIX-ifaddrs

C
2
star
65

go.dev

go.dev: Go module imports (personal backup)
Shell
2
star
66

tde

tde: Thomson-Davis Editor (public domain)
C
1
star
67

libsir

C11 logging solution
C
1
star
68

loadwait

C
1
star
69

yabbawhap

yabbawhap: djb's yabba / unyabba & whap / unwhap, portable implementations of Y & AP coding.
C
1
star
70

localbrew

Localbrew: Creates portable virtualenv-like Homebrew environments.
1
star
71

cku

[wip]
C
1
star
72

amd_memcpy

C
1
star
73

charandom

C
1
star
74

alog

C
1
star
75

CoC

1
star
76

atlast-96

ATLAST-96: ATLAST-32 1.2 + ATLAST-64 2.0 Unification
C
1
star
77

dpsprintf

C
1
star
78

cobol_samples

IBM Enterprise COBOL Example Code
COBOL
1
star
79

fifolog

[WIP - NOT READY FOR PRODUCTION] Portable fifolog: FreeBSD's libfifolog and utilities for POSIX systems
C
1
star
80

mantra

mantra: https://macintoshgarden.org/games/mantra
C
1
star
81

bash-hello

C
1
star
82

ndk

ndk
1
star
83

osc126

osc126
1
star
84

hexdump

hexdump
C
1
star
85

divmnu

C
1
star
86

voof

voof: Mike Gleason's LZRW3-A / LZRW1-A compression / decompression tool.
C
1
star
87

VEDIT

Assembly
1
star