Кресты / Говнокод #1459 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
try
{
   fIn = fopen(cszFileName, "rb");
   if (fIn == 0)
     throw (std::string("Can not open file: ") + cszFileName);
  
   if (!ParseFile(fIn, pLookup))
     throw (std::string("Bad file format. File: ") + cszFileName);
 
   throw std::string("");
}
catch (std::string& e)
{
   if (fIn != 0)
   {
      fclose(fIn);
      fIn = NULL;
   }
   if (e.length() != 0)
   {
      throw std::exception(e.c_str());
   }
}

Исправленный говнокод

guest guest, (Updated )

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

Кресты / Говнокод #1458 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
try
{
   fIn = fopen(cszFileName, "rb");
   if (fIn == 0)
   {
       throw (std::string("Can not open file: ") + cszFileName);
       if (!ParseFile(fIn, pLookup))
           throw (std::string("Bad file format. File: ") + cszFileName);
        
        throw std::string("");
    }
}
catch (std::string& e)
{
   if (fIn != 0)
   {
      fclose(fIn);
      fIn = NULL;
   }
   if (e.length() != 0)
   {
      throw std::exception(e.c_str());
   }
}

Просто говнокод

guest guest, (Updated )

Комментарии (2, +2)

Кресты / Говнокод #1455 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
#define KOEF_A	31415926
#define KOEF_B	27182818
#define INIT_VAL 3091976

unsigned long dVal;		

unsigned char rnd()
{
	unsigned long r = dVal*KOEF_A + KOEF_B;
	int m = dVal % 8;
	dVal = r >> m;
	dVal++;
	return (unsigned char)(dVal & 0xFF);
}

void Encode(void* data, int len)
{
	if( len < 1 ) return;
	for( int i = 0; i < len; i++ )
	{
		int xval = rnd();
		((char*)data)[i] ^= xval;
	}
}

используется для шифрования и дешифрования файла

guest guest, (Updated )

Комментарии (10, +10)

Кресты / Говнокод #1375 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
class Par_host_port
{
private:
        std::string vdata;
public:
//...
        char* get () { return (char*)vdata.c_str (); }
};

char const* превращается... Превращается char const*... В char*!

guest guest, (Updated )

Комментарии (7, +7)