forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath2str.c
More file actions
29 lines (27 loc) · 661 Bytes
/
Copy pathpath2str.c
File metadata and controls
29 lines (27 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "path2str.h"
#include "sc_memmgr.h"
#include <string.h>
/* for windows, rewrite backslashes in paths
* that will be written to generated code
*/
const char * path2str_fn( const char * fileMacro ) {
static char * result = 0;
static size_t rlen = 0;
char * p;
if( rlen < strlen( fileMacro ) ) {
if( result ) {
sc_free( result );
}
rlen = strlen( fileMacro );
result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 );
}
strcpy( result, fileMacro );
p = result;
while( *p ) {
if( *p == '\\' ) {
*p = '/';
}
p++;
}
return result;
}