]> code.delx.au - gnu-emacs/blobdiff - lib-src/pop.c
Switch to recommended form of GPLv3 permissions notice.
[gnu-emacs] / lib-src / pop.c
index 814575f06d51300dd6b05879c7dbd8a93313005b..76cd2fb57925c077a41cfb757d5443dd877f13c4 100644 (file)
@@ -1,14 +1,15 @@
 /* pop.c: client routines for talking to a POP3-protocol post-office server
    Copyright (C) 1991, 1993, 1996, 1997, 1999, 2001, 2002, 2003, 2004,
                  2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-   Written by Jonathan Kamens, jik@security.ov.com.
+
+Author: Jonathan Kamens <jik@security.ov.com>
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,12 +17,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
 
 #ifdef HAVE_CONFIG_H
-#define NO_SHORTNAMES  /* Tell config not to load remap.h */
 #include <config.h>
 #else
 #define MAIL_USE_POP
@@ -381,25 +380,18 @@ pop_stat (server, count, size)
   errno = 0;
   *count = strtol (&fromserver[4], &end_ptr, 10);
   /* Check validity of string-to-integer conversion. */
-  if (fromserver[4] == 0 || *end_ptr != 0 || errno)
+  if (fromserver + 4 == end_ptr || *end_ptr != ' ' || errno)
     {
       strcpy (pop_error, "Unexpected response from POP server in pop_stat");
       pop_trash (server);
       return (-1);
     }
 
-  fromserver = index (&fromserver[4], ' ');
-  if (! fromserver)
-    {
-      strcpy (pop_error,
-             "Badly formatted response from server in pop_stat");
-      pop_trash (server);
-      return (-1);
-    }
+  fromserver = end_ptr;
 
   errno = 0;
   *size = strtol (fromserver + 1, &end_ptr, 10);
-  if (*(fromserver + 1) == 0 || *end_ptr != 0 || errno)
+  if (fromserver + 1 == end_ptr || errno)
     {
       strcpy (pop_error, "Unexpected response from POP server in pop_stat");
       pop_trash (server);
@@ -933,7 +925,7 @@ pop_last (server)
       int count;
       errno = 0;
       count = strtol (&fromserver[4], &end_ptr, 10);
-      if (fromserver[4] == 0 || *end_ptr != 0 || errno)
+      if (fromserver + 4 == end_ptr || errno)
        {
          strcpy (pop_error, "Unexpected response from server in pop_last");
          pop_trash (server);
@@ -1006,8 +998,7 @@ pop_quit (server)
       close (server->file);
     }
 
-  if (server->buffer)
-    free (server->buffer);
+  free (server->buffer);
   free ((char *) server);
 
   return (ret);
@@ -1637,7 +1628,7 @@ pop_close (server)
  * Function: pop_trash
  *
  * Purpose: Like pop_close or pop_quit, but doesn't deallocate the
- *     memory associated with the server.  It is legal to call
+ *     memory associated with the server.  It is valid to call
  *     pop_close or pop_quit after this function has been called.
  */
 static void