1. Си / Говнокод #15828

    +133

    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
    ...
    int
    (mblen)(const char *s, size_t n)
    {
    	if (s == (const char *)NULL) return 0;	/* no state dependent codings */
    	if (n <= 0) return 0;
    	return (*s != 0);
    }
    ...
     int
    mbtowc(wchar_t *pwc, register const char *s, size_t n)
    {
    	if (s == (const char *)NULL) return 0;
    	if (n <= 0) return 0;
    	if (pwc) *pwc = *s;
    	return (*s != 0);
    }
    ...
     int
    wctomb(char *s, wchar_t wchar)
    {
    	if (!s) return 0;		/* no state dependent codings */
    
    	*s = wchar;
    	return 1;
    }

    THE AMSTERDAM COMPILER KIT V6.0pre4
    ===================================

    © 1987-2005 Vrije Universiteit, Amsterdam
    2010-08-08

    ...

    SUPPORT
    =======

    Languages:

    ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler.



    А где здесь, собсно, ANSI C?

    Pythoner, 23 Апреля 2014

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

    +141

    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
    ...
    else if ( (!BG_InSpecialJump( legsAnim )//not in a special jump anim 
    						||BG_InReboundJump( legsAnim )//we're already in a rebound
    						||BG_InBackFlip( legsAnim ) )//a backflip (needed so you can jump off a wall behind you)
    					//&& pm->ps->velocity[2] <= 0 
    					&& pm->ps->velocity[2] > -1200 //not falling down very fast
    					&& !(pm->ps->pm_flags&PMF_JUMP_HELD)//have to have released jump since last press
    					&& (pm->cmd.forwardmove||pm->cmd.rightmove)//pushing in a direction
    					//&& pm->ps->forceRageRecoveryTime < pm->cmd.serverTime	//not in a force Rage recovery period
    					&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_2//level 3 jump or better
    					//&& WP_ForcePowerAvailable( pm->gent, FP_LEVITATION, 10 )//have enough force power to do another one
    					&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_LEVITATION)
    					&& (pm->ps->origin[2]-pm->ps->fd.forceJumpZStart) < (forceJumpHeightMax[FORCE_LEVEL_3]-(BG_ForceWallJumpStrength()/2.0f)) //can fit at least one more wall jump in (yes, using "magic numbers"... for now)
    					//&& (pm->ps->legsAnim == BOTH_JUMP1 || pm->ps->legsAnim == BOTH_INAIR1 ) )//not in a flip or spin or anything
    					)
    			{//see if we're pushing at a wall and jump off it if so
    				if ( allowWallGrabs )
    				{
    					//FIXME: make sure we have enough force power
    					//FIXME: check  to see if we can go any higher
    					//FIXME: limit to a certain number of these in a row?
    					//FIXME: maybe don't require a ucmd direction, just check all 4?
    					//FIXME: should stick to the wall for a second, then push off...
    ...

    Больше условий богу условий!
    Jedi Academy source, 2003

    gost, 21 Апреля 2014

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

    +123

    1. 1
    drwsr

    Pizda, 12 Апреля 2014

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

    +117

    1. 1
    bormand сосёт анус своему отцу, размазывая говно по лицу.

    Pizda, 12 Апреля 2014

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

    +133

    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
    #ifndef _TOGGLE_H_
    #define _TOGGLE_H_
    
    #include <winbase.h>
    #include "Python.h"
    
    #define ID(X) "id(" #X ")"
    
    #define SET_OBJ_POINTER(OBJ, NAME)\
        OBJ = (PyObject *)PyLong_AsLong\    
        (PyRun_String(ID(NAME), Py_eval_input,\
        PyEval_GetGlobals(), PyEval_GetLocals()))
    
    //////////////////////////////////////////////////////
    
    PyObject * __Py_None__;
    PyObject * __Py_True__;
    PyObject * __Py_False__;
    PyObject * __Py_NotImplemented__;
    
    #undef  Py_None
    #undef  Py_True
    #undef  Py_False
    #undef  Py_NotImplemented
    
    #define Py_None __Py_None__
    #define Py_True __Py_True__
    #define Py_False __Py_False__
    #define Py_NotImplemented __Py_NotImplemented__
    
    //////////////////////////////////////////////////////
    
    static void initToggle(void) {
        SET_OBJ_POINTER(Py_None, None);
        SET_OBJ_POINTER(Py_True, True);
        SET_OBJ_POINTER(Py_False, False);
        SET_OBJ_POINTER(Py_NotImplemented, NotImplemented);
    }
    
    int WINAPI DllMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved) {
        initToggle();
        return 1;
    }
    
    #endif

    Раскопал на старой флешке костыль, позволяющий компилить сишные модули для питона прям на кпк под WinMobile с помощью портанутой gcc. Была там бага - не видел собранный модуль Py_None, Py_True и т.д из python.dll. При помощи макроса SET_OBJ_POINTER приходилось вытаскивать указатели на них.

    Pythoner, 12 Апреля 2014

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

    +133

    1. 1
    2. 2
    3. 3
    if (access(path, aflag) && mkfifo(path, mode) {
            exit(-1);
    }

    Весьма интуитивная запись условия

    evg_ever, 11 Апреля 2014

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

    +140

    1. 1
    http://yadi.sk/d/4HDnPUi2MCCRa

    Мисато и говнокод.

    Здесь мы видим пять прототипов WinMain'а подряд, а шестой, который чуть пониже, использует вывод типов сишкофичу int-по-умолчанию...

    P.S. Скорее всего этот пост заминусуют за оффтоп и передачу по ссылке, но я просто не мог не выложить этот снимок ;)

    bormand, 10 Апреля 2014

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

    +131

    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
    int main(void)
    {
    printf ("NIGGA0");
            int pipeKey, pipeText, i,test;
            char key[BUFSIZEKEY];
            char *p;
            char buf;
            pipeKey = open(PATHKEY, O_RDONLY);
            //for (p = key; read(pipeKey, p, 1); p++);
            for (i=0; i<BUFSIZEKEY; i++)
            {
                    read(pipeKey, &key[i], 1); 
            }
            close(pipeKey);
            pipeKey = open(PATHTEXT, O_RDONLY);
            printf ("NIGGA1");
            //for (i=1; read(pipeText, &buf, 1); i++)
            for (i=1; i<=20; i++)
            {
                    printf ("nigersonly");
                    printf ("\n-----\n i= %d test= %c \n-----\n", i, buf);

    Чувак минут 20 не мог понять, почему у него buf всегда 0 в последней строчке из приведённых. printf'ы тоже норм =)

    evg_ever, 09 Апреля 2014

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

    +133

    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
    #ifndef ORDER32_H
    #define ORDER32_H
    
    #include <limits.h>
    #include <stdint.h>
    
    #if CHAR_BIT != 8
    #error "unsupported char size"
    #endif
    
    enum
    {
        O32_LITTLE_ENDIAN = 0x03020100ul,
        O32_BIG_ENDIAN = 0x00010203ul,
        O32_PDP_ENDIAN = 0x01000302ul
    };
    
    static const union { unsigned char bytes[4]; uint32_t value; } o32_host_order =
        { { 0, 1, 2, 3 } };
    
    #define O32_HOST_ORDER (o32_host_order.value)
    
    #endif

    Говнокод из http://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine
    Мало того, что писать в один тип из юниона и потом читать из другого это UB, так еще компилятор (в случае GCC) из

    int main(void)
    {return O32_HOST_ORDER == O32_LITTLE_ENDIAN;}

    нагенерирует код
    main:
    xor eax, eax
    cmp DWORD PTR o32_host_order[rip], 50462976
    sete al
    ret
    o32_host_order:
    .byte 0
    .byte 1
    .byte 2
    .byte 3

    т.е. всякий раз, когда надо узнать endianess, мы лезем в константную статическую переменную и сравниваем ее с константой

    j123123, 08 Апреля 2014

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

    +131

    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
    /*
    =====================
    Q_acos
    
    the msvc acos doesn't always return a value between -PI and PI:
    
    int i;
    i = 1065353246;
    acos(*(float*) &i) == -1.#IND0
    
    	This should go in q_math but it is too late to add new traps
    	to game and ui
    =====================
    */

    Астрологи объявили неделю Деда Лайна - количество говнокода и костылей увеличилось вдвое.

    gost, 05 Апреля 2014

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