Skip to content

Commit

Permalink
Af few upstream commits, as pointed out by Leonid Bobrov
Browse files Browse the repository at this point in the history
  • Loading branch information
hboetes committed Jul 13, 2018
1 parent cc1ac33 commit 3de34d8
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 52 deletions.
86 changes: 43 additions & 43 deletions CVS/Entries
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@
/main.c/1.84/Result of merge//
/tags.c/1.16/Result of merge//
/re_search.c/1.33/Mon Aug 28 19:36:58 2017//
/Makefile/1.33/Tue Apr 10 04:57:08 2018//
/README/1.14/Tue Apr 10 04:57:08 2018//
/autoexec.c/1.17/Tue Apr 10 04:57:08 2018//
/basic.c/1.47/Tue Apr 10 04:57:08 2018//
/bell.c/1.4/Tue Apr 10 04:57:08 2018//
/buffer.c/1.104/Tue Apr 10 04:57:08 2018//
/chrdef.h/1.10/Tue Apr 10 04:57:08 2018//
/cinfo.c/1.18/Tue Apr 10 04:57:08 2018//
/cmode.c/1.16/Tue Apr 10 04:57:08 2018//
/cscope.c/1.17/Tue Apr 10 04:57:08 2018//
/dir.c/1.30/Tue Apr 10 04:57:08 2018//
/dired.c/1.83/Tue Apr 10 04:57:08 2018//
/display.c/1.48/Tue Apr 10 04:57:08 2018//
/echo.c/1.66/Tue Apr 10 04:57:08 2018//
/extend.c/1.64/Tue Apr 10 04:57:08 2018//
/file.c/1.100/Tue Apr 10 04:57:08 2018//
/fileio.c/1.105/Result of merge+Thu Apr 19 17:50:42 2018//
/funmap.c/1.53/Tue Apr 10 18:50:09 2018//
/funmap.h/1.7/Tue Apr 10 04:57:08 2018//
/grep.c/1.46/Tue Apr 10 04:57:08 2018//
/help.c/1.35/Tue Apr 10 04:57:08 2018//
/kbd.c/1.30/Tue Apr 10 04:57:08 2018//
/kbd.h/1.19/Tue Apr 10 04:57:08 2018//
/key.h/1.5/Tue Apr 10 04:57:08 2018//
/keymap.c/1.58/Tue Apr 10 04:57:08 2018//
/line.c/1.59/Tue Apr 10 04:57:08 2018//
/macro.c/1.16/Tue Apr 10 04:57:08 2018//
/macro.h/1.7/Tue Apr 10 04:57:08 2018//
/match.c/1.19/Tue Apr 10 04:57:08 2018//
/mg.1/1.106/Tue Apr 10 04:57:08 2018//
/modes.c/1.21/Tue Apr 10 04:57:08 2018//
/paragraph.c/1.45/Tue Apr 10 04:57:08 2018//
/pathnames.h/1.1/Tue Apr 10 04:57:08 2018//
/search.c/1.46/Tue Apr 10 04:57:08 2018//
/spawn.c/1.12/Tue Apr 10 04:57:08 2018//
/tty.c/1.36/Tue Apr 10 04:57:08 2018//
/ttykbd.c/1.19/Tue Apr 10 04:57:08 2018//
/undo.c/1.58/Tue Apr 10 04:57:08 2018//
/util.c/1.38/Tue Apr 10 04:57:08 2018//
/version.c/1.10/Tue Apr 10 04:57:08 2018//
/window.c/1.36/Tue Apr 10 04:57:08 2018//
/word.c/1.19/Tue Apr 10 04:57:08 2018//
/yank.c/1.14/Tue Apr 10 04:57:08 2018//
/tutorial/1.18/Mon May 28 16:13:00 2018//
/Makefile/1.33/Fri Jul 13 09:14:14 2018//
/README/1.14/Fri Jul 13 09:14:14 2018//
/autoexec.c/1.17/Fri Jul 13 09:14:14 2018//
/basic.c/1.47/Fri Jul 13 09:14:14 2018//
/bell.c/1.4/Fri Jul 13 09:14:14 2018//
/buffer.c/1.104/Fri Jul 13 09:14:14 2018//
/chrdef.h/1.10/Fri Jul 13 09:14:14 2018//
/cinfo.c/1.18/Fri Jul 13 09:14:14 2018//
/cmode.c/1.16/Fri Jul 13 09:14:14 2018//
/cscope.c/1.17/Fri Jul 13 09:14:14 2018//
/dir.c/1.30/Fri Jul 13 09:14:14 2018//
/dired.c/1.83/Fri Jul 13 09:14:14 2018//
/display.c/1.48/Fri Jul 13 09:14:14 2018//
/echo.c/1.66/Fri Jul 13 09:14:14 2018//
/extend.c/1.64/Fri Jul 13 09:14:14 2018//
/file.c/1.100/Fri Jul 13 09:14:14 2018//
/funmap.c/1.53/Fri Jul 13 09:14:14 2018//
/funmap.h/1.7/Fri Jul 13 09:14:14 2018//
/grep.c/1.46/Fri Jul 13 09:14:14 2018//
/help.c/1.35/Fri Jul 13 09:14:14 2018//
/kbd.c/1.30/Fri Jul 13 09:14:14 2018//
/kbd.h/1.19/Fri Jul 13 09:14:14 2018//
/key.h/1.5/Fri Jul 13 09:14:14 2018//
/keymap.c/1.58/Fri Jul 13 09:14:14 2018//
/line.c/1.60/Fri Jul 13 09:14:22 2018//
/macro.c/1.16/Fri Jul 13 09:14:14 2018//
/macro.h/1.7/Fri Jul 13 09:14:14 2018//
/match.c/1.19/Fri Jul 13 09:14:14 2018//
/mg.1/1.106/Fri Jul 13 09:14:14 2018//
/modes.c/1.21/Fri Jul 13 09:14:14 2018//
/paragraph.c/1.45/Fri Jul 13 09:14:14 2018//
/pathnames.h/1.1/Fri Jul 13 09:14:14 2018//
/search.c/1.47/Fri Jul 13 09:14:22 2018//
/spawn.c/1.12/Fri Jul 13 09:14:14 2018//
/tty.c/1.36/Fri Jul 13 09:14:14 2018//
/ttykbd.c/1.19/Fri Jul 13 09:14:14 2018//
/tutorial/1.18/Fri Jul 13 09:14:14 2018//
/undo.c/1.58/Fri Jul 13 09:14:14 2018//
/util.c/1.38/Fri Jul 13 09:14:14 2018//
/version.c/1.10/Fri Jul 13 09:14:14 2018//
/window.c/1.36/Fri Jul 13 09:14:14 2018//
/word.c/1.19/Fri Jul 13 09:14:14 2018//
/yank.c/1.14/Fri Jul 13 09:14:14 2018//
D
56 changes: 52 additions & 4 deletions line.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: line.c,v 1.59 2017/09/09 13:10:28 florian Exp $ */
/* $OpenBSD: line.c,v 1.60 2018/07/12 12:38:56 florian Exp $ */

/* This file is in the public domain. */

Expand All @@ -18,6 +18,7 @@
*/

#include <sys/queue.h>
#include <ctype.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
Expand Down Expand Up @@ -511,7 +512,11 @@ int
lreplace(RSIZE plen, char *st)
{
RSIZE rlen; /* replacement length */
int s;
struct line *lp;
RSIZE n;
int s, doto, is_query_capitalised = 0, is_query_allcaps = 0;
int is_replace_alllower = 0;
char *repl;

if ((s = checkdirty(curbp)) != TRUE)
return (s);
Expand All @@ -520,16 +525,59 @@ lreplace(RSIZE plen, char *st)
ewprintf("Buffer is read only");
return (FALSE);
}

if ((repl = strdup(st)) == NULL) {
dobeep();
ewprintf("out of memory");
return (FALSE);
}

undo_boundary_enable(FFRAND, 0);

(void)backchar(FFARG | FFRAND, (int)plen);

lp = curwp->w_dotp;
doto = curwp->w_doto;
n = plen;

is_query_capitalised = isupper((unsigned char)lgetc(lp, doto));

if (is_query_capitalised) {
for (n = 0, is_query_allcaps = 1; n < plen && is_query_allcaps;
n++) {
is_query_allcaps = !isalpha((unsigned char)lgetc(lp,
doto)) || isupper((unsigned char)lgetc(lp, doto));
doto++;
if (doto == llength(lp)) {
doto = 0;
lp = lforw(lp);
n++; /* \n is implicit in the buffer */
}
}
}

(void)ldelete(plen, KNONE);

rlen = strlen(st);
region_put_data(st, rlen);
rlen = strlen(repl);
for (n = 0, is_replace_alllower = 1; n < rlen && is_replace_alllower;
n++)
is_replace_alllower = !isupper((unsigned char)repl[n]);

if (is_replace_alllower) {
if (is_query_allcaps) {
for (n = 0; n < rlen; n++)
repl[n] = toupper((unsigned char)repl[n]);
} else if (is_query_capitalised) {
repl[0] = toupper((unsigned char)repl[0]);
}
}

region_put_data(repl, rlen);
lchange(WFFULL);

undo_boundary_enable(FFRAND, 1);

free(repl);
return (TRUE);
}

Expand Down
10 changes: 5 additions & 5 deletions search.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: search.c,v 1.46 2017/08/06 04:39:45 bcallah Exp $ */
/* $OpenBSD: search.c,v 1.47 2018/07/11 12:21:37 krw Exp $ */

/* This file is in the public domain. */

Expand Down Expand Up @@ -159,10 +159,11 @@ backisearch(int f, int n)
/*
* Incremental Search.
* dir is used as the initial direction to search.
* ^M exit from Isearch, set mark
* ^S switch direction to forward
* ^R switch direction to reverse
* ^Q quote next character (allows searching for ^N etc.)
* <ESC> exit from Isearch
* <ESC> exit from Isearch, set mark
* <DEL> undoes last character typed. (tricky job to do this correctly).
* other ^ exit search, don't set mark
* else accumulate into search string
Expand Down Expand Up @@ -213,6 +214,8 @@ isearch(int dir)
*/
if (ttwait(300) == FALSE)
ungetkey(c);
/* FALLTHRU */
case CCHR('M'):
srch_lastdir = dir;
curwp->w_markp = clp;
curwp->w_marko = cbo;
Expand Down Expand Up @@ -360,9 +363,6 @@ isearch(int dir)
case CCHR('Q'):
c = (char)getkey(FALSE);
goto addchar;
case CCHR('M'):
c = CCHR('J');
goto addchar;
default:
if (ISCTRL(c)) {
ungetkey(c);
Expand Down

0 comments on commit 3de34d8

Please sign in to comment.