aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2012-06-04 21:54:44 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2012-06-04 21:54:44 -0800
commit938f13179d26313f8f92b7eb22ca2617bdeabe49 (patch)
treeefb76a74bfca4085381d4f52af93e763ff497805 /src
parent3cdf151e89a3e8db19211e08adff778e55a44a9d (diff)
downloaddmstools-938f13179d26313f8f92b7eb22ca2617bdeabe49.tar.gz
dmstools-938f13179d26313f8f92b7eb22ca2617bdeabe49.tar.bz2
dmstools-938f13179d26313f8f92b7eb22ca2617bdeabe49.tar.xz
dmstools-938f13179d26313f8f92b7eb22ca2617bdeabe49.zip
Fixing loop of sub matches.
Diffstat (limited to 'src')
-rw-r--r--src/posixregex.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/posixregex.c b/src/posixregex.c
index 97980dd..dae9d4a 100644
--- a/src/posixregex.c
+++ b/src/posixregex.c
@@ -370,16 +370,16 @@ int main(int argc, char * argv[])
370 if (opt.verbosity) 370 if (opt.verbosity)
371 { 371 {
372 // displays submatches 372 // displays submatches
373 for(y = 0; ((y < MAX_MATCHES) && (matches[y].rm_eo > -1)); y++) 373 for(y = 0; ((y < MAX_MATCHES) && (y <= regex.re_nsub)); y++)
374 { 374 {
375 // copies sub matches in buffer string 375 // copies sub matches in buffer string
376 memset(str, 0, (size_t)BUFFER_SIZE); 376 memset(str, 0, (size_t)BUFFER_SIZE);
377 if ((str_len = matches[y].rm_eo - matches[y].rm_so)) 377 if ((str_len = matches[y].rm_eo - matches[y].rm_so) > 0)
378 { 378 {
379 strncpy(str, &arg[matches[y].rm_so], (size_t)str_len); 379 strncpy(str, &arg[matches[y].rm_so], (size_t)str_len);
380 printf(" submatch %u: %s\n", y, str); 380 printf(" submatch %u: %s\n", y, str);
381 } else if (matches[y].rm_eo > 0) { 381 } else {
382 printf(" submatch %u:\n", y); 382 printf(" submatch %u:\n", y);
383 }; 383 };
384 }; 384 };
385 printf("\n"); 385 printf("\n");