--- parser3/src/main/pa_common.C 2016/09/21 14:12:23 1.293 +++ parser3/src/main/pa_common.C 2016/12/28 22:50:07 1.298 @@ -50,7 +50,7 @@ #define pa_mkdir(path, mode) mkdir(path, mode) #endif -volatile const char * IDENT_PA_COMMON_C="$Id: pa_common.C,v 1.293 2016/09/21 14:12:23 moko Exp $" IDENT_PA_COMMON_H IDENT_PA_HASH_H IDENT_PA_ARRAY_H IDENT_PA_STACK_H; +volatile const char * IDENT_PA_COMMON_C="$Id: pa_common.C,v 1.298 2016/12/28 22:50:07 moko Exp $" IDENT_PA_COMMON_H IDENT_PA_HASH_H IDENT_PA_ARRAY_H IDENT_PA_STACK_H; // some maybe-undefined constants @@ -75,11 +75,6 @@ volatile const char * IDENT_PA_COMMON_C= #define FILE_STATUS_NAME "status" -// defines for vs2015 linking with old libs -#if _MSC_VER >= 1900 -int (WINAPIV * __vsnprintf)(char *, size_t, const char*, va_list) = _vsnprintf; -#endif - // globals const String file_status_name(FILE_STATUS_NAME); @@ -161,9 +156,9 @@ File_read_result file_read(Request_chars Charset* asked_charset=0; if(params) if(Value* vcharset_name=params->get(PA_CHARSET_NAME)) - asked_charset=&::charsets.get(vcharset_name->as_string()); + asked_charset=&pa_charsets.get(vcharset_name->as_string()); - asked_charset=::charsets.checkBOM(result.str, result.length, asked_charset); + asked_charset=pa_charsets.checkBOM(result.str, result.length, asked_charset); if(result.length && transcode_text_result && asked_charset){ // length must be checked because transcode returns CONST string in case length==0, which contradicts hacking few lines below String::C body=String::C(result.str, result.length); @@ -245,7 +240,7 @@ bool file_read_action_under_lock(const S throw Exception("file.lock", &file_spec, "shared lock failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); struct stat finfo; - if(fstat(f, &finfo)!=0) + if(pa_fstat(f, &finfo)!=0) throw Exception("file.missing", // hardly possible: we just opened it OK &file_spec, "stat failed: %s (%d), actual filename '%s'", strerror(errno), errno, fname); @@ -307,7 +302,7 @@ bool file_write_action_under_lock( try { #if (defined(HAVE_FCHMOD) && defined(PA_SAFE_MODE)) struct stat finfo; - if(fstat(f, &finfo)==0 && finfo.st_mode & 0111) + if(pa_fstat(f, &finfo)==0 && finfo.st_mode & 0111) fchmod(f, finfo.st_mode & 0666/*clear executable bits*/); // backward: ignore errors if any #endif action(f, context); @@ -467,7 +462,7 @@ void file_move(const String& old_spec, c bool entry_exists(const char* fname, struct stat *afinfo) { struct stat lfinfo; - bool result=stat(fname, &lfinfo)==0; + bool result=pa_stat(fname, &lfinfo)==0; if(afinfo) *afinfo=lfinfo; return result; @@ -498,15 +493,10 @@ bool file_executable(const String& file_ return access(file_spec.taint_cstr(String::L_FILE_SPEC), X_OK)==0; } -bool file_stat(const String& file_spec, - size_t& rsize, - time_t& ratime, - time_t& rmtime, - time_t& rctime, - bool fail_on_read_problem) { +bool file_stat(const String& file_spec, uint64_t& rsize, time_t& ratime, time_t& rmtime, time_t& rctime, bool fail_on_read_problem) { const char* fname=file_spec.taint_cstr(String::L_FILE_SPEC); struct stat finfo; - if(stat(fname, &finfo)!=0) { + if(pa_stat(fname, &finfo)!=0) { if(fail_on_read_problem) throw Exception("file.missing", &file_spec, "getting file size failed: %s (%d), real filename '%s'", strerror(errno), errno, fname); else @@ -1256,7 +1246,7 @@ inline void CalcCrc32(const unsigned cha } -const unsigned long pa_crc32(const char *in, size_t in_size){ +unsigned long pa_crc32(const char *in, size_t in_size){ unsigned long crc32=0xFFFFFFFF; InitCrc32Table(); @@ -1279,7 +1269,7 @@ static void file_crc32_file_action(struc } } -const unsigned long pa_crc32(const String& file_spec){ +unsigned long pa_crc32(const String& file_spec){ unsigned long crc32=0xFFFFFFFF; file_read_action_under_lock(file_spec, "crc32", file_crc32_file_action, &crc32); return ~crc32; @@ -1306,7 +1296,7 @@ Charset* detect_charset(const char* cont if(end) *end=0; // terminator - return *begin?&charsets.get_direct(begin):0; + return *begin ? &pa_charsets.get_direct(begin) : 0; } } return 0; @@ -1333,7 +1323,7 @@ const char *pa_idna_encode(const char *i String::C sIn(in,strlen(in)); if(!source_charset.isUTF8()) - sIn=Charset::transcode(sIn, source_charset, UTF8_charset); + sIn=Charset::transcode(sIn, source_charset, pa_UTF8_charset); int status=pa_convertUTF8toUTF32((const UTF8**)&sIn.str, (const UTF8*)(sIn.str+sIn.length), &utf32_end, utf32+MAX_IDNA_LENGTH-1, strictConversion); if(status != conversionOK) @@ -1374,7 +1364,7 @@ const char *pa_idna_decode(const char *i *result_end='\0'; if(!asked_charset.isUTF8()) - result = (char *)Charset::transcode(result, UTF8_charset, asked_charset).cstr(); + result = (char *)Charset::transcode(result, pa_UTF8_charset, asked_charset).cstr(); return result; }