Ensure the EOF \n in both UserPhrases and Replacement Map.
This commit is contained in:
parent
d072b95a99
commit
79e30215a1
|
@ -41,7 +41,7 @@ bool FastLM::open(const char *path)
|
||||||
char z;
|
char z;
|
||||||
zfd.get(z);
|
zfd.get(z);
|
||||||
if(z!='\n'){
|
if(z!='\n'){
|
||||||
syslog(LOG_CONS, "REPORT: File is not ended with a new line.\n");
|
syslog(LOG_CONS, "REPORT: Core Language Data file is not ended with a new line.\n");
|
||||||
syslog(LOG_CONS, "PROCEDURE: Trying to insert a new line as EOF before per-line check process.\n");
|
syslog(LOG_CONS, "PROCEDURE: Trying to insert a new line as EOF before per-line check process.\n");
|
||||||
ofstream zfdo(path, std::ios_base::app);
|
ofstream zfdo(path, std::ios_base::app);
|
||||||
zfdo << std::endl;
|
zfdo << std::endl;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Some rights reserved. See "LICENSE.TXT" for details.
|
* Some rights reserved. See "LICENSE.TXT" for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <syslog.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -38,6 +39,22 @@ bool PhraseReplacementMap::open(const char *path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::fstream zfd(path);
|
||||||
|
zfd.seekg(-1,std::ios_base::end);
|
||||||
|
char z;
|
||||||
|
zfd.get(z);
|
||||||
|
if(z!='\n'){
|
||||||
|
syslog(LOG_CONS, "REPORT: Phrase Replacement Map File is not ended with a new line.\n");
|
||||||
|
syslog(LOG_CONS, "PROCEDURE: Trying to insert a new line as EOF before per-line check process.\n");
|
||||||
|
std::ofstream zfdo(path, std::ios_base::app);
|
||||||
|
zfdo << std::endl;
|
||||||
|
zfdo.close();
|
||||||
|
if (zfdo.fail()) {
|
||||||
|
syslog(LOG_CONS, "REPORT: Failed to append a newline to the data file. Insufficient Privileges?\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fd = ::open(path, O_RDONLY);
|
fd = ::open(path, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
printf("open:: file not exist");
|
printf("open:: file not exist");
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UserPhrasesLM.h"
|
#include "UserPhrasesLM.h"
|
||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
#include "KeyValueBlobReader.h"
|
#include "KeyValueBlobReader.h"
|
||||||
|
|
||||||
|
@ -38,6 +38,22 @@ bool UserPhrasesLM::open(const char *path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::fstream zfd(path);
|
||||||
|
zfd.seekg(-1,std::ios_base::end);
|
||||||
|
char z;
|
||||||
|
zfd.get(z);
|
||||||
|
if(z!='\n'){
|
||||||
|
syslog(LOG_CONS, "REPORT: User Phrase Data File is not ended with a new line.\n");
|
||||||
|
syslog(LOG_CONS, "PROCEDURE: Trying to insert a new line as EOF before per-line check process.\n");
|
||||||
|
std::ofstream zfdo(path, std::ios_base::app);
|
||||||
|
zfdo << std::endl;
|
||||||
|
zfdo.close();
|
||||||
|
if (zfdo.fail()) {
|
||||||
|
syslog(LOG_CONS, "REPORT: Failed to append a newline to the data file. Insufficient Privileges?\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fd = ::open(path, O_RDONLY);
|
fd = ::open(path, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
printf("open:: file not exist");
|
printf("open:: file not exist");
|
||||||
|
|
Loading…
Reference in New Issue