Skip to content

Commit

Permalink
Clean usage of assert.h
Browse files Browse the repository at this point in the history
Remove unneeded include statements, remove conditional statements and
replace the remaining assert.h by their standard C++ variant cassert.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 21, 2018
1 parent 629a10b commit 112aeb9
Show file tree
Hide file tree
Showing 32 changed files with 123 additions and 202 deletions.
27 changes: 12 additions & 15 deletions src/ccmain/adaptions.cpp
@@ -1,9 +1,9 @@
/**********************************************************************
* File: adaptions.cpp (Formerly adaptions.c)
* Description: Functions used to adapt to blobs already confidently
* identified
* Author: Chris Newton
* Created: Thu Oct 7 10:17:28 BST 1993
* identified
* Author: Chris Newton
* Created: Thu Oct 7 10:17:28 BST 1993
*
* (C) Copyright 1992, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,18 +18,15 @@
*
**********************************************************************/

#ifdef __UNIX__
#include <assert.h>
#endif
#include <ctype.h>
#include <string.h>
#include "tessbox.h"
#include "tessvars.h"
#include "memry.h"
#include "reject.h"
#include "control.h"
#include "stopper.h"
#include "tesseractclass.h"
#include <ctype.h>
#include <string.h>
#include "tessbox.h"
#include "tessvars.h"
#include "memry.h"
#include "reject.h"
#include "control.h"
#include "stopper.h"
#include "tesseractclass.h"

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
Expand Down
5 changes: 1 addition & 4 deletions src/ccmain/applybox.cpp
Expand Up @@ -18,11 +18,8 @@
**********************************************************************/

#include <ctype.h>
#include <string.h>
#ifdef __UNIX__
#include <assert.h>
#include <errno.h>
#endif
#include <string.h>
#include "allheaders.h"
#include "boxread.h"
#include "chopper.h"
Expand Down
3 changes: 1 addition & 2 deletions src/ccmain/control.cpp
Expand Up @@ -27,11 +27,10 @@
#include <string.h>
#include <cmath>
#ifdef __UNIX__
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#endif
#include <ctype.h>
#include <errno.h>
#include "callcpp.h"
#include "control.h"
#include "docqual.h"
Expand Down
7 changes: 3 additions & 4 deletions src/ccmain/output.cpp
Expand Up @@ -17,12 +17,11 @@
*
**********************************************************************/

#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#ifdef __UNIX__
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <unistd.h>
#endif
#include "helpers.h"
#include "tessvars.h"
Expand Down
27 changes: 12 additions & 15 deletions src/ccmain/reject.cpp
Expand Up @@ -17,21 +17,18 @@
*
**********************************************************************/

#include "tessvars.h"
#ifdef __UNIX__
#include <assert.h>
#include <errno.h>
#endif
#include "scanutils.h"
#include <ctype.h>
#include <string.h>
#include "genericvector.h"
#include "reject.h"
#include "control.h"
#include "docqual.h"
#include "globaloc.h" // For err_exit.
#include "globals.h"
#include "helpers.h"
#include "tessvars.h"
#include "scanutils.h"
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include "genericvector.h"
#include "reject.h"
#include "control.h"
#include "docqual.h"
#include "globaloc.h" // For err_exit.
#include "globals.h"
#include "helpers.h"

#include "tesseractclass.h"

Expand Down
15 changes: 6 additions & 9 deletions src/ccstruct/blread.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
* File: blread.cpp (Formerly pdread.c)
* Description: Friend function of BLOCK to read the uscan pd file.
* Author: Ray Smith
* Created: Mon Mar 18 14:39:00 GMT 1991
* Author: Ray Smith
* Created: Mon Mar 18 14:39:00 GMT 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,13 +17,10 @@
*
**********************************************************************/

#include <stdlib.h>
#ifdef __UNIX__
#include <assert.h>
#endif
#include "scanutils.h"
#include "fileerr.h"
#include "blread.h"
#include <stdlib.h>
#include "scanutils.h"
#include "fileerr.h"
#include "blread.h"

#define UNLV_EXT ".uzn" // unlv zone file

Expand Down
7 changes: 2 additions & 5 deletions src/ccstruct/coutln.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
* File: coutln.cpp (Formerly coutline.c)
* Description: Code for the C_OUTLINE class.
* Author: Ray Smith
* Created: Mon Oct 07 16:01:57 BST 1991
* Author: Ray Smith
* Created: Mon Oct 07 16:01:57 BST 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,9 +19,6 @@

#include <algorithm>
#include <string.h>
#ifdef __UNIX__
#include <assert.h>
#endif

#include "coutln.h"

Expand Down
13 changes: 6 additions & 7 deletions src/ccstruct/pageres.cpp
Expand Up @@ -21,13 +21,12 @@
** limitations under the License.
*
**********************************************************************/
#include <stdlib.h>
#ifdef __UNIX__
#include <assert.h>
#endif
#include "blamer.h"
#include "pageres.h"
#include "blobs.h"

#include <stdlib.h>
#include <cassert>
#include "blamer.h"
#include "pageres.h"
#include "blobs.h"

ELISTIZE (BLOCK_RES)
CLISTIZE (BLOCK_RES) ELISTIZE (ROW_RES) ELISTIZE (WERD_RES)
Expand Down
11 changes: 4 additions & 7 deletions src/ccstruct/polyaprx.cpp
Expand Up @@ -17,14 +17,11 @@
*
**********************************************************************/

#include <stdio.h>
#ifdef __UNIX__
#include <assert.h>
#endif
#include <stdio.h>
#define FASTEDGELENGTH 256
#include "polyaprx.h"
#include "params.h"
#include "tprintf.h"
#include "polyaprx.h"
#include "params.h"
#include "tprintf.h"

#define EXTERN

Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/ratngs.h
Expand Up @@ -20,7 +20,7 @@
#ifndef RATNGS_H
#define RATNGS_H

#include <assert.h>
#include <cassert>

#include "clst.h"
#include "elst.h"
Expand Down
3 changes: 0 additions & 3 deletions src/ccstruct/rejctmap.h
Expand Up @@ -41,9 +41,6 @@ OF THIS IMPLIED TEMPORAL ORDERING OF THE FLAGS!!!!
#ifndef REJCTMAP_H
#define REJCTMAP_H

#ifdef __UNIX__
#include <assert.h>
#endif
#include <memory>
#include "bits16.h"
#include "errcode.h"
Expand Down
4 changes: 0 additions & 4 deletions src/ccstruct/split.cpp
Expand Up @@ -36,10 +36,6 @@

#include <algorithm>

#ifdef __UNIX__
#include <assert.h>
#endif

/*----------------------------------------------------------------------
V a r i a b l e s
----------------------------------------------------------------------*/
Expand Down
6 changes: 3 additions & 3 deletions src/ccutil/strngs.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
* File: strngs.cpp (Formerly strings.c)
* Description: STRING class functions.
* Author: Ray Smith
* Created: Fri Feb 15 09:13:30 GMT 1991
* Author: Ray Smith
* Created: Fri Feb 15 09:13:30 GMT 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +19,7 @@

#include "strngs.h"

#include <assert.h>
#include <cassert>

#include "errcode.h"
#include "genericvector.h"
Expand Down
4 changes: 1 addition & 3 deletions src/classify/adaptmatch.cpp
Expand Up @@ -55,13 +55,11 @@
#include "werd.h"

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#ifdef __UNIX__
#include <assert.h>
#endif

#define ADAPT_TEMPLATE_SUFFIX ".a"

Expand Down
23 changes: 10 additions & 13 deletions src/cutil/callcpp.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
* File: callcpp.cpp
* Description: extern C interface calling C++ from C.
* Author: Ray Smith
* Created: Sun Feb 04 20:39:23 MST 1996
* Author: Ray Smith
* Created: Sun Feb 04 20:39:23 MST 1996
*
* (C) Copyright 1996, Hewlett-Packard Co.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,18 +22,15 @@
#include "config_auto.h"
#endif

#include "errcode.h"
#ifdef __UNIX__
#include <assert.h>
#include "errcode.h"
#include <stdarg.h>
#endif
#include <time.h>
#include "memry.h"
#include "scrollview.h"
#include "params.h"
#include "callcpp.h"
#include "tprintf.h"
#include "host.h"
#include <time.h>
#include "memry.h"
#include "scrollview.h"
#include "params.h"
#include "callcpp.h"
#include "tprintf.h"
#include "host.h"
#include "unichar.h"

#include <memory>
Expand Down
7 changes: 2 additions & 5 deletions src/cutil/callcpp.h
@@ -1,8 +1,8 @@
/**********************************************************************
* File: callcpp.h
* Description: extern C interface calling C++ from C.
* Author: Ray Smith
* Created: Sun Feb 04 20:39:23 MST 1996
* Author: Ray Smith
* Created: Sun Feb 04 20:39:23 MST 1996
*
* (C) Copyright 1996, Hewlett-Packard Co.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,9 +20,6 @@
#ifndef CALLCPP_H
#define CALLCPP_H

#ifndef __UNIX__
#include <assert.h>
#endif
#include "host.h"
#include "params.h"
#include "unichar.h"
Expand Down
3 changes: 0 additions & 3 deletions src/cutil/danerror.cpp
Expand Up @@ -22,9 +22,6 @@
#include "danerror.h"
#include "tprintf.h"
#include "globaloc.h"
#ifdef __UNIX__
#include "assert.h"
#endif

#include <cstdio>

Expand Down
17 changes: 7 additions & 10 deletions src/textord/fpchop.cpp
Expand Up @@ -17,16 +17,13 @@
*
**********************************************************************/

#ifdef __UNIX__
#include <assert.h>
#endif
#include "stderr.h"
#include "blobbox.h"
#include "statistc.h"
#include "drawtord.h"
#include "tovars.h"
#include "topitch.h"
#include "fpchop.h"
#include "stderr.h"
#include "blobbox.h"
#include "statistc.h"
#include "drawtord.h"
#include "tovars.h"
#include "topitch.h"
#include "fpchop.h"

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
Expand Down

0 comments on commit 112aeb9

Please sign in to comment.