pike.git / src / sscanf.c

version» Context lines:

pike.git/src/sscanf.c:2010:    if (flags & SSCANF_FLAG_80_COMPAT) {    /* All integer formats were signed in Pike 8.0. */    push_finished_type(int_type_string);    } else {    push_int_type(0, 0x7fffffff);    }    }    break;       case 'c': -  /* FIXME: Use the width of the input string and format_len. */ +  /* FIXME: Also consider the format_len (eg %4c). */ +  if (!no_assign) { +  struct svalue *s = +  simple_mapping_string_lookup(state, "sscanf_input_character"); +  if (s) { +  if (TYPEOF(*s) == PIKE_T_TYPE) { +  /* Use the width of the input string. */ +  push_finished_type(s->u.type); +  } else { +  push_type(PIKE_T_ZERO); +  } +  break; +  } +  }    /* FALLTHRU */    case 'd':    case 'D':    case 'i':    /* Signed integers. */    if (!no_assign)    push_finished_type(int_type_string);    break;       case '[':
pike.git/src/sscanf.c:2083:    break;    }    ch = INDEX_PCHARP(format, cnt);    }    }    /* FALLTHRU */    case 's':    case 'H':    if (!no_assign) {    struct svalue *s = -  simple_mapping_string_lookup(state, "sscanf_input"); +  simple_mapping_string_lookup(state, "sscanf_input_character"); +  if (s) { +  if (TYPEOF(*s) == PIKE_T_TYPE) { +  /* Use the width of the input string. */ +  push_finished_type(s->u.type); +  s = simple_mapping_string_lookup(state, "sscanf_input_length");    if (s && (TYPEOF(*s) == PIKE_T_TYPE)) { -  /* Use the type of the input string. */ +  /* Use the length of the input string. */    push_finished_type(s->u.type); -  +  push_type(PIKE_T_STRING);    } else { -  +  push_unlimited_array_type(PIKE_T_STRING); +  } +  } else { +  push_finished_type(string0_type_string); +  } +  } else {    push_finished_type(string_type_string);    }    }    break;       case 'F':    case 'f':    if (!no_assign)    push_finished_type(float_type_string);    break;
pike.git/src/sscanf.c:2156:    tmp = Pike_sp[-2].u.type;    if ((tmp->type != PIKE_T_FUNCTION) && (tmp->type != T_MANY)) {    SIMPLE_ARG_TYPE_ERROR("__handle_sscanf_format", 4, "type(function)");    }       state = Pike_sp[-1].u.mapping;       MAKE_CONST_STRING(sscanf_input_string, "sscanf_input");       if (Pike_sp[-5].u.string == sscanf_input_string) { +  /* Save the type of the input string. */    mapping_string_insert(state, sscanf_input_string, Pike_sp-3); -  pop_n_elems(args); +  +  /* Get the type of the characters of the input string. */ +  push_type_value(index_type(Pike_sp[-3].u.type, int_type_string, NULL)); +  push_constant_text("sscanf_input_character"); +  mapping_insert(state, Pike_sp-1, Pike_sp-2); +  +  /* Get the range of lengths for substrings of the input string. */ +  type_stack_mark(); +  tmp = key_type(Pike_sp[-5].u.type, NULL); +  if (tmp) { +  push_finished_type(tmp); +  free_type(tmp); +  push_type(PIKE_T_ZERO); +  push_type(PIKE_T_INT_OP_RANGE); +  push_type_value(pop_unfinished_type()); +  } else {    push_undefined(); -  +  } +  push_constant_text("sscanf_input_length"); +  mapping_insert(state, Pike_sp-1, Pike_sp-2); +  +  pop_n_elems(args + 4); +  push_undefined();    return;    }       if (TYPEOF(Pike_sp[-4]) != PIKE_T_STRING) {    if (TYPEOF(Pike_sp[-4]) == PIKE_T_INT) {    pop_n_elems(args);    push_undefined();    return;    }    SIMPLE_ARG_TYPE_ERROR("__handle_sscanf_format", 2, "string");