]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Merge branch 'master' into cooking
authorWolfgang Bumiller <blub@speed.at>
Tue, 12 Feb 2013 13:31:27 +0000 (14:31 +0100)
committerWolfgang Bumiller <blub@speed.at>
Tue, 12 Feb 2013 13:31:27 +0000 (14:31 +0100)
1  2 
ftepp.c

diff --combined ftepp.c
index 8889068c5fedd26107bc9600800ee93398696158,2ce9f4734fc7abd50357f5ad01bb59e040ab8988..68491ed6dd2af72e1c8e69035b6e48bce5384a35
+++ b/ftepp.c
@@@ -124,6 -124,7 +124,6 @@@ char *ftepp_predef_line(lex_file *conte
  char *ftepp_predef_file(lex_file *context) {
      size_t  length = strlen(context->name) + 3; /* two quotes and a terminator */
      char   *value  = (char*)mem_a(length);
 -    memset (value, 0, length);
      sprintf(value, "\"%s\"", context->name);
  
      return value;
@@@ -450,12 -451,8 +450,12 @@@ static bool ftepp_define_body(ftepp_t *
                  ftepp->token = old;
              }
          }
 -        else
 -        {
 +        else if (macro->variadic && !strcmp(ftepp_tokval(ftepp), "__VA_COUNT__")) {
 +            ftepp->token = TOKEN_VA_COUNT;
 +            ptok         = pptoken_make(ftepp);
 +            vec_push(macro->output, ptok);
 +            ftepp_next(ftepp);
 +        } else {
              ptok = pptoken_make(ftepp);
              vec_push(macro->output, ptok);
              ftepp_next(ftepp);
@@@ -684,7 -681,6 +684,7 @@@ static void ftepp_param_out(ftepp_t *ft
  static bool ftepp_preprocess(ftepp_t *ftepp);
  static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params, bool resetline)
  {
 +    char     *buffer       = NULL;
      char     *old_string   = ftepp->output_string;
      char     *inner_string;
      lex_file *old_lexer    = ftepp->lex;
                  ftepp_param_out(ftepp, &params[out->constval.i + vararg_start]);
                  break;
  
 +            case TOKEN_VA_COUNT:
 +                util_asprintf(&buffer, "%d", varargs);
 +                ftepp_out(ftepp, buffer, false);
 +                mem_d(buffer);
 +                break;
 +
              case TOKEN_IDENT:
              case TOKEN_TYPENAME:
              case TOKEN_KEYWORD:
@@@ -1260,9 -1250,9 +1260,9 @@@ static char *ftepp_include_find_path(co
      memcpy(vec_add(filename, len+1), file, len);
      vec_last(filename) = 0;
  
 -    fp = file_open(filename, "rb");
 +    fp = fs_file_open(filename, "rb");
      if (fp) {
 -        file_close(fp);
 +        fs_file_close(fp);
          return filename;
      }
      vec_free(filename);
@@@ -1389,6 -1379,11 +1389,11 @@@ static bool ftepp_include(ftepp_t *ftep
          return false;
      }
  
+     if (!ftepp->output_on) {
+         ftepp_next(ftepp);
+         return true;
+     }
      ctx = ftepp_ctx(ftepp);
  
      unescape(ftepp_tokval(ftepp), ftepp_tokval(ftepp));