Skip to content

Commit

Permalink
fix configure.ac; unify identifiers (WIN32 vs _WIN32)
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@688 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
zdenop@gmail.com committed Mar 2, 2012
1 parent 657722a commit e216ada
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 51 deletions.
2 changes: 1 addition & 1 deletion api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "allheaders.h"

#ifdef USE_NLS
#ifdef USING_GETTEXT
#include <libintl.h>
#include <locale.h>
#define _(x) gettext(x)
Expand Down
2 changes: 1 addition & 1 deletion api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
**********************************************************************/

int main(int argc, char **argv) {
#ifdef USE_NLS
#ifdef USING_GETTEXT
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
Expand Down
5 changes: 5 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#
# All the rest is auto-generated.

# create m4 directory if it not exists
if [ ! -d m4 ]; then
mkdir m4
fi

bail_out()
{
echo
Expand Down
2 changes: 1 addition & 1 deletion ccmain/pagesegmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
**********************************************************************/

#ifdef WIN32
#ifdef _WIN32
#ifndef __GNUC__
#include <windows.h>
#endif /* __GNUC__ */
Expand Down
2 changes: 1 addition & 1 deletion ccmain/paramsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//
// The parameters editor is used to edit all the parameters used within
// tesseract from the ui.
#ifdef WIN32
#ifdef _WIN32
#else
#include <stdlib.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions ccutil/ambigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include "ambigs.h"
#include "helpers.h"

#ifdef WIN32
#ifdef _WIN32
#ifndef __GNUC__
#define strtok_r strtok_s
#else
#include "strtok_r.h"
#endif /* __GNUC__ */
#endif /* WIN32 */
#endif /* _WIN32 */

namespace tesseract {

Expand Down
6 changes: 3 additions & 3 deletions ccutil/ccutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ CCUtil::~CCUtil() {


CCUtilMutex::CCUtilMutex() {
#ifdef WIN32
#ifdef _WIN32
mutex_ = CreateMutex(0, FALSE, 0);
#else
pthread_mutex_init(&mutex_, NULL);
#endif
}

void CCUtilMutex::Lock() {
#ifdef WIN32
#ifdef _WIN32
WaitForSingleObject(mutex_, INFINITE);
#else
pthread_mutex_lock(&mutex_);
#endif
}

void CCUtilMutex::Unlock() {
#ifdef WIN32
#ifdef _WIN32
ReleaseMutex(mutex_);
#else
pthread_mutex_unlock(&mutex_);
Expand Down
4 changes: 2 additions & 2 deletions ccutil/ccutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "params.h"
#include "unicharset.h"

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
Expand All @@ -43,7 +43,7 @@ class CCUtilMutex {

void Unlock();
private:
#ifdef WIN32
#ifdef _WIN32
HANDLE mutex_;
#else
pthread_mutex_t mutex_;
Expand Down
2 changes: 1 addition & 1 deletion classify/mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ FEATURE_SET ExtractMicros(TBLOB *Blob, const DENORM& denorm) {
Feature->Params[MFBulge1] = 0.0f;
Feature->Params[MFBulge2] = 0.0f;

#ifndef WIN32
#ifndef _WIN32
// Assert that feature parameters are well defined.
int i;
for (i = 0; i < Feature->Type->NumParams; i++) {
Expand Down
4 changes: 2 additions & 2 deletions classify/ocrfeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ FEATURE ReadFeature(FILE *File, const FEATURE_DESC_STRUCT* FeatureDesc) {
for (i = 0; i < Feature->Type->NumParams; i++) {
if (fscanf (File, "%f", &(Feature->Params[i])) != 1)
DoError (ILLEGAL_FEATURE_PARAM, "Illegal feature parameter spec");
#ifndef WIN32
#ifndef _WIN32
assert (!isnan(Feature->Params[i]));
#endif
}
Expand Down Expand Up @@ -230,7 +230,7 @@ void WriteFeature(FILE *File, FEATURE Feature) {
int i;

for (i = 0; i < Feature->Type->NumParams; i++) {
#ifndef WIN32
#ifndef _WIN32
assert(!isnan(Feature->Params[i]));
#endif
fprintf(File, " %g", Feature->Params[i]);
Expand Down
14 changes: 0 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ if test "$enable_embedded" = "yes"; then
AC_SUBST([AM_CPPFLAGS], [-DEMBEDDED])
fi

# check whether to build embedded version
AC_MSG_CHECKING(--enable-embedded argument)
AC_ARG_ENABLE([embedded],
[ --enable-embedded enable embedded build (default=no)],
[enable_embedded=$enableval],
[enable_embedded="no"])
AC_MSG_RESULT($enable_embedded)
AM_CONDITIONAL([EMBEDDED], [test "$enable_embedded" = "yes"])
if test "$enable_embedded" = "yes"; then
#AC_DEFINE([EMBEDDED], [], [Embedded Mode])
AC_SUBST([AM_CXXFLAGS], [-DEMBEDDED])
AC_SUBST([AM_CPPFLAGS], [-DEMBEDDED])
fi

# check whether to build multiple libraries
AC_MSG_CHECKING(--enable-multiple-libraries argument)
AC_ARG_ENABLE([multiple-libraries],
Expand Down
2 changes: 1 addition & 1 deletion cube/bmp_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using std::min;
using std::max;
#endif

#ifdef WIN32
#ifdef _WIN32
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down
2 changes: 1 addition & 1 deletion cube/feature_chebyshev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "const.h"
#include "char_samp.h"

#ifdef WIN32
#ifdef _WIN32
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down
2 changes: 1 addition & 1 deletion training/mftraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#ifdef WIN32
#ifdef _WIN32
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down
34 changes: 17 additions & 17 deletions viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// thread/process creation & synchronization and network connection.

#include <stdio.h>
#ifdef WIN32
#ifdef _WIN32
struct addrinfo {
struct sockaddr* ai_addr;
int ai_addrlen;
Expand Down Expand Up @@ -64,7 +64,7 @@ const int kMaxMsgSize = 4096;

// Signals a thread to exit.
void SVSync::ExitThread() {
#ifdef WIN32
#ifdef _WIN32
// ExitThread(0);
#else
pthread_exit(0);
Expand All @@ -73,7 +73,7 @@ void SVSync::ExitThread() {

// Starts a new process.
void SVSync::StartProcess(const char* executable, const char* args) {
#ifdef WIN32
#ifdef _WIN32
std::string proc;
proc.append(executable);
proc.append(" ");
Expand Down Expand Up @@ -123,47 +123,47 @@ void SVSync::StartProcess(const char* executable, const char* args) {
}

SVSemaphore::SVSemaphore() {
#ifdef WIN32
#ifdef _WIN32
semaphore_ = CreateSemaphore(0, 0, 10, 0);
#else
sem_init(&semaphore_, 0, 0);
#endif
}

void SVSemaphore::Signal() {
#ifdef WIN32
#ifdef _WIN32
ReleaseSemaphore(semaphore_, 1, NULL);
#else
sem_post(&semaphore_);
#endif
}

void SVSemaphore::Wait() {
#ifdef WIN32
#ifdef _WIN32
WaitForSingleObject(semaphore_, INFINITE);
#else
sem_wait(&semaphore_);
#endif
}

SVMutex::SVMutex() {
#ifdef WIN32
#ifdef _WIN32
mutex_ = CreateMutex(0, FALSE, 0);
#else
pthread_mutex_init(&mutex_, NULL);
#endif
}

void SVMutex::Lock() {
#ifdef WIN32
#ifdef _WIN32
WaitForSingleObject(mutex_, INFINITE);
#else
pthread_mutex_lock(&mutex_);
#endif
}

void SVMutex::Unlock() {
#ifdef WIN32
#ifdef _WIN32
ReleaseMutex(mutex_);
#else
pthread_mutex_unlock(&mutex_);
Expand All @@ -173,7 +173,7 @@ void SVMutex::Unlock() {
// Create new thread.

void SVSync::StartThread(void *(*func)(void*), void* arg) {
#ifdef WIN32
#ifdef _WIN32
LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE) func;
DWORD threadid;
HANDLE newthread = CreateThread(
Expand Down Expand Up @@ -210,7 +210,7 @@ void SVNetwork::Flush() {
// This will always return one line of char* (denoted by \n).
char* SVNetwork::Receive() {
char* result = NULL;
#ifdef WIN32
#ifdef _WIN32
if (has_content) { result = strtok (NULL, "\n"); }
#else
if (buffer_ptr_ != NULL) { result = strtok_r(NULL, "\n", &buffer_ptr_); }
Expand Down Expand Up @@ -246,7 +246,7 @@ char* SVNetwork::Receive() {
if (i <= 0) { return NULL; }
msg_buffer_in_[i] = '\0';
has_content = true;
#ifdef WIN32
#ifdef _WIN32
return strtok(msg_buffer_in_, "\n");
#else
// Setup a new string tokenizer.
Expand All @@ -257,7 +257,7 @@ char* SVNetwork::Receive() {

// Close the connection to the server.
void SVNetwork::Close() {
#ifdef WIN32
#ifdef _WIN32
closesocket(stream_);
#else
close(stream_);
Expand All @@ -267,7 +267,7 @@ void SVNetwork::Close() {

// The program to invoke to start ScrollView
static const char* ScrollViewProg() {
#ifdef WIN32
#ifdef _WIN32
const char* prog = "java -Xms512m -Xmx1024m";
#else
const char* prog = "sh";
Expand All @@ -283,7 +283,7 @@ static std::string ScrollViewCommand(std::string scrollview_path) {
// exceptions in piccolo. Ideally piccolo would be debugged to make
// this unnecessary.
// Also the path has to be separated by ; on windows and : otherwise.
#ifdef WIN32
#ifdef _WIN32
const char* cmd_template = "-Djava.library.path=%s -cp %s/ScrollView.jar;"
"%s/piccolo-1.2.jar;%s/piccolox-1.2.jar"
" com.google.scrollview.ScrollView";
Expand Down Expand Up @@ -332,7 +332,7 @@ static int GetAddrInfoNonLinux(const char* hostname, int port,
(*addr_info)->ai_socktype = SOCK_STREAM;

struct hostent *name;
#ifdef WIN32
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(1, 1), &wsaData);
name = gethostbyname(hostname);
Expand Down Expand Up @@ -412,7 +412,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
while (connect(stream_, (struct sockaddr *) addr_info->ai_addr,
addr_info->ai_addrlen) < 0) {
std::cout << "ScrollView: Waiting for server...\n";
#ifdef WIN32
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
Expand Down
6 changes: 3 additions & 3 deletions viewer/svutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef TESSERACT_VIEWER_SVUTIL_H__
#define TESSERACT_VIEWER_SVUTIL_H__

#ifdef WIN32
#ifdef _WIN32
#ifndef __GNUC__
#include <windows.h>
#define snprintf _snprintf
Expand Down Expand Up @@ -73,7 +73,7 @@ class SVSemaphore {
/// Wait on a semaphore.
void Wait();
private:
#ifdef WIN32
#ifdef _WIN32
HANDLE semaphore_;
#else
sem_t semaphore_;
Expand All @@ -91,7 +91,7 @@ class SVMutex {
/// Unlocks on a mutex.
void Unlock();
private:
#ifdef WIN32
#ifdef _WIN32
HANDLE mutex_;
#else
pthread_mutex_t mutex_;
Expand Down

0 comments on commit e216ada

Please sign in to comment.