6 changed files with 113 additions and 2 deletions
@ -0,0 +1 @@ |
|||
2021/11/23 - Added true and false, as well as a skeleton for wc. Created LOG. |
@ -0,0 +1,34 @@ |
|||
.TH wc 1 2021-11-21 mp-utils Userland |
|||
|
|||
.SH NAME |
|||
wc \- print to stdout forever |
|||
.PP |
|||
.SH SYNOPSIS |
|||
.PP |
|||
Print the provided string to stdout forever. |
|||
.SH DESCRIPTION |
|||
.PP |
|||
Yes is a standard Unix tool that accepts input from the user and prints it to stdout repeatedly, or y when no input is provided. |
|||
.SH OPTIONS |
|||
.PP |
|||
This implementation of wc accepts no arguments. |
|||
.SH ENVIRONMENT |
|||
This implementation of wc requires a C89 compiler. |
|||
.SH FILES |
|||
/usr/src/mp-utils/src/wc.c |
|||
.SH CONFORMING TO |
|||
.PP |
|||
.SM |
|||
POSIX |
|||
2017, |
|||
.SM |
|||
SUS |
|||
3 |
|||
.SH NOTES |
|||
.PP |
|||
None. |
|||
.SH BUGS |
|||
.PP |
|||
None known. |
|||
.SH SEE ALSO |
|||
wc(1p) |
@ -1,3 +1,4 @@ |
|||
#include <stdlib.h> |
|||
#include <stdio.h> |
|||
#include <unistd.h> |
|||
#include <string.h> |
|||
|
@ -0,0 +1,9 @@ |
|||
#include "common.h" |
|||
|
|||
int main(int argc, char **argv) |
|||
{ |
|||
if(!strcmp(argv[0], "true")) |
|||
return 0; |
|||
else |
|||
return 1; |
|||
} |
@ -0,0 +1,67 @@ |
|||
#include "common.h" |
|||
|
|||
enum { |
|||
LINES, |
|||
WORDS, |
|||
BYTES |
|||
}; |
|||
|
|||
int* count_values(FILE *fp) |
|||
{ |
|||
static int count[3] = {0}; |
|||
char in_word, c; |
|||
in_word = c = 0; |
|||
|
|||
while((c = getc(fp)) != EOF) |
|||
if(in_word) |
|||
switch(c) |
|||
{ |
|||
case '\n': |
|||
count[LINES]++, count[BYTES]++; |
|||
in_word = 0; |
|||
break; |
|||
|
|||
case ' ': |
|||
in_word = 0; |
|||
count[BYTES]++; |
|||
break; |
|||
|
|||
case '\t': |
|||
in_word = 0; |
|||
count[BYTES]++; |
|||
break; |
|||
|
|||
default: |
|||
count[BYTES]++; |
|||
break; |
|||
} |
|||
else |
|||
switch(c) |
|||
{ |
|||
case '\n': |
|||
count[LINES]++, count[BYTES]++; |
|||
break; |
|||
|
|||
case ' ': |
|||
count[BYTES]++; |
|||
break; |
|||
|
|||
case '\t': |
|||
count[BYTES]++; |
|||
break; |
|||
|
|||
default: |
|||
count[WORDS]++, count[BYTES]++; |
|||
in_word = 1; |
|||
break; |
|||
} |
|||
|
|||
return count; |
|||
} |
|||
|
|||
int main(int argc, char **argv) |
|||
{ |
|||
return 0; |
|||
|
|||
err: |
|||
} |
Loading…
Reference in new issue