[svn:parrot] r42332 - in trunk: src src/io src/packfile src/string/charset t/codingstd

coke at svn.parrot.org coke at svn.parrot.org
Sat Nov 7 18:59:04 UTC 2009


Author: coke
Date: Sat Nov  7 18:59:03 2009
New Revision: 42332
URL: https://trac.parrot.org/parrot/changeset/42332

Log:
Fix codingstd outdent test, courtesy plobsing++
 -- also fix 'denting levels on files that were incorrect
    (but passed the old test.)

Resolves issue #1137.

Modified:
   trunk/src/events.c
   trunk/src/io/socket_unix.c
   trunk/src/io/socket_win32.c
   trunk/src/io/unix.c
   trunk/src/packfile/pf_items.c
   trunk/src/string/charset/unicode.c
   trunk/t/codingstd/c_indent.t

Modified: trunk/src/events.c
==============================================================================
--- trunk/src/events.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/events.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -919,83 +919,82 @@
         const int retval = select(n_highest, &rfds, &wfds, NULL, NULL);
 
         switch (retval) {
-            case -1:
-                if (errno == EINTR) {
-                    edebug((stderr, "select EINTR\n"));
-                    if (sig_int) {
-                        edebug((stderr, "int arrived\n"));
-                        sig_int = 0;
-                        /*
-                         * signal the event thread
-                         */
-                        schedule_signal_event(SIGINT);
-                    }
-                    if (sig_hup) {
-                        edebug((stderr, "int arrived\n"));
-                        sig_hup = 0;
+          case -1:
+            if (errno == EINTR) {
+                edebug((stderr, "select EINTR\n"));
+                if (sig_int) {
+                    edebug((stderr, "int arrived\n"));
+                    sig_int = 0;
+                    /*
+                     * signal the event thread
+                     */
+                    schedule_signal_event(SIGINT);
+                }
+                if (sig_hup) {
+                    edebug((stderr, "int arrived\n"));
+                    sig_hup = 0;
+                    /*
+                     * signal the event thread
+                     */
+                    schedule_signal_event(SIGHUP);
+                }
+
+            }
+            break;
+          case 0:     /* timeout - can't happen */
+            break;
+          default:
+            edebug((stderr, "IO ready\n"));
+            for (i = 0; i < n_highest; ++i) {
+                if (FD_ISSET(i, &rfds)) {
+                    if (i == PIPE_READ_FD) {
+                        io_thread_msg buf;
                         /*
-                         * signal the event thread
+                         * a command arrived
                          */
-                        schedule_signal_event(SIGHUP);
-                    }
-
-                }
-                break;
-            case 0:     /* timeout - can't happen */
-                break;
-            default:
-                edebug((stderr, "IO ready\n"));
-                for (i = 0; i < n_highest; ++i) {
-                    if (FD_ISSET(i, &rfds)) {
-                        if (i == PIPE_READ_FD) {
-                            io_thread_msg buf;
-                            /*
-                             * a command arrived
-                             */
-                            edebug((stderr, "msg arrived\n"));
-                            if (read(PIPE_READ_FD, &buf, sizeof (buf)) != sizeof (buf))
-                                exit_fatal(1,
-                                        "read error from msg pipe");
-                            switch (buf.command) {
-                                case IO_THR_MSG_TERMINATE:
-                                    running = 0;
-                                    break;
-                                case IO_THR_MSG_ADD_SELECT_RD:
-                                    {
-                                        PMC * const pio = buf.ev->u.io_event.pio;
-                                        const int fd = Parrot_io_getfd(buf.ev->interp, pio);
-                                        if (FD_ISSET(fd, &act_rfds)) {
-                                            mem_sys_free(buf.ev);
-                                            break;
-                                        }
-                                        FD_SET(fd, &act_rfds);
-                                        if (fd >= n_highest)
-                                            n_highest = fd + 1;
-                                        store_io_event(&ios, buf.ev);
-                                    }
-                                    break;
-                                    /* TODO */
-                                default:
-                                    exit_fatal(1,
-                                            "unhandled msg in pipe");
+                        edebug((stderr, "msg arrived\n"));
+                        if (read(PIPE_READ_FD, &buf, sizeof (buf)) != sizeof (buf))
+                            exit_fatal(1,
+                                    "read error from msg pipe");
+                        switch (buf.command) {
+                          case IO_THR_MSG_TERMINATE:
+                            running = 0;
+                            break;
+                          case IO_THR_MSG_ADD_SELECT_RD:
+                            {
+                                PMC * const pio = buf.ev->u.io_event.pio;
+                                const int fd = Parrot_io_getfd(buf.ev->interp, pio);
+                                if (FD_ISSET(fd, &act_rfds)) {
+                                    mem_sys_free(buf.ev);
                                     break;
+                                }
+                                FD_SET(fd, &act_rfds);
+                                if (fd >= n_highest)
+                                    n_highest = fd + 1;
+                                store_io_event(&ios, buf.ev);
                             }
-
-                        }
-                        else {
-                            /*
-                             * one of the io_event fds is ready
-                             * remove from active set, as we don't
-                             * want to fire again during io_handler
-                             * invocation
-                             */
-                            FD_CLR(i, &act_rfds);
-                            io_thread_ready_rd(&ios, i);
+                            break;
+                          default:
+                            /* TODO */
+                            exit_fatal(1, "unhandled msg in pipe");
+                            break;
                         }
+
+                    }
+                    else {
+                        /*
+                         * one of the io_event fds is ready
+                         * remove from active set, as we don't
+                         * want to fire again during io_handler
+                         * invocation
+                         */
+                        FD_CLR(i, &act_rfds);
+                        io_thread_ready_rd(&ios, i);
                     }
                 }
-                /* TODO check fds */
-                break;
+            }
+            /* TODO check fds */
+            break;
         }
     }
     edebug((stderr, "IO thread terminated\n"));

Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/io/socket_unix.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -166,14 +166,14 @@
     if ((connect(io->os_handle, (struct sockaddr *)SOCKADDR_REMOTE(socket),
             sizeof (struct sockaddr_in))) != 0) {
         switch (errno) {
-            case EINTR:
-                goto AGAIN;
-            case EINPROGRESS:
-                goto AGAIN;
-            case EISCONN:
-                return 0;
-            default:
-                return -1;
+          case EINTR:
+            goto AGAIN;
+          case EINPROGRESS:
+            goto AGAIN;
+          case EISCONN:
+            return 0;
+          default:
+            return -1;
         }
     }
 
@@ -312,21 +312,21 @@
     }
     else {
         switch (errno) {
-            case EINTR:
-                goto AGAIN;
+          case EINTR:
+            goto AGAIN;
 #    ifdef EWOULDBLOCK
-            case EWOULDBLOCK:
-                goto AGAIN;
+          case EWOULDBLOCK:
+            goto AGAIN;
 #    else
-            case EAGAIN:
-                goto AGAIN;
+          case EAGAIN:
+            goto AGAIN;
 #    endif
-            case EPIPE:
-                /* XXX why close it here and not below */
-                close(io->os_handle);
-                return -1;
-            default:
-                return -1;
+          case EPIPE:
+            /* XXX why close it here and not below */
+            close(io->os_handle);
+            return -1;
+          default:
+            return -1;
         }
     }
 }
@@ -361,24 +361,24 @@
     }
     else {
         switch (errno) {
-            case EINTR:
-                goto AGAIN;
+          case EINTR:
+            goto AGAIN;
 #    ifdef EWOULDBLOCK
-            case EWOULDBLOCK:
-                goto AGAIN;
+          case EWOULDBLOCK:
+            goto AGAIN;
 #    else
-            case EAGAIN:
-                goto AGAIN;
+          case EAGAIN:
+            goto AGAIN;
 #    endif
-            case ECONNRESET:
-                /* XXX why close it on err return result is -1 anyway */
-                close(io->os_handle);
-                *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
-                return -1;
-            default:
-                close(io->os_handle);
-                *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
-                return -1;
+          case ECONNRESET:
+            /* XXX why close it on err return result is -1 anyway */
+            close(io->os_handle);
+            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            return -1;
+          default:
+            close(io->os_handle);
+            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            return -1;
         }
     }
 }

Modified: trunk/src/io/socket_win32.c
==============================================================================
--- trunk/src/io/socket_win32.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/io/socket_win32.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -113,14 +113,14 @@
     if ((connect((int)io->os_handle, (struct sockaddr *)SOCKADDR_REMOTE(socket),
             sizeof (struct sockaddr_in))) != 0) {
         switch (errno) {
-            case WSAEINTR:
-                goto AGAIN;
-            case WSAEINPROGRESS:
-                goto AGAIN;
-            case WSAEISCONN:
-                return 0;
-            default:
-                return -1;
+          case WSAEINTR:
+            goto AGAIN;
+          case WSAEINPROGRESS:
+            goto AGAIN;
+          case WSAEISCONN:
+            return 0;
+          default:
+            return -1;
         }
     }
 
@@ -259,21 +259,21 @@
     }
     else {
         switch (errno) {
-            case WSAEINTR:
-                goto AGAIN;
+          case WSAEINTR:
+            goto AGAIN;
 #    ifdef WSAEWOULDBLOCK
-            case WSAEWOULDBLOCK:
-                goto AGAIN;
+          case WSAEWOULDBLOCK:
+            goto AGAIN;
 #    else
-            case WSAEAGAIN:
-                goto AGAIN;
+          case WSAEAGAIN:
+            goto AGAIN;
 #    endif
-            case EPIPE:
-                /* XXX why close it here and not below */
-                close((int)io->os_handle);
-                return -1;
-            default:
-                return -1;
+          case EPIPE:
+            /* XXX why close it here and not below */
+            close((int)io->os_handle);
+            return -1;
+          default:
+            return -1;
         }
     }
 }
@@ -308,24 +308,24 @@
     }
     else {
         switch (errno) {
-            case EINTR:
-                goto AGAIN;
+          case EINTR:
+            goto AGAIN;
 #    ifdef WSAEWOULDBLOCK
-            case WSAEWOULDBLOCK:
-                goto AGAIN;
+          case WSAEWOULDBLOCK:
+            goto AGAIN;
 #    else
-            case WSAEAGAIN:
-                goto AGAIN;
+          case WSAEAGAIN:
+            goto AGAIN;
 #    endif
-            case WSAECONNRESET:
-                /* XXX why close it on err return result is -1 anyway */
-                close((int)io->os_handle);
-                *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
-                return -1;
-            default:
-                close((int)io->os_handle);
-                *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
-                return -1;
+          case WSAECONNRESET:
+            /* XXX why close it on err return result is -1 anyway */
+            close((int)io->os_handle);
+            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            return -1;
+          default:
+            close((int)io->os_handle);
+            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            return -1;
         }
     }
 }

Modified: trunk/src/io/unix.c
==============================================================================
--- trunk/src/io/unix.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/io/unix.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -512,9 +512,9 @@
         }
         else if (bytes < 0) {
             switch (errno) {
-            case EINTR:
+              case EINTR:
                 continue;
-            default:
+              default:
                 s->bufused = s->strlen = 0;
                 return bytes;
             }
@@ -551,7 +551,7 @@
     size_t to_write = s->bufused;
     size_t written  = 0;
 
-    write_through:
+  write_through:
     while (to_write > 0) {
         const int err = write(file_descriptor, ptr, to_write);
         if (err >= 0) {
@@ -599,24 +599,24 @@
 
     if (pos >= 0) {
         switch (whence) {
-            case SEEK_SET:
-                if (offset > Parrot_io_get_file_size(interp, filehandle)) {
-                    Parrot_io_set_file_size(interp, filehandle, offset);
-                }
-                break;
-            case SEEK_CUR:
-                {
-                    const PIOOFF_T avail = offset
-                            + Parrot_io_get_buffer_next(interp, filehandle)
-                            - Parrot_io_get_buffer_start(interp, filehandle);
-                    if (avail > Parrot_io_get_file_size(interp, filehandle)) {
-                        Parrot_io_set_file_size(interp, filehandle, avail);
-                    }
+          case SEEK_SET:
+            if (offset > Parrot_io_get_file_size(interp, filehandle)) {
+                Parrot_io_set_file_size(interp, filehandle, offset);
+            }
+            break;
+          case SEEK_CUR:
+            {
+                const PIOOFF_T avail = offset
+                        + Parrot_io_get_buffer_next(interp, filehandle)
+                        - Parrot_io_get_buffer_start(interp, filehandle);
+                if (avail > Parrot_io_get_file_size(interp, filehandle)) {
+                    Parrot_io_set_file_size(interp, filehandle, avail);
                 }
-                break;
-            case SEEK_END:
-            default:
-                break;
+             }
+            break;
+          case SEEK_END:
+          default:
+            break;
         }
 
         Parrot_io_set_file_position(interp, filehandle, pos);

Modified: trunk/src/packfile/pf_items.c
==============================================================================
--- trunk/src/packfile/pf_items.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/packfile/pf_items.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -1537,28 +1537,28 @@
 
         switch (pf->header->floattype) {
 #  if NUMVAL_SIZE == 8
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = fetch_buf_le_8;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num8_le;
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num8_le;
             break;
 #  endif
 #  if NUMVAL_SIZE == 16
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num16_le;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num16_le;
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = fetch_buf_le_16;
             break;
 #  endif
-        default:
+          default:
             exit_fatal(1,
               "PackFile_unpack: unsupported float conversion %d to %d, "
               "PARROT_BIGENDIAN=%d\n",
@@ -1576,26 +1576,26 @@
 
         switch (pf->header->floattype) {
 #  if NUMVAL_SIZE == 8
-        case FLOATTYPE_8: /* native */
+          case FLOATTYPE_8: /* native */
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num8;
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num8;
             break;
 #  endif
 #  if NUMVAL_SIZE == 16
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num16;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num16;
             break;
-        case FLOATTYPE_16: /* native */
+          case FLOATTYPE_16: /* native */
             break;
 #  endif
-        default:
+          default:
             exit_fatal(1,
               "PackFile_unpack: unsupported float conversion %d to %d, "
               "PARROT_BIGENDIAN=%d\n",
@@ -1617,39 +1617,39 @@
 
         switch (pf->header->floattype) {
 #  if NUMVAL_SIZE == 8
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = fetch_buf_be_8;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             exit_fatal(1, "PackFile_unpack: invalid floattype 1 big-endian");
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num8_be;
             break;
 #  endif
 #  if NUMVAL_SIZE == 12
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num12_be;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             exit_fatal(1, "PackFile_unpack: invalid floattype 1 big-endian");
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num12_be;
             break;
 #  endif
 #  if NUMVAL_SIZE == 16
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num16_be;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             exit_fatal(1, "PackFile_unpack: invalid floattype 1 big-endian");
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = fetch_buf_be_16;
             break;
 #  endif
-        default:
+          default:
             exit_fatal(1,
               "PackFile_unpack: unsupported float conversion %d to %d, "
               "PARROT_BIGENDIAN=%d\n",
@@ -1667,33 +1667,33 @@
 
         switch (pf->header->floattype) {
 #  if NUMVAL_SIZE == 8
-        case FLOATTYPE_8: /* native */
+          case FLOATTYPE_8: /* native */
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num8;
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num8;
             break;
 #  endif
 #  if NUMVAL_SIZE == 12
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num12;
             break;
-        case FLOATTYPE_12: /* native */
+          case FLOATTYPE_12: /* native */
             break;
-        case FLOATTYPE_16:
+          case FLOATTYPE_16:
             pf->fetch_nv = cvt_num16_num12;
             break;
 #  endif
 #  if NUMVAL_SIZE == 16
-        case FLOATTYPE_8:
+          case FLOATTYPE_8:
             pf->fetch_nv = cvt_num8_num16;
             break;
-        case FLOATTYPE_12:
+          case FLOATTYPE_12:
             pf->fetch_nv = cvt_num12_num16;
             break;
-        case FLOATTYPE_16: /* native */
+          case FLOATTYPE_16: /* native */
             break;
 #  endif
           default:

Modified: trunk/src/string/charset/unicode.c
==============================================================================
--- trunk/src/string/charset/unicode.c	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/src/string/charset/unicode.c	Sat Nov  7 18:59:03 2009	(r42332)
@@ -834,14 +834,14 @@
     if (flags & enum_cclass_whitespace) {
         /* from http://www.unicode.org/Public/UNIDATA/PropList.txt */
         switch (codepoint) {
-            case 0x1680: case 0x180e: case 0x2000: case 0x2001:
-            case 0x2002: case 0x2003: case 0x2004: case 0x2005:
-            case 0x2006: case 0x2007: case 0x2008: case 0x2009:
-            case 0x200a: case 0x2028: case 0x2029: case 0x202f:
-            case 0x205f: case 0x3000:
-                return 1;
-            default:
-                break;
+          case 0x1680: case 0x180e: case 0x2000: case 0x2001:
+          case 0x2002: case 0x2003: case 0x2004: case 0x2005:
+          case 0x2006: case 0x2007: case 0x2008: case 0x2009:
+          case 0x200a: case 0x2028: case 0x2029: case 0x202f:
+          case 0x205f: case 0x3000:
+            return 1;
+          default:
+            break;
         }
     }
 

Modified: trunk/t/codingstd/c_indent.t
==============================================================================
--- trunk/t/codingstd/c_indent.t	Sat Nov  7 14:44:32 2009	(r42331)
+++ trunk/t/codingstd/c_indent.t	Sat Nov  7 18:59:03 2009	(r42332)
@@ -188,15 +188,26 @@
             #
             # The indentation of the previous line is not considered.
             # Check sanity by verifying that the indentation of the current line
-            # is divisible by four.
-            if ( $indent % 4 &&
-                !$state{in_comment} &&
-                $state{prev_last_char} eq ';'
-            ) {
-                push @c_indent => "$path:$state{line_cnt}\n"
-                    . "    apparent non-4 space indenting ($indent space"
-                    . ( $indent == 1 ? '' : 's' ) . ")\n";
-                $c_failed{"$path\n"} = 1;
+            # is divisible by four, unless it should be outdented by 2.
+            if ($line =~ m{: (?:\s* /\* .*? \*/)? $}x) {
+                if ( $indent % 4 != 2 &&
+                    !$state{in_comment} &&
+                    $state{prev_last_char} eq ';'
+                ) {
+                    push @c_indent => "$path:$state{line_cnt}\n"
+                        . "    apparent non-2 space outdenting ($indent spaces)\n";
+                    $c_failed{"$path\n"} = 1
+                }
+            } else {
+                if ( $indent % 4 &&
+                    !$state{in_comment} &&
+                    $state{prev_last_char} eq ';'
+                ) {
+                    push @c_indent => "$path:$state{line_cnt}\n"
+                        . "    apparent non-4 space indenting ($indent space"
+                        . ( $indent == 1 ? '' : 's' ) . ")\n";
+                    $c_failed{"$path\n"} = 1;
+                }
             }
         }
     }


More information about the parrot-commits mailing list