• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*-C-*-
2  ********************************************************************************
3  *
4  * File:         helpers.h
5  * Description:  General utility functions
6  * Author:       Daria Antonova
7  * Created:      Wed Apr 8 14:37:00 2009
8  * Language:     C
9  * Package:      N/A
10  * Status:       Reusable Software Component
11  *
12  * (c) Copyright 2009, Google Inc.
13  ** Licensed under the Apache License, Version 2.0 (the "License");
14  ** you may not use this file except in compliance with the License.
15  ** You may obtain a copy of the License at
16  ** http://www.apache.org/licenses/LICENSE-2.0
17  ** Unless required by applicable law or agreed to in writing, software
18  ** distributed under the License is distributed on an "AS IS" BASIS,
19  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  ** See the License for the specific language governing permissions and
21  ** limitations under the License.
22  *
23  ********************************************************************************/
24 
25 #ifndef TESSERACT_CCUTIL_HELPERS_H_
26 #define TESSERACT_CCUTIL_HELPERS_H_
27 
28 // Remove newline (if any) at the end of the string.
chomp_string(char * string)29 inline void chomp_string(char *string) {
30   int last_index = strlen(string) - 1;
31   if (string[last_index] == '\n') {
32     string[last_index] = '\0';
33   }
34 }
35 
36 // Advance the current pointer of the file if it points to a newline character.
SkipNewline(FILE * file)37 inline void SkipNewline(FILE *file) {
38   if (fgetc(file) != '\n') fseek(file, -1, SEEK_CUR);
39 }
40 
41 #endif
42