diff options
author | Stefan Schmidt <stefan@datenfreihafen.org> | 2012-06-26 09:08:54 +0000 |
---|---|---|
committer | Stefan Schmidt <stefan@datenfreihafen.org> | 2012-06-26 09:08:54 +0000 |
commit | 76070c522ce247952ffd59bc6b8bbc4bd72b873f (patch) | |
tree | d1cdd8dcb72c34bd9fcb8eff9c35c4c788112acf /legacy/embryo | |
parent | d8a9a480ee199ab6cfc34ca3f04ec60967169cb8 (diff) |
embryo: Avoid shadowing of the global index variable
SVN revision: 72865
Diffstat (limited to 'legacy/embryo')
-rw-r--r-- | legacy/embryo/src/bin/embryo_cc_sc1.c | 48 | ||||
-rw-r--r-- | legacy/embryo/src/bin/embryo_cc_sc2.c | 8 | ||||
-rw-r--r-- | legacy/embryo/src/lib/embryo_amx.c | 22 |
3 files changed, 39 insertions, 39 deletions
diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index 180679678e..371a1c930d 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c | |||
@@ -3010,7 +3010,7 @@ destructsymbols(symbol * root, int level) | |||
3010 | 3010 | ||
3011 | static constvalue * | 3011 | static constvalue * |
3012 | insert_constval(constvalue * prev, constvalue * next, char *name, | 3012 | insert_constval(constvalue * prev, constvalue * next, char *name, |
3013 | cell val, short index) | 3013 | cell val, short idx) |
3014 | { | 3014 | { |
3015 | constvalue *cur; | 3015 | constvalue *cur; |
3016 | 3016 | ||
@@ -3019,14 +3019,14 @@ insert_constval(constvalue * prev, constvalue * next, char *name, | |||
3019 | memset(cur, 0, sizeof(constvalue)); | 3019 | memset(cur, 0, sizeof(constvalue)); |
3020 | strcpy(cur->name, name); | 3020 | strcpy(cur->name, name); |
3021 | cur->value = val; | 3021 | cur->value = val; |
3022 | cur->index = index; | 3022 | cur->index = idx; |
3023 | cur->next = next; | 3023 | cur->next = next; |
3024 | prev->next = cur; | 3024 | prev->next = cur; |
3025 | return cur; | 3025 | return cur; |
3026 | } | 3026 | } |
3027 | 3027 | ||
3028 | constvalue * | 3028 | constvalue * |
3029 | append_constval(constvalue * table, char *name, cell val, short index) | 3029 | append_constval(constvalue * table, char *name, cell val, short idx) |
3030 | { | 3030 | { |
3031 | constvalue *cur, *prev; | 3031 | constvalue *cur, *prev; |
3032 | 3032 | ||
@@ -3034,17 +3034,17 @@ append_constval(constvalue * table, char *name, cell val, short index) | |||
3034 | for (prev = table, cur = table->next; cur; | 3034 | for (prev = table, cur = table->next; cur; |
3035 | prev = cur, cur = cur->next) | 3035 | prev = cur, cur = cur->next) |
3036 | /* nothing */ ; | 3036 | /* nothing */ ; |
3037 | return insert_constval(prev, NULL, name, val, index); | 3037 | return insert_constval(prev, NULL, name, val, idx); |
3038 | } | 3038 | } |
3039 | 3039 | ||
3040 | constvalue * | 3040 | constvalue * |
3041 | find_constval(constvalue * table, char *name, short index) | 3041 | find_constval(constvalue * table, char *name, short idx) |
3042 | { | 3042 | { |
3043 | constvalue *ptr = table->next; | 3043 | constvalue *ptr = table->next; |
3044 | 3044 | ||
3045 | while (ptr) | 3045 | while (ptr) |
3046 | { | 3046 | { |
3047 | if (strcmp(name, ptr->name) == 0 && ptr->index == index) | 3047 | if (strcmp(name, ptr->name) == 0 && ptr->index == idx) |
3048 | return ptr; | 3048 | return ptr; |
3049 | ptr = ptr->next; | 3049 | ptr = ptr->next; |
3050 | } /* while */ | 3050 | } /* while */ |
@@ -3326,7 +3326,7 @@ static void | |||
3326 | doexpr(int comma, int chkeffect, int allowarray, int mark_endexpr, | 3326 | doexpr(int comma, int chkeffect, int allowarray, int mark_endexpr, |
3327 | int *tag, int chkfuncresult) | 3327 | int *tag, int chkfuncresult) |
3328 | { | 3328 | { |
3329 | int constant, index, ident; | 3329 | int constant, idx, ident; |
3330 | int localstaging = FALSE; | 3330 | int localstaging = FALSE; |
3331 | cell val; | 3331 | cell val; |
3332 | 3332 | ||
@@ -3336,12 +3336,12 @@ doexpr(int comma, int chkeffect, int allowarray, int mark_endexpr, | |||
3336 | localstaging = TRUE; | 3336 | localstaging = TRUE; |
3337 | assert(stgidx == 0); | 3337 | assert(stgidx == 0); |
3338 | } /* if */ | 3338 | } /* if */ |
3339 | index = stgidx; | 3339 | idx = stgidx; |
3340 | errorset(sEXPRMARK); | 3340 | errorset(sEXPRMARK); |
3341 | do | 3341 | do |
3342 | { | 3342 | { |
3343 | /* on second round through, mark the end of the previous expression */ | 3343 | /* on second round through, mark the end of the previous expression */ |
3344 | if (index != stgidx) | 3344 | if (idx != stgidx) |
3345 | endexpr(TRUE); | 3345 | endexpr(TRUE); |
3346 | sideeffect = FALSE; | 3346 | sideeffect = FALSE; |
3347 | ident = expression(&constant, &val, tag, chkfuncresult); | 3347 | ident = expression(&constant, &val, tag, chkfuncresult); |
@@ -3356,7 +3356,7 @@ doexpr(int comma, int chkeffect, int allowarray, int mark_endexpr, | |||
3356 | errorset(sEXPRRELEASE); | 3356 | errorset(sEXPRRELEASE); |
3357 | if (localstaging) | 3357 | if (localstaging) |
3358 | { | 3358 | { |
3359 | stgout(index); | 3359 | stgout(idx); |
3360 | stgset(FALSE); /* stop staging */ | 3360 | stgset(FALSE); /* stop staging */ |
3361 | } /* if */ | 3361 | } /* if */ |
3362 | } | 3362 | } |
@@ -3366,14 +3366,14 @@ doexpr(int comma, int chkeffect, int allowarray, int mark_endexpr, | |||
3366 | int | 3366 | int |
3367 | constexpr(cell * val, int *tag) | 3367 | constexpr(cell * val, int *tag) |
3368 | { | 3368 | { |
3369 | int constant, index; | 3369 | int constant, idx; |
3370 | cell cidx; | 3370 | cell cidx; |
3371 | 3371 | ||
3372 | stgset(TRUE); /* start stage-buffering */ | 3372 | stgset(TRUE); /* start stage-buffering */ |
3373 | stgget(&index, &cidx); /* mark position in code generator */ | 3373 | stgget(&idx, &cidx); /* mark position in code generator */ |
3374 | errorset(sEXPRMARK); | 3374 | errorset(sEXPRMARK); |
3375 | expression(&constant, val, tag, FALSE); | 3375 | expression(&constant, val, tag, FALSE); |
3376 | stgdel(index, cidx); /* scratch generated code */ | 3376 | stgdel(idx, cidx); /* scratch generated code */ |
3377 | stgset(FALSE); /* stop stage-buffering */ | 3377 | stgset(FALSE); /* stop stage-buffering */ |
3378 | if (constant == 0) | 3378 | if (constant == 0) |
3379 | error(8); /* must be constant expression */ | 3379 | error(8); /* must be constant expression */ |
@@ -3395,7 +3395,7 @@ constexpr(cell * val, int *tag) | |||
3395 | static void | 3395 | static void |
3396 | test(int label, int parens, int invert) | 3396 | test(int label, int parens, int invert) |
3397 | { | 3397 | { |
3398 | int index, tok; | 3398 | int idx, tok; |
3399 | cell cidx; | 3399 | cell cidx; |
3400 | value lval = { NULL, 0, 0, 0, 0, NULL }; | 3400 | value lval = { NULL, 0, 0, 0, 0, NULL }; |
3401 | int localstaging = FALSE; | 3401 | int localstaging = FALSE; |
@@ -3405,9 +3405,9 @@ test(int label, int parens, int invert) | |||
3405 | stgset(TRUE); /* start staging */ | 3405 | stgset(TRUE); /* start staging */ |
3406 | localstaging = TRUE; | 3406 | localstaging = TRUE; |
3407 | #if !defined NDEBUG | 3407 | #if !defined NDEBUG |
3408 | stgget(&index, &cidx); /* should start at zero if started | 3408 | stgget(&idx, &cidx); /* should start at zero if started |
3409 | * locally */ | 3409 | * locally */ |
3410 | assert(index == 0); | 3410 | assert(idx == 0); |
3411 | #endif | 3411 | #endif |
3412 | } /* if */ | 3412 | } /* if */ |
3413 | 3413 | ||
@@ -3417,7 +3417,7 @@ test(int label, int parens, int invert) | |||
3417 | needtoken('('); | 3417 | needtoken('('); |
3418 | do | 3418 | do |
3419 | { | 3419 | { |
3420 | stgget(&index, &cidx); /* mark position (of last expression) in | 3420 | stgget(&idx, &cidx); /* mark position (of last expression) in |
3421 | * code generator */ | 3421 | * code generator */ |
3422 | if (hier14(&lval)) | 3422 | if (hier14(&lval)) |
3423 | rvalue(&lval); | 3423 | rvalue(&lval); |
@@ -3437,7 +3437,7 @@ test(int label, int parens, int invert) | |||
3437 | if (lval.ident == iCONSTEXPR) | 3437 | if (lval.ident == iCONSTEXPR) |
3438 | { /* constant expression */ | 3438 | { /* constant expression */ |
3439 | intest = (int)(long)popstk(); /* restore stack */ | 3439 | intest = (int)(long)popstk(); /* restore stack */ |
3440 | stgdel(index, cidx); | 3440 | stgdel(idx, cidx); |
3441 | if (lval.constval) | 3441 | if (lval.constval) |
3442 | { /* code always executed */ | 3442 | { /* code always executed */ |
3443 | error(206); /* redundant test: always non-zero */ | 3443 | error(206); /* redundant test: always non-zero */ |
@@ -3549,7 +3549,7 @@ dofor(void) | |||
3549 | { | 3549 | { |
3550 | int wq[wqSIZE], skiplab; | 3550 | int wq[wqSIZE], skiplab; |
3551 | cell save_decl; | 3551 | cell save_decl; |
3552 | int save_nestlevel, index; | 3552 | int save_nestlevel, idx; |
3553 | int *ptr; | 3553 | int *ptr; |
3554 | 3554 | ||
3555 | save_decl = declared; | 3555 | save_decl = declared; |
@@ -3595,7 +3595,7 @@ dofor(void) | |||
3595 | assert(!staging); | 3595 | assert(!staging); |
3596 | stgset(TRUE); /* start staging */ | 3596 | stgset(TRUE); /* start staging */ |
3597 | assert(stgidx == 0); | 3597 | assert(stgidx == 0); |
3598 | index = stgidx; | 3598 | idx = stgidx; |
3599 | stgmark(sSTARTREORDER); | 3599 | stgmark(sSTARTREORDER); |
3600 | stgmark((char)(sEXPRSTART + 0)); /* mark start of 2nd expression | 3600 | stgmark((char)(sEXPRSTART + 0)); /* mark start of 2nd expression |
3601 | * in stage */ | 3601 | * in stage */ |
@@ -3614,7 +3614,7 @@ dofor(void) | |||
3614 | needtoken(')'); | 3614 | needtoken(')'); |
3615 | } /* if */ | 3615 | } /* if */ |
3616 | stgmark(sENDREORDER); /* mark end of reversed evaluation */ | 3616 | stgmark(sENDREORDER); /* mark end of reversed evaluation */ |
3617 | stgout(index); | 3617 | stgout(idx); |
3618 | stgset(FALSE); /* stop staging */ | 3618 | stgset(FALSE); /* stop staging */ |
3619 | statement(NULL, FALSE); | 3619 | statement(NULL, FALSE); |
3620 | jumplabel(wq[wqLOOP]); | 3620 | jumplabel(wq[wqLOOP]); |
@@ -3807,7 +3807,7 @@ doswitch(void) | |||
3807 | static void | 3807 | static void |
3808 | doassert(void) | 3808 | doassert(void) |
3809 | { | 3809 | { |
3810 | int flab1, index; | 3810 | int flab1, idx; |
3811 | cell cidx; | 3811 | cell cidx; |
3812 | value lval = { NULL, 0, 0, 0, 0, NULL }; | 3812 | value lval = { NULL, 0, 0, 0, 0, NULL }; |
3813 | 3813 | ||
@@ -3824,12 +3824,12 @@ doassert(void) | |||
3824 | else | 3824 | else |
3825 | { | 3825 | { |
3826 | stgset(TRUE); /* start staging */ | 3826 | stgset(TRUE); /* start staging */ |
3827 | stgget(&index, &cidx); /* mark position in code generator */ | 3827 | stgget(&idx, &cidx); /* mark position in code generator */ |
3828 | do | 3828 | do |
3829 | { | 3829 | { |
3830 | if (hier14(&lval)) | 3830 | if (hier14(&lval)) |
3831 | rvalue(&lval); | 3831 | rvalue(&lval); |
3832 | stgdel(index, cidx); /* just scrap the code */ | 3832 | stgdel(idx, cidx); /* just scrap the code */ |
3833 | } | 3833 | } |
3834 | while (matchtoken(',')); | 3834 | while (matchtoken(',')); |
3835 | stgset(FALSE); /* stop staging */ | 3835 | stgset(FALSE); /* stop staging */ |
diff --git a/legacy/embryo/src/bin/embryo_cc_sc2.c b/legacy/embryo/src/bin/embryo_cc_sc2.c index c1094d61fe..04cb537128 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc2.c +++ b/legacy/embryo/src/bin/embryo_cc_sc2.c | |||
@@ -721,7 +721,7 @@ static int | |||
721 | preproc_expr(cell * val, int *tag) | 721 | preproc_expr(cell * val, int *tag) |
722 | { | 722 | { |
723 | int result; | 723 | int result; |
724 | int index; | 724 | int idx; |
725 | cell code_index; | 725 | cell code_index; |
726 | char *term; | 726 | char *term; |
727 | 727 | ||
@@ -730,7 +730,7 @@ preproc_expr(cell * val, int *tag) | |||
730 | * compilations. Reset the staging index, but keep the code | 730 | * compilations. Reset the staging index, but keep the code |
731 | * index. | 731 | * index. |
732 | */ | 732 | */ |
733 | if (stgget(&index, &code_index)) | 733 | if (stgget(&idx, &code_index)) |
734 | { | 734 | { |
735 | error(57); /* unfinished expression */ | 735 | error(57); /* unfinished expression */ |
736 | stgdel(0, code_index); | 736 | stgdel(0, code_index); |
@@ -819,7 +819,7 @@ command(void) | |||
819 | int tok, ret; | 819 | int tok, ret; |
820 | cell val; | 820 | cell val; |
821 | char *str; | 821 | char *str; |
822 | int index; | 822 | int idx; |
823 | cell code_index; | 823 | cell code_index; |
824 | 824 | ||
825 | while (*lptr <= ' ' && *lptr != '\0') | 825 | while (*lptr <= ' ' && *lptr != '\0') |
@@ -834,7 +834,7 @@ command(void) | |||
834 | /* on a pending expression, force to return a silent ';' token and force to | 834 | /* on a pending expression, force to return a silent ';' token and force to |
835 | * re-read the line | 835 | * re-read the line |
836 | */ | 836 | */ |
837 | if (!sc_needsemicolon && stgget(&index, &code_index)) | 837 | if (!sc_needsemicolon && stgget(&idx, &code_index)) |
838 | { | 838 | { |
839 | lptr = term_expr; | 839 | lptr = term_expr; |
840 | return CMD_TERM; | 840 | return CMD_TERM; |
diff --git a/legacy/embryo/src/lib/embryo_amx.c b/legacy/embryo/src/lib/embryo_amx.c index 689e5e42f4..55423b443b 100644 --- a/legacy/embryo/src/lib/embryo_amx.c +++ b/legacy/embryo/src/lib/embryo_amx.c | |||
@@ -43,9 +43,9 @@ | |||
43 | static void _embryo_byte_swap_16 (unsigned short *v); | 43 | static void _embryo_byte_swap_16 (unsigned short *v); |
44 | static void _embryo_byte_swap_32 (unsigned int *v); | 44 | static void _embryo_byte_swap_32 (unsigned int *v); |
45 | #endif | 45 | #endif |
46 | static int _embryo_native_call (Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params); | 46 | static int _embryo_native_call (Embryo_Program *ep, Embryo_Cell idx, Embryo_Cell *result, Embryo_Cell *params); |
47 | static int _embryo_func_get (Embryo_Program *ep, int index, char *funcname); | 47 | static int _embryo_func_get (Embryo_Program *ep, int idx, char *funcname); |
48 | static int _embryo_var_get (Embryo_Program *ep, int index, char *varname, Embryo_Cell *ep_addr); | 48 | static int _embryo_var_get (Embryo_Program *ep, int idx, char *varname, Embryo_Cell *ep_addr); |
49 | static int _embryo_program_init (Embryo_Program *ep, void *code); | 49 | static int _embryo_program_init (Embryo_Program *ep, void *code); |
50 | 50 | ||
51 | #ifdef WORDS_BIGENDIAN | 51 | #ifdef WORDS_BIGENDIAN |
@@ -70,14 +70,14 @@ _embryo_byte_swap_32(unsigned int *v) | |||
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | static int | 72 | static int |
73 | _embryo_native_call(Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params) | 73 | _embryo_native_call(Embryo_Program *ep, Embryo_Cell idx, Embryo_Cell *result, Embryo_Cell *params) |
74 | { | 74 | { |
75 | Embryo_Header *hdr; | 75 | Embryo_Header *hdr; |
76 | Embryo_Func_Stub *func_entry; | 76 | Embryo_Func_Stub *func_entry; |
77 | Embryo_Native f; | 77 | Embryo_Native f; |
78 | 78 | ||
79 | hdr = (Embryo_Header *)ep->base; | 79 | hdr = (Embryo_Header *)ep->base; |
80 | func_entry = GETENTRY(hdr, natives, index); | 80 | func_entry = GETENTRY(hdr, natives, idx); |
81 | if ((func_entry->address <= 0) || | 81 | if ((func_entry->address <= 0) || |
82 | (func_entry->address > ep->native_calls_size)) | 82 | (func_entry->address > ep->native_calls_size)) |
83 | { | 83 | { |
@@ -96,32 +96,32 @@ _embryo_native_call(Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, | |||
96 | } | 96 | } |
97 | 97 | ||
98 | static int | 98 | static int |
99 | _embryo_func_get(Embryo_Program *ep, int index, char *funcname) | 99 | _embryo_func_get(Embryo_Program *ep, int idx, char *funcname) |
100 | { | 100 | { |
101 | Embryo_Header *hdr; | 101 | Embryo_Header *hdr; |
102 | Embryo_Func_Stub *func; | 102 | Embryo_Func_Stub *func; |
103 | 103 | ||
104 | hdr = (Embryo_Header *)ep->code; | 104 | hdr = (Embryo_Header *)ep->code; |
105 | if (index >= (Embryo_Cell)NUMENTRIES(hdr, publics, natives)) | 105 | if (idx >= (Embryo_Cell)NUMENTRIES(hdr, publics, natives)) |
106 | return EMBRYO_ERROR_INDEX; | 106 | return EMBRYO_ERROR_INDEX; |
107 | 107 | ||
108 | func = GETENTRY(hdr, publics, index); | 108 | func = GETENTRY(hdr, publics, idx); |
109 | strcpy(funcname, GETENTRYNAME(hdr, func)); | 109 | strcpy(funcname, GETENTRYNAME(hdr, func)); |
110 | return EMBRYO_ERROR_NONE; | 110 | return EMBRYO_ERROR_NONE; |
111 | } | 111 | } |
112 | 112 | ||
113 | static int | 113 | static int |
114 | _embryo_var_get(Embryo_Program *ep, int index, char *varname, Embryo_Cell *ep_addr) | 114 | _embryo_var_get(Embryo_Program *ep, int idx, char *varname, Embryo_Cell *ep_addr) |
115 | { | 115 | { |
116 | 116 | ||
117 | Embryo_Header *hdr; | 117 | Embryo_Header *hdr; |
118 | Embryo_Func_Stub *var; | 118 | Embryo_Func_Stub *var; |
119 | 119 | ||
120 | hdr=(Embryo_Header *)ep->base; | 120 | hdr=(Embryo_Header *)ep->base; |
121 | if (index >= (Embryo_Cell)NUMENTRIES(hdr, pubvars, tags)) | 121 | if (idx >= (Embryo_Cell)NUMENTRIES(hdr, pubvars, tags)) |
122 | return EMBRYO_ERROR_INDEX; | 122 | return EMBRYO_ERROR_INDEX; |
123 | 123 | ||
124 | var = GETENTRY(hdr, pubvars, index); | 124 | var = GETENTRY(hdr, pubvars, idx); |
125 | strcpy(varname, GETENTRYNAME(hdr, var)); | 125 | strcpy(varname, GETENTRYNAME(hdr, var)); |
126 | *ep_addr = var->address; | 126 | *ep_addr = var->address; |
127 | return EMBRYO_ERROR_NONE; | 127 | return EMBRYO_ERROR_NONE; |