1. C++ / Говнокод #2368

    +51.9

    1. 1
    2. 2
    3. 3
    #define GetNextWindow(hWnd, wCmd) GetWindow(hWnd, wCmd)
    #define GetSysModalWindow() (NULL)
    #define SetSysModalWindow(hWnd) (NULL)

    Microsoft SDK, WinUser.h.

    Altravert, 04 Января 2010

    Комментарии (43)
  2. C++ / Говнокод #2367

    +65.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    case WM_DESTROY:
        // Microsoft, you MORONS! Don't destroy stuff I create!
        // Oh well, try to handle this as gracefully as possible so we
        // don't send any commands to the now non-existent window:
        tablet_close(hWnd);
        if (window) window->destroy();
        fl_prune_deferred_calls(hWnd);
        break;

    FLTK. В свое время заставило похихикать.

    Altravert, 04 Января 2010

    Комментарии (13)
  3. C++ / Говнокод #2366

    +66.4

    1. 1
    2. 2
    3. 3
    4. 4
    int str_length(const char *str)
    {
    	return (int)strlen(str);
    }

    Опенсорс, если чо.

    Ambilight, 03 Января 2010

    Комментарии (69)
  4. C++ / Говнокод #2365

    +65.3

    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
    struct Point
    {
    	double x,y,z;
    	Point()
    	{
    L1:
    		x=Rand();
    		y=Rand();
    		z=Rand();
    		double r=sqrt(x*x+y*y+z*z);
    		if(r<eps)
    			goto L1;
    		x/=r;
    		y/=r;
    		z/=r;
    	}
    
    	...
    };

    brainiac, 03 Января 2010

    Комментарии (42)
  5. C# / Говнокод #2364

    +134.5

    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
    static void Main(string[] args)
            {
                if (args.Length < 1)
                    Console.WriteLine("Usage:\n\tprogram <Folder> [output file]");
                else if (args.Length == 1)
                {
                    string outf = args[0] + "\\output.txt";
                    System.IO.File.WriteAllLines
                        (
                            outf,
                            new List<string>
                                (
                                    System.IO.Directory.GetFiles(args[0])
                                )
                                    .Concat(System.IO.Directory.GetDirectories(args[0]))
                                    .ToArray()
                        );
                }
                else if(args.Length == 2)
                {
                    string outf = args[1];
                    System.IO.File.WriteAllLines
                        (
                            outf,
                            new List<string>
                                (
                                    System.IO.Directory.GetFiles(args[0])
                                )
                                    .Concat(System.IO.Directory.GetDirectories(args[0]))
                                    .ToArray()
                        );
                }
            }

    Видите ли, я не знал как это сделать с помощью скриптовых языков виндовс.

    psina-from-ua, 01 Января 2010

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

    +55.3

    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
    #define constuserColor "usercolor"
    #define consttagColor "tagcolor"
    #define constmsgColor "idcolor"
    #define constQcolor "quotecolor"
    #define constLcolor "linkcolor"
    #define constUbold "userbold"
    #define constTbold "tagbold"
    #define constMbold "idbold"
    #define constQbold "quotebold"
    #define constLbold "linkbold"
    #define constUitalic "useritalic"
    #define constTitalic "tagitalic"
    #define constMitalic "iditalic"
    #define constQitalic "quoteitalic"
    #define constLitalic "linkitalic"
    #define constUunderline "userunderline"
    #define constTunderline "tagunderline"
    #define constMunderline "idunderline"
    #define constQunderline "quoteunderline"
    #define constLunderline "linkunderline"
    #define constIdAsResource "idAsResource"
    #define constShowPhoto "showphoto"
    #define constShowAvatars "showavatars"
    #define constWorkInGroupchat "workingroupchat"
    #define constVersion "0.9.9"
    
    class JuickPlugin : public QObject, public PsiPlugin, public EventFilter, public OptionAccessor, public ActiveTabAccessor,
        public StanzaFilter, public ApplicationInfoAccessor
    {
            Q_OBJECT
            Q_INTERFACES(PsiPlugin EventFilter OptionAccessor ActiveTabAccessor StanzaFilter ApplicationInfoAccessor)
    
    public:
            JuickPlugin();
            virtual QString name() const;
            virtual QString shortName() const;
            virtual QString version() const;
            virtual QWidget* options();
            virtual bool enable();
            virtual bool disable();
            virtual void applyOptions();
            virtual void restoreOptions();
            virtual bool processEvent(int account, QDomElement& e);
            virtual bool processMessage(int account, const QString& fromJid, const QString& body, const QString& subject);
            // OptionAccessor
            virtual void setOptionAccessingHost(OptionAccessingHost* host);
            virtual void optionChanged(const QString& option);
            //ActiveTabAccessor
            virtual void setActiveTabAccessingHost(ActiveTabAccessingHost* host);
            //ApplicationInfoAccessor
            virtual void setApplicationInfoAccessingHost(ApplicationInfoAccessingHost* host);
    
            virtual bool incomingStanza(int account, const QDomElement& stanza);
            void elementFromString(QDomElement& body,QDomDocument e, QString& msg, QString jid, QString resource = "");
            void nl2br(QDomElement& body,QDomDocument e, QString msg);
            void addPlus(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addSubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addHttpLink(QDomElement& body,QDomDocument e, QString msg);
            void addTagLink(QDomElement& body,QDomDocument e, QString tag, QString jid);
            void addUserLink(QDomElement& body,QDomDocument e, QString nick, QString altText, QString pattern, QString jid);
            void addMessageId(QDomElement& body,QDomDocument e, QString mId, QString altText,QString pattern, QString jid, QString resource = "");
            void addUnsubscribe(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addDelete(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");
            void addFavorite(QDomElement& body,QDomDocument e, QString msg, QString jid, QString resource = "");

    Краткость - сестра таланта... Только видимо авторы этого чуда эту пословицу не знают.
    Да и количество непонятных макросов нам тоже намекает.
    Ну и конечно же необходимость в таком страшном множественном наследовании с возможностью рандомных побочных эффектов тоже намекает нам о говноархитектуре. В общем не зря авторы Psi решили начать писать новый клиент.

    Sauron, 01 Января 2010

    Комментарии (13)
  7. C# / Говнокод #2362

    +950.3

    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
    //...
    for (int i = 0; i < arr.Length; i++)
    {
          if (i == 5)
          {
                 if (arr[i] == -1)
                 {
                        break;
                 }
                 else
                 {
                        return -1;
                 }
          }
          else continue;
    }
    //...

    FMB, 31 Декабря 2009

    Комментарии (14)
  8. PHP / Говнокод #2361

    +162.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $comments = (isset($_POST['lici-'.$login->id.'-comments']))?"yes":"no";
    
    if($comments === "yes")
    {
    $xml .= "<nocomment>1</nocomment>\r\n";
    }

    Код из плагина кросспостера для wordpress.
    Автор, видимо, не знает про булев тип. Все бы было хорошо, если бы плагин не закрывал комментарии, когда их нужно было открывать.

    gunya, 31 Декабря 2009

    Комментарии (4)
  9. C# / Говнокод #2360

    +131.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    internal static System.Drawing.Font ToWindowsFont(Microsoft.Office.Interop.PowerPoint.Font ppFont)
    {
    	FontStyle style = ToGdiFontStyle(ppFont.Style);
    	System.Drawing.Font gdiFont = new System.Drawing.Font(ppFont.Name, ppFont.Size, style);
    	// из-за следующей строчки проект не скомпилируется под .NET 2.0, требуя ещё и один из более новых SP
    	if ( windowsFont.Name != windowsFont.OriginalFontName )
    	{
    		windowsFont = new System.Drawing.Font(TextConverter.DefaultUnicodeSubstituteFont, ppFont.Size, style);
    	}
    	return windowsFont;
    }

    Баг был случайно найден на виртуалке с чистой Windows XP и MS Visual Studio 2005, поскольку мы по собственной глупости упустили тот факт, что на хост-машинах давно стоит .NET 3.5. Строчка "if ( windowsFont.Name != ppFont.Name )" решает проблему совместимости. Вот как иногда из-за маленькой, не бросающейся в глаза, ошибки можно завалить весь проект. Каюсь, этот код - мой. ))

    cyba, 31 Декабря 2009

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

    +184.4

    1. 1
    $happy = new Year();

    C наступающим ;)

    miami, 31 Декабря 2009

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