mojoshader_preprocessor.c
changeset 748 818ae6582f24
parent 746 6b368eeaa3fc
child 754 d405cfa22392
equal deleted inserted replaced
747:0d1dbadcb387 748:818ae6582f24
   995         {
   995         {
   996             fail(ctx, "syntax error in macro parameter list");
   996             fail(ctx, "syntax error in macro parameter list");
   997             goto handle_pp_define_failed;
   997             goto handle_pp_define_failed;
   998         } // if
   998         } // if
   999 
   999 
  1000         idents = (char **) Malloc(ctx, sizeof (char *) * params);
  1000         if (params > 0)
  1001         if (idents == NULL)
  1001         {
  1002             goto handle_pp_define_failed;
  1002             idents = (char **) Malloc(ctx, sizeof (char *) * params);
       
  1003             if (idents == NULL)
       
  1004                 goto handle_pp_define_failed;
       
  1005         } // if
  1003 
  1006 
  1004         // roll all the way back, do it again.
  1007         // roll all the way back, do it again.
  1005         memcpy(state, &saved, sizeof (IncludeState));
  1008         memcpy(state, &saved, sizeof (IncludeState));
  1006         memset(idents, '\0', sizeof (char *) * params);
  1009         memset(idents, '\0', sizeof (char *) * params);
  1007         
  1010         
  1016 
  1019 
  1017             memcpy(dst, state->token, state->tokenlen);
  1020             memcpy(dst, state->token, state->tokenlen);
  1018             dst[state->tokenlen] = '\0';
  1021             dst[state->tokenlen] = '\0';
  1019             idents[i] = dst;
  1022             idents[i] = dst;
  1020 
  1023 
  1021             lexer(state);
  1024             if (i < (params-1))
  1022             assert( (state->tokenval == ((Token) ')')) || (state->tokenval == ((Token) ',')) );
  1025             {
       
  1026                 lexer(state);
       
  1027                 assert(state->tokenval == ((Token) ','));
       
  1028             } // if
  1023         } // for
  1029         } // for
  1024 
  1030 
  1025         if (i != params)
  1031         if (i != params)
  1026         {
  1032         {
  1027             assert(ctx->out_of_memory);
  1033             assert(ctx->out_of_memory);
  1028             goto handle_pp_define_failed;
  1034             goto handle_pp_define_failed;
  1029         } // if
  1035         } // if
  1030 
  1036 
       
  1037         lexer(state);
  1031         assert(state->tokenval == ((Token) ')'));
  1038         assert(state->tokenval == ((Token) ')'));
  1032         lexer(state);
  1039         lexer(state);
  1033     } // else if
  1040     } // else if
  1034 
  1041 
  1035     pushback(state);
  1042     pushback(state);
  1080 
  1087 
  1081     if (ctx->out_of_memory)
  1088     if (ctx->out_of_memory)
  1082         goto handle_pp_define_failed;
  1089         goto handle_pp_define_failed;
  1083 
  1090 
  1084     assert(done);
  1091     assert(done);
       
  1092 
  1085     if (!add_define(ctx, sym, definition, idents, params))
  1093     if (!add_define(ctx, sym, definition, idents, params))
  1086         goto handle_pp_define_failed;
  1094         goto handle_pp_define_failed;
  1087 
  1095 
  1088     return;
  1096     return;
  1089 
  1097