Permalink
Browse files

Minor refactoring in main.c

  • Loading branch information...
nickolasburr committed Nov 18, 2018
1 parent 4f9d640 commit 4be887d0661fa7c7ee9a4a67b6a1f358e8156614
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/main.c
@@ -9,7 +9,7 @@
int main (int argc, char **argv) {
int i, n;
int start, end, count;
int sets, index, zindex;
int pairs, index, zindex;
int opt_value, long_opt_index;
size_t len;
ssize_t read;
@@ -72,7 +72,7 @@ int main (int argc, char **argv) {
}
}

sets = 0;
pairs = 0;
ranges = ALLOC(sizeof(*ranges) * n);

for (index = 1; index < argc; index += 1) {
@@ -124,7 +124,7 @@ int main (int argc, char **argv) {
zindex++;
}

ranges[sets++] = rng;
ranges[pairs++] = rng;
}

break;
@@ -153,7 +153,7 @@ int main (int argc, char **argv) {
count = 1;

while ((read = getline(&line, &len, stream)) != -1) {
for (index = 0; index < sets; index += 1) {
for (index = 0; index < pairs; index += 1) {
if (count >= ranges[index]->start && (count <= ranges[index]->end || !ranges[index]->end)) {
fwrite(line, read, 1, stdout);
}
@@ -165,7 +165,7 @@ int main (int argc, char **argv) {
/**
* Run clean-up tasks.
*/
for (index = 0; index < sets; index += 1) {
for (index = 0; index < pairs; index += 1) {
FREE(ranges[index]);
}

@@ -177,7 +177,7 @@ int main (int argc, char **argv) {
/**
* Run clean-up tasks.
*/
for (index = 0; index < sets; index += 1) {
for (index = 0; index < pairs; index += 1) {
FREE(ranges[index]);
}

0 comments on commit 4be887d

Please sign in to comment.