本文整理汇总了C++中parse_num函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_num函数的具体用法?C++ parse_num怎么用?C++ parse_num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_num函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parse_line_column
/* Read two ssize_t's, separated by a comma, from str, and store them in
* *line and *column (if they're not both NULL). Return FALSE on error,
* or TRUE otherwise. */
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{
bool retval = TRUE;
const char *comma;
assert(str != NULL);
comma = strchr(str, ',');
if (comma != NULL && column != NULL) {
if (!parse_num(comma + 1, column))
retval = FALSE;
}
if (line != NULL) {
if (comma != NULL) {
char *str_line = mallocstrncpy(NULL, str, comma - str + 1);
str_line[comma - str] = '\0';
if (str_line[0] != '\0' && !parse_num(str_line, line))
retval = FALSE;
free(str_line);
} else if (!parse_num(str, line))
retval = FALSE;
}
return retval;
}
开发者ID:sria91,项目名称:nano,代码行数:32,代码来源:utils.c
示例2: parse_hunk_header
int parse_hunk_header(char *line, int len,
int *ob, int *on,
int *nb, int *nn)
{
char *cp;
cp = line + 4;
if (parse_num(&cp, ob)) {
bad_line:
return error("malformed diff output: %s", line);
}
if (*cp == ',') {
cp++;
if (parse_num(&cp, on))
goto bad_line;
}
else
*on = 1;
if (*cp++ != ' ' || *cp++ != '+')
goto bad_line;
if (parse_num(&cp, nb))
goto bad_line;
if (*cp == ',') {
cp++;
if (parse_num(&cp, nn))
goto bad_line;
}
else
*nn = 1;
return -!!memcmp(cp, " @@", 3);
}
开发者ID:chidveer,项目名称:git,代码行数:30,代码来源:xdiff-interface.c
示例3: uforth_interpret
uforth_stat uforth_interpret(char *str) {
uforth_stat stat;
char *word;
CELL wd_idx;
char immediate = 0;
char primitive = 0;
uforth_iram->inbufptr = str;
while(*(word = uforth_next_word()) != 0) {
wd_idx = find_word(word,uforth_iram->currwordlen,0,&immediate,&primitive);
switch (uforth_iram->compiling) {
case 0: /* interpret mode */
if (wd_idx == 0) { /* number or trash */
DCELL num = parse_num(word,uforth_uram->base);
if (num == 0 && word[0] != '0') {
uforth_abort_request(ABORT_NAW);
uforth_abort();
return E_NOT_A_WORD;
}
if (abs32(num) > (int32_t)MAX_CELL_NUM){
dpush32(num);
} else {
dpush(num);
}
} else {
stat = exec(wd_idx,primitive,uforth_uram->ridx-1);
if (stat != OK) {
uforth_abort();
uforth_abort_clr();
return stat;
}
}
break;
case 1: /* in the middle of a colon def */
if (wd_idx == 0) { /* number or trash */
DCELL num = parse_num(word,uforth_uram->base);
if (num == 0 && word[0] != '0') {
uforth_abort_request(ABORT_NAW);
uforth_abort();
dict_end_def();
return E_NOT_A_WORD;
}
/* OPTIMIZATION: Only DLIT big numbers */
if (num < 0 || abs32(num) > (int32_t)MAX_CELL_NUM){
dict_append(DLIT);
dict_append(((uint32_t)num)>>16);
dict_append(((uint16_t)num)&0xffff);
} else {
dict_append(LIT);
dict_append(num);
}
} else if (word[0] == ';') { /* exit from a colon def */
开发者ID:item28,项目名称:tosqa-ssb,代码行数:52,代码来源:uforth.c
示例4: parse_real
/* int parse_real(char *str, double *v)
* check whether str[] starts with a number, or number/number. If yes,
* store the value in *v and return the length of the matching part.
* Return value is the same as for the previous routine.
*/
static int parse_real(char *str, double *v)
{int i,ret; double d;
i=0; if(*str==' '){ str++; i++; }
ret=parse_num(str,v);
if(ret<=0) return ret; // 0 or -1
i+=ret; str+=ret;
if(*str=='/'){
str++; i++; d=*v;
ret=parse_num(str,v);
if(ret<=0) return -1; // syntax error
i+=ret; *v = d/(*v);
}
return i;
}
开发者ID:lcsirmaz,项目名称:inner,代码行数:19,代码来源:data.c
示例5: act_width
static void act_width (void) {
char buffer[80];
char prompt[80];
fileoffset_t w;
fileoffset_t new_top;
int error;
sprintf (prompt, "Enter screen width in bytes (now %"OFF"d): ", width);
if (!get_str (prompt, buffer, FALSE))
return;
w = parse_num (buffer, &error);
if (error) {
display_beep();
strcpy (message, "Unable to parse width value");
return;
}
if (w > 0) {
width = w;
fix_offset();
new_top = cur_pos - (scrlines-1) * width;
new_top = begline(new_top);
if (top_pos < new_top)
top_pos = new_top;
}
}
开发者ID:rdebath,项目名称:sgt,代码行数:25,代码来源:actions.c
示例6: act_goto
static void act_goto (void) {
char buffer[80];
fileoffset_t position, new_top;
int error;
if (!get_str("Enter position to go to: ", buffer, FALSE))
return; /* user break */
position = parse_num (buffer, &error);
if (error) {
display_beep();
strcpy (message, "Unable to parse position value");
return;
}
if (position < 0 || position > file_size) {
display_beep();
strcpy (message, "Position is outside bounds of file");
return;
}
cur_pos = position;
edit_type = !!edit_type;
new_top = cur_pos - (scrlines-1) * width;
if (new_top < 0)
new_top = 0;
new_top = begline(new_top);
if (top_pos > cur_pos)
top_pos = begline(cur_pos);
if (top_pos < new_top)
top_pos = new_top;
}
开发者ID:rdebath,项目名称:sgt,代码行数:32,代码来源:actions.c
示例7: parse_cryptofunction
static int
parse_cryptofunction(ocra_suite * ocra, const char *in)
{
int ret, l;
char *token, *string, *tofree;
if (NULL == (tofree = string = strdup(in)))
return RFC6287_ERR_POSIX;
if ((NULL == (token = strsep(&string, "-"))) ||
(0 != strcmp(token, "HOTP")) ||
(NULL == (token = strsep(&string, "-"))) ||
(none == (ocra->hotp_alg = parse_alg(token))) ||
(NULL == (token = strsep(&string, "-"))) ||
(2 < (l = strlen(token))) ||
(-1 == (ocra->hotp_trunc = parse_num(token))) ||
((0 != ocra->hotp_trunc) &&
((4 > ocra->hotp_trunc) || (11 < ocra->hotp_trunc))) ||
((10 > ocra->hotp_trunc) && (2 == l)))
ret = RFC6287_INVALID_SUITE;
else
ret = 0;
free(tofree);
return ret;
}
开发者ID:sg2342,项目名称:pam_ocra,代码行数:25,代码来源:rfc6287.c
示例8: get_second_value
int
get_second_value(longint_t vars[], char *rhsarg,
longint_t *second_value) {
char *p;
int varnum2;
if (strchr(NUMCHRS, *rhsarg) != NULL ||
strchr(SGNCHRS, *rhsarg) != NULL) {
/* first character is a digit or a sign, so RHS
* should be a number
*/
p = rhsarg+1;
while (*p) {
if (strchr(NUMCHRS, *p) == NULL) {
/* nope, found an illegal character */
return ERROR;
}
p++;
}
*second_value = parse_num(rhsarg);
return !ERROR;
} else {
/* argument is not a number, so might be a variable */
varnum2 = to_varnum(*rhsarg);
if (varnum2==ERROR || strlen(rhsarg)!=1) {
/* nope, not a variable either */
return ERROR;
}
/* is a variable, so can use its value to assign to
* second_value
*/
*second_value = vars[varnum2];
return !ERROR;
}
return ERROR;
}
开发者ID:ShreyashPatodia,项目名称:MyC,代码行数:35,代码来源:assignment2013comp10002.c
示例9: parse_timecmp
static struct expr *
parse_timecmp()
{
enum prop prop;
enum op op;
if (token("atime"))
prop = PROP_ATIME;
else if (token("ctime"))
prop = PROP_CTIME;
else if (token("mtime"))
prop = PROP_MTIME;
else if (token("date"))
prop = PROP_DATE;
else
return parse_cmp();
op = parse_op();
if (!op)
parse_error("invalid comparison at '%.15s'", pos);
int64_t n;
if (parse_num(&n) || parse_dur(&n)) {
struct expr *e = mkexpr(op);
e->a.prop = prop;
e->b.num = n;
return e;
}
return 0;
}
开发者ID:Duncaen,项目名称:mblaze,代码行数:31,代码来源:mpick.c
示例10: act_offset
static void act_offset (void) {
char buffer[80];
char prompt[80];
fileoffset_t o;
fileoffset_t new_top;
int error;
sprintf (prompt, "Enter start-of-file offset in bytes (now %"OFF"d): ",
realoffset);
if (!get_str (prompt, buffer, FALSE))
return;
o = parse_num (buffer, &error);
if (error) {
display_beep();
strcpy (message, "Unable to parse offset value");
return;
}
if (o >= 0) {
realoffset = o;
fix_offset();
new_top = cur_pos - (scrlines-1) * width;
new_top = begline(new_top);
if (top_pos < new_top)
top_pos = new_top;
}
}
开发者ID:rdebath,项目名称:sgt,代码行数:26,代码来源:actions.c
示例11: parse_row
/* parses a line of the file
* tries to set the corresponding row in the matrix
* returns false on error
*/
bool parse_row(char* s, int row, LinearProgram* lp) {
assert(lp_is_valid(lp));
assert(row >= 0);
assert(row < get_rows(lp));
char* end_ptr;
int cols = get_cols(lp);
int i;
for (i = 0; i < cols; i++) {
num_t num = parse_num(s, &end_ptr);
if (!is_num_valid(num, s, end_ptr)) {
return false;
}
set_coef(lp, row, i, num);
s = end_ptr;
}
s = parse_type(s, row, lp);
if (NULL == s) {
return false;
}
num_t num = parse_num(s, &end_ptr);
if (!is_num_valid(num, s, end_ptr)) {
return false;
}
s = end_ptr;
s = skip_spaces(s);
if ('\0' != *s) {
return false;
}
set_rhs(lp, row, num);
assert(lp_is_valid(lp));
return true;
}
开发者ID:hensc,项目名称:appfs,代码行数:48,代码来源:read_lp.c
示例12: sendhup
static void sendhup(char *str)
{
int pid;
if (parse_num(str, "PPPD_PID=", &pid) && pid != getpid()) {
if (debug)
dbglog("sending SIGHUP to process %d", pid);
kill(pid, SIGHUP);
}
}
开发者ID:AdrianHuang,项目名称:rt-thread-for-vmm,代码行数:10,代码来源:multilink.c
示例13: sophon_time_parse
Sophon_Result
sophon_time_parse (Sophon_VM *vm, Sophon_String *str, Sophon_Time *time)
{
Sophon_Char *ptr;
Sophon_Date date;
Sophon_Result r;
SOPHON_ASSERT(str && time);
sophon_memset(&date, 0, sizeof(date));
ptr = sophon_string_chars(vm, str);
while (*ptr && sophon_isspace(*ptr))
ptr++;
if ((r = parse_num(vm, ptr, &date.year)) < 0)
return r;
date.year -= 1900;
ptr += r;
if (*ptr++ != '-')
return SOPHON_ERR_PARSE;
if ((r = parse_num(vm, ptr, &date.mon)) < 0)
return r;
date.mon--;
ptr += r;
if (*ptr++ != '-')
return SOPHON_ERR_PARSE;
if ((r = parse_num(vm, ptr, &date.mday)) < 0)
return r;
ptr += r;
if ((*ptr == 'T') || (*ptr == ' ')) {
ptr++;
if ((r = parse_num(vm, ptr, &date.hour)) < 0)
return r;
ptr += r;
if (*ptr++ != ':')
return SOPHON_ERR_PARSE;
if ((r = parse_num(vm, ptr, &date.min)) < 0)
return r;
ptr += r;
if (*ptr++ != ':')
return SOPHON_ERR_PARSE;
if ((r = parse_num(vm, ptr, &date.sec)) < 0)
return r;
ptr += r;
if (*ptr++ == '.') {
if ((r = parse_num(vm, ptr, &date.msec)) < 0)
return r;
ptr += r;
}
} else {
date.mday = 1;
}
return sophon_date_to_time(vm, &date, time);
}
开发者ID:sharpglasses,项目名称:SophonJS,代码行数:57,代码来源:sophon_date.c
示例14: parse_row
/* parses a line of the file
* tries to set the corresponding row in the matrix
* returns false on error
*/
bool parse_row(char* s, int row, LinearProgram* lp) {
assert(lp_is_valid(lp));
assert(row >= 0);
assert(row < lp->rows);
int i;
char* end_ptr;
for (i = 0; i < lp->cols; i++) {
num_t num = parse_num(s, &end_ptr);
if (!is_num_valid(num, s, end_ptr)) {
return false;
}
lp->matrix[row][i] = num;
s = end_ptr;
}
s = parse_type(s, row, lp);
if (NULL == s) {
return false;
}
num_t num = parse_num(s, &end_ptr);
if (!is_num_valid(num, s, end_ptr)) {
return false;
}
s = end_ptr;
s = skip_spaces(s);
if ('\0' != *s) {
return false;
}
lp->vector[row] = num;
assert(lp_is_valid(lp));
return true;
}
开发者ID:AndreG-P,项目名称:appfs,代码行数:46,代码来源:linear_program.c
示例15: write_byte
/*----------------------------------------------------------------------
* Write this byte into current packet
*/
static void
write_byte (const char *str)
{
guint32 num;
num = parse_num(str, FALSE);
packet_buf[curr_offset] = (guint8) num;
curr_offset ++;
if (curr_offset >= max_offset) /* packet full */
start_new_packet();
}
开发者ID:GerardGarcia,项目名称:wireshark,代码行数:14,代码来源:text_import.c
示例16: parse_packet
static void parse_packet(indexer_dv_context *This, unsigned char *p)
{
indexer_dv_bitstream b;
int type = p[0];
b = bitstream_new(p + 1);
switch (type) {
case 0x62: /* Record date */
parse_num(&b, 8);
This->rec_curr_day = parse_bcd(&b, 6);
parse_num(&b, 2);
This->rec_curr_month = parse_bcd(&b, 5);
parse_num(&b, 3);
This->rec_curr_year = parse_bcd(&b, 8);
if (This->rec_curr_year < 25) {
This->rec_curr_year += 2000;
}
else {
This->rec_curr_year += 1900;
}
This->got_record_date = 1;
break;
case 0x63: /* Record time */
This->rec_curr_frame = parse_bcd(&b, 6);
parse_num(&b, 2);
This->rec_curr_second = parse_bcd(&b, 7);
parse_num(&b, 1);
This->rec_curr_minute = parse_bcd(&b, 7);
parse_num(&b, 1);
This->rec_curr_hour = parse_bcd(&b, 6);
This->got_record_time = 1;
break;
}
}
开发者ID:244xiao,项目名称:blender,代码行数:35,代码来源:indexer_dv.c
示例17: parse_baud
bool
parse_baud(char *s, unsigned long *val, char **es, char *delim)
{
if (!parse_num(s, val, es, delim)) {
return false;
}
if ((*val == 9600) || (*val == 19200) || (*val == 38400) ||
(*val == 57600) || (*val == 115200))
return true;
else
return false;
}
开发者ID:Joel397,项目名称:Ongoing_work_files,代码行数:13,代码来源:parse.c
示例18: read_parse
//parser
cellpoint read_parse(char *ibuf, char **pscan)
{
current_state = STATE_INIT;
stack_init(&parser_stack);
stack_init(&state_stack);
while (*pscan == NULL || **pscan == '\0'){
*pscan = reload_ibuffer(ibuf);
}
while (1){
if (current_state == STATE_INIT && !stack_is_empty(&parser_stack)){
//parses a object
return stack_pop(&parser_stack);
}
if (current_state == STATE_INIT){
do_state_init(ibuf, pscan);
}else if (current_state == STATE_SHARP){
do_state_sharp(ibuf, pscan);
}else if (current_state == STATE_DOT){
do_state_dot(pscan);
}else if (current_state == STATE_ADD){
do_state_add(pscan);
}else if (current_state == STATE_SUB){
do_state_sub(pscan);
}else if (current_state == STATE_NUM){
//parses number object
parse_num(pscan);
}else if (current_state == STATE_CHAR){
//parses character object
parse_char(pscan);
}else if (current_state == STATE_STR){
//parses string object
parse_string(ibuf, pscan);
}else if (current_state == STATE_SYM){
//parses symbol object
parse_sym(pscan);
}else if (current_state == STATE_LIST){
//parses list object
parse_list(ibuf, pscan);
}else if (current_state == STATE_VEC){
//parses vector object
parse_vector(ibuf, pscan);
}else {
perror("Error: Bad state. -- READ\n");
error_handler();
return NIL;
}
}
}
开发者ID:lienhua34,项目名称:CSchemer,代码行数:52,代码来源:read_parse.c
示例19: parse_factor
// factor = number | string_literal | "(" expression ")" |
// variable | "this" | "null" | "true" | "false" |
// "{" object_literal "}" |
// "[" array_literal "]" |
// function_definition |
// function_call
static enum v7_err parse_factor(struct v7 *v7) {
int old_sp = v7_sp(v7);
if (*v7->cursor == '(') {
TRY(match(v7, '('));
TRY(parse_expression(v7));
TRY(match(v7, ')'));
} else if (*v7->cursor == '\'' || *v7->cursor == '"') {
TRY(parse_string_literal(v7));
} else if (*v7->cursor == '{') {
TRY(parse_object_literal(v7));
} else if (is_alpha(*v7->cursor) || *v7->cursor == '_') {
TRY(parse_identifier(v7));
if (test_token(v7, "this", 4)) {
inc_stack(v7, 1);
v7_top(v7)[-1] = &v7->scopes[v7->current_scope];
} else if (test_token(v7, "null", 4)) {
TRY(v7_make_and_push(v7, V7_NULL));
} else if (test_token(v7, "true", 4)) {
TRY(v7_make_and_push(v7, V7_BOOL));
v7_top(v7)[-1]->v.num = 1;
} else if (test_token(v7, "false", 5)) {
TRY(v7_make_and_push(v7, V7_BOOL));
v7_top(v7)[-1]->v.num = 0;
} else if (test_token(v7, "function", 8)) {
TRY(parse_function_definition(v7, NULL, 0));
} else if (test_token(v7, "delete", 6)) {
TRY(parse_delete(v7));
} else {
TRY(parse_variable(v7));
}
} else {
TRY(parse_num(v7));
}
if (*v7->cursor == '(') {
TRY(parse_function_call(v7));
}
// Don't leave anything on stack if no execution flag is set
if (v7->no_exec) {
inc_stack(v7, old_sp - v7->sp);
}
return V7_OK;
}
开发者ID:di3online,项目名称:v7,代码行数:52,代码来源:v7.c
示例20: ungetc
object_t *parse_sexp(FILE *fp){
char buf;
buf=skip_space_getchar(fp);
ungetc(buf,fp);
if(isalpha(buf) || buf=='+' || buf=='*' || buf=='-'){
return parse_sym(fp);
}
else if(isdigit(buf)){
return parse_num(fp);
}
else if(buf=='('){
return parse_list(fp);
}
return (object_t*)NULL;
}
开发者ID:tanatana,项目名称:nandemoiiyo,代码行数:17,代码来源:parser.c
注:本文中的parse_num函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论