commit d716f2936bd00c1b23ff69eada519f157ad3a9cc
parent a74d57d57fcb5b50d93409172f611c20f5e9848a
Author: qorg11 <qorg@vxempire.xyz>
Date: Sat, 26 Dec 2020 03:57:32 +0100
Add todo to wc
Diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/wc.c b/src/wc.c
@@ -5,6 +5,14 @@
#include <errno.h>
#include <string.h>
+/* TODO: fucking make this thing read binary data
+* Possible solutions:
+* fread()
+* fgets()
+* rewrite this entire thing using read() (not a good idea
+* because it's slow as shit)
+*/
+
int show_lines, show_words, show_bytes;
struct wc_values data;
@@ -26,12 +34,16 @@ wc(const char *filename, struct wc_values *data)
return -1;
}
char c;
+ char a;
int newlines, spaces, bytes = 0;
newlines = spaces = bytes = 0;
while((c = fgetc(file)) > 0)
{
+ a = c;
+ if(!isascii(c))
+ a = toascii(c);
bytes++;
- if(c == '\n')
+ if(a == '\n')
newlines++;
if(isspace(c))
spaces++;