1. PHP / Говнокод #25400

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
    	$i = -1;
    	while ($i == $i)
    	{
    		$i = $i + (1);
    		echo($i + "," + " ");
    	}
    ?>

    KEK

    GenkaFF, 23 Февраля 2019

    Комментарии (40)
  2. Си / Говнокод #25399

    0

    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
    // https://github.com/ghc/ghc/blob/e204431e5a5e2fd16da52b04bda2798f16c51344/rts/Interpreter.c#L1184
    
            case bci_PUSH8: {
                int off = BCO_NEXT;
                Sp_subB(1);
                *(StgWord8*)Sp = *(StgWord8*)(Sp_plusB(off+1));
                goto nextInsn;
            }
    
            case bci_PUSH16: {
                int off = BCO_NEXT;
                Sp_subB(2);
                *(StgWord16*)Sp = *(StgWord16*)(Sp_plusB(off+2));
                goto nextInsn;
            }
    
            case bci_PUSH32: {
                int off = BCO_NEXT;
                Sp_subB(4);
                *(StgWord32*)Sp = *(StgWord32*)(Sp_plusB(off+4));
                goto nextInsn;
            }
    
            case bci_PUSH8_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }
    
            case bci_PUSH16_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }
    
            case bci_PUSH32_W: {
                int off = BCO_NEXT;
                *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off));
                Sp_subW(1);
                goto nextInsn;
            }

    https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Interpreter

    > The linker lives in rts/Linker.c and is responsible for handling runtime loading of code into a Haskell process. This is something of a big blob of unpleasant code, and see DynamicGhcPrograms for information about efforts to reduce our dependence on this linker.

    Итак, тут у нас стековая машина из хачкеля, которая вродекак отвечает за динамическую загрузку какого-то говна.

    j123123, 22 Февраля 2019

    Комментарии (101)
  3. Куча / Говнокод #25398

    +1

    1. 1
    Прыщи

    syoma, 22 Февраля 2019

    Комментарии (299)
  4. Си / Говнокод #25397

    0

    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
    // https://github.com/alpertron/calculators/blob/15607feafb0ddb1c075bb326dc6ea2224a4c50bb/siqs.c#L3720
    
                switch (NumberLengthA)
                {
                case 7:
                  dRem = (double)*(piDividend + 6) * (double)rowPrimeTrialDivisionData->exp6 +
                    (double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
                    (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 6:
                  dRem = (double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
                    (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 5:
                  dRem = (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
                    (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                case 4:
                  dRem = (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
                    (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                default:
                  dRem = (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
                    (double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
                  break;
                }

    Generic two integer variable equation solver
    This calculator can solve equations of the form a⁢x² + b⁢x⁢y + c⁢y² + dx + ey + f = 0 where the unknowns x and y are integer numbers.

    j123123, 22 Февраля 2019

    Комментарии (6)
  5. Куча / Говнокод #25396

    0

    1. 1
    Хостинг

    syoma, 22 Февраля 2019

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

    +1

    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
    // https://github.com/CVC4/CVC4/blob/14b9dbaa0c9e8dce52d1a28595dc1cc80756abed/src/expr/pickler.cpp
    
    
    static Block mkBlockBody4Chars(char a, char b, char c, char d) {
      Block newBody;
      newBody.d_body.d_data = (a << 24) | (b << 16) | (c << 8) | d;
      return newBody;
    }
    
    static char getCharBlockBody(BlockBody body, int i) {
      Assert(0 <= i && i <= 3);
    
      switch(i) {
      case 0: return (body.d_data & 0xff000000) >> 24;
      case 1: return (body.d_data & 0x00ff0000) >> 16;
      case 2: return (body.d_data & 0x0000ff00) >> 8;
      case 3: return (body.d_data & 0x000000ff);
      default:
        Unreachable();
      }
      return '\0';
    }
    
    // ...
    
    void PicklerPrivate::toCaseString(Kind k, const std::string& s) {
      d_current << mkConstantHeader(k, s.size());
    
      unsigned size = s.size();
      unsigned i;
      for(i = 0; i + 4 <= size; i += 4) {
        d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], s[i + 3]);
      }
      switch(size % 4) {
      case 0: break;
      case 1: d_current << mkBlockBody4Chars(s[i + 0], '\0','\0', '\0'); break;
      case 2: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1], '\0', '\0'); break;
      case 3: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], '\0'); break;
      default:
        Unreachable();
      }
    
    }

    Очередное переизобретение какой-то байтоебской поеботы типа ntohl(). И вообще, тут UB.

    j123123, 21 Февраля 2019

    Комментарии (94)
  7. Kotlin / Говнокод #25394

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private fun GetDeviceInfo(request: HttpServerRequest): HashMap<String, Info>
    	{
    		val deviceInfo = request.getParam(NAME_ID)?.let { id ->
    			(Ports.ById(id) ?: Ports.ByDeviceId(id))?.let(DeviceInfo.Companion::Create)
    			?: Files.FromPath(id)?.let { file ->
    				FileInfo.GetInfo(file)
    			} ?: (Core.GetTask(id) as? Scenario)?.SourceFile?.let(::FileInfo)
    		}
    
    		return deviceInfo?.let { hashMapOf(REQUEST_RESULT to it) } ?: hashMapOf()
    	}

    jadedolej, 21 Февраля 2019

    Комментарии (15)
  8. VisualBasic / Говнокод #25393

    +1

    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
    sub addleft
    	for i = 1 to 4
    		for j = 1 to 3
    			if a(i,j)<>0 and a(i,j) = a(i,j+1) then
    				moved = true 
    				a(i,j) = a(i,j)+1
    				a(i,j+1) = 0
    				score = score + integer ( 2**a(i,j) )
    			end if
    		end for
    	end for
    end sub
    
    sub left
    	for i = 1 to 4
    		for k = 1 to 3
    			for j = 1 to 3
    				if a(i,j) = 0 and a(i,j+1) <> 0 then
    					moved = true
    					a(i,j) = a(i,j+1)
    					a(i,j+1) = 0
    				end if
    			end for
    		end for
    	end for
    end sub
    
    rem addright, addup, adddown, right, up, down в том же духе
    
    rem . . .
    
    rem главный суслик
    while true
    		xy = touchdown()
    		if xy <> -1 then
    			x = xy/65536&0x0000ffff
    			y = xy&0x0000ffff
    			repeat
    				sleep 10
    				xy = touchup()
    			until xy <> -1
    			x = x - (xy/65536&0x0000ffff)
    			y = y - (xy&0x0000ffff)
    			if (abs(x)>100) <> (abs(y)>100) then
    				moved = false
    				if abs(x) > 100 then
    					if x > 0 then
    						left
    						addleft
    						left
    					else
    						right
    						addright
    						right
    					end if
    				else
    					if y > 0 then
    						up
    						addup
    						up
    					else
    						down
    						adddown
    						down
    					end if
    				end if
    				if moved then
    					rand
    				end if
    			end if
    		else
    			sleep 10
    		end if
    		draw
    		sleep 50
    	end while

    Не визуальный, но всё-таки барсик (могильный).

    Hu3KoypoBHeBblunemyx, 21 Февраля 2019

    Комментарии (21)
  9. Java / Говнокод #25392

    +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
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    /*
     * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     *
     * This code is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License version 2 only, as
     * published by the Free Software Foundation.
     *
     * This code is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     * version 2 for more details (a copy is included in the LICENSE file that
     * accompanied this code).
     *
     * You should have received a copy of the GNU General Public License version
     * 2 along with this work; if not, write to the Free Software Foundation,
     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     *
     * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     * or visit www.oracle.com if you need additional information or have any
     * questions.
     */
    
    /* @test
       @bug 4890726
       @summary Check the correctness of KOI8_U by comparing to KOI8_R
     */
    
    import java.util.*;
    import static java.lang.Character.UnicodeBlock;
    
    public class UkrainianIsNotRussian {
        private static String decode(byte[] bytes, String encoding) throws Throwable {
            String s = new String(bytes, encoding);
            equal(s.length(), 1);
            check(Arrays.equals(s.getBytes(encoding), bytes));
            return s;
        }
    
        private static void realMain(String[] args) throws Throwable {
            final byte[] bytes = new byte[1];
            int differences = 0;
            for (int i = 0; i < 0xff; i++) {
                bytes[0] = (byte) i;
                final String r = decode(bytes, "KOI8_R");
                final String u = decode(bytes, "KOI8_U");
                if (! r.equals(u)) {
                    differences++;
                    final char rc = r.charAt(0);
                    final char uc = u.charAt(0);
                    final UnicodeBlock rcb = UnicodeBlock.of(rc);
                    final UnicodeBlock ucb = UnicodeBlock.of(uc);
                    System.out.printf("%02x => %04x %s, %04x %s%n",
                                      i, (int) rc, rcb, (int) uc, ucb);
                    check(rcb == UnicodeBlock.BOX_DRAWING &&
                          ucb == UnicodeBlock.CYRILLIC);
                }
            }
            equal(differences, 8);
        }
    
        //--------------------- Infrastructure ---------------------------
        static volatile int passed = 0, failed = 0;
        static void pass() {passed++;}
        static void fail() {failed++; Thread.dumpStack();}
        static void fail(String msg) {System.out.println(msg); fail();}
        static void unexpected(Throwable t) {failed++; t.printStackTrace();}
        static void check(boolean cond) {if (cond) pass(); else fail();}
        static void equal(Object x, Object y) {
            if (x == null ? y == null : x.equals(y)) pass();
            else fail(x + " not equal to " + y);}
        public static void main(String[] args) throws Throwable {
            try {realMain(args);} catch (Throwable t) {unexpected(t);}
            System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
            if (failed > 0) throw new AssertionError("Some tests failed");}
    }

    https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/test/jdk/sun/nio/cs/UkrainianIsNotRussian.java

    j123123, 21 Февраля 2019

    Комментарии (159)
  10. JavaScript / Говнокод #25391

    0

    1. 1
    $(`.js-filter-panel__radio__pre-tuned-up-settings`).find(`.js-filter-reg-date-radio-item:not(#${$input.attr(this._preTunedSelectedPeriod)})`).prop('checked', false);

    webviewer, 20 Февраля 2019

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