1. Список говнокодов пользователя xaionaro

    Всего: 12

  2. PHP / Говнокод #11916

    +66

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    <?php
    
       //You can even add more Dollar Signs
    
       $Bar = "a";
       $Foo = "Bar";
       $World = "Foo";
       $Hello = "World";
       $a = "Hello";
    
       $a; //Returns Hello
       $$a; //Returns World
       $$$a; //Returns Foo
       $$$$a; //Returns Bar
       $$$$$a; //Returns a
    
       $$$$$$a; //Returns Hello
       $$$$$$$a; //Returns World
    
       //... and so on ...//
    
    ?>

    Из комментов на http://www.php.net/manual/en/language.variables.variable.php

    xaionaro, 12 Октября 2012

    Комментарии (24)
  3. Си / Говнокод #5839

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #define v putchar
    #define print(x) main(){v(4+v(v(52)-4));return 0;} /*
    #>++++++4[>++++++<-]>++++.----.++++.**/
    print(202*2);exit();
    #define/*>.@*/exit()

    Для кого-то покажется бояном, но меня улыбнуло. Явно искусственный код взятый со stackoverflow.com

    xaionaro, 01 Марта 2011

    Комментарии (21)
  4. bash / Говнокод #5734

    −131

    1. 1
    ping -q -c 2 -i "0.$ACTN" localhost > /dev/null

    Способ заснуть менее чем на секунду, не дописывая для этого отдельную программу Сишную с использованием nanosleep().

    xaionaro, 21 Февраля 2011

    Комментарии (28)
  5. bash / Говнокод #5674

    −135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    parsemask() {
            echo -n "$@" | tr -d "\n" | sed -e "s#%%#\n#g" | sed -e "s#%C#$CLUSTER#g" | sed -e "s#%R#$XENXROOT#g" | tr "\n" "%";
            return;
    }
    
    for pvar in STATUSPATH LOGPATH DRBDLOGPATH XENXPREFIX CLUSTERSPATH; do
            eval R${pvar}="`parsemask "$(eval echo \\\$${pvar})"`"
    done

    Реализация разыменовки и замены в цикле, для того, чтобы для каждой переменной (например LOGPATH="%R/var/log/xenx/%C.log") определилась соответствующая переменная с произведёнными подстановками (например RLOGPATH="/usr/local/xenx/var/log/xenx/stormrage.log").

    xaionaro, 14 Февраля 2011

    Комментарии (3)
  6. Си / Говнокод #3472

    +131

    1. 1
    2. 2
    3. 3
    int newclient(var v, newconn oldconn) {
            [...]
    }

    Ничего особенного, конечно. Просто порадовало "newconn oldconn".

    xaionaro, 14 Июня 2010

    Комментарии (10)
  7. Си / Говнокод #2691

    +133.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    char *errdesc;
    
    [...]
    
                switch errno
                {
                    case EACCES: errdesc="For Unix domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also path_resolution(2).) " ;break;
                    case EPERM: errdesc="The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule. ";break;
                    case EADDRINUSE: errdesc="Local address is already in use. ";break;
                    case EAFNOSUPPORT: errdesc="The passed address didn't have the correct address family in its sa_family field. ";break;
                    case EAGAIN: errdesc="No more free local ports or insufficient entries in the routing cache. For PF_INET see the net.ipv4.ip_local_port_range sysctl in ip(7) on how to increase the number of local ports. ";break;
                    case EALREADY: errdesc="The socket is non-blocking and a previous connection attempt has not yet been completed. ";break;
                    case EBADF: errdesc="The file descriptor is not a valid index in the descriptor table. ";break;
                    case ECONNREFUSED: errdesc="No one listening on the remote address. ";break;
                    case EFAULT: errdesc="The socket structure address is outside the user's address space. ";break;
                    case EINPROGRESS: errdesc="The socket is non-blocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure). ";break;
                    case EINTR: errdesc="The system call was interrupted by a signal that was caught. ";break;
                    case EISCONN: errdesc="The socket is already connected. ";break;
                    case ENETUNREACH: errdesc="Network is unreachable. ";break;
                    case ENOTSOCK: errdesc="The file descriptor is not associated with a socket. ";break;
                    case ETIMEDOUT: errdesc="Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.";break;
                    case EADDRNOTAVAIL: errdesc="EADDRNOTAVAIL";break;
                    case EPROTOTYPE: errdesc="EPROTOTYPE";break;
                    case EINVAL: errdesc="Invalid argument passed.";break;
                    case ENOMEM: errdesc="Could not allocate memory for recvmsg().";break;
                    case ENOTCONN: errdesc="The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)).";break;
                    default: errdesc="Unknown error";break;
                }

    Мдя, просматривать код писанный мной же, когда я ещё только-только начинал писать на Си стыдновато. :)

    xaionaro, 28 Февраля 2010

    Комментарии (17)
  8. Си / Говнокод #2302

    +99.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #include "org_herac_tuxguitar_player_impl_midiport_oss_MidiSystem.h"
    ...
    JNIEXPORT jlong JNICALL Java_org_herac_tuxguitar_player_impl_midiport_oss_MidiSystem_malloc(JNIEnv* env, jobject obj) {
        ...
    }

    Взято из TuxGuitar

    xaionaro, 19 Декабря 2009

    Комментарии (30)
  9. PHP / Говнокод #2274

    +190.1

    1. 1
    if (isset($_COOKIE[SECURITY_COOKIE]) == "block")

    После этой строки шёл код для забаненных.

    (код взят из SLAED)

    xaionaro, 13 Декабря 2009

    Комментарии (7)
  10. Си / Говнокод #2135

    +136.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    ...
    
    // TODO: remove this godless "switch()"!
                    switch(tuntype) { // TODO: Important: do as in documentation instead of reverse-ingeniering!
    #define PACKET_TRY {\
                    if(packet->ip_v == 4) {\
                            hl=packet->ip_hl<<2;\
                            if(hl>=sizeof(*packet))\
                                    break;\
                            /* TODO: Check in RFC something about of ICMP send-back in this case */\
                            fprintf(stderr, "Got too short IP-header (%i)...\n",hl);\
                    }\
                    if((packet->ip_v&IPV6_VERSION_MASK) == IPV6_VERSION) {\
                            break;\
                    }\
    }
    #define NEXT(a) tuntype=a;\
                    if(tuntry>=2)\
                            goto tun_process_switch_end;\
                    tuntry++;
    #define CASE(a) NEXT(a);\
            case a
    tun_process_switch:
    //              switch(tuntype) {
                            case TUNTYPE_NORM:              // NetBSD-like?
                                    packet=(typeof(packet))ptr;
                                    PACKET_TRY;
                            CASE(TUNTYPE_EXT):              // FreeBSD-like?
                                    packet=(typeof(packet))((char *)ptr + 4);
                                    if(s>4)
                                            if(*ptr==0x02)
                                                    PACKET_TRY;
                            CASE(TUNTYPE_ETH):              // Ethernet? TODO: Implement VLAN-tagging
                                    packet=(typeof(packet))((char *)ptr + sizeof(*eth));
                                    eth=(typeof(eth))ptr;
                                    if(!teth) {
                                            teth=alloca(sizeof(*teth));
                                            memcpy(&teth->ether_shost, &eth->ether_dhost, sizeof(teth->ether_shost));
                                            memcpy(&teth->ether_dhost, &eth->ether_shost, sizeof(teth->ether_dhost));
                                            teth->ether_type=ETHERTYPE_IP;
                                    }
                                    if(s>sizeof(*eth))
    //                                      if((*(char *)&eth->ether_type==0x08/* not IPv4? */)||(*(char *)&eth->ether_type==0x86/* not IPv6? */))  // TODO: Implement compatibility with all protocols over ethernet
                                                    PACKET_TRY;
                                    NEXT(TUNTYPE_NORM);
                                    goto tun_process_switch;
                            
                            default:                        
                                    tuntype=TUNTYPE_NORM;
                                    goto tun_process_switch;
    //              }
    tun_process_switch_end:
    #undef CASE
    #undef NEXT
    #undef PACKET_TRY
                                    if(tuntry<~0)
                                            tuntry=0;
                                    tuntype=oldtuntype;
                                    fprintf(stderr, "Got unknown packet. Flushing...\n");
                                    FLUSH;  // Flush all. We don't know the length of packet with unknown type.. So, we have to flush the buffer, to probably get new packets from the start.
                                    goto tun_process_while;
                    }
    
    ...

    "Ляпотааааа"... Очень "структурный" switch...

    xaionaro, 11 Ноября 2009

    Комментарии (11)
  11. Си / Говнокод #1659

    +136.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    #define CHAINFREE_STATIC_DAT(a, field) {\
        ptr=(typeof(ptr))&(a);\
        if(((typeof(&(a)))(ptr))->field)\
            free(((typeof(&(a)))(ptr))->field);\
        ptr=(typeof(ptr))(((typeof(&a))(ptr))->next);\
        if(ptr) {\
            while(((typeof(&(a)))(ptr))->next) {\
                if(((typeof(&(a)))(ptr))->field)\
                    free(((typeof(&(a)))(ptr))->field);\
                ptr=(typeof(ptr))(((typeof(&a))(ptr))->next);\
                free(((typeof(&(a)))(ptr))->prev);\
            }\
            if(((typeof(&(a)))(ptr))->field)\
                free(((typeof(&(a)))(ptr))->field);\
            free(ptr);\
        }\
        memset(&(a), 0, sizeof(a));\
    }

    Кол-во скобок радует :)

    xaionaro, 22 Августа 2009

    Комментарии (13)