Exemple #1
0
// same, but check beginning of adr with s (for <object src="bar.mov" .. hotspot123="foo.html">)
HTS_INLINE int __rech_tageqbegdigits(const char *adr, const char *s) {
  int p;

  p = strfield(adr, s);
  if (p) {
    while(isdigit((unsigned char) adr[p]))
      p++;                      // jump digits
    while(is_space(adr[p]))
      p++;
    if (adr[p] == '=') {
      return p + 1;
    }
  }
  return 0;
}
Exemple #2
0
static int get_section_name(char* buf, char** secName)
{
	char* s = buf;
	char* name = NULL;
	int len = 0;
	while (is_space(*s) || is_left_barce(*s)) {
		s++;
	}
	len = (int)(strlen(s) - strlen(strstr(s, "]")));
	name = (char*) malloc(len + 1);
	memcpy(name, s, len);
	name[len] = '\0';
	(*secName) = name;
	return 0;
}
Exemple #3
0
int ld_cmd_setopt(db_cmd_t* cmd, char* optname, va_list ap)
{
	struct ld_fld* lfld;
	char* val, *c;
	int i;
		
	if (!strcasecmp("client_side_filtering", optname)) {
		val = va_arg(ap, char*);

		for(i = 0; !DB_FLD_EMPTY(cmd->result) && !DB_FLD_LAST(cmd->result[i]); i++) {
			c = val;
			do {
				c = strstr(c, cmd->result[i].name);
				if (c) {
					if ((c == val || is_space(*(c-1))) && is_space(*(c+strlen(cmd->result[i].name)))) {
						lfld = (struct ld_fld*)DB_GET_PAYLOAD(cmd->result + i);
						lfld->client_side_filtering = 1;
						break;
					}
					c += strlen(cmd->result[i].name);
				}
			} while (c != NULL);
		}
	}
Exemple #4
0
enum parse_sst_result
parse_min_se_body( struct hdr_field *hf )
{
	int len = hf->body.len;
	char *p = hf->body.s;
	int pos = 0;
	unsigned int interval = 0;

	/* skip whitespace */
	for ( ; pos < len && is_space(*p); ++pos, ++p )
		/*nothing*/;
	if ( pos == len )
		return parse_sst_no_value;
	/* collect a number */
	for ( ; pos < len && is_num(*p); ++pos, ++p )
		interval = interval*10/*radix*/ + (*p - '0');
	/* skip whitespace */
	for ( ; pos < len && is_space(*p); ++pos, ++p )
		/*nothing*/;
	if ( pos != len ) /* shouldn't be any more junk */
		return parse_sst_parse_error;
	hf->parsed=(void*)(long)interval;
	return parse_sst_success;
}
Exemple #5
0
std::vector<std::string>  postfix(std::string infix_str){
	if(!infix_is_correct(infix_str)){
		std::vector<std::string> err;
		err.push_back(infix_str);
		return err;
	}

	std::stack<char> char_stack;
 	std::vector<std::string> result;
	char  clean_number[5];
	int clean_index=0;
	
	for(int i=0;i<infix_str.size() ;++i){
		int q=prior(infix_str[i]);
	
		if(is_number(q)){
			clean_number[clean_index++]=infix_str[i];
		}
		else if(is_space(q) && clean_index>0){

			clean_number[clean_index]='\0';
			result.push_back(clean_number);
			clean_index=0;
		}
		else if(is_operator(q)){
			
			while(!char_stack.empty() && prior(char_stack.top())>q){
				save(char_stack,result);
			}
			char_stack.push(infix_str[i]);
		}
		else if(is_brk_open(q)){
			char_stack.push(infix_str[i]);
		}else if(is_brk_close(q)){
			while( char_stack.top()!='('){
				save(char_stack,result);
			}	
			char_stack.pop();		
		}

	}
	
	while(!char_stack.empty()){
		save(char_stack,result);
	}

	return result;
}
Exemple #6
0
// 看是否读到文件结尾
bool TokenAnalyze::has_tokens()
{
	char ch;
	while(filein.get(ch) && is_space(ch))  // 读空白
		if(ch == '\n')
			line_number ++;
	if(filein.eof()) // 判断是是否到达文件结尾
	{
		return false;
	}
	else 
	{
		filein.unget();
		return true;
	}
}
Exemple #7
0
void
texpdf_skip_white (const char **start, const char *end)
{
  /*
   * The null (NUL; 0x00) character is a white-space character in PDF spec
   * but isspace(0x00) returns FALSE; on the other hand, the vertical tab
   * (VT; 0x0B) character is not a white-space character in PDF spec but
   * isspace(0x0B) returns TRUE.
   */
  while (*start < end && (is_space(**start) || **start == '%')) {
    if (**start == '%')
      skip_line(start, end);
    else
      (*start)++;
  }
}
char*
bib_last_char (tree t) {
  if (is_atomic (t)) {
    string s= t->label;
    int end= N(s)-1;
    while ((end >= 0) && is_space (s[end])) end--;
    if (end >= 0) return &(s[end]);
    else return 0;
  }
  else {
    int pos= N(t)-1;
    while ((pos >= 0) && bib_is_bad (t[pos])) pos--;
    if (pos >= 0) return bib_last_char (t[pos]);
    else return 0;
  }
}
Exemple #9
0
tree
xml_html_parser::parse_misc () {
  s += 2;
  tree t= tuple ("misc");
  while (true) {
    skip_space ();
    if (test (s, ">")) { s += 1; break; }
    string r;
    while (s) {
      if (is_space (s[0]) || (s[0] == '>')) break;
      r << s->read (1);
    }
    t << r;
  }
  return t;
}
Exemple #10
0
////////////////////
// Function name	: RemoveTailSpaces
// Description	    : 끝의 공백을 제거, 원본을 수정
// Return type		: char*
//					: 입력 문자열 포인터 반환
// Argument         : char* string
//					: 공백을 제거하고자 하는 문자열
char* RemoveTailSpaces(char* string)
{
    // 길이를 구하고
    int len = strlen(string);

    // 끝부터 공백을 검사하여
    for (int i = len - 1; i >= 0; i++)
    {
        // 공백이면 NULL 문자로 대체
        if (is_space(string[i]))
            string[i] = '\0';
        else
            break;
    }

    return string;
}
int _atoi( LPCTSTR pszLine, int nRadix )
{
	LPCTSTR psz = pszLine;
	// skip leading spaces
	while ( *psz && is_space( *psz ) )
		psz++;
	LPCTSTR pszStart = psz;
	if ( nRadix == CM_HEXADECIMAL )
	{
		// tolerate 0x at the start of the number
		while ( *psz && *psz != _T('x') && *psz != _T('X') )
			psz++;

		if ( *psz )	// if found an 'x' -- start after this char
			pszStart = psz + 1;
	}

	int nResult = 0;
	psz = pszStart;
	while ( *psz )
	{
		TCHAR chDigit = CEdit::g_UpperConv[ *psz ];
		int nDigit = INT_MAX;
		if ( chDigit >= _T('0') && chDigit <= _T('9') )
			nDigit = chDigit - _T('0');
		else if ( chDigit >= _T('A') && chDigit <= _T('F') )
			nDigit = chDigit - _T('A') + 10;

		if ( nDigit > ( nRadix - 1 ) )
		{
			// digit is not valid for the numbering system
			nResult = 0;
			break;
		}
		else
		{
			// shift over one magnitude and add new digit
			nResult *= nRadix;
			nResult += nDigit;
		}
		psz++;
	}

	return nResult;
}
Exemple #12
0
CFSWString DealWithText(CFSWString text) {
    /* Proovin kogu sõnniku minema loopida */
    CFSWString res;
    text.Trim();
    text.Replace(L"\n\n", L"\n", 1);    
    for (INTPTR i = 0; i < text.GetLength(); i++) {
        CFSWString c = text.GetAt(i);
        CFSWString pc = res.GetAt(res.GetLength() - 1);
        CFSWString nc = text.GetAt(i + 1);
        if (is_char(c)) res += c;
        else
            if (is_digit(c)) res += c;
        else
            if (is_hyphen(c) && is_char(pc) && is_char(nc)) res += sp;
        else
            if (is_symbol(c)) res += c;
        else
            if (is_colon(c) && !is_colon(pc)) res += c;
        else
            if (is_bbracket(c) && !is_bbracket(pc)) res += c;
        else
            if (is_ebracket(c) && is_ending(nc)) res += L"";
        else
            if (is_ebracket(c) && !is_ebracket(pc)) res += c;
        else
            if (is_comma(c) && !is_comma(pc)) res += c;
        else
            if (is_fchar(c)) res += replace_fchar(c);
        else
            if (is_space(c) && !is_whitespace(pc)) res += c;
        else
            if (is_break(c) && !is_break(pc)) { 
                
                res += c;   
            } //kahtlane
        else
            if (is_tab(c) && !is_whitespace(pc)) res += c;
        else
            if (is_ending(c) && !is_ending(pc) && !is_whitespace(pc)) res += c;

    }
    res.Trim();        
    return res;

}
Exemple #13
0
long
ctol(wchar_t *str)
{
	int sign;
	long num;

	while (is_space(*str))
		++str;
	num = 0;
	if (*str == '-') {
		sign = -1;
		++str;
	} else
		sign = 1;
	while (is_digit(*str))
		num = num*10 + *str++ - '0';
	return (sign * num);
}
Exemple #14
0
void	get_key_pressed(t_select *params)
{
	char	*key;

	key = ft_strnew(4);
	while (read(0, key, 3))
	{
		if (is_escape(key))
			break ;
		else if (is_space(key))
			space_key_pressed(params);
		else if (is_return(key))
			return_key_pressed(params);
		else if (is_arrow(key))
			arrow_key_pressed(key[2] - 64, params);
		ft_bzero(key, 4);
	}
}
Exemple #15
0
 int atoi(char s[])
 { int i, n, sign;

       for (i = 0; is_space(s[i]); i++)  /* skip white space */           ;

            sign = (s[i] == '-') ? -1 : 1;

        if (s[i] == '+' || s[i] == '-')  /* skip sign */

            i++;

       for (n = 0; is_digit(s[i]);i++)

            n = 10 * n + (s[i] - '0');

        return sign * n;

    }
Exemple #16
0
int str_ltrim(char* str)
{
	char* s = str;
	int len = 0;
	CHECK_NULL_TO_RETURN(str, -1);
	while (is_space(*s)) {
		s++;
	}
	if (*s) {
		len = (int)strlen(s);
		if (s != str) {
			memmove(str, s, len);
			str[len] = '\0';
		}
	} else
		str[0] = '\0';
	return 0;
}
Exemple #17
0
void pass_closed_expression()
{
	int d=0;
	do{
		if(get_tval()=="(") {
			++d;
			fprintf(OUTF,"(");
			try_lex();
		} else if(get_tval()==")") {
			--d;
			fprintf(OUTF,")");
			try_lex();
		} else {
			step();
			while(is_space(get_tid())) step();
		}
	} while(d || (get_tval()!="," && get_tval()!=")"));
}
Exemple #18
0
static int find_hf_value_param(struct hname_data* hname, str* param_area, str* value, str* lump_upd, str* lump_del) {
	int i, j, found;

	i = 0;
	while (1) {
		lump_del->s = param_area->s + i;
		for (; i < param_area->len && is_space(param_area->s[i]); i++);
		if (i < param_area->len && param_area->s[i] == ';') {	/* found a param ? */
			i++;
			for (; i < param_area->len && is_space(param_area->s[i]); i++);
			j = i;
			for (; i < param_area->len && !is_space(param_area->s[i]) && param_area->s[i]!='=' && param_area->s[i]!=';'; i++);

			found = hname->param.len == i-j && !strncasecmp(hname->param.s, param_area->s+j, i-j);
			lump_upd->s = param_area->s+i;
			value->s = param_area->s+i;
			value->len = 0;
			for (; i < param_area->len && is_space(param_area->s[i]); i++);
			if (i < param_area->len && param_area->s[i]=='=') {
				i++;
				for (; i < param_area->len && is_space(param_area->s[i]); i++);
				value->s = param_area->s+i;
				if (i < param_area->len) {
					if (param_area->s[i]=='\"') {
						i++;
						value->s++;
						for (; i<param_area->len; i++) {
							if (param_area->s[i]=='\"') {
								i++;
								break;
							}
							value->len++;
						}
					}
					else {
						for (; i<param_area->len && !is_space(param_area->s[i]) && param_area->s[i]!=';'; i++, value->len++);
					}
				}
			}
			if (found) {
				lump_del->len = param_area->s+i - lump_del->s;
				lump_upd->len = param_area->s+i - lump_upd->s;
				return 1;
			}
		}
		else { /* not found, return last correct position, should be end of param area */
			lump_del->len = 0;
			return 0;
		}
	}
}
inline int get_gap(struct ir_remote *remote, lirc_t gap)
{
	lirc_t data;

	logprintf(2, "sum: %d", rec_buffer.sum);
	data = get_next_rec_buffer(gap - gap * remote->eps / 100);
	if (data == 0)
		return (1);
	if (!is_space(data)) {
		logprintf(2, "space expected");
		return (0);
	}
	unget_rec_buffer(1);
	if (!expect_at_least(remote, data, gap)) {
		logprintf(1, "end of signal not found");
		return (0);
	}
	return (1);
}
int split_string(char const** tags, int buf_size, char* in)
{
    int ret = 0;
    char* i = in;
    for (; *i; ++i)
    {
        if (!is_print(*i) || is_space(*i))
        {
            *i = 0;
            if (ret == buf_size) return ret;
            continue;
        }
        if (i == in || i[-1] == 0)
        {
            tags[ret++] = i;
        }
    }
    return ret;
}
Exemple #21
0
void pass_case_or_scope()
{
	int d=0;
	do{
		if(get_tval()=="{") {
			++d;
			fprintf(OUTF,"{");
			try_lex();
		} else if(get_tval()=="}") {
			--d;
			fprintf(OUTF,"}");
			try_lex();
		} else {
			step();
			while(is_space(get_tid())) step();
		}
	} while(d || (get_tval()!="case" && get_tval()!="}"));

}
Exemple #22
0
Fichier : parser.c Projet : kube/RT
static int	count_indentation(char *line, int line_number)
{
	int		i;

	i = 0;
	while (is_space(line[i]))
	{
		if (line[i] != '\t')
		{
			ft_putstr_fd("Line ", 2);
			ft_putnbr_fd(line_number, 2);
			ft_putendl_fd(":\tERROR! Bad Indentation.", 2);
			exit(1);
		}
		else
			i++;
	}
	return (i);
}
Exemple #23
0
symbol *create_symbol (FILE *input, bool *eof, int *line)
{
	char c;
	int i = 0;
	char buffer [BUF_LEN];
	char *word;
	symbol *new_symbol;

	if ((c = skip_space (input, eof, line)) != EOF)
	{
		buffer [i++] = c;

		while (((c = get_char (input, eof)) != EOF) && (i < BUF_LEN))
		{
			if (is_space (c))
				break;

			buffer [i++] = c;
		}

		buffer [i++] = '\0';
	}

	if (i == 0)
	{
		word = "";
	}
	else
	{
		word = get_mem (i);
		strcpy (word, buffer);
	}

	new_symbol = get_mem (sizeof (symbol));

	new_symbol->word = word;
	new_symbol->line = (*line);

	if ((c == '\n') || (c == '\f'))
		++(*line);

	return (new_symbol);
}
Exemple #24
0
string
xml_html_parser::finalize_space (string s, bool first, bool last) {
  int i, n= N(s);
  string r;
  bool flag= first;
  for (i=0; i<n; i++)
    if (is_space (s[i])) {
      if (!flag) r << ' ';
      flag= true;
    }
    else {
      r << s[i];
      flag= false;
    }
  n= N(r);
  if (last && (n>0) && (r[n-1] == ' '))
    r->resize (n-1);
  return r;
}
Exemple #25
0
char	*without_quotes(char **line)
{
  char	*res;
  int	len, i;

  for (len = 0; (!is_space((*line)[len])) &&
	 ((*line)[len] != ',') &&
	 ((*line)[len] != ']'); len++) ;
  if (((*line)[len] == ',') || ((*line)[len] == ']'))
     len++;
  res = xmalloc(sizeof (char) * len + 2);
  for (i = 0; i < len; i++)
    res[i] = (*line)[i];
  if ((*line)[len])
    *line = &((*line)[len]);
  else
    *line = NULL;
  res[i] = '\0';
  return (res);
}
Exemple #26
0
/* aTof: convert string s to double */
double aTof(const char *s)
{
	int sign;
	double val, power;

	while (is_space(*s))
		++s;
	sign = (*s == '-') ? -1 : 1;
	if (*s == '+' || *s == '-')
		++s;
	for (val = 0.0; is_digit(*s); ++s)
		val = 10.0 * val + (*s - '0');
	if (*s == '.')
		++s;
	for (power = 1.0; is_digit(*s); ++s) {
		val = 10.0 * val + (*s - '0');
		power *= 10.0;
	}
	return sign * val / power;
}
Exemple #27
0
long			ft_atol(const char *str)
{
	int		sign;
	long	result;

	result = 0;
	while (is_space(*str))
		str++;
	sign = 1;
	if (*str == '+')
		str++;
	else if (*str == '-')
	{
		sign = -1;
		str++;
	}
	while (*str >= '0' && *str <= '9')
		result = result * 10 + (*str++ - '0');
	return (sign * result);
}
Exemple #28
0
inline int get_gap(struct ir_remote *remote,lirc_t gap)
{
	lirc_t data;
	
	LOGPRINTF(2,"sum: %ld",rec_buffer.sum);
	data=get_next_rec_buffer(gap*(100-remote->eps)/100);
	if(data==0) return(1);
	if(!is_space(data))
	{
		LOGPRINTF(2,"space expected");
		return(0);
	}
	unget_rec_buffer(1);
	if(data<gap*(100-remote->eps)/100 &&
	   data<gap-remote->aeps)
	{
		LOGPRINTF(1,"end of signal not found");
		return(0);
	}
	return(1);	
}
char*
bib_first_char (tree t) {
  if (is_atomic (t)) {
    string s= t->label;
    int beg= 0;
    while ((beg < N(s)) && is_space (s[beg])) beg++;
    if (beg < N(s)) return &(s[beg]);
    else return 0;
  }
  else if (is_compound (t, "verbatim"))
    return 0;
  else if (is_func (t, WITH, 3) && t[0] == FONT_FAMILY && t[1] == "tt")
    return 0;
  else {
    int pos= 0;
    if (L(t) == WITH) pos= N(t)-1;
    else while ((pos < N(t)) && bib_is_bad (t[pos])) pos++;
    if (pos < N(t)) return bib_first_char (t[pos]);
    else return 0;
  }
}
Exemple #30
0
////////////////////
// Function name	: AnyOneArg
// Description	    : 공백 단위로 문자열 토큰화
// Return type		: char*
//					: 다음 토큰 위치
// Argument         : char* argument
//					: 원본 문자열
// Argument         : char* first_arg
//					: 토큰화된 문자열을 담을 곧
// Argument         : bool toLower
//					: 소문자로 강제 변환할지 여부
const char* AnyOneArg(const char* argument, char* first_arg, bool toLower)
{
    argument = SkipSpaces(argument);

    while (argument && *argument && !is_space(*argument))
    {
        if (toLower)
        {
            *(first_arg++) = LOWER(*argument);
        }
        else
        {
            *(first_arg++) = *argument;
        }
        argument++;
    }

    *first_arg = '\0';

    return (argument);
}