Skip to content

Commit

Permalink
serialis: Modernize and format code
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 31, 2019
1 parent 8b663e7 commit 127d0e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/ccutil/params.h
Expand Up @@ -22,6 +22,7 @@
#include <cstdio>

#include "genericvector.h"
#include "host.h" // for BOOL8
#include "strngs.h"

namespace tesseract {
Expand Down
17 changes: 9 additions & 8 deletions src/ccutil/serialis.h
Expand Up @@ -2,7 +2,6 @@
* File: serialis.h (Formerly serialmac.h)
* Description: Inline routines and macros for serialisation functions
* Author: Phil Cheatle
* Created: Tue Oct 08 08:33:12 BST 1991
*
* (C) Copyright 1990, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,12 +19,13 @@
#ifndef SERIALIS_H
#define SERIALIS_H

#include <cstdint> // uint8_t
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include "host.h"

template <typename T> class GenericVector;
template <typename T>
class GenericVector;
class STRING;

/***********************************************************************
Expand All @@ -46,11 +46,10 @@ constexpr size_t countof(T const (&)[N]) noexcept {

// Function to read a GenericVector<char> from a whole file.
// Returns false on failure.
typedef bool (*FileReader)(const STRING& filename, GenericVector<char>* data);
using FileReader = bool (*)(const STRING&, GenericVector<char>*);
// Function to write a GenericVector<char> to a whole file.
// Returns false on failure.
typedef bool (*FileWriter)(const GenericVector<char>& data,
const STRING& filename);
using FileWriter = bool (*)(const GenericVector<char>&, const STRING&);

// Deserialize data from file.
bool DeSerialize(FILE* fp, char* data, size_t n = 1);
Expand Down Expand Up @@ -88,7 +87,9 @@ class TFile {
// From an open file and an end offset.
bool Open(FILE* fp, int64_t end_offset);
// Sets the value of the swap flag, so that FReadEndian does the right thing.
void set_swap(bool value) { swap_ = value; }
void set_swap(bool value) {
swap_ = value;
}

// Deserialize data.
bool DeSerialize(char* data, size_t count = 1);
Expand Down

2 comments on commit 127d0e3

@nguyenq
Copy link
Contributor

@nguyenq nguyenq commented on 127d0e3 Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit broke my Windows build with the following errors:

Severity Code Description Project File Line Suppression State
Error C2065 'CP_ACP': undeclared identifier libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 133
Error C3861 'MultiByteToWideChar': identifier not found libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 133
Error C2061 syntax error: identifier 'WCHAR' libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 134
Error C2065 'CP_ACP': undeclared identifier libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 135
Error C3861 'MultiByteToWideChar': identifier not found libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 135
Error C2065 'CP_UTF8': undeclared identifier libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 137
Error C3861 'WideCharToMultiByte': identifier not found libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 137
Error C2065 'CP_UTF8': undeclared identifier libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 140
Error C3861 'WideCharToMultiByte': identifier not found libtesseract410 c:\projects\github\tesseract-ocr\src\api\altorenderer.cpp 140

Putting #include "host.h" back in serialis.h would make it work again at this revision.

@stweil
Copy link
Contributor Author

@stweil stweil commented on 127d0e3 Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reporting this. It should be fixed now in latest Git master, see commit 81fbd87.

Please sign in to comment.