Re: strtod / strtol patch for POSIX module
[p5sagit/p5-mst-13.2.git] / ext / POSIX / POSIX.pod
index 2549a61..7dee4a3 100644 (file)
@@ -849,10 +849,30 @@ setjmp() is C-specific: use eval {} instead.
 
 Modifies and queries program's locale.
 
-The following will set the traditional UNIX system locale behavior.
+The following will set the traditional UNIX system locale behavior
+(the second argument C<"C">).
 
        $loc = POSIX::setlocale( &POSIX::LC_ALL, "C" );
 
+The following will query (the missing second argument) the current
+LC_CTYPE category.
+
+       $loc = POSIX::setlocale( &POSIX::LC_CTYPE);
+
+The following will set the LC_CTYPE behaviour according to the locale
+environment variables (the second argument C<"">).
+Please see your systems L<setlocale(3)> documentation for the locale
+environment variables' meaning or consult L<perli18n>.
+
+       $loc = POSIX::setlocale( &POSIX::LC_CTYPE, "");
+
+The following will set the LC_COLLATE behaviour to Argentinian
+Spanish. B<NOTE>: The naming and availability of locales depends on
+your operating system. Please consult L<perli18n> for how to find
+out which locales are available in your system.
+
+       $loc = POSIX::setlocale( &POSIX::LC_ALL, "es_AR.ISO8859-1" );
+
 =item setpgid
 
 This is similar to the C function C<setpgid()>.
@@ -1040,7 +1060,26 @@ This is identical to Perl's builtin C<index()> function.
 
 =item strtod
 
-strtod() is C-specific.
+String to double translation. Returns the parsed number and the number
+of characters in the unparsed portion of the string.  Truly
+POSIX-compliant systems set $! ($ERRNO) to indicate a translation
+error, so clear $! before calling strtod.  However, non-POSIX systems
+may not check for overflow, and therefore will never set $!.
+
+strtod should respect any POSIX I<setlocale()> settings.
+
+To parse a string $str as a floating point number use
+
+    $! = 0;
+    ($num, $n_unparsed) = POSIX::strtod($str);
+
+The second returned item and $! can be used to check for valid input:
+
+    if (($str eq '') || ($n_unparsed != 0) || !$!) {
+        die "Non-numeric input $str" . $! ? ": $!\n" : "\n";
+    }
+
+When called in a scalar context strtod returns the parsed number.
 
 =item strtok
 
@@ -1048,7 +1087,42 @@ strtok() is C-specific.
 
 =item strtol
 
-strtol() is C-specific.
+String to (long) integer translation.  Returns the parsed number and
+the number of characters in the unparsed portion of the string.  Truly
+POSIX-compliant systems set $! ($ERRNO) to indicate a translation
+error, so clear $! before calling strtol.  However, non-POSIX systems
+may not check for overflow, and therefore will never set $!.
+
+strtol should respect any POSIX I<setlocale()> settings.
+
+To parse a string $str as a number in some base $base use
+
+    $! = 0;
+    ($num, $n_unparsed) = POSIX::strtol($str, $base);
+
+The base should be zero or between 2 and 36, inclusive.  When the base
+is zero or omitted strtol will use the string itself to determine the
+base: a leading "0x" or "0X" means hexadecimal; a leading "0" means
+octal; any other leading characters mean decimal.  Thus, "1234" is
+parsed as a decimal number, "01234" as an octal number, and "0x1234"
+as a hexadecimal number.
+
+The second returned item and $! can be used to check for valid input:
+
+    if (($str eq '') || ($n_unparsed != 0) || !$!) {
+        die "Non-numeric input $str" . $! ? ": $!\n" : "\n";
+    }
+
+When called in a scalar context strtol returns the parsed number.
+
+=item strtoul
+
+String to unsigned (long) integer translation.  strtoul is identical
+to strtol except that strtoul only parses unsigned integers.  See
+I<strtol> for details.
+
+Note: Some vendors supply strtod and strtol but not strtoul.
+Other vendors that do suply strtoul parse "-1" as a valid value.
 
 =item strxfrm
 
@@ -1230,144 +1304,6 @@ Returns C<undef> on failure.
 
 =head1 CLASSES
 
-=head2 FileHandle
-
-=over 8
-
-=item new
-
-Open a file and return a Perl filehandle.  The first parameter is the
-filename and the second parameter is the mode.  The mode should be specified
-as C<a> for append, C<w> for write, and E<lt> or C<""> for read.
-
-Open a file for reading.
-
-       $fh = FileHandle->new( "foo", "" );
-       die "Unable to open foo for reading" unless $fh;
-
-Open a file for writing.
-
-       $fh = FileHandle->new( "foo", "w" );
-       die "Unable to open foo for writing" unless $fh;
-
-Use C<FileHandle::close()> to close the file or let the FileHandle object's
-destructor perform the close.
-
-=item clearerr
-
-Resets the error indicator and EOF indicator to zero.
-
-       $fh->clearerr;
-
-=item close
-
-Close the file.
-
-       $fh->close;
-
-=item eof
-
-Tests for end of file.
-
-       if( $fh->eof ){
-               print "end of file\n";
-       }
-
-=item error
-
-Returns non-zero if there has been an error while reading or writing a file.
-
-       if( $fh->error ){
-               print "error\n";
-       }
-
-=item fileno
-
-Returns the integer file descriptor associated with the file.
-
-       $fileno = $fh->fileno;
-
-=item flush
-
-Flush the stream.
-
-       $fh->flush;
-
-Returns C<undef> on failure.
-
-=item getc
-
-Get a character from the stream.
-
-       $ch = $fh->getc;
-
-=item getpos
-
-Retrieve the file pointer position.  The returned value can be used as an
-argument to C<setpos()>.
-
-       $pos = $fh->getpos;
-
-=item gets
-
-Retrieve a line from the open file.
-
-       $line = $fh->gets;
-
-=item new_from_fd
-
-Open a file using a file descriptor.  Return a Perl filehandle.  The first
-parameter should be a file descriptor, which can come from C<POSIX::open()>.
-The second parameter, the mode, should be C<a> for append, C<w> for write,
-and E<lt> or C<""> for read.  The mode should match the mode which was used
-when the file descriptor was created.
-
-       $fd = POSIX::open( "typemap" );
-       $fh = FileHandle->new_from_fd( $fd, "<" );
-       die "FileHandle failed" unless $fh;
-
-=item new_tmpfile
-
-Creates a temporary file, opens it for writing, and returns a Perl
-filehandle.  Consult your system's C<tmpfile()> manpage for details.
-
-       $fh = FileHandle->new_tmpfile;
-       die "FileHandle failed" unless $fh;
-
-=item seek
-
-Reposition file pointer.
-
-       $fh->seek( 2, &POSIX::SEEK_SET );
-
-=item setbuf
-
-
-=item setpos
-
-Set the file pointer position.
-
-       $pos = $fh->getpos;
-       $fh->setpos( $pos );
-
-Returns C<undef> on failure.
-
-=item setvbuf
-
-
-Returns C<undef> on failure.
-
-=item tell
-
-Returns the current file position, in bytes.
-
-       $pos = $fh->tell;
-
-=item ungetc
-
-
-=back
-
 =head2 POSIX::SigAction
 
 =over 8
@@ -1531,7 +1467,7 @@ Returns C<undef> on failure.
 Set a value in the c_cc field of a termios object.  The c_cc field is an
 array so an index must be specified.
 
-       $termios->setcc( 1, &POSIX::VEOF );
+       $termios->setcc( &POSIX::VEOF, 1 );
 
 =item setcflag
 
@@ -1733,7 +1669,7 @@ EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX
 
 =item Constants
 
-BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX _IOFBF _IOLBF _IONBF
+BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid L_tmpname TMP_MAX
 
 =back
 
@@ -1773,5 +1709,5 @@ WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG
 
 =head1 CREATION
 
-This document generated by ./mkposixman.PL version 19951212.
+This document generated by ./mkposixman.PL version 19960129.