all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#12968: Assume POSIX 1003.1-1988 or later for errno.h.
@ 2012-11-23  9:04 Paul Eggert
  2012-11-23  9:38 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2012-11-23  9:04 UTC (permalink / raw
  To: 12968

Here's a patch to simplify Emacs by assuming
POSIX 1003.1-1988 or later for errno.h, which I plan
to install soon.  This should be safe as other parts of Emacs
are already assuming the relevant macros.  I haven't tested
this on Microsoft platforms though.

=== modified file 'lib-src/ChangeLog'
--- lib-src/ChangeLog	2012-11-23 08:28:06 +0000
+++ lib-src/ChangeLog	2012-11-23 08:56:17 +0000
@@ -1,5 +1,8 @@
 2012-11-23  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Assume POSIX 1003.1-1988 or later for errno.h.
+	* movemail.c (main): Assume EAGAIN and EBUSY.
+
 	movemail: treat EACCES etc. failures as permanent
 	* movemail.c (main): Treat any link failure other than EEXIST as a
 	permanent failure, not just EPERM.  EACCES, for example.

=== modified file 'lib-src/movemail.c'
--- lib-src/movemail.c	2012-11-23 08:28:06 +0000
+++ lib-src/movemail.c	2012-11-23 08:56:17 +0000
@@ -430,22 +430,10 @@
 	 for certain failure codes.  */
       if (status < 0)
 	{
-	  if (++lockcount <= 5)
+	  if (++lockcount <= 5 && (errno == EAGAIN || errno == EBUSY))
 	    {
-#ifdef EAGAIN
-	      if (errno == EAGAIN)
-		{
-		  sleep (1);
-		  goto retry_lock;
-		}
-#endif
-#ifdef EBUSY
-	      if (errno == EBUSY)
-		{
-		  sleep (1);
-		  goto retry_lock;
-		}
-#endif
+	      sleep (1);
+	      goto retry_lock;
 	    }
 
 	  pfatal_with_name (inname);

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-11-23 08:47:34 +0000
+++ src/ChangeLog	2012-11-23 08:59:17 +0000
@@ -1,3 +1,16 @@
+2012-11-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for errno.h.
+	* dired.c (directory_files_internal, file_name_completion):
+	Assume EAGAIN and EINTR are defined.
+	* fileio.c (Fcopy_file): Assume EISDIR is defined.
+	* gmalloc.c (ENOMEM, EINVAL): Assume they're defined.
+	* gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined.
+	* lread.c (readbyte_from_file): Assume EINTR is defined.
+	* process.c (wait_reading_process_output, send_process) [subprocesses]:
+	Assume EIO and EAGAIN are defined.
+	* unexcoff.c (write_segment): Assume EFAULT is defined.
+
 2012-11-23  Eli Zaretskii  <eliz@gnu.org>
 
 	* makefile.w32-in (globals.h, gl-stamp): Use $(SWITCHCHAR) instead

=== modified file 'src/dired.c'
--- src/dired.c	2012-11-23 07:48:43 +0000
+++ src/dired.c	2012-11-23 08:56:17 +0000
@@ -193,19 +193,15 @@
 
       errno = 0;
       dp = readdir (d);
-
-      if (dp == NULL && (0
-#ifdef EAGAIN
-			 || errno == EAGAIN
-#endif
-#ifdef EINTR
-			 || errno == EINTR
-#endif
-			 ))
-	{ QUIT; continue; }
-
-      if (dp == NULL)
-	break;
+      if (!dp)
+	{
+	  if (errno == EAGAIN || errno == EINTR)
+	    {
+	      QUIT;
+	      continue;
+	    }
+	  break;
+	}
 
       len = dirent_namelen (dp);
       name = finalname = make_unibyte_string (dp->d_name, len);
@@ -480,17 +476,15 @@
 
       errno = 0;
       dp = readdir (d);
-      if (dp == NULL && (0
-# ifdef EAGAIN
-			 || errno == EAGAIN
-# endif
-# ifdef EINTR
-			 || errno == EINTR
-# endif
-			 ))
-	{ QUIT; continue; }
-
-      if (!dp) break;
+      if (!dp)
+	{
+	  if (errno == EAGAIN || errno == EINTR)
+	    {
+	      QUIT;
+	      continue;
+	    }
+	  break;
+	}
 
       len = dirent_namelen (dp);
 

=== modified file 'src/fileio.c'
--- src/fileio.c	2012-11-21 21:06:52 +0000
+++ src/fileio.c	2012-11-23 08:56:17 +0000
@@ -1995,10 +1995,8 @@
     {
       if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode)))
 	{
-#if defined (EISDIR)
 	  /* Get a better looking error message. */
 	  errno = EISDIR;
-#endif /* EISDIR */
 	  report_file_error ("Non-regular file", Fcons (file, Qnil));
 	}
     }

=== modified file 'src/gmalloc.c'
--- src/gmalloc.c	2012-10-01 06:36:54 +0000
+++ src/gmalloc.c	2012-11-23 08:56:17 +0000
@@ -1645,14 +1645,6 @@
   return result;
 }
 
-#ifndef ENOMEM
-#define ENOMEM 12
-#endif
-
-#ifndef EINVAL
-#define EINVAL 22
-#endif
-
 int
 posix_memalign (void **memptr, size_t alignment, size_t size)
 {

=== modified file 'src/gnutls.c'
--- src/gnutls.c	2012-09-23 19:36:31 +0000
+++ src/gnutls.c	2012-11-23 08:56:17 +0000
@@ -359,12 +359,7 @@
 
   if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
     {
-#ifdef EWOULDBLOCK
-      errno = EWOULDBLOCK;
-#endif
-#ifdef EAGAIN
       errno = EAGAIN;
-#endif
       return 0;
     }
 
@@ -384,14 +379,7 @@
 		 appropriately so that send_process retries the
 		 correct way instead of erroring out. */
 	      if (rtnval == GNUTLS_E_AGAIN)
-		{
-#ifdef EWOULDBLOCK
-		  errno = EWOULDBLOCK;
-#endif
-#ifdef EAGAIN
-		  errno = EAGAIN;
-#endif
-		}
+		errno = EAGAIN;
 	      break;
 	    }
 	}

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2012-11-17 22:12:47 +0000
+++ src/keyboard.c	2012-11-23 08:56:17 +0000
@@ -6986,10 +6986,7 @@
             an EAGAIN error.  Does anybody know of a situation
             where a retry is actually needed?  */
 #if 0
-         nread < 0 && (errno == EAGAIN
-#ifdef EFAULT
-                       || errno == EFAULT
-#endif
+         nread < 0 && (errno == EAGAIN || errno == EFAULT
 #ifdef EBADSLT
                        || errno == EBADSLT
 #endif

=== modified file 'src/lread.c'
--- src/lread.c	2012-11-20 20:06:17 +0000
+++ src/lread.c	2012-11-23 08:56:17 +0000
@@ -440,7 +440,6 @@
   block_input ();
   c = getc (instream);
 
-#ifdef EINTR
   /* Interrupted reads have been observed while reading over the network.  */
   while (c == EOF && ferror (instream) && errno == EINTR)
     {
@@ -450,7 +449,6 @@
       clearerr (instream);
       c = getc (instream);
     }
-#endif
 
   unblock_input ();
 

=== modified file 'src/process.c'
--- src/process.c	2012-11-17 22:12:47 +0000
+++ src/process.c	2012-11-23 08:56:17 +0000
@@ -4432,14 +4432,8 @@
 		  total_nread += nread;
 		  got_some_input = 1;
 		}
-#ifdef EIO
-	      else if (nread == -1 && EIO == errno)
-		break;
-#endif
-#ifdef EAGAIN
-	      else if (nread == -1 && EAGAIN == errno)
-		break;
-#endif
+	      else if (nread == -1 && (errno == EIO || errno == EAGAIN))
+		break;
 #ifdef EWOULDBLOCK
 	      else if (nread == -1 && EWOULDBLOCK == errno)
 		break;
@@ -5517,13 +5511,10 @@
 
 	  if (rv < 0)
 	    {
-	      if (0
+	      if (errno == EAGAIN
 #ifdef EWOULDBLOCK
 		  || errno == EWOULDBLOCK
 #endif
-#ifdef EAGAIN
-		  || errno == EAGAIN
-#endif
 		  )
 		/* Buffer is full.  Wait, accepting input;
 		   that may allow the program

=== modified file 'src/unexcoff.c'
--- src/unexcoff.c	2012-09-15 07:06:56 +0000
+++ src/unexcoff.c	2012-11-23 08:56:17 +0000
@@ -332,11 +332,7 @@
 	 a gap between the old text segment and the old data segment.
 	 This gap has probably been remapped into part of the text segment.
 	 So write zeros for it.  */
-      if (ret == -1
-#ifdef EFAULT
-	  && errno == EFAULT
-#endif
-	  )
+      if (ret == -1 && errno == EFAULT)
 	{
 	  /* Write only a page of zeros at once,
 	     so that we don't overshoot the start






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#12968: Assume POSIX 1003.1-1988 or later for errno.h.
  2012-11-23  9:04 bug#12968: Assume POSIX 1003.1-1988 or later for errno.h Paul Eggert
@ 2012-11-23  9:38 ` Eli Zaretskii
  2012-11-27  5:17   ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2012-11-23  9:38 UTC (permalink / raw
  To: Paul Eggert; +Cc: 12968

> Date: Fri, 23 Nov 2012 01:04:27 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> Here's a patch to simplify Emacs by assuming
> POSIX 1003.1-1988 or later for errno.h, which I plan
> to install soon.  This should be safe as other parts of Emacs
> are already assuming the relevant macros.  I haven't tested
> this on Microsoft platforms though.

Looks OK for MS-Windows, all the referenced errno values are defined
in errno.h.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#12968: Assume POSIX 1003.1-1988 or later for errno.h.
  2012-11-23  9:38 ` Eli Zaretskii
@ 2012-11-27  5:17   ` Paul Eggert
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2012-11-27  5:17 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: 12968-done

On 11/23/2012 01:38 AM, Eli Zaretskii wrote:
> Looks OK for MS-Windows, all the referenced errno values are defined
> in errno.h.

Thanks for the review, I committed the patch as
trunk bzr 111016.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-27  5:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-23  9:04 bug#12968: Assume POSIX 1003.1-1988 or later for errno.h Paul Eggert
2012-11-23  9:38 ` Eli Zaretskii
2012-11-27  5:17   ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.