bpo-38600: NULL -> ``NULL``. (GH-17001)

Also fix some other formatting.
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 4504a80..1f84b7a 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -152,8 +152,8 @@
 epoch, and the ``GetModuleHandleA()`` function, which returns a win32 module
 handle.
 
-This example calls both functions with a NULL pointer (``None`` should be used
-as the NULL pointer)::
+This example calls both functions with a ``NULL`` pointer (``None`` should be used
+as the ``NULL`` pointer)::
 
    >>> print(libc.time(None))  # doctest: +SKIP
    1150640792
@@ -1110,7 +1110,7 @@
 can iterate over it, but we just have to make sure that our loop terminates,
 because pointers have no size. Sooner or later it would probably crash with an
 access violation or whatever, so it's better to break out of the loop when we
-hit the NULL entry::
+hit the ``NULL`` entry::
 
    >>> for item in table:
    ...     if item.name is None:
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
index 084cd6a..366861c 100644
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -212,7 +212,7 @@
    A list of objects which the collector found to be unreachable but could
    not be freed (uncollectable objects).  Starting with Python 3.4, this
    list should be empty most of the time, except when using instances of
-   C extension types with a non-NULL ``tp_del`` slot.
+   C extension types with a non-``NULL`` ``tp_del`` slot.
 
    If :const:`DEBUG_SAVEALL` is set, then all unreachable objects will be
    added to this list rather than freed.
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index d443e97..62552bc 100755
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -1675,9 +1675,9 @@
    ``None`` or a :term:`bytes-like object` representing a buffer. In the later
    case it is up to the caller to ensure that the bytestring contains the
    proper bits (see the optional built-in module :mod:`struct` for a way to
-   encode C structures as bytestrings). When value is set to ``None``,
-   optlen argument is required. It's equivalent to call setsockopt C
-   function with optval=NULL and optlen=optlen.
+   encode C structures as bytestrings). When *value* is set to ``None``,
+   *optlen* argument is required. It's equivalent to call :c:func:`setsockopt` C
+   function with ``optval=NULL`` and ``optlen=optlen``.
 
 
    .. versionchanged:: 3.5
diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst
index cb67f2f..5e81068 100644
--- a/Doc/library/winreg.rst
+++ b/Doc/library/winreg.rst
@@ -343,7 +343,7 @@
    value set by the :func:`SetValue` method for the key identified by *key*.
 
    Values in the registry have name, type, and data components. This method
-   retrieves the data for a key's first value that has a NULL name. But the
+   retrieves the data for a key's first value that has a ``NULL`` name. But the
    underlying API call doesn't return the type, so always use
    :func:`QueryValueEx` if possible.
 
@@ -391,7 +391,7 @@
    <https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__
    for more details.
 
-   This function passes NULL for *security_attributes* to the API.
+   This function passes ``NULL`` for *security_attributes* to the API.
 
 
 .. function:: SetValue(key, sub_key, type, value)