From |kry|ov @end|ng |rom d|@root@org  Tue Oct  8 09:16:52 2024
From: |kry|ov @end|ng |rom d|@root@org (Ivan Krylov)
Date: Tue, 8 Oct 2024 10:16:52 +0300
Subject: [Rd] WRE about R_strtod
Message-ID: <20241008101618.6acf739c@Tarkus>

Hello,

This is what "Writing R extensions" currently says about R_atof and
R_strtod:

>> Function: void R_atof (const char* str)
>> Function: void R_strtod (const char* str, char ** end)
>>
>> Implementations of the C99/POSIX functions atof and strtod which
>> guarantee platform-dependent behaviour, including always using the
>> period as the decimal point aka ?radix character? and converting
>> "NA" to R?s NA_REAL_ . 

Besides the easily fixable return type (void -> double), shouldn't the
documentation mention the fact that, unlike the standard C library
functions, R's parser returns NA_REAL instead of 0 when no conversion
is performed (including for the "NA" string, *end == str)?

Index: doc/manual/R-exts.texi
===================================================================
--- doc/manual/R-exts.texi	(revision 87211)
+++ doc/manual/R-exts.texi	(working copy)
@@ -16482,12 +16482,12 @@
 
 @apifun R_atof
 @apifun R_strtod
- at deftypefun void R_atof (const char* @var{str})
- at deftypefunx void R_strtod (const char* @var{str}, char ** @var{end})
+ at deftypefun double R_atof (const char* @var{str})
+ at deftypefunx double R_strtod (const char* @var{str}, char ** @var{end})
 Implementations of the C99/POSIX functions @code{atof} and @code{strtod}
 which guarantee platform-dependent behaviour, including always using the
-period as the decimal point @emph{aka} `@I{radix character}' and converting
- at code{"NA"} to R's @code{NA_REAL_} .
+period as the decimal point @emph{aka} `@I{radix character}' and returning
+R's @code{NA_REAL_} for all unconverted strings, including @code{"NA"}.
 @end deftypefun
 

-- 
Best regards,
Ivan



[Rd] WRE about R_strtod
Ivan Krylov