• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cast_uchar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cast_uchar函数的典型用法代码示例。如果您正苦于以下问题:C++ cast_uchar函数的具体用法?C++ cast_uchar怎么用?C++ cast_uchar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cast_uchar函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: readhexa

static lua_Number readhexa (const char **s, lua_Number r, int *count) {
  for (; lisxdigit(cast_uchar(**s)); (*s)++) {  /* read integer part */
    r = (r * cast_num(16.0)) + cast_num(luaO_hexavalue(cast_uchar(**s)));
    (*count)++;
  }
  return r;
}
开发者ID:chongpeixiang,项目名称:drill,代码行数:7,代码来源:lobject.c


示例2: lua_strx2number

/*
** convert an hexadecimal numeric string to a number, following
** C99 specification for 'strtod'
*/
static lua_Number lua_strx2number (const char *s, char **endptr) {
  lua_Number r = 0.0;  /* result (accumulator) */
  int sigdig = 0;  /* number of significant digits */
  int nosigdig = 0;  /* number of non-significant digits */
  int e = 0;  /* exponent correction */
  int neg = 0;  /* 1 if number is negative */
  int dot = 0;  /* true after seen a dot */
  *endptr = cast(char *, s);  /* nothing is valid yet */
  while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */
  neg = isneg(&s);  /* check signal */
  if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')))  /* check '0x' */
    return 0.0;  /* invalid format (no '0x') */
  for (s += 2; ; s++) {  /* skip '0x' and read numeral */
    if (*s == '.') {
      if (dot) break;  /* second dot? stop loop */
      else dot = 1;
    }
    else if (lisxdigit(cast_uchar(*s))) {
      if (sigdig == 0 && *s == '0') {  /* non-significant zero? */
        nosigdig++;
        if (dot) e--;  /* zero after dot? correct exponent */
      }
      else {
        if (++sigdig <= MAXSIGDIG) {  /* can read it without overflow? */
          r = (r * cast_num(16.0)) + luaO_hexavalue(cast_uchar(*s));
          if (dot) e--;  /* decimal digit */
        }
        else  /* too many digits; ignore */ 
          if (!dot) e++;  /* still count it for exponent */
      }
    }
    else break;  /* neither a dot nor a digit */
  }
  if (nosigdig + sigdig == 0)  /* no digits? */
    return 0.0;  /* invalid format */
  *endptr = cast(char *, s);  /* valid up to here */
  e *= 4;  /* each digit multiplies/divides value by 2^4 */
  if (*s == 'p' || *s == 'P') {  /* exponent part? */
    int exp1 = 0;  /* exponent value */
    int neg1;  /* exponent signal */
    s++;  /* skip 'p' */
    neg1 = isneg(&s);  /* signal */
    if (!lisdigit(cast_uchar(*s)))
      return 0.0;  /* invalid; must have at least one digit */
    while (lisdigit(cast_uchar(*s)))  /* read exponent */
      exp1 = exp1 * 10 + *(s++) - '0';
    if (neg1) exp1 = -exp1;
    e += exp1;
    *endptr = cast(char *, s);  /* valid up to here */
  }
开发者ID:2ion,项目名称:lua-column,代码行数:54,代码来源:lobject.c


示例3: if

char *tempnam(const char *dir, const char *pfx)
{
	static int counter = 0;
	unsigned char *d, *s, *a;
	int l;
	if (!(d = cast_uchar getenv("TMPDIR"))) {
		if (dir) d = cast_uchar dir;
		else if (!(d = cast_uchar getenv("TMP")) && !(d = cast_uchar getenv("TEMP"))) {
#ifdef P_tmpdir
			d = cast_uchar(P_tmpdir);
#else
			d = cast_uchar "/tmp";
#endif
		}
	}
	l = 0;
	s = init_str();
	add_to_str(&s, &l, d);
	if (s[0] && s[strlen(cast_const_char s) - 1] != '/') add_chr_to_str(&s, &l, '/');
	add_to_str(&s, &l, cast_uchar pfx);
	add_num_to_str(&s, &l, counter++);
	a = cast_uchar strdup(cast_const_char s);
	mem_free(s);
	return cast_char a;
}
开发者ID:JamesLinus,项目名称:LiteBSD-Ports,代码行数:25,代码来源:fn_impl.c


示例4: luaZ_fill

int luaZ_fill (ZIO *z) {
  size_t size;
  terra_State *T = z->L;
  const char *buff;
  buff = z->reader(T->L, z->data, &size);
  if (buff == NULL || size == 0)
    return EOZ;
  z->n = size - 1;  /* discount char being returned */
  z->p = buff;
  return cast_uchar(*(z->p++));
}
开发者ID:2php,项目名称:terra,代码行数:11,代码来源:lzio.cpp


示例5: luaO_str2d

int luaO_str2d (const char *s, size_t len, lua_Number *result) {
  char *endptr;
  if (strpbrk(s, "nN"))  /* reject 'inf' and 'nan' */
    return 0;
  else if (strpbrk(s, "xX"))  /* hexa? */
    *result = lua_strx2number(s, &endptr);
  else
    *result = lua_str2number(s, &endptr);
  if (endptr == s) return 0;  /* nothing recognized */
  while (lisspace(cast_uchar(*endptr))) endptr++;
  return (endptr == s + len);  /* OK if no trailing characters */
}
开发者ID:chongpeixiang,项目名称:drill,代码行数:12,代码来源:lobject.c


示例6: lua_strx2number

/*
** convert an hexadecimal numeric string to a number, following
** C99 specification for 'strtod'
*/
static lua_Number lua_strx2number (const char *s, char **endptr) {
  lua_Number r = 0.0;
  int e = 0, i = 0;
  int neg = 0;  /* 1 if number is negative */
  *endptr = cast(char *, s);  /* nothing is valid yet */
  while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */
  neg = isneg(&s);  /* check signal */
  if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')))  /* check '0x' */
    return 0.0;  /* invalid format (no '0x') */
  s += 2;  /* skip '0x' */
  r = readhexa(&s, r, &i);  /* read integer part */
  if (*s == '.') {
    s++;  /* skip dot */
    r = readhexa(&s, r, &e);  /* read fractional part */
  }
  if (i == 0 && e == 0)
    return 0.0;  /* invalid format (no digit) */
  e *= -4;  /* each fractional digit divides value by 2^-4 */
  *endptr = cast(char *, s);  /* valid up to here */
  if (*s == 'p' || *s == 'P') {  /* exponent part? */
    int exp1 = 0;
    int neg1;
    s++;  /* skip 'p' */
    neg1 = isneg(&s);  /* signal */
    if (!lisdigit(cast_uchar(*s)))
      goto ret;  /* must have at least one digit */
    while (lisdigit(cast_uchar(*s)))  /* read exponent */
      exp1 = exp1 * 10 + *(s++) - '0';
    if (neg1) exp1 = -exp1;
    e += exp1;
  }
  *endptr = cast(char *, s);  /* valid up to here */
 ret:
  if (neg) r = -r;
  return l_mathop(ldexp)(r, e);
}
开发者ID:chongpeixiang,项目名称:drill,代码行数:40,代码来源:lobject.c


示例7: if

unsigned char *get_text_translation(unsigned char *text, struct terminal *term)
{
	unsigned char **current_tra;
	struct conv_table *conv_table;
	unsigned char *trn;
	int charset;
	if (!term) charset = 0;
	else if (term->spec) charset = term->spec->charset;
	else charset = utf8_table;
	if (is_direct_text(text)) return text;
	if ((current_tra = translation_array[current_language][charset])) {
		unsigned char *tt;
		if ((trn = current_tra[text - dummyarray])) return trn;
		tr:
		if (!(tt = cast_uchar translations[current_language].t[text - dummyarray].name)) {
			trn = cast_uchar translation_english[text - dummyarray].name;
		} else {
			struct document_options l_opt;
			memset(&l_opt, 0, sizeof(l_opt));
			l_opt.plain = 0;
			l_opt.cp = charset;
			conv_table = get_translation_table(current_lang_charset, charset);
			trn = convert_string(conv_table, tt, (int)strlen(cast_const_char tt), &l_opt);
			if (!strcmp(cast_const_char trn, cast_const_char tt)) {
				mem_free(trn);
				trn = tt;
			}
		}
		current_tra[text - dummyarray] = trn;
	} else {
		if (current_lang_charset && charset != current_lang_charset) {
			current_tra = translation_array[current_language][charset] = mem_alloc(sizeof (unsigned char **) * T__N_TEXTS);
			memset(current_tra, 0, sizeof (unsigned char **) * T__N_TEXTS);
			goto tr;
		}
		if (!(trn = cast_uchar translations[current_language].t[text - dummyarray].name)) {
			trn = cast_uchar(translations[current_language].t[text - dummyarray].name = translation_english[text - dummyarray].name);	/* modifying translation structure */
		}
	}
	return trn;
}
开发者ID:engine12,项目名称:links,代码行数:41,代码来源:language.c


示例8: lua_strb2number

static lua_Number lua_strb2number (const char *s, char **endptr) {
  lua_Number r = 0.0;
  int i = 0; int f = 0;
  *endptr = cast(char *, s);  /* nothing is valid yet */
  while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */
  if (!(*s == '0' && (*(s + 1) == 'b' || *(s + 1) == 'B')))  /* check '0b' */
    return 0.0;  /* invalid format (no '0b') */
  s += 2;  /* skip '0b' */
  while ((*s == '0') || (*s == '1'))
  {
	f = 0;
	r *= 2.0;
	if (*s == '1') r += 1.0;
	i++; s++;
	while (*s == '_') {s++; f = 1;}
  }
  if ((i == 0) || (f > 0))
    return 0.0;  /* invalid format */
  *endptr = cast(char *, s);  /* valid up to here */
  return r;
}
开发者ID:JohnHind,项目名称:Winsh.lua,代码行数:21,代码来源:lobject.c



注:本文中的cast_uchar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cat函数代码示例发布时间:2022-05-30
下一篇:
C++ cast_to_fptr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap