changeset 5426:e760cb72c02e

osutil: simplify DT_REG support
author Matt Mackall <mpm@selenic.com>
date Mon, 08 Oct 2007 18:47:17 -0500
parents 830f6e280c90
children dae6188e8c9e
files mercurial/osutil.c
diffstat 1 files changed, 14 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/osutil.c	Mon Oct 08 18:47:16 2007 -0500
+++ b/mercurial/osutil.c	Mon Oct 08 18:47:17 2007 -0500
@@ -206,37 +206,29 @@
 		PyObject *name = NULL;
 		PyObject *py_kind = NULL;
 		PyObject *val = NULL;
-		unsigned char d_type;
 		int kind = -1;
 
 		if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
 			continue;
 
 #ifdef DT_REG
-		if (do_stat)
-			d_type = 0;
-		else
-			d_type = ent->d_type;
+		if (!do_stat)
+			switch (ent->d_type) {
+			case DT_REG: kind = S_IFREG; break;
+			case DT_DIR: kind = S_IFDIR; break;
+			case DT_LNK: kind = S_IFLNK; break;
+			case DT_BLK: kind = S_IFBLK; break;
+			case DT_CHR: kind = S_IFCHR; break;
+			case DT_FIFO: kind = S_IFIFO; break;
+			case DT_SOCK: kind = S_IFSOCK; break;
+			default:
+				all_kinds = 0;
+				break;
+			}
 #else
-		d_type = 0;
+		all_kinds = 0;
 #endif
 
-		switch (d_type) {
-#ifdef DT_REG
-		case DT_REG: kind = S_IFREG; break;
-		case DT_DIR: kind = S_IFDIR; break;
-		case DT_LNK: kind = S_IFLNK; break;
-		case DT_BLK: kind = S_IFBLK; break;
-		case DT_CHR: kind = S_IFCHR; break;
-		case DT_FIFO: kind = S_IFIFO; break;
-		case DT_SOCK: kind = S_IFSOCK; break;
-#endif
-		default:
-			if (all_kinds)
-				all_kinds = 0;
-			break;
-		}
-
 		name = PyString_FromString(ent->d_name);
 		if (kind != -1)
 			py_kind = PyInt_FromLong(kind);