1
0

changes to str from old dir

This commit is contained in:
dtb 2023-08-17 17:51:21 -04:00
parent 787437106d
commit 4f7d204f5a
3 changed files with 12 additions and 23 deletions

View File

@ -1,2 +0,0 @@
#define _isempty_c
int isempty(int c){ return 0; }

View File

@ -22,6 +22,10 @@ Str will exit unsuccessfully if a string is empty, as none of its contents passe
.PP
Str will print a message to standard error and exit unsuccessfully if used improperly.
.SH EXTENSIONS FROM CTYPE
Using the ctype "isvalue", which does not exist within ctype(3), will make str exit successfully as long as the given string(s) have non-zero length.
.SH BUGS
There's no way of knowing which argument failed the test without re-testing arguments individually.

View File

@ -1,31 +1,21 @@
#include <ctype.h>
#include <stddef.h> /* NULL */
#include <stdio.h> /* fprintf(3) */
#include <string.h> /* strcmp(3) */
#if defined DONT_USE_SYSTEM_SYSEXITS
# include "../include/sysexits.h" /* EX_USAGE */
#else
# include <sysexits.h> /* EX_USAGE */
#if !defined EX_USAGE
# include <sysexits.h>
#endif
static char *program_name = "str";
/* don't use this */
/* #include "isempty.c" */
/* An isempty() won't work; see implementation - the default behavior of str(1)
* is to return 1, so it would return 1 (false) no matter what. I'm not adding
* a special case, just do something like `! str isvalue "$input"` in the
* higher level.
* However, if you wanna make it work, the file is included, just hack on this
* source file after removing the comment on the include. */
#include <ctype.h>
#include "isvalue.c"
#if defined INCLUDE_ISVALUE_C
# include "isvalue.c"
/* This is a special addition to the command that lets `str isvalue "$input"`
* function as a lightweight replacement to the common `test -n "$input"` or
* `[ -n "$input" ]`. This will speed up your shellscript execution by a tad
* ONLY if test(1) isn't already built into your shell (most of the time, it
* is, and saves you the overhead of spawning a new process, which is greater
* than the savings of switching from test(1) to this program). */
#endif
static char *program_name = "str";
static struct {
char *name;
@ -37,9 +27,6 @@ static struct {
{ "iscntrl", iscntrl },
{ "isdigit", isdigit },
{ "isxdigit", isxdigit },
#if defined _isempty_c
{ "isempty", isempty },
#endif
{ "isgraph", isgraph },
{ "islower", islower },
{ "isprint", isprint },