Ejemplo n.º 1
0
int __numeric_load_locale (struct __locale_t *locale, const char *name ,
		       void *f_wctomb, const char *charset)
{
  int ret = 0;
  struct lc_numeric_T nm;
  char *bufp = NULL;

#ifdef __CYGWIN__
  extern int __set_lc_numeric_from_win (const char *,
					const struct lc_numeric_T *,
					struct lc_numeric_T *, char **,
					void *, const char *);
  ret = __set_lc_numeric_from_win (name, &_C_numeric_locale, &nm, &bufp,
				   f_wctomb, charset);
  /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
  if (ret >= 0)
    {
      struct lc_numeric_T *nmp = NULL;

      if (ret > 0)
	{
	  nmp = (struct lc_numeric_T *) calloc (1, sizeof *nmp);
	  if (!nmp)
	    {
	      free (bufp);
	      return -1;
	    }
	  *nmp = nm;
	}
      struct __lc_cats tmp = locale->lc_cat[LC_NUMERIC];
      locale->lc_cat[LC_NUMERIC].ptr = ret == 0 ? &_C_numeric_locale : nmp;
      locale->lc_cat[LC_NUMERIC].buf = bufp;
      /* If buf is not NULL, both pointers have been alloc'ed */
      if (tmp.buf)
	{
	  free ((void *) tmp.ptr);
	  free (tmp.buf);
	}
      ret = 0;
    }
#else
	/* TODO */
	_CRT_UNUSED(bufp);
	_CRT_UNUSED(nm);
	_CRT_UNUSED(locale);
	_CRT_UNUSED(name);
	_CRT_UNUSED(f_wctomb);
	_CRT_UNUSED(charset);
#endif
  return ret;
}
Ejemplo n.º 2
0
int
__numeric_load_locale(const char *name , void *f_wctomb, const char *charset)
{
	int ret;

#ifdef __CYGWIN__
	extern int __set_lc_numeric_from_win (const char *,
					      const struct lc_numeric_T *,
					      struct lc_numeric_T *, char **,
					      void *, const char *);
	int old_numeric_using_locale = _numeric_using_locale;
	_numeric_using_locale = 0;
	ret = __set_lc_numeric_from_win (name, &_C_numeric_locale,
					 &_numeric_locale, &_numeric_locale_buf,
					 f_wctomb, charset);
	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
	if (ret < 0)
	  _numeric_using_locale = old_numeric_using_locale;
	else
	  {
	    _numeric_using_locale = ret;
	    __nlocale_changed = 1;
	    ret = 0;
	  }
#else
	__nlocale_changed = 1;
	ret = __part_load_locale(name, &_numeric_using_locale,
		_numeric_locale_buf, "LC_NUMERIC",
		LCNUMERIC_SIZE, LCNUMERIC_SIZE,
		(const char **)&_numeric_locale);
	if (ret == 0 && _numeric_using_locale)
		_numeric_locale.grouping =
			__fix_locale_grouping_str(_numeric_locale.grouping);
#endif
	return ret;
}