Hello community, here is the log from the commit of package vis for openSUSE:Factory checked in at 2020-06-05 20:24:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/vis (Old) and /work/SRC/openSUSE:Factory/.vis.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vis" Fri Jun 5 20:24:09 2020 rev:3 rq:811839 version:0.5+git.1590819266.c37f09e Changes: -------- --- /work/SRC/openSUSE:Factory/vis/vis.changes 2020-04-18 00:32:14.726277815 +0200 +++ /work/SRC/openSUSE:Factory/.vis.new.3606/vis.changes 2020-06-05 20:29:01.493315284 +0200 @@ -1,0 +2,27 @@ +Fri Jun 05 13:33:07 UTC 2020 - [email protected] + +- Update to version 0.5+git.1590819266.c37f09e: + * test: update + * vis: fix implicit enum conversion warning + * build: update alpine in docker build to version 3.12 + * doc: update outdated version information + * doc: update sphinx configuration to python 3 + * test: update + * text: introduce text_save_method, remove text_save_range + * test: update + * build: use -O2 by default + * vis: cleanup pre-processing of :-commands + * Tweak README + * vt100: do not crash if termkey is not yet initialized + * ui: fix line number drawing + * build: fix _XOPEN_SOURCE redefinition warning + * vis: make <Escape> reset count in visual modes + * vis: make <Escape> reset count in normal mode + * lexers: prioritize markdown list rule + * lexers: make markdown white space rule less greedy + * man: document theme location + * Avoid use of VLAs + * vt100: use shorter escape sequence to clear screen + * Add Julia lexer + +------------------------------------------------------------------- Old: ---- vis-0.5+git.1584517720.08a550d.tar.xz New: ---- vis-0.5+git.1590819266.c37f09e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vis.spec ++++++ --- /var/tmp/diff_new_pack.PIkt6u/_old 2020-06-05 20:29:02.377317896 +0200 +++ /var/tmp/diff_new_pack.PIkt6u/_new 2020-06-05 20:29:02.377317896 +0200 @@ -17,7 +17,7 @@ Name: vis -Version: 0.5+git.1584517720.08a550d +Version: 0.5+git.1590819266.c37f09e Release: 0 Summary: An editor combining the strengths of both vi(m) and sam License: ISC ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.PIkt6u/_old 2020-06-05 20:29:02.421318026 +0200 +++ /var/tmp/diff_new_pack.PIkt6u/_new 2020-06-05 20:29:02.421318026 +0200 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/martanne/vis.git</param> - <param name="changesrevision">08a550deac6f55f32f131f66992994b3944011ce</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">c37f09ed99baae4ae42381ebfc608003942528b3</param></service></servicedata> \ No newline at end of file ++++++ vis-0.5+git.1584517720.08a550d.tar.xz -> vis-0.5+git.1590819266.c37f09e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/Dockerfile new/vis-0.5+git.1590819266.c37f09e/Dockerfile --- old/vis-0.5+git.1584517720.08a550d/Dockerfile 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/Dockerfile 2020-05-30 08:14:26.000000000 +0200 @@ -1,5 +1,5 @@ # Run 'make docker' to build a statically linked vis executable! -FROM i386/alpine:3.11 +FROM i386/alpine:3.12 RUN apk update && apk add --upgrade --no-cache \ acl-dev \ acl-static \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/README.md new/vis-0.5+git.1590819266.c37f09e/README.md --- old/vis-0.5+git.1584517720.08a550d/README.md 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/README.md 2020-05-30 08:14:26.000000000 +0200 @@ -1,5 +1,4 @@ -Vis a vim-like text editor -========================== +# Vis - Combining Modal Editing with Structural Regular Expressions [](https://builds.sr.ht/~martanne/vis) [](https://scan.coverity.com/projects/3939) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/config.def.h new/vis-0.5+git.1590819266.c37f09e/config.def.h --- old/vis-0.5+git.1584517720.08a550d/config.def.h 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/config.def.h 2020-05-30 08:14:26.000000000 +0200 @@ -225,7 +225,7 @@ { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) }, { "D", ALIAS("d$") }, { "<Delete>", ALIAS("x") }, - { "<Escape>", ACTION(SELECTIONS_REMOVE_ALL) }, + { "<Escape>", ACTION(MODE_NORMAL_ESCAPE) }, { "<F1>", ALIAS(":help<Enter>") }, { "ga", ACTION(UNICODE_INFO) }, { "g8", ACTION(UTF8_INFO) }, @@ -284,7 +284,7 @@ { "<C-u>", ACTION(SELECTIONS_PREV) }, { "<C-x>", ACTION(SELECTIONS_NEW_MATCH_SKIP) }, { "<Delete>", ALIAS("<Backspace>") }, - { "<Escape>", ACTION(MODE_NORMAL) }, + { "<Escape>", ACTION(MODE_VISUAL_ESCAPE) }, { "I", ACTION(SELECTIONS_NEW_LINES_BEGIN) }, { "J", ACTION(JOIN_LINES) }, { "gJ", ACTION(JOIN_LINES_TRIM) }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/configure new/vis-0.5+git.1590819266.c37f09e/configure --- old/vis-0.5+git.1584517720.08a550d/configure 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/configure 2020-05-30 08:14:26.000000000 +0200 @@ -220,7 +220,7 @@ tryldflag LDFLAGS_TRY -Werror=unknown-warning-option tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument -CFLAGS_STD="-std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DNDEBUG -D_FORTIFY_SOURCE=2" +CFLAGS_STD="-std=c99 -D_POSIX_C_SOURCE=200809L -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG -D_FORTIFY_SOURCE=2" LDFLAGS_STD="-lc" OS=$(uname) @@ -235,7 +235,7 @@ tryflag CFLAGS -pipe # Try flags to optimize binary size -tryflag CFLAGS -Os +tryflag CFLAGS -O2 tryflag CFLAGS -ffunction-sections tryflag CFLAGS -fdata-sections tryldflag LDFLAGS_AUTO -Wl,--gc-sections diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/doc/conf.py new/vis-0.5+git.1590819266.c37f09e/doc/conf.py --- old/vis-0.5+git.1584517720.08a550d/doc/conf.py 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/doc/conf.py 2020-05-30 08:14:26.000000000 +0200 @@ -24,7 +24,7 @@ # on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' -print subprocess.check_output('mkdir -p build/doxygen && doxygen', shell=True) +print(subprocess.check_output('mkdir -p build/doxygen && doxygen', shell=True)) breathe_projects = { 'vis': 'build/doxygen/xml' @@ -58,18 +58,18 @@ master_doc = 'index' # General information about the project. -project = u'Vis Editor' -copyright = u'2017, Marc André Tanner' -author = u'Marc André Tanner' +project = 'Vis Editor' +copyright = '2017, Marc André Tanner' +author = 'Marc André Tanner' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'0.3' +version = '0.5' # The full version, including alpha/beta/rc tags. -release = u'0.3' +release = '0.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -140,8 +140,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'VisEditor.tex', u'Vis Editor Documentation', - u'Marc André Tanner', 'manual'), + (master_doc, 'VisEditor.tex', 'Vis Editor Documentation', + 'Marc André Tanner', 'manual'), ] @@ -150,7 +150,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'viseditor', u'Vis Editor Documentation', + (master_doc, 'viseditor', 'Vis Editor Documentation', [author], 1) ] @@ -161,7 +161,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'VisEditor', u'Vis Editor Documentation', + (master_doc, 'VisEditor', 'Vis Editor Documentation', author, 'VisEditor', 'One line description of project.', 'Miscellaneous'), ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/lua/lexers/julia.lua new/vis-0.5+git.1590819266.c37f09e/lua/lexers/julia.lua --- old/vis-0.5+git.1584517720.08a550d/lua/lexers/julia.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/lua/lexers/julia.lua 2020-05-30 08:14:26.000000000 +0200 @@ -0,0 +1,147 @@ +-- Julia lexer. + +local l = require('lexer') +local token, word_match = l.token, l.word_match +local B, P, R, S = lpeg.B, lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'julia'} + +-- Whitespace. +local ws = token(l.WHITESPACE, l.space^1) + + +-- Identifier +local id = l.word * P('!')^0 +local identifier = token(l.IDENTIFIER, id) + + +-- Operator +local operator = token(l.OPERATOR, S('+-*/÷<>=!≠≈≤≥%^&|⊻~\\\':?.√')) + + +-- Comment +local line_comment = '#' * l.nonnewline^0 +local block_comment = '#=' * (l.any - '=#')^0 * P('=#')^-1 +local comment = token(l.COMMENT, block_comment + line_comment) + + +-- Constant +local const_bool = word_match{'true', 'false'} +local const_numerical = (P('Inf') + P('NaN')) * (P('16') + P('32') + P('64'))^-1 * #(-l.alnum) +local const_special = word_match{'nothing', 'undef', 'missing'} +local const_env = word_match{'ARGS', 'ENV', 'ENDIAN_BOM', 'LOAD_PATH', 'VERSION', 'PROGRAM_FILE', 'DEPOT_PATH'} +local const_io = word_match{'stdout', 'stdin', 'stderr', 'devnull'} +local constant = token(l.CONSTANT, const_bool + const_numerical + const_special + const_env + const_io) + + +-- Number +local decimal = l.digit^1 * ('_' * l.digit^1)^0 +local hex_digits = l.xdigit^1 * ('_' * l.xdigit^1)^0 +local hexadecimal = '0x' * hex_digits +local binary = '0b' * S('01')^1 * ('_' * S('01')^1)^0 +local integer = binary + hexadecimal + decimal + +local float_dec_coeff = decimal^0 * '.' * decimal + decimal * '.' * decimal^0 +local float_dec_expon = S('eEf') * S('+-')^-1 * l.digit^1 +local float_dec = float_dec_coeff * float_dec_expon^-1 + decimal * float_dec_expon + +local float_hex_coeff = '0x' * (hex_digits^0 * '.' * hex_digits + hex_digits * '.' * hex_digits^0) +local float_hex_expon = 'p' * S('+-')^-1 * l.digit^1 +local float_hex = float_hex_coeff * float_hex_expon^-1 + hexadecimal * float_hex_expon + +local float = float_dec + float_hex + +local imaginary = (float_dec + decimal) * 'im' + +local number = token(l.NUMBER, S('+-')^-1 * (imaginary + float + integer) * #(-l.alpha)) + + +-- Character & String +local c_esc = '\\' * S('\\"\'nrbtfav') +local unicode = '\\' * S('uU') * l.xdigit^1 +local char = "'" * (l.alnum + c_esc + unicode) * "'" +local character = token('character', char) + +local doc_str = l.delimited_range('"""') +local str = l.delimited_range('"') +local string = token(l.STRING, doc_str + str) + + +-- Keyword +local keyword_single = word_match{ + 'baremodule', 'begin', 'break', 'catch', 'const', 'continue', + 'do', 'else', 'elseif', 'end', 'export', 'finally', 'for', + 'function', 'global', 'if', 'in', 'isa', 'import', 'let', 'local', + 'macro', 'module', 'quote', 'return', 'struct', 'try', 'using', + 'where', 'while' +} +local keyword_mult = P('abstract type') + P('mutable struct') + P('primitive type') +local keyword = token(l.KEYWORD, keyword_single + keyword_mult) + + +-- Function +local func = token(l.FUNCTION, id * #(P('.')^-1 * #P('('))) + + +-- Macro +local macro = token('macro', '@' * (id + '.')) + + +-- Type +local type_annotated = (B('::') + B(':: ')) * id +local type_para = id * #P('{') +local type_subtyping = id * #(l.space^0 * P('<:')) + (B('<:') + B('<: ')) * id +local type_struct = B('struct ') * id +local type_builtin_numerical = ( + (P('Abstract') + P('Big')) * P('Float') + + P('Float') * (P('16') + P('32') + P('64')) + + P('U')^-1 * P('Int') * (P('8') + P('16') + P('32') + P('64') + P('128'))^-1 + + P('Abstract')^-1 * P('Irrational') + ) * #(-l.alnum) + + word_match{'Number', 'Complex', 'Real', 'Integer', 'Bool', 'Signed', 'Unsigned', 'Rational'} +local type_builtin_range = ( + (P('Lin') + P('Ordinal') + (P('Abstract')^-1 * P('Unit')^-1)) * P('Range') + + P('StepRange') * P('Len')^-1 - P('Range') + ) * #(-l.alnum) +local type_builtin_array = ( + (P('Abstract') + P('Bit') + P('Dense') + P('PermutedDims') + P('Sub'))^-1 * + (P('Array') + P('Vector') + P('Matrix') + P('VecOrMat')) + + (P('Abstract') + P('Sym') + (P('Unit')^-1 * (P('Lower') + P('Upper'))))^-1 * P('Triangular') + ) * #(-l.alnum) + + word_match{ + 'Adjoint', 'Bidiagonal', 'Diagonal', 'Hermitian', 'LQPackedQ', + 'Symmetric', 'Transpose', 'UpperHessenberg' + } +local type = token(l.TYPE, + type_para + type_annotated + type_subtyping + type_struct + type_builtin_numerical + type_builtin_range + + type_builtin_array + ) + + +-- Symbol +local symbol = token('symbol', -B(P(':') + P('<')) * P(':') * id) + + +M._rules = { + {'whitespace', ws}, + {'comment', comment}, + {'string', string}, + {'character', character}, + {'keyword', keyword}, + {'constant', constant}, + {'type', type}, + {'symbol', symbol}, + {'macro', macro}, + {'function', func}, + {'identifier', identifier}, + {'operator', operator}, + {'number', number}, +} + +M._tokenstyles = { + character = l.STYLE_CONSTANT, + symbol = l.STYLE_CONSTANT, + macro = l.STYLE_PREPROCESSOR, +} + +return M diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/lua/lexers/markdown.lua new/vis-0.5+git.1590819266.c37f09e/lua/lexers/markdown.lua --- old/vis-0.5+git.1584517720.08a550d/lua/lexers/markdown.lua 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/lua/lexers/markdown.lua 2020-05-30 08:14:26.000000000 +0200 @@ -8,7 +8,7 @@ local M = {_NAME = 'markdown'} -- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) +local ws = token(l.WHITESPACE, S(' \t')^1 + S('\v\r\n')^1) -- Block elements. local header = token('h6', l.starts_line('######') * l.nonnewline^0) + @@ -68,10 +68,10 @@ M._rules = { {'header', header}, + {'list', list}, {'blockquote', blockquote}, {'blockcode', blockcode}, {'hr', hr}, - {'list', list}, {'whitespace', ws}, {'link_label', link_label}, {'escape', escape}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/lua/plugins/filetype.lua new/vis-0.5+git.1590819266.c37f09e/lua/plugins/filetype.lua --- old/vis-0.5+git.1584517720.08a550d/lua/plugins/filetype.lua 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/lua/plugins/filetype.lua 2020-05-30 08:14:26.000000000 +0200 @@ -213,6 +213,9 @@ jsp = { ext = { "%.jsp$" }, }, + julia = { + ext = { "%.jl$" }, + }, latex = { ext = { "%.bbl$", "%.cls$", "%.dtx$", "%.ins$", "%.ltx$", "%.tex$", "%.sty$" }, mime = { "text/x-tex" }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/main.c new/vis-0.5+git.1590819266.c37f09e/main.c --- old/vis-0.5+git.1584517720.08a550d/main.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/main.c 2020-05-30 08:14:26.000000000 +0200 @@ -32,6 +32,10 @@ static const char *macro_replay(Vis*, const char *keys, const Arg *arg); /* temporarily suspend the editor and return to the shell, type 'fg' to get back */ static const char *suspend(Vis*, const char *keys, const Arg *arg); +/* reset count if set, otherwise remove all but the primary selection */ +static const char *normalmode_escape(Vis*, const char *keys, const Arg *arg); +/* reset count if set, otherwise switch to normal mode */ +static const char *visualmode_escape(Vis*, const char *keys, const Arg *arg); /* switch to mode indicated by arg->i */ static const char *switchmode(Vis*, const char *keys, const Arg *arg); /* switch to insert mode after performing movement indicated by arg->i */ @@ -200,7 +204,9 @@ VIS_ACTION_WINDOW_HALFPAGE_UP, VIS_ACTION_WINDOW_HALFPAGE_DOWN, VIS_ACTION_MODE_NORMAL, + VIS_ACTION_MODE_NORMAL_ESCAPE, VIS_ACTION_MODE_VISUAL, + VIS_ACTION_MODE_VISUAL_ESCAPE, VIS_ACTION_MODE_VISUAL_LINE, VIS_ACTION_MODE_INSERT, VIS_ACTION_MODE_REPLACE, @@ -600,11 +606,21 @@ VIS_HELP("Enter normal mode") switchmode, { .i = VIS_MODE_NORMAL } }, + [VIS_ACTION_MODE_NORMAL_ESCAPE] = { + "vis-mode-normal-escape", + VIS_HELP("Reset count or remove all non-primary selections") + normalmode_escape, + }, [VIS_ACTION_MODE_VISUAL] = { "vis-mode-visual-charwise", VIS_HELP("Enter characterwise visual mode") switchmode, { .i = VIS_MODE_VISUAL } }, + [VIS_ACTION_MODE_VISUAL_ESCAPE] = { + "vis-mode-visual-escape", + VIS_HELP("Reset count or switch to normal mode") + visualmode_escape, + }, [VIS_ACTION_MODE_VISUAL_LINE] = { "vis-mode-visual-linewise", VIS_HELP("Enter linewise visual mode") @@ -2228,6 +2244,22 @@ return keys; } +static const char *normalmode_escape(Vis *vis, const char *keys, const Arg *arg) { + if (vis_count_get(vis) == VIS_COUNT_UNKNOWN) + selections_clear(vis, keys, arg); + else + vis_count_set(vis, VIS_COUNT_UNKNOWN); + return keys; +} + +static const char *visualmode_escape(Vis *vis, const char *keys, const Arg *arg) { + if (vis_count_get(vis) == VIS_COUNT_UNKNOWN) + vis_mode_switch(vis, VIS_MODE_NORMAL); + else + vis_count_set(vis, VIS_COUNT_UNKNOWN); + return keys; +} + static const char *switchmode(Vis *vis, const char *keys, const Arg *arg) { vis_mode_switch(vis, arg->i); return keys; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/man/vis.1 new/vis-0.5+git.1590819266.c37f09e/man/vis.1 --- old/vis-0.5+git.1584517720.08a550d/man/vis.1 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/man/vis.1 2020-05-30 08:14:26.000000000 +0200 @@ -1380,6 +1380,11 @@ . .It Ic theme Op Do default-16 Dc or Do default-256 Dc Color theme to use, name without file extension. +Loaded from a +.Pa themes/ +sub directory of the paths listed in the +.Sx FILES +section. . .It Cm syntax Op Cm off Syntax highlighting lexer to use, name without file extension. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/sam.c new/vis-0.5+git.1590819266.c37f09e/sam.c --- old/vis-0.5+git.1584517720.08a550d/sam.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/sam.c 2020-05-30 08:14:26.000000000 +0200 @@ -1389,9 +1389,9 @@ bool trailing_match = false; size_t start = range->start, end = range->end, last_start = EPOS; size_t nsub = 1 + text_regex_nsub(cmd->regex); - if (nsub > 10) - nsub = 10; - RegexMatch match[nsub]; + if (nsub > MAX_REGEX_SUB) + nsub = MAX_REGEX_SUB; + RegexMatch match[MAX_REGEX_SUB]; while (start < end || trailing_match) { trailing_match = false; char c; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/Makefile new/vis-0.5+git.1590819266.c37f09e/test/core/Makefile --- old/vis-0.5+git.1584517720.08a550d/test/core/Makefile 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/Makefile 2020-05-30 08:14:26.000000000 +0200 @@ -43,7 +43,7 @@ $(MAKE) CFLAGS_EXTRA='-fsanitize=undefined' msan: clean - $(MAKE) CFLAGS_EXTRA='-g -fsanitize=memory' + $(MAKE) CFLAGS_EXTRA='-fsanitize=memory -fsanitize-memory-track-origins' valgrind: clean ${ALL} @for test in ${ALL}; do \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/array-test.c new/vis-0.5+git.1590819266.c37f09e/test/core/array-test.c --- old/vis-0.5+git.1584517720.08a550d/test/core/array-test.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/array-test.c 2020-05-30 08:14:26.000000000 +0200 @@ -146,6 +146,7 @@ ok(array_add(&arr, &byte) && (ptr = array_get(&arr, 0)) && *ptr == byte, "Add byte element"); ok(!array_get_ptr(&arr, 0) && errno == ENOTSUP, "Get pointer from non-pointer array"); + array_release(&arr); array_init(&arr); ok(array_length(&arr) == 0 && array_get_ptr(&arr, 0) == NULL && errno == EINVAL, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.3 new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.3 --- old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.3 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.3 2020-05-30 08:14:26.000000000 +0200 @@ -285,7 +285,7 @@ .Xc .El .Pp -For maximum compatability your test program should return a particular +For maximum compatibility your test program should return a particular exit code. This is calculated by .Fn exit_status so it is sufficient to always return from @@ -303,7 +303,7 @@ functionality, written using .Nm . Examine them for examples of how to construct test suites. -.Sh COMPATABILITY +.Sh COMPATIBILITY .Nm strives to be compatible with the Perl Test::More and Test::Harness modules. The test suite verifies that diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.c new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.c --- old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.c 2020-05-30 08:14:26.000000000 +0200 @@ -32,6 +32,8 @@ #include "tap.h" +void (*tap_fail_callback)(void) = NULL; + static int no_plan = 0; static int skip_all = 0; static int have_plan = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.h new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.h --- old/vis-0.5+git.1584517720.08a550d/test/core/ccan/tap/tap.h 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/ccan/tap/tap.h 2020-05-30 08:14:26.000000000 +0200 @@ -246,6 +246,6 @@ * * This can be used to ease debugging, or exit on the first failure. */ -void (*tap_fail_callback)(void); +extern void (*tap_fail_callback)(void); #endif /* CCAN_TAP_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/core/text-test.c new/vis-0.5+git.1590819266.c37f09e/test/core/text-test.c --- old/vis-0.5+git.1584517720.08a550d/test/core/text-test.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/core/text-test.c 2020-05-30 08:14:26.000000000 +0200 @@ -94,12 +94,75 @@ plan_no_plan(); skip_if(TIS_INTERPRETER, 2, "I/O related") { - txt = text_load("/"); - ok(txt == NULL && errno == EISDIR, "Opening directory"); - if (access("/etc/shadow", F_OK) == 0 && access("/etc/shadow", R_OK) != 0) { - txt = text_load("/etc/shadow"); - ok(txt == NULL && errno == EACCES, "Opening file without sufficient permissions"); + const char *filename = "data"; + unlink(filename); + + enum TextLoadMethod load_method[] = { + TEXT_LOAD_AUTO, + TEXT_LOAD_READ, + TEXT_LOAD_MMAP, + }; + + for (size_t i = 0; i < LENGTH(load_method); i++) { + txt = text_load_method("/", load_method[i]); + ok(txt == NULL && errno == EISDIR, "Opening directory (method %zu)", i); + + if (access("/etc/shadow", F_OK) == 0 && access("/etc/shadow", R_OK) != 0) { + txt = text_load_method("/etc/shadow", load_method[i]); + ok(txt == NULL && errno == EACCES, "Opening file without sufficient permissions (method %zu)", i); + } + } + + char buf[BUFSIZ] = "Hello World!\n"; + txt = text_load(NULL); + ok(txt && insert(txt, 0, buf) && compare(txt, buf), "Inserting into empty text"); + ok(txt && text_save(txt, filename), "Text save"); + text_free(txt); + + for (size_t i = 0; i < LENGTH(load_method); i++) { + txt = text_load_method(filename, load_method[i]); + ok(txt && compare(txt, buf), "Load text (method %zu)", i); + text_free(txt); + } + + enum TextSaveMethod save_method[] = { + TEXT_SAVE_AUTO, + TEXT_SAVE_ATOMIC, + TEXT_SAVE_INPLACE, + }; + + for (size_t i = 0; i < LENGTH(save_method); i++) { + snprintf(buf, sizeof buf, "Hello World: %zu\n", i); + txt = text_load(NULL); + ok(txt && insert(txt, 0, buf) && compare(txt, buf), "Preparing to save (method %zu)", i); + ok(txt && text_save_method(txt, filename, save_method[i]), "Text save (method %zu)", i); + text_free(txt); + + txt = text_load(filename); + ok(txt && compare(txt, buf), "Verify save (method %zu)", i); + text_free(txt); + } + + int (*creation[])(const char*, const char*) = { symlink, link }; + const char *names[] = { "symlink", "hardlink" }; + + for (size_t i = 0; i < LENGTH(names); i++) { + const char *linkname = names[i]; + unlink(linkname); + ok(creation[i](filename, linkname) == 0, "%s creation", names[i]); + + snprintf(buf, sizeof buf, "%s\n", names[i]); + txt = text_load(NULL); + ok(txt && insert(txt, 0, buf) && compare(txt, buf), "Preparing %s content", names[i]); + ok(txt && text_save(txt, linkname), "Text save %s", names[i]); + text_free(txt); + + txt = text_load(linkname); + ok(txt && compare(txt, buf), "Load %s", names[i]); + + ok(txt && !text_save_method(txt, linkname, TEXT_SAVE_ATOMIC), "Text save %s atomic", names[i]); + text_free(txt); } } @@ -219,7 +282,6 @@ text_snapshot(txt); for (size_t i = 0; i < LENGTH(positions); i++) { size_t pos = positions[i]; - size_t newpos = pos+delta; Mark bof = text_mark_set(txt, 0); ok(text_mark_get(txt, bof) == 0, "Mark at beginning of file"); Mark mof = text_mark_set(txt, pos); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/fuzz/Makefile new/vis-0.5+git.1590819266.c37f09e/test/fuzz/Makefile --- old/vis-0.5+git.1584517720.08a550d/test/fuzz/Makefile 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/fuzz/Makefile 2020-05-30 08:14:26.000000000 +0200 @@ -1,18 +1,24 @@ -include ../../config.mk -ALL = text-fuzzer buffer-fuzzer +ALL = text-fuzzer text-libfuzzer buffer-fuzzer CC = afl-gcc CFLAGS += -I. -I../.. -DBUFFER_SIZE=4 -DBLOCK_SIZE=4 +TEXT_SRC = ../../text.c ../../text-util.c ../../text-motions.c ../../text-objects.c ../../text-regex.c + test: $(ALL) -text-fuzzer: text-fuzzer.c fuzzer.h ../../text.c ../../text-util.c ../../text-motions.c ../../text-objects.c ../../text-regex.c +text-fuzzer: text-fuzzer.c fuzzer.h $(TEXT_SRC) + @echo Compiling $@ binary + @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@ + +text-libfuzzer: text-fuzzer.c fuzzer.h $(TEXT_SRC) @echo Compiling $@ binary - ${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@ + @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} -DLIBFUZZER ${filter %.c, $^} -fsanitize=fuzzer,address,undefined ${LDFLAGS} -o $@ buffer-fuzzer: buffer-fuzzer.c fuzzer.h ../../buffer.c @echo Compiling $@ binary - @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@ + @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_LIBC} ${CFLAGS_EXTRA} ${filter %.c, $^} ${LDFLAGS} -o $@ debug: clean $(MAKE) CFLAGS_EXTRA='${CFLAGS_EXTRA} ${CFLAGS_DEBUG}' @@ -22,6 +28,10 @@ @afl-fuzz -i - -x "dictionaries/$<.dict" -o "results/$<" -- "./$<" || \ afl-fuzz -i "inputs/$<" -x "dictionaries/$<.dict" -o "results/$<" -- "./$<" +libfuzzer-text: text-libfuzzer + @mkdir -p "results/$<" + @./$< -close_fd_mask=1 -only_ascii=1 -print_final_stats=1 "-dict=dictionaries/$<.dict" "inputs/$<" "results/$<" + afl-fuzz-buffer: buffer-fuzzer @mkdir -p "results/$<" @afl-fuzz -i - -x "dictionaries/$<.dict" -o "results/$<" -- "./$<" || \ @@ -34,4 +44,4 @@ distclean: clean @rm -rf results/ -.PHONY: clean distclean debug afl-fuzz-text afl-fuzz-buffer +.PHONY: clean distclean debug afl-fuzz-text libfuzzer-text afl-fuzz-buffer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/fuzz/dictionaries/text-libfuzzer.dict new/vis-0.5+git.1590819266.c37f09e/test/fuzz/dictionaries/text-libfuzzer.dict --- old/vis-0.5+git.1584517720.08a550d/test/fuzz/dictionaries/text-libfuzzer.dict 1970-01-01 01:00:00.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/fuzz/dictionaries/text-libfuzzer.dict 2020-06-05 20:29:02.825319219 +0200 @@ -0,0 +1 @@ +symbolic link to text-fuzzer.dict diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/fuzz/inputs/text-libfuzzer/text-libfuzzer.in new/vis-0.5+git.1590819266.c37f09e/test/fuzz/inputs/text-libfuzzer/text-libfuzzer.in --- old/vis-0.5+git.1584517720.08a550d/test/fuzz/inputs/text-libfuzzer/text-libfuzzer.in 1970-01-01 01:00:00.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/fuzz/inputs/text-libfuzzer/text-libfuzzer.in 2020-06-05 20:29:02.821319207 +0200 @@ -0,0 +1 @@ +symbolic link to ../text-fuzzer/text-fuzzer.in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/fuzz/text-fuzzer.c new/vis-0.5+git.1590819266.c37f09e/test/fuzz/text-fuzzer.c --- old/vis-0.5+git.1584517720.08a550d/test/fuzz/text-fuzzer.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/fuzz/text-fuzzer.c 2020-05-30 08:14:26.000000000 +0200 @@ -1,5 +1,6 @@ #include <stddef.h> #include <stdbool.h> +#include <stdlib.h> #include <string.h> #include <errno.h> #include <stdio.h> @@ -52,11 +53,11 @@ } static enum CmdStatus cmd_earlier(Text *txt, const char *cmd) { - return text_earlier(txt, 1) != EPOS; + return text_earlier(txt) != EPOS; } static enum CmdStatus cmd_later(Text *txt, const char *cmd) { - return text_later(txt, 1) != EPOS; + return text_later(txt) != EPOS; } static enum CmdStatus cmd_mark_set(Text *txt, const char *cmd) { @@ -112,8 +113,7 @@ ['u'] = cmd_undo, }; -int main(int argc, char *argv[]) { - char line[BUFSIZ], *name = (argc == 1) ? NULL : argv[1]; +static int repl(const char *name, FILE *input) { Text *txt = text_load(name); if (!name) name = "-"; @@ -124,9 +124,10 @@ printf("Loaded %zu bytes from `%s'\n", text_size(txt), name); + char line[BUFSIZ]; for (;;) { printf("> "); - if (!fgets(line, sizeof(line), stdin)) + if (!fgets(line, sizeof(line), input)) break; if (!isatty(0)) printf("%s", line); @@ -147,3 +148,22 @@ return 0; } + +#ifdef LIBFUZZER + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t len) { + FILE *input = fmemopen((void*)data, len, "r"); + if (!input) + return 1; + int r = repl(NULL, input); + fclose(input); + return r; +} + +#else + +int main(int argc, char *argv[]) { + return repl(argc == 1 ? NULL : argv[1], stdin); +} + +#endif /* LIBFUZZER */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.in new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.in --- old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.in 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -Ivm is an awesome text editor based on -Iv, and is used to play a game called -Ivmgolf. A challenge, simple for many -Ivmgolfers, can still hide secrets. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.keys new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.keys --- old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.keys 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.keys 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -qq -xp -vhg~ -<Escape> -+ -q -3@q diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.ref new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.ref --- old/vis-0.5+git.1584517720.08a550d/test/vim/golf/50ae009b65b8db0002000047/1.ref 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/test/vim/golf/50ae009b65b8db0002000047/1.ref 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ -Vim is an awesome text editor based on -Vi, and is used to play a game called -Vimgolf. A challenge, simple for many -Vimgolfers, can still hide secrets. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/text-regex-tre.c new/vis-0.5+git.1590819266.c37f09e/text-regex-tre.c --- old/vis-0.5+git.1584517720.08a550d/text-regex-tre.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/text-regex-tre.c 2020-05-30 08:14:26.000000000 +0200 @@ -136,7 +136,7 @@ r->it = text_iterator_get(txt, pos); r->end = pos+len; - regmatch_t match[nmatch]; + regmatch_t match[MAX_REGEX_SUB]; int ret = tre_reguexec(&r->regex, &r->str_source, nmatch, match, eflags); if (!ret) { for (size_t i = 0; i < nmatch; i++) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/text-regex.c new/vis-0.5+git.1590819266.c37f09e/text-regex.c --- old/vis-0.5+git.1584517720.08a550d/text-regex.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/text-regex.c 2020-05-30 08:14:26.000000000 +0200 @@ -45,7 +45,7 @@ return REG_NOMATCH; char *cur = buf, *end = buf + len; int ret = REG_NOMATCH; - regmatch_t match[nmatch]; + regmatch_t match[MAX_REGEX_SUB]; for (size_t junk = len; len > 0; len -= junk, pos += junk) { ret = regexec(&r->regex, cur, nmatch, match, eflags); if (!ret) { @@ -73,7 +73,7 @@ return REG_NOMATCH; char *cur = buf, *end = buf + len; int ret = REG_NOMATCH; - regmatch_t match[nmatch]; + regmatch_t match[MAX_REGEX_SUB]; for (size_t junk = len; len > 0; len -= junk, pos += junk) { char *next; if (!regexec(&r->regex, cur, nmatch, match, eflags)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/text-regex.h new/vis-0.5+git.1590819266.c37f09e/text-regex.h --- old/vis-0.5+git.1584517720.08a550d/text-regex.h 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/text-regex.h 2020-05-30 08:14:26.000000000 +0200 @@ -9,6 +9,8 @@ #endif #include "text.h" +#define MAX_REGEX_SUB 10 + typedef struct Regex Regex; typedef Filerange RegexMatch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/text.c new/vis-0.5+git.1590819266.c37f09e/text.c --- old/vis-0.5+git.1584517720.08a550d/text.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/text.c 2020-05-30 08:14:26.000000000 +0200 @@ -1067,26 +1067,26 @@ errno = saved_errno; } -bool text_save(Text *txt, const char *filename) { - Filerange r = (Filerange){ .start = 0, .end = text_size(txt) }; - return text_save_range(txt, &r, filename); -} - /* First try to save the file atomically using rename(2) if this does not * work overwrite the file in place. However if something goes wrong during * this overwrite the original file is permanently damaged. */ -bool text_save_range(Text *txt, Filerange *range, const char *filename) { +bool text_save(Text *txt, const char *filename) { + return text_save_method(txt, filename, TEXT_SAVE_AUTO); +} + +bool text_save_method(Text *txt, const char *filename, enum TextSaveMethod method) { if (!filename) { txt->saved_revision = txt->history; text_snapshot(txt); return true; } - TextSave *ctx = text_save_begin(txt, filename, TEXT_SAVE_AUTO); + TextSave *ctx = text_save_begin(txt, filename, method); if (!ctx) return false; - ssize_t written = text_write_range(txt, range, ctx->fd); - if (written == -1 || (size_t)written != text_range_size(range)) { + Filerange range = (Filerange){ .start = 0, .end = text_size(txt) }; + ssize_t written = text_save_write_range(ctx, &range); + if (written == -1 || (size_t)written != text_range_size(&range)) { text_save_cancel(ctx); return false; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/text.h new/vis-0.5+git.1590819266.c37f09e/text.h --- old/vis-0.5+git.1584517720.08a550d/text.h 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/text.h 2020-05-30 08:14:26.000000000 +0200 @@ -302,14 +302,6 @@ * @{ */ /** - * Save the whole text to the given file name. - */ -bool text_save(Text*, const char *filename); -/** - * Save a file range to the given file name. - */ -bool text_save_range(Text*, Filerange*, const char *filename); -/** * Method used to save the text. */ enum TextSaveMethod { @@ -346,6 +338,19 @@ }; /** + * Save the whole text to the given file name. + */ +bool text_save(Text*, const char *filename); +/** + * Save the whole text to the given file name, using the specified method. + * + * @rst + * .. note:: Equivalent to ``text_save_method(filename, TEXT_SAVE_AUTO)``. + * @endrst + */ +bool text_save_method(Text*, const char *filename, enum TextSaveMethod); + +/** * Setup a sequence of write operations. * * The returned `TextSave` pointer can be used to write multiple, possibly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/ui-terminal-vt100.c new/vis-0.5+git.1590819266.c37f09e/ui-terminal-vt100.c --- old/vis-0.5+git.1584517720.08a550d/ui-terminal-vt100.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/ui-terminal-vt100.c 2020-05-30 08:14:26.000000000 +0200 @@ -108,8 +108,8 @@ CellColor fg = CELL_COLOR_DEFAULT, bg = CELL_COLOR_DEFAULT; int w = tui->width, h = tui->height; Cell *cell = tui->cells; - /* erase screen, reposition cursor, reset attributes */ - buffer_append0(buf, "\x1b[2J" "\x1b[H" "\x1b[0m"); + /* reposition cursor, erase screen, reset attributes */ + buffer_append0(buf, "\x1b[H" "\x1b[J" "\x1b[0m"); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { CellStyle *style = &cell->style; @@ -186,6 +186,7 @@ } static void ui_vt100_suspend(UiTerm *tui) { + if (!tui->termkey) return; termkey_stop(tui->termkey); cursor_visible(true); screen_alternate(false); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/ui-terminal.c new/vis-0.5+git.1590819266.c37f09e/ui-terminal.c --- old/vis-0.5+git.1584517720.08a550d/ui-terminal.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/ui-terminal.c 2020-05-30 08:14:26.000000000 +0200 @@ -198,11 +198,11 @@ if (x < 0 || x >= tui->width || y < 0 || y >= tui->height) return; CellStyle style = tui->styles[style_id]; - Cell (*cells)[tui->width] = (void*)tui->cells; + Cell *cells = tui->cells + y * tui->width; while (x < tui->width) { - cells[y][x].data[0] = c; - cells[y][x].data[1] = '\0'; - cells[y][x].style = style; + cells[x].data[0] = c; + cells[x].data[1] = '\0'; + cells[x].style = style; x++; } } @@ -213,17 +213,17 @@ return; CellStyle style = tui->styles[(win ? win->id : 0)*UI_STYLE_MAX + style_id]; // FIXME: does not handle double width characters etc, share code with view.c? - Cell (*cells)[tui->width] = (void*)tui->cells; - const size_t cell_size = sizeof(cells[0][0].data)-1; + Cell *cells = tui->cells + y * tui->width; + const size_t cell_size = sizeof(cells[0].data)-1; for (const char *next = str; *str && x < tui->width; str = next) { do next++; while (!ISUTF8(*next)); size_t len = next - str; if (!len) break; len = MIN(len, cell_size); - strncpy(cells[y][x].data, str, len); - cells[y][x].data[len] = '\0'; - cells[y][x].style = style; + strncpy(cells[x].data, str, len); + cells[x].data[len] = '\0'; + cells[x].style = style; x++; } } @@ -232,7 +232,6 @@ UiTermWin *win = (UiTermWin*)w; UiTerm *ui = win->ui; View *view = win->win->view; - Cell (*cells)[ui->width] = (void*)ui->cells; int width = win->width, height = win->height; const Line *line = view_lines_first(view); bool status = win->options & UI_OPTION_STATUSBAR; @@ -250,12 +249,13 @@ Selection *sel = view_selections_primary_get(view); const Line *cursor_line = view_cursors_line_get(sel); size_t cursor_lineno = cursor_line->lineno; - char buf[sidebar_width+1]; + char buf[(sizeof(size_t) * CHAR_BIT + 2) / 3 + 1 + 1]; int x = win->x, y = win->y; int view_width = view_width_get(view); + Cell *cells = ui->cells + y * ui->width; if (x + sidebar_width + view_width > ui->width) view_width = ui->width - x - sidebar_width; - for (const Line *l = line; l; l = l->next) { + for (const Line *l = line; l; l = l->next, y++) { if (sidebar) { if (!l->lineno || !l->len || l->lineno == prev_lineno) { memset(buf, ' ', sizeof(buf)); @@ -276,7 +276,8 @@ prev_lineno = l->lineno; } debug("draw-window: [%d][%d] ... cells[%d][%d]\n", y, x+sidebar_width, y, view_width); - memcpy(&cells[y++][x+sidebar_width], l->cells, sizeof(Cell) * view_width); + memcpy(&cells[x+sidebar_width], l->cells, sizeof(Cell) * view_width); + cells += ui->width; } } @@ -299,7 +300,6 @@ debug("ui-arrange\n"); UiTerm *tui = (UiTerm*)ui; tui->layout = layout; - Cell (*cells)[tui->width] = (void*)tui->cells; int n = 0, m = !!tui->info[0], x = 0, y = 0; for (UiTermWin *win = tui->windows; win; win = win->next) { if (win->options & UI_OPTION_ONELINE) @@ -325,9 +325,11 @@ ui_window_move(win, x, y); x += w; if (n) { + Cell *cells = tui->cells; for (int i = 0; i < max_height; i++) { - strcpy(cells[i][x].data,"│"); - cells[i][x].style = tui->styles[UI_STYLE_SEPARATOR]; + strcpy(cells[x].data,"│"); + cells[x].style = tui->styles[UI_STYLE_SEPARATOR]; + cells += tui->width; } x++; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/view.c new/vis-0.5+git.1590819266.c37f09e/view.c --- old/vis-0.5+git.1584517720.08a550d/view.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/view.c 2020-05-30 08:14:26.000000000 +0200 @@ -55,6 +55,7 @@ struct View { Text *text; /* underlying text management */ + char *textbuf; /* scratch buffer used for drawing */ UiWin *ui; /* corresponding ui window */ Cell cell_blank; /* used for empty/blank cells */ int width, height; /* size of display area */ @@ -328,7 +329,7 @@ /* read a screenful of text considering each character as 4-byte UTF character*/ const size_t size = view->width * view->height * 4; /* current buffer to work with */ - char text[size+1]; + char *text = view->textbuf; /* remaining bytes to process in buffer */ size_t rem = text_bytes_get(view->text, view->start, size, text); /* NUL terminate text section */ @@ -454,14 +455,21 @@ view->need_update = true; return true; } + char *textbuf = malloc(width * height * 4 + 1); + if (!textbuf) + return false; size_t lines_size = height*(sizeof(Line) + width*sizeof(Cell)); if (lines_size > view->lines_size) { Line *lines = realloc(view->lines, lines_size); - if (!lines) + if (!lines) { + free(textbuf); return false; + } view->lines = lines; view->lines_size = lines_size; } + free(view->textbuf); + view->textbuf = textbuf; view->width = width; view->height = height; memset(view->lines, 0, view->lines_size); @@ -482,6 +490,7 @@ return; while (view->selections) selection_free(view->selections); + free(view->textbuf); free(view->lines); free(view); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/vis-digraph.c new/vis-0.5+git.1590819266.c37f09e/vis-digraph.c --- old/vis-0.5+git.1584517720.08a550d/vis-digraph.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/vis-digraph.c 2020-05-30 08:14:26.000000000 +0200 @@ -2,6 +2,7 @@ #include <termios.h> #include <locale.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <wchar.h> @@ -1993,8 +1994,11 @@ return 1; } - wchar_t runes[argc-1]; - memset(runes, 0, sizeof(runes)); + wchar_t *runes = calloc(argc-1, sizeof(runes[0])); + if (!runes) { + perror(NULL); + return 1; + } for (int i = 1; i < argc; i++) { int l = lookup(argv[i], &runes[i-1]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/vis-operators.c new/vis-0.5+git.1590819266.c37f09e/vis-operators.c --- old/vis-0.5+git.1584517720.08a550d/vis-operators.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/vis-operators.c 2020-05-30 08:14:26.000000000 +0200 @@ -303,7 +303,7 @@ if (vis->action.op == op) { /* hacky way to handle double operators i.e. things like * dd, yy etc where the second char isn't a movement */ - vis->action.type = LINEWISE; + vis_motion_type(vis, VIS_MOTIONTYPE_LINEWISE); vis_motion(vis, VIS_MOVE_LINE_NEXT); } else { vis->action.op = op; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vis-0.5+git.1584517720.08a550d/vis.c new/vis-0.5+git.1590819266.c37f09e/vis.c --- old/vis-0.5+git.1584517720.08a550d/vis.c 2020-03-18 08:48:40.000000000 +0100 +++ new/vis-0.5+git.1590819266.c37f09e/vis.c 2020-05-30 08:14:26.000000000 +0200 @@ -1946,14 +1946,14 @@ return true; while (*cmdline == ':') cmdline++; - size_t len = strlen(cmdline); - char *line = malloc(len+2); + char *line = strdup(cmdline); if (!line) return false; - strncpy(line, cmdline, len+1); - for (char *end = line + len - 1; end >= line && isspace((unsigned char)*end); end--) - *end = '\0'; + size_t len = strlen(line); + while (len > 0 && isspace((unsigned char)line[len-1])) + len--; + line[len] = '\0'; enum SamError err = sam_cmd(vis, line); if (err != SAM_ERR_OK)
