Browse Source

ternary fcn in numparam bugfix 2936702

pre-master-46
h_vogt 16 years ago
parent
commit
2fe85974ce
  1. 3
      ChangeLog
  2. 26
      src/frontend/inpcom.c

3
ChangeLog

@ -1,3 +1,6 @@
2010-05-21 Holger Vogt
* inpcom.c: bugfix 2936702 correct handling of ternary fcn in numparam
2010-05-15 Holger Vogt
* inpcom.c: exclude comment lines from stripping EOL comments,
make ngspice abort if .inc <file> fails.

26
src/frontend/inpcom.c

@ -892,19 +892,8 @@ inp_fix_ternary_operator_str( char *line )
paren_ptr = strstr( str_ptr, "(" );
if ( paren_ptr != NULL && paren_ptr < question ) {
str_ptr = question;
while ( *str_ptr != '(' ) str_ptr--;
*str_ptr = '\0';
beg_str = strdup(line);
*str_ptr = '(';
str_ptr++;
paren_ptr = NULL;
}
else {
keep = *str_ptr; *str_ptr = '\0';
beg_str = strdup(line);
*str_ptr = keep;
}
}
else return line; // hvogt
@ -913,12 +902,23 @@ inp_fix_ternary_operator_str( char *line )
str_ptr2--;
while ( isspace(*str_ptr2) ) str_ptr2--;
if ( *str_ptr2 == ')' ) {
while ( *str_ptr != '(' ) str_ptr--;
count = 1;
str_ptr = str_ptr2;
while ( (count != 0) && (str_ptr != line) ){
str_ptr--;
if ( *str_ptr == '(' ) count--;
if ( *str_ptr == ')' ) count++;
}
}
str_ptr2++; keep = *str_ptr2; *str_ptr2 = '\0';
conditional = strdup(str_ptr);
*str_ptr2 = keep;
// get beginning (whatever is left before the conditional)
keep = *str_ptr; *str_ptr = '\0';
beg_str = strdup(line);
*str_ptr = keep;
// get if
str_ptr = question + 1;
while ( isspace(*str_ptr) ) str_ptr++;
@ -941,6 +941,8 @@ inp_fix_ternary_operator_str( char *line )
fprintf(stderr,"ERROR: problem parsing ternary string (finding ':') %s!\n", line);
controlled_exit(EXIT_FAILURE);
}
str_ptr2 = colon - 1;
while ( isspace(*str_ptr2) ) str_ptr2--;
}
else if ( ( colon = strstr( str_ptr, ":" ) ) ) {
str_ptr2 = colon - 1;

Loading…
Cancel
Save