[ros-diffs] [dchapyshev] 40778: - Implement _wfreopen, _y0, _y1, _yn - Partially implement _j0, _j1, _jn All from Wine.

dchapyshev at svn.reactos.org dchapyshev at svn.reactos.org
Sun May 3 16:57:57 CEST 2009


Author: dchapyshev
Date: Sun May  3 18:57:56 2009
New Revision: 40778

URL: http://svn.reactos.org/svn/reactos?rev=40778&view=rev
Log:
- Implement _wfreopen, _y0, _y1, _yn
- Partially implement _j0, _j1, _jn
All from Wine.

Modified:
    trunk/reactos/lib/sdk/crt/math/j0_y0.c
    trunk/reactos/lib/sdk/crt/math/j1_y1.c
    trunk/reactos/lib/sdk/crt/math/jn_yn.c
    trunk/reactos/lib/sdk/crt/stdio/file.c

Modified: trunk/reactos/lib/sdk/crt/math/j0_y0.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/math/j0_y0.c?rev=40778&r1=40777&r2=40778&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/math/j0_y0.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/math/j0_y0.c [iso-8859-1] Sun May  3 18:57:56 2009
@@ -1,18 +1,30 @@
 #include <math.h>
 
+typedef int fpclass_t;
+fpclass_t _fpclass(double __d);
+int *_errno(void);
 
 /*
  * @unimplemented
  */
-double _j0(double x)
+double _j0(double num)
 {
-	return x;
+  /* FIXME: errno handling */
+  return j0(num);
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-double _y0(double x)
+double _y0(double num)
 {
-	return x;
+  double retval;
+  if (!isfinite(num)) *_errno() = EDOM;
+  retval  = y0(num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *_errno() = EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
 }

Modified: trunk/reactos/lib/sdk/crt/math/j1_y1.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/math/j1_y1.c?rev=40778&r1=40777&r2=40778&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/math/j1_y1.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/math/j1_y1.c [iso-8859-1] Sun May  3 18:57:56 2009
@@ -1,18 +1,30 @@
 #include <math.h>
 
+typedef int fpclass_t;
+fpclass_t _fpclass(double __d);
+int *_errno(void);
 
 /*
  * @unimplemented
  */
-double _j1(double x)
+double _j1(double num)
 {
-	return x;
+  /* FIXME: errno handling */
+  return j1(num);
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-double _y1(double x)
+double _y1(double num)
 {
-	return x;
+  double retval;
+  if (!isfinite(num)) *_errno() = EDOM;
+  retval  = y1(num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *_errno() = EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
 }

Modified: trunk/reactos/lib/sdk/crt/math/jn_yn.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/math/jn_yn.c?rev=40778&r1=40777&r2=40778&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/math/jn_yn.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/math/jn_yn.c [iso-8859-1] Sun May  3 18:57:56 2009
@@ -1,18 +1,30 @@
 #include <math.h>
 
+typedef int fpclass_t;
+fpclass_t _fpclass(double __d);
+int *_errno(void);
 
 /*
  * @unimplemented
  */
-double _jn(int n, double x)
+double _jn(int n, double num)
 {
-	return x;
+  /* FIXME: errno handling */
+  return jn(n, num);
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
-double _yn(int n, double x)
+double _yn(int order, double num)
 {
-	return x;
+  double retval;
+  if (!isfinite(num)) *_errno() = EDOM;
+  retval  = yn(order,num);
+  if (_fpclass(retval) == _FPCLASS_NINF)
+  {
+    *_errno() = EDOM;
+    retval = sqrt(-1);
+  }
+  return retval;
 }

Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?rev=40778&r1=40777&r2=40778&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Sun May  3 18:57:56 2009
@@ -2434,8 +2434,35 @@
  */
 FILE* CDECL _wfreopen(const wchar_t *path, const wchar_t *mode,FILE* file)
 {
-    FIXME("UNIMPLEMENTED stub!\n");
-    return NULL;
+  int open_flags, stream_flags, fd;
+
+  TRACE(":path (%p) mode (%s) file (%p) fd (%d)\n", debugstr_w(path), debugstr_w(mode), file, file->_file);
+
+  LOCK_FILES();
+  if (!file || ((fd = file->_file) < 0) || fd > fdend)
+    file = NULL;
+  else
+  {
+    fclose(file);
+    /* map mode string to open() flags. "man fopen" for possibilities. */
+    if (get_flags((char*)mode, &open_flags, &stream_flags) == -1)
+      file = NULL;
+    else
+    {
+      fd = _wopen(path, open_flags, _S_IREAD | _S_IWRITE);
+      if (fd < 0)
+        file = NULL;
+      else if (init_fp(file, fd, stream_flags) == -1)
+      {
+          file->_flag = 0;
+          WARN(":failed-last error (%d)\n",GetLastError());
+          _dosmaperr(GetLastError());
+          file = NULL;
+      }
+    }
+  }
+  UNLOCK_FILES();
+  return file;
 }
 
 /*********************************************************************



More information about the Ros-diffs mailing list