Remove unused sys/time.h, remove snprintf, add casts for sign/unsigned complaints, all Visual C++
git-svn-id: https://cld2.googlecode.com/svn/trunk@78 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
@@ -68,7 +68,7 @@ uint32 GetNextLangprob(ULScriptRType rtype,
|
||||
uint32 probs = QuadHashV3Lookup4(wrt_quadgram_obj, quadhash);
|
||||
int indirect_subscr = probs & ~wrt_quadgram_obj->kCLDTableKeyMask;
|
||||
uint32 langprob;
|
||||
if (indirect_subscr < wrt_quadgram_obj->kCLDTableSizeOne) {
|
||||
if (indirect_subscr < static_cast<int>(wrt_quadgram_obj->kCLDTableSizeOne)) {
|
||||
// Up to three languages at indirect
|
||||
langprob = wrt_quadgram_obj->kCLDTableInd[indirect_subscr];
|
||||
} else {
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include "compact_lang_det_hint_code.h"
|
||||
|
||||
#include <stdlib.h> // for abs()
|
||||
#include <stdio.h> // for snprintf()
|
||||
#include <stdio.h> // for sprintf()
|
||||
#include <string.h> //
|
||||
#include "lang_script.h"
|
||||
#include "port.h"
|
||||
@@ -1506,12 +1506,12 @@ void SetCLDLanguageHint(Language lang, CLDLangPriors* langpriors) {
|
||||
}
|
||||
|
||||
|
||||
// Make printable stringof priors
|
||||
// Make printable string of priors
|
||||
string DumpCLDLangPriors(const CLDLangPriors* langpriors) {
|
||||
string retval;
|
||||
for (int i = 0; i < langpriors->n; ++i) {
|
||||
char temp[32];
|
||||
snprintf(temp, sizeof(temp), "%s.%d ",
|
||||
char temp[64];
|
||||
sprintf(temp, "%s.%d ",
|
||||
LanguageCode(GetCLDPriorLang(langpriors->prior[i])),
|
||||
GetCLDPriorWeight(langpriors->prior[i]));
|
||||
retval.append(temp);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h> // for gettimeofday
|
||||
#include <string>
|
||||
|
||||
#include "cldutil.h"
|
||||
|
@@ -128,7 +128,7 @@ string GetScoreTxt(const ScoringContext* scoringcontext,
|
||||
const CLD2TableSummary* base_obj, int indirect) {
|
||||
string retval;
|
||||
retval.clear();
|
||||
if (indirect < base_obj->kCLDTableSizeOne) {
|
||||
if (indirect < static_cast<int>(base_obj->kCLDTableSizeOne)) {
|
||||
// Up to three languages at indirect
|
||||
uint32 langprob = base_obj->kCLDTableInd[indirect];
|
||||
retval.append(GetLangProbTxt(scoringcontext, langprob));
|
||||
@@ -209,7 +209,7 @@ static int GetTextColor(Language lang, bool lighten) {
|
||||
string GetPlainEscapedText(const string& txt) {
|
||||
string retval;
|
||||
retval.clear();
|
||||
for (int i = 0; i < txt.size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(txt.size()); ++i) {
|
||||
char c = txt[i];
|
||||
if (c == '\n') {
|
||||
retval.append(" ");
|
||||
@@ -225,7 +225,7 @@ string GetPlainEscapedText(const string& txt) {
|
||||
string GetHtmlEscapedText(const string& txt) {
|
||||
string retval;
|
||||
retval.clear();
|
||||
for (int i = 0; i < txt.size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(txt.size()); ++i) {
|
||||
char c = txt[i];
|
||||
if (c == '<') {
|
||||
retval.append("<");
|
||||
@@ -463,7 +463,7 @@ void CLD2_Debug2(const char* text,
|
||||
void DumpResultChunkVector(FILE* f, const char* src,
|
||||
ResultChunkVector* resultchunkvector) {
|
||||
fprintf(f, "DumpResultChunkVector[%ld]<br>\n", resultchunkvector->size());
|
||||
for (int i = 0; i < resultchunkvector->size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(resultchunkvector->size()); ++i) {
|
||||
ResultChunk* rc = &(*resultchunkvector)[i];
|
||||
Language lang1 = static_cast<Language>(rc->lang1);
|
||||
string this_chunk = string(src, rc->offset, rc->bytes);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
|
||||
#include "getonescriptspan.h"
|
||||
#include <sys/time.h> // for gettimeofday
|
||||
#include <string.h>
|
||||
|
||||
#include "fixunicodevalue.h"
|
||||
@@ -287,14 +286,6 @@ int runetochar(char *str, const char32 *rune) {
|
||||
}
|
||||
|
||||
|
||||
// Convert GetTimeOfDay output to 64-bit usec
|
||||
static inline uint64 Microseconds(const struct timeval& t) {
|
||||
// The SumReducer uses uint64, so convert to (uint64) microseconds,
|
||||
// not (double) seconds.
|
||||
return t.tv_sec * 1000000ULL + t.tv_usec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Useful for converting an entity to an ascii value.
|
||||
// RETURNS unicode value, or -1 if entity isn't valid. Don't include & or ;
|
||||
@@ -844,7 +835,6 @@ bool ScriptScanner::GetOneScriptSpan(LangSpan* span) {
|
||||
map2original_.Clear();
|
||||
map2original_.Delete(span->offset); // So that MapBack(0) gives offset
|
||||
|
||||
// gettimeofday(&script_start, NULL);
|
||||
// Get to the first real non-tag letter or entity that is a letter
|
||||
int skip = SkipToFrontOfSpan(next_byte_, byte_length_, &spanscript);
|
||||
next_byte_ += skip;
|
||||
@@ -861,8 +851,6 @@ bool ScriptScanner::GetOneScriptSpan(LangSpan* span) {
|
||||
return false; // No more letters to be found
|
||||
}
|
||||
|
||||
// gettimeofday(&script_mid, NULL);
|
||||
|
||||
// There is at least one letter, so we know the script for this span
|
||||
span->ulscript = (ULScript)spanscript;
|
||||
|
||||
|
@@ -80,7 +80,7 @@ void OffsetMap::Printmap(const char* filename) {
|
||||
|
||||
Flush(); // Make sure any pending entry gets printed
|
||||
fprintf(fout, "Offsetmap: %ld bytes\n", diffs_.size());
|
||||
for (int i = 0; i < diffs_.size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(diffs_.size()); ++i) {
|
||||
fprintf(fout, "%c%02d ", "&=+-"[OpPart(diffs_[i])], LenPart(diffs_[i]));
|
||||
if ((i % 20) == 19) {fprintf(fout, "\n");}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ void OffsetMap::Emit(MapOp op, int len) {
|
||||
}
|
||||
|
||||
void OffsetMap::DumpString() {
|
||||
for (int i = 0; i < diffs_.size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(diffs_.size()); ++i) {
|
||||
fprintf(stderr, "%c%02d ", "&=+-"[OpPart(diffs_[i])], LenPart(diffs_[i]));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
@@ -216,7 +216,7 @@ void OffsetMap::DumpString() {
|
||||
int aoffset = 0;
|
||||
int aprimeoffset = 0;
|
||||
int length = 0;
|
||||
for (int i = 0; i < diffs_.size(); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(diffs_.size()); ++i) {
|
||||
char c = diffs_[i];
|
||||
MapOp op = static_cast<MapOp>(OpPart(c));
|
||||
int len = LenPart(c);
|
||||
@@ -317,7 +317,7 @@ int OffsetMap::ParseNext(int sub, MapOp* op, int* length) {
|
||||
*op = PREFIX_OP;
|
||||
*length = 0;
|
||||
char c;
|
||||
while ((sub < diffs_.size()) && (*op == PREFIX_OP)) {
|
||||
while ((sub < static_cast<int>(diffs_.size())) && (*op == PREFIX_OP)) {
|
||||
c = diffs_[sub++];
|
||||
*op = static_cast<MapOp>(OpPart(c));
|
||||
int len = LenPart(c);
|
||||
@@ -339,7 +339,7 @@ int OffsetMap::ParsePrevious(int sub, MapOp* op, int* length) {
|
||||
void OffsetMap::PrintPosition(const char* str) {
|
||||
MapOp op = PREFIX_OP;
|
||||
int length = 0;
|
||||
if ((0 < next_diff_sub_) && (next_diff_sub_ <= diffs_.size())) {
|
||||
if ((0 < next_diff_sub_) && (next_diff_sub_ <= static_cast<int>(diffs_.size()))) {
|
||||
op = static_cast<MapOp>(OpPart(diffs_[next_diff_sub_ - 1]));
|
||||
length = LenPart(diffs_[next_diff_sub_ - 1]);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ void OffsetMap::PrintPosition(const char* str) {
|
||||
// Return true if move was OK
|
||||
bool OffsetMap::MoveRight() {
|
||||
// If at last range or RIGHT, set to RIGHT, return error
|
||||
if (next_diff_sub_ >= diffs_.size()) {
|
||||
if (next_diff_sub_ >= static_cast<int>(diffs_.size())) {
|
||||
SetRight();
|
||||
return false;
|
||||
}
|
||||
|
@@ -184,7 +184,7 @@ void GetTextSpanOffsets(const ScoringHitBuffer* hitbuffer,
|
||||
|
||||
int DiffScore(const CLD2TableSummary* obj, int indirect,
|
||||
uint16 lang1, uint16 lang2) {
|
||||
if (indirect < obj->kCLDTableSizeOne) {
|
||||
if (indirect < static_cast<int>(obj->kCLDTableSizeOne)) {
|
||||
// Up to three languages at indirect
|
||||
uint32 langprob = obj->kCLDTableInd[indirect];
|
||||
return GetLangScore(langprob, lang1) - GetLangScore(langprob, lang2);
|
||||
@@ -914,7 +914,7 @@ void LinearizeAll(ScoringContext* scoringcontext, bool score_cjk,
|
||||
++base_i;
|
||||
// One langprob in kQuadInd[0..SingleSize),
|
||||
// two in kQuadInd[SingleSize..Size)
|
||||
if (indirect < base_obj->kCLDTableSizeOne) {
|
||||
if (indirect < static_cast<int>(base_obj->kCLDTableSizeOne)) {
|
||||
// Up to three languages at indirect
|
||||
uint32 langprob = base_obj->kCLDTableInd[indirect];
|
||||
if (langprob > 0) {
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <math.h> // for sqrt
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h> // for gettimeofday
|
||||
#include <string>
|
||||
|
||||
#include "debug.h" // for uint8 etc
|
||||
|
Reference in New Issue
Block a user