diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-05-19 06:19:27 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-05-19 06:19:27 +0000 |
| commit | e5831d197bd2a0cf0cecd1a6e9de63a68b75bc32 (patch) | |
| tree | 55efc6bb274a6e350ae312c795fb44ea954695d3 /src/libstddjb/gol.c | |
| parent | b708eef95c98ba9215f5eef2c2911e4f87ebc7a5 (diff) | |
| download | skalibs-e5831d197bd2a0cf0cecd1a6e9de63a68b75bc32.tar.gz | |
gol fixes and improvements
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/gol.c')
| -rw-r--r-- | src/libstddjb/gol.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstddjb/gol.c b/src/libstddjb/gol.c index bc1f7b9..c608ed4 100644 --- a/src/libstddjb/gol.c +++ b/src/libstddjb/gol.c @@ -18,8 +18,9 @@ int gol (char const *const *argv, unsigned int argc, gol_bool const *b, unsigned if (x) { size_t len = x - argv[i] - 2 ; + if (!len) return (*problem = 0, -1-i) ; for (; j < an ; j++) if (!strncmp(argv[i] + 2, a[j].lo, len) && !a[j].lo[len]) break ; - if (j >= an) return (*problem = -1, -1-i) ; + if (j >= an) return (*problem = -len-2, -1-i) ; ar[a[j].i] = x + 1 ; } else @@ -32,7 +33,7 @@ int gol (char const *const *argv, unsigned int argc, gol_bool const *b, unsigned else { char const *p = argv[i] + 1 ; - for (; !*p ; p++) + for (; *p ; p++) { unsigned int j = 0 ; for (; j < an ; j++) if (*p == a[j].so) break ; |
