Remove strcmp. Add manpages for overwrite and vis.

This commit is contained in:
Mid Favila 2022-09-13 18:36:47 -04:00
parent 9d80a006d5
commit 5103583012
5 changed files with 60 additions and 47 deletions

1
README
View File

@ -6,7 +6,6 @@
highly portable and to cover common problems that can't be easily solved with
shell.
-strcmp: Exits with 0 if the provided pair of strings differs. Otherwise, 1. [done]
-vis: Replaces non-printing and non-ASCII characters with octal values. [done]
-unfold: Exactly what it sounds like. unfold will attempt to merge lines
with fewer than the provided number of characters with the next

30
doc/overwrite.1 Normal file
View File

@ -0,0 +1,30 @@
.TH overwrite 1 2021-11-21 me-utils "Extended Userland"
.SH NAME
overwrite \- Overwrite named file(s) with stdin
.PP
.SH SYNOPSIS
.PP
overwrite [ files ... ]
.SH DESCRIPTION
.PP
Overwrite is an extension to the standard userland that reads standard input
into an internal buffer before writing that internal buffer to each named file.
.SH OPTIONS
.PP
Overwrite accepts no arguments.
.SH ENVIRONMENT
This program requires a C89 compiler.
.SH FILES
/usr/src/me-utils/src/overwrite.c
.SH CONFORMING TO
.PP
Non-standard tool.
.SH NOTES
.PP
Nothing to note.
.SH BUGS
.PP
No bugs known. Please report any to <midfavila@sdf.org>.
.SH SEE ALSO
tee(1p)

30
doc/vis.1 Normal file
View File

@ -0,0 +1,30 @@
.TH vis 1 2021-11-21 me-utils "Extended Userland"
.SH NAME
vis \- Print octal values of invisible characters
.PP
.SH SYNOPSIS
.PP
vis
.SH DESCRIPTION
.PP
Vis is an extension to the standard userland that reads standard input
and replaces any non-printing or blank characters with their octal values.
.SH OPTIONS
.PP
Vis accepts no arguments.
.SH ENVIRONMENT
This program requires a C89 compiler.
.SH FILES
/usr/src/me-utils/src/vis.c
.SH CONFORMING TO
.PP
Non-standard tool.
.SH NOTES
.PP
Nothing to note.
.SH BUGS
.PP
No bugs known. Please report any to <midfavila@sdf.org>.
.SH SEE ALSO
od(1p), printf(1p), echo(1p)

View File

@ -5,7 +5,6 @@ PREFIX = /usr
BINS = \
overwrite \
strcmp \
vis
all: $(BINS)

View File

@ -1,45 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "support.h"
int shortestword(const char* word1, const char* word2)
{
int len = 0;
for(;;)
{
if(!word1[len])
{
return 0;
}
else if(!word2[len++])
{
return 1;
}
}
}
int main(int argc, char **argv)
{
int swl = 0;
/* modify the program to support comparison of an arbitrary number of strings */
if(argc != 3)
{
throw(NEEDARG_FAIL, mastrcat(argv[0], " str1 str2"));
}
if(!shortestword(argv[1], argv[2]))
{
swl = (int) strlen(argv[1]);
}
else
{
swl = (int) strlen(argv[2]);
}
return(strncmp(argv[1], argv[2], swl));
}