When viewing sbase's man pages the date displayed at the bottom is
the current date rather than the date entered in the <program>.1
file.
According to this:
https://mandoc.bsd.lv/mdoc/details/date.html
The traditional man date format used by sbase (.Dd year-month-day)
is no longer recommended and no longer supported by GNU troff or
Heirloom Docs and as a result the current date is displayed instead.
Although this format is still accepted by mandoc for backward
compatibility.
For portability it states the standard mdoc date format should be
used instead: .Dd month day, year
I applied the following patch to sbase's last commit b30fb56 and
it fixes the issue.
The target tried to execute a non valid shell script
and there was a possibility to fatorize the creation
of the proto file instead of repeating it in all
the actions that required.
Some tar archives (eg. ftp://ftp.gnu.org/gnu/shtool/shtool-2.0.8.tar.gz)
use leading spaces instead of leading zeroes for numeric fields.
Although it is not allowed by the ustar specification, most tar
implementations recognize it as correct. But since 3ef6d4e4, we
replace all spaces by NULs here, not just trailing ones, which leads to
recognizing such archives as malformed. This fixes it: we now skip
over leading spaces, allowing strtol(3) to read those numeric fields.
As pointed out in a mail to dev expr was segfaulting when multiple
math operations were specified on the command line: eg. 'expr 3 \*
2 + 1'. This happens because the tonum(), introduced in e50d533,
assumed that v->str was always non null. parse() guarantees this
for user input but this is not the case when doop() is called with
the result of a previous calculation. However in that case we know
that v->num is already valid so we can simply return.
The MAN macro was not used, and it and OBJ had the same problem
because they were defined using an empty string in the replace
pattern of the macro expansion, but as it is said by POSIX:
The subst1 to be replaced shall be recognized when it is a suffix
at the end of a word in string1
so, an empty string should not be used.
Also, a new inference rule is added to generate the binary
directly from the .c without generating the intermediate
object, removing the need of chaining different inference
rules which is not guaranteed to work in all the make
implementations.
POSIX specifies that if the pattern contains a subexpression then
the first matched subexpression should be returned if it exists.
This fixes things like the following:
./expr 00003 : '\(.*\)'
Before: 3
After: 00003
Comparison operations (>, <, =, etc.) and matching operations must
operate originally provided string not one that has gone back and
forth through string formatting. This caused operations such as
the following to give incorrect results:
./expr 00003 : '.*'
Before: 1
After: 5
This commit fixes that issue.
The s command can apply a replace pattern with embedded newlines
which modifies the line/index assignament. Using a range in the
address fail because afther the call to subline() the next line
has to be searched based in the index because the replace could
insert newlines.
when sbase-box is executed without argument, the check sbase-box
options doesn't verify the argument count leading to a segfault.
Add a check on the argc before parsing sbase-box options (currently
only `-i`)
If newcmd is 0 then error() undo all the modifications
that happened since the last command, but this is not
what POSIX mandates:
SIGINT The ed utility shall interrupt its current activity, write the
string "?\n" to standard output, and return to command mode
(see the EXTENDED DESCRIPTION section).
Strings without newlines created problems in the function
and the global field was not updated, making that new lines
added were marked as global being processed in the current
global command.
If the string r.str is freed but error() is called then
next call will see a pointer that maybe it will try to free
because the call to error unwind the frame stack.
These functions allow to read from stdin the full next
line or seting as input a character array. These functions
avoid all the complexity about repeat commands that is very
fragile and depends on having multiple global variables with
weak relation between them.
Make will search in the catalogue of rules for a way to
update the target, and in case of finding the dependency
it will apply the rule without a need of specifying that
dependency.
The Makefile rule was too complex and these cases is better to just
move it to a script where will be eassier to use sed properly
and not looping over all the files 4 times.
The signal handlers were calling longjmp() but as the code was calling
non signal safe functions the behaviour was very unpredictable generating
segmentation faults and dead lock. This commit changes the signal handlers
to only set a variable that is checked in safe places where long loops
happen.
POSIX.1-2017 demands in Shell & Utilities under 'Commands in ed':
The e, E, f, r, and w commands shall take an optional file parameter,
separated from the command letter by one or more <blank> characters.
Ensure at least one <blank> character (as defined for the POSIX locale)
is present or error out.
Signed-off-by: Rene Kita <mail@rkta.de>
Fopen() and Popen() were open as read streams, but we were writing
in both cases. In the same way, the FILE pointer returned by popen()
was close with fclose() that can lead to file descriptor leaks and
zombie processes.
Discard() was reading stdin until a new line was found, but in
case of having an empty line in the input buffer then it didn't
make sense because we were just discarding the full next line.
The substitution must happen in all the parameters that contain
the replacement string, but the code was soing the substitution
only once and in the parameter with an exact match.
Also, the argument length was not updated correctly, assuming
that the final argument had the size read from stdin.
The free() was added in the wrong assumption that xargs was not
freeing the argument in the position replaced, but it actually
does it.
Also, removing the call to free() makes more general the function.