1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. C++ / Говнокод #2357

    +67.4

    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
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    // die elemente aufbauen
    // wasserstoff (gruppe 1, Nichtmetalle)
    Element* wasserstoff = new Element(this);
    wasserstoff->setObjectName("wasserstoff");
    wasserstoff->setze_element_namen(tr("Hydrogen"));
    wasserstoff->setze_atomzahl(1);
    wasserstoff->setze_symbol("H");
    wasserstoff->setze_masse("1,00794 u");
    wasserstoff->setze_exakte_masse("1.007825032");
    wasserstoff->setze_ionisation("13,5984 kJ/mol");
    wasserstoff->setze_elektronenaffinitaet("1.007825032");
    wasserstoff->setze_elektronen_negativitaet("2,2");
    wasserstoff->setze_kovalenter("37 pm");
    wasserstoff->setze_van_der_waals_radius("120 pm");
    wasserstoff->setze_schmelzpunkt("13.81");
    wasserstoff->setze_siedepunkt("20.28");
    wasserstoff->setze_familie(tr("nonmetal"));
    wasserstoff->setze_gruppenfarbe(gruppenfarben.at(1));
    wasserstoff->setze_entdeckungsjahr(1766);
    wasserstoff->setze_position(0, 1);
    elementliste.insert(wasserstoff->atomzahl(), wasserstoff);
    wasserstoff->registriere_agrgatzustandsfarben(agregatzustandsfarben);
    wasserstoff->fuege_elektronen_hinzu(1, 1);
    
    // helium (gruppe 18, Edelgase)
    Element* helium = new Element(this);
    helium->setObjectName("helium");
    helium->setze_element_namen(tr("Helium"));
    helium->setze_atomzahl(2);
    helium->setze_symbol("He");
    helium->setze_masse("4,0026 u");
    helium->setze_exakte_masse("4.002603254");
    helium->setze_ionisation("24,5874 kJ/mol");
    helium->setze_elektronenaffinitaet("4.002603254");
    helium->setze_elektronen_negativitaet("-1");
    helium->setze_kovalenter("32 pm");
    helium->setze_van_der_waals_radius("140 pm");
    helium->setze_schmelzpunkt("0.95");
    helium->setze_siedepunkt("4.216");
    helium->setze_familie(tr("noble gases"));
    helium->setze_gruppenfarbe(gruppenfarben.at(18));
    helium->setze_entdeckungsjahr(1868);
    helium->setze_position(17, 1);
    elementliste.insert(helium->atomzahl(), helium);
    helium->fuege_elektronen_hinzu(1, 2);
    
    // lithium (gruppe 1, Alkalimetalle)
    Element* lithium = new Element(this);
    
    
    ...
    
    
    // ununhexium (gruppe 16, Metalle)
    Element* ununhexium = new Element(this);
    ununhexium->setObjectName("ununhexium");
    ununhexium->setze_element_namen(tr("Ununhexium"));
    ununhexium->setze_atomzahl(116);
    ununhexium->setze_symbol("Uuh");
    ununhexium->setze_masse("292 u");
    ununhexium->setze_exakte_masse("292.19979");
    ununhexium->setze_ionisation("-1");
    ununhexium->setze_elektronenaffinitaet("292.19979");
    ununhexium->setze_elektronen_negativitaet("-1");
    ununhexium->setze_kovalenter("-1");
    ununhexium->setze_van_der_waals_radius("-1");
    ununhexium->setze_schmelzpunkt(QString::number(INT_MAX));
    ununhexium->setze_siedepunkt(QString::number(INT_MAX));
    ununhexium->setze_familie(tr("other metal"));
    ununhexium->setze_gruppenfarbe(gruppenfarben.at(16));
    ununhexium->setze_entdeckungsjahr(2000);
    ununhexium->setze_position(15, 7);
    elementliste.insert(ununhexium->atomzahl(), ununhexium);
    ununhexium->fuege_elektronen_hinzu(1, 2);
    ununhexium->fuege_elektronen_hinzu(2, 8);
    ununhexium->fuege_elektronen_hinzu(3, 18);
    ununhexium->fuege_elektronen_hinzu(4, 32);
    ununhexium->fuege_elektronen_hinzu(5, 32);
    ununhexium->fuege_elektronen_hinzu(6, 18);
    ununhexium->fuege_elektronen_hinzu(7, 6);
    
    ЗЫ: итого порядка 3000 строк кода

    http://sourceforge.net/projects/qperiodictable

    3dEyes**, 31 Декабря 2009

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

    +63.4

    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
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    /* This construction seems to be more optimiser friendly.
           (without it gcc does the isDIGIT test and the *s - '0' separately)
           With it gcc on arm is managing 6 instructions (6 cycles) per digit.
           In theory the optimiser could deduce how far to unroll the loop
           before checking for overflow.  */
        if (++s < send) {
          int digit = *s - '0';
          if (digit >= 0 && digit <= 9) {
            value = value * 10 + digit;
            if (++s < send) {
              digit = *s - '0';
              if (digit >= 0 && digit <= 9) {
                value = value * 10 + digit;
                if (++s < send) {
                  digit = *s - '0';
                  if (digit >= 0 && digit <= 9) {
                    value = value * 10 + digit;
    		        if (++s < send) {
                      digit = *s - '0';
                      if (digit >= 0 && digit <= 9) {
                        value = value * 10 + digit;
                        if (++s < send) {
                          digit = *s - '0';
                          if (digit >= 0 && digit <= 9) {
                            value = value * 10 + digit;
                            if (++s < send) {
                              digit = *s - '0';
                              if (digit >= 0 && digit <= 9) {
                                value = value * 10 + digit;
                                if (++s < send) {
                                  digit = *s - '0';
                                  if (digit >= 0 && digit <= 9) {
                                    value = value * 10 + digit;
                                    if (++s < send) {
                                      digit = *s - '0';
                                      if (digit >= 0 && digit <= 9) {
                                        value = value * 10 + digit;
                                        if (++s < send) {
                                          /* Now got 9 digits, so need to check
                                             each time for overflow.  */
                                          digit = *s - '0';
                                          while (digit >= 0 && digit <= 9
                                                 && (value < max_div_10
                                                     || (value == max_div_10
                                                         && digit <= max_mod_10))) {
                                            value = value * 10 + digit;
                                            if (++s < send)
                                              digit = *s - '0';
                                            else
                                              break;
                                          }
                                          if (digit >= 0 && digit <= 9
                                              && (s < send)) {
                                            /* value overflowed.
                                               skip the remaining digits, don't
                                               worry about setting *valuep.  */
                                            do {
                                              s++;
                                            } while (s < send && isDIGIT(*s));
                                            numtype |=
                                              IS_NUMBER_GREATER_THAN_UV_MAX;
                                            goto skip_value;
                                          }
                                        }
                                      }
    				 }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
    	 }
          }
        }

    Проверка числа в Perl-модуле. Судя по всему стояла задача оптимизировать под что-то.

    Thomas_55, 30 Декабря 2009

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

    +64.4

    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
    int main(int argc, char **argv){
      QApplication app(argc, argv);
      QWebView view;
      view.load(QUrl("http://www.linuxcertif.com/"));
      view.show();
      app.exec();
      QWebSettings::setIconDatabasePath("/tmp");
      QWebSettings::iconForUrl(QUrl("http://www.linuxcertif.com/"));
      QIcon icon = QWebSettings::iconForUrl(QUrl("http://www.linuxcertif.com/"));
      QPushButton button;
      button.setIcon(icon);
      button.show();
      return app.exec();
    }

    смотрим на восьмую строку и понимаем, что она не делает ничего....
    ошибка то мелкая, было бы не смешно, если тока этот код не распологался бы на багтрекере вебикита - https://bugs.webkit.org/show_bug.cgi?id=29440
    еще в вебките забавно, что если в этом семпле седьмую строку переместить сразу за второй, семпл работает...

    LuCiFer, 29 Декабря 2009

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

    +59.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    //и теперь шлём запрос письма
                        reply = QString("<iq type='get' from='%1' to='%2' id='mail-request-%3'>"\
                            "<query xmlns='google:mail:notify' %4 %5/></iq>")
                                .arg(from)
                                .arg(to)
                                .arg(id)
                                .arg((lastCheck.value(QString("%1").arg(account),"")=="")?QString(""):QString("newer-than-time='%1'").arg(lastCheck.value(QString("%1").arg(account))))
                                .arg((lastTid.value(QString("%1").arg(account),"")=="")?QString(""):QString("newer-than-tid='%1'").arg(lastTid.value(QString("%1").arg(account))));
                        stanzaSender->sendStanza(account, reply);

    Раскопано в недрах плагинов к psi:
    Особенно радует шедевральная конвертация int'а в строку при помощи QString("%1").arg(account),"")
    Плюс ко всему комменты на русском в интернациональном проекте это немножко моветон

    Sauron, 29 Декабря 2009

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

    +67.3

    1. 1
    length=length%8==0?0:length+8-length%8;

    пытаемся округлить length до 8 в большую сторону...
    краткость - сестра ... таланта?

    dIsoVi, 24 Декабря 2009

    Комментарии (41)
  10. C++ / Говнокод #2285

    +143.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #define true false
    
    ...
    
    
    #define double int
    
    ...
    
    
    #define TRUE FALSE
    // удачной отладки суки

    4cppMan, 16 Декабря 2009

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