1. Си / Говнокод #16835

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #ifdef __APPLE__
    #define OPENGL_LIBRARY "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
    #else
    #define OPENGL_LIBRARY "libGL.so"
    #endif

    А вообще, у мака есть переменные окружения?

    Pythoner, 10 Октября 2014

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

    +136

    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
    DIR_STRUCT * fill_dir_struct(DIR_STRUCT * dir_stc, _ptr_by_val_(char *) base_dir_path, _ptr_by_val_(char *) offset_dir)
    {
    	DIR_STRUCT * 		sub_dir;
    	DIR * 				srcdir;
    	struct 				stat st;
    	char 				full_sub_dir_path[MAX_PATH_SIZE];
    	struct dirent * 	dent;
    
    	sprintf(full_sub_dir_path, "%s/%s", base_dir_path, offset_dir);
    	dbgprintln("Directory %s", full_sub_dir_path);
    
    	if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    	{
    		memset(dir_stc, 0x00, sizeof(DIR_STRUCT));
    		if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		{
    			if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				strcpy(dir_stc->dir_path, offset_dir);
    				for( ;(NULL != (dent = readdir(srcdir))); )
    				{
    					if((0 != strcmp(dent->d_name, ".")) &&
    					   (0 != strcmp(dent->d_name, "..")) &&
    					   (0 <= fstatat(dirfd(srcdir), dent->d_name, &st, 0)))
    					{
    						if (S_ISDIR(st.st_mode)) //Directory
    						{
    							if(NULL != (sub_dir = fill_dir_struct(sub_dir, full_sub_dir_path, dent->d_name)))
    							{
    								dir_stc->sub_dirs 		 	  = list_append_node(dir_stc->sub_dirs, sub_dir);
    								dir_stc->dir_files_size 	 += sub_dir->dir_files_size;
    								dir_stc->sub_dir_files_count += sub_dir->sub_dir_files_count;
    							}
    							else
    							{
    								dir_stc = destroy_dir_struct(dir_stc);
    								break;
    							}
    						}
    						else 					//File
    						{
    							dbgprintln("File %s, size %lu bytes", dent->d_name, st.st_size);
    							dir_stc->dir_files 		 	 = list_append_node(dir_stc->dir_files, allocate_and_copy_char_buffer(dent->d_name, strlen(dent->d_name) + 1));
    							dir_stc->dir_files_size 	+= st.st_size;
    							dir_stc->sub_dir_files_count++;
    						}
    					}
    				}//End of for(;NULL != (dent = readdir(srcdir)); )
    				closedir(srcdir);
    			}
    			else//End of if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				dir_stc = destroy_dir_struct(dir_stc);
    			}
    		}//End of if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		else
    		{
    			dir_stc = destroy_dir_struct(dir_stc);
    		}
    	}//End of if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    
    	return dir_stc;
    }

    Восьмикратный индент, Йода нотейшн, const *(x) const в аргументах. Есть подозрение, что велосипедисты не знали о scandir.

    Это кладезь говна.

    codemonkey, 08 Октября 2014

    Комментарии (33)
  3. Си / Говнокод #16821

    +138

    1. 1
    if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))

    А кому-то это говно меинтейнить надо будет...

    codemonkey, 08 Октября 2014

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

    +133

    1. 1
    2. 2
    //str will destroy
    char* strdup_(char* str){

    wat?

    LispGovno, 07 Октября 2014

    Комментарии (24)
  5. Си / Говнокод #16809

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #define TIME_MATCH    500 /* 5 seconds */
    #define TIMEOUT       2000 /* 20 seconds */
    ...
    if ((pPoint->dwTimer >= TIME_MATCH) 
        || (pPoint->dwTimer >= TIMEOUT)) {
    	    bNewDigit = TRUE;
          }

    И вроде бы причем тут индусы со построчной оплатой кода.

    qxoz, 07 Октября 2014

    Комментарии (1)
  6. Си / Говнокод #16806

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SDL_Rect sr = {
    		e->outputRect.x,
    		e->outputRect.y+e->lineHeight*line,
    		e->outputRect.w,
    		sr.y + e->lineHeight };

    laMer007, 06 Октября 2014

    Комментарии (3)
  7. Си / Говнокод #16775

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
           would seem more natural, but the C99 standard leaves
           casting from "void *" to a function pointer undefined.
           The assignment used below is the POSIX.1-2003 (Technical
           Corrigendum 1) workaround; see the Rationale for the
           POSIX specification of dlsym(). */
    
    *(void **) (&cosine) = dlsym(handle, "cos");

    Сишкопроблемы.

    http://linux.die.net/man/3/dlsym

    someone, 28 Сентября 2014

    Комментарии (3)
  8. Си / Говнокод #16742

    +121

    1. 1
    int main(void)

    GreenKiller, 21 Сентября 2014

    Комментарии (18)
  9. Си / Говнокод #16740

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    typedef struct tagКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ {
        тыц;
        тыц;
        и еще пару раз тыц;
    } КАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ, *PКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ, *LPКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ;

    Винстайл такой няшный ^_^

    Pythoner, 21 Сентября 2014

    Комментарии (15)
  10. Си / Говнокод #16725

    +140

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    //********************************************************************************
    //                                                        (c) корпорация Галактика
    // Галактика 7.12 - Управление производственной логистикой
    // Функции для пересчета в накладных/актах
    //********************************************************************************
    ...
                  ECTb_npux_OPgEP  := False;
                  if (SpSopr.PrMC = word(1))
                  { //--- проверяем только Материалы ---
                    ECTb_PACX_OPgEP  := False;
    ...

    Язык программирования - адская смесь Pascal и С. Но не в этом дело. Я ещё никогда прежде не хотел так сильно надавать по рукам автору названий переменных! Это официальный исходник :(

    st-vincent, 19 Сентября 2014

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