I was looking at the source code for nmap that was released in 1997 and I noticed this section of code that looks a little odd to me:
int i=0, j=0,start,end;
char *expr = strdup(origexpr);
ports = safe_malloc(65536 * sizeof(short));
i++; /* <<<<<< */
i--; /* <<<<<< */
for(;j < exlen; j++)
if (expr[j] != ' ') expr[i++] = expr[j];
expr[i] = '\0';
Why would you have i++;
and then i--;
right after each other? i
is 0
, then i++
turns i
to 1
. After that, i--
turns i
to 0
.
Link to original source code. Search for:
i++;
i--;
Can anyone explain what this is for?
-O
it does indeed optimize out those statements. – Crocoite