[svn:parrot] r39051 - trunk/src/pmc

coke at svn.parrot.org coke at svn.parrot.org
Fri May 22 19:30:33 UTC 2009


Author: coke
Date: Fri May 22 19:30:32 2009
New Revision: 39051
URL: https://trac.parrot.org/parrot/changeset/39051

Log:
[codingstd] make 'make codetest' happy.

I think this improves the readability of the invalid filehandle, but
obscures the function that is now split in two. YMMV.

Modified:
   trunk/src/pmc/filehandle.pmc

Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc	Fri May 22 19:12:51 2009	(r39050)
+++ trunk/src/pmc/filehandle.pmc	Fri May 22 19:30:32 2009	(r39051)
@@ -31,6 +31,17 @@
 #endif
 #endif
 
+#ifdef PIO_OS_WIN32
+#  define PIO_INVALID_HANDLE INVALID_HANDLE_VALUE
+#endif
+
+#ifdef PIO_OS_UNIX
+#  define PIO_INVALID_HANDLE -1
+#endif
+
+#ifdef PIO_OS_STDIO
+#  define PIO_INVALID_HANDLE NULL
+#endif
 
 pmclass FileHandle need_ext {
     ATTR INTVAL flags;                /* Filehandle flags             */
@@ -84,18 +95,7 @@
         data_struct->buffer_next   = NULL;
 
         /* Initialize the os_handle to the platform-specific value for closed. */
-
-#ifdef PIO_OS_WIN32
-        data_struct->os_handle     = (PIOHANDLE)INVALID_HANDLE_VALUE;
-#endif
-
-#ifdef PIO_OS_UNIX
-        data_struct->os_handle     = (PIOHANDLE)-1;
-#endif
-
-#ifdef PIO_OS_STDIO
-        data_struct->os_handle     = (PIOHANDLE)NULL;
-#endif
+        data_struct->os_handle     = (PIOHANDLE) PIO_INVALID_HANDLE;
 
         PObj_custom_mark_SET(SELF);
         PObj_active_destroy_SET(SELF);
@@ -395,9 +395,9 @@
 
 */
 
+#ifdef PARROT_HAS_READLINE
     METHOD readline_interactive(STRING *prompt :optional, INTVAL got_prompt :opt_flag) {
         STRING *string_result;
-#ifdef PARROT_HAS_READLINE
         char * const r = readline(got_prompt ? prompt->strstart : NULL);
 
         if (r) {
@@ -410,7 +410,10 @@
         }
 
         RETURN(PMC *PMCNULL);
+    }
 #else
+    METHOD readline_interactive(STRING *prompt :optional, INTVAL got_prompt :opt_flag) {
+        STRING *string_result;
         UINTVAL len;
 
         if (got_prompt)
@@ -434,8 +437,8 @@
         }
 
         RETURN(STRING *string_result);
-#endif
     }
+#endif
 
 /*
 


More information about the parrot-commits mailing list