/wc.c (d3316c60317a88cbe4f9c4230cec56022348dca6) (1444 bytes) (mode 100644) (type blob)
#include <stdio.h>
void wcout(char *wd, int lines, int words, int bytes, char name[])
{
while (*wd) switch(*wd++) {
case 'l':
printf("%7i", lines);
break;
case 'w':
printf("%7i", words);
break;
case 'c':
printf("%8i", bytes);
break;
}
printf("%12s\n", name);
}
int main(int argc, char *argv[])
{
int character;
int linec=0, wordc=0, bytec=0, iter = 1;
int tlinec=0, twordc=0, tbytec=0;
unsigned int spaceflag, lineflag, tabflag;
char *wd = "lwc";
FILE *filep = stdin;
if (argc > 1 && argv[1][0]=='-') {
wd = ++argv[1];
argc--;
argv++;
}
do {
lineflag=1;
if (argc > 1 && (filep = fopen(argv[iter], "r"))==NULL) {
fprintf(stderr, "wc: unable to open %s\n", argv[iter]);
continue;
}
while ((character = fgetc(filep)) != EOF) {
bytec++;
if (character>='A' && character<='z' && (spaceflag==1||lineflag==1||tabflag==1)) {
wordc++;
spaceflag=0;
lineflag=0;
tabflag=0;
}
switch(character) {
case '\n': linec++;
lineflag=1;
break;
case ' ': spaceflag=1;
break;
case '\t': tabflag=1;
break;
}
} fclose(filep);
if (argc > 2) {
tlinec += linec;
twordc += wordc;
tbytec += bytec;
}
if (argc > 1)
wcout(wd, linec, wordc, bytec, argv[iter]);
else
wcout(wd, linec, wordc, bytec, "");
linec = 0;
wordc = 0;
bytec = 0;
} while (++iter<argc);
if (argc > 2)
wcout(wd, tlinec, twordc, tbytec, "total");
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
1488 |
4f3466dbd6e7f10f771ec95842644cf40bb1cdda |
COPYING |
100755 |
blob |
730 |
d96251c8e9f070bdf36552db47a2c7518065f56c |
INSTALL |
100644 |
blob |
1224 |
cc37ebb68b792ee29b9f99111c7ee88e5ffa7723 |
README |
100644 |
blob |
3482 |
5834d6d134f4e7557193d4b4b53eceedd05f8d59 |
clp.c |
100644 |
blob |
142 |
66ddd77911db11fab37139f10ccace21a21ea7e8 |
echo.c |
100644 |
blob |
404 |
b285e6453e6bf738ef8cc2ce7df9564695d1a612 |
nl.l |
100644 |
blob |
1278 |
5d13cc09ac4024170ba3ca102c657f10e2d0fac5 |
sc.c |
100644 |
blob |
341 |
0a5de084da1b736602af29a9175341ac9322ffcd |
spng.c |
100644 |
blob |
513 |
1ad1125d57e0a255ed9218defa5b14d9c7962b0a |
tee.c |
100644 |
blob |
1444 |
d3316c60317a88cbe4f9c4230cec56022348dca6 |
wc.c |
100644 |
blob |
130 |
17ddde74c448540143c760e7cacd359c3d6ca85e |
yes.c |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/spicylord/clutils
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/spicylord/clutils
Clone this repository using git:
git clone git://git.rocketgit.com/user/spicylord/clutils
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main