diff options
author | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-07-14 16:56:33 +0200 |
---|---|---|
committer | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-07-14 16:56:33 +0200 |
commit | 6bf915fc6513257a6703240ae43dee20a39e8969 (patch) | |
tree | 302c99c4f6cefc0abf77b456b4b4255fa405458c | |
parent | 64ee4628e219ef3653d3555b94ba091d12e7bb39 (diff) |
some comments
-rw-r--r-- | src/omd.c | 1 | ||||
-rw-r--r-- | src/toilet.c | 3 |
2 files changed, 3 insertions, 1 deletions
@@ -38,6 +38,7 @@ static char** parse_options(int argc, char **argv) { } static void reverse_in_place(char *buf, size_t len) { + // TODO: kijk of dit sneller kan met SIMD for (size_t i = 0, j = len - 1; i < len / 2; i++, j--) { char c = buf[i]; buf[i] = buf[j]; diff --git a/src/toilet.c b/src/toilet.c index 24b19a4..fb011fa 100644 --- a/src/toilet.c +++ b/src/toilet.c @@ -73,6 +73,7 @@ size_t get_count(enum MODE mode, struct map *map) { size_t words = 0; assert(map->sb.st_size >= 0); + // (c) Tom Forging for (size_t i = 0; i < (size_t)map->sb.st_size;) { size_t previ = i; while (!isspace(map->addr[i])) i++; @@ -91,6 +92,7 @@ size_t get_count(enum MODE mode, struct map *map) { map->addr++; } + // handle case if file does not have trailing newline if (*(map->addr - 1) != '\n') { lines++; } @@ -104,7 +106,6 @@ int entry_toilet(int argc, char **argv) { enum MODE mode; char **args = parse_options(argc, argv, &mode); - while (*args != NULL) { struct map *map = open_map(*args); if (map == NULL) { |