Skip to content

Commit 67d8e8e

Browse files
register short_file_name. needed for debugging
1 parent 52504d6 commit 67d8e8e

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

inst/include/Rcpp/macros/debug.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424

2525
// simple logging help
2626
#ifndef RCPP_DEBUG_LEVEL
27-
#define RCPP_DEBUG_LEVEL 0
27+
#define RCPP_DEBUG_LEVEL 0
2828
#endif
2929

30-
const char* short_file_name(const char* file) ;
31-
3230
#if RCPP_DEBUG_LEVEL > 0
3331
#define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , short_file_name(__FILE__), __LINE__, MSG ) ;
3432
#define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, MSG ) ;

inst/include/Rcpp/routines.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Rcpp{
3939
struct tm * gmtime_(const time_t * const) ;
4040
}
4141

42+
const char* short_file_name(const char* ) ;
4243
int* get_cache( int n ) ;
4344
SEXP stack_trace( const char *file, int line) ;
4445
SEXP get_string_elt(SEXP s, int i);
@@ -129,6 +130,11 @@ namespace Rcpp {
129130

130131
}
131132

133+
inline const char* short_file_name(const char* file) {
134+
typedef const char* (*Fun)(const char*) ;
135+
static Fun fun = GET_CALLABLE("short_file_name") ;
136+
return fun(file) ;
137+
}
132138
inline SEXP stack_trace( const char *file, int line){
133139
typedef SEXP (*Fun)(const char*, int) ;
134140
static Fun fun = GET_CALLABLE("stack_trace") ;

src/api.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,19 @@ namespace Rcpp {
169169
}
170170
}
171171

172-
// [[Rcpp::register]]
173-
const char* short_file_name(const char* file){
174-
std::string f(file) ;
175-
size_t index = f.find("/include/") ;
176-
if( index != std::string::npos ){
177-
f = f.substr( index + 9 ) ;
178-
}
179-
return f.c_str() ;
180-
}
181-
182172

183173
} // namespace Rcpp
184174

175+
// [[Rcpp::register]]
176+
const char* short_file_name(const char* file){
177+
std::string f(file) ;
178+
size_t index = f.find("/include/") ;
179+
if( index != std::string::npos ){
180+
f = f.substr( index + 9 ) ;
181+
}
182+
return f.c_str() ;
183+
}
184+
185185
// [[Rcpp::internal]]
186186
SEXP as_character_externalptr(SEXP xp){
187187
char buffer[20] ;

0 commit comments

Comments
 (0)