logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

duplocale.3p (4243B)


  1. '\" et
  2. .TH DUPLOCALE "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. duplocale
  12. \(em duplicate a locale object
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <locale.h>
  17. .P
  18. locale_t duplocale(locale_t \fIlocobj\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIduplocale\fR()
  23. function shall create a duplicate copy of the locale object referenced
  24. by the
  25. .IR locobj
  26. argument.
  27. .P
  28. If the
  29. .IR locobj
  30. argument is LC_GLOBAL_LOCALE,
  31. \fIduplocale\fR()
  32. shall create a new locale object containing a copy of the global locale
  33. determined by the
  34. \fIsetlocale\fR()
  35. function.
  36. .P
  37. The behavior is undefined if the
  38. .IR locobj
  39. argument is not a valid locale object handle.
  40. .SH "RETURN VALUE"
  41. Upon successful completion, the
  42. \fIduplocale\fR()
  43. function shall return a handle for a new locale object. Otherwise,
  44. \fIduplocale\fR()
  45. shall return (\c
  46. .BR locale_t )0
  47. and set
  48. .IR errno
  49. to indicate the error.
  50. .SH ERRORS
  51. The
  52. \fIduplocale\fR()
  53. function shall fail if:
  54. .TP
  55. .BR ENOMEM
  56. There is not enough memory available to create the locale object or
  57. load the locale data.
  58. .LP
  59. .IR "The following sections are informative."
  60. .SH EXAMPLES
  61. .SS "Constructing an Altered Version of an Existing Locale Object"
  62. .P
  63. The following example shows a code fragment to create a slightly
  64. altered version of an existing locale object. The function takes a
  65. locale object and a locale name and it replaces the
  66. .IR LC_TIME
  67. category data in the locale object with that from the named locale.
  68. .sp
  69. .RS 4
  70. .nf
  71. #include <locale.h>
  72. \&...
  73. .P
  74. locale_t
  75. with_changed_lc_time (locale_t obj, const char *name)
  76. {
  77. .P
  78. locale_t retval = duplocale (obj);
  79. if (retval != (locale_t) 0)
  80. {
  81. locale_t changed = newlocale (LC_TIME_MASK, name, retval);
  82. if (changed == (locale_t) 0)
  83. /* An error occurred. Free all allocated resources. */
  84. freelocale (retval);
  85. retval = changed;
  86. }
  87. return retval;
  88. }
  89. .fi
  90. .P
  91. .RE
  92. .SH "APPLICATION USAGE"
  93. The use of the
  94. \fIduplocale\fR()
  95. function is recommended for situations where a locale object is being
  96. used in multiple places, and it is possible that the lifetime of the
  97. locale object might end before all uses are finished. Another reason to
  98. duplicate a locale object is if a slightly modified form is needed.
  99. This can be achieved by a call to
  100. \fInewlocale\fR()
  101. following the
  102. \fIduplocale\fR()
  103. call.
  104. .P
  105. As with the
  106. \fInewlocale\fR()
  107. function, handles for locale objects created by the
  108. \fIduplocale\fR()
  109. function should be released by a corresponding call to
  110. \fIfreelocale\fR().
  111. .P
  112. The
  113. \fIduplocale\fR()
  114. function can also be used in conjunction with
  115. .IR uselocale ((\c
  116. .BR locale_t )0).
  117. This returns the locale in effect for the calling thread, but can have
  118. the value LC_GLOBAL_LOCALE. Passing LC_GLOBAL_LOCALE to functions such as
  119. \fIisalnum_l\fR()
  120. results in undefined behavior, but applications can convert it into a
  121. usable locale object by using
  122. \fIduplocale\fR().
  123. .SH RATIONALE
  124. None.
  125. .SH "FUTURE DIRECTIONS"
  126. None.
  127. .SH "SEE ALSO"
  128. .IR "\fIfreelocale\fR\^(\|)",
  129. .IR "\fInewlocale\fR\^(\|)",
  130. .IR "\fIuselocale\fR\^(\|)"
  131. .P
  132. The Base Definitions volume of POSIX.1\(hy2017,
  133. .IR "\fB<locale.h>\fP"
  134. .\"
  135. .SH COPYRIGHT
  136. Portions of this text are reprinted and reproduced in electronic form
  137. from IEEE Std 1003.1-2017, Standard for Information Technology
  138. -- Portable Operating System Interface (POSIX), The Open Group Base
  139. Specifications Issue 7, 2018 Edition,
  140. Copyright (C) 2018 by the Institute of
  141. Electrical and Electronics Engineers, Inc and The Open Group.
  142. In the event of any discrepancy between this version and the original IEEE and
  143. The Open Group Standard, the original IEEE and The Open Group Standard
  144. is the referee document. The original Standard can be obtained online at
  145. http://www.opengroup.org/unix/online.html .
  146. .PP
  147. Any typographical or formatting errors that appear
  148. in this page are most likely
  149. to have been introduced during the conversion of the source files to
  150. man page format. To report such errors, see
  151. https://www.kernel.org/doc/man-pages/reporting_bugs.html .