コード例 #1
0
ファイル: clutter-color.c プロジェクト: GNOME/clutter
static gboolean
parse_rgba (ClutterColor *color,
            gchar        *str,
            gboolean      has_alpha)
{
  skip_whitespace (&str);

  if (*str != '(')
    return FALSE;

  str += 1;

  /* red */
  parse_rgb_value (str, &color->red, &str);
  skip_whitespace (&str);
  if (*str != ',')
    return FALSE;

  str += 1;

  /* green */
  parse_rgb_value (str, &color->green, &str);
  skip_whitespace (&str);
  if (*str != ',')
    return FALSE;

  str += 1;

  /* blue */
  parse_rgb_value (str, &color->blue, &str);
  skip_whitespace (&str);

  /* alpha (optional); since the alpha channel value can only
   * be between 0 and 1 we don't use the parse_rgb_value()
   * function
   */
  if (has_alpha)
    {
      gdouble number;

      if (*str != ',')
        return FALSE;

      str += 1;

      skip_whitespace (&str);
      number = g_ascii_strtod (str, &str);

      color->alpha = CLAMP (number * 255.0, 0, 255);
    }
  else
    color->alpha = 255;

  skip_whitespace (&str);
  if (*str != ')')
    return FALSE;

  return TRUE;
}
コード例 #2
0
ファイル: gui_script.c プロジェクト: DIYBookScanner/chdk
//-------------------------------------------------------------------
static void process_title(const char *title)
{
    register const char *ptr = title;
    register int i=0;

    ptr = skip_whitespace(ptr);
    while (i<(sizeof(script_title)-1) && ptr[i] && ptr[i]!='\r' && ptr[i]!='\n')
    {
        script_title[i]=ptr[i];
        ++i;
    }
    script_title[i]=0;
}
コード例 #3
0
/**
 * Execute the BASIC command in 's'.
 */
void execute(char *s) {
  unsigned char command;
  char * args;
  reset_interrupted();
  s = skip_whitespace(s);
  args = find_args(s);
  command = find_keyword(s);
  if (command != CMD_UNKNOWN) {
    command_functions[command](args);
  } else {
    lcd_puts("Unknown command!\n");
  }
}
コード例 #4
0
ファイル: gui_script.c プロジェクト: DIYBookScanner/chdk
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE" to check if it exists
//      param = ptr right after descriptor (should point to var)
// RETURN VALUE: 0 if not found, 1..26 = id of var
// Used to ensure that a param loaded from an old saved paramset does
// not overwrite defaults from script
//-------------------------------------------------------------------
static int check_param(const char *param)
{
    register const char *ptr = param;
    register int n=0, l;

    ptr = skip_whitespace(ptr);
    if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
    {
        n = ptr[0]-'a';                                 // VAR
        ptr = skip_whitespace(ptr+2);                   // skip to TITLE
        l = skip_toeol(ptr) - ptr;                      // get length of TITLE
        if (l > MAX_PARAM_NAME_LEN)
            l = MAX_PARAM_NAME_LEN;
        if (l != strlen(script_params[n]))              // Check length matches existing TITLE length
            n = 0;
        else if (strncmp(ptr,script_params[n],l) != 0)  // Check that TITLE matches existing TITLE
            n = 0;
        else
            n++;
    }
    return n; // n=1 if '@param a' was processed, n=2 for 'b' ... n=26 for 'z'. n=0 if failed.
}
コード例 #5
0
ファイル: gui_script.c プロジェクト: DIYBookScanner/chdk
//-------------------------------------------------------------------
// Process one entry "@range VAR MIN MAX"
//      param = ptr right after descriptor (should point to var)
//-------------------------------------------------------------------
static void process_range(const char *param)
{
    register const char *ptr = param;
    register int n;

    ptr = skip_whitespace(ptr);
    if (ptr[0] && (ptr[0]>='a' && ptr[0]<='a'+SCRIPT_NUM_PARAMS) && (ptr[1]==' ' || ptr[1]=='\t'))
    {
        n = ptr[0]-'a';
        ptr = skip_whitespace(ptr+2);
        int min = strtol(ptr,NULL,0);
        ptr = skip_whitespace(skip_token(ptr));
        int max = strtol(ptr,NULL,0);
        script_range_values[n] = MENU_MINMAX(min,max);
        if ((min == 0) && (max == 1))
            script_range_types[n] = MENUITEM_BOOL;
        else if ((min >= 0) && (max >= 0)) 
            script_range_types[n] = MENUITEM_INT|MENUITEM_F_MINMAX|MENUITEM_F_UNSIGNED;
        else
            script_range_types[n] = MENUITEM_INT|MENUITEM_F_MINMAX;
    } // ??? else produce error message
}
コード例 #6
0
ファイル: rich_json.c プロジェクト: vaughan0/vlib
static void read_map(JSONSource* self, rich_Sink* to) {
  Input* in = self->in;
  call(to, sink, RICH_MAP, NULL);
  bool first = true;
  for (;;) {
    int ch = skip_whitespace(in);
    if (ch == '}') break;
    if (first) {
      first = false;
    } else {
      if (ch != ',') RAISE(MALFORMED);
      ch = skip_whitespace(in);
    }
    if (ch != '"') RAISE(MALFORMED);
    read_string(self);
    call(to, sink, RICH_KEY, &self->sval);
    ch = skip_whitespace(in);
    if (ch != ':') RAISE(MALFORMED);
    read_value(self, to);
  }
  call(to, sink, RICH_ENDMAP, NULL);
}
コード例 #7
0
	void streamtools_object::test<1>()
	{
		char arr[255];
		std::string str;
		std::string expected_result;
		std::string actual_result;
		std::istringstream is;

		is.str(str = "");
		ensure("skip_whitespace: empty string", (false == skip_whitespace(is)));

		is.clear();
		is.str(str = " SecondLife is a 3D World");
		skip_whitespace(is);
		is.get(arr, 255, '\0');
		expected_result = "SecondLife is a 3D World";
		ensure_equals("skip_whitespace: space", arr, expected_result);

		is.clear();
		is.str(str = "\t          \tSecondLife is a 3D World");
		skip_whitespace(is);
		is.get(arr, 255, '\0');
		expected_result = "SecondLife is a 3D World";
		ensure_equals("skip_whitespace: space and tabs", arr, expected_result);

		is.clear();
		is.str(str = "\t          \tSecondLife is a 3D World       ");
		skip_whitespace(is);
		is.get(arr, 255, '\0');
		expected_result = "SecondLife is a 3D World       ";
		ensure_equals("skip_whitespace: space at end", arr, expected_result);

		is.clear();
		is.str(str = "\t \r\nSecondLife is a 3D World");
		skip_whitespace(is);
		is.get(arr, 255, '\0');
		expected_result = "\r\nSecondLife is a 3D World";
		ensure_equals("skip_whitespace: space at end", arr, expected_result);
	}
コード例 #8
0
ファイル: utils.cpp プロジェクト: RickyXwang/transf-badapple
bool line_has_word (char *ptr, const char *word, int word_len) {

	ptr = skip_whitespace(ptr);
	//make sure the file doesn't end before the end of the word + required whitespace,
	// then see if the word's found on the line
	if (strnlen (ptr, word_len) == word_len && !strncasecmp (ptr, word, word_len)) {
		//then make sure it isn't just the start of another word
		ptr += word_len;
		//if (isspace (*ptr) || is_end_of_code_line (ptr))
			return true;
	}
	return false;
}
コード例 #9
0
ファイル: mask.c プロジェクト: Araneidae/fa-archiver
/* Each line in the file consists of up to four whitespace separated fields:
 *  id [description] [x_name] [y_name]
 */
static bool parse_fa_id_line(const char **line, bool seen[])
{
    int id;
    bool ok =
        parse_int(line, &id)  &&
        TEST_OK_(0 <= id  &&  (uint32_t) id < id_list_length,
            "FA id %d out of range", id)  &&
        TEST_OK_(!seen[id], "FA id %u repeated", id);
    if (ok)
    {
        seen[id] = true;
        struct fa_id_list *entry = &fa_id_list[id];
        IGNORE(
            skip_whitespace(line)  &&
            maybe_parse_word(line, &entry->description)  &&
            skip_whitespace(line)  &&
            maybe_parse_word(line, &entry->x_name)  &&
            skip_whitespace(line)  &&
            maybe_parse_word(line, &entry->y_name));
    }
    return ok;
}
コード例 #10
0
ファイル: dendrite.c プロジェクト: satterly/ganglia-1.0
void process_memstate ( void ) 
{
   char *p;

   if ( ! slurpfile( "/proc/meminfo" ) ){
      return;
   }

   p = strstr( buffer, "MemFree:" );
   p = skip_token(p);
   p = skip_whitespace(p);

   now.mem_free  = strtod( p, (char **)NULL);

   p = strstr( buffer, "MemShared:" );
   p = skip_token(p);
   p = skip_whitespace(p);
   
   now.mem_shared = strtod( p, (char **)NULL);

   p = strstr( buffer, "Buffers:" );
   p = skip_token(p);
   p = skip_whitespace(p);

   now.mem_buffers = strtod( p, (char **)NULL);

   p = strstr( buffer, "Cached:" );
   p = skip_token(p);
   p = skip_whitespace(p);

   now.mem_cached = strtod( p, (char **)NULL);

   p = strstr( buffer, "SwapFree:" );
   p = skip_token(p);
   p = skip_whitespace(p);

   now.swap_free = strtod( p, (char **)NULL );

}
コード例 #11
0
Token_type get_integer_token(FILE *fp, int *i)
{
    int c;

    c = skip_whitespace(fp);
    if (c == EOF)
        return Token_EOF;

    ungetc(c, fp);
    if (fscanf(fp, "%d", i) != 1)
        parse_error("integer constant expected");

    return Token_integer;
}
コード例 #12
0
ファイル: esp_http.c プロジェクト: cristidbr/aircore
/**
 * Parses first line of request
 */
uint8_t* ICACHE_FLASH_ATTR http_request_parse_method_line( http_request_object_type* request, uint8_t* data )
{
    uint8_t* w, v, *end, ev;
    char hpost[ 5 ] = "POST", hget[ 4 ] = "GET";

    ev = *( end = get_line_ending( data ));
    ( *end ) = '\0';
    request->method = HTTP_METHOD_NONE;
    data = skip_whitespace( data );
    v = *( w = skip_to_whitespace( data ) );
    ( *w ) = '\0';
    if( strcmp( hget, ( char* ) data ) == 0 ) request->method = HTTP_METHOD_GET;
    if( strcmp( hpost, ( char* ) data ) == 0 ) request->method = HTTP_METHOD_POST;
    ( *w ) = v;

    data = skip_whitespace( w );
    v = *( w = skip_to_whitespace( data ) );
    ( *w ) = '\0';
    url_parse_path( request->location, data );
    ( *w ) = v;
    ( *end ) = ev;
    return skip_line_ending( end );
}
コード例 #13
0
ファイル: parse.c プロジェクト: mk12/eva
// Parses a pair, assuming the opening left parenthesis has already been read.
static struct ParseResult parse_pair(const char *text) {
	struct ParseResult result;
	result.err_type = -1;
	const char *s = text;
	s += skip_whitespace(s);

	if (*s == ')') {
		s++;
		result.expr = new_null();
		goto chars_read;
	}

	struct ParseResult first = parse(s);
	s += first.chars_read;
	if (first.err_type != -1) {
		result.err_type = first.err_type;
		goto chars_read;
	}

	if (*s == '.') {
		s++;
		struct ParseResult second = parse(s);
		s += second.chars_read;
		if (second.err_type != -1) {
			result.err_type = second.err_type;
			release_expression(first.expr);
			goto chars_read;
		}
		if (*s != ')') {
			result.err_type = *s ? ERR_EXPECTED_RPAREN : ERR_UNEXPECTED_EOI;
			release_expression(first.expr);
			goto chars_read;
		}
		s++;
		result.expr = new_pair(first.expr, second.expr);
	} else {
		struct ParseResult rest = parse_pair(s);
		s += rest.chars_read;
		if (rest.err_type != -1) {
			result.err_type = rest.err_type;
			release_expression(first.expr);
			goto chars_read;
		}
		result.expr = new_pair(first.expr, rest.expr);
	}

chars_read:
	result.chars_read = (size_t)(s - text);
	return result;
}
コード例 #14
0
ファイル: hfp.c プロジェクト: AlanApter/steamlink-sdk
bool hfp_context_close_container(struct hfp_context *context)
{
	skip_whitespace(context);

	/* The list shall be followed by a right parenthesis (")" V250 5.7.3.1*/
	if (context->data[context->offset] != ')')
		return false;

	context->offset++;

	next_field(context);

	return true;
}
コード例 #15
0
ファイル: gui_script.c プロジェクト: c10ud/CHDK
// Extract name up to maxlen, find or create sc_param based on name
// Return pointer past name.
// Sets *sp to sc_param entry, or 0 if not found
const char* get_name(const char *p, int maxlen, sc_param **sp, int create)
{
    char str[MAX_PARAM_NAME_LEN+1];
    *sp = 0;
    p = skip_whitespace(p);
    if (p[0] && isalpha(p[0]))
    {
        p = get_token(p, str, maxlen);
        *sp = find_param(str);
        if ((*sp == 0) && create)
            *sp = new_param(str);
    }
    return p;
}
コード例 #16
0
ファイル: scas.c プロジェクト: thentenaar/sctools
static int cmd_layerdef(const char *p)
{
	int fn, n, ret = ERR_INVALID_ARGS;
	unsigned char fn_combo = 0;

	p = skip_whitespace(p);
	for (p = skip_whitespace(p); *p; p = skip_token(p)) {
		fn = parse_function_n(p);
		if (fn == INVALID_NUMBER) break;
		fn_combo |= (unsigned char)(1 << (fn - 1));
	}
	if (!fn_combo) goto ret;

	/* layer id */
	n = parse_int(p, 1, 255);
	if (n == INVALID_NUMBER) goto ret;

	pair_list_push(LAYERDEF_LIST, fn_combo, (unsigned char)n);
	ret = 0;

ret:
	return ret;
}
コード例 #17
0
ファイル: gui_script.c プロジェクト: c10ud/CHDK
//-------------------------------------------------------------------
// Process one entry "@param VAR TITLE"
// RESULT: params[VAR].desc - parameter title
// RETURN VALUE: 0 if err, 1 if ok
//-------------------------------------------------------------------
static void process_param(const char *ptr)
{
    sc_param *p;
    ptr = get_name(ptr, MAX_PARAM_NAME_LEN, &p, 1);
    if (p)
    {
        ptr = skip_whitespace(ptr);
        int l = skip_toeol(ptr) - ptr;
        if (l > MAX_PARAM_NAME_LEN) l = MAX_PARAM_NAME_LEN;
        p->desc = malloc(l+1);
        strncpy(p->desc, ptr, l);
        p->desc[l] = 0;
    }
}
コード例 #18
0
ファイル: cpptrad.c プロジェクト: Fokycnuk/gcc
/* Read and record the parameters, if any, of a function-like macro
   definition.  Destroys pfile->out.cur.

   Returns true on success, false on failure (syntax error or a
   duplicate parameter).  On success, CUR (pfile->context) is just
   past the closing parenthesis.  */
static bool
scan_parameters (cpp_reader *pfile, cpp_macro *macro)
{
  const uchar *cur = CUR (pfile->context) + 1;
  bool ok;

  for (;;)
    {
      cur = skip_whitespace (pfile, cur, true /* skip_comments */);

      if (is_idstart (*cur))
	{
	  ok = false;
	  if (_cpp_save_parameter (pfile, macro, lex_identifier (pfile, cur)))
	    break;
	  cur = skip_whitespace (pfile, CUR (pfile->context),
				 true /* skip_comments */);
	  if (*cur == ',')
	    {
	      cur++;
	      continue;
	    }
	  ok = (*cur == ')');
	  break;
	}

      ok = (*cur == ')' && macro->paramc == 0);
      break;
    }

  if (!ok)
    cpp_error (pfile, CPP_DL_ERROR, "syntax error in macro parameter list");

  CUR (pfile->context) = cur + (*cur == ')');

  return ok;
}
コード例 #19
0
ファイル: tkparse.c プロジェクト: xinpianyu72/nemo
static char * parse_choices(struct kconfig * choice_kcfg, char * pnt)
{
  struct kconfig * kcfg;
  int index = 1;

  /*
   * Choices appear in pairs of strings.  The parse is fairly trivial.
   */
  while(1)
    {
      pnt = skip_whitespace(pnt);
      if(*pnt == '\0') break;

      kcfg = (struct kconfig *) malloc(sizeof(struct kconfig));
      memset(kcfg, 0, sizeof(struct kconfig));
      kcfg->tok = tok_choice;
      if( clast != NULL )
	{
	  clast->next = kcfg;
	  clast = kcfg;
	}
      else
	{
	  clast = config = kcfg;
	}

      pnt = get_string(pnt, &kcfg->label);
      pnt = skip_whitespace(pnt);
      pnt = get_string(pnt, &kcfg->optionname);
      kcfg->choice_label = choice_kcfg;
      kcfg->choice_value = index++;
      if( strcmp(kcfg->label, choice_kcfg->value) == 0 )
	choice_kcfg->choice_value = kcfg->choice_value;
    }
    
    return pnt;
}
コード例 #20
0
ファイル: pmgetopt.c プロジェクト: Aconex/pcp
/*
 * Parse non-option commands: getopts, (short)usage, or end.
 * The return code indicates whether the end directive was observed.
 */
static int
command(pmOptions *opts, char *buffer)
{
    char *start, *finish;

    start = skip_whitespace(buffer);

    if (strncasecmp(start, "getopt", sizeof("getopt")-1) == 0) {
	start = skip_whitespace(skip_nonwhitespace(start));
	finish = skip_nonwhitespace(start);
	*finish = '\0';
	if (pmDebug & DBG_TRACE_DESPERATE)
	    fprintf(stderr, "%s: getopt command: '%s'\n", pmProgname, start);
	if ((opts->short_options = strdup(start)) == NULL)
	    __pmNoMem("short_options", strlen(start), PM_FATAL_ERR);
	return 0;
    }

    if (strncasecmp(start, "usage", sizeof("usage")-1) == 0) {
	start = skip_whitespace(skip_nonwhitespace(start));
	if (pmDebug & DBG_TRACE_DESPERATE)
	    fprintf(stderr, "%s: usage command: '%s'\n", pmProgname, start);
	if ((opts->short_usage = strdup(start)) == NULL)
	    __pmNoMem("short_usage", strlen(start), PM_FATAL_ERR);
	return 0;
    }

    if (strncasecmp(start, "end", sizeof("end")-1) == 0) {
	if (pmDebug & DBG_TRACE_DESPERATE)
	    fprintf(stderr, "%s: end command\n", pmProgname);
	return 1;
    }

    fprintf(stderr, "%s: unrecognized command: '%s'\n", pmProgname, buffer);
    return 0;
}
コード例 #21
0
int string_to_kcg_real(const char* str, void* pValue, const char** endptr)
{
    skip_whitespace(str);
    if (pSimDoubleVTable != NULL
        && pSimDoubleVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
        return string_to_VTable(str, pSimDoubleVTable, pValue, endptr);
    }
    {
        double nTemp = 0;
        int nRet = pConverter->m_pfnStringToReal(str, &nTemp, endptr);
        if (nRet != 0 && pValue != NULL)
            *(kcg_real*)pValue = (kcg_real)nTemp;
        return nRet;
    }
}
コード例 #22
0
int string_to_kcg_bool(const char* str, void* pValue, const char** endptr)
{
    skip_whitespace(str);
    if (pSimBoolVTable != NULL
        && pSimBoolVTable->m_pfnGetConvInfo(SptNone, SptString) == 1) {
        return string_to_VTable(str, pSimBoolVTable, pValue, endptr);
    }
    {
        int nTemp = 0;
        int nRet = pConverter->m_pfnStringToBool(str, &nTemp, endptr);
        if (nRet != 0 && pValue != NULL)
            *(kcg_bool*)pValue = nTemp == 1 ? kcg_true : kcg_false;
        return nRet;
    }
}
コード例 #23
0
/**
 * Parse a string argument ("...") at the beginning of the string pointed to by 's'.
 * If a string argument is found, it is copied to the buffer 'value' and a pointer
 * behind the string argument is returned from parse_string().
 * If no string argument is found, NULL is returned and 'value' is not modified.
 */
char *parse_string(char *s, char *value) {
  char *right_mark;
  s = skip_whitespace(s);
  if (*s == '"') {
    ++s;
    right_mark = strchr(s, '"');
    if (right_mark) {
      int len = right_mark - s;
      strncpy(value, s, len);
      *(value + len) = '\0';
      return right_mark + 1;
    }
  }
  return NULL;
}
コード例 #24
0
ファイル: abrt_curl.c プロジェクト: wyuka/abrt
char *find_header_in_abrt_post_state(abrt_post_state_t *state, const char *str)
{
    char **headers = state->headers;
    if (headers)
    {
        unsigned len = strlen(str);
        while (*headers)
        {
            if (strncmp(*headers, str, len) == 0)
                return skip_whitespace(*headers + len);
            headers++;
        }
    }
    return NULL;
}
コード例 #25
0
ファイル: metrics.cpp プロジェクト: imaxxs/cyton
unsigned int num_cpustates_func ( void ) {
   char *p;
   unsigned int i=0;

   p = update_file(&proc_stat);

/*
** Skip initial "cpu" token
*/
   p = skip_token(p);
   p = skip_whitespace(p);
/*
** Loop over file until next "cpu" token is found.
** i=4 : Linux 2.4.x
** i=7 : Linux 2.6.x
*/
   while (strncmp(p,"cpu",3)) {
     p = skip_token(p);
     p = skip_whitespace(p);
     i++;
     }

   return i;
}
コード例 #26
0
ファイル: filetype.c プロジェクト: lowtalker/vifm
/* Associates pattern with the list of programs either for X or non-X
 * associations and depending on current execution environment. */
static void
assoc_programs(matcher_t *matcher, const assoc_records_t *programs, int for_x,
		int in_x)
{
	const assoc_t assoc = {
		.matcher = matcher,
		.records = clone_assoc_records(programs, matcher_get_expr(matcher),
				for_x ? &xfiletypes : &filetypes),
	};

	register_assoc(assoc, for_x, in_x);
}

/* Parses comma separated list of commands into array of associations.  Returns
 * the list. */
static assoc_records_t
parse_command_list(const char cmds[], int with_descr)
{
	assoc_records_t records = {};

	char *free_this = strdup(cmds);

	char *part = free_this, *state = NULL;
	while((part = split_and_get_dc(part, &state)) != NULL)
	{
		const char *description = "";

		if(with_descr && *part == '{')
		{
			char *p = strchr(part + 1, '}');
			if(p != NULL)
			{
				*p = '\0';
				description = part + 1;
				part = skip_whitespace(p + 1);
			}
		}

		if(part[0] != '\0')
		{
			ft_assoc_record_add(&records, part, description);
		}
	}

	free(free_this);

	return records;
}
コード例 #27
0
ファイル: strings.c プロジェクト: davidmreed/bouncingbots
void bb_create_board_from_string(const char *str, bb_board **b, bb_pawn_state ps)
{
	bb_board *board;
	long width, height, i, j;
	char *cur;
	
	width = strtol(str, &cur, 0);
	height = strtol(cur, &cur, 0);
	
	if ((width < 1) || (height < 1) || (width > BB_MAX_DIMENSION) || (height > BB_MAX_DIMENSION)) {
		*b = NULL;
		return;
	}
	
	board = bb_board_alloc(width, height);
	if (board == NULL) {
		*b = NULL;
		return;
	}
	bb_init_pawn_state(ps);
	
	cur = skip_whitespace(cur);
	
	for (i = 0; i < height; i++) {
		for (j = 0; j < width; j++) {	
			bb_bool success;
			bb_pawn pawn;
			bb_cell *cell = bb_get_cell(board, i, j);
			
			pawn = 0;
			cur = read_cell(cur, cell, &success, &pawn);
						
			if (!success) {
				bb_board_dealloc(board);
				*b = NULL;
				return;
			}
			
			/* Make sure we record where the pawn is */
			if (pawn != 0) {
				ps[pawn - 1].row = i;
				ps[pawn - 1].col = j;
			}
		}
	}
	
	*b = board;
}
コード例 #28
0
ファイル: hfp.c プロジェクト: AlanApter/steamlink-sdk
bool hfp_context_get_number_default(struct hfp_context *context,
						unsigned int *val,
						unsigned int default_val)
{
	skip_whitespace(context);

	if (context->data[context->offset] == ',') {
		if (val)
			*val = default_val;

		context->offset++;
		return true;
	}

	return hfp_context_get_number(context, val);
}
コード例 #29
0
ファイル: parse.c プロジェクト: Ramblurr/Far-Horizons
/* Read a long decimal and place its value in 'value'. */
int get_value ()
{
    int		n;


    skip_whitespace();

    n = sscanf (input_line_pointer, "%ld", &value);
    if (n != 1) return 0;	/* Not a numeric value. */

    /* Skip numeric string. */
    ++input_line_pointer;	/* Skip first sign or digit. */
    while (isdigit(*input_line_pointer)) ++input_line_pointer;

    return 1;
}
コード例 #30
0
ファイル: hexdump.c プロジェクト: ThinkIntegrate/busybox
static void bb_dump_addfile(dumper_t *dumper, char *name)
{
	char *p;
	FILE *fp;
	char *buf;

	fp = xfopen_for_read(name);
	while ((buf = xmalloc_fgetline(fp)) != NULL) {
		p = skip_whitespace(buf);
		if (*p && (*p != '#')) {
			bb_dump_add(dumper, p);
		}
		free(buf);
	}
	fclose(fp);
}