- 1
argc
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
argc
Зачем нужен argc? Нельзя просто смотреть NULL-terminated argv?
0
void check_manifest_line (int p) {
static char c[MAX_LINE_LEN + 1];
int l = p - START_MANIFEST_POSITION;
if (l <= MAX_LINE_LEN && l > 4) {
get_binlog_data (c, START_MANIFEST_POSITION, l);
c[l] = 0;
char *pp = c;
int op = -1;
if (l >= 6 && !memcmp (c, "start", 5)) {
op = 1;
pp += 5;
} else if (l >= 5 && !memcmp (c, "stop", 4)) {
op = 2;
pp += 4;
} else if (l >= 8 && !memcmp (c, "version", 7)) {
op = 3;
pp += 7;
}
if (is_whitespace (*pp) && op > 0) {
pp ++;
pp = eat_whitespace (pp);
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
if (op == 1 || op == 2) {
char *rr = pp;
pp = eat_not_whitespace (pp);
char *zz = pp;
pp = eat_whitespace (pp);
*zz = 0;
if (pp == c + l && zz - rr > 0) {
struct cluster *C = CC;
int x = BINLOG_NAME_LEN - 1;
while (x >= 0 && BINLOG_NAME[x] != '/') {
x--;
}
add_cluster (BINLOG_NAME, x + 1, rr, (MAIN_REPLICA ? 2 : 0) + (op == 2 ? 4 : 0) + (1 << 30));
CC = C;
}
} else {
assert (op == 3);
char *rr = pp;
pp = eat_not_whitespace (pp);
char *rr_end = pp;
pp = eat_whitespace (pp);
*rr_end = 0;
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
int version = atoi (pp);
pp = eat_not_whitespace (pp);
pp = eat_whitespace (pp);
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
long long size = atoll (pp);
pp = eat_not_whitespace (pp);
pp = eat_whitespace (pp);
if (pp == c + l && rr_end > rr && version > 0 && size >= 0) {
struct cluster *C = CC;
int x = BINLOG_NAME_LEN - 1;
while (x >= 0 && BINLOG_NAME[x] != '/') {
x --;
}
int rrlen = rr_end - rr;
int i;
for (i = 0; i < max_cluster; i++) if (Clusters[i]) {
//fprintf (stderr, "i = %d, binlog_name = %s, rr = %s, rrlen = %d\n", i, Clusters[i]->binlog_name, rr, rrlen);
const char *s = Clusters[i]->binlog_name;
int l = strlen (Clusters[i]->binlog_name) - 1;
while (l >= 0 && s[l] != '/') { l --; }
s = s + l + 1;
if (!memcmp (s, rr, rrlen) && s[rrlen] == '.') {
int old = atoi (s + rrlen + 1);
if (old >= version) {
vkprintf (0, "New version %d, old %d. Skipping\n", version, old);
START_MANIFEST_POSITION = p + 1;
return;
}
if (unlink (Clusters[i]->binlog_name) < 0) {
fprintf (stderr, "Can not delete old file %s: %m\n", Clusters[i]->binlog_name);
}
delete_cluster (i);
}
}
static char name[1024];
memcpy (name, rr, rrlen);
name[rrlen] = '.';
sprintf (name + rrlen + 1, "%06d", version);
add_cluster (BINLOG_NAME, x + 1, name, (MAIN_REPLICA ? 2 : 0) + (1 << 30));
LAST_SIZE = size;
CC = C;
}
}
}
}
START_MANIFEST_POSITION = p + 1;
https://github.com/vk-com/kphp-kdb/blob/ce6dead5b3345f4b38487cc9e45d55ced3dd7139/copyfast/copyfast-engine.c#L1081-L1181
−1
main(){int i=0;char*c = "(5((((`+((((f(H+(P7(d(([)(/(`G(X)7d+(.X+d)X+d(_(d.GXA`gg/d(dggI7(dgg`+(dg7^)(dgKE((dGD/((d/K)(((((((((0X)(((7F(<(XK/H7(d`)`)(.D(F(H(G(/(D`7X(HOg+6(`YgX;(fd7d7//d+7X[+GHKgdX7gg77fcggYKgfg/";while(i++<1122)printf(i%34?(c[i/6]-40&1<<i%6)?"XX":" ":"\n");}
Ёбаные обфускаторы.
0
int removing_mask (int *x , int *y, int *lng , char board[][Y],
char *content[PL] , int select, void (*write )( int x , int y ,char board[][Y],
char *content) , int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x , int in_y) ,
int (*chk_mask )(char board[][Y] , int mem ,int sh, int br )
){
char mask_word[LN] = {0} ;
int sm = 1;
int lvl = 0;
int shift = 0;
int brd = 0;
int mem = 0;
int stp = 0;
int mn = 0;
int bi = 0;
int rd = 0;
int gor = 0 ,vert = 0;
int pnt = 0;
int hg = 15;
int sr = 0;
int *one_value = 0 , *second_value = 0;
int ctr = 0;
if(select == 0 ){
mem = *y;
hg = *y < LN ? *y : hg ;
}
else {
mem = *x;
hg = *x < LN ? *x : hg ;
}
for( lvl = 0 ,rd = 0; lvl <= *lng - 1 ; lvl++ ,mem++ ){
for(brd = 0 ; brd <= hg ; brd++ ){
select == 0 ? ( shift = *x , one_value = &sr , second_value = &mem) : (shift = *y , one_value = &mem , second_value = &sr ) ;
if( (select == 0 && board[ shift - 1][ *second_value ] == 0 ) || (select == 1 && board[*one_value ][shift - 1 ] == 0 )){
for( pnt = 0, stp = 0; stp <= LN ;stp++ ){
if ( chk_mask ( board , mem , shift , brd ) == 1 ){
pnt = 1;
break;
}
sr = shift++ - brd ;
mask_word[stp] = board[ *one_value ][ *second_value ] ;
}
}
if(pnt == 1 ){
break;
}
sm = search_cross_pnt( mask_word ,&mn , content ,*x, *y ) ;
if( sm > bi ){
select == 0 ? ( gor = *x - brd, vert = mem) : (gor = mem ,vert = *y - brd) ;
bi = sm ;
rd = mn;
}
}
}
if( (select == 1 && isalpha(board[gor][vert - 1] ) ||
(select == 0 && isalpha(board[gor - 1 ][vert] )) ||
( gor && vert ) == 0
) ) {
ctr = 1;
}
if( ( ( content[rd] != " " ) ) &&
( board[gor ][vert ] == content[rd][0] || !isalpha (board[gor ][vert ] ) )
&& !ctr
) {
*x = gor ;
*y = vert ;
*lng = strlen(content[rd ]);
write( gor , vert , board , content[rd] );
content[rd] = " ";
return 1 ;
}
return 0;
}
полный аут кроссворду 3 ч.
0
int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x, int in_y ){
int x = 0;
int y = 0;
int m = 0;
int key = 0;
for(x = 0; x <= PL - 1 ; x++) {
y = strlen(content[x] ) ;
for( m = 0; m <= y; m++ ){
if( ( *(cross_point + m ) != *(*(content + x ) + m ) && *(cross_point + m ) != 0 ) ||
( (( in_x + y ) > (X - 1) ) || ( ( in_y + y ) > (Y - 1) ) ) ) {
key = 0;
break;
}
if( *(cross_point + m ) == *(*(content + x ) + m )){
key++;
}
if( m == y ){
*point = x ; return key ;
}
}
}
return 0;
}
void write_horizantal ( int x , int y ,char board[][Y] , char *content ){
while( *content ){
*( *(board + x) + y++ ) = *content++ ;
}
}
void write_vertical( int x , int y , char board[][Y] , char *content ){
while( *content ){
*( *(board + x++ ) + y) = *content++ ;
}
}
int checking_space_null (char board[][Y] , int mem ,int sh, int br ){
int slc = 0;
if(
( board[ ( sh ) - br ][mem - 1 ] != 0 || board[ ( sh ) - br ][mem + 1 ] != 0 ) &&
board[ ( sh ) - br ][mem ] == 0 ) {
slc = 1;
}
return slc;
}
int checking_space_one (char board[][Y] , int mem ,int sh, int br ){
int slc = 0;
if(
( board[ mem - 1 ][ ( sh ) - br ] != 0 || board[ mem + 1 ][ ( sh ) - br ] != 0 ) &&
board[ mem ][ ( sh ) - br ] == 0
) {
slc = 1;
} return slc;
}
дегенератор кроссворда 2 ч.
−1
#include<stdio.h>
#include<stdlib.h>
#include <time.h>
#include <locale.h>
#include <string.h>
#include <ctype.h>
#define PL 300
#define X 35
#define Y 35
#define LN 15
#define MN 2
int main(void){
char *words[PL] = {
"гарпия","ястреб", "самоходка","снайпер","медведь","баркас","ельцин", "пушкин","рязанов","рузвельт","вагонетка","богатырь", "галстук","мебель","вождь","кобра","журналист", "валюта","кабель","реванш",
"фляжка","пирожок", "гайдай","люстра","соль","вантуз","дерево", "крантик","гитара","спилберг", "пижон","европа", "достоевский","самокрутка","адвокат","колыбель","калькулятор", "освальд","остановка","фикус",
"вавилен","мыщъх", "озборн","ильинский","пархоменко","связка","стекло", "крепеж","тайсон","мэйсон","николай","глушитель", "сапфир","служанка","стояк","пфайфер","градусник", "стамбул","маядзаки","эйзенхаур",
"али","колбаса", "яжевика","совок","число","кобель","ожог", "страница","ваучер","пафос", "самокат","хвостик", "дурында","пучков","дворкович","барабас","сурков", "шут","асфальт","токио",
"лепесток","удав", "выстрел","калибр","улов","копенгаген","осло", "калипсо","грунт","процент", "блоха","след", "пружина","монтажник","экран","боромир","оскар", "бобик","курасава","никсон",
"сталкер","ягодица", "глазок","шмель","геринг","монро","бондаренко", "стрела","носок","мачетэ","шпицберген","сталь", "монолит","случай","зуб","малохит","клубника", "золото","чехов","диск",
"форд","чубайс", "пелевин","юматов","молоток","демократия","сократ", "геродот","невзоров","сорокин","макконохи","быков", "штанга","гвоздь","весло","табурет","вопрос", "колдовство","обида","смерчь",
"блэкмор","тезка", "зубик","сноха","порше","тормоз","туше", " сигал","баярский","китано", "лунаход","гагарин", "синематограф","жим","электрика","веретино","шахматы", "кувшин","букварь","символ",
"башня","котенок", "револьвер","леннон","тигр","телефон","хамелеон", "матрас","зубр","техникс","леонов","коппола", "овчарка","ауди","сфинкс","матрос","ленин", "доберман","фролово","банан",
"самосвал","куба", "амстердам","клык","шпиль","мука","край", "чатский","бугур","паскаль","альпы","лодка", "транспорт","гиря","шпагат","боцман","мауддиб", "игра","крыло","окно",
"одежда","кольцо", "монитор","гриб","тетрис","человек","обезьяна", "шахматы","кинг","эллрой","кобейн","немезида", "ванна","волонтер","эхо","икота","пена", "звук","сьемка","отстойник",
"мачо","конверт", "снаряд","писатель","поисковик","бегун","бетон", "коллапс","пожарник","сигнал","балоболка","свекровь", "спойлер","запас","морковь","питбуль","кемерово", "загон","юпитер","вашингтон",
"труба","статуя", "дверь","агрегат","мачта","корень","волчара", "корова","маскит","радзинский","канада","челюсть", "сейлормун","ньютон","дзержинский","шестерня","валькирия", "компот","адам","матрица",
"бетховен","пудель", "деталь","коломбо","рахит","монголия","колба", "конфета","енот","груздь","наполеон","вертухай", "сковородка","гейша","мост","гриль","комедия", "кубрик","ганапольский","паук",
"скороход","крым", "ротшильд","гайдар","пешка","козырь","дерижабль", "магнезия","магнум","рогатка","гайка","штопор", "перевертыш","репортаж","москва","дзедун","меньшов", "пиксель","розетка","гарем",
};
srand(time(NULL));
setlocale( LC_ALL,"Russian" );
void write_vertical( int x , int y , char board[][Y] , char *content );
void write_horizantal( int x , int y ,char board[][Y] , char *content );
void(*write[ MN])( int x , int y ,char board[][Y] , char *content ) = {write_vertical,write_horizantal};
int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x , int in_y );
int checking_space_null (char board[][Y] , int mem ,int sh, int br );
int checking_space_one (char board[][Y] , int mem ,int sh, int br );
int (*chk_mask[ MN])(char board[][Y] , int mem ,int sh, int br ) = { checking_space_null , checking_space_one } ;
int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x , int in_y ) ;
int n_x = 2 , n_y = 3 ;
int kk = 0;
int first = first = 1 + rand() % 299 ;
int lng = strlen(words[first]) ;
char crossboard[X][Y] = {" "} ;
int removing_mask (int *x , int *y, int *lng , char board[][Y],
char *content[PL], int select, void (*write )( int x , int y ,char board[][Y],
char *content ),
int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x , int in_y) ,
int (*chk_mask )(char board[][Y] , int mem ,int sh, int br ) );
write_horizantal( n_x , n_y , crossboard , words[first] );
words[first] = " ";
for(removing_mask( &n_x , &n_y , &lng , crossboard , words , kk % MN , write[kk % MN] , search_cross_pnt , chk_mask[kk % MN] );
removing_mask( &n_x , &n_y , &lng , crossboard , words , kk % MN , write[kk % MN] , search_cross_pnt , chk_mask[kk % MN] ) ;
kk++
) ;
for( n_x = 0 ;n_x <= X - 1 ; n_x ++, puts(" ") ){
for(n_y = 0 ;n_y <= Y - 1 ; n_y++ ){
printf("%c " , crossboard[n_x ][n_y ] ) ;
}
}
return 0;
}
Якобы генератор Кроссворда 1
0
void trampoline(void (*func)(void), bool flag)
{
if (flag)
func();
else
trampoline(func, true);
}
int
main(int argc, char *argv[])
{
/*... */
trampoline(set_aes_keys, false);
}
Зачем так? ЯННП.
−1
bool P(int *X, int k, int y, int N) // Поиск позиции для ферзя
{
int i = 0;
while ((i<k) && (y != X[i]) && (abs(k - i) != abs(y - X[i]))) { i++; }
if (i == k)
return true;
else if (i != k)
return false;
else
return !true && !false;
}
Часть задачи о восьми ферзях. Обнаружена на Тостере.
Обратите внимание на цикл («обнаружен бой — стоп»), и на аналог return (i==k).
0
LRESULT WINAPI DefWindowProc(
_In_ HWND hWnd,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
0
// https://github.com/google/brotli/blob/29dc2cce9090d6c92c908116e11373bc7fdc8ad1/c/enc/static_dict.c#L82
/* Transforms "" + BROTLI_TRANSFORM_IDENTITY + <suffix> */
if (s[0] == ' ') {
AddMatch(id + n, l + 1, l, matches);
if (s[1] == 'a') {
if (s[2] == ' ') {
AddMatch(id + 28 * n, l + 3, l, matches);
} else if (s[2] == 's') {
if (s[3] == ' ') AddMatch(id + 46 * n, l + 4, l, matches);
} else if (s[2] == 't') {
if (s[3] == ' ') AddMatch(id + 60 * n, l + 4, l, matches);
} else if (s[2] == 'n') {
if (s[3] == 'd' && s[4] == ' ') {
AddMatch(id + 10 * n, l + 5, l, matches);
}
}
} else if (s[1] == 'b') {
if (s[2] == 'y' && s[3] == ' ') {
AddMatch(id + 38 * n, l + 4, l, matches);
}
} else if (s[1] == 'i') {
if (s[2] == 'n') {
if (s[3] == ' ') AddMatch(id + 16 * n, l + 4, l, matches);
} else if (s[2] == 's') {
if (s[3] == ' ') AddMatch(id + 47 * n, l + 4, l, matches);
}
} else if (s[1] == 'f') {
if (s[2] == 'o') {
if (s[3] == 'r' && s[4] == ' ') {
AddMatch(id + 25 * n, l + 5, l, matches);
}
} else if (s[2] == 'r') {
if (s[3] == 'o' && s[4] == 'm' && s[5] == ' ') {
AddMatch(id + 37 * n, l + 6, l, matches);
}
}
} else if (s[1] == 'o') {
if (s[2] == 'f') {
if (s[3] == ' ') AddMatch(id + 8 * n, l + 4, l, matches);
} else if (s[2] == 'n') {
if (s[3] == ' ') AddMatch(id + 45 * n, l + 4, l, matches);
}
} else if (s[1] == 'n') {
if (s[2] == 'o' && s[3] == 't' && s[4] == ' ') {
AddMatch(id + 80 * n, l + 5, l, matches);
}
} else if (s[1] == 't') {
if (s[2] == 'h') {
if (s[3] == 'e') {
if (s[4] == ' ') AddMatch(id + 5 * n, l + 5, l, matches);
} else if (s[3] == 'a') {
if (s[4] == 't' && s[5] == ' ') {
AddMatch(id + 29 * n, l + 6, l, matches);
}
}
} else if (s[2] == 'o') {
if (s[3] == ' ') AddMatch(id + 17 * n, l + 4, l, matches);
}
} else if (s[1] == 'w') {
if (s[2] == 'i' && s[3] == 't' && s[4] == 'h' && s[5] == ' ') {
AddMatch(id + 35 * n, l + 6, l, matches);
}
}
} else if (s[0] == '"') {
AddMatch(id + 19 * n, l + 1, l, matches);
if (s[1] == '>') {
AddMatch(id + 21 * n, l + 2, l, matches);
}
} else if (s[0] == '.') {
AddMatch(id + 20 * n, l + 1, l, matches);
if (s[1] == ' ') {
AddMatch(id + 31 * n, l + 2, l, matches);
if (s[2] == 'T' && s[3] == 'h') {
if (s[4] == 'e') {
if (s[5] == ' ') AddMatch(id + 43 * n, l + 6, l, matches);
} else if (s[4] == 'i') {
if (s[5] == 's' && s[6] == ' ') {
AddMatch(id + 75 * n, l + 7, l, matches);
}
}
}
}
} else if (s[0] == ',') {
AddMatch(id + 76 * n, l + 1, l, matches);
if (s[1] == ' ') {
AddMatch(id + 14 * n, l + 2, l, matches);
}
} else if (s[0] == '\n') {
AddMatch(id + 22 * n, l + 1, l, matches);
if (s[1] == '\t') {
AddMatch(id + 50 * n, l + 2, l, matches);
}
} else if (s[0] == ']') {
AddMatch(id + 24 * n, l + 1, l, matches);
} else if (s[0] == '\'') {
AddMatch(id + 36 * n, l + 1, l, matches);
} else if (s[0] == ':') {
AddMatch(id + 51 * n, l + 1, l, matches);
Какая-то непонятная херота из архиватора Brotli с кучей магических констант, которые хрен знает что означают. Очевидно, этот код должен находить в текстовых данных какие-то часто встречающиеся куски текста, и таким образом сжимать эту хрень (т.н. словарный метод сжатия) но зачем все так пиздануто рассовывать по буквам в куче if() ?
Не могли для этого каких-нибудь ГОМОИКОН сделать?