The Daily WTF



  • genial, werd ich auch gleich mal so machen 😉



  • Fuck!

    Ich bin grad Code am Ändern, nen auto_ptr durch einen anderen intelligenten Pointer ersetzen.
    Nun compiliert aber gerade dieser eine Funktionsaufruf nicht. Ich schaue also nach und sehe,
    dass ein anderer Programmierer das hier hingeschrieben hat:

    void foo( auto_ptr<X>* ptr);
    

    WTF!! 😮 😮

    Nachtrag:

    In der Funktion steht dann als einzige Verwendung das hier:

    ptr->get()->.....
    


  • Ist ein auto_ptr per Referenz okay?



  • & schrieb:

    Ist ein auto_ptr per Referenz okay?

    Kommt darauf an was du bezweckst. Wenn du den Besitz nicht an die Funktion übergeben willst dann mußt du sogar eine Reference nehmen (oder theoretisch macht es auch der Zeiger wie oben gezeigt auch) wenn du den Besitz aber übergeben willst dann musst du einen Wert übergeben.

    Hängt also vom Gebrauch ab.



  • Welchen Sinn macht denn solch eine Funktion? 😮

    Ich übergebe den Besitz "vielleicht"?
    Wenn nur der nackte Pointer gebraucht wird, warum dann die Schnittstelle vom auto_ptr abhängig machen?
    Vor allem, wenn das hier völlig gültiger Code ist:

    void foo( auto_ptr<X>* ptr)
    {
       auto_ptr<X> harry = *ptr;
    }
    

    Entweder ich übergebe den Besitz oder nicht - nix dazwischen. Nix auto_ptr per Referenz oder Pointer -.-'



  • naja, wenn der programmierer selber hauptsächlich mit auto_ptr arbeitet(weil er von shared_ptr nix gehört hat), und in der funktion selber den zeiger nur benutzen will, ohne dann immer ein lästiges bar.get() zu schreiben, dann versteh ich das.



  • Wenn man eigentlich boost::scoped_ptr meint, dann aber trotzdem std::auto_ptr nimmt macht die Übergabe per Referenz z.B. Sinn.



  • enum Bool 
    { 
        True, 
        False, 
        FileNotFound 
    };
    


  • sort(gvProjekt.begin(), gvProjekt.end());
    
    if (!bAufsteigend)
      reverse(gvProjekt.begin(), gvProjekt.end());
    

    😃 👍





  • Nicht schlecht, wir könnten hier bei c++.de eine Headersammlung erstellen, so daß man sich hier alle existierenden Header in einer einzigen Zip laden kann. 🙂



  • Marc++us schrieb:

    Nicht schlecht, wir könnten hier bei c++.de eine Headersammlung erstellen, so daß man sich hier alle existierenden Header in einer einzigen Zip laden kann. 🙂

    Na, für die Humor-Seite wär' das doch was. 😃

    Dann aber bitte auch 'nen FAQ Beitrag. 🤡



  • <xsl:template name="Replace">
      <xsl:param name="string" select="''"/>
      <xsl:param name="pattern" select="''"/>
      <xsl:param name="replacement" select="''"/>
      <xsl:choose>
      <xsl:when test="$pattern!='' and $string!='' and contains($string, $pattern)">
        <xsl:value-of select="substring-before($string, $pattern)"/>
    
        <xsl:copy-of select="$replacement"/>
        <xsl:call-template name="Replace">
          <xsl:with-param name="string" select="substring-after($string, $pattern)"/>
          <xsl:with-param name="pattern" select="$pattern"/>
          <xsl:with-param name="replacement" select="$replacement"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$string"/>
      </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    
    <xsl:template name="ReplaceLCWithHTML">
        <xsl:param name="input" select="''"/>
        <xsl:choose>
        <xsl:when test="$input!=''">
            <xsl:call-template name="Replace">
                <xsl:with-param name="string">
                <xsl:call-template name="Replace">
                    <xsl:with-param name="string">
                    <xsl:call-template name="Replace">
                        <xsl:with-param name="string">
                        <xsl:call-template name="Replace">
                            <xsl:with-param name="string">
                            <xsl:call-template name="Replace">
                                <xsl:with-param name="string">
                                <xsl:call-template name="Replace">
                                    <xsl:with-param name="string">
                                    <xsl:call-template name="Replace">
                                        <xsl:with-param name="string">
                                        <xsl:call-template name="Replace">
                                            <xsl:with-param name="string">
                                            <xsl:call-template name="Replace">
                                                <xsl:with-param name="string">
                                                <xsl:call-template name="Replace">
                                                    <xsl:with-param name="string">
                                                    <xsl:call-template name="Replace">
                                                        <xsl:with-param name="string">
                                                        <xsl:call-template name="Replace">
                                                            <xsl:with-param name="string">
                                                            <xsl:call-template name="Replace">
                                                                <xsl:with-param name="string">
                                                                <xsl:call-template name="Replace">
                                                                    <xsl:with-param name="string">
                                                                    <xsl:call-template name="Replace">
                                                                        <xsl:with-param name="string">
                                                                        <xsl:call-template name="Replace">
                                                                            <xsl:with-param name="string">
                                                                            <xsl:call-template name="Replace">
                                                                                <xsl:with-param name="string">
                                                                                <xsl:call-template name="Replace">
                                                                                    <xsl:with-param name="string">
                                                                                    <xsl:call-template name="Replace">
                                                                                        <xsl:with-param name="string">
                                                                                        <xsl:call-template name="Replace">
                                                                                            <xsl:with-param name="string">
                                                                                            <xsl:call-template name="Replace">
                                                                                                <xsl:with-param name="string">
                                                                                                <xsl:call-template name="Replace">
                                                                                                    <xsl:with-param name="string">
                                                                                                    <xsl:call-template name="Replace">
                                                                                                        <xsl:with-param name="string">
                                                                                                        <xsl:call-template name="Replace">
                                                                                                            <xsl:with-param name="string">
                                                                                                            <xsl:call-template name="Replace">
                                                                                                                <xsl:with-param name="string">
                                                                                                                <xsl:call-template name="Replace">
                                                                                                                    <xsl:with-param name="string" select="$input"/>
                                                                                                                    <xsl:with-param name="pattern" select="'à'"/>
                                                                                                                    <xsl:with-param name="replacement" select="'&agrave;'"/>
                                                                                                                </xsl:call-template>
                                                                                                                </xsl:with-param>
                                                                                                                <xsl:with-param name="pattern" select="'á"/>
                                                                                                                <xsl:with-param name="replacement" select="'&aacute;'"/>
                                                                                                            </xsl:call-template>
                                                                                                            </xsl:with-param>
                                                                                                            <xsl:with-param name="pattern" select="'â'"/>
                                                                                                            <xsl:with-param name="replacement" select="'&acirc;'"/>
                                                                                                        </xsl:call-template>
                                                                                                        </xsl:with-param>
                                                                                                        <xsl:with-param name="pattern" select="'è'"/>
                                                                                                        <xsl:with-param name="replacement" select="'&egrave;'"/>
                                                                                                    </xsl:call-template>
                                                                                                    </xsl:with-param>
                                                                                                    <xsl:with-param name="pattern" select="'é'"/>
                                                                                                    <xsl:with-param name="replacement" select="'&eacute;'"/>
                                                                                                </xsl:call-template>
                                                                                                </xsl:with-param>
                                                                                                <xsl:with-param name="pattern" select="'ê'"/>
                                                                                                <xsl:with-param name="replacement" select="'&ecirc;'"/>
                                                                                            </xsl:call-template>
                                                                                            </xsl:with-param>
                                                                                            <xsl:with-param name="pattern" select="'ì'"/>
                                                                                            <xsl:with-param name="replacement" select="'&igrave;'"/>
                                                                                        </xsl:call-template>
                                                                                        </xsl:with-param>
                                                                                        <xsl:with-param name="pattern" select="'í'"/>
                                                                                        <xsl:with-param name="replacement" select="'&iacute;'"/>
                                                                                    </xsl:call-template>
                                                                                    </xsl:with-param>
                                                                                    <xsl:with-param name="pattern" select="'î'"/>
                                                                                    <xsl:with-param name="replacement" select="'&icirc;'"/>
                                                                                </xsl:call-template>
                                                                                </xsl:with-param>
                                                                                <xsl:with-param name="pattern" select="'ò'"/>
                                                                                <xsl:with-param name="replacement" select="'&ograve;'"/>
                                                                            </xsl:call-template>
                                                                            </xsl:with-param>
                                                                            <xsl:with-param name="pattern" select="'ó'"/>
                                                                            <xsl:with-param name="replacement" select="'&oacute;'"/>
                                                                        </xsl:call-template>
                                                                        </xsl:with-param>
                                                                        <xsl:with-param name="pattern" select="'ô'"/>
                                                                        <xsl:with-param name="replacement" select="'&ocirc;'"/>
                                                                    </xsl:call-template>
                                                                    </xsl:with-param>
                                                                    <xsl:with-param name="pattern" select="'ù'"/>
                                                                    <xsl:with-param name="replacement" select="'&ugrave;'"/>
                                                                </xsl:call-template>
                                                                </xsl:with-param>
                                                                <xsl:with-param name="pattern" select="'ú'"/>
                                                                <xsl:with-param name="replacement" select="'&uacute;'"/>
                                                            </xsl:call-template>
                                                            </xsl:with-param>
                                                            <xsl:with-param name="pattern" select="'û'"/>
                                                            <xsl:with-param name="replacement" select="'&ucirc;'"/>
                                                        </xsl:call-template>
                                                        </xsl:with-param>
                                                        <xsl:with-param name="pattern" select="'ý'"/>
                                                        <xsl:with-param name="replacement" select="'&yacute;'"/>
                                                    </xsl:call-template>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="pattern" select="'œ'"/>
                                                    <xsl:with-param name="replacement" select="'&oelig;'"/>
                                                </xsl:call-template>
                                                </xsl:with-param>
                                                <xsl:with-param name="pattern" select="'ç'"/>
                                                <xsl:with-param name="replacement" select="'&ccedil;'"/>
                                            </xsl:call-template>
                                            </xsl:with-param>
                                            <xsl:with-param name="pattern" select="'™'"/>
                                            <xsl:with-param name="replacement" select="'&trade;'"/>
                                        </xsl:call-template>
                                        </xsl:with-param>
                                        <xsl:with-param name="pattern" select="'¢'"/>
                                        <xsl:with-param name="replacement" select="'&cent;'"/>
                                    </xsl:call-template>
                                    </xsl:with-param>
                                    <xsl:with-param name="pattern" select="'©'"/>
                                    <xsl:with-param name="replacement" select="'&copy;'"/>
                                </xsl:call-template>
                                </xsl:with-param>
                                <xsl:with-param name="pattern" select="'®'"/>
                                <xsl:with-param name="replacement" select="'&reg;'"/>
                            </xsl:call-template>
                            </xsl:with-param>
                            <xsl:with-param name="pattern" select="'°'"/>
                            <xsl:with-param name="replacement" select="'&deg;'"/>
                        </xsl:call-template>
                        </xsl:with-param>
                        <xsl:with-param name="pattern" select="'&nbsp;'"/>
                        <xsl:with-param name="replacement" select="' '"/>
                    </xsl:call-template>
                    </xsl:with-param>
                    <xsl:with-param name="pattern" select="'&shy;'"/>
                    <xsl:with-param name="replacement" select="' '"/>
                </xsl:call-template>
                </xsl:with-param>
                <xsl:with-param name="pattern" select="'·'"/>
                <xsl:with-param name="replacement" select="'&middot;'"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$input"/>
        </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="ReplaceUCWithHTML">
        <xsl:param name="input" select="''"/>
        <xsl:choose>
        <xsl:when test="$input!=''">
        <xsl:call-template name="Replace">
            <xsl:with-param name="string">
            <xsl:call-template name="Replace">
                <xsl:with-param name="string">
                <xsl:call-template name="Replace">
                    <xsl:with-param name="string">
                    <xsl:call-template name="Replace">
                        <xsl:with-param name="string">
                        <xsl:call-template name="Replace">
                            <xsl:with-param name="string">
                            <xsl:call-template name="Replace">
                                <xsl:with-param name="string">
                                <xsl:call-template name="Replace">
                                    <xsl:with-param name="string">
                                    <xsl:call-template name="Replace">
                                        <xsl:with-param name="string">
                                        <xsl:call-template name="Replace">
                                            <xsl:with-param name="string">
                                            <xsl:call-template name="Replace">
                                                <xsl:with-param name="string">
                                                <xsl:call-template name="Replace">
                                                    <xsl:with-param name="string">
                                                    <xsl:call-template name="Replace">
                                                        <xsl:with-param name="string">
                                                        <xsl:call-template name="Replace">
                                                            <xsl:with-param name="string">
                                                            <xsl:call-template name="Replace">
                                                                <xsl:with-param name="string">
                                                                <xsl:call-template name="Replace">
                                                                    <xsl:with-param name="string">
                                                                    <xsl:call-template name="Replace">
                                                                        <xsl:with-param name="string">
                                                                        <xsl:call-template name="Replace">
                                                                            <xsl:with-param name="string">
                                                                            <xsl:call-template name="Replace">
                                                                                <xsl:with-param name="string">
                                                                                <xsl:call-template name="Replace">
                                                                                    <xsl:with-param name="string">
                                                                                    <xsl:call-template name="Replace">
                                                                                        <xsl:with-param name="string" select="$input"/>
                                                                                        <xsl:with-param name="pattern" select="'À'"/>
                                                                                        <xsl:with-param name="replacement" select="'&Agrave;'"/>
                                                                                    </xsl:call-template>
                                                                                    </xsl:with-param>
                                                                                    <xsl:with-param name="pattern" select="'Á'"/>
                                                                                    <xsl:with-param name="replacement" select="'&Aacute;'"/>
                                                                                </xsl:call-template>
                                                                                </xsl:with-param>
                                                                                <xsl:with-param name="pattern" select="'Â'"/>
                                                                                <xsl:with-param name="replacement" select="'&Acirc;'"/>
                                                                            </xsl:call-template>
                                                                            </xsl:with-param>
                                                                            <xsl:with-param name="pattern" select="'È'"/>
                                                                            <xsl:with-param name="replacement" select="'&Egrave;'"/>
                                                                        </xsl:call-template>
                                                                        </xsl:with-param>
                                                                        <xsl:with-param name="pattern" select="'É'"/>
                                                                        <xsl:with-param name="replacement" select="'&Eacute;'"/>
                                                                    </xsl:call-template>
                                                                    </xsl:with-param>
                                                                    <xsl:with-param name="pattern" select="'Ê'"/>
                                                                    <xsl:with-param name="replacement" select="'&Ecirc;'"/>
                                                                </xsl:call-template>
                                                                </xsl:with-param>
                                                                <xsl:with-param name="pattern" select="'Ì'"/>
                                                                <xsl:with-param name="replacement" select="'&Igrave;'"/>
                                                            </xsl:call-template>
                                                            </xsl:with-param>
                                                            <xsl:with-param name="pattern" select="'Í'"/>
                                                            <xsl:with-param name="replacement" select="'&Iacute;'"/>
                                                        </xsl:call-template>
                                                        </xsl:with-param>
                                                        <xsl:with-param name="pattern" select="'Î'"/>
                                                        <xsl:with-param name="replacement" select="'&Icirc;'"/>
                                                    </xsl:call-template>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="pattern" select="'Ò'"/>
                                                    <xsl:with-param name="replacement" select="'&Ograve;'"/>
                                                </xsl:call-template>
                                                </xsl:with-param>
                                                <xsl:with-param name="pattern" select="'Ó'"/>
                                                <xsl:with-param name="replacement" select="'&Oacute;'"/>
                                            </xsl:call-template>
                                            </xsl:with-param>
                                            <xsl:with-param name="pattern" select="'Ô'"/>
                                            <xsl:with-param name="replacement" select="'&Ocirc;'"/>
                                        </xsl:call-template>
                                        </xsl:with-param>
                                        <xsl:with-param name="pattern" select="'Ù'"/>
                                        <xsl:with-param name="replacement" select="'&Ugrave;'"/>
                                    </xsl:call-template>
                                    </xsl:with-param>
                                    <xsl:with-param name="pattern" select="'Ú'"/>
                                    <xsl:with-param name="replacement" select="'&Uacute;'"/>
                                </xsl:call-template>
                                </xsl:with-param>
                                <xsl:with-param name="pattern" select="'Û'"/>
                                <xsl:with-param name="replacement" select="'&Ucirc;'"/>
                            </xsl:call-template>
                            </xsl:with-param>
                            <xsl:with-param name="pattern" select="'Ý'"/>
                            <xsl:with-param name="replacement" select="'&Yacute;'"/>
                        </xsl:call-template>
                        </xsl:with-param>
                        <xsl:with-param name="pattern" select="'Œ'"/>
                        <xsl:with-param name="replacement" select="'&OElig;'"/>
                    </xsl:call-template>
                    </xsl:with-param>
                    <xsl:with-param name="pattern" select="'Ç'"/>
                    <xsl:with-param name="replacement" select="'&Ccedil;'"/>
                </xsl:call-template>
                </xsl:with-param>
                <xsl:with-param name="pattern" select="'&NBSP;'"/>
                <xsl:with-param name="replacement" select="' '"/>
            </xsl:call-template>
            </xsl:with-param>
            <xsl:with-param name="pattern" select="'&SHY;'"/>
            <xsl:with-param name="replacement" select="' '"/>
        </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$input"/>
        </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    


  • *IIIHH* jetzt hab ich wegen dir Augenkrebs 😮



  • void printf_to_string( int first, char * fomat, ... )
    {
      va_list marker;
    
      va_start( marker, first );
    
      // this is required, or it will not work for some reason
      *(char*)*va_arg( marker, char * );
    
      // string to write to
      // ** MUST BE FIRST AFTER FORMAT IN FUNCTION COMAND LINE **
    
      {} /* make the variable */
      char * string_write_to = va_arg( marker, char * );
      char temporary_file_name[ 19 ];
      char * temorary_file_name_name ;
    
      strcpy( temporary_file_name, "thefileXXXX" );
    
      temorary_file_name_name = _mktemp( temporary_file_name );
    
      {}
    
      FILE * FILE1 = fopen( temporary_file_name, "w" );
    
      vfprintf( FILE1, fomat, marker );
    
      fclose( FILE1 );
    
      {} FILE * FILE11 = fopen( temporary_file_name, "r" ); {}
    
      // 2 is to the end ... it took some experamenting
      // -1 is so we go back and dont get the blank after it
      fseek( FILE11, -1, 2 ); 
    
      {}
      double bignumberjustincase = ftell( FILE11 );
    
      fclose( FILE1 );
    
      FILE * FILE111 = fopen( temporary_file_name, "r" );
    
      read( _fileno( FILE111 ), string_write_to, (short)bignumberjustincase );
    
      int stopHere = (long)string_write_to + (int)0;
    
      stopHere = stopHere + (bignumberjustincase);
    
      if ( stopHere != 0 ) 
      {
        ((char*)stopHere)[ 0 ] = '\0';
        strcpy( string_write_to + int(bignumberjustincase ), "" );  
        va_end( marker );
      }
    }
    


  • Das erklärt dann auch das Performanceproblem der zugehörigen Applikation. 🙂



  • Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
        Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, 
                                                      ByVal dy As Long, ByVal cButtons As Long, 
                                                      ByVal dwExtraInfo As Long)
        Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
        Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
        Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
        Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
        Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
        Private Const MOUSEEVENTF_MIDDLEUP = &H40
        Private Const MOUSEEVENTF_RIGHTDOWN = &H8
        Private Const MOUSEEVENTF_RIGHTUP = &H10
    
        Private Sub Register(OCXName As String)
          SetCursorPos 32, Screen.Height / 15 - 10
          mouse_event MOUSEEVENTF_ABSOLUTE, 32, Screen.Height / 15 - 10, 1, 1
          mouse_event MOUSEEVENTF_LEFTDOWN, 32, Screen.Height / 15 - 10, 1, 1
          mouse_event MOUSEEVENTF_LEFTUP, 32, Screen.Height / 15 - 10, 1, 1
          SendKeys ("R")
          SendKeys ("regsvr32 " & OCXName)
          SendKeys (vbKeyReturn)
        End Sub
    


  • for(int i=1;i<=EdtEingabe->Text.Length();i++)
       {
        switch(EdtEingabe->Text[i])
         {
          //Buchstaben A-Z
          case 'A':K L           Sleep(y); break;
          case 'B':L K K K       Sleep(y); break;
          case 'C':L K L K       Sleep(y); break;
          case 'D':L K K     Sleep(y); break;
          case 'E':K               Sleep(y); break;
          case 'F':K K L K       Sleep(y); break;
          case 'G':L L K         Sleep(y); break;
          case 'H':K K K K       Sleep(y); break;
          case 'I':K K           Sleep(y); break;
          case 'J':K L L L       Sleep(y); break;
          case 'K':L K L         Sleep(y); break;
          case 'L':K L K K       Sleep(y); break;
          case 'M':L L           Sleep(y); break;
          case 'N':L K           Sleep(y); break;
          case 'O':L L L         Sleep(y); break;
          case 'P':K L L K       Sleep(y); break;
          case 'Q':L L K L       Sleep(y); break;
          case 'R':K L K      Sleep(y); break;
          case 'S':K K K      Sleep(y); break;
          case 'T':L             Sleep(y); break;
          case 'U':K K L      Sleep(y); break;
          case 'V':K K K L       Sleep(y); break;
          case 'W':K L L         Sleep(y); break;
          case 'X':L K K L       Sleep(y); break;
          case 'Y':L K L L       Sleep(y); break;
          case 'Z':L L K K       Sleep(y); break;
          case '1':K L L L L     Sleep(y); break;
          //Zahlen 0-9
          case '2':K K L L L     Sleep(y); break;
          case '3':K K K L L     Sleep(y); break;
          case '4':K K K K L     Sleep(y); break;
          case '5':K K K K K     Sleep(y); break;
          case '6':L K K K K     Sleep(y); break;
          case '7':L L K K K     Sleep(y); break;
          case '8':L L L K K     Sleep(y); break;
          case '9':L L L L K     Sleep(y); break;
          case '0':L L L L L     Sleep(y); break;
          //Sonderzeichen
          case ':':L L L K K K   Sleep(y); break;
          case ';':L K L K L K   Sleep(y); break;
          case '?':K K L L K K   Sleep(y); break;
          case '(':L K L L K     Sleep(y); break;
          case ')':L K L L K L   Sleep(y); break;
          case '=':L K L L K     Sleep(y); break;
          case '+':K L K L K     Sleep(y); break;
          case '-':L K K K K L   Sleep(y); break;
          case '/':L K K L K     Sleep(y); break;
          case '@':K L L K L K   Sleep(y); break;
          case 'Ä':K L K L       Sleep(y); break;
          case 'Ü':K K L L       Sleep(y); break;
          case 'Ö':L L L K       Sleep(y); break;
    
         }
        }
    


  • Die meisten Sachen hier sind nicht so komisch weil sie auf Teufel komm raus absichtlich versuchen komisch zu sein. Zum Beispiel diese ganzen ReturnTrueIfBooleanIsTrue() Funktionen, haha witz komm raus du bist umzingelt! 🙄



  • Das ist auch nicht schlecht: http://www.thedailywtf.com/forums/57053/ShowPost.aspx

    Intrigued, he dug a little deeper into their stylesheets and learned that the developers were able to find a way to tie back together style and content within a technology designed to do the opposite ...

    😃


Anmelden zum Antworten