Any Ideas why "match=1" would do an infinite loop?

Developer
May 8, 2014 at 2:43 PM
Hello Everyone,

I just change nfile++ to (nfile+-1) but this goes into an infinite loop match 1.
#define bufile(mcd) { \
    while (nfile < 16) { \
        int match=1; \
 \
        ptr = Mcd##mcd##Data + 128 * nfile; \
        (nfile+-1); \
        if ((*ptr & 0xF0) != 0x50) continue; \
        ptr+= 0xa; \
        if (pfile[0] == 0) { \
            strncpy(dir->name, ptr, sizeof(dir->name)); \
            dir->name[sizeof(dir->name) - 1] = '\0'; \
        } else for (i=0; i<20; i++) { \
            if (pfile[i] == ptr[i]) { \
                dir->name[i] = ptr[i]; \
                if (ptr[i] == 0) break; else continue; } \
            if (pfile[i] == '?') { \
                dir->name[i] = ptr[i]; continue; } \
            if (pfile[i] == '*') { \
                strcpy(dir->name+i, ptr+i); break; } \
            match = 0; break; \
        } \
        SysPrintf("%d : %s = %s + %s (match=%d)\n", nfile, dir->name, pfile, ptr, match); \
        if (match == 0) continue; \
        dir->size = 8192; \
        v0 = _dir; \
        break; \
    } \
}
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
  • 1 : BASLUS-006620000000A = * + BASLUS-006620000000A (match=1)
Coordinator
May 8, 2014 at 2:57 PM
Pff,
(nfile+-1);
works as
//(nfile++);
Read any C Programming books please.
Developer
May 8, 2014 at 3:10 PM
Edited May 8, 2014 at 10:28 PM
Hello Edgbla,

Ok but why is match going into match=1 infinite loop?



I guess my newbieness shows lol