Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# readxl (development version)

<<<<<<< reorder-header-includes
* readxl should once again compile on Alpine Linux. (#775)
=======
* `read_excel()` and friends should no longer emit a spurious "Access is denied" warning when reading a file on a network drive and the user doesn't have access to a parent directory (#730).
>>>>>>> main

# readxl 1.4.5

Expand Down
9 changes: 9 additions & 0 deletions maintenance/02_apply-our-libxls-patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@
# git diff ':!maintenance/02_apply-our-libxls-patches.txt' > maintenance/patches/snprintf.patch
# discard changes
# git apply maintenance/patches/snprintf.patch

# Implement the include of <stdint.h> in the global namespace at the top of
# src/libxls/xls.h, before the `namespace xls { extern "C" {` block opens, so
# that stdint typedefs (int64_t etc.) aren't trapped in xls:: when libxls is
# consumed from C++ on a libc (e.g. musl/Alpine) that hasn't transitively
# pre-loaded <stdint.h>. (#775)
# git diff ':!maintenance/02_apply-our-libxls-patches.txt' > maintenance/patches/stdint.patch
# discard changes
# git apply maintenance/patches/stdint.patch
20 changes: 20 additions & 0 deletions maintenance/patches/stdint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/libxls/xls.h b/src/libxls/xls.h
index 89b8b92..59da631 100644
--- a/src/libxls/xls.h
+++ b/src/libxls/xls.h
@@ -33,7 +33,14 @@

#ifndef XLS_INCLUDE
#define XLS_INCLUDE
-
+
+/* readxl modification: process <stdint.h> in the global namespace, not inside
+ * namespace xls. Otherwise, on libcs (e.g. musl/Alpine) where <stdint.h> has
+ * not been transitively pre-loaded by other system or vendored headers, its
+ * typedefs (int64_t etc.) end up trapped in xls:: when libxls is consumed
+ * from C++ code. See readxl issue #775. */
+#include <stdint.h>
+
#ifdef __cplusplus
namespace xls {
extern "C" {
6 changes: 4 additions & 2 deletions src/CellLimits.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#include "XlsCell.h"
#include "cpp11/integers.hpp"
#include <vector>

#include "cpp11/integers.hpp"

#include "XlsCell.h"

class CellLimits {
int minRow_, maxRow_, minCol_, maxCol_;

Expand Down
10 changes: 5 additions & 5 deletions src/ColSpec.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once

#include "utils.h"
#include "StringSet.h"

#include "libxls/xls.h"

#include "cpp11/doubles.hpp"
#include "cpp11/list.hpp"
#include "cpp11/logicals.hpp"
#include "cpp11/protect.hpp"
#include "cpp11/sexp.hpp"
#include "cpp11/strings.hpp"

#include "libxls/xls.h"

#include "StringSet.h"
#include "utils.h"

enum CellType {
CELL_UNKNOWN,
CELL_BLANK,
Expand Down
7 changes: 3 additions & 4 deletions src/Read.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include "SheetView.h"

#include "ColSpec.h"
#include <string>

#include "cpp11/as.hpp"
#include "cpp11/list.hpp"
#include "cpp11/R.hpp"
#include "cpp11/strings.hpp"

#include <string>
#include "ColSpec.h"
#include "SheetView.h"

template <typename T>
cpp11::list read_this_(
Expand Down
25 changes: 12 additions & 13 deletions src/SheetView.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#include <sys/time.h> // alpine linux / musl must be before others
#include <unistd.h> // alpine linux / musl must be before others
#include <algorithm>
#include <string>
#include <sys/time.h>
#include <unistd.h>
#include <vector>

#include "cpp11/R.hpp"
#include "cpp11/strings.hpp"

#include "CellLimits.h"
#include "ColSpec.h"
#include "XlsWorkBook.h"
#include "XlsxWorkBook.h"
#include "XlsCellSet.h"
#include "XlsxCellSet.h"
#include "XlsCell.h"
#include "XlsCellSet.h"
#include "XlsWorkBook.h"
#include "XlsxCell.h"

#include "cpp11/R.hpp"
#include "cpp11/strings.hpp"

#include <algorithm>
#include <string>
#include <vector>
#include "XlsxCellSet.h"
#include "XlsxWorkBook.h"

class Xls {
public:
Expand Down
8 changes: 4 additions & 4 deletions src/StringSet.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "utils.h"

#include "cpp11/strings.hpp"

#include <cstring>
#include <set>
#include <vector>

#include "cpp11/strings.hpp"

#include "utils.h"

class StringSet
{
std::set<std::string> set_;
Expand Down
12 changes: 8 additions & 4 deletions src/XlsCell.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#pragma once

#include "ColSpec.h"
#include "utils.h"
#include <cstdint>
#include <iomanip>
#include <limits.h>

#include "cpp11/protect.hpp"
#include "cpp11/sexp.hpp"

#include "libxls/xls.h"
#include "libxls/xlsstruct.h"
#include "libxls/xlstypes.h"

#include <iomanip>
#include <limits.h>
#include "ColSpec.h"
#include "utils.h"

// Key reference for understanding the structure of the xls format is
// [MS-XLS]: Excel Binary File Format (.xls) Structure
Expand Down
16 changes: 8 additions & 8 deletions src/XlsCellSet.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#pragma once

#include "CellLimits.h"
#include "Spinner.h"
#include "XlsCell.h"
#include "XlsWorkBook.h"

#include "libxls/xls.h"
#include "libxls/xlsstruct.h"

#include "cpp11/as.hpp"
#include "cpp11/integers.hpp"
#include "cpp11/list.hpp"
Expand All @@ -16,6 +8,14 @@
#include "cpp11/sexp.hpp"
#include "cpp11/strings.hpp"

#include "libxls/xls.h"
#include "libxls/xlsstruct.h"

#include "CellLimits.h"
#include "Spinner.h"
#include "XlsCell.h"
#include "XlsWorkBook.h"

class XlsCellSet {
// xls specifics
xls::xlsWorkBook* pWB_;
Expand Down
8 changes: 4 additions & 4 deletions src/XlsWorkBook.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "ColSpec.h"
#include "cpp11/R.hpp"
#include "cpp11/r_string.hpp"
#include "cpp11/strings.hpp"

#include "libxls/xls.h"
#include "libxls/xlsstruct.h"

#include "cpp11/R.hpp"
#include "cpp11/r_string.hpp"
#include "cpp11/strings.hpp"
#include "ColSpec.h"

class XlsWorkBook {

Expand Down
4 changes: 2 additions & 2 deletions src/XlsxCell.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "rapidxml/rapidxml.h"

#include "ColSpec.h"
#include "XlsxString.h"
#include "utils.h"

#include "rapidxml/rapidxml.h"

// Key reference for understanding the structure of the XML is
// ECMA-376 (http://www.ecma-international.org/publications/standards/Ecma-376.htm)
// Section and page numbers below refer to the 5th edition October 2016
Expand Down
16 changes: 8 additions & 8 deletions src/XlsxCellSet.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#pragma once

#include "CellLimits.h"
#include "ColSpec.h"
#include "Spinner.h"
#include "XlsxCell.h"
#include "XlsxWorkBook.h"

#include "rapidxml/rapidxml.h"

#include "cpp11/integers.hpp"
#include "cpp11/list.hpp"
#include "cpp11/protect.hpp"
#include "cpp11/sexp.hpp"
#include "cpp11/strings.hpp"

#include "rapidxml/rapidxml.h"

#include "CellLimits.h"
#include "ColSpec.h"
#include "Spinner.h"
#include "XlsxCell.h"
#include "XlsxWorkBook.h"

// Page and section numbers below refer to
// ECMA-376 (version, date, and download URL given in XlsxCell.h)
// 18.3.1.73 row (Row) [p1685]
Expand Down
7 changes: 4 additions & 3 deletions src/XlsxString.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include "rapidxml/rapidxml.h"

// R_ext/GraphicsEngine.h must be included before R_ext/GraphicsDevice.h
#include <R_ext/GraphicsEngine.h>
#include <R_ext/GraphicsDevice.h> // Rf_ucstoutf8 is exported in R_ext/GraphicsDevice.h
#include <R_ext/GraphicsDevice.h> // Rf_ucstoutf8 is exported here

#include "rapidxml/rapidxml.h"


// unescape an ST_Xstring. See 22.9.2.19 [p3786]
Expand Down
14 changes: 7 additions & 7 deletions src/XlsxWorkBook.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include "ColSpec.h"
#include "utils.h"
#include "XlsxString.h"
#include "zip.h"

#include "rapidxml/rapidxml.h"
#include <map>

#include "cpp11/protect.hpp"
#include "cpp11/strings.hpp"

#include <map>
#include "rapidxml/rapidxml.h"

#include "ColSpec.h"
#include "utils.h"
#include "XlsxString.h"
#include "zip.h"

class XlsxWorkBook {

Expand Down
9 changes: 8 additions & 1 deletion src/libxls/xls.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@

#ifndef XLS_INCLUDE
#define XLS_INCLUDE


/* readxl modification: process <stdint.h> in the global namespace, not inside
* namespace xls. Otherwise, on libcs (e.g. musl/Alpine) where <stdint.h> has
* not been transitively pre-loaded by other system or vendored headers, its
* typedefs (int64_t etc.) end up trapped in xls:: when libxls is consumed
* from C++ code. See readxl issue #775. */
#include <stdint.h>

#ifdef __cplusplus
namespace xls {
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "cpp11/protect.hpp"

#include <cerrno>
#include <cmath>
#include <cstring>
#include <sstream>

#include "cpp11/protect.hpp"

//May appear in cpp11
template <typename T, typename N>
T new_vector(R_xlen_t size, N val) {
Expand Down
4 changes: 2 additions & 2 deletions src/zip.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "zip.h"

#include "rapidxml/rapidxml_print.h"

#include "cpp11/as.hpp"
#include "cpp11/function.hpp"
#include "cpp11/raws.hpp"
#include "cpp11/sexp.hpp"

#include "rapidxml/rapidxml_print.h"

std::string zip_buffer(const std::string& zip_path,
const std::string& file_path) {
cpp11::function zip_buffer = cpp11::package("readxl")["zip_buffer"];
Expand Down
3 changes: 2 additions & 1 deletion src/zip.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include "rapidxml/rapidxml.h"
#include <string>

#include "rapidxml/rapidxml.h"

std::string zip_buffer(const std::string& zip_path, const std::string& file_path);
bool zip_has_file(const std::string& zip_path, const std::string& file_path);
Loading