⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcigettext.c

📁 磁盘管理工具,主要管理光盘信息和内容希望大家喜欢
💻 C
📖 第 1 页 / 共 4 页
字号:
		  size_t inleft = resultlen;		  char *outptr = (char *) outbuf;		  size_t outleft;		  if (freemem_size < sizeof (size_t))		    goto resize_freemem;		  outleft = freemem_size - sizeof (size_t);		  if (iconv (convd->conv,			     (ICONV_CONST char **) &inptr, &inleft,			     &outptr, &outleft)		      != (size_t) (-1))		    {		      outbuf = (unsigned char *) outptr;		      break;		    }		  if (errno != E2BIG)		    {		      __libc_lock_unlock (lock);		      return NULL;		    }#  endif# endif		resize_freemem:		  /* We must allocate a new buffer or resize the old one.  */		  if (malloc_count > 0)		    {		      ++malloc_count;		      freemem_size = malloc_count * INITIAL_BLOCK_SIZE;		      newmem = (transmem_block_t *) realloc (transmem_list,							     freemem_size);# ifdef _LIBC		      if (newmem != NULL)			transmem_list = transmem_list->next;		      else			{			  struct transmem_list *old = transmem_list;			  transmem_list = transmem_list->next;			  free (old);			}# endif		    }		  else		    {		      malloc_count = 1;		      freemem_size = INITIAL_BLOCK_SIZE;		      newmem = (transmem_block_t *) malloc (freemem_size);		    }		  if (__builtin_expect (newmem == NULL, 0))		    {		      freemem = NULL;		      freemem_size = 0;		      __libc_lock_unlock (lock);		      return (char *) -1;		    }# ifdef _LIBC		  /* Add the block to the list of blocks we have to free		     at some point.  */		  newmem->next = transmem_list;		  transmem_list = newmem;		  freemem = (unsigned char *) newmem->data;		  freemem_size -= offsetof (struct transmem_list, data);# else		  transmem_list = newmem;		  freemem = newmem;# endif		  outbuf = freemem + sizeof (size_t);		}	      /* We have now in our buffer a converted string.  Put this		 into the table of conversions.  */	      *(size_t *) freemem = outbuf - freemem - sizeof (size_t);	      convd->conv_tab[act] = (char *) freemem;	      /* Shrink freemem, but keep it aligned.  */	      freemem_size -= outbuf - freemem;	      freemem = outbuf;	      freemem += freemem_size & (alignof (size_t) - 1);	      freemem_size = freemem_size & ~ (alignof (size_t) - 1);	      __libc_lock_unlock (lock);	    }	  /* Now convd->conv_tab[act] contains the translation of all	     the plural variants.  */	  result = convd->conv_tab[act] + sizeof (size_t);	  resultlen = *(size_t *) convd->conv_tab[act];	}    }  /* The result string is converted.  */#endif /* _LIBC || HAVE_ICONV */  *lengthp = resultlen;  return result;}/* Look up a plural variant.  */static char *internal_functionplural_lookup (struct loaded_l10nfile *domain, unsigned long int n,	       const char *translation, size_t translation_len){  struct loaded_domain *domaindata = (struct loaded_domain *) domain->data;  unsigned long int index;  const char *p;  index = plural_eval (domaindata->plural, n);  if (index >= domaindata->nplurals)    /* This should never happen.  It means the plural expression and the       given maximum value do not match.  */    index = 0;  /* Skip INDEX strings at TRANSLATION.  */  p = translation;  while (index-- > 0)    {#ifdef _LIBC      p = __rawmemchr (p, '\0');#else      p = strchr (p, '\0');#endif      /* And skip over the NUL byte.  */      p++;      if (p >= translation + translation_len)	/* This should never happen.  It means the plural expression	   evaluated to a value larger than the number of variants	   available for MSGID1.  */	return (char *) translation;    }  return (char *) p;}#ifndef _LIBC/* Return string representation of locale CATEGORY.  */static const char *internal_functioncategory_to_name (int category){  const char *retval;  switch (category)  {#ifdef LC_COLLATE  case LC_COLLATE:    retval = "LC_COLLATE";    break;#endif#ifdef LC_CTYPE  case LC_CTYPE:    retval = "LC_CTYPE";    break;#endif#ifdef LC_MONETARY  case LC_MONETARY:    retval = "LC_MONETARY";    break;#endif#ifdef LC_NUMERIC  case LC_NUMERIC:    retval = "LC_NUMERIC";    break;#endif#ifdef LC_TIME  case LC_TIME:    retval = "LC_TIME";    break;#endif#ifdef LC_MESSAGES  case LC_MESSAGES:    retval = "LC_MESSAGES";    break;#endif#ifdef LC_RESPONSE  case LC_RESPONSE:    retval = "LC_RESPONSE";    break;#endif#ifdef LC_ALL  case LC_ALL:    /* This might not make sense but is perhaps better than any other       value.  */    retval = "LC_ALL";    break;#endif  default:    /* If you have a better idea for a default value let me know.  */    retval = "LC_XXX";  }  return retval;}#endif/* Guess value of current locale from value of the environment variables   or system-dependent defaults.  */static const char *internal_function#ifdef IN_LIBGLOCALEguess_category_value (int category, const char *categoryname,		      const char *locale)#elseguess_category_value (int category, const char *categoryname)#endif{  const char *language;#ifndef IN_LIBGLOCALE  const char *locale;# ifndef _LIBC  const char *language_default;  int locale_defaulted;# endif#endif  /* We use the settings in the following order:     1. The value of the environment variable 'LANGUAGE'.  This is a GNU        extension.  Its value can be a colon-separated list of locale names.     2. The value of the environment variable 'LC_ALL', 'LC_xxx', or 'LANG'.        More precisely, the first among these that is set to a non-empty value.        This is how POSIX specifies it.  The value is a single locale name.     3. A system-dependent preference list of languages.  Its value can be a        colon-separated list of locale names.     4. A system-dependent default locale name.     This way:       - System-dependent settings can be overridden by environment variables.       - If the system provides both a list of languages and a default locale,         the former is used.  */#ifndef IN_LIBGLOCALE  /* Fetch the locale name, through the POSIX method of looking to `LC_ALL',     `LC_xxx', and `LANG'.  On some systems this can be done by the     `setlocale' function itself.  */# ifdef _LIBC  locale = __current_locale_name (category);# else#  if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS  /* The __names field is not public glibc API and must therefore not be used     in code that is installed in public locations.  */  locale_t thread_locale = uselocale (NULL);  if (thread_locale != LC_GLOBAL_LOCALE)    {      locale = thread_locale->__names[category];      locale_defaulted = 0;    }  else#  endif    {      locale = _nl_locale_name_posix (category, categoryname);      locale_defaulted = 0;      if (locale == NULL)	{	  locale = _nl_locale_name_default ();	  locale_defaulted = 1;	}    }# endif#endif  /* Ignore LANGUAGE and its system-dependent analogon if the locale is set     to "C" because     1. "C" locale usually uses the ASCII encoding, and most international	messages use non-ASCII characters. These characters get displayed	as question marks (if using glibc's iconv()) or as invalid 8-bit	characters (because other iconv()s refuse to convert most non-ASCII	characters to ASCII). In any case, the output is ugly.     2. The precise output of some programs in the "C" locale is specified	by POSIX and should not depend on environment variables like	"LANGUAGE" or system-dependent information.  We allow such programs        to use gettext().  */  if (strcmp (locale, "C") == 0)    return locale;  /* The highest priority value is the value of the 'LANGUAGE' environment     variable.  */  language = getenv ("LANGUAGE");  if (language != NULL && language[0] != '\0')    return language;#if !defined IN_LIBGLOCALE && !defined _LIBC  /* The next priority value is the locale name, if not defaulted.  */  if (locale_defaulted)    {      /* The next priority value is the default language preferences list. */      language_default = _nl_language_preferences_default ();      if (language_default != NULL)        return language_default;    }  /* The least priority value is the locale name, if defaulted.  */#endif  return locale;}#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE/* Returns the output charset.  */static const char *internal_functionget_output_charset (struct binding *domainbinding){  /* The output charset should normally be determined by the locale.  But     sometimes the locale is not used or not correctly set up, so we provide     a possibility for the user to override this: the OUTPUT_CHARSET     environment variable.  Moreover, the value specified through     bind_textdomain_codeset overrides both.  */  if (domainbinding != NULL && domainbinding->codeset != NULL)    return domainbinding->codeset;  else    {      /* For speed reasons, we look at the value of OUTPUT_CHARSET only	 once.  This is a user variable that is not supposed to change	 during a program run.  */      static char *output_charset_cache;      static int output_charset_cached;      if (!output_charset_cached)	{	  const char *value = getenv ("OUTPUT_CHARSET");	  if (value != NULL && value[0] != '\0')	    {	      size_t len = strlen (value) + 1;	      char *value_copy = (char *) malloc (len);	      if (value_copy != NULL)		memcpy (value_copy, value, len);	      output_charset_cache = value_copy;	    }	  output_charset_cached = 1;	}      if (output_charset_cache != NULL)	return output_charset_cache;      else	{# ifdef _LIBC	  return _NL_CURRENT (LC_CTYPE, CODESET);# else#  if HAVE_ICONV	  extern const char *locale_charset (void);	  return locale_charset ();#  endif# endif	}    }}#endif/* @@ begin of epilog @@ *//* We don't want libintl.a to depend on any other library.  So we   avoid the non-standard function stpcpy.  In GNU C Library this   function is available, though.  Also allow the symbol HAVE_STPCPY   to be defined.  */#if !_LIBC && !HAVE_STPCPYstatic char *stpcpy (char *dest, const char *src){  while ((*dest++ = *src++) != '\0')    /* Do nothing. */ ;  return dest - 1;}#endif#if !_LIBC && !HAVE_MEMPCPYstatic void *mempcpy (void *dest, const void *src, size_t n){  return (void *) ((char *) memcpy (dest, src, n) + n);}#endif#ifdef _LIBC/* If we want to free all resources we have to do some work at   program's end.  */libc_freeres_fn (free_mem){  void *old;  while (_nl_domain_bindings != NULL)    {      struct binding *oldp = _nl_domain_bindings;      _nl_domain_bindings = _nl_domain_bindings->next;      if (oldp->dirname != _nl_default_dirname)	/* Yes, this is a pointer comparison.  */	free (oldp->dirname);      free (oldp->codeset);      free (oldp);    }  if (_nl_current_default_domain != _nl_default_default_domain)    /* Yes, again a pointer comparison.  */    free ((char *) _nl_current_default_domain);  /* Remove the search tree with the known translations.  */  __tdestroy (root, free);  root = NULL;  while (transmem_list != NULL)    {      old = transmem_list;      transmem_list = transmem_list->next;      free (old);    }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -