Skip to content

Commit

Permalink
Use C++ versions of C headers. work-around bug in older GNU sscanf de…
Browse files Browse the repository at this point in the history
…finition
  • Loading branch information
diyessi committed Sep 28, 2015
1 parent 914932f commit 9b44e1f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
14 changes: 7 additions & 7 deletions DataReader/KaldiReader/basetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ OACR_WARNING_DISABLE(POTENTIAL_ARGUMENT_TYPE_MISMATCH, "Not level1 or level2_sec
#endif

#include "Platform.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // include here because we redefine some names later
#include <errno.h>
#include <cstdio>
#include <cstdlib>
#include <cstring> // include here because we redefine some names later
#include <cerrno>
#include <string>
#include <vector>
#include <math.h> // for HUGE_VAL // potential double isnan definition
#include <assert.h>
#include <stdarg.h>
#include <cmath> // for HUGE_VAL // potential double isnan definition
#include <cassert>
#include <cstdarg>
#include <map>
#include <stdexcept>
#include <locale> // std::wstring_convert
Expand Down
10 changes: 5 additions & 5 deletions DataReader/KaldiReader/fileutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define _FILEUTIL_

#include "Platform.h"
#include <stdio.h>
#include <cstdio>
#ifdef __unix__
#include <sys/types.h>
#include <sys/stat.h>
Expand All @@ -18,10 +18,10 @@
#include <map>
#include <functional>
#include <cctype>
#include <errno.h>
#include <stdint.h>
#include <assert.h>
#include <string.h> // for strerror()
#include <cerrno>
#include <cstdint>
#include <cassert>
#include <cstring> // for strerror()

using namespace std;

Expand Down
6 changes: 3 additions & 3 deletions DataReader/KaldiReader/htkfeatio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <regex>
#include <set>
#include <unordered_map>
#include <stdint.h>
#include <limits.h>
#include <wchar.h>
#include <cstdint>
#include <climits>
#include <cwchar>
#include <fstream>
#include "util/common-utils.h"
#include "base/kaldi-common.h"
Expand Down
7 changes: 4 additions & 3 deletions DataReader/KaldiReader/latticearchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "latticestorage.h"
#include "simple_checked_arrays.h"
#include "fileutil.h"
#include <stdint.h>
#include <inttypes.h>
#include <cstdint>
#include <cinttypes>
#include <vector>
#include <string>
#include <algorithm> // for find()
Expand Down Expand Up @@ -1132,7 +1132,8 @@ class archive
throw std::runtime_error ("open: invalid TOC line (empty archive pathname): " + std::string (line));
char c;
uint64_t offset;
if (sscanf(q, "[%" PRId64 "]%c", &offset, &c) != 1)
const char *scanformat = "[%" PRId64 "]%c"; // Work-around for GNU/Linux bug in sscanf in older libc (2.15) versions
if (sscanf(q, scanformat, &offset, &c) != 1)
throw std::runtime_error ("open: invalid TOC line (bad [] expression): " + std::string (line));
if (!toc.insert (make_pair (key, latticeref (offset, archiveindex))).second)
throw std::runtime_error ("open: TOC entry leads to duplicate key: " + std::string (line));
Expand Down
2 changes: 1 addition & 1 deletion DataReader/KaldiReader/latticestorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma once
#include <string> // for the error message in checkoverflow() only
#include <stdexcept>
#include <stdint.h>
#include <cstdint>

#undef INITIAL_STRANGE // [v-hansu] intialize structs to strange values
#define PARALLEL_SIL // [v-hansu] process sil on CUDA, used in other files, please search this
Expand Down
2 changes: 1 addition & 1 deletion DataReader/KaldiReader/minibatchsourcehelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include "basetypes.h"
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <algorithm>

Expand Down
4 changes: 2 additions & 2 deletions DataReader/KaldiReader/simple_checked_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#pragma once

#include <stddef.h> // for size_t
#include <assert.h>
#include <cstddef> // for size_t
#include <cassert>

// ---------------------------------------------------------------------------
// array_ref -- wraps a C pointer to an array together with its size.
Expand Down

0 comments on commit 9b44e1f

Please sign in to comment.