about summary refs log tree commit diff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/socket.texi8
-rw-r--r--manual/stdio.texi31
2 files changed, 21 insertions, 18 deletions
diff --git a/manual/socket.texi b/manual/socket.texi
index 91084be16d..cb7b5ddc94 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -747,7 +747,7 @@ host address number as an @code{unsigned long int}.
 
 @comment netinet/in.h
 @comment BSD
-@deftypevr Macro {unsigned long int} INADDR_LOOPBACK
+@deftypevr Macro {unsigned int} INADDR_LOOPBACK
 You can use this constant to stand for ``the address of this machine,''
 instead of finding its actual address.  It is the Internet address
 @samp{127.0.0.1}, which is usually called @samp{localhost}.  This
@@ -759,7 +759,7 @@ talking to itself.
 
 @comment netinet/in.h
 @comment BSD
-@deftypevr Macro {unsigned long int} INADDR_ANY
+@deftypevr Macro {unsigned int} INADDR_ANY
 You can use this constant to stand for ``any incoming address,'' when
 binding to an address.  @xref{Setting Address}.  This is the usual
 address to give in the @code{sin_addr} member of @w{@code{struct
@@ -768,14 +768,14 @@ sockaddr_in}} when you want to accept Internet connections.
 
 @comment netinet/in.h
 @comment BSD
-@deftypevr Macro {unsigned long int} INADDR_BROADCAST
+@deftypevr Macro {unsigned int} INADDR_BROADCAST
 This constant is the address you use to send a broadcast message.
 @c !!! broadcast needs further documented
 @end deftypevr
 
 @comment netinet/in.h
 @comment BSD
-@deftypevr Macro {unsigned long int} INADDR_NONE
+@deftypevr Macro {unsigned int} INADDR_NONE
 This constant is returned by some functions to indicate an error.
 @end deftypevr
 
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 04c635b054..103be34abb 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -1479,9 +1479,9 @@ the @var{size} argument specifies the maximum number of characters to
 produce.  The trailing null character is counted towards this limit, so
 you should allocate at least @var{size} characters for the string @var{s}.
 
-The return value is the number of characters stored, not including the
-terminating null.  If this value equals @code{@var{size} - 1}, then
-there was not enough space in @var{s} for all the output.  You should
+The return value is the number of characters which are generated for the
+given input.  If this value is greater than @var{size}, not all
+characters from the result have been stored in @var{s}.  You should
 try again with a bigger output string.  Here is an example of doing
 this:
 
@@ -1495,21 +1495,24 @@ make_message (char *name, char *value)
   /* @r{Guess we need no more than 100 chars of space.} */
   int size = 100;
   char *buffer = (char *) xmalloc (size);
+  int nchars;
 @end group
 @group
-  while (1)
+ /* @r{Try to print in the allocated space.} */
+  nchars = snprintf (buffer, size, "value of %s is %s",
+                     name, value);
+@end group
+@group
+  if (nchars) >= size)
     @{
-      /* @r{Try to print in the allocated space.} */
-      int nchars = snprintf (buffer, size,
-                             "value of %s is %s",
-                             name, value);
-      /* @r{If that worked, return the string.} */
-      if (nchars < size)
-        return buffer;
-      /* @r{Else try again with twice as much space.} */
-      size *= 2;
-      buffer = (char *) xrealloc (size, buffer);
+      /* @r{Reallocate buffer now that we know how much space is needed.} */
+      buffer = (char *) xrealloc (buffer, nchars + 1);
+
+      /* @r{Try again.} */
+      snprintf (buffer, size, "value of %s is %s", name, value);
     @}
+  /* @r{The last call worked, return the string.} */
+  return buffer;
 @}
 @end group
 @end smallexample