pike.git/
src/
cpp.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2018-02-21
2018-02-21 16:48:06 by Henrik Grubbström (Grubba) <grubba@grubba.org>
67103432ac5f50f9c6c0fcde2c418a228cb8bed8 (
33
lines) (+
31
/-
2
)
[
Show
|
Annotate
]
Branch:
master
Preprocessor: Some more cpp() API cleanups.
2966:
/* * Preprocessor template. *
+
* NB: There are two basic cases where this function is called:
+
*
+
* * Either when switching to a new input data string
+
* (eg macro expansion or #include). The result of
+
* this is added to the current buffer.
+
*
+
* * Or parsing to the end of the line after a directive.
+
* The result of this is added to a temporary buffer.
*/ static ptrdiff_t low_cpp(struct CPP_struct *this, PCHARP data,
4252:
return pos; }
-
PIKEFUN void cpp(string data, int flags)
+
PIKEFUN void
low_
cpp(string data, int flags)
{ low_cpp(THIS, MKPCHARP_STR(data), data->len, flags, THIS->charset); }
-
+
PIKEFUN string cpp(string data, int flags)
+
{
+
struct CPP_struct *this = THIS;
+
struct string_builder save_buf = this->buf;
+
struct pike_string *save_file = this->current_file;
+
INT_TYPE save_line = this->current_line;
+
+
if (save_file) add_ref(save_file);
+
init_string_builder(&this->buf, 0);
+
+
low_cpp(this, MKPCHARP_STR(data), data->len, flags, THIS->charset);
+
+
push_string(finish_string_builder(&this->buf));
+
+
this->buf = save_buf;
+
if (this->current_file) free_string(this->current_file);
+
this->current_file = save_file;
+
this->current_line = save_line;
+
}
+
/*** Magic defines ***/ /*! @decl constant __LINE__
4966:
ref_push_string(data); /* data */ push_int(0); /* flags */
-
apply(cpp_obj, "cpp", 2);
+
apply(cpp_obj, "
low_
cpp", 2);
#ifdef PIKE_DEBUG UNSET_ONERROR(tmp);