strcmp moved to bonsai
This commit is contained in:
parent
8d54508796
commit
2842bb0a33
@ -1 +0,0 @@
|
||||
strcmp: strcmp.c
|
@ -1,47 +0,0 @@
|
||||
.TH STREQ 1
|
||||
|
||||
.SH NAME
|
||||
|
||||
strcmp \(en compare strings
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
strcmp
|
||||
.RM [ string ]
|
||||
.RB [ strings... ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
Strcmp checks whether the given strings are the same.
|
||||
Strcmp exits successfully if the strings are identical. Otherwise, strcmp exits
|
||||
with the value 1 if an earlier string has a greater byte value than a later
|
||||
string (e.g.
|
||||
.R strcmp b a
|
||||
)
|
||||
and 255 if an earlier string has a lesser byte value (e.g.
|
||||
.R strcmp a b
|
||||
).
|
||||
|
||||
.SH DIAGNOSTICS
|
||||
|
||||
Strcmp will print an error message and exit unsuccessfully with a status
|
||||
described in sysexits(3) if used incorrectly (given less than two operands).
|
||||
|
||||
.SH UNICODE
|
||||
|
||||
Strcmp will exit unsuccessfully if the given strings are not identical;
|
||||
Unicode strings may need to normalized if the intent is to check visual
|
||||
similarity and not byte similarity.
|
||||
|
||||
.SH STANDARDS
|
||||
|
||||
Strcmp is not described in POSIX.1-2017.
|
||||
Strcmp's function may be performed on a purely POSIX system with test(1).
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
Public domain.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
strcmp(3), test(1)
|
@ -1,25 +0,0 @@
|
||||
#include <stdio.h> /* fprintf(3), stderr */
|
||||
#ifndef EX_USAGE
|
||||
# include <sysexits.h> /* EX_USAGE */
|
||||
#endif
|
||||
|
||||
static char *program_name = "strcmp";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int i;
|
||||
|
||||
if(argc < 3){
|
||||
fprintf(stderr, "Usage: %s [string] [string...]\n",
|
||||
argv[0] == NULL ? program_name : argv[0]);
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
for(; *argv[1] != '\0'; ++argv[1])
|
||||
for(i = 2; i < argc; ++i)
|
||||
if(*argv[i-1] > *argv[i])
|
||||
return 1;
|
||||
else if(*argv[i-1] < *argv[i]++)
|
||||
return -1; /* actually 255 */
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user