[go: up one dir, main page]

Menu

[97a570]: / src / utils.cc  Maximize  Restore  History

Download this file

37 lines (33 with data), 833 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
30
31
32
33
34
35
#include <stdio.h>
#include <ctype.h>
#include <string>
#include "utils.h"
//////////////////////////////////////////////////////////////////////////
//
void print_with_escapes( FILE* f, const string& str)
//
// Prints a string into a file (or std[out|err]) while
// replacing " " by "\ "
//
//////////////////////////////////////////////////////////////////////////
{
const char *s = str.c_str();
while ( *s ) {
if ( isspace( *s ) ) {
fputc( '\\', f);
}
fputc( *s, f);
s++;
}
}
//////////////////////////////////////////////////////////////////////////
//
char* nccs( const string& s)
//
// C-Client doesn't declare anything const
// If you're paranoid, you can allocate a new char[] here
//
//////////////////////////////////////////////////////////////////////////
{
return (char*) s.c_str();
}