Hello everyone,
here is my code:
void get_comp_regex(regex_t *reg, size_t nreg, char *argv[]){
7 int i = 1;
8 int rc = 0;
9
10 // check if the -o flag was given
11 if (!strncmp(argv[1], “-o”,2)){
12
13 // or
14 debug(“nreg: %li”,nreg);
15 for (i = 2; i <= nreg; i++){
16 rc = regcomp(®[i-1],argv[i],0);
17 if (rc == 0) {debug(“rc == 0”);}
18 check(rc == 0, “Compilation of regex failed.”);
19 }
20
21 }else{
22 // and
23 }
24
25 error: {printf(“error label\n”); exit(1);}
26 }
27
28
29
30 int main(int argc, char *argv[]){
31
32 regex_t regex[argc-1];
33 size_t nreg = argc-1;
34
35 get_comp_regex(regex,nreg,argv);
36
37 return 0;
}
I run: ./ex26 -o hello
OUTPUT:
DEBUG ex26.c:14: nreg: 2
DEBUG ex26.c:17: rc == 0
error label
if I comment out the check in line 18 I get the “warning: label ‘error’ defined but not used” but the label executes also and I get the same output.
It should not execute in both cases, right? In the first case the check is true so it should not jump, in the second there is no jump statment.
All help is very much appreciated! Thank you!