diff options
| author | Mike Pritchard <mpp@FreeBSD.org> | 1996-05-01 23:21:43 +0000 |
|---|---|---|
| committer | Mike Pritchard <mpp@FreeBSD.org> | 1996-05-01 23:21:43 +0000 |
| commit | 078f9c128762765ee873d2f02730339e4d4b6e54 (patch) | |
| tree | 7e4e1b5a841f7235dd04e4f248597c325baf9c62 /lib/libc | |
| parent | 21ce69b4581854fa4c25cf1517a66287c88779eb (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdio/fgets.3 | 17 | ||||
| -rw-r--r-- | lib/libc/stdio/fopen.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/fread.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/funopen.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/getc.3 | 8 | ||||
| -rw-r--r-- | lib/libc/stdio/mktemp.3 | 22 | ||||
| -rw-r--r-- | lib/libc/stdio/printf.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/scanf.3 | 4 | ||||
| -rw-r--r-- | lib/libc/stdio/stdio.3 | 22 | ||||
| -rw-r--r-- | lib/libc/stdio/tmpnam.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdlib/abort.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdlib/alloca.3 | 4 | ||||
| -rw-r--r-- | lib/libc/stdlib/exit.3 | 8 | ||||
| -rw-r--r-- | lib/libc/stdlib/random.3 | 13 | ||||
| -rw-r--r-- | lib/libc/stdlib/system.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdtime/ctime.3 | 5 | ||||
| -rw-r--r-- | lib/libc/stdtime/strftime.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdtime/time2posix.3 | 95 | ||||
| -rw-r--r-- | lib/libc/string/strcat.3 | 5 | ||||
| -rw-r--r-- | lib/libc/string/strerror.3 | 15 | ||||
| -rw-r--r-- | lib/libc/string/strspn.3 | 2 |
21 files changed, 137 insertions, 99 deletions
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3 index 827de6b51463..e1693828e6ee 100644 --- a/lib/libc/stdio/fgets.3 +++ b/lib/libc/stdio/fgets.3 @@ -53,7 +53,7 @@ The .Fn fgets function reads at most one less than the number of characters specified by -.Xr size +.Fa size from the given .Fa stream and stores them in the string @@ -61,7 +61,7 @@ and stores them in the string Reading stops when a newline character is found, at end-of-file or error. The newline, if any, is retained. -In any case a +If any characters are read and there is no error, a .Ql \e0 character is appended to end the string. .Pp @@ -71,7 +71,7 @@ function is equivalent to .Fn fgets with an infinite -.Xr size +.Fa size and a .Fa stream of @@ -87,14 +87,19 @@ and .Fn gets return a pointer to the string. -If end-of-file or an error occurs before any characters are read, +If end-of-file occurs before any characters are read, they return -.Dv NULL. +.Dv NULL +and the buffer contents is unchanged. +If an error occurs, +they return +.Dv NULL +and the buffer contents is indeterminate. The .Fn fgets and -functions .Fn gets +functions do not distinguish between end-of-file and error, and callers must use .Xr feof 3 and diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3 index 23d790c79a03..87bb0494e0ab 100644 --- a/lib/libc/stdio/fopen.3 +++ b/lib/libc/stdio/fopen.3 @@ -142,7 +142,7 @@ The original stream (if it exists) is closed. The .Fa mode argument is used just as in the -.Xr fopen +.Fn fopen function. The primary use of the .Fn freopen diff --git a/lib/libc/stdio/fread.3 b/lib/libc/stdio/fread.3 index 8dd65af6e779..03a91412bc88 100644 --- a/lib/libc/stdio/fread.3 +++ b/lib/libc/stdio/fread.3 @@ -54,7 +54,7 @@ The function reads .Fa nmemb objects, each -.Xr size +.Fa size bytes long, from the stream pointed to by .Fa stream , storing them at the location given by diff --git a/lib/libc/stdio/funopen.3 b/lib/libc/stdio/funopen.3 index 8ed9b3074a2b..dbdd5cab661b 100644 --- a/lib/libc/stdio/funopen.3 +++ b/lib/libc/stdio/funopen.3 @@ -44,7 +44,7 @@ .Sh SYNOPSIS .Fd #include <stdio.h> .Ft FILE * -.Fn funopen "void *cookie" "int (*readfn)(void *, char *, int)" "int (writefn*)(void *, const char *, int)" "fpos_t (seekfn*)(void *, fpos_t, int)" "int (closefn*)(void *)" +.Fn funopen "void *cookie" "int (*readfn)(void *, char *, int)" "int (*writefn)(void *, const char *, int)" "fpos_t (*seekfn)(void *, fpos_t, int)" "int (*closefn)(void *)" .Ft FILE * .Fn fropen "void *cookie" "int (*readfn)(void *, char *, int)" .Ft FILE * diff --git a/lib/libc/stdio/getc.3 b/lib/libc/stdio/getc.3 index de93a198438e..352f20baf7cc 100644 --- a/lib/libc/stdio/getc.3 +++ b/lib/libc/stdio/getc.3 @@ -61,7 +61,7 @@ function obtains the next input character (if present) from the stream pointed at by .Fa stream , or the next character pushed back on the stream via -.Xr ungetc . +.Xr ungetc 3 . .Pp The .Fn getc @@ -103,7 +103,7 @@ The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return .Dv EOF until the condition is cleared with -.Xr clearerr . +.Xr clearerr 3 . .Sh SEE ALSO .Xr ferror 3 , .Xr fread 3 , @@ -123,9 +123,9 @@ conform to Since .Dv EOF is a valid integer value, -.Xr feof +.Xr feof 3 and -.Xr ferror +.Xr ferror 3 must be used to check for failure after calling .Fn getw . The size and byte order of an diff --git a/lib/libc/stdio/mktemp.3 b/lib/libc/stdio/mktemp.3 index 361bebf685e0..28a662d11beb 100644 --- a/lib/libc/stdio/mktemp.3 +++ b/lib/libc/stdio/mktemp.3 @@ -124,6 +124,28 @@ may also set to any value specified by the .Xr open 2 function. +.Sh NOTES +A common problem that results in a core dump is that the programmer +passes in a read-only string to +.Fn mktemp +or +.Fn mkstemp . +This is common with programs that were developed before +.St -ansiC +compilers were common. +For example, calling +.Fn mkstemp +with an argument of +.Qq /tmp/tempfile.XXXXXX +will result in a core dump due to +.Fn mkstemp +attempting to modify the string constant that was given. +If the program in question makes heavy use of that type +of function call, you do have the option of compiling the program +so that it will store string constants in a writable segment of memory. +See +.Xr gcc 1 +for more information. .Sh SEE ALSO .Xr chmod 2 , .Xr getpid 2 , diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3 index cf64e1e80e99..4238a90a889e 100644 --- a/lib/libc/stdio/printf.3 +++ b/lib/libc/stdio/printf.3 @@ -228,7 +228,7 @@ For all conversions except .Cm n , the converted value is padded on the left with zeros rather than blanks. If a precision is given with a numeric conversion -.Pf ( Mc d , +.Pf ( Cm d , .Cm i , .Cm o , .Cm u , diff --git a/lib/libc/stdio/scanf.3 b/lib/libc/stdio/scanf.3 index 377a60262a41..dbfff8871273 100644 --- a/lib/libc/stdio/scanf.3 +++ b/lib/libc/stdio/scanf.3 @@ -200,7 +200,7 @@ the next pointer must be a pointer to .Em int . .It Cm D Equivalent to -.Xr ld ; +.Cm ld ; this exists only for backwards compatibility. .It Cm i Matches an optionally signed integer; @@ -221,7 +221,7 @@ the next pointer must be a pointer to .Em unsigned int . .It Cm O Equivalent to -.Xr lo ; +.Cm lo ; this exists for backwards compatibility. .It Cm u Matches an optionally signed decimal integer; diff --git a/lib/libc/stdio/stdio.3 b/lib/libc/stdio/stdio.3 index 09d7e36a4e50..7ebc782d06e3 100644 --- a/lib/libc/stdio/stdio.3 +++ b/lib/libc/stdio/stdio.3 @@ -151,7 +151,7 @@ function. The .Nm stdio library is a part of the library -.Xr libc +.Nm libc and routines are automatically loaded as needed by the compilers .Xr cc 1 and @@ -192,15 +192,15 @@ without first removing their current definitions with .Dv stdin , .Dv stdout . Function versions of the macro functions -.Xr feof , -.Xr ferror , -.Xr clearerr , -.Xr fileno , -.Xr getc , -.Xr getchar , -.Xr putc , +.Fn feof , +.Fn ferror , +.Fn clearerr , +.Fn fileno , +.Fn getc , +.Fn getchar , +.Fn putc , and -.Xr putchar +.Fn putchar exist and will be used if the macros definitions are explicitly removed. .Sh SEE ALSO @@ -211,9 +211,9 @@ definitions are explicitly removed. .Sh BUGS The standard buffered functions do not interact well with certain other library and system functions, especially -.Xr vfork +.Xr vfork 2 and -.Xr abort . +.Xr abort 3 . .Sh STANDARDS The .Nm stdio diff --git a/lib/libc/stdio/tmpnam.3 b/lib/libc/stdio/tmpnam.3 index 3b053ee20042..d7e032697614 100644 --- a/lib/libc/stdio/tmpnam.3 +++ b/lib/libc/stdio/tmpnam.3 @@ -201,7 +201,7 @@ Second, most historic implementations provide only a limited number of possible temporary file names (usually 26) before file names will start being recycled. Third, the System V implementations of these functions (and of -.Xr mktemp ) +.Xr mktemp 3 ) use the .Xr access 2 function to determine whether or not the temporary file may be created. diff --git a/lib/libc/stdlib/abort.3 b/lib/libc/stdlib/abort.3 index 83b4e04f6fde..7be4ee6b8248 100644 --- a/lib/libc/stdlib/abort.3 +++ b/lib/libc/stdlib/abort.3 @@ -61,7 +61,7 @@ function never returns. .Sh SEE ALSO .Xr sigaction 2 , -.Xr exit 2 +.Xr exit 3 .Sh STANDARDS The .Fn abort diff --git a/lib/libc/stdlib/alloca.3 b/lib/libc/stdlib/alloca.3 index ad5aaf694900..498348c51dfc 100644 --- a/lib/libc/stdlib/alloca.3 +++ b/lib/libc/stdlib/alloca.3 @@ -59,10 +59,10 @@ If the allocation failed, a pointer is returned. .Sh SEE ALSO .Xr brk 2 , -.Xr pagesize 2 .Xr calloc 3 , +.Xr getpagesize 3 , .Xr malloc 3 , -.Xr realloc 3 , +.Xr realloc 3 .Sh BUGS The .Fn alloca diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3 index 43ee3c04a795..8beca7c6fae8 100644 --- a/lib/libc/stdlib/exit.3 +++ b/lib/libc/stdlib/exit.3 @@ -65,6 +65,11 @@ Unlink all files created with the .Xr tmpfile 3 function. .El +.Pp +Passing arbitrary values back to the environment as +.Ar status +is considered bad style. Instead, use the values as described in +.Xr sysexits 3 . .Sh RETURN VALUES The .Fn exit @@ -74,7 +79,8 @@ never returns. .Xr _exit 2 , .Xr atexit 3 , .Xr intro 3 , -.Xr tmpfile 3 +.Xr tmpfile 3 , +.Xr sysexits 3 .Sh STANDARDS The .Fn exit diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index 84680e27b411..d1b8208d521b 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -64,11 +64,16 @@ The period of this random number generator is very large, approximately .if n 16*((2**31)\(mi1). .Pp The -.Fn random Ns / Fn srandom -have (almost) the same calling sequence and initialization properties as -.Xr rand 3 Ns / Xr srand 3 . +.Fn random +and +.Fn srandom +functions have (almost) the same calling sequence and initialization properties as the +.Xr rand 3 +and +.Xr srand 3 +functions. The difference is that -.Xr rand +.Xr rand 3 produces a much less random sequence \(em in fact, the low dozen bits generated by rand go through a cyclic pattern. All the bits generated by .Fn random diff --git a/lib/libc/stdlib/system.3 b/lib/libc/stdlib/system.3 index d89c79e25c15..44aaf0c863b8 100644 --- a/lib/libc/stdlib/system.3 +++ b/lib/libc/stdlib/system.3 @@ -76,7 +76,7 @@ The .Fn system function returns the exit status of the shell, or \-1 if the -.Xr wait 3 +.Xr wait 2 for the shell failed. A return value of 127 means the execution of the shell failed. diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3 index ff6a8efd5967..eccb664ce85c 100644 --- a/lib/libc/stdtime/ctime.3 +++ b/lib/libc/stdtime/ctime.3 @@ -46,7 +46,6 @@ .Nd transform binary date and time value to .Tn ASCII .Sh SYNOPSIS -.Fd #include <sys/types.h> .Fd #include <time.h> .Vt extern char *tzname[2]; .Ft char * @@ -89,9 +88,9 @@ environmental variable (see The function .Fn localtime uses -.Xr tzset +.Xr tzset 3 to initialize time conversion information if -.Xr tzset +.Xr tzset 3 has not already been called by the process. .Pp After filling in the tm structure, diff --git a/lib/libc/stdtime/strftime.3 b/lib/libc/stdtime/strftime.3 index b0647b3b1521..6f4a86b9bed9 100644 --- a/lib/libc/stdtime/strftime.3 +++ b/lib/libc/stdtime/strftime.3 @@ -42,9 +42,7 @@ .Nm strftime .Nd format date and time .Sh SYNOPSIS -.Fd #include <sys/types.h> .Fd #include <time.h> -.Fd #include <string.h> .Ft size_t .Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" .Sh DESCRIPTION diff --git a/lib/libc/stdtime/time2posix.3 b/lib/libc/stdtime/time2posix.3 index 846a52ed1931..6715eeb9ef43 100644 --- a/lib/libc/stdtime/time2posix.3 +++ b/lib/libc/stdtime/time2posix.3 @@ -1,29 +1,25 @@ -.TH TIME2POSIX 3 -.SH NAME -time2posix, posix2time \- convert seconds since the Epoch -.SH SYNOPSIS -.nf -.B #include <sys/types.h> -.B #include <time.h> -.PP -.B time_t time2posix(t) -.B time_t t -.PP -.B time_t posix2time(t) -.B time_t t -.PP -.B cc ... -lz -.fi -.SH DESCRIPTION -IEEE Standard 1003.1 -(POSIX) +.Dd May 1, 1996 +.Dt TIME2POSIX 3 +.Os +.Sh NAME +.Nm time2posix , +.Nm posix2time +.Nd convert seconds since the Epoch +.Sh SYNOPSIS +.Fd #include <time.h> +.Ft time_t +.Fn time2posix "const time_t *t" +.Ft time_t +.Fn posix2time "const time_t *t" +.Sh DESCRIPTION +.St -p1003.1-88 legislates that a time_t value of 536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986." This effectively implies that POSIX time_t's cannot include leap seconds and, therefore, that the system time must be adjusted as each leap occurs. -.PP +.Pp If the time package is configured with leap-second support enabled, however, @@ -32,19 +28,20 @@ time_t values continue to increase over leap events (as a true `seconds since...' value). This means that these values will differ from those required by POSIX by the net number of leap seconds inserted since the Epoch. -.PP +.Pp Typically this is not a problem as the type time_t is intended to be (mostly) opaque\(emtime_t values should only be obtained-from and passed-to functions such as -.IR time(2) , -.IR localtime(3) , -.IR mktime(3) , +.Xr time 2 , +.Xr localtime 3 , +.Xr mktime 3 and -.IR difftime(3) . +.Xr difftime 3 . However, -POSIX gives an arithmetic +.Std -p1003.1-88 +gives an arithmetic expression for directly computing a time_t value from a given date/time, and the same relationship is assumed by some (usually older) @@ -52,11 +49,11 @@ applications. Any programs creating/dissecting time_t's using such a relationship will typically not handle intervals over leap seconds correctly. -.PP +.Pp The -.I time2posix +.Fn time2posix and -.I posix2time +.Fn posix2time functions are provided to address this time_t mismatch by converting between local time_t values and their POSIX equivalents. This is done by accounting for the number of time-base changes that @@ -65,26 +62,27 @@ or deleted. These converted values can then be used in lieu of correcting the older applications, or when communicating with POSIX-compliant systems. -.PP -.I Time2posix -is single-valued. +.Pp +The +.Fn time2posix +function is single-valued. That is, every local time_t corresponds to a single POSIX time_t. -.I Posix2time -is less well-behaved: +The +.Fn posix2time +function is less well-behaved: for a positive leap second hit the result is not unique, and for a negative leap second hit the corresponding POSIX time_t doesn't exist so an adjacent value is returned. Both of these are good indicators of the inferiority of the POSIX representation. -.PP -The following table summarizes the relationship between a time -T and it's conversion to, +.Pp +The following table summarizes the relationship between a time_t +nd it's conversion to, and back from, the POSIX representation over the leap second inserted at the end of June, 1993. -.nf .ta \w'93/06/30 'u +\w'23:59:59 'u +\w'A+0 'u +\w'X=time2posix(T) 'u DATE TIME T X=time2posix(T) posix2time(X) 93/06/30 23:59:59 A+0 B+0 A+0 @@ -98,22 +96,19 @@ DATE TIME T X=time2posix(T) posix2time(X) ??/06/30 23:59:58 A+0 B+0 A+0 ??/07/01 00:00:00 A+1 B+2 A+1 ??/07/01 00:00:01 A+2 B+3 A+2 -.sp -.ce +.Pp [Note: posix2time(B+1) => A+0 or A+1] -.fi -.PP +.Pp If leap-second support is not enabled, local time_t's and POSIX time_t's are equivalent, and both -.I time2posix +.Fn time2posix and -.I posix2time +.Fn posix2time degenerate to the identity function. -.SH SEE ALSO -difftime(3), -localtime(3), -mktime(3), -time(2) -.\" @(#)time2posix.3 7.3 +.Sh "SEE ALSO" +.Xr difftime 3 , +.Xr localtime 3 , +.Xr mktime 3 , +.Xr time 3 diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3 index 6fe13aa691c3..0d34d58a47e0 100644 --- a/lib/libc/string/strcat.3 +++ b/lib/libc/string/strcat.3 @@ -68,7 +68,10 @@ The function appends not more than .Fa count -characters. +characters from +.Fa append , +and then adds a terminating +.Ql \e0. .Sh RETURN VALUES The .Fn strcat diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index 784c06168ada..ebf18fda1792 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -48,8 +48,8 @@ .Fd #include <stdio.h> .Ft void .Fn perror "const char *string" -.Vt extern char *sys_errlist[]; -.Vt extern int sys_nerr; +.Vt extern const char * const sys_errlist[]; +.Vt extern const int sys_nerr; .Fd #include <string.h> .Ft char * .Fn strerror "int errnum" @@ -100,11 +100,11 @@ followed by the error number in decimal. .Pp The message strings can be accessed directly using the external array -.Fa sys_errlist . +.Va sys_errlist . The external value -.Fa sys_nerr +.Va sys_nerr contains a count of the messages in -.Fa sys_errlist . +.Va sys_errlist . The use of these variables is deprecated; .Fn strerror should be used instead. @@ -122,3 +122,8 @@ For unknown error numbers, the .Fn strerror function will return its result in a static buffer which may be overwritten by subsequent calls. +.Pp +Programs that use the deprecated +.Va sys_errlist +variable often fail to compile because they declare it +inconsistently. diff --git a/lib/libc/string/strspn.3 b/lib/libc/string/strspn.3 index 04c4bdc3ae61..e96cbebab8a1 100644 --- a/lib/libc/string/strspn.3 +++ b/lib/libc/string/strspn.3 @@ -47,7 +47,7 @@ .Fn strspn "const char *s" "const char *charset" .Sh DESCRIPTION The -.Fn strcspn +.Fn strspn function spans the initial part of the null-terminated string .Fa s |
