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

    −40

    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
    #include <stdio.h>
    #include <unistd.h> 
    #include <stdlib.h> 
    #include <string.h>
    #include <iostream>
    #include <string>
    using namespace std;
    
    static char ifnm[100];
    string *tags = new string [100];
    int tags_init(string stag[]){
      int i=0;
      stag[i++]="root";
      stag[i++]="word";
      stag[i++]="english";
      stag[i++]="russian";
      stag[i++]="russian2";
    //  stag[i++]="id";
      return i;
    };
    int main(int argc,char *argv[]){
    FILE *fp;
    if(argc=0){printf("No file name\n");exit(0);}
    strcpy(ifnm,argv[1]);
    fp = fopen(ifnm, "r");
    if (fp == NULL)exit(-1);
      //Error;
    char str[180];
    int tn=tags_init(tags);
    cout<<"<"<<tags[0]<<">"<<endl;
    while(fgets(str, 180,fp))
    {
      fgets(str,180, fp);
      //cout<<str<<endl;
      char *pname;
        pname = strtok (str,"-");
        int ti=0;
        cout<<"<"<<tags[1]<<">"<<endl;
        ti=1;
      while (pname != NULL && ti<=tn)
      {
        ti++;
        cout<<"<"<<tags[ti]<<">"<<endl;
        printf ("\t%s\n",pname);
        cout<<"</"<<tags[ti]<<">"<<endl;
        pname = strtok (NULL, "-");
      }
    cout<<"</"<<tags[1]<<">"<<endl;
    }
    cout<<"</"<<tags[0]<<">"<<endl;
    
    fclose(fp);
    }

    Преобразует текстовый файл в xml формат

    AliceGoth, 21 Июня 2012

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

    −40

    1. 1
    *new

    Самая соль.

    Говногость, 20 Июня 2012

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

    −36

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    //установка режима реализма
    		void includeRealTimeMode()
    		{
    			TSerialCommand^ command = gcnew TSerialCommand;
    			command->cmd = CMD_CONTROL;
    			command->sc1 = SC_REAL_TIME_MODE;
    			command->sc2 = NULL; //_portManager.oscillFrequency;
    			_portManager.sendCommand(command);
    
    		}

    Команда включает (активирует) режим реального времени.
    C++\CLI

    Говногость, 19 Июня 2012

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

    −30

    1. 1
    TTime childStartTime(TDateTime(2006, EJanuary, 8, 14, 0, 0, 0)); // January 9th 2pm

    Из примера calexample в symbian sdk.

    bormand, 19 Июня 2012

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

    −35

    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
    // For the probably_koi8_locales we have to look. the standard says
    // these are 8859-5, but almost all Russian users use KOI8-R and
    // incorrectly set $LANG to ru_RU. We'll check tolower() to see what
    // it thinks ru_RU means.
    // If you read the history, it seems that many Russians blame ISO and
    // Perestroika for the confusion.
    ...
    static QTextCodec * ru_RU_hack(const char * i) {
        QTextCodec * ru_RU_codec = 0;
    
    #if !defined(QT_NO_SETLOCALE)
        QByteArray origlocale(setlocale(LC_CTYPE, i));
    #else
        QByteArray origlocale(i);
    #endif
        // unicode   koi8r   latin5   name
        // 0x044E    0xC0    0xEE     CYRILLIC SMALL LETTER YU
        // 0x042E    0xE0    0xCE     CYRILLIC CAPITAL LETTER YU
        int latin5 = tolower(0xCE);
        int koi8r = tolower(0xE0);
        if (koi8r == 0xC0 && latin5 != 0xEE) {
            ru_RU_codec = QTextCodec::codecForName("KOI8-R");
        } else if (koi8r != 0xC0 && latin5 == 0xEE) {
            ru_RU_codec = QTextCodec::codecForName("ISO 8859-5");
        } else {
            // something else again... let's assume... *throws dice*
            ru_RU_codec = QTextCodec::codecForName("KOI8-R");
            qWarning("QTextCodec: Using KOI8-R, probe failed (%02x %02x %s)",
                      koi8r, latin5, i);
        }
    #if !defined(QT_NO_SETLOCALE)
        setlocale(LC_CTYPE, origlocale);
    #endif
    
        return ru_RU_codec;
    }

    Снова Qt. На этот раз src/corelib/codecs/qtextcodec.cpp и борьба бобра с ослом русских с буржуинскими стандартами ISO.

    bormand, 14 Июня 2012

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

    −55

    1. 1
    2. 2
    3. 3
    void f(int...)
    {
    };

    Компилится.
    http://ideone.com/yPgoq

    HaskellGovno, 13 Июня 2012

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

    −37

    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
    static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        ... еще 12 строк ...
        QPainterPath::MoveToElement, QPainterPath::LineToElement
    };
    
    static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 1
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 2
        ... еще 29 строк ...
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 31
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 32
    };

    Qt 4.x.x, src/gui/painting/qpaintengineex.cpp
    Как я понял, используется для ускорения функций drawLines и clip (дабы не выделять память и не заполнять path каждый раз).

    bormand, 13 Июня 2012

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

    −51

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void a() 
    {
    }
     
    void b()
    {
      return a();
    }

    Компилится.
    http://ideone.com/8eP1w

    HaskellGovno, 13 Июня 2012

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

    −16

    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
    template <class T>
    inline T qobject_cast(const QObject *object)
    {
        // this will cause a compilation error if T is not const
        register T ptr = static_cast<T>(object);
        Q_UNUSED(ptr);
    
    #if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
        reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
    #endif
        return static_cast<T>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject
     *>(object))));
    }

    Кастовали-кастовали и выкастовали!
    corelib/kernel/qobject.h в Qt 4.7.x

    bormand, 12 Июня 2012

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

    −33

    1. 1
    2. 2
    bool operator()(int x,int y)
    {return x<y;}

    Вторая часть) реально интересуются люди
    "надо два объекта моего класса сравнить, так?"
    ну, вообще жесть

    Diss, 11 Июня 2012

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