Commit Graph

1715 Commits

Author SHA1 Message Date
sin
16159a61ac ed: Use snprintf() for constructing the scratch filename 2016-01-02 10:33:56 +00:00
sin
3300d5d47a ed: Use strlcpy/strlcat to construct the scratch filename 2016-01-02 09:46:48 +00:00
Roberto E. Vargas Caballero
36e2bdf517 ed: Use TMPDIR to locate the temporal file
The current behaviour of storing the scratch file in
the current directory is a bit painful, because it
generates files in all the directories where you
execute ed. BSD ed uses TMPDIR for this purpouse,
so if the user wants to put the scratch file in
other place different of /tmp it only has to set
this variable.
2016-01-02 09:46:48 +00:00
Roberto E. Vargas Caballero
cf0a0fc940 ed: Fix error introduced in b19d708
This patch introduced init() function, which removed the initialization
code of savfname in doread, but this is incorrect, because savfname
can be initialized with a r command if savfname is empty.
2016-01-02 09:46:48 +00:00
Roberto E. Vargas Caballero
6630bd97cf ed: Don't show '!' in exec with -s
POSIX indicates that this '!' is a diagnosis
that must not be printed when -s is supplied.
2016-01-02 09:46:48 +00:00
Roberto E. Vargas Caballero
b2ef7e73e0 ed: Correct error message when open file
"input/output" error was to general and could create confusion.
All the other ed implementations give a "cannot open input file"
2016-01-02 09:46:48 +00:00
Roberto E. Vargas Caballero
c5e28b5fe9 ed: Don't show size of files in no diagnosistic mode
-s flag disables such warnings.
2016-01-01 10:39:59 +00:00
Roberto E. Vargas Caballero
b19d708923 ed: add init()
These funcction initializes the scratch buffer, and in case of
having a file name parameter it loads the file in the scratch.
It also fixes a problem before this version, where the saved
filename was not set when the file didn't exist.
2016-01-01 10:39:59 +00:00
Roberto E. Vargas Caballero
03d27b7806 ed: Reset modflag in clearbuf()
For the same reason we don't care about the state of
the buffer in clearundo() we can reset modflag in
clearbuf(), because after calling it we don't want
to know anything about the previous state.
2016-01-01 10:39:59 +00:00
Roberto E. Vargas Caballero
58c9739532 ed: Move modflag=0 to clearundo()
When we discard the content of an undo buffer
is because we don't need it anymore, and it means
that we don't care about the modify state of the buffer
so we can reset the modflag in clearundo(), and
remove this assignation each time clearundo() is called.
2016-01-01 10:39:59 +00:00
sin
69855fe1bb Update copyright years 2016-01-01 10:39:59 +00:00
Roberto E. Vargas Caballero
b08660e1fd ed: Fix infinite recursion to undo() 2015-12-31 19:38:17 +00:00
Quentin Rameau
a02d66b8fc chown: fix user:group option parsing
Check that either user or group is correctly passed, and adapt
documention according to that.
2015-12-21 19:07:51 +00:00
Quentin Rameau
6e7743eb56 Cleanup usage() across sbase
Some tools didn't use argv0 for tool name, or usage() at all.
2015-12-21 18:07:25 +00:00
sin
00d7bf4ea5 flock: Check for waitpid() error 2015-12-21 14:13:36 +00:00
sin
0c3440253b flock: Close fd early for correct error propagation
Spotted by FRIGN.
2015-12-21 14:13:36 +00:00
FRIGN
e40fc2b176 Check argv0 in xvprintf()
You never know, given printf'ing NULL-strings might crash the
program, we shouldn't just pass argv0 blindly to it.
2015-12-21 14:13:36 +00:00
sin
3b1b50cffa Do not indent label 2015-12-21 09:55:01 +00:00
FRIGN
94e92d9cc0 Refactor eprintf.c
When we move the exit() out of venprintf(), we can reuse it for
weprintf(), which basically had duplicate code.
I also renamed venprintf() to xvprintf (extended vprintf) so it's
more obvious what it actually does.
2015-12-21 09:34:13 +00:00
Roberto E. Vargas Caballero
6135cad495 Move edit logic to an individual function
It is better to separate this logic from
the parameter logic in main().
2015-12-16 20:25:50 +00:00
Roberto E. Vargas Caballero
05af2156b6 Fix small typo in comment 2015-12-16 20:25:50 +00:00
Roberto E. Vargas Caballero
694a5ef7fb call to addpre() in every iteration of subline()
It is needed to call to addpre(), because in other
case the prefix of all the occurrences before
the target will not be copied to the result
string.
2015-12-16 20:16:12 +00:00
Roberto E. Vargas Caballero
3e130cee66 Escape correctly characters in getrhs()
getrhs() must remove \ excepts in the case of & and \d
(where d is a digit), because in this case are sequences
understood by addsub(), so addsub() must be able to see
them.
2015-12-16 20:16:12 +00:00
Roberto E. Vargas Caballero
a65e180e5e Discard input at the end of global commands
If there is no any match, then the rest of the line
is not read, and it means that ed thins it is a new
command.
2015-12-16 20:16:12 +00:00
Quentin Rameau
d1bef890ea ed: use arg.h 2015-12-16 09:52:35 +00:00
Quentin Rameau
c5b36e1760 ed: fix cmd e/E
Ensure we have a filename before taking further action.
2015-12-16 09:52:35 +00:00
Roberto E. Vargas Caballero
d84070398b Check if PRIO_MIN and PRIO_MAX are defined
The majority of the systems define PRIO_MAX and PRIO_MIN,
but there is an obscure system, whose name I am not going
to tell, where they were not defined.
2015-12-15 17:05:21 +00:00
sin
7949adf9c4 No need for using a sub-shell in getconf.sh 2015-12-15 09:46:06 +00:00
sin
e52845281a Fix warning in join(1)
Spotted by Random832.
2015-12-15 09:40:52 +00:00
sin
fdf9ab9b2d Fix some useless warnings
Makes the code uglier but I cannot stand them.
2015-12-15 09:05:02 +00:00
sin
6b14c50e57 Fix sbase-box target 2015-12-15 08:48:43 +00:00
sin
c0eafd4610 Fix getconf(1) usage 2015-12-15 08:45:39 +00:00
Roberto E. Vargas Caballero
136f012d23 Remove ifdef hell from getconf.c
Every system is going to have a different configuration
so the only solution is to put an ifdef guard for every
value.  To do this, we generate the header at compile time
with a shell script.
2015-12-15 08:45:39 +00:00
Roberto E. Vargas Caballero
a19aad7c70 Fix getrhs()
getrhs() must not interpret escapes, because in other case
addsub() will not be able to see the escaped characters.
2015-12-14 14:52:53 +00:00
Roberto E. Vargas Caballero
0cd385d164 Restore state of buffer in errors
When a error occurs it is important to remove all the modifications
done by the offending command and restore the value of dot to the
state before of executing the command.
2015-12-14 14:52:53 +00:00
Roberto E. Vargas Caballero
13e0b6c605 Do not modify curln with w commands
POSIX declares that dot is not modified by w commands
2015-12-14 14:52:53 +00:00
sin
25f87bc360 Staticise globals in ed(1) 2015-12-14 12:14:52 +00:00
sin
912c21ab1f Remove unused variables in ed(1) 2015-12-14 12:14:52 +00:00
Roberto E. Vargas Caballero
1de650edf5 Add ed(1) - the standard text editor 2015-12-14 12:14:52 +00:00
sin
b533625aac Fix style issue in whoami which broke the sbase-box target
sbase-box.c:(.text+0xd88): undefined reference to `whoami_main'
collect2: ld returned 1 exit status

Broke the sed magic in Makefile.
2015-12-14 11:59:48 +00:00
FRIGN
09c279285a Add whoami(1)
including manpage and other stuff. This program is a no-brainer.
This was inspired by an initial commit by e@bestmx.net. Thanks!
2015-12-14 10:14:07 +00:00
sin
bb7427f6c1 Fix type mismatch in split(1)
Adapted from a patch sent by Random832.
2015-11-26 10:35:46 +00:00
sin
67157b7c4e Use SSIZE_MAX for overflow check in parseoffset()
There's no such thing as OFF_MAX so we can't use that.  off_t is
signed, so use SSIZE_MAX which will typically match the range of
off_t.
2015-11-26 10:35:46 +00:00
sin
1be832320c Fix type mismatches
Thanks to Random832 for the patch.
2015-11-26 10:35:46 +00:00
sin
41a9742037 cal: Highlight current day
Thanks cls!
2015-11-21 10:20:07 +00:00
Brad Barden
211c565b3d tar: improve file status handling on extract
by re-ordering when chmod/chown is done, only a list of directories (not
all files) need be kept for fixing mtime.

this also fixes an issue where set-user-id files in a tar may not work. chmod
is done before chown and before the file is written. if ownership changes, or
the file is being written as a normal user, the setuid bit would be cleared.

also fixes ownership of symbolic links. previously a chown() was called,
which would change the ownership of the link target. lchown() is now
used for symbolic links.

renamed all ent, ent* functions to dir* as it better describes what they
do.

use timespec/utimensat instead of timeval/utimes to get AT_SYMLINK_NOFOLLOW
2015-11-20 09:58:38 +00:00
Brad Barden
85a9254d3a tar: extract creation mode
mode for newly-created files should be restrictive. chmod is always
called soon after to set correct mode from the archive.
2015-11-20 09:58:38 +00:00
sin
11fee4c8ba readlink: Remove broken support for -m and -e
There is no need to bloat readlink with these options.  No one has
ever used them anyway.
2015-11-16 16:30:19 +00:00
sin
d24584466c Revert "enmasse: For the special case of 2 args, do not distinguish between dirs and files"
This reverts commit a564a67c4ea70e90a4dc543814458e4903869d3e.

Not as trivial as I thought.  This breaks cp when used as:
cp -r /foo/bar /baz

The old code expands this to:
cp -r /foo/bar /baz/bar
2015-11-13 14:31:34 +00:00
sin
4c1f9ecdd2 Align end of comment 2015-11-13 14:24:09 +00:00