]> granicus.if.org Git - sysstat/commitdiff
Fix alg used to find pair of matching items
authorSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 28 Dec 2017 20:33:17 +0000 (21:33 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 28 Dec 2017 20:33:17 +0000 (21:33 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
json_stats.c
pr_stats.c
raw_stats.c
rndr_stats.c
sa_common.c
svg_stats.c
xml_stats.c

index 0df37804eb1cf041d7be3b7de608721cfb704dd0..01f9a7cd72973407a7df3f954bf5d84f72f075f8 100644 (file)
@@ -644,29 +644,32 @@ __print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab,
 
        for (i = 0; i < a->nr[curr]; i++) {
 
-               ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+               found = FALSE;
 
-               /* Look for corresponding serial line in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
+               if (a->nr[!curr] > 0) {
+                       ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding serial line in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (ssc->line == ssp->line) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (ssc->line == ssp->line) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
@@ -2233,29 +2236,33 @@ __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab,
        xprintf(tab++, "\"fchosts\": [");
 
        for (i = 0; i < a->nr[curr]; i++) {
-               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-               /* Look for corresponding structure in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
-
-               j0 = j;
                found = FALSE;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+               if (a->nr[!curr] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
+
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
index e419af6358a4826aa74d857dcc09133b0047b022..8071bf79131db978e81b34927910ced95523f249 100644 (file)
@@ -956,29 +956,32 @@ __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
 
        for (i = 0; i < a->nr[curr]; i++) {
 
-               ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
+               found = FALSE;
 
-               /* Look for corresponding serial line in previous iteration */
-               j = i;
-               if (j > a->nr[prev]) {
-                       j = a->nr[prev];
-               }
+               if (a->nr[prev] > 0) {
+                       ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding serial line in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[prev]) {
-                               j = 0;
+                       if (j >= a->nr[prev]) {
+                               j = a->nr[prev] - 1;
                        }
-                       ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
-                       if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
+                               if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[prev]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
@@ -2782,29 +2785,33 @@ __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
 
        for (i = 0; i < a->nr[curr]; i++) {
 
-               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+               found = FALSE;
 
-               /* Look for corresponding structure in previous iteration */
-               j = i;
-               if (j > a->nr[prev]) {
-                       j = a->nr[prev];
-               }
+               if (a->nr[prev] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[prev]) {
-                               j = 0;
+                       if (j >= a->nr[prev]) {
+                               j = a->nr[prev] - 1;
                        }
-                       sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
-                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+
+                               if (++j >= a->nr[prev]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
index a560fc2f0bc2ae2abdeff7ab99ef1cf3a9135971..ce7fe494ceecdba1c50e440714aab3f398fb8b33 100644 (file)
@@ -466,29 +466,32 @@ __print_funct_t raw_print_serial_stats(struct activity *a, char *timestr, int cu
 
        for (i = 0; i < a->nr[curr]; i++) {
 
+               found = FALSE;
                ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
 
-               /* Look for corresponding serial line in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
+               if (a->nr[!curr] > 0) {
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding serial line in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (ssc->line == ssp->line) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (ssc->line == ssp->line) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                printf("%s %s: %u", timestr, pfield(a->hdr_line, FIRST), ssc->line);
 
@@ -1564,29 +1567,33 @@ __print_funct_t raw_print_fchost_stats(struct activity *a, char *timestr, int cu
        }
 
        for (i = 0; i < a->nr[curr]; i++) {
-               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-               /* Look for corresponding structure in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
-
-               j0 = j;
                found = FALSE;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+               if (a->nr[!curr] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
+
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
index da2bbb82c27baeaa513973f8fc62af137ed39330..a86ff6a20afb60f1dcc195011c5a1270c054a099 100644 (file)
@@ -974,29 +974,32 @@ __print_funct_t render_serial_stats(struct activity *a, int isdb, char *pre,
 
        for (i = 0; i < a->nr[curr]; i++) {
 
-               ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
+               found = FALSE;
 
-               /* Look for corresponding serial line in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
+               if (a->nr[!curr] > 0) {
+                       ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding serial line in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (ssc->line == ssp->line) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (ssc->line == ssp->line) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
@@ -2975,29 +2978,33 @@ __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre,
        struct stats_fchost *sfcc, *sfcp;
 
        for (i = 0; i < a->nr[curr]; i++) {
-               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-               /* Look for corresponding structure in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
-
-               j0 = j;
                found = FALSE;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+               if (a->nr[!curr] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
+
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
index 4ae504a81286f0a2cc07c73463c9299233376511..b1d8627568e13163971b4e1caab7d34c7f347aa2 100644 (file)
@@ -641,19 +641,23 @@ void print_report_hdr(unsigned int flags, struct tm *rectime,
 int check_net_dev_reg(struct activity *a, int curr, int ref, int pos)
 {
        struct stats_net_dev *sndc, *sndp;
-       int j0, j= pos;
+       int j0, j = pos;
 
-       if (j > a->nr[ref]) {
-               j = a->nr[ref];
+       if (!a->nr[ref])
+               /*
+                * No items found in previous iteration:
+                * Current interface is necessarily new.
+                */
+               return -1;
+
+       if (j >= a->nr[ref]) {
+               j = a->nr[ref] - 1;
        }
        j0 = j;
 
        sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + pos * a->msize);
 
        do {
-               if (j > a->nr[ref]) {
-                       j = 0;
-               }
                sndp = (struct stats_net_dev *) ((char *) a->buf[ref] + j * a->msize);
 
                if (!strcmp(sndc->interface, sndp->interface)) {
@@ -718,7 +722,9 @@ int check_net_dev_reg(struct activity *a, int curr, int ref, int pos)
                        }
                        return j;
                }
-               j++;
+               if (++j >= a->nr[ref]) {
+                       j = 0;
+               }
        }
        while (j != j0);
 
@@ -750,17 +756,21 @@ int check_net_edev_reg(struct activity *a, int curr, int ref, int pos)
        struct stats_net_edev *snedc, *snedp;
        int j0, j = pos;
 
-       if (j > a->nr[ref]) {
-               j = a->nr[ref];
+       if (!a->nr[ref])
+               /*
+                * No items found in previous iteration:
+                * Current interface is necessarily new.
+                */
+               return -1;
+
+       if (j >= a->nr[ref]) {
+               j = a->nr[ref] - 1;
        }
        j0 = j;
 
        snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + pos * a->msize);
 
        do {
-               if (j > a->nr[ref]) {
-                       j = 0;
-               }
                snedp = (struct stats_net_edev *) ((char *) a->buf[ref] + j * a->msize);
 
                if (!strcmp(snedc->interface, snedp->interface)) {
@@ -785,7 +795,9 @@ int check_net_edev_reg(struct activity *a, int curr, int ref, int pos)
 
                        return j;
                }
-               j++;
+               if (++j >= a->nr[ref]) {
+                       j = 0;
+               }
        }
        while (j != j0);
 
@@ -816,17 +828,21 @@ int check_disk_reg(struct activity *a, int curr, int ref, int pos)
        struct stats_disk *sdc, *sdp;
        int j0, j = pos;
 
-       if (j > a->nr[ref]) {
-               j = a->nr[ref];
+       if (!a->nr[ref])
+               /*
+                * No items found in previous iteration:
+                * Current interface is necessarily new.
+                */
+               return -1;
+
+       if (j >= a->nr[ref]) {
+               j = a->nr[ref] - 1;
        }
        j0 = j;
 
        sdc = (struct stats_disk *) ((char *) a->buf[curr] + pos * a->msize);
 
        do {
-               if (j > a->nr[ref]) {
-                       j = 0;
-               }
                sdp = (struct stats_disk *) ((char *) a->buf[ref] + j * a->msize);
 
                if ((sdc->major == sdp->major) &&
@@ -846,7 +862,9 @@ int check_disk_reg(struct activity *a, int curr, int ref, int pos)
 
                        return j;
                }
-               j++;
+               if (++j >= a->nr[ref]) {
+                       j = 0;
+               }
        }
        while (j != j0);
 
index f5abdcf150c665da06155d5d14421a033ddd59aa..b47cee907c5c24c287dca393368239d41531ea85 100644 (file)
@@ -4850,54 +4850,58 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
 
                /* For each FC HBA */
                for (i = 0; i < a->nr[curr]; i++) {
-                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-                       /* Look for corresponding graph */
-                       for (k = 0; k < svg_p->nr_max; k++) {
-                               item_name = *(out + k * 5 + 4);
-                               if (!strcmp(sfcc->fchost_name, item_name))
-                                       /* Graph found! */
-                                       break;
-                       }
-                       if (k == svg_p->nr_max) {
-                               /* Graph not found: Look for first free entry */
+                       found = FALSE;
+
+                       if (a->nr[!curr] > 0) {
+                               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                               /* Look for corresponding graph */
                                for (k = 0; k < svg_p->nr_max; k++) {
                                        item_name = *(out + k * 5 + 4);
-                                       if (!strcmp(item_name, ""))
+                                       if (!strcmp(sfcc->fchost_name, item_name))
+                                               /* Graph found! */
                                                break;
                                }
                                if (k == svg_p->nr_max) {
-                                       /* No free graph entry: Extend all buffers */
-                                       reallocate_all_graph_lines(svg_p->nr_max,
-                                                                  &out, &outsize, &spmin, &spmax);
-                                       svg_p->nr_max *= 2;
+                                       /* Graph not found: Look for first free entry */
+                                       for (k = 0; k < svg_p->nr_max; k++) {
+                                               item_name = *(out + k * 5 + 4);
+                                               if (!strcmp(item_name, ""))
+                                                       break;
+                                       }
+                                       if (k == svg_p->nr_max) {
+                                               /* No free graph entry: Extend all buffers */
+                                               reallocate_all_graph_lines(svg_p->nr_max,
+                                                                          &out, &outsize, &spmin, &spmax);
+                                               svg_p->nr_max *= 2;
+                                       }
                                }
-                       }
 
-                       pos = k * 5;
-                       unregistered = outsize + pos + 4;
+                               pos = k * 5;
+                               unregistered = outsize + pos + 4;
 
-                       /* Look for corresponding structure in previous iteration */
-                       j = i;
-                       if (j > a->nr[!curr]) {
-                               j = a->nr[!curr];
-                       }
-
-                       j0 = j;
-                       found = FALSE;
+                               /* Look for corresponding structure in previous iteration */
+                               j = i;
 
-                       do {
-                               if (j > a->nr[!curr]) {
-                                       j = 0;
+                               if (j >= a->nr[!curr]) {
+                                       j = a->nr[!curr] - 1;
                                }
-                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
-                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                                       found = TRUE;
-                                       break;
+
+                               j0 = j;
+
+                               do {
+                                       sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                               found = TRUE;
+                                               break;
+                                       }
+                                       if (++j >= a->nr[!curr]) {
+                                               j = 0;
+                                       }
                                }
-                               j++;
+                               while (j != j0);
                        }
-                       while (j != j0);
 
                        if (!found)
                                continue;
index b2b9c78b203fb898410b0d0b62e60113bf96bf46..4bd0829617ac5e4a3142ef2d3b6e0334a0cb6d8c 100644 (file)
@@ -636,29 +636,32 @@ __print_funct_t xml_print_serial_stats(struct activity *a, int curr, int tab,
 
        for (i = 0; i < a->nr[curr]; i++) {
 
-               ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
+               found = FALSE;
 
-               /* Look for corresponding serial line in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
+               if (a->nr[!curr] > 0) {
+                       ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
 
-               j0 = j;
-               found = FALSE;
+                       /* Look for corresponding serial line in previous iteration */
+                       j = i;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (ssc->line == ssp->line) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (ssc->line == ssp->line) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;
@@ -2131,29 +2134,33 @@ __print_funct_t xml_print_fchost_stats(struct activity *a, int curr, int tab,
        tab++;
 
        for (i = 0; i < a->nr[curr]; i++) {
-               sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
 
-               /* Look for corresponding structure in previous iteration */
-               j = i;
-               if (j > a->nr[!curr]) {
-                       j = a->nr[!curr];
-               }
-
-               j0 = j;
                found = FALSE;
 
-               do {
-                       if (j > a->nr[!curr]) {
-                               j = 0;
+               if (a->nr[!curr] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
+
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
                        }
-                       sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
-                       if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
-                               found = TRUE;
-                               break;
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
                        }
-                       j++;
+                       while (j != j0);
                }
-               while (j != j0);
 
                if (!found)
                        continue;