pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:23:   #include "version.h"   #include "pike_types.h"   #include "cpp.h"   #include "lex.h"   #include "sprintf.h"      #include <ctype.h>      #define DEFAULT_CMOD_STORAGE    - #define sp Pike_sp -  +    #define CPP_NO_OUTPUT 1 /* Inside false section of #if/#else */   #define CPP_EXPECT_ELSE 2 /* Expect #else/#elif/#elseif. */   #define CPP_EXPECT_ENDIF 4 /* Expect #endif */   #define CPP_REALLY_NO_OUTPUT 8 /* Entire preprocessor is in false section. */   #define CPP_END_AT_NEWLINE 16 /* Halt at end of line. */   #define CPP_DO_IF 32   #define CPP_NO_EXPAND 64      #define OUTP() (!(flags & (CPP_NO_OUTPUT | CPP_REALLY_NO_OUTPUT)))   #define PUTNL() string_builder_putchar(&this->buf, '\n')
pike.git/src/cpp.cmod:240:    va_list args;    va_start (args, cpp_error_fmt);    cpp_error_vsprintf (this, cpp_error_fmt, args);    va_end (args);    }       push_svalue(&thrown);    low_safe_apply_handler("compile_exception",    this->handler, this->compat_handler, 1);    -  if (SAFE_IS_ZERO(sp-1)) { +  if (SAFE_IS_ZERO(Pike_sp-1)) {    struct pike_string *s = format_exception_for_error_msg (&thrown);    if (s) {    cpp_error_sprintf(this, "%S", s);    free_string (s);    }    }       pop_stack();    free_svalue(&thrown);   }
pike.git/src/cpp.cmod:504:    minor == PIKE_MINOR_VERSION) || major < 0)    {    this->compat_major=PIKE_MAJOR_VERSION;    this->compat_minor=PIKE_MINOR_VERSION;    return; /* Our work here is done */    }       push_int(major);    push_int(minor);    SAFE_APPLY_MASTER("get_compilation_handler",2); -  if(TYPEOF(sp[-1]) == T_OBJECT) +  if(TYPEOF(Pike_sp[-1]) == T_OBJECT)    { -  if (SUBTYPEOF(sp[-1])) { +  if (SUBTYPEOF(Pike_sp[-1])) {    cpp_error(this,    "#pike: Subtyped compilation handlers are not supported yet.");    } -  this->compat_handler=sp[-1].u.object; +  this->compat_handler=Pike_sp[-1].u.object;    dmalloc_touch_svalue(Pike_sp-1); -  sp--; +  Pike_sp--;    }    this->compat_major=major;    this->compat_minor=minor;   }      /* #if macros and functions. */      /*! @namespace cpp::    *!    *! Pike has a builtin C-style preprocessor. It works similar to the
pike.git/src/cpp.cmod:915:       if (SETJMP_SP(recovery, 1)) {    if(this->picky_cpp)    cpp_warning (this, "Error indexing module with %S.", s);    res = 0;    push_undefined();    } else {    ref_push_string(s);    f_index(2);    -  res=!(UNSAFE_IS_ZERO(sp-1) && SUBTYPEOF(sp[-1]) == NUMBER_UNDEFINED); +  res=!(UNSAFE_IS_ZERO(Pike_sp-1) && SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED);    }    UNSETJMP(recovery);    return res;   }      /*! @decl int(0..1) constant(mixed identifier)    *! @decl __deprecated__ int(0..1) efun(mixed identifier)    *!    *! Check whether the argument resolves to a constant or not.    *!    *! @seealso    *! @[#if], @[defined()]    */   static void cpp_constant(struct cpp *this, int value)   { -  struct svalue *save_stack=sp; +  struct svalue *save_stack=Pike_sp;    struct array *arr;    INT_TYPE res = 0;    int n;       /* FIXME: Protection against errors. */    /* Remove extra whitespace. */    push_static_text(" ");    o_subtract();    push_static_text("\t");    o_subtract();
pike.git/src/cpp.cmod:995:    if ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&    Pike_sp[-1].u.object == placeholder_object) ||    (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&    Pike_sp[-1].u.program == placeholder_program)) {    cpp_error_sprintf (this, "Got placeholder %s (resolver problem) "    "when resolving %S.",    get_name_of_type(TYPEOF(Pike_sp[-1])),    str);    }    else -  res = !(SAFE_IS_ZERO(sp-1) && SUBTYPEOF(sp[-1]) == NUMBER_UNDEFINED); +  res = !(SAFE_IS_ZERO(Pike_sp-1) && SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED);    }    else if (TYPEOF(throw_value) == T_STRING &&    !throw_value.u.string->size_shift) {    cpp_error(this, throw_value.u.string->str);    free_svalue(&throw_value);    mark_free_svalue (&throw_value);    res = 0;    } else if(this->picky_cpp) {    cpp_warning (this, "Error resolving %S.", str);    res = 0;
pike.git/src/cpp.cmod:1022:       if (this->handler) {    ref_push_object(this->handler);    } else {    push_int(0);    }       if (safe_apply_handler("handle_import", this->handler,    this->compat_handler, 3,    BIT_MAPPING|BIT_OBJECT|BIT_PROGRAM)) -  res = !(SAFE_IS_ZERO(sp-1) && SUBTYPEOF(sp[-1]) == NUMBER_UNDEFINED); +  res = !(SAFE_IS_ZERO(Pike_sp-1) && SUBTYPEOF(Pike_sp[-1]) == NUMBER_UNDEFINED);    else {    cpp_handle_exception (this, "Error importing '.'.");    }    }       for (n = 1; res && (n < arr->size); n++) {    res = do_safe_index_call(this, arr->item[n].u.string);    }       if (value && res) { -  if (TYPEOF(sp[-1]) == T_INT) -  res = sp[-1].u.integer; +  if (TYPEOF(Pike_sp[-1]) == T_INT) +  res = Pike_sp[-1].u.integer;    else    res = 0;    }    -  pop_n_elems(1 + sp - save_stack); +  pop_n_elems(1 + Pike_sp - save_stack);    push_int(res);   }      static struct mapping *initial_predefs_mapping(void)   {    struct pike_predef_s *def;    struct mapping *map = allocate_mapping (0);   #ifdef PIKE_DEBUG    if (!use_initial_predefs) Pike_fatal ("Initial predefs has been taken over.\n");   #endif
pike.git/src/cpp.cmod:1709:    int i;    for(i=0; i<data->len; i++) {    new_str->str[i^1] = data->str[i];    }    free_string(data);    data = end_shared_string(new_str);    }    /* Note: We lose the extra reference to data here. */    push_string(data);    f_unicode_to_string(1); -  add_ref(data = sp[-1].u.string); +  add_ref(data = Pike_sp[-1].u.string);    pop_stack();    return data;    }    } else if (data->str[0] == '{') {    /* EBCDIC */    /* Notes on EBCDIC:    *    * * EBCDIC conversion needs to first convert the first line    * according to EBCDIC-US, and then the rest of the string    * according to the encoding specified by the first line.
pike.git/src/cpp.cmod:1760:       memcpy(new_str->str, data->str, len);       push_string(end_shared_string(new_str));       push_static_text("ebcdic-us");       if (safe_apply_handler ("decode_charset", this->handler, this->compat_handler,    2, BIT_STRING)) {    /* Various consistency checks. */ -  if ((sp[-1].u.string->size_shift) || -  (((size_t)sp[-1].u.string->len) < CONSTANT_STRLEN("#charset")) || -  (sp[-1].u.string->str[0] != '#')) { +  if ((Pike_sp[-1].u.string->size_shift) || +  (((size_t)Pike_sp[-1].u.string->len) < CONSTANT_STRLEN("#charset")) || +  (Pike_sp[-1].u.string->str[0] != '#')) {    pop_stack();    return data;    }    }    else {    cpp_handle_exception (this, "Error decoding with charset 'ebcdic-us'");    return data;    }       /* At this point the decoded first line is on the stack. */       /* Extract the charset name */    -  p = sp[-1].u.string->str + 1; +  p = Pike_sp[-1].u.string->str + 1;    while (*p && isspace(*((unsigned char *)p))) {    p++;    }       if (strncmp(p, "charset", CONSTANT_STRLEN("charset")) ||    !isspace(((unsigned char *)p)[CONSTANT_STRLEN("charset")])) {    pop_stack();    return data;    }   
pike.git/src/cpp.cmod:1840:    2, BIT_STRING)) {    cpp_handle_exception (this, "Error decoding with charset %S", new_str);    free_string (new_str);    return data;    }    free_string (new_str);       /* Accept the new string */       free_string(data); -  add_ref(data = sp[-1].u.string); +  add_ref(data = Pike_sp[-1].u.string);    pop_stack();    }    return data;   }      static struct pike_string *filter_bom(struct pike_string *data)   {    /* More notes:    *    * * Character 0xfeff (ZERO WIDTH NO-BREAK SPACE = BYTE ORDER MARK = BOM)
pike.git/src/cpp.cmod:3150:      static void insert_callback_define(struct cpp *this,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp)   {    ref_push_string( def->name );    ref_push_string( arg );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 2, 0 ) && -  TYPEOF(sp[-1]) == T_STRING ) { -  string_builder_shared_strcat(tmp, sp[-1].u.string); +  TYPEOF(Pike_sp[-1]) == T_STRING ) { +  string_builder_shared_strcat(tmp, Pike_sp[-1].u.string);    if( !this->prefix ){    int min; -  check_string_range( sp[-1].u.string, 0, &min, 0 ); +  check_string_range( Pike_sp[-1].u.string, 0, &min, 0 );    if( min < 32 )    {    string_builder_sprintf(tmp, "\n#line %ld ", (long)this->current_line);    insert_current_file_as_string( this,def,arg,tmp);    string_builder_putchar(tmp, '\n');    }    }    pop_stack();    }   }      static void insert_callback_define_no_args(struct cpp *this,    struct define_struct *def,    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    struct svalue *save_sp = Pike_sp;    ref_push_string( def->name );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 1, 0 ) && -  TYPEOF(sp[-1]) == T_STRING ) -  string_builder_shared_strcat(tmp, sp[-1].u.string); +  TYPEOF(Pike_sp[-1]) == T_STRING ) +  string_builder_shared_strcat(tmp, Pike_sp[-1].u.string);    if (Pike_sp > save_sp) pop_n_elems(Pike_sp-save_sp);   }         /*! @decl constant __REAL_VERSION__    *!    *! This define always contains the version of the current Pike,    *! represented as a float.    *!    *! @seealso
pike.git/src/cpp.cmod:3355:   PIKEFUN string cpp(string data,    mapping|string|void opts_or_file,    int|string|void charset_sv,    object|void handler,    int|void compat_major_sv,    int|void compat_minor_sv,    int|void picky_cpp_sv)    efun;   {    struct cpp this; -  struct svalue *save_sp = sp - args; +  struct svalue *save_sp = Pike_sp - args;    struct mapping *predefs = NULL;       struct pike_string *prefix = NULL;       struct pike_string *current_file = 0;       int auto_convert = 0;    struct pike_string *charset = NULL;       int compat_major = compat_major_sv?compat_major_sv->u.integer:0;
pike.git/src/cpp.cmod:3450:    charset = charset_sv->u.string;    push_string(data);    this.data = data = NULL;    ref_push_string(charset);    if (!safe_apply_handler ("decode_charset", this.handler,    this.compat_handler, 2, BIT_STRING)) {    cpp_handle_exception (&this, "Error decoding with charset %S",    charset);    Pike_error("Unknown charset.\n");    } -  this.data = data = sp[-1].u.string; -  sp--; -  dmalloc_touch_svalue(sp); +  this.data = data = Pike_sp[-1].u.string; +  Pike_sp--; +  dmalloc_touch_svalue(Pike_sp);    }    else if(TYPEOF(*charset_sv) == T_INT)    auto_convert = charset_sv->u.integer;    else {    SIMPLE_ARG_TYPE_ERROR("cpp", 3, "string|int");    }    }       if(compat_major)    cpp_change_compat(&this, compat_major, compat_minor);       this.picky_cpp = picky_cpp;       if (use_initial_predefs)    /* Typically compiling the master here. */    predefs = initial_predefs_mapping();    else {    low_unsafe_apply_handler ("get_predefines", this.handler,    this.compat_handler, 0); -  if (!UNSAFE_IS_ZERO (sp - 1)) { +  if (!UNSAFE_IS_ZERO (Pike_sp - 1)) {    struct keypair *k;    int e, sprintf_args = 0; -  if (TYPEOF(sp[-1]) != T_MAPPING) { +  if (TYPEOF(Pike_sp[-1]) != T_MAPPING) {    push_static_text ("Invalid return value from get_predefines, got %O\n"); -  push_svalue (sp - 3); +  push_svalue (Pike_sp - 3);    sprintf_args = 2;    }    else { -  predefs = copy_mapping (sp[-1].u.mapping); +  predefs = copy_mapping (Pike_sp[-1].u.mapping);    NEW_MAPPING_LOOP (predefs->data) {    if (TYPEOF(k->ind) != T_STRING || !k->ind.u.string->len) {    push_static_text ("Expected nonempty string as predefine name, got %O\n");    push_svalue (&k->ind);    sprintf_args = 2;    free_mapping (predefs);    predefs = NULL;    goto predef_map_error;    } else if (!(TYPEOF(k->val) == T_INT && !k->val.u.integer)    && TYPEOF(k->val) != T_STRING
pike.git/src/cpp.cmod:3508:    sprintf_args = 2;    free_mapping (predefs);    predefs = NULL;    goto predef_map_error;    }    }    }    if (!predefs) {    predef_map_error:    f_sprintf (sprintf_args); -  Pike_error("%S", sp[-1].u.string); +  Pike_error("%S", Pike_sp[-1].u.string);    }    }    pop_stack();    }       if (auto_convert && (!data->size_shift) && (data->len > 1)) {    /* Try to determine if we need to recode the string */    struct pike_string *new_data = recode_string(&this, data);    free_string(data);    this.data = data = new_data;
pike.git/src/cpp.cmod:3655:       if(this.compile_errors)    {    free_string_builder(&this.buf);    throw_error_object(fast_clone_object(cpp_error_program), 0, 0, 0,    "Cpp() failed\n");    }    else if(this.dependencies_fail)    {    free_string_builder(&this.buf); -  pop_n_elems(sp - save_sp); +  pop_n_elems(Pike_sp - save_sp);    push_int(0);    }    else    { -  pop_n_elems(sp - save_sp); +  pop_n_elems(Pike_sp - save_sp);    push_string(finish_string_builder(&this.buf));    }   }      /*! @module Builtin    */      /*! @decl mapping(string:mixed) _take_over_initial_predefines()    */   void f__take_over_initial_predefines (INT32 args)