Кресты / Говнокод #2219 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
void write_msg(const QString& msg, AsyncMp* mp) {
    written(QString(mp?"%1[%2]":"" " %3").arg(mp->my_host()).arg(mp->my_index()).arg(msg));
}

А потом удивляемся: чего же оно не работает?

Thomas_55 Thomas_55, (Updated )

Комментарии (5, +5)

Кресты / Говнокод #2210 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
int proverka_na_chislo(string str){
  int l=0;
  for(unsigned int i=0; i<str.length();i++) {
   if(str.compare(i,i+1,"0")!=0){
     if(str.compare(i,i+1,"1")!=0){
       if(str.compare(i,i+1,"2")!=0){
         if(str.compare(i,i+1,"3")!=0){
           if(str.compare(i,i+1,"4")!=0){
             if(str.compare(i,i+1,"5")!=0){
               if(str.compare(i,i+1,"6")!=0){
                 if(str.compare(i,i+1,"7")!=0){
                   if(str.compare(i,i+1,"8")!=0){
                      if(str.compare(i,i+1,"9")!=0){
                        throw std::invalid_argument("invalid argument\n");
                        l=-1;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return l;
}

Проверка на число.

LocalStorm LocalStorm, (Updated )

Комментарии (26, +26)

Кресты / Говнокод #2208 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
#include "qscriptdebuggercodefinderwidgetinterface_p.h"
#include "qscriptdebuggercodefinderwidgetinterface_p_p.h"

QT_BEGIN_NAMESPACE

QScriptDebuggerCodeFinderWidgetInterfacePrivate::QScriptDebuggerCodeFinderWidgetInterfacePrivate()
{
}

QScriptDebuggerCodeFinderWidgetInterfacePrivate::~QScriptDebuggerCodeFinderWidgetInterfacePrivate()
{
}

QScriptDebuggerCodeFinderWidgetInterface::~QScriptDebuggerCodeFinderWidgetInterface()
{
}

QScriptDebuggerCodeFinderWidgetInterface::QScriptDebuggerCodeFinderWidgetInterface(
    QScriptDebuggerCodeFinderWidgetInterfacePrivate &dd,
    QWidget *parent, Qt::WindowFlags flags)
    : QWidget(dd, parent, flags)
{
}

QT_END_NAMESPACE

Qt 4.6. Файл src/scripttools/debugging/qscriptdebuggercodefinderwidgetinterface .cpp, типичный образец исходного кода класса Qt.

Lockal Lockal, (Updated )

Комментарии (8, +8)

Кресты / Говнокод #2200 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
// Код на Qt
QStringList list;
...
if (0 == QString::compare(list[i].data()[0],' ',Qt::CaseInsensitive))
{
...
}
..

Сравнение нулевого символа i-той строки с пробелом)))

k06a k06a, (Updated )

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

Кресты / Говнокод #2155 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
// Finally, parse shader script and load data
if (!LoadShaderResource(_proxyShader, scriptData))
{
        runtime_assert_msg(ASSERT_Forced, "Proxy shader failed to initialize.\n"
                "You are not assumed to be using such sucking hardware.\n"
                "Kill your GPU and then kill yourself, looser!\n\n"
                "Best regards, Abyss Lights Team");
}

Хорошо что в релиз не попало :) Совершенно случайно нашел в render системе.

Durane Durane, (Updated )

Комментарии (7, +7)

Кресты / Говнокод #2142 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
std::string basic::_gettime(time_t t)
    {
        string res;
        string tt;
        //must be Wdy, DD-Mon-YYYY HH:MM:SS GMT
        struct tm *tm_res;
        tm_res=gmtime(&t);
        switch(tm_res->tm_wday)
        {
            case 0:
                res+="Sun";
                break;
            case 1:
                res+="Mon";
                break;
            case 2:
                res+="Tue";
                break;
            case 3:
                res+="Wed";
                break;
            case 4:
                res+="Thu";
                break;
            case 5:
                res+="Fri";
                break;
            case 6:
                res+="Sat";
                break;
            default:
                throw "Internal error: cgi_app::_gettime(): Day num>6!";
        }
        res+=", ";
        tt=itoa(tm_res->tm_mday);
        if(tt.length()==1)
            tt="0"+tt;
        res+=tt;
        res+="-";
        switch(tm_res->tm_mon)
        {
            case 0:
                res+="Jan";
                break;
            case 1:
                res+="Feb";
                break;
            case 2:
                res+="Mar";
                break;
            case 3:
                res+="Apr";
                break;
            case 4:
                res+="May";
                break;
            case 5:
                res+="Jun";
                break;
            case 6:
                res+="Jul";
                break;
            case 7:
                res+="Aug";
                break;
            case 8:
                res+="Sep";
                break;
            case 9:
                res+="Oct";
                break;
            case 10:
                res+="Nov";
                break;
            case 11:
                res+="Dec";
                break;
            default:
                throw "Internal error: cgi_app::_gettime(): Month num>11!";
        }
        res+="-";
        tt=itoa(tm_res->tm_year+1900);
        res+=tt;
        res+=" ";
        tt=itoa(tm_res->tm_hour);
        if(tt.length()==1)
            tt="0"+tt;
        res+=tt;
        res+=":";
        tt=itoa(tm_res->tm_min);
        if(tt.length()==1)
            tt="0"+tt;
        res+=tt;
        res+=":";
        tt=itoa(tm_res->tm_sec);
        if(tt.length()==1)
            tt="0"+tt;
        res+=tt;
        res+=" GMT";
}

Делаю класс для работы с CGI. Сначала хотел использовать какое-нибудь готовое решение, но ничего подходящего не нашел. По общей концепции понравилась библиотека "CGI C++ Library v0.30a". До тех пор, пока не посмотрел исходники более внимательно... Это функция, которая формирует строку для поля заголовка HTTP "Last-Modified".

Ez-Presso Ez-Presso, (Updated )

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

Кресты / Говнокод #2140 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
if(p) {
     if (p->m_String[0] == 0) {
         strcpy("foo", p->m_String);
      }
      DrawText(hdc, p->m_String, strlen(p->m_String), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}

и такие веселые куски попадаются в официальном примере написания плагинов на сайте Mozilla
пруф линк - http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/npruntime/plugin.cpp - строка 750

Coach Coach, (Updated )

Комментарии (20, +20)

Кресты / Говнокод #2139 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
#if 0
  n = NPN_GetStringIdentifier("prompt");

  NPVariant vars[3];
  STRINGZ_TO_NPVARIANT("foo", vars[0]);
  STRINGZ_TO_NPVARIANT("bar", vars[1]);
  STRINGZ_TO_NPVARIANT("foof", vars[2]);
  NPN_Invoke(sWindowObj, n, vars, 3, &rval);
  if (NPVARIANT_IS_STRING(rval)) {
   printf ("prompt returned '%s'\n", NPVARIANT_TO_STRING(rval).utf8characters);
  }

   NPN_ReleaseVariantValue(&rval);
#endif

и это официальный пример написания плагина с сайта Mozilla
пруф линк - http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/npruntime/plugin.cpp - строка 564

Coach Coach, (Updated )

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