- 1
sprintf(path, "/usr/local/something/something_else_%d_%d.uyvy%c", some_int, some_other_int, '\0');
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+143
sprintf(path, "/usr/local/something/something_else_%d_%d.uyvy%c", some_int, some_other_int, '\0');
Мда-с.
+141
date = j / 86400l;
t = j - (date * 86400l);
date += 731000ul;
y = (4 * date - 1) / 146097;
d = (4 * date - 1 - 146097 * y) / 4;
date = (4 * d + 3) / 1461;
d = (4 * d + 7 - 1461 * date) / 4;
m = (5 * d - 3) / 153;
d = (5 * d + 2 - 153 * m) / 5;
y = 100 * y + date;
if (m < 10) {
m += 3;
} else {
m -= 9;
y++;
}
Voodoo magic...
+139
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
Совместимость
+140
HIMAGELIST ImageList_LoadImageV(PVOID ImageBase, PCWSTR a[], int level)
{
PIMAGE_RESOURCE_DATA_ENTRY pirde;
PBITMAPINFOHEADER pbih;
DWORD cx, cy, cb, n, ofs;
if (
0 <= LdrFindResource_U(ImageBase, a, level, &pirde) &&
0 <= LdrAccessResource(ImageBase, pirde, (void**)&pbih, &cb) &&
cb > sizeof(BITMAPINFOHEADER) &&
pbih->biSize >= sizeof(BITMAPINFOHEADER) &&
(cx = pbih->biWidth) <= (cy = pbih->biHeight) &&
!(cy % cx) &&
pbih->biBitCount == 32 &&
(ofs = pbih->biSize) + (cx * cy << 2) == cb
)
{
n = cy / cx, cb = cx * cx << 2;
if (HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR32, n, 0))
{
BITMAPINFO bi = { {sizeof(BITMAPINFOHEADER), cx, cx, 1, 32 } };
if (HDC hdc = GetDC(0))
{
if (HBITMAP hbmp = CreateCompatibleBitmap(hdc, cx, cx))
{
do ; while (
SetDIBits(hdc, hbmp, 0, cx, RtlOffsetToPointer(pbih, ofs), &bi, DIB_RGB_COLORS) &&
0 <= ImageList_Add(himl, hbmp, 0) &&
(ofs += cb, --n)
);
DeleteObject(hbmp);
}
ReleaseDC(0, hdc);
}
if (!n) return himl;
ImageList_Destroy(himl);
}
}
return 0;
}
+135
int log2_floor (unsigned x)
{
#define NIMHTNOE0WNM(n) (((~(x>>n)+1)>>n)&n)
int res, n;
n = NIMHTNOE0WNM(16); res = n; x >>= n;
n = NIMHTNOE0WNM( 8); res |= n; x >>= n;
n = NIMHTNOE0WNM( 4); res |= n; x >>= n;
n = NIMHTNOE0WNM( 2); res |= n; x >>= n;
n = NIMHTNOE0WNM( 1); res |= n;
return res;
}
Кто-то Воррена перечитал.
+138
int fermat (void)
{
const int MAX = 1000;
int a=1,b=1,c=1;
while (1) {
if (((a*a*a) == ((b*b*b)+(c*c*c)))) return 1;
a++;
if (a>MAX) {
a=1;
b++;
}
if (b>MAX) {
b=1;
c++;
}
if (c>MAX) {
c=1;
}
}
return 0;
}
#include <stdio.h>
int main (void)
{
if (fermat()) {
printf ("Fermat's Last Theorem has been disproved.\n");
} else {
printf ("Fermat's Last Theorem has not been disproved.\n");
}
return 0;
}
Fermat's Last Theorem has been disproved
http://blog.regehr.org/archives/140
Если уже было черкните мне на /dev/null@localhost, удалю
+136
/* To the unenlightened: This sets the 20 MSBs to 0 for sanity's sake. */
return four_bytes_to_uint32(four_byte_array) & ~(~0 << 12);
Так приказали K&R.
+139
char* xml_compose_simple_response(char* response, int code, char* description, char* additional_data)
{
size_t resp_length = 0;
char* buff = NULL;
resp_length += strlen(RESPONSE_HEADER_PREFIX);
resp_length += strlen(session_type);
resp_length += strlen(transaction_id);
resp_length += strlen(response) + strlen(EMPTY_TAG);
if(NULL != additional_data)
{
resp_length += strlen(additional_data);
}
resp_length += strlen(description) + strlen(RESULT_INT) + sizeof(int) * 8;
resp_length += strlen(RESPONSE_HEADER_SUFFIX);
resp_length += 1;
if(NULL != (buff = malloc(resp_length)))
{
buff[0] = '\0';
sprintf(buff, RESPONSE_HEADER_PREFIX""EMPTY_TAG, session_type, transaction_id, response);
if (additional_data != NULL)
{
char tmp_desc[_2K];
sprintf(tmp_desc, description, additional_data);
sprintf(&buff[strlen(buff)], RESULT_INT, code, tmp_desc);
}
else
{
sprintf(&buff[strlen(buff)], RESULT_INT, code, description);
}
strcat(buff, RESPONSE_HEADER_SUFFIX);
}
else
{
mng_report_memory_failure_location_and_exit();
}
return buff;
}
XML вручную собирай @ на кавычкай падай. Никакого АПИ, только хардкор.
+135
return (true == is_break) ? resource : NULL;
Вонъ изъ профессiи!
+131
// bg_pmove.c -- both games player movement code
// takes a playerstate and a usercmd as input and returns a modifed playerstate
Дальше идут 11 тысяч строк нечитаемого говна. Это вообще нормально?!