1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

215 Commits

Author SHA1 Message Date
jsg
1ca96170b4 remove duplicate unistd.h include 2024-10-12 07:58:40 +00:00
deraadt
421bf2dd52 move ed/tests files to regress/bin/ed, where they are used 2024-08-19 01:43:23 +00:00
deraadt
2bde29b351 Fix the SIGHUP signal race. ed's "event loop" operates a getchar(); check
the hup flag before and after that call, when the buffer structures are stable
for write_file() to work.  Remove the hup handling from the SPL0() macro,
because this is run in at least one place during structure instability.
The SIGINT handler, which uses siglongjmp(), is also trusting the SPL1/SPL0
dance more than it should.
ok millert
2024-07-16 05:01:10 +00:00
jsg
e6c7c102cf correct indentation; no functional change
ok tb@
2024-04-23 13:34:50 +00:00
millert
a565d659ae Write number of bytes read/written and "?" prompt to stdout, not stderr.
This matches both historical behavior and the POSIX specification.
From Soeren Tempel.
2022-11-18 14:52:03 +00:00
jmc
e6e8f672aa grammar fix; from S M 2022-06-19 05:49:51 +00:00
millert
1f6b116283 Flush all stdio streams before running a shell command.
Otherwise, if ed's output is not line buffered (e.g. if it is
redirected to a file or pipe) the shell command output may be
displayed before data buffered by ed itself is written.
From Soeren Tempel.  OK deraadt@
2022-01-22 23:22:11 +00:00
jsg
093fc5b92d Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff
2021-03-08 02:47:25 +00:00
bluhm
d7dde21195 Rev 1.17 of sub.c removed infinite loop detection from s command.
Adapt substitute test to new ed(1) behavior.  Note that substitute
result from sed(1) is still different.
2020-01-09 18:34:08 +00:00
bluhm
934f3ca2b7 Rev 1.59 of main.c allows omission of addresses in a range.
Adapt ed test.
2020-01-09 17:16:37 +00:00
bluhm
6c910bd32f Rev 1.42 of main.c allows zero address for i command.
Adapt ed test.
2020-01-09 14:58:26 +00:00
schwarze
d01da9da9f In addresses, consistently use "+" rather than ".+1".
Both have the same meaning, but the former is explicitly defined
in this manual page as "the next line" whereas the latter requires
combining various pieces of information for understanding.
Unification suggested and patch OK'ed by martijn@.
2019-07-30 09:23:35 +00:00
schwarze
32c5747327 1. Correct the description of the g command to match POSIX and our
implementation; it was oversimplified and arguably incorrect.
2. Explicitely compare the behaviour of empty command lists for g,
empty command lists for G, and empty commands because these subtle
differences are quite confusing.
3. Say more precisely what the v and V commands do, avoiding the
fuzzy wording "similar".
All these issues were first pointed out by martijn@.
Feedback and OK martijn@; "diff reads ok" jmc@ on an earlier version.
2019-07-20 15:28:54 +00:00
schwarze
493e33563b Explain in which circumstances trailing slashes can be omitted after
the g and G commands, and polish the wording a bit explaining empty
command lists.
Closing a gap in the manual reported by <mazocomp at disroot dot org>.
OK jmc@ martijn@
2019-07-15 17:57:48 +00:00
schwarze
d397aeb5b5 Minor polishing:
* Delete a stray blank from the command line synopsis
and add the missing .Ar markup to it.
* Do not mention the terminating newline for the empty command
since it isn't mentioned for any other command either.
* Make the description of the empty command easier to understand.
Joint work with martijn@ and jmc@.
2019-07-12 19:28:48 +00:00
jmc
a74ab9fe9f document the dropping of the second / and ? in line address REs;
thread started by mazocomp; diff from ropers, shortened by me;

ok martijn schwarze
2019-07-10 13:35:51 +00:00
deraadt
64fca36ce7 fputc returns EOF 2019-06-28 13:41:42 +00:00
deraadt
3aaa63eb46 When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
2019-06-28 13:34:58 +00:00
florian
3cd3751cbb Be precise in checking for errors. pclose(3) returns -1 and fclose(3)
EOF in case of errors, not any negative number.
EOF corner case spotted while reviewing a much bigger diff by deraadt

OK deraadt, millert
2019-06-27 06:41:36 +00:00
martijn
56c391f4a1 Revert previous, there were some unintended beviour changes. 2018-06-19 12:36:18 +00:00
martijn
c717a4838b Remove the parse_char_class and let regcomp determine if our brackets
are balanced.

OK millert@ and tb@
2018-06-18 17:08:20 +00:00
martijn
1a4ed9d924 Remove references to BACKWARDS.
OK tb@
2018-06-15 08:46:24 +00:00
martijn
94ed1c32eb Make sure we always return more than a single '!' in get_shell_command.
This is similar to what vi/ex does and removes the final BACKWARDS flag.

Behaviour requested by and OK tb@
2018-06-15 08:45:03 +00:00
martijn
b0cb3eaf5e Remove the non-BACKWARDS option for GET_THIRD_ADDR. No change to current
behaviour.

OK tb@
2018-06-15 08:26:31 +00:00
martijn
7718bbbdae Remove the extra pager code when compiled without the BACKWARDS flag.
Most terminals have scrollback options, or can be achieved via tmux, so
it's not needed.

OK millert@
2018-06-04 13:29:07 +00:00
martijn
9018d1b5df Definitively choose the existing semantics for the scroll and null command.
POSIX states: "An empty command list shall be equivalent to the p command",
so changing the behaviour of a null-command in any other case is a
violation of POSIX.

OK millert@
2018-06-04 13:26:21 +00:00
martijn
189341d15a Fail earlier if we don't have a current filename. This simlifies the
code and removes a few BACKWARDS flags.

OK otto@
2018-05-24 06:24:29 +00:00
martijn
0deac3349e Make ed's 'l' command end lines with a '$' and make sure that literal
'$' characters are escaped, so that we are POSIX compliant.

The omission of trailing '$' was originally hidden behind a BACKWARDS
flag. This flag was most likely introduced to be compatible with 4.4BSD.
Thanks to naddy@ for pointing me to the 4.4BSD ed implementation.

I tried to trace the origin and enabling of the BACKWARDS flag, since
both FreeBSD and NetBSD have the flag, but only FreeBSD doesn't have it
enabled. Both projects had an alm@ working on ed during 1993-1995 during
which he added this flag to both projects and only enabled it on NetBSD,
but I wasn't able to reach him on any known address.
Thanks to Ed Schouten (ed@freebsd), and Michael W. Lucas of the ed
Mastery book for helping me trying to locate Andrew Moore.

Problem originally prodded by garzon.lucero@gmail.com and later
independently re-requested by n.reusse@hxgn.net.

OK tb@, guenther@, and mwl@mwl.io
2018-04-26 12:18:54 +00:00
martijn
6aeae0a8cf Make ed(1) warn about modifications if 'r'ead in an empty file and
trying to quit.

Diff from Tim Chase
OK tb@ and millert@
2018-02-26 17:35:08 +00:00
bluhm
e09f564437 Rename test file =.err to eq.err for simpler make file scripts. 2018-01-09 00:43:10 +00:00
schwarze
4522452324 nits about trailing punctuation found with mandoc -Tlint 2017-07-05 12:23:46 +00:00
naddy
e768d0ed36 silence clang warnings: add an extra pair of parentheses and stop
passing empty format strings to printf-family functions; ok millert@
2017-04-26 21:25:43 +00:00
tb
b4c905bbf3 Allow the omission of one address in (.,.) and (.;.) address ranges
as per POSIX. With this patch, ",n" is an abbreviation for "1,n",
";n" abbreviates ".;n". The "n," and "n;" variants mean "n,n" and "n;n",
respectively.

Patch from Jerome FRGAGIC; ok stefan, deraadt
2017-01-03 20:24:29 +00:00
martijn
5c1c584960 Reimplement g flag for s commands. Got lost in previous commit.
Found because of a hint by and OK schwarze@.
2016-10-11 06:54:05 +00:00
martijn
ec842024e1 Remove infinite loop detection from the s-command.
If a zero-length match is found do the replacement and increment the start point
for the next search by one. This allows for commands like s/^/- /
This brings the behaviour closer to the way sed and vi work.

OK schwarze@
2016-10-10 17:36:03 +00:00
jmc
6cb920ff32 remove the note about the list command (l) displaying a --More--
prompt for huge lines (according to otto this happens only when
BACKWARDS is not defined);

ok otto
2016-09-23 06:17:43 +00:00
natano
cdc56b0e2b Piping to a shell command does not count as a save, so don't reset the
modified flag.
from Jerome Frgacic (jerome.frgacic (at) yahoo.fr)
ok tb
2016-08-16 20:04:46 +00:00
martijn
ce8ab6eee4 Fix the begin of word bug in s-command, similar to sed.
nit fix and OK schwarze@
2016-08-02 20:17:06 +00:00
mmcc
8891069247 actually remove unnecessary includes
from Edgar Pettijohn, ok and with input from tb@
2016-03-27 00:43:38 +00:00
mmcc
df7744bf30 header cleanup
from Edgar Pettijohn, correction from deraadt@
2016-03-22 17:58:28 +00:00
tb
9cca507621 honestly i think you should just zap that paragraph - it doesn;t make
sense to document that posix more or less says something should happen,
and that it does.

jmc
2015-11-20 20:13:32 +00:00
tb
7b8e453116 make ed restore the user defined prompt (specified with -p) when it was turned
off and then on again with 'P'.

ok daniel@
2015-11-20 08:53:28 +00:00
guenther
571819d879 POSIX says that you can't capture the return value of sigsetjmp().
Fortunately, we don't need it as we only pass siglongjmp() a single value.

ok deraadt@
2015-10-25 03:40:58 +00:00
millert
dc548fa222 Style fixes; from Ilya Kaliman 2015-10-21 16:06:57 +00:00
tobias
d9ee4fa8f3 The variable errmsg can be static in main.c if code in re.c uses an own
buffer to construct error messages.

with input by and ok millert@
2015-10-09 21:24:05 +00:00
tobias
7aba22276a Define functions as static when they are not used outside their own c-files.
ok millert@
2015-10-09 20:27:28 +00:00
millert
67d9079789 Mark static globals that are only used in their respective .c files.
Also make stdin unbuffered since that is the same as using a
single-byte buffer.  OK tobias@
2015-10-09 19:47:02 +00:00
deraadt
0bd1216cbf Change all tame callers to namechange to pledge(2). 2015-10-09 01:37:06 +00:00
deraadt
d92db9d4ad tame "stdio rpath wpath cpath proc exec tty". proc and exec because ed
it is a shell (it has a !command).  tty because it uses TIOCGWINSZ in
a SIGWINCH handler.
2015-10-07 05:37:42 +00:00
millert
6cdce3367b Remove useless pattern_t typedef, POSIX regex is here to stay so
just use regex_t directly.
2015-10-04 15:23:24 +00:00